]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/tbargtk.h
Added wxTolBar::etMargins
[wxWidgets.git] / include / wx / gtk1 / tbargtk.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tbargtk.h
3 // Purpose: GTK toolbar
4 // Author: Robert Roebling
5 // RCS-ID: $Id$
6 // Copyright: (c) Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __TBARGTKH__
11 #define __TBARGTKH__
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "wx/defs.h"
18 #include "wx/control.h"
19
20 //-----------------------------------------------------------------------------
21 // classes
22 //-----------------------------------------------------------------------------
23
24 class wxToolBarTool;
25 class wxToolBar;
26
27 //-----------------------------------------------------------------------------
28 // constants
29 //-----------------------------------------------------------------------------
30
31 #define wxTOOL_STYLE_BUTTON 1
32 #define wxTOOL_STYLE_SEPARATOR 2
33
34 //-----------------------------------------------------------------------------
35 // global data
36 //-----------------------------------------------------------------------------
37
38 extern const char *wxToolBarNameStr;
39
40 //-----------------------------------------------------------------------------
41 // wxToolBarTool
42 //-----------------------------------------------------------------------------
43
44 class wxToolBarTool: public wxObject
45 {
46 DECLARE_DYNAMIC_CLASS(wxToolBarTool)
47
48 public:
49
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 );
56 ~wxToolBarTool(void);
57
58 public:
59
60 int m_toolStyle;
61 wxObject *m_clientData;
62 int m_index;
63 bool m_toggleState;
64 bool m_isToggle;
65 bool m_deleteSecondBitmap;
66 bool m_enabled;
67 wxBitmap m_bitmap1;
68 wxBitmap m_bitmap2;
69 bool m_isMenuCommand;
70 wxString m_shortHelpString;
71 wxString m_longHelpString;
72 wxToolBar *m_owner;
73 GtkWidget *m_item;
74 };
75
76 //-----------------------------------------------------------------------------
77 // wxToolBar
78 //-----------------------------------------------------------------------------
79
80 class wxToolBar: public wxControl
81 {
82 DECLARE_DYNAMIC_CLASS(wxToolBar)
83
84 public:
85
86 wxToolBar(void);
87 wxToolBar( wxWindow *parent, wxWindowID id,
88 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
89 long style = 0, const wxString& name = wxToolBarNameStr );
90 ~wxToolBar(void);
91
92 bool Create( wxWindow *parent, wxWindowID id,
93 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
94 long style = 0, const wxString& name = wxToolBarNameStr);
95
96 // Only allow toggle if returns TRUE. Call when left button up.
97 virtual bool OnLeftClick(int toolIndex, bool toggleDown);
98
99 // Call when right button down.
100 virtual void OnRightClick(int toolIndex, float x, float y);
101
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);
105
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);
115
116 virtual bool Realize(void);
117
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;
121
122 virtual bool GetToolState(int toolIndex) const;
123 virtual bool GetToolEnabled(int toolIndex) const;
124
125 virtual void SetMargins(int x, int y);
126 void SetMargins(const wxSize& size) { SetMargins(size.x, size.y); };
127 virtual wxSize GetToolMargins(void) { return wxSize(m_xMargin, m_yMargin); }
128
129 virtual void SetToolPacking(int packing);
130 virtual void SetToolSeparation(int separation);
131 virtual int GetToolPacking();
132 virtual int GetToolSeparation();
133
134 virtual wxString GetToolLongHelp(int toolIndex);
135 virtual wxString GetToolShortHelp(int toolIndex);
136
137 virtual void SetToolLongHelp(int toolIndex, const wxString& helpString);
138 virtual void SetToolShortHelp(int toolIndex, const wxString& helpString);
139
140 // implementation
141
142 GtkToolbar *m_toolbar;
143 int m_separation;
144 wxList m_tools;
145
146 GdkColor m_fg;
147 GdkColor m_bg;
148 int m_xMargin;
149 int m_yMargin;
150 bool m_hasToolAlready;
151 };
152
153 #endif
154 // __TBARGTKH__
155