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