]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | #if wxUSE_TOOLBAR | |
20 | ||
21 | #include "wx/control.h" | |
22 | #include "wx/bitmap.h" | |
23 | #include "wx/tbarbase.h" | |
24 | ||
25 | //----------------------------------------------------------------------------- | |
26 | // classes | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
29 | class wxToolBarTool; | |
30 | class wxToolBar; | |
31 | ||
32 | //----------------------------------------------------------------------------- | |
33 | // constants | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | #define wxTOOL_STYLE_BUTTON 1 | |
37 | #define wxTOOL_STYLE_SEPARATOR 2 | |
38 | ||
39 | //----------------------------------------------------------------------------- | |
40 | // global data | |
41 | //----------------------------------------------------------------------------- | |
42 | ||
43 | extern const wxChar *wxToolBarNameStr; | |
44 | ||
45 | //----------------------------------------------------------------------------- | |
46 | // wxToolBar | |
47 | //----------------------------------------------------------------------------- | |
48 | ||
49 | class wxToolBar: public wxControl | |
50 | { | |
51 | public: | |
52 | wxToolBar(); | |
53 | wxToolBar( wxWindow *parent, wxWindowID id, | |
54 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
55 | long style = 0, const wxString& name = wxToolBarNameStr ); | |
56 | ~wxToolBar(); | |
57 | ||
58 | bool Create( wxWindow *parent, wxWindowID id, | |
59 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
60 | long style = 0, const wxString& name = wxToolBarNameStr); | |
61 | ||
62 | // Only allow toggle if returns TRUE. Call when left button up. | |
63 | virtual bool OnLeftClick(int toolIndex, bool toggleDown); | |
64 | ||
65 | // Call when right button down. | |
66 | virtual void OnRightClick(int toolIndex, float x, float y); | |
67 | ||
68 | // Called when the mouse cursor enters a tool bitmap. | |
69 | // Argument is -1 if mouse is exiting the toolbar. | |
70 | virtual void OnMouseEnter(int toolIndex); | |
71 | ||
72 | // If pushedBitmap is NULL, a reversed version of bitmap is | |
73 | // created and used as the pushed/toggled image. | |
74 | // If toggle is TRUE, the button toggles between the two states. | |
75 | virtual wxToolBarTool *AddTool( int toolIndex, const wxBitmap& bitmap, | |
76 | const wxBitmap& pushedBitmap = wxNullBitmap, bool toggle = FALSE, | |
77 | wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = (wxObject *)NULL, | |
78 | const wxString& helpString1 = "", const wxString& helpString2 = ""); | |
79 | ||
80 | // Add arbitrary control | |
81 | virtual bool AddControl(wxControl *control); | |
82 | ||
83 | // Add space | |
84 | virtual void AddSeparator(); | |
85 | ||
86 | virtual void ClearTools(); | |
87 | ||
88 | virtual bool Realize(); | |
89 | ||
90 | virtual void EnableTool(int toolIndex, bool enable); | |
91 | virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on | |
92 | virtual wxObject *GetToolClientData(int index) const; | |
93 | ||
94 | virtual bool GetToolState(int toolIndex) const; | |
95 | virtual bool GetToolEnabled(int toolIndex) const; | |
96 | ||
97 | virtual void SetMargins(int x, int y); | |
98 | void SetMargins(const wxSize& size) { SetMargins(size.x, size.y); }; | |
99 | virtual wxSize GetToolMargins(void) { return wxSize(m_xMargin, m_yMargin); } | |
100 | ||
101 | virtual void SetToolPacking(int packing); | |
102 | virtual void SetToolSeparation(int separation); | |
103 | virtual int GetToolPacking(); | |
104 | virtual int GetToolSeparation(); | |
105 | ||
106 | virtual wxString GetToolLongHelp(int toolIndex); | |
107 | virtual wxString GetToolShortHelp(int toolIndex); | |
108 | ||
109 | virtual void SetToolLongHelp(int toolIndex, const wxString& helpString); | |
110 | virtual void SetToolShortHelp(int toolIndex, const wxString& helpString); | |
111 | ||
112 | void OnIdle( wxIdleEvent &ievent ); | |
113 | ||
114 | // implementation | |
115 | ||
116 | GtkToolbar *m_toolbar; | |
117 | int m_separation; | |
118 | wxList m_tools; | |
119 | ||
120 | GdkColor *m_fg; | |
121 | GdkColor *m_bg; | |
122 | int m_xMargin; | |
123 | int m_yMargin; | |
124 | bool m_hasToolAlready; | |
125 | bool m_blockNextEvent; | |
126 | ||
127 | void OnInternalIdle(); | |
128 | ||
129 | private: | |
130 | DECLARE_EVENT_TABLE() | |
131 | DECLARE_DYNAMIC_CLASS(wxToolBar) | |
132 | }; | |
133 | ||
134 | #endif | |
135 | ||
136 | #endif | |
137 | // __TBARGTKH__ |