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 and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TBARSMPLH__
13 #define _WX_TBARSMPLH__
16 #pragma interface "tbarsmpl.h"
19 #include "wx/tbarbase.h"
21 #if 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
, id
, 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
*AddTool
60 const wxBitmap
& bitmap
,
61 const wxBitmap
& pushedBitmap
,
65 wxObject
*clientData
= NULL
,
66 const wxString
& helpString1
= wxEmptyString
,
67 const wxString
& helpString2
= wxEmptyString
70 virtual wxToolBarToolBase
*FindToolForPosition(wxCoord x
, wxCoord y
) const;
72 virtual bool Realize();
74 virtual void SetRows(int nRows
);
76 // implementation from now on
77 // --------------------------
79 // SCROLLING: this has to be copied from wxScrolledWindow since
80 // wxToolBarBase inherits from wxControl. This could have been put into
81 // wxToolBarSimple, but we might want any derived toolbar class to be
84 // Number of pixels per user unit (0 or -1 for no scrollbar)
85 // Length of virtual canvas in user units
86 virtual void SetScrollbars(int horizontal
, int vertical
,
87 int x_length
, int y_length
,
88 int x_pos
= 0, int y_pos
= 0);
90 // Physically scroll the window
91 virtual void Scroll(int x_pos
, int y_pos
);
92 virtual void GetScrollPixelsPerUnit(int *x_unit
, int *y_unit
) const;
93 virtual void EnableScrolling(bool x_scrolling
, bool y_scrolling
);
94 virtual void AdjustScrollbars();
96 // Prepare the DC by translating it according to the current scroll position
97 virtual void PrepareDC(wxDC
& dc
);
99 int GetScrollPageSize(int orient
) const ;
100 void SetScrollPageSize(int orient
, int pageSize
);
102 // Get the view start
103 virtual void ViewStart(int *x
, int *y
) const;
105 // Actual size in pixels when scrolling is taken into account
106 virtual void GetVirtualSize(int *x
, int *y
) const;
108 int CalcScrollInc(wxScrollEvent
& event
);
111 void OnPaint(wxPaintEvent
& event
);
112 void OnSize(wxSizeEvent
& event
);
113 void OnMouseEvent(wxMouseEvent
& event
);
114 void OnKillFocus(wxFocusEvent
& event
);
115 void OnScroll(wxScrollEvent
& event
);
118 // common part of all ctors
121 // implement base class pure virtuals
122 virtual bool DoInsertTool(size_t pos
, wxToolBarToolBase
*tool
);
123 virtual bool DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
);
125 virtual void DoEnableTool(wxToolBarToolBase
*tool
, bool enable
);
126 virtual void DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
);
127 virtual void DoSetToggle(wxToolBarToolBase
*tool
, bool toggle
);
129 virtual wxToolBarToolBase
*CreateTool(int id
,
130 const wxBitmap
& bitmap1
,
131 const wxBitmap
& bitmap2
,
133 wxObject
*clientData
,
134 const wxString
& shortHelpString
,
135 const wxString
& longHelpString
);
136 virtual wxToolBarToolBase
*CreateTool(wxControl
*control
);
139 void DrawTool(wxToolBarToolBase
*tool
);
140 virtual void DrawTool(wxDC
& dc
, wxToolBarToolBase
*tool
);
141 virtual void SpringUpButton(int index
);
143 int m_currentRowsOrColumns
;
145 int m_pressedTool
, m_currentTool
;
147 wxCoord m_lastX
, m_lastY
;
148 wxCoord m_maxWidth
, m_maxHeight
;
149 wxCoord m_xPos
, m_yPos
;
152 int m_xScrollPixelsPerLine
;
153 int m_yScrollPixelsPerLine
;
154 bool m_xScrollingEnabled
;
155 bool m_yScrollingEnabled
;
156 int m_xScrollPosition
;
157 int m_yScrollPosition
;
160 int m_xScrollLinesPerPage
;
161 int m_yScrollLinesPerPage
;
164 DECLARE_EVENT_TABLE()
165 DECLARE_DYNAMIC_CLASS(wxToolBarSimple
)
168 #endif // wxUSE_TOOLBAR_SIMPLE