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