X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3cbab64109b007fa1d939fe588f5e79f9105b915..e558f9533e5e628efef8027b2434c00f3d4ed8cf:/src/gtk1/tbargtk.cpp diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index b81c5c77ec..be2f5ff3c6 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: tbargtk.cpp +// Name: src/gtk1/tbargtk.cpp // Purpose: GTK toolbar // Author: Robert Roebling // Modified: 13.12.99 by VZ to derive from wxToolBarBase @@ -19,11 +19,13 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/toolbar.h" - #if wxUSE_TOOLBAR_NATIVE -#include "wx/frame.h" +#include "wx/toolbar.h" + +#ifndef WX_PRECOMP + #include "wx/frame.h" +#endif #include #include "wx/gtk1/private.h" @@ -86,8 +88,8 @@ public: Init(); } - wxToolBarTool(wxToolBar *tbar, wxControl *control) - : wxToolBarToolBase(tbar, control) + wxToolBarTool(wxToolBar *tbar, wxControl *control, const wxString& label) + : wxToolBarToolBase(tbar, control, label) { Init(); } @@ -110,7 +112,7 @@ public: return GTK_TOOLBAR_CHILD_RADIOBUTTON; default: - wxFAIL_MSG( _T("unknown toolbar child type") ); + wxFAIL_MSG( wxT("unknown toolbar child type") ); // fall through case wxITEM_NORMAL: @@ -123,7 +125,7 @@ public: if (bitmap.Ok()) { GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() - : (GdkBitmap *)NULL; + : NULL; gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask ); } } @@ -228,7 +230,7 @@ static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent), void wxToolBarTool::Init() { m_item = - m_pixmap = (GtkWidget *)NULL; + m_pixmap = NULL; } wxToolBarToolBase *wxToolBar::CreateTool(int id, @@ -244,9 +246,10 @@ wxToolBarToolBase *wxToolBar::CreateTool(int id, clientData, shortHelpString, longHelpString); } -wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) +wxToolBarToolBase * +wxToolBar::CreateTool(wxControl *control, const wxString& label) { - return new wxToolBarTool(this, control); + return new wxToolBarTool(this, control, label); } //----------------------------------------------------------------------------- @@ -255,7 +258,7 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) void wxToolBar::Init() { - m_toolbar = (GtkToolbar *)NULL; + m_toolbar = NULL; m_blockEvent = false; m_defaultWidth = 32; m_defaultHeight = 32; @@ -283,6 +286,8 @@ bool wxToolBar::Create( wxWindow *parent, return false; } + FixupStyle(); + GtkOrientation orient; GtkToolbarStyle gtkStyle; GetGtkStyle(style, &orient, >kStyle); @@ -361,11 +366,11 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) wxCHECK_MSG( bitmap.GetPixmap() != NULL, false, wxT("wxToolBar::Add needs a wxBitmap") ); - GtkWidget *tool_pixmap = (GtkWidget *)NULL; + GtkWidget *tool_pixmap = NULL; GdkPixmap *pixmap = bitmap.GetPixmap(); - GdkBitmap *mask = (GdkBitmap *)NULL; + GdkBitmap *mask = NULL; if ( bitmap.GetMask() ) mask = bitmap.GetMask()->GetBitmap(); @@ -434,7 +439,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) if ( !tool->m_item ) { - wxFAIL_MSG( _T("gtk_toolbar_insert_element() failed") ); + wxFAIL_MSG( wxT("gtk_toolbar_insert_element() failed") ); return false; } @@ -477,19 +482,26 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) return true; } -bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *toolBase) +bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) { wxToolBarTool *tool = (wxToolBarTool *)toolBase; switch ( tool->GetStyle() ) { case wxTOOL_STYLE_CONTROL: - tool->GetControl()->Destroy(); + // don't destroy the control here as we can be called from + // RemoveTool() and then we need to keep the control alive; + // while if we're called from DeleteTool() the control will + // be destroyed when wxToolBarToolBase itself is deleted break; case wxTOOL_STYLE_BUTTON: gtk_widget_destroy( tool->m_item ); break; + + default: + wxFAIL_MSG( "unknown tool style" ); + return false; } InvalidateBestSize(); @@ -531,7 +543,7 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool), bool WXUNUSED(toggle)) { // VZ: absolutely no idea about how to do it - wxFAIL_MSG( _T("not implemented") ); + wxFAIL_MSG( wxT("not implemented") ); } // ---------------------------------------------------------------------------- @@ -542,9 +554,9 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) const { // VZ: GTK+ doesn't seem to have such thing - wxFAIL_MSG( _T("wxToolBar::FindToolForPosition() not implemented") ); + wxFAIL_MSG( wxT("wxToolBar::FindToolForPosition() not implemented") ); - return (wxToolBarToolBase *)NULL; + return NULL; } void wxToolBar::SetMargins( int x, int y )