]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/toolbar.cpp
4 // Author: William Osborne
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
)
96 EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged
)
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 class wxToolBarTool
: public wxToolBarToolBase
106 wxToolBarTool(wxToolBar
*tbar
,
108 const wxString
& label
,
109 const wxBitmap
& bmpNormal
,
110 const wxBitmap
& bmpDisabled
,
112 wxObject
*clientData
,
113 const wxString
& shortHelp
,
114 const wxString
& longHelp
)
115 : wxToolBarToolBase(tbar
, id
, label
, bmpNormal
, bmpDisabled
, kind
,
116 clientData
, shortHelp
, longHelp
)
120 wxToolBarTool(wxToolBar
*tbar
, wxControl
*control
)
121 : wxToolBarToolBase(tbar
, control
)
125 virtual void SetLabel(const wxString
& label
)
129 // set/get the number of separators which we use to cover the space used by
130 // a control in the toolbar
131 void SetSeparatorsCount(size_t count
) { m_nSepCount
= count
; }
132 size_t GetSeparatorsCount() const { return m_nSepCount
; }
137 DECLARE_NO_COPY_CLASS(wxToolBarTool
)
141 // ============================================================================
143 // ============================================================================
145 // ----------------------------------------------------------------------------
147 // ----------------------------------------------------------------------------
149 wxToolBarToolBase
*wxToolBar::CreateTool(int id
,
150 const wxString
& label
,
151 const wxBitmap
& bmpNormal
,
152 const wxBitmap
& bmpDisabled
,
154 wxObject
*clientData
,
155 const wxString
& shortHelp
,
156 const wxString
& longHelp
)
158 return new wxToolBarTool(this, id
, label
, bmpNormal
, bmpDisabled
, kind
,
159 clientData
, shortHelp
, longHelp
);
162 wxToolBarToolBase
*wxToolBar::CreateTool(wxControl
*control
)
164 return new wxToolBarTool(this, control
);
167 // ----------------------------------------------------------------------------
168 // wxToolBar construction
169 // ----------------------------------------------------------------------------
171 void wxToolBar::Init()
175 bool wxToolBar::Create(wxWindow
*parent
,
180 const wxString
& name
)
185 void wxToolBar::Recreate()
189 wxToolBar::~wxToolBar()
193 wxSize
wxToolBar::DoGetBestSize() const
198 // ----------------------------------------------------------------------------
199 // adding/removing tools
200 // ----------------------------------------------------------------------------
202 bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos
), wxToolBarToolBase
*tool
)
207 bool wxToolBar::DoDeleteTool(size_t pos
, wxToolBarToolBase
*tool
)
212 bool wxToolBar::Realize()
217 // ----------------------------------------------------------------------------
219 // ----------------------------------------------------------------------------
221 void wxToolBar::SetToolBitmapSize(const wxSize
& size
)
225 void wxToolBar::SetRows(int nRows
)
229 // The button size is bigger than the bitmap size
230 wxSize
wxToolBar::GetToolSize() const
236 wxToolBarToolBase
*GetItemSkippingDummySpacers(const wxToolBarToolsList
& tools
,
242 wxToolBarToolBase
*wxToolBar::FindToolForPosition(wxCoord x
, wxCoord y
) const
247 void wxToolBar::UpdateSize()
251 // ----------------------------------------------------------------------------
253 // ---------------------------------------------------------------------------
255 void wxToolBar::SetWindowStyleFlag(long style
)
259 // ----------------------------------------------------------------------------
261 // ----------------------------------------------------------------------------
263 void wxToolBar::DoEnableTool(wxToolBarToolBase
*tool
, bool enable
)
267 void wxToolBar::DoToggleTool(wxToolBarToolBase
*tool
, bool toggle
)
271 void wxToolBar::DoSetToggle(wxToolBarToolBase
*WXUNUSED(tool
), bool WXUNUSED(toggle
))
275 // ----------------------------------------------------------------------------
277 // ----------------------------------------------------------------------------
279 // Responds to colour changes, and passes event on to children.
280 void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent
& event
)
284 void wxToolBar::OnMouseEvent(wxMouseEvent
& event
)
288 #endif // wxUSE_TOOLBAR