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