1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: GTK toolbar
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/control.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 #define wxTOOL_STYLE_BUTTON 1
34 #define wxTOOL_STYLE_SEPARATOR 2
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 extern const char *wxToolBarNameStr
;
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 class wxToolBarTool
: public wxObject
48 DECLARE_DYNAMIC_CLASS(wxToolBarTool
)
52 wxToolBarTool(void) {};
53 wxToolBarTool( wxToolBar
*owner
, int theIndex
= 0,
54 const wxBitmap
& bitmap1
= wxNullBitmap
, const wxBitmap
& bitmap2
= wxNullBitmap
,
55 bool toggle
= FALSE
, wxObject
*clientData
= (wxObject
*) NULL
,
56 const wxString
& shortHelpString
= "", const wxString
& longHelpString
= "",
57 GtkWidget
*item
= (GtkWidget
*) NULL
);
63 wxObject
*m_clientData
;
67 bool m_deleteSecondBitmap
;
72 wxString m_shortHelpString
;
73 wxString m_longHelpString
;
78 //-----------------------------------------------------------------------------
80 //-----------------------------------------------------------------------------
82 class wxToolBar
: public wxControl
84 DECLARE_DYNAMIC_CLASS(wxToolBar
)
89 wxToolBar( wxWindow
*parent
, wxWindowID id
,
90 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
91 long style
= 0, const wxString
& name
= wxToolBarNameStr
);
94 bool Create( wxWindow
*parent
, wxWindowID id
,
95 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
96 long style
= 0, const wxString
& name
= wxToolBarNameStr
);
98 // Only allow toggle if returns TRUE. Call when left button up.
99 virtual bool OnLeftClick(int toolIndex
, bool toggleDown
);
101 // Call when right button down.
102 virtual void OnRightClick(int toolIndex
, float x
, float y
);
104 // Called when the mouse cursor enters a tool bitmap.
105 // Argument is -1 if mouse is exiting the toolbar.
106 virtual void OnMouseEnter(int toolIndex
);
108 // If pushedBitmap is NULL, a reversed version of bitmap is
109 // created and used as the pushed/toggled image.
110 // If toggle is TRUE, the button toggles between the two states.
111 virtual wxToolBarTool
*AddTool( int toolIndex
, const wxBitmap
& bitmap
,
112 const wxBitmap
& pushedBitmap
= wxNullBitmap
, bool toggle
= FALSE
,
113 float xPos
= -1, float yPos
= -1, wxObject
*clientData
= (wxObject
*)NULL
,
114 const wxString
& helpString1
= "", const wxString
& helpString2
= "");
115 virtual void AddSeparator(void);
116 virtual void ClearTools(void);
118 virtual void Realize(void);
120 virtual void EnableTool(int toolIndex
, bool enable
);
121 virtual void ToggleTool(int toolIndex
, bool toggle
); // toggle is TRUE if toggled on
122 virtual wxObject
*GetToolClientData(int index
) const;
124 virtual bool GetToolState(int toolIndex
) const;
125 virtual bool GetToolEnabled(int toolIndex
) const;
127 virtual void SetMargins(int x
, int y
);
128 void SetMargins(const wxSize
& size
) { SetMargins(size
.x
, size
.y
); };
129 virtual void SetToolPacking(int packing
);
130 virtual void SetToolSeparation(int separation
);
134 GtkToolbar
*m_toolbar
;