]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/toolbar.cpp
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "toolbar.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/dynarray.h"
36 #include "wx/settings.h"
37 #include "wx/bitmap.h"
38 #include "wx/dcmemory.h"
39 #include "wx/control.h"
42 #if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE
44 #include "wx/toolbar.h"
45 #include "wx/sysopt.h"
47 #include "wx/palmos/private.h"
49 #include "wx/palmos/wrapcctl.h"
51 #include "wx/app.h" // for GetComCtl32Version
53 // ----------------------------------------------------------------------------
54 // conditional compilation
55 // ----------------------------------------------------------------------------
57 // wxWidgets previously always considered that toolbar buttons have light grey
58 // (0xc0c0c0) background and so ignored any bitmap masks - however, this
59 // doesn't work with XPMs which then appear to have black background. To make
60 // this work, we must respect the bitmap masks - which we do now. This should
61 // be ok in any case, but to restore 100% compatible with the old version
62 // behaviour, you can set this to 0.
63 #define USE_BITMAP_MASKS 1
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxControl
)
85 style ( wxNO_BORDER | wxTB_HORIZONTAL)
94 BEGIN_EVENT_TABLE(wxToolBar
, wxToolBarBase
)
95 EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent
)
98 // ----------------------------------------------------------------------------
100 // ----------------------------------------------------------------------------
102 class wxToolBarTool
: public wxToolBarToolBase
105 wxToolBarTool(wxToolBar
*tbar
,
107 const wxString
& label
,
108 const wxBitmap
& bmpNormal
,
109 const wxBitmap
& bmpDisabled
,
111 wxObject
*clientData
,
112 const wxString
& shortHelp
,
113 const wxString
& longHelp
)
114 : wxToolBarToolBase(tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
115 clientData
, shortHelp
, longHelp
)
119 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
)
120 : wxToolBarToolBase(tbar
, control
)
124 virtual void SetLabel(const wxString
& label
)
128 // set/get the number of separators which we use to cover the space used by
129 // a control in the toolbar
130 void SetSeparatorsCount(size_t count
) { m_nSepCount
= count
; }
131 size_t GetSeparatorsCount() const { return m_nSepCount
; }
136 DECLARE_NO_COPY_CLASS(wxToolBarTool
)
140 // ============================================================================
142 // ============================================================================
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
148 wxToolBarToolBase
*wxToolBar::CreateTool(int id
,
149 const wxString
& label
,
150 const wxBitmap
& bmpNormal
,
151 const wxBitmap
& bmpDisabled
,
153 wxObject
*clientData
,
154 const wxString
& shortHelp
,
155 const wxString
& longHelp
)
157 return new wxToolBarTool(this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
158 clientData
, shortHelp
, longHelp
);
161 wxToolBarToolBase
*wxToolBar::CreateTool(wxControl
*control
)
163 return new wxToolBarTool(this, control
);
166 // ----------------------------------------------------------------------------
167 // wxToolBar construction
168 // ----------------------------------------------------------------------------
170 void wxToolBar::Init()
174 bool wxToolBar::Create(wxWindow
*parent
,
179 const wxString
& name
)
184 void wxToolBar::Recreate()
188 wxToolBar::~wxToolBar()
192 wxSize
wxToolBar::DoGetBestSize() const
197 // ----------------------------------------------------------------------------
198 // adding/removing tools
199 // ----------------------------------------------------------------------------
201 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*tool
)
206 bool wxToolBar::DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
)
211 bool wxToolBar::Realize()
216 // ----------------------------------------------------------------------------
218 // ----------------------------------------------------------------------------
220 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
224 void wxToolBar::SetRows(int nRows
)
228 // The button size is bigger than the bitmap size
229 wxSize
wxToolBar::GetToolSize() const
235 wxToolBarToolBase
*GetItemSkippingDummySpacers(const wxToolBarToolsList
& tools
,
241 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
246 void wxToolBar::UpdateSize()
250 // ----------------------------------------------------------------------------
252 // ----------------------------------------------------------------------------
254 void wxToolBar::DoEnableTool(wxToolBarToolBase
*tool
, bool enable
)
258 void wxToolBar::DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
)
262 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
266 // ----------------------------------------------------------------------------
268 // ----------------------------------------------------------------------------
270 void wxToolBar::OnMouseEvent(wxMouseEvent
& event
)
274 #endif // wxUSE_TOOLBAR