]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/tbarsmpl.h
Replaced typedef with #define for VC++ 1.5, to prevent 'no constructor' error
[wxWidgets.git] / include / wx / tbarsmpl.h
... / ...
CommitLineData
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
23class WXDLLEXPORT wxMemoryDC;
24
25// ----------------------------------------------------------------------------
26// wxToolBarSimple is a generic toolbar implementation in pure wxWindows
27// ----------------------------------------------------------------------------
28
29class WXDLLEXPORT wxToolBarSimple : public wxToolBarBase
30{
31public:
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 *AddTool
58 (
59 int id,
60 const wxBitmap& bitmap,
61 const wxBitmap& pushedBitmap,
62 bool toggle,
63 wxCoord xPos,
64 wxCoord yPos = -1,
65 wxObject *clientData = NULL,
66 const wxString& helpString1 = wxEmptyString,
67 const wxString& helpString2 = wxEmptyString
68 );
69
70 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
71
72 virtual bool Realize();
73
74 virtual void SetRows(int nRows);
75
76 // implementation from now on
77 // --------------------------
78
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
82 // scrollable.
83
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);
89
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();
95
96 // Prepare the DC by translating it according to the current scroll position
97 virtual void PrepareDC(wxDC& dc);
98
99 int GetScrollPageSize(int orient) const ;
100 void SetScrollPageSize(int orient, int pageSize);
101
102 // Get the view start
103 virtual void ViewStart(int *x, int *y) const;
104
105 // Actual size in pixels when scrolling is taken into account
106 virtual void GetVirtualSize(int *x, int *y) const;
107
108 int CalcScrollInc(wxScrollEvent& event);
109
110 // event handlers
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);
116
117protected:
118 // common part of all ctors
119 void Init();
120
121 // implement base class pure virtuals
122 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
123 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
124
125 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
126 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
127 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
128
129 virtual wxToolBarToolBase *CreateTool(int id,
130 const wxBitmap& bitmap1,
131 const wxBitmap& bitmap2,
132 bool toggle,
133 wxObject *clientData,
134 const wxString& shortHelpString,
135 const wxString& longHelpString);
136 virtual wxToolBarToolBase *CreateTool(wxControl *control);
137
138 // helpers
139 void DrawTool(wxToolBarToolBase *tool);
140 virtual void DrawTool(wxDC& dc, wxToolBarToolBase *tool);
141 virtual void SpringUpButton(int index);
142
143 int m_currentRowsOrColumns;
144
145 int m_pressedTool, m_currentTool;
146
147 wxCoord m_lastX, m_lastY;
148 wxCoord m_maxWidth, m_maxHeight;
149 wxCoord m_xPos, m_yPos;
150
151 // scrolling data
152 int m_xScrollPixelsPerLine;
153 int m_yScrollPixelsPerLine;
154 bool m_xScrollingEnabled;
155 bool m_yScrollingEnabled;
156 int m_xScrollPosition;
157 int m_yScrollPosition;
158 int m_xScrollLines;
159 int m_yScrollLines;
160 int m_xScrollLinesPerPage;
161 int m_yScrollLinesPerPage;
162
163private:
164 DECLARE_EVENT_TABLE()
165 DECLARE_DYNAMIC_CLASS(wxToolBarSimple)
166};
167
168#endif // wxUSE_TOOLBAR_SIMPLE
169
170#endif
171 // _WX_TBARSMPLH__
172