1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: GTK toolbar
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "tbargtk.h"
16 #include "wx/toolbar.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool
,wxObject
)
24 wxToolBarTool::wxToolBarTool( wxToolBar
*owner
, int theIndex
,
25 const wxBitmap
& bitmap1
, const wxBitmap
& bitmap2
,
26 bool toggle
, wxObject
*clientData
,
27 const wxString
& shortHelpString
, const wxString
& longHelpString
)
35 m_toggleState
= FALSE
;
36 m_shortHelpString
= shortHelpString
;
37 m_longHelpString
= longHelpString
;
38 m_isMenuCommand
= TRUE
;
39 m_clientData
= clientData
;
40 m_deleteSecondBitmap
= FALSE
;
43 wxToolBarTool::~wxToolBarTool(void)
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
,wxControl
)
53 BEGIN_EVENT_TABLE(wxToolBar
, wxControl
)
56 wxToolBar::wxToolBar(void)
60 wxToolBar::wxToolBar( wxWindow
*parent
, wxWindowID id
,
61 const wxPoint
& pos
, const wxSize
& size
,
62 long style
, const wxString
& name
)
64 Create( parent
, id
, pos
, size
, style
, name
);
67 wxToolBar::~wxToolBar(void)
71 bool wxToolBar::Create( wxWindow
*parent
, wxWindowID id
,
72 const wxPoint
& pos
, const wxSize
& size
,
73 long style
, const wxString
& name
)
78 bool wxToolBar::OnLeftClick( int toolIndex
, bool toggleDown
)
80 wxCommandEvent
event( wxEVT_COMMAND_TOOL_CLICKED
, toolIndex
);
81 event
.SetEventObject(this);
82 event
.SetInt( toolIndex
);
83 event
.SetExtraLong((long) toggleDown
);
85 GetEventHandler()->ProcessEvent(event
);
90 void wxToolBar::OnRightClick( int toolIndex
, float WXUNUSED(x
), float WXUNUSED(y
) )
92 wxCommandEvent
event( wxEVT_COMMAND_TOOL_RCLICKED
, toolIndex
);
93 event
.SetEventObject( this );
94 event
.SetInt( toolIndex
);
96 GetEventHandler()->ProcessEvent(event
);
99 void wxToolBar::OnMouseEnter( int toolIndex
)
101 wxCommandEvent
event( wxEVT_COMMAND_TOOL_ENTER
, toolIndex
);
102 event
.SetEventObject(this);
103 event
.SetInt( toolIndex
);
105 GetEventHandler()->ProcessEvent(event
);
108 wxToolBarTool
*wxToolBar::AddTool( int toolIndex
, const wxBitmap
& bitmap
,
109 const wxBitmap
& pushedBitmap
, bool toggle
,
110 float WXUNUSED(xPos
), float WXUNUSED(yPos
), wxObject
*clientData
,
111 const wxString
& helpString1
, const wxString
& helpString2
)
115 void wxToolBar::AddSeparator(void)
119 void wxToolBar::ClearTools(void)
123 void wxToolBar::Realize(void)
127 void wxToolBar::EnableTool(int toolIndex
, bool enable
)
129 wxNode
*node
= m_tools
.First();
132 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
133 if (tool
->m_index
== toolIndex
)
135 tool
->m_enabled
= enable
;
142 void wxToolBar::ToggleTool(int WXUNUSED(toolIndex
), bool WXUNUSED(toggle
) )
146 wxObject
*wxToolBar::GetToolClientData(int index
) const
148 wxNode
*node
= m_tools
.First();
151 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
152 if (tool
->m_index
== index
) return tool
->m_clientData
;;
155 return (wxObject
*)NULL
;
158 bool wxToolBar::GetToolState(int toolIndex
) const
160 wxNode
*node
= m_tools
.First();
163 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
164 if (tool
->m_index
== toolIndex
) return tool
->m_toggleState
;
170 bool wxToolBar::GetToolEnabled(int toolIndex
) const
172 wxNode
*node
= m_tools
.First();
175 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
176 if (tool
->m_index
== toolIndex
) return tool
->m_enabled
;
182 void wxToolBar::SetMargins( int WXUNUSED(x
), int WXUNUSED(y
) )
186 void wxToolBar::SetToolPacking( int WXUNUSED(packing
) )
190 void wxToolBar::SetToolSeparation( int separation
)