1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxToolBarSimple class
4 // Author: Julian Smart
5 // Modified by: VZ on 14.12.99 during wxToolBar classes reorganization
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TBARSMPLH__
13 #define _WX_TBARSMPLH__
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "tbarsmpl.h"
19 #include "wx/tbarbase.h"
21 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_SIMPLE
23 class WXDLLEXPORT wxMemoryDC
;
25 // ----------------------------------------------------------------------------
26 // wxToolBarSimple is a generic toolbar implementation in pure wxWindows
27 // ----------------------------------------------------------------------------
29 class WXDLLEXPORT wxToolBarSimple
: public wxToolBarBase
33 wxToolBarSimple() { Init(); }
35 wxToolBarSimple(wxWindow
*parent
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
39 long style
= wxNO_BORDER
| wxTB_HORIZONTAL
,
40 const wxString
& name
= wxToolBarNameStr
)
44 Create(parent
, winid
, pos
, size
, style
, name
);
47 bool Create(wxWindow
*parent
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
51 long style
= wxNO_BORDER
| wxTB_HORIZONTAL
,
52 const wxString
& name
= wxToolBarNameStr
);
54 virtual ~wxToolBarSimple();
56 // override/implement base class virtuals
57 virtual wxToolBarToolBase
*FindToolForPosition(wxCoord x
, wxCoord y
) const;
59 virtual bool Realize();
61 virtual void SetRows(int nRows
);
63 // implementation from now on
64 // --------------------------
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
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);
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();
83 // Prepare the DC by translating it according to the current scroll position
84 virtual void PrepareDC(wxDC
& dc
);
86 int GetScrollPageSize(int orient
) const ;
87 void SetScrollPageSize(int orient
, int pageSize
);
90 virtual void ViewStart(int *x
, int *y
) const;
92 // Actual size in pixels when scrolling is taken into account
93 virtual void GetVirtualSize(int *x
, int *y
) const;
95 int CalcScrollInc(wxScrollEvent
& event
);
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
);
105 // common part of all ctors
108 // implement base class pure virtuals
109 virtual wxToolBarToolBase
*DoAddTool
112 const wxString
& label
,
113 const wxBitmap
& bitmap
,
114 const wxBitmap
& bmpDisabled
,
116 const wxString
& shortHelp
= wxEmptyString
,
117 const wxString
& longHelp
= wxEmptyString
,
118 wxObject
*clientData
= NULL
,
123 virtual bool DoInsertTool(size_t pos
, wxToolBarToolBase
*tool
);
124 virtual bool DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
);
126 virtual void DoEnableTool(wxToolBarToolBase
*tool
, bool enable
);
127 virtual void DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
);
128 virtual void DoSetToggle(wxToolBarToolBase
*tool
, bool toggle
);
130 virtual wxToolBarToolBase
*CreateTool(int winid
,
131 const wxString
& label
,
132 const wxBitmap
& bmpNormal
,
133 const wxBitmap
& bmpDisabled
,
135 wxObject
*clientData
,
136 const wxString
& shortHelp
,
137 const wxString
& longHelp
);
138 virtual wxToolBarToolBase
*CreateTool(wxControl
*control
);
141 void DrawTool(wxToolBarToolBase
*tool
);
142 virtual void DrawTool(wxDC
& dc
, wxToolBarToolBase
*tool
);
143 virtual void SpringUpButton(int index
);
145 int m_currentRowsOrColumns
;
147 int m_pressedTool
, m_currentTool
;
149 wxCoord m_lastX
, m_lastY
;
150 wxCoord m_maxWidth
, m_maxHeight
;
151 wxCoord m_xPos
, m_yPos
;
154 int m_xScrollPixelsPerLine
;
155 int m_yScrollPixelsPerLine
;
156 bool m_xScrollingEnabled
;
157 bool m_yScrollingEnabled
;
158 int m_xScrollPosition
;
159 int m_yScrollPosition
;
162 int m_xScrollLinesPerPage
;
163 int m_yScrollLinesPerPage
;
166 DECLARE_EVENT_TABLE()
167 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolBarSimple
)
170 #endif // wxUSE_TOOLBAR_SIMPLE