]>
Commit | Line | Data |
---|---|---|
c08a4f00 RR |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/toolbar.h | |
3 | // Purpose: wxToolBar declaration | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 10.09.00 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Robert Roebling | |
9 | // Licence: wxWindows license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_UNIV_TOOLBAR_H_ | |
13 | #define _WX_UNIV_TOOLBAR_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "univtoolbar.h" | |
17 | #endif | |
18 | ||
3216dbf5 VZ |
19 | #include "wx/button.h" // for wxStdButtonInputHandler |
20 | ||
21 | class WXDLLEXPORT wxToolBarTool; | |
c08a4f00 RR |
22 | |
23 | // ---------------------------------------------------------------------------- | |
3216dbf5 | 24 | // the actions supported by this control |
c08a4f00 RR |
25 | // ---------------------------------------------------------------------------- |
26 | ||
3216dbf5 VZ |
27 | #define wxACTION_TOOLBAR_TOGGLE wxACTION_BUTTON_TOGGLE |
28 | #define wxACTION_TOOLBAR_PRESS wxACTION_BUTTON_PRESS | |
29 | #define wxACTION_TOOLBAR_RELEASE wxACTION_BUTTON_RELEASE | |
30 | #define wxACTION_TOOLBAR_CLICK wxACTION_BUTTON_CLICK | |
31 | #define wxACTION_TOOLBAR_ENTER _T("enter") // highlight the tool | |
32 | #define wxACTION_TOOLBAR_LEAVE _T("leave") // unhighlight the tool | |
c08a4f00 | 33 | |
3216dbf5 VZ |
34 | // ---------------------------------------------------------------------------- |
35 | // wxToolBar | |
36 | // ---------------------------------------------------------------------------- | |
c08a4f00 | 37 | |
3216dbf5 | 38 | class WXDLLEXPORT wxToolBar : public wxToolBarBase |
c08a4f00 RR |
39 | { |
40 | public: | |
41 | // construction/destruction | |
42 | wxToolBar() { Init(); } | |
3216dbf5 VZ |
43 | wxToolBar(wxWindow *parent, |
44 | wxWindowID id, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | long style = 0, | |
48 | const wxString& name = wxToolBarNameStr) | |
c08a4f00 RR |
49 | { |
50 | Init(); | |
51 | ||
52 | Create(parent, id, pos, size, style, name); | |
53 | } | |
54 | ||
55 | bool Create( wxWindow *parent, | |
56 | wxWindowID id, | |
57 | const wxPoint& pos = wxDefaultPosition, | |
58 | const wxSize& size = wxDefaultSize, | |
59 | long style = 0, | |
60 | const wxString& name = wxToolBarNameStr ); | |
61 | ||
3216dbf5 | 62 | virtual ~wxToolBar(); |
c08a4f00 RR |
63 | |
64 | virtual bool Realize(); | |
65 | ||
66 | virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; | |
67 | ||
68 | virtual void SetToolShortHelp(int id, const wxString& helpString); | |
69 | ||
70 | protected: | |
71 | // common part of all ctors | |
72 | void Init(); | |
73 | ||
74 | // implement base class pure virtuals | |
75 | virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); | |
76 | virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); | |
77 | ||
78 | virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); | |
79 | virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); | |
80 | virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); | |
81 | ||
82 | virtual wxToolBarToolBase *CreateTool(int id, | |
83 | const wxBitmap& bitmap1, | |
84 | const wxBitmap& bitmap2, | |
85 | bool toggle, | |
86 | wxObject *clientData, | |
87 | const wxString& shortHelpString, | |
88 | const wxString& longHelpString); | |
89 | virtual wxToolBarToolBase *CreateTool(wxControl *control); | |
16c9a425 | 90 | |
3216dbf5 VZ |
91 | // implement wxUniversal methods |
92 | virtual bool PerformAction(const wxControlAction& action, | |
93 | long numArg = -1, | |
94 | const wxString& strArg = wxEmptyString); | |
95 | virtual wxSize DoGetBestClientSize() const; | |
96 | virtual void DoDraw(wxControlRenderer *renderer); | |
97 | ||
98 | // get the bounding rect for the given tool | |
99 | wxRect GetToolRect(wxToolBarToolBase *tool) const; | |
100 | ||
101 | // redraw the given tool | |
102 | void RefreshTool(wxToolBarToolBase *tool); | |
103 | ||
104 | // (re)calculate the tool positions, should only be called if it is | |
105 | // necessary to do it, i.e. m_needsLayout == TRUE | |
106 | void DoLayout(); | |
c08a4f00 | 107 | |
3216dbf5 VZ |
108 | // get the rect limits depending on the orientation: top/bottom for a |
109 | // vertical toolbar, left/right for a horizontal one | |
110 | void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const; | |
111 | ||
112 | // wxButton actions: all these use m_toolPressed and can only be called if | |
113 | // we have one | |
114 | void Toggle(); | |
115 | void Press(); | |
116 | void Release(); | |
117 | ||
118 | // this one used m_toolCurrent | |
119 | void Click(); | |
c08a4f00 RR |
120 | |
121 | private: | |
3216dbf5 VZ |
122 | // have we calculated the positions of our tools? |
123 | bool m_needsLayout; | |
124 | ||
125 | // the width of a separator | |
126 | wxCoord m_widthSeparator; | |
127 | ||
128 | // the total size of all toolbar elements | |
129 | wxCoord m_maxWidth, | |
130 | m_maxHeight; | |
131 | ||
5a73d082 | 132 | // the tool over which the mouse currently is or NULL |
3216dbf5 VZ |
133 | wxToolBarToolBase *m_toolCurrent; |
134 | ||
5a73d082 VZ |
135 | // the tool which currently has the mouse capture (i.e. the one user is |
136 | // pressing) or NULL | |
137 | wxToolBarTool *m_toolPressed; | |
3216dbf5 VZ |
138 | |
139 | DECLARE_DYNAMIC_CLASS(wxToolBar) | |
140 | }; | |
141 | ||
142 | // ---------------------------------------------------------------------------- | |
143 | // wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse | |
144 | // click into button press/release actions | |
145 | // ---------------------------------------------------------------------------- | |
146 | ||
147 | class WXDLLEXPORT wxStdToolbarInputHandler : public wxStdButtonInputHandler | |
148 | { | |
149 | public: | |
150 | wxStdToolbarInputHandler(wxInputHandler *inphand); | |
151 | ||
152 | virtual bool HandleKey(wxInputConsumer *consumer, | |
153 | const wxKeyEvent& event, | |
154 | bool pressed); | |
4e89ceb1 VZ |
155 | virtual bool HandleMouse(wxInputConsumer *consumer, |
156 | const wxMouseEvent& event); | |
3216dbf5 VZ |
157 | virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); |
158 | virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event); | |
159 | virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); | |
c08a4f00 RR |
160 | }; |
161 | ||
162 | #endif // _WX_UNIV_TOOLBAR_H_ |