]> git.saurik.com Git - wxWidgets.git/blob - src/stubs/toolbar.cpp
fixed menu accelerators
[wxWidgets.git] / src / stubs / toolbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: toolbar.cpp
3 // Purpose: wxToolBar
4 // Author: AUTHOR
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "toolbar.h"
14 #endif
15
16 #include "wx/wx.h"
17 #include "wx/toolbar.h"
18
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
21
22 BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
23 END_EVENT_TABLE()
24 #endif
25
26 wxToolBar::wxToolBar()
27 {
28 m_maxWidth = -1;
29 m_maxHeight = -1;
30 m_defaultWidth = 24;
31 m_defaultHeight = 22;
32 // TODO
33 }
34
35 bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
36 long style, const wxString& name)
37 {
38 m_maxWidth = -1;
39 m_maxHeight = -1;
40
41 m_defaultWidth = 24;
42 m_defaultHeight = 22;
43 SetName(name);
44
45 m_windowStyle = style;
46
47 SetParent(parent);
48
49 if (parent) parent->AddChild(this);
50
51 // TODO create toolbar
52
53 return FALSE;
54 }
55
56 wxToolBar::~wxToolBar()
57 {
58 // TODO
59 }
60
61 bool wxToolBar::CreateTools()
62 {
63 if (m_tools.Number() == 0)
64 return FALSE;
65
66 // TODO
67 return FALSE;
68 }
69
70 void wxToolBar::SetToolBitmapSize(const wxSize& size)
71 {
72 m_defaultWidth = size.x; m_defaultHeight = size.y;
73 // TODO
74 }
75
76 wxSize wxToolBar::GetMaxSize() const
77 {
78 // TODO
79 return wxSize(0, 0);
80 }
81
82 // The button size is bigger than the bitmap size
83 wxSize wxToolBar::GetToolSize() const
84 {
85 // TODO
86 return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
87 }
88
89 void wxToolBar::EnableTool(int toolIndex, bool enable)
90 {
91 wxNode *node = m_tools.Find((long)toolIndex);
92 if (node)
93 {
94 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
95 tool->m_enabled = enable;
96 // TODO enable button
97 }
98 }
99
100 void wxToolBar::ToggleTool(int toolIndex, bool toggle)
101 {
102 wxNode *node = m_tools.Find((long)toolIndex);
103 if (node)
104 {
105 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
106 if (tool->m_isToggle)
107 {
108 tool->m_toggleState = toggle;
109 // TODO: set toggle state
110 }
111 }
112 }
113
114 void wxToolBar::ClearTools()
115 {
116 // TODO
117 wxToolBarBase::ClearTools();
118 }
119
120 // If pushedBitmap is NULL, a reversed version of bitmap is
121 // created and used as the pushed/toggled image.
122 // If toggle is TRUE, the button toggles between the two states.
123
124 wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
125 bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
126 {
127 wxToolBarTool *tool = new wxToolBarTool(index, bitmap, wxNullBitmap, toggle, xPos, yPos, helpString1, helpString2);
128 tool->m_clientData = clientData;
129
130 if (xPos > -1)
131 tool->m_x = xPos;
132 else
133 tool->m_x = m_xMargin;
134
135 if (yPos > -1)
136 tool->m_y = yPos;
137 else
138 tool->m_y = m_yMargin;
139
140 tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight());
141
142 m_tools.Append((long)index, tool);
143 return tool;
144 }
145