]>
Commit | Line | Data |
---|---|---|
8e08b761 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4cbc57f0 JS |
2 | // Name: newbmpbtn.h |
3 | // Purpose: wxNewBitmapButton header. | |
8e08b761 JS |
4 | // Author: Aleksandras Gluchovas |
5 | // Modified by: | |
6 | // Created: ??/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
4cbc57f0 | 9 | // Licence: wxWindows licence |
8e08b761 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __NEWBMPBTN_G__ | |
13 | #define __NEWBMPBTN_G__ | |
14 | ||
ab7ce33c | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
8e08b761 JS |
16 | #pragma interface "newbmpbtn.h" |
17 | #endif | |
18 | ||
19 | #include "wx/button.h" | |
20 | #include "wx/string.h" | |
2b5f62a0 | 21 | #include "wx/fl/fldefs.h" |
8e08b761 | 22 | |
65e50848 JS |
23 | // defaults |
24 | #define NB_DEFAULT_MARGIN 2 | |
25 | ||
4cbc57f0 | 26 | // button label-text alignment types |
8e08b761 JS |
27 | |
28 | #define NB_ALIGN_TEXT_RIGHT 0 | |
29 | #define NB_ALIGN_TEXT_BOTTOM 1 | |
30 | #define NB_NO_TEXT 2 | |
31 | #define NB_NO_IMAGE 3 | |
32 | ||
33 | // classes declared in this header file | |
34 | ||
510b9edb VS |
35 | class WXDLLIMPEXP_FL wxNewBitmapButton; |
36 | class WXDLLIMPEXP_FL wxBorderLessBitmapButton; | |
8e08b761 | 37 | |
4cbc57f0 JS |
38 | /* |
39 | This is an alternative class to wxBitmapButton. It is used | |
40 | in the implementation of dynamic toolbars. | |
41 | */ | |
8e08b761 JS |
42 | |
43 | class wxNewBitmapButton: public wxPanel | |
44 | { | |
4cbc57f0 | 45 | DECLARE_DYNAMIC_CLASS(wxNewBitmapButton) |
8e08b761 JS |
46 | |
47 | protected: | |
48 | ||
4cbc57f0 | 49 | friend class wxNewBitmapButtonSerializer; |
8e08b761 | 50 | |
4cbc57f0 JS |
51 | int mTextToLabelGap; |
52 | int mMarginX; | |
53 | int mMarginY; | |
54 | int mTextAlignment; | |
55 | bool mIsSticky; | |
56 | bool mIsFlat; | |
8e08b761 | 57 | |
4cbc57f0 JS |
58 | wxString mLabelText; |
59 | wxString mImageFileName; | |
60 | wxBitmapType mImageFileType; | |
8e08b761 | 61 | |
4cbc57f0 JS |
62 | wxBitmap mDepressedBmp; // source image for rendering |
63 | // labels for particular state | |
8e08b761 | 64 | |
4cbc57f0 | 65 | wxBitmap mFocusedBmp; // may not be always present - |
c82c42d4 | 66 | // only if mHasFocusedBmp is true |
8e08b761 | 67 | |
4cbc57f0 JS |
68 | wxBitmap* mpDepressedImg; |
69 | wxBitmap* mpPressedImg; | |
70 | wxBitmap* mpDisabledImg; | |
71 | wxBitmap* mpFocusedImg; | |
8e08b761 | 72 | |
4cbc57f0 JS |
73 | // button state variables; |
74 | bool mDragStarted; | |
75 | bool mIsPressed; | |
76 | bool mIsInFocus; | |
ab839dff | 77 | bool mIsToggled; |
8e08b761 | 78 | |
4cbc57f0 | 79 | bool mHasFocusedBmp; |
8e08b761 | 80 | |
4cbc57f0 JS |
81 | // type of event which is fired upon depression of this button |
82 | int mFiredEventType; | |
8e08b761 | 83 | |
4cbc57f0 JS |
84 | // pens for drawing decorations (borders) |
85 | wxPen mBlackPen; | |
86 | wxPen mDarkPen; | |
87 | wxPen mGrayPen; | |
88 | wxPen mLightPen; | |
8e08b761 | 89 | |
4cbc57f0 JS |
90 | bool mIsCreated; |
91 | int mSizeIsSet; | |
8e08b761 JS |
92 | |
93 | protected: | |
8e08b761 | 94 | |
4cbc57f0 JS |
95 | // Internal function for destroying labels. |
96 | void DestroyLabels(); | |
8e08b761 | 97 | |
4cbc57f0 JS |
98 | // Returns the label that matches the current button state. |
99 | virtual wxBitmap* GetStateLabel(); | |
8e08b761 | 100 | |
4cbc57f0 JS |
101 | // Draws shading on the button. |
102 | virtual void DrawShade( int outerLevel, | |
103 | wxDC& dc, | |
104 | wxPen& upperLeftSidePen, | |
105 | wxPen& lowerRightSidePen ); | |
106 | ||
c82c42d4 | 107 | // Returns true if the given point is in the window. |
4cbc57f0 | 108 | bool IsInWindow( int x, int y ); |
8e08b761 | 109 | |
ab839dff JS |
110 | virtual void OnIdle(wxIdleEvent& event); |
111 | // (EVT_UPDATE_UI handler) | |
112 | virtual void DoButtonUpdate(); | |
113 | ||
8e08b761 JS |
114 | public: |
115 | ||
4cbc57f0 JS |
116 | // Constructor. |
117 | wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap, | |
873a543b | 118 | const wxString& labelText = wxT(""), |
4cbc57f0 | 119 | int alignText = NB_ALIGN_TEXT_BOTTOM, |
c82c42d4 | 120 | bool isFlat = true, |
4cbc57f0 JS |
121 | // this is the default type of fired events |
122 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
65e50848 JS |
123 | int marginX = NB_DEFAULT_MARGIN, |
124 | int marginY = NB_DEFAULT_MARGIN, | |
4cbc57f0 | 125 | int textToLabelGap = 2, |
c82c42d4 | 126 | bool isSticky = false |
4cbc57f0 JS |
127 | ); |
128 | ||
129 | // Use this constructor if buttons have to be persistant | |
130 | wxNewBitmapButton( const wxString& bitmapFileName, | |
52b5ab7e | 131 | const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP, |
873a543b | 132 | const wxString& labelText = wxT(""), |
52b5ab7e | 133 | int alignText = NB_ALIGN_TEXT_BOTTOM, |
c82c42d4 | 134 | bool isFlat = true, |
52b5ab7e GD |
135 | // this is the default type of fired events |
136 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
65e50848 JS |
137 | int marginX = NB_DEFAULT_MARGIN, |
138 | int marginY = NB_DEFAULT_MARGIN, | |
52b5ab7e | 139 | int textToLabelGap = 2, |
c82c42d4 | 140 | bool isSticky = false |
52b5ab7e | 141 | ); |
8e08b761 | 142 | |
4cbc57f0 JS |
143 | // Destructor. |
144 | ~wxNewBitmapButton(); | |
145 | ||
146 | // This function should be called after Create. It renders the labels, having | |
147 | // reloaded the button image if necessary. | |
148 | virtual void Reshape(); | |
149 | ||
150 | // Sets the label and optionally label text. | |
873a543b | 151 | virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = wxT("") ); |
4cbc57f0 | 152 | |
8552e6f0 MB |
153 | // Unhide method from parents. |
154 | ||
155 | virtual void SetLabel(const wxString& label) | |
156 | { wxPanel::SetLabel(label); }; | |
157 | ||
4cbc57f0 JS |
158 | // Sets the text alignment and margins. |
159 | virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, | |
65e50848 JS |
160 | int marginX = NB_DEFAULT_MARGIN, |
161 | int marginY = NB_DEFAULT_MARGIN, | |
4cbc57f0 JS |
162 | int textToLabelGap = 2); |
163 | ||
164 | // Draws the decorations. | |
165 | virtual void DrawDecorations( wxDC& dc ); | |
166 | ||
167 | // Draws the label. | |
168 | virtual void DrawLabel( wxDC& dc ); | |
169 | ||
170 | // Renders the label image. | |
171 | virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, | |
c82c42d4 WS |
172 | bool isEnabled = true, |
173 | bool isPressed = false); | |
4cbc57f0 JS |
174 | |
175 | // Renders label images. | |
176 | virtual void RenderLabelImages(); | |
177 | ||
178 | // Renders label images. | |
179 | virtual void RenderAllLabelImages(); | |
180 | ||
45da7759 JS |
181 | // Enables/disables button |
182 | virtual bool Enable(bool enable); | |
183 | ||
ab839dff JS |
184 | // Depress button |
185 | virtual bool Toggle(bool enable); | |
186 | ||
4cbc57f0 JS |
187 | // Responds to a left mouse button down event. |
188 | void OnLButtonDown( wxMouseEvent& event ); | |
8e08b761 | 189 | |
4cbc57f0 JS |
190 | // Responds to a left mouse button up event. |
191 | void OnLButtonUp( wxMouseEvent& event ); | |
8e08b761 | 192 | |
45da7759 JS |
193 | // Responds to mouse enter to window. |
194 | void OnMouseEnter( wxMouseEvent& event ); | |
195 | ||
196 | // Responds to mouse leave from window. | |
197 | void OnMouseLeave( wxMouseEvent& event ); | |
8e08b761 | 198 | |
4cbc57f0 JS |
199 | // Responds to a size event. |
200 | void OnSize( wxSizeEvent& event ); | |
8e08b761 | 201 | |
4cbc57f0 JS |
202 | // Responds to a paint event. |
203 | void OnPaint( wxPaintEvent& event ); | |
8e08b761 | 204 | |
4cbc57f0 JS |
205 | // Responds to an erase background event. |
206 | void OnEraseBackground( wxEraseEvent& event ); | |
8e08b761 | 207 | |
4cbc57f0 JS |
208 | // Responds to a kill focus event. |
209 | void OnKillFocus( wxFocusEvent& event ); | |
8e08b761 | 210 | |
4cbc57f0 | 211 | DECLARE_EVENT_TABLE() |
8e08b761 JS |
212 | }; |
213 | ||
214 | #endif /* __NEWBMPBTN_G__ */ | |
215 |