1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: GTK toolbar
4 // Author: Robert Roebling
6 // Copyright: (c) Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
18 #include "wx/control.h"
19 #include "wx/bitmap.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
32 #define wxTOOL_STYLE_BUTTON 1
33 #define wxTOOL_STYLE_SEPARATOR 2
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 extern const char *wxToolBarNameStr
;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 class wxToolBarTool
: public wxObject
47 DECLARE_DYNAMIC_CLASS(wxToolBarTool
)
51 wxToolBarTool(void) {};
52 wxToolBarTool( wxToolBar
*owner
, int theIndex
= 0,
53 const wxBitmap
& bitmap1
= wxNullBitmap
, const wxBitmap
& bitmap2
= wxNullBitmap
,
54 bool toggle
= FALSE
, wxObject
*clientData
= (wxObject
*) NULL
,
55 const wxString
& shortHelpString
= "", const wxString
& longHelpString
= "",
56 GtkWidget
*item
= (GtkWidget
*) NULL
);
62 wxObject
*m_clientData
;
66 bool m_deleteSecondBitmap
;
71 wxString m_shortHelpString
;
72 wxString m_longHelpString
;
77 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
81 class wxToolBar
: public wxControl
83 DECLARE_DYNAMIC_CLASS(wxToolBar
)
88 wxToolBar( wxWindow
*parent
, wxWindowID id
,
89 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
90 long style
= 0, const wxString
& name
= wxToolBarNameStr
);
93 bool Create( wxWindow
*parent
, wxWindowID id
,
94 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
95 long style
= 0, const wxString
& name
= wxToolBarNameStr
);
97 // Only allow toggle if returns TRUE. Call when left button up.
98 virtual bool OnLeftClick(int toolIndex
, bool toggleDown
);
100 // Call when right button down.
101 virtual void OnRightClick(int toolIndex
, float x
, float y
);
103 // Called when the mouse cursor enters a tool bitmap.
104 // Argument is -1 if mouse is exiting the toolbar.
105 virtual void OnMouseEnter(int toolIndex
);
107 // If pushedBitmap is NULL, a reversed version of bitmap is
108 // created and used as the pushed/toggled image.
109 // If toggle is TRUE, the button toggles between the two states.
110 virtual wxToolBarTool
*AddTool( int toolIndex
, const wxBitmap
& bitmap
,
111 const wxBitmap
& pushedBitmap
= wxNullBitmap
, bool toggle
= FALSE
,
112 float xPos
= -1, float yPos
= -1, wxObject
*clientData
= (wxObject
*)NULL
,
113 const wxString
& helpString1
= "", const wxString
& helpString2
= "");
114 virtual void AddSeparator(void);
115 virtual void ClearTools(void);
117 virtual bool Realize(void);
119 virtual void EnableTool(int toolIndex
, bool enable
);
120 virtual void ToggleTool(int toolIndex
, bool toggle
); // toggle is TRUE if toggled on
121 virtual wxObject
*GetToolClientData(int index
) const;
123 virtual bool GetToolState(int toolIndex
) const;
124 virtual bool GetToolEnabled(int toolIndex
) const;
126 virtual void SetMargins(int x
, int y
);
127 void SetMargins(const wxSize
& size
) { SetMargins(size
.x
, size
.y
); };
128 virtual wxSize
GetToolMargins(void) { return wxSize(m_xMargin
, m_yMargin
); }
130 virtual void SetToolPacking(int packing
);
131 virtual void SetToolSeparation(int separation
);
132 virtual int GetToolPacking();
133 virtual int GetToolSeparation();
135 virtual wxString
GetToolLongHelp(int toolIndex
);
136 virtual wxString
GetToolShortHelp(int toolIndex
);
138 virtual void SetToolLongHelp(int toolIndex
, const wxString
& helpString
);
139 virtual void SetToolShortHelp(int toolIndex
, const wxString
& helpString
);
143 GtkToolbar
*m_toolbar
;
151 bool m_hasToolAlready
;