]>
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 JS |
65 | wxBitmap mFocusedBmp; // may not be always present - |
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; | |
8e08b761 | 77 | |
4cbc57f0 | 78 | bool mHasFocusedBmp; |
8e08b761 | 79 | |
4cbc57f0 JS |
80 | // type of event which is fired upon depression of this button |
81 | int mFiredEventType; | |
8e08b761 | 82 | |
4cbc57f0 JS |
83 | // pens for drawing decorations (borders) |
84 | wxPen mBlackPen; | |
85 | wxPen mDarkPen; | |
86 | wxPen mGrayPen; | |
87 | wxPen mLightPen; | |
8e08b761 | 88 | |
4cbc57f0 JS |
89 | bool mIsCreated; |
90 | int mSizeIsSet; | |
8e08b761 JS |
91 | |
92 | protected: | |
8e08b761 | 93 | |
4cbc57f0 JS |
94 | // Internal function for destroying labels. |
95 | void DestroyLabels(); | |
8e08b761 | 96 | |
4cbc57f0 JS |
97 | // Returns the label that matches the current button state. |
98 | virtual wxBitmap* GetStateLabel(); | |
8e08b761 | 99 | |
4cbc57f0 JS |
100 | // Draws shading on the button. |
101 | virtual void DrawShade( int outerLevel, | |
102 | wxDC& dc, | |
103 | wxPen& upperLeftSidePen, | |
104 | wxPen& lowerRightSidePen ); | |
105 | ||
106 | // Returns TRUE if the given point is in the window. | |
107 | bool IsInWindow( int x, int y ); | |
8e08b761 JS |
108 | |
109 | public: | |
110 | ||
4cbc57f0 JS |
111 | // Constructor. |
112 | wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap, | |
873a543b | 113 | const wxString& labelText = wxT(""), |
4cbc57f0 JS |
114 | int alignText = NB_ALIGN_TEXT_BOTTOM, |
115 | bool isFlat = TRUE, | |
116 | // this is the default type of fired events | |
117 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
65e50848 JS |
118 | int marginX = NB_DEFAULT_MARGIN, |
119 | int marginY = NB_DEFAULT_MARGIN, | |
4cbc57f0 JS |
120 | int textToLabelGap = 2, |
121 | bool isSticky = FALSE | |
122 | ); | |
123 | ||
124 | // Use this constructor if buttons have to be persistant | |
125 | wxNewBitmapButton( const wxString& bitmapFileName, | |
52b5ab7e | 126 | const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP, |
873a543b | 127 | const wxString& labelText = wxT(""), |
52b5ab7e GD |
128 | int alignText = NB_ALIGN_TEXT_BOTTOM, |
129 | bool isFlat = TRUE, | |
130 | // this is the default type of fired events | |
131 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
65e50848 JS |
132 | int marginX = NB_DEFAULT_MARGIN, |
133 | int marginY = NB_DEFAULT_MARGIN, | |
52b5ab7e GD |
134 | int textToLabelGap = 2, |
135 | bool isSticky = FALSE | |
136 | ); | |
8e08b761 | 137 | |
4cbc57f0 JS |
138 | // Destructor. |
139 | ~wxNewBitmapButton(); | |
140 | ||
141 | // This function should be called after Create. It renders the labels, having | |
142 | // reloaded the button image if necessary. | |
143 | virtual void Reshape(); | |
144 | ||
145 | // Sets the label and optionally label text. | |
873a543b | 146 | virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = wxT("") ); |
4cbc57f0 JS |
147 | |
148 | // Sets the text alignment and margins. | |
149 | virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, | |
65e50848 JS |
150 | int marginX = NB_DEFAULT_MARGIN, |
151 | int marginY = NB_DEFAULT_MARGIN, | |
4cbc57f0 JS |
152 | int textToLabelGap = 2); |
153 | ||
154 | // Draws the decorations. | |
155 | virtual void DrawDecorations( wxDC& dc ); | |
156 | ||
157 | // Draws the label. | |
158 | virtual void DrawLabel( wxDC& dc ); | |
159 | ||
160 | // Renders the label image. | |
161 | virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, | |
162 | bool isEnabled = TRUE, | |
163 | bool isPressed = FALSE); | |
164 | ||
165 | // Renders label images. | |
166 | virtual void RenderLabelImages(); | |
167 | ||
168 | // Renders label images. | |
169 | virtual void RenderAllLabelImages(); | |
170 | ||
45da7759 JS |
171 | // Enables/disables button |
172 | virtual bool Enable(bool enable); | |
173 | ||
4cbc57f0 JS |
174 | // Responds to a left mouse button down event. |
175 | void OnLButtonDown( wxMouseEvent& event ); | |
8e08b761 | 176 | |
4cbc57f0 JS |
177 | // Responds to a left mouse button up event. |
178 | void OnLButtonUp( wxMouseEvent& event ); | |
8e08b761 | 179 | |
45da7759 JS |
180 | // Responds to mouse enter to window. |
181 | void OnMouseEnter( wxMouseEvent& event ); | |
182 | ||
183 | // Responds to mouse leave from window. | |
184 | void OnMouseLeave( wxMouseEvent& event ); | |
8e08b761 | 185 | |
4cbc57f0 JS |
186 | // Responds to a size event. |
187 | void OnSize( wxSizeEvent& event ); | |
8e08b761 | 188 | |
4cbc57f0 JS |
189 | // Responds to a paint event. |
190 | void OnPaint( wxPaintEvent& event ); | |
8e08b761 | 191 | |
4cbc57f0 JS |
192 | // Responds to an erase background event. |
193 | void OnEraseBackground( wxEraseEvent& event ); | |
8e08b761 | 194 | |
4cbc57f0 JS |
195 | // Responds to a kill focus event. |
196 | void OnKillFocus( wxFocusEvent& event ); | |
8e08b761 | 197 | |
4cbc57f0 | 198 | DECLARE_EVENT_TABLE() |
8e08b761 JS |
199 | }; |
200 | ||
201 | #endif /* __NEWBMPBTN_G__ */ | |
202 |