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