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