git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@522
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxToolBarTool( wxToolBar *owner, int theIndex = 0,
const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, wxObject *clientData = NULL,
wxToolBarTool( wxToolBar *owner, int theIndex = 0,
const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, wxObject *clientData = NULL,
- const wxString& shortHelpString = "", const wxString& longHelpString = "");
+ const wxString& shortHelpString = "", const wxString& longHelpString = "",
+ GtkWidget *item = NULL );
~wxToolBarTool(void);
public:
~wxToolBarTool(void);
public:
wxString m_shortHelpString;
wxString m_longHelpString;
wxToolBar *m_owner;
wxString m_shortHelpString;
wxString m_longHelpString;
wxToolBar *m_owner;
};
//-----------------------------------------------------------------------------
};
//-----------------------------------------------------------------------------
wxToolBarTool( wxToolBar *owner, int theIndex = 0,
const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, wxObject *clientData = NULL,
wxToolBarTool( wxToolBar *owner, int theIndex = 0,
const wxBitmap& bitmap1 = wxNullBitmap, const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE, wxObject *clientData = NULL,
- const wxString& shortHelpString = "", const wxString& longHelpString = "");
+ const wxString& shortHelpString = "", const wxString& longHelpString = "",
+ GtkWidget *item = NULL );
~wxToolBarTool(void);
public:
~wxToolBarTool(void);
public:
wxString m_shortHelpString;
wxString m_longHelpString;
wxToolBar *m_owner;
wxString m_shortHelpString;
wxString m_longHelpString;
wxToolBar *m_owner;
};
//-----------------------------------------------------------------------------
};
//-----------------------------------------------------------------------------
wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex,
const wxBitmap& bitmap1, const wxBitmap& bitmap2,
bool toggle, wxObject *clientData,
wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex,
const wxBitmap& bitmap1, const wxBitmap& bitmap2,
bool toggle, wxObject *clientData,
- const wxString& shortHelpString, const wxString& longHelpString )
+ const wxString& shortHelpString, const wxString& longHelpString,
+ GtkWidget *item )
{
m_owner = owner;
m_index = theIndex;
{
m_owner = owner;
m_index = theIndex;
m_isMenuCommand = TRUE;
m_clientData = clientData;
m_deleteSecondBitmap = FALSE;
m_isMenuCommand = TRUE;
m_clientData = clientData;
m_deleteSecondBitmap = FALSE;
wxToolBarTool::~wxToolBarTool()
{
wxToolBarTool::~wxToolBarTool()
{
//-----------------------------------------------------------------------------
// wxToolBar
//-----------------------------------------------------------------------------
// wxToolBar
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, pos, size, style, name );
wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, pos, size, style, name );
wxToolBar::~wxToolBar()
{
wxToolBar::~wxToolBar()
{
bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
Show( TRUE );
return TRUE;
Show( TRUE );
return TRUE;
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{
GetEventHandler()->ProcessEvent(event);
return TRUE;
GetEventHandler()->ProcessEvent(event);
return TRUE;
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
void wxToolBar::OnMouseEnter( int toolIndex )
{
void wxToolBar::OnMouseEnter( int toolIndex )
{
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap, bool toggle,
wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap, bool toggle,
if (!bitmap.Ok()) return NULL;
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle,
if (!bitmap.Ok()) return NULL;
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle,
- clientData, helpString1, helpString2 );
+ clientData, helpString1, helpString2 );
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkPixmap *pixmap = bitmap.GetPixmap();
GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON;
if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON;
if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
- gtk_toolbar_append_element( m_toolbar,
- ctype, NULL, NULL, helpString1, "", tool_pixmap, (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
+ tool->m_item = gtk_toolbar_append_element( m_toolbar, ctype, NULL, NULL, helpString1, "", tool_pixmap,
+ (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
m_tools.Append( tool );
return tool;
m_tools.Append( tool );
return tool;
void wxToolBar::AddSeparator(void)
{
gtk_toolbar_append_space( m_toolbar );
void wxToolBar::AddSeparator(void)
{
gtk_toolbar_append_space( m_toolbar );
void wxToolBar::ClearTools(void)
{
void wxToolBar::ClearTools(void)
{
- wxFAIL_MSG(_("wxToolBar::ClearTools not implemented"));
-};
+ wxFAIL_MSG( "wxToolBar::ClearTools not implemented" );
+}
void wxToolBar::Realize(void)
{
void wxToolBar::Realize(void)
{
{
int tool_height = tool->m_bitmap1.GetHeight();
if (tool_height > m_height) m_height = tool_height;
{
int tool_height = tool->m_bitmap1.GetHeight();
if (tool_height > m_height) m_height = tool_height;
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
return;
}
node = node->Next();
return;
}
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+}
-void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
+void wxToolBar::ToggleTool( int toolIndex, bool toggle )
- wxFAIL_MSG(_("wxToolBar::ToggleTool not implemented"));
-};
+ wxNode *node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool*)node->Data();
+ if (tool->m_index == toolIndex)
+ {
+ tool->m_toggleState = toggle;
+ if ((tool->m_item) && (GTK_IS_TOGGLE_BUTTON(tool->m_item)))
+ gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(tool->m_item), toggle );
+ return;
+ }
+ node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+}
-wxObject *wxToolBar::GetToolClientData(int index) const
+wxObject *wxToolBar::GetToolClientData( int index ) const
{
wxNode *node = m_tools.First();
while (node)
{
wxNode *node = m_tools.First();
while (node)
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
bool wxToolBar::GetToolState(int toolIndex) const
{
bool wxToolBar::GetToolState(int toolIndex) const
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
bool wxToolBar::GetToolEnabled(int toolIndex) const
{
bool wxToolBar::GetToolEnabled(int toolIndex) const
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{
void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{
void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{
void wxToolBar::SetToolSeparation( int separation )
{
gtk_toolbar_set_space_size( m_toolbar, separation );
void wxToolBar::SetToolSeparation( int separation )
{
gtk_toolbar_set_space_size( m_toolbar, separation );
wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex,
const wxBitmap& bitmap1, const wxBitmap& bitmap2,
bool toggle, wxObject *clientData,
wxToolBarTool::wxToolBarTool( wxToolBar *owner, int theIndex,
const wxBitmap& bitmap1, const wxBitmap& bitmap2,
bool toggle, wxObject *clientData,
- const wxString& shortHelpString, const wxString& longHelpString )
+ const wxString& shortHelpString, const wxString& longHelpString,
+ GtkWidget *item )
{
m_owner = owner;
m_index = theIndex;
{
m_owner = owner;
m_index = theIndex;
m_isMenuCommand = TRUE;
m_clientData = clientData;
m_deleteSecondBitmap = FALSE;
m_isMenuCommand = TRUE;
m_clientData = clientData;
m_deleteSecondBitmap = FALSE;
wxToolBarTool::~wxToolBarTool()
{
wxToolBarTool::~wxToolBarTool()
{
//-----------------------------------------------------------------------------
// wxToolBar
//-----------------------------------------------------------------------------
// wxToolBar
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
if (tool->m_isToggle) tool->m_toggleState = !tool->m_toggleState;
tool->m_owner->OnLeftClick( tool->m_index, tool->m_toggleState );
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, pos, size, style, name );
wxToolBar::wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, pos, size, style, name );
wxToolBar::~wxToolBar()
{
wxToolBar::~wxToolBar()
{
bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
Show( TRUE );
return TRUE;
Show( TRUE );
return TRUE;
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{
bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
{
GetEventHandler()->ProcessEvent(event);
return TRUE;
GetEventHandler()->ProcessEvent(event);
return TRUE;
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{
void wxToolBar::OnRightClick( int toolIndex, float WXUNUSED(x), float WXUNUSED(y) )
{
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
void wxToolBar::OnMouseEnter( int toolIndex )
{
void wxToolBar::OnMouseEnter( int toolIndex )
{
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
event.SetInt( toolIndex );
GetEventHandler()->ProcessEvent(event);
wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap, bool toggle,
wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap, bool toggle,
if (!bitmap.Ok()) return NULL;
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle,
if (!bitmap.Ok()) return NULL;
wxToolBarTool *tool = new wxToolBarTool( this, toolIndex, bitmap, pushedBitmap, toggle,
- clientData, helpString1, helpString2 );
+ clientData, helpString1, helpString2 );
GdkPixmap *pixmap = bitmap.GetPixmap();
GdkPixmap *pixmap = bitmap.GetPixmap();
GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON;
if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
GtkToolbarChildType ctype = GTK_TOOLBAR_CHILD_BUTTON;
if (toggle) ctype = GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
- gtk_toolbar_append_element( m_toolbar,
- ctype, NULL, NULL, helpString1, "", tool_pixmap, (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
+ tool->m_item = gtk_toolbar_append_element( m_toolbar, ctype, NULL, NULL, helpString1, "", tool_pixmap,
+ (GtkSignalFunc)gtk_toolbar_callback, (gpointer)tool );
m_tools.Append( tool );
return tool;
m_tools.Append( tool );
return tool;
void wxToolBar::AddSeparator(void)
{
gtk_toolbar_append_space( m_toolbar );
void wxToolBar::AddSeparator(void)
{
gtk_toolbar_append_space( m_toolbar );
void wxToolBar::ClearTools(void)
{
void wxToolBar::ClearTools(void)
{
- wxFAIL_MSG(_("wxToolBar::ClearTools not implemented"));
-};
+ wxFAIL_MSG( "wxToolBar::ClearTools not implemented" );
+}
void wxToolBar::Realize(void)
{
void wxToolBar::Realize(void)
{
{
int tool_height = tool->m_bitmap1.GetHeight();
if (tool_height > m_height) m_height = tool_height;
{
int tool_height = tool->m_bitmap1.GetHeight();
if (tool_height > m_height) m_height = tool_height;
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
return;
}
node = node->Next();
return;
}
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+}
-void wxToolBar::ToggleTool(int WXUNUSED(toolIndex), bool WXUNUSED(toggle) )
+void wxToolBar::ToggleTool( int toolIndex, bool toggle )
- wxFAIL_MSG(_("wxToolBar::ToggleTool not implemented"));
-};
+ wxNode *node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool*)node->Data();
+ if (tool->m_index == toolIndex)
+ {
+ tool->m_toggleState = toggle;
+ if ((tool->m_item) && (GTK_IS_TOGGLE_BUTTON(tool->m_item)))
+ gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(tool->m_item), toggle );
+ return;
+ }
+ node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+}
-wxObject *wxToolBar::GetToolClientData(int index) const
+wxObject *wxToolBar::GetToolClientData( int index ) const
{
wxNode *node = m_tools.First();
while (node)
{
wxNode *node = m_tools.First();
while (node)
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == index) return tool->m_clientData;;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
bool wxToolBar::GetToolState(int toolIndex) const
{
bool wxToolBar::GetToolState(int toolIndex) const
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_toggleState;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
bool wxToolBar::GetToolEnabled(int toolIndex) const
{
bool wxToolBar::GetToolEnabled(int toolIndex) const
{
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
if (tool->m_index == toolIndex) return tool->m_enabled;
node = node->Next();
+ }
+
+ wxFAIL_MSG( "wrong toolbar index" );
+
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{
void wxToolBar::SetMargins( int WXUNUSED(x), int WXUNUSED(y) )
{
void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{
void wxToolBar::SetToolPacking( int WXUNUSED(packing) )
{
void wxToolBar::SetToolSeparation( int separation )
{
gtk_toolbar_set_space_size( m_toolbar, separation );
void wxToolBar::SetToolSeparation( int separation )
{
gtk_toolbar_set_space_size( m_toolbar, separation );