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