]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/tbarsmpl.h | |
3 | // Purpose: wxToolBarSimple class | |
4 | // Author: Julian Smart | |
5 | // Modified by: VZ on 14.12.99 during wxToolBar classes reorganization | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_TBARSMPLH__ | |
13 | #define _WX_TBARSMPLH__ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "tbarsmpl.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/tbarbase.h" | |
20 | ||
21 | #if wxUSE_TOOLBAR_SIMPLE | |
22 | ||
23 | class WXDLLEXPORT wxMemoryDC; | |
24 | ||
25 | // ---------------------------------------------------------------------------- | |
26 | // wxToolBarSimple is a generic toolbar implementation in pure wxWindows | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
29 | class WXDLLEXPORT wxToolBarSimple : public wxToolBarBase | |
30 | { | |
31 | public: | |
32 | // ctors and dtor | |
33 | wxToolBarSimple() { Init(); } | |
34 | ||
35 | wxToolBarSimple(wxWindow *parent, | |
36 | wxWindowID id, | |
37 | const wxPoint& pos = wxDefaultPosition, | |
38 | const wxSize& size = wxDefaultSize, | |
39 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
40 | const wxString& name = wxToolBarNameStr) | |
41 | { | |
42 | Init(); | |
43 | ||
44 | Create(parent, id, pos, size, style, name); | |
45 | } | |
46 | ||
47 | bool Create(wxWindow *parent, | |
48 | wxWindowID id, | |
49 | const wxPoint& pos = wxDefaultPosition, | |
50 | const wxSize& size = wxDefaultSize, | |
51 | long style = wxNO_BORDER | wxTB_HORIZONTAL, | |
52 | const wxString& name = wxToolBarNameStr); | |
53 | ||
54 | virtual ~wxToolBarSimple(); | |
55 | ||
56 | // override/implement base class virtuals | |
57 | virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; | |
58 | ||
59 | virtual bool Realize(); | |
60 | ||
61 | virtual void SetRows(int nRows); | |
62 | ||
63 | // implementation from now on | |
64 | // -------------------------- | |
65 | ||
66 | // SCROLLING: this has to be copied from wxScrolledWindow since | |
67 | // wxToolBarBase inherits from wxControl. This could have been put into | |
68 | // wxToolBarSimple, but we might want any derived toolbar class to be | |
69 | // scrollable. | |
70 | ||
71 | // Number of pixels per user unit (0 or -1 for no scrollbar) | |
72 | // Length of virtual canvas in user units | |
73 | virtual void SetScrollbars(int horizontal, int vertical, | |
74 | int x_length, int y_length, | |
75 | int x_pos = 0, int y_pos = 0); | |
76 | ||
77 | // Physically scroll the window | |
78 | virtual void Scroll(int x_pos, int y_pos); | |
79 | virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const; | |
80 | virtual void EnableScrolling(bool x_scrolling, bool y_scrolling); | |
81 | virtual void AdjustScrollbars(); | |
82 | ||
83 | // Prepare the DC by translating it according to the current scroll position | |
84 | virtual void PrepareDC(wxDC& dc); | |
85 | ||
86 | int GetScrollPageSize(int orient) const ; | |
87 | void SetScrollPageSize(int orient, int pageSize); | |
88 | ||
89 | // Get the view start | |
90 | virtual void ViewStart(int *x, int *y) const; | |
91 | ||
92 | // Actual size in pixels when scrolling is taken into account | |
93 | virtual void GetVirtualSize(int *x, int *y) const; | |
94 | ||
95 | int CalcScrollInc(wxScrollEvent& event); | |
96 | ||
97 | // event handlers | |
98 | void OnPaint(wxPaintEvent& event); | |
99 | void OnSize(wxSizeEvent& event); | |
100 | void OnMouseEvent(wxMouseEvent& event); | |
101 | void OnKillFocus(wxFocusEvent& event); | |
102 | void OnScroll(wxScrollEvent& event); | |
103 | ||
104 | protected: | |
105 | // common part of all ctors | |
106 | void Init(); | |
107 | ||
108 | // implement base class pure virtuals | |
109 | virtual wxToolBarToolBase *DoAddTool | |
110 | ( | |
111 | int id, | |
112 | const wxString& label, | |
113 | const wxBitmap& bitmap, | |
114 | const wxBitmap& bmpDisabled, | |
115 | wxItemKind kind, | |
116 | const wxString& shortHelp = wxEmptyString, | |
117 | const wxString& longHelp = wxEmptyString, | |
118 | wxObject *clientData = NULL, | |
119 | wxCoord xPos = -1, | |
120 | wxCoord yPos = -1 | |
121 | ); | |
122 | ||
123 | virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); | |
124 | virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); | |
125 | ||
126 | virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); | |
127 | virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); | |
128 | virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); | |
129 | ||
130 | virtual wxToolBarToolBase *CreateTool(int id, | |
131 | const wxString& label, | |
132 | const wxBitmap& bmpNormal, | |
133 | const wxBitmap& bmpDisabled, | |
134 | wxItemKind kind, | |
135 | wxObject *clientData, | |
136 | const wxString& shortHelp, | |
137 | const wxString& longHelp); | |
138 | virtual wxToolBarToolBase *CreateTool(wxControl *control); | |
139 | ||
140 | // helpers | |
141 | void DrawTool(wxToolBarToolBase *tool); | |
142 | virtual void DrawTool(wxDC& dc, wxToolBarToolBase *tool); | |
143 | virtual void SpringUpButton(int index); | |
144 | ||
145 | int m_currentRowsOrColumns; | |
146 | ||
147 | int m_pressedTool, m_currentTool; | |
148 | ||
149 | wxCoord m_lastX, m_lastY; | |
150 | wxCoord m_maxWidth, m_maxHeight; | |
151 | wxCoord m_xPos, m_yPos; | |
152 | ||
153 | // scrolling data | |
154 | int m_xScrollPixelsPerLine; | |
155 | int m_yScrollPixelsPerLine; | |
156 | bool m_xScrollingEnabled; | |
157 | bool m_yScrollingEnabled; | |
158 | int m_xScrollPosition; | |
159 | int m_yScrollPosition; | |
160 | int m_xScrollLines; | |
161 | int m_yScrollLines; | |
162 | int m_xScrollLinesPerPage; | |
163 | int m_yScrollLinesPerPage; | |
164 | ||
165 | private: | |
166 | DECLARE_EVENT_TABLE() | |
167 | DECLARE_DYNAMIC_CLASS(wxToolBarSimple) | |
168 | }; | |
169 | ||
170 | #endif // wxUSE_TOOLBAR_SIMPLE | |
171 | ||
172 | #endif | |
173 | // _WX_TBARSMPLH__ | |
174 |