]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/tbargtk.cpp
New wxEventType for event type enum, and corresponding alterations.
[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
24wxToolBarTool::wxToolBarTool( wxToolBarGTK *owner, const int theIndex,
25 const wxBitmap& bitmap1, const wxBitmap& bitmap2,
26 const bool toggle, wxObject *clientData,
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
71wxToolBarGTK::wxToolBarGTK( wxWindow *parent, const wxWindowID id,
72 const wxPoint& pos, const wxSize& size,
73 const long style, const wxString& name )
74{
75 Create( parent, id, pos, size, style, name );
76};
77
78wxToolBarGTK::~wxToolBarGTK(void)
79{
80};
81
82bool wxToolBarGTK::Create( wxWindow *parent, const wxWindowID id,
83 const wxPoint& pos, const wxSize& size,
84 const long style, const wxString& name )
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
134wxToolBarTool *wxToolBarGTK::AddTool( const int toolIndex, const wxBitmap& bitmap,
135 const wxBitmap& pushedBitmap, const bool toggle,
136 const float WXUNUSED(xPos), const float WXUNUSED(yPos), wxObject *clientData,
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
172void wxToolBarGTK::EnableTool(const int toolIndex, const bool enable)
173{
174};
175
176void wxToolBarGTK::ToggleTool(const int toolIndex, const bool toggle)
177{
178};
179
180void wxToolBarGTK::SetToggle(const int toolIndex, const bool toggle)
181{
182};
183
184wxObject *wxToolBarGTK::GetToolClientData(const int index) const
185{
186};
187
188bool wxToolBarGTK::GetToolState(const int toolIndex) const
189{
190};
191
192bool wxToolBarGTK::GetToolEnabled(const int toolIndex) const
193{
194};
195
196void wxToolBarGTK::SetMargins(const int x, const int y)
197{
198};
199
200void wxToolBarGTK::SetToolPacking(const int packing)
201{
202};
203
204void wxToolBarGTK::SetToolSeparation(const int separation)
205{
206};
207