]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/tbargtk.cpp
Changed __GTK__, __WINDOWS__ and __MOTIF__ to __WXGTK__, __WXMSW__ and __WXMOTIF__
[wxWidgets.git] / src / gtk1 / tbargtk.cpp
CommitLineData
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
22IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool,wxObject)
23
debe6624
JS
24wxToolBarTool::wxToolBarTool( wxToolBarGTK *owner, int theIndex,
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
43wxToolBarTool::~wxToolBarTool(void)
44{
45};
46
47//-----------------------------------------------------------------------------
48// wxToolBarGTK
49//-----------------------------------------------------------------------------
50
51static 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
62IMPLEMENT_DYNAMIC_CLASS(wxToolBarGTK,wxControl)
63
64BEGIN_EVENT_TABLE(wxToolBarGTK, wxControl)
65END_EVENT_TABLE()
66
67wxToolBarGTK::wxToolBarGTK(void)
68{
69};
70
debe6624 71wxToolBarGTK::wxToolBarGTK( 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
78wxToolBarGTK::~wxToolBarGTK(void)
79{
80};
81
debe6624 82bool wxToolBarGTK::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
107bool wxToolBarGTK::OnLeftClick( int toolIndex, bool toggleDown )
108{
109 wxCommandEvent event(wxEVT_COMMAND_TOOL_CLICKED, toolIndex);
110 event.SetEventObject(this);
111 event.SetExtraLong((long) toggleDown);
112
113 GetEventHandler()->ProcessEvent(event);
114
115 return TRUE;
116};
117
118void wxToolBarGTK::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
119{
120 wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, toolIndex);
121 event.SetEventObject(this);
122
123 GetEventHandler()->ProcessEvent(event);
124};
125
126void wxToolBarGTK::OnMouseEnter( int toolIndex )
127{
128 wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex);
129 event.SetEventObject(this);
130
131 GetEventHandler()->ProcessEvent(event);
132};
133
debe6624
JS
134wxToolBarTool *wxToolBarGTK::AddTool( int toolIndex, const wxBitmap& bitmap,
135 const wxBitmap& pushedBitmap, bool toggle,
136 float WXUNUSED(xPos), float WXUNUSED(yPos), wxObject *clientData,
c801d85f
KB
137 const wxString& helpString1, const wxString& helpString2 )
138{
139 if (!bitmap.Ok()) return NULL;
140
141 wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle,
142 clientData, helpString1, helpString2 );
143
144 GdkPixmap *pixmap = bitmap.GetPixmap();
145
146 GdkBitmap *mask = NULL;
147 if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
148
149 GtkWidget *tool_pixmap = gtk_pixmap_new( pixmap, mask );
150 gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
151
152 GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON;
153 if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
154
155 gtk_toolbar_append_element( m_toolbar,
156 ctype, NULL, NULL, helpString1, "", tool_pixmap, (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
157
158 m_tools.Append( tool );
159
160 return tool;
161};
162
163void wxToolBarGTK::AddSeparator(void)
164{
165 gtk_toolbar_append_space( m_toolbar );
166};
167
168void wxToolBarGTK::ClearTools(void)
169{
170};
171
debe6624 172void wxToolBarGTK::EnableTool(int toolIndex, bool enable)
c801d85f
KB
173{
174};
175
debe6624 176void wxToolBarGTK::ToggleTool(int toolIndex, bool toggle)
c801d85f
KB
177{
178};
179
debe6624 180void wxToolBarGTK::SetToggle(int toolIndex, bool toggle)
c801d85f
KB
181{
182};
183
debe6624 184wxObject *wxToolBarGTK::GetToolClientData(int index) const
c801d85f
KB
185{
186};
187
debe6624 188bool wxToolBarGTK::GetToolState(int toolIndex) const
c801d85f
KB
189{
190};
191
debe6624 192bool wxToolBarGTK::GetToolEnabled(int toolIndex) const
c801d85f
KB
193{
194};
195
debe6624 196void wxToolBarGTK::SetMargins(int x, int y)
c801d85f
KB
197{
198};
199
debe6624 200void wxToolBarGTK::SetToolPacking(int packing)
c801d85f
KB
201{
202};
203
debe6624 204void wxToolBarGTK::SetToolSeparation(int separation)
c801d85f
KB
205{
206};
207