]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/newbmpbtn.h
Added files to Tex2RTF file list
[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 // defaults
23 #define NB_DEFAULT_MARGIN 2
24
25 // button label-text alignment types
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
37 /*
38 This is an alternative class to wxBitmapButton. It is used
39 in the implementation of dynamic toolbars.
40 */
41
42 class wxNewBitmapButton: public wxPanel
43 {
44 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
45
46 protected:
47
48 friend class wxNewBitmapButtonSerializer;
49
50 int mTextToLabelGap;
51 int mMarginX;
52 int mMarginY;
53 int mTextAlignment;
54 bool mIsSticky;
55 bool mIsFlat;
56
57 wxString mLabelText;
58 wxString mImageFileName;
59 wxBitmapType mImageFileType;
60
61 wxBitmap mDepressedBmp; // source image for rendering
62 // labels for particular state
63
64 wxBitmap mFocusedBmp; // may not be always present -
65 // only if mHasFocusedBmp is TRUE
66
67 wxBitmap* mpDepressedImg;
68 wxBitmap* mpPressedImg;
69 wxBitmap* mpDisabledImg;
70 wxBitmap* mpFocusedImg;
71
72 // button state variables;
73 bool mDragStarted;
74 bool mIsPressed;
75 bool mIsInFocus;
76
77 bool mHasFocusedBmp;
78
79 // type of event which is fired upon depression of this button
80 int mFiredEventType;
81
82 // pens for drawing decorations (borders)
83 wxPen mBlackPen;
84 wxPen mDarkPen;
85 wxPen mGrayPen;
86 wxPen mLightPen;
87
88 bool mIsCreated;
89 int mSizeIsSet;
90
91 protected:
92
93 // Internal function for destroying labels.
94 void DestroyLabels();
95
96 // Returns the label that matches the current button state.
97 virtual wxBitmap* GetStateLabel();
98
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 );
107
108 public:
109
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,
117 int marginX = NB_DEFAULT_MARGIN,
118 int marginY = NB_DEFAULT_MARGIN,
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,
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,
131 int marginX = NB_DEFAULT_MARGIN,
132 int marginY = NB_DEFAULT_MARGIN,
133 int textToLabelGap = 2,
134 bool isSticky = FALSE
135 );
136
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,
149 int marginX = NB_DEFAULT_MARGIN,
150 int marginY = NB_DEFAULT_MARGIN,
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
170 // Enables/disables button
171 virtual bool Enable(bool enable);
172
173 // Responds to a left mouse button down event.
174 void OnLButtonDown( wxMouseEvent& event );
175
176 // Responds to a left mouse button up event.
177 void OnLButtonUp( 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 // Maps bitmap to current system colours on Windows
198 #ifdef __WXMSW__
199 WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height);
200 #endif
201
202 DECLARE_EVENT_TABLE()
203 };
204
205 #endif /* __NEWBMPBTN_G__ */
206