]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: tbargtk.cpp | |
3 | // Purpose: GTK toolbar | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: | |
8 | // Copyright: (c) Robert Roebling | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "tbargtk.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/toolbar.h" | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // wxToolBarTool | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool,wxObject) | |
23 | ||
716b7364 | 24 | wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex, |
debe6624 JS |
25 | const wxBitmap& bitmap1, const wxBitmap& bitmap2, |
26 | bool toggle, wxObject *clientData, | |
c801d85f KB |
27 | const wxString& shortHelpString, const wxString& longHelpString ) |
28 | { | |
29 | m_owner = owner; | |
30 | m_index = theIndex; | |
31 | m_bitmap1 = bitmap1; | |
32 | m_bitmap2 = bitmap2; | |
33 | m_isToggle = toggle; | |
34 | m_enabled = TRUE; | |
35 | m_toggleState = FALSE; | |
36 | m_shortHelpString = shortHelpString; | |
37 | m_longHelpString = longHelpString; | |
38 | m_isMenuCommand = TRUE; | |
39 | m_clientData = clientData; | |
40 | m_deleteSecondBitmap = FALSE; | |
41 | }; | |
42 | ||
43 | wxToolBarTool::~wxToolBarTool(void) | |
44 | { | |
45 | }; | |
46 | ||
47 | //----------------------------------------------------------------------------- | |
716b7364 | 48 | // wxToolBar |
c801d85f KB |
49 | //----------------------------------------------------------------------------- |
50 | ||
51 | static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool ) | |
52 | { | |
53 | if (!tool->m_enabled) return; | |
54 | ||
55 | if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState; | |
56 | ||
57 | tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState ); | |
58 | }; | |
59 | ||
60 | //----------------------------------------------------------------------------- | |
61 | ||
716b7364 | 62 | IMPLEMENT_DYNAMIC_CLASS(wxToolBar,wxControl) |
c801d85f | 63 | |
716b7364 | 64 | BEGIN_EVENT_TABLE(wxToolBar, wxControl) |
c801d85f KB |
65 | END_EVENT_TABLE() |
66 | ||
716b7364 | 67 | wxToolBar::wxToolBar(void) |
c801d85f KB |
68 | { |
69 | }; | |
70 | ||
716b7364 | 71 | wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id, |
c801d85f | 72 | const wxPoint& pos, const wxSize& size, |
debe6624 | 73 | long style, const wxString& name ) |
c801d85f KB |
74 | { |
75 | Create( parent, id, pos, size, style, name ); | |
76 | }; | |
77 | ||
716b7364 | 78 | wxToolBar::~wxToolBar(void) |
c801d85f KB |
79 | { |
80 | }; | |
81 | ||
716b7364 | 82 | bool wxToolBar::Create( wxWindow *parent, wxWindowID id, |
c801d85f | 83 | const wxPoint& pos, const wxSize& size, |
debe6624 | 84 | long style, const wxString& name ) |
c801d85f KB |
85 | { |
86 | m_needParent = TRUE; | |
87 | ||
88 | PreCreation( parent, id, pos, size, style, name ); | |
89 | ||
90 | m_tools.DeleteContents( TRUE ); | |
91 | ||
92 | m_widget = gtk_handle_box_new(); | |
93 | ||
94 | m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS ) ); | |
95 | ||
96 | gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); | |
97 | ||
98 | gtk_widget_show( GTK_WIDGET(m_toolbar) ); | |
99 | ||
100 | PostCreation(); | |
101 | ||
102 | Show( TRUE ); | |
103 | ||
104 | return TRUE; | |
105 | }; | |
106 | ||
716b7364 | 107 | bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown ) |
c801d85f | 108 | { |
46dc76ba RR |
109 | wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); |
110 | event.SetEventObject( this ); | |
111 | event.SetInt( toolIndex ); | |
112 | event.SetExtraLong( (long) toggleDown); | |
113 | ||
114 | /* | |
c801d85f KB |
115 | wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex); |
116 | event.SetEventObject(this); | |
46dc76ba | 117 | event.SetInt( toolIndex ); |
c801d85f | 118 | event.SetExtraLong((long) toggleDown); |
46dc76ba | 119 | */ |
c801d85f KB |
120 | |
121 | GetEventHandler()->ProcessEvent(event); | |
122 | ||
123 | return TRUE; | |
124 | }; | |
125 | ||
716b7364 | 126 | void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) ) |
c801d85f | 127 | { |
46dc76ba RR |
128 | wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, toolIndex ); |
129 | event.SetEventObject( this ); | |
130 | event.SetInt( toolIndex ); | |
c801d85f KB |
131 | |
132 | GetEventHandler()->ProcessEvent(event); | |
133 | }; | |
134 | ||
716b7364 | 135 | void wxToolBar::OnMouseEnter( int toolIndex ) |
c801d85f KB |
136 | { |
137 | wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); | |
138 | event.SetEventObject(this); | |
46dc76ba | 139 | event.SetInt( toolIndex ); |
c801d85f KB |
140 | |
141 | GetEventHandler()->ProcessEvent(event); | |
142 | }; | |
143 | ||
716b7364 | 144 | wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap, |
debe6624 JS |
145 | const wxBitmap& pushedBitmap, bool toggle, |
146 | float WXUNUSED(xPos), float WXUNUSED(yPos), wxObject *clientData, | |
c801d85f KB |
147 | const wxString& helpString1, const wxString& helpString2 ) |
148 | { | |
149 | if (!bitmap.Ok()) return NULL; | |
150 | ||
151 | wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle, | |
152 | clientData, helpString1, helpString2 ); | |
153 | ||
154 | GdkPixmap *pixmap = bitmap.GetPixmap(); | |
155 | ||
156 | GdkBitmap *mask = NULL; | |
157 | if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap(); | |
158 | ||
159 | GtkWidget *tool_pixmap = gtk_pixmap_new( pixmap, mask ); | |
160 | gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); | |
161 | ||
162 | GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON; | |
163 | if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON; | |
164 | ||
165 | gtk_toolbar_append_element( m_toolbar, | |
166 | ctype, NULL, NULL, helpString1, "", tool_pixmap, (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool ); | |
167 | ||
168 | m_tools.Append( tool ); | |
169 | ||
170 | return tool; | |
171 | }; | |
172 | ||
716b7364 | 173 | void wxToolBar::AddSeparator(void) |
c801d85f KB |
174 | { |
175 | gtk_toolbar_append_space( m_toolbar ); | |
176 | }; | |
177 | ||
716b7364 | 178 | void wxToolBar::ClearTools(void) |
c801d85f KB |
179 | { |
180 | }; | |
181 | ||
46dc76ba RR |
182 | void wxToolBar::Layout(void) |
183 | { | |
184 | m_x = 0; | |
185 | m_y = 0; | |
186 | m_width = 100; | |
187 | m_height = 0; | |
188 | ||
189 | wxNode *node = m_tools.First(); | |
190 | while (node) | |
191 | { | |
192 | wxToolBarTool *tool = (wxToolBarTool*)node->Data(); | |
193 | if (tool->m_bitmap1.Ok()) | |
194 | { | |
195 | int tool_height = tool->m_bitmap1.GetHeight(); | |
196 | if (tool_height > m_height) m_height = tool_height; | |
197 | }; | |
198 | ||
199 | node = node->Next(); | |
200 | }; | |
201 | ||
202 | m_height += 10; | |
203 | }; | |
204 | ||
716b7364 | 205 | void wxToolBar::EnableTool(int toolIndex, bool enable) |
c801d85f KB |
206 | { |
207 | }; | |
208 | ||
716b7364 | 209 | void wxToolBar::ToggleTool(int toolIndex, bool toggle) |
c801d85f KB |
210 | { |
211 | }; | |
212 | ||
716b7364 | 213 | void wxToolBar::SetToggle(int toolIndex, bool toggle) |
c801d85f KB |
214 | { |
215 | }; | |
216 | ||
716b7364 | 217 | wxObject *wxToolBar::GetToolClientData(int index) const |
c801d85f KB |
218 | { |
219 | }; | |
220 | ||
716b7364 | 221 | bool wxToolBar::GetToolState(int toolIndex) const |
c801d85f KB |
222 | { |
223 | }; | |
224 | ||
716b7364 | 225 | bool wxToolBar::GetToolEnabled(int toolIndex) const |
c801d85f KB |
226 | { |
227 | }; | |
228 | ||
716b7364 | 229 | void wxToolBar::SetMargins(int x, int y) |
c801d85f KB |
230 | { |
231 | }; | |
232 | ||
716b7364 | 233 | void wxToolBar::SetToolPacking(int packing) |
c801d85f KB |
234 | { |
235 | }; | |
236 | ||
716b7364 | 237 | void wxToolBar::SetToolSeparation(int separation) |
c801d85f KB |
238 | { |
239 | }; | |
240 |