]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/toolbar.h
Blind fixes for warnings in wxTinderbox.
[wxWidgets.git] / include / wx / univ / toolbar.h
CommitLineData
c08a4f00
RR
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/toolbar.h
3// Purpose: wxToolBar declaration
4// Author: Robert Roebling
5// Modified by:
6// Created: 10.09.00
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
65571936 9// Licence: wxWindows licence
c08a4f00
RR
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_TOOLBAR_H_
13#define _WX_UNIV_TOOLBAR_H_
14
3216dbf5
VZ
15#include "wx/button.h" // for wxStdButtonInputHandler
16
17class WXDLLEXPORT wxToolBarTool;
c08a4f00
RR
18
19// ----------------------------------------------------------------------------
3216dbf5 20// the actions supported by this control
c08a4f00
RR
21// ----------------------------------------------------------------------------
22
3216dbf5
VZ
23#define wxACTION_TOOLBAR_TOGGLE wxACTION_BUTTON_TOGGLE
24#define wxACTION_TOOLBAR_PRESS wxACTION_BUTTON_PRESS
25#define wxACTION_TOOLBAR_RELEASE wxACTION_BUTTON_RELEASE
26#define wxACTION_TOOLBAR_CLICK wxACTION_BUTTON_CLICK
27#define wxACTION_TOOLBAR_ENTER _T("enter") // highlight the tool
28#define wxACTION_TOOLBAR_LEAVE _T("leave") // unhighlight the tool
c08a4f00 29
3216dbf5
VZ
30// ----------------------------------------------------------------------------
31// wxToolBar
32// ----------------------------------------------------------------------------
c08a4f00 33
3216dbf5 34class WXDLLEXPORT wxToolBar : public wxToolBarBase
c08a4f00
RR
35{
36public:
37 // construction/destruction
6463b9f5 38 wxToolBar() { Init(); }
3216dbf5
VZ
39 wxToolBar(wxWindow *parent,
40 wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = 0,
6463b9f5
JS
44 const wxString& name = wxToolBarNameStr)
45 {
46 Init();
47
48 Create(parent, id, pos, size, style, name);
49 }
c08a4f00
RR
50
51 bool Create( wxWindow *parent,
52 wxWindowID id,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = 0,
56 const wxString& name = wxToolBarNameStr );
57
3216dbf5 58 virtual ~wxToolBar();
c08a4f00
RR
59
60 virtual bool Realize();
61
62 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
63
64 virtual void SetToolShortHelp(int id, const wxString& helpString);
65
34d26f42
RR
66 virtual void SetMargins(int x, int y);
67 void SetMargins(const wxSize& size)
68 { SetMargins((int) size.x, (int) size.y); }
69
c08a4f00
RR
70protected:
71 // common part of all ctors
72 void Init();
73
74 // implement base class pure virtuals
75 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
76 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
77
78 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
79 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
80 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
81
82 virtual wxToolBarToolBase *CreateTool(int id,
d448aec3
VZ
83 const wxString& label,
84 const wxBitmap& bmpNormal,
85 const wxBitmap& bmpDisabled,
86 wxItemKind kind,
c08a4f00 87 wxObject *clientData,
d448aec3
VZ
88 const wxString& shortHelp,
89 const wxString& longHelp);
c08a4f00 90 virtual wxToolBarToolBase *CreateTool(wxControl *control);
16c9a425 91
3216dbf5
VZ
92 // implement wxUniversal methods
93 virtual bool PerformAction(const wxControlAction& action,
94 long numArg = -1,
95 const wxString& strArg = wxEmptyString);
96 virtual wxSize DoGetBestClientSize() const;
dda4f6c0
JS
97 virtual void DoSetSize(int x, int y,
98 int width, int height,
99 int sizeFlags = wxSIZE_AUTO);
3216dbf5
VZ
100 virtual void DoDraw(wxControlRenderer *renderer);
101
102 // get the bounding rect for the given tool
103 wxRect GetToolRect(wxToolBarToolBase *tool) const;
104
105 // redraw the given tool
106 void RefreshTool(wxToolBarToolBase *tool);
107
108 // (re)calculate the tool positions, should only be called if it is
a290fa5a 109 // necessary to do it, i.e. m_needsLayout == true
3216dbf5 110 void DoLayout();
c08a4f00 111
3216dbf5
VZ
112 // get the rect limits depending on the orientation: top/bottom for a
113 // vertical toolbar, left/right for a horizontal one
114 void GetRectLimits(const wxRect& rect, wxCoord *start, wxCoord *end) const;
115
c08a4f00 116private:
3216dbf5
VZ
117 // have we calculated the positions of our tools?
118 bool m_needsLayout;
119
120 // the width of a separator
121 wxCoord m_widthSeparator;
122
123 // the total size of all toolbar elements
124 wxCoord m_maxWidth,
125 m_maxHeight;
3216dbf5 126
34d26f42 127private:
3216dbf5
VZ
128 DECLARE_DYNAMIC_CLASS(wxToolBar)
129};
130
131// ----------------------------------------------------------------------------
132// wxStdToolbarInputHandler: translates SPACE and ENTER keys and the left mouse
133// click into button press/release actions
134// ----------------------------------------------------------------------------
135
34d26f42 136class WXDLLEXPORT wxStdToolbarInputHandler : public wxStdInputHandler
3216dbf5
VZ
137{
138public:
139 wxStdToolbarInputHandler(wxInputHandler *inphand);
140
141 virtual bool HandleKey(wxInputConsumer *consumer,
142 const wxKeyEvent& event,
143 bool pressed);
4e89ceb1
VZ
144 virtual bool HandleMouse(wxInputConsumer *consumer,
145 const wxMouseEvent& event);
3216dbf5
VZ
146 virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
147 virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
148 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
34d26f42
RR
149
150private:
151 wxWindow *m_winCapture;
152 wxToolBarToolBase *m_toolCapture;
153 wxToolBarToolBase *m_toolLast;
c08a4f00
RR
154};
155
156#endif // _WX_UNIV_TOOLBAR_H_