Audacity 3.2.0
RulerPanel.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 RulerPanel.h
6
7 Dominic Mazzoni
8
9 Michael Papadopoulos split from Ruler.h
10
11**********************************************************************/
12
13#ifndef __AUDACITY_RULER_PANEL__
14#define __AUDACITY_RULER_PANEL__
15
16#include "Ruler.h"
17#include "wxPanelWrapper.h" // to inherit
18
19class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
20 DECLARE_DYNAMIC_CLASS(RulerPanel)
21
22 public:
23 using Range = std::pair<double, double>;
24
25 struct Options {
26 bool log { false };
27 bool flip { false };
28 bool labelEdges { false };
29 bool ticksAtExtremes { false };
30 bool hasTickColour{ false };
31 wxColour tickColour;
32
34
35 Options &Log( bool l )
36 { log = l; return *this; }
37
38 Options &Flip( bool f )
39 { flip = f; return *this; }
40
42 { labelEdges = l; return *this; }
43
45 { ticksAtExtremes = t; return *this; }
46
47 Options &TickColour( const wxColour c )
48 { tickColour = c; hasTickColour = true; return *this; }
49 };
50
51 RulerPanel(wxWindow* parent, wxWindowID id,
52 wxOrientation orientation,
53 const wxSize &bounds,
54 const Range &range,
55 const RulerFormat &format,
56 const TranslatableString &units,
57 const Options &options = {},
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize);
60
62
63 void DoSetSize(int x, int y,
64 int width, int height,
65 int sizeFlags = wxSIZE_AUTO) override;
66
67 void OnErase(wxEraseEvent &evt);
68 void OnPaint(wxPaintEvent &evt);
69 void OnSize(wxSizeEvent &evt);
70 void SetTickColour( wxColour & c){ ruler.SetTickColour( c );}
71
72 // We don't need or want to accept focus.
73 bool AcceptsFocus() const override { return false; }
74 // So that wxPanel is not included in Tab traversal - see wxWidgets bug 15581
75 bool AcceptsFocusFromKeyboard() const override { return false; }
76
77 public:
78
80
81private:
82 DECLARE_EVENT_TABLE()
83};
84
85#endif //define __AUDACITY_RULER_PANEL__
static void OnSize(wxSizeEvent &evt)
Definition: VSTEditor.cpp:224
Used to display a Ruler.
Definition: Ruler.h:34
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:135
RulerPanel class allows you to work with a Ruler like any other wxWindow.
Definition: RulerPanel.h:19
Ruler ruler
Definition: RulerPanel.h:79
void SetTickColour(wxColour &c)
Definition: RulerPanel.h:70
bool AcceptsFocusFromKeyboard() const override
Definition: RulerPanel.h:75
std::pair< double, double > Range
Definition: RulerPanel.h:23
bool AcceptsFocus() const override
Definition: RulerPanel.h:73
Holds a msgid for the translation catalog; may also bind format arguments.
Options & TickColour(const wxColour c)
Definition: RulerPanel.h:47
Options & TicksAtExtremes(bool t)
Definition: RulerPanel.h:44
wxColour tickColour
Definition: RulerPanel.h:31
Options & LabelEdges(bool l)
Definition: RulerPanel.h:41
Options & Flip(bool f)
Definition: RulerPanel.h:38
Options & Log(bool l)
Definition: RulerPanel.h:35