]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/newbmpbtn.h
Applied patch [ 868061 ] Warning free OGL
[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 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "newbmpbtn.h"
17 #endif
18
19 #include "wx/button.h"
20 #include "wx/string.h"
21 #include "wx/fl/fldefs.h"
22
23 // defaults
24 #define NB_DEFAULT_MARGIN 2
25
26 // button label-text alignment types
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
35 class WXDLLIMPEXP_FL wxNewBitmapButton;
36 class WXDLLIMPEXP_FL wxBorderLessBitmapButton;
37
38 /*
39 This is an alternative class to wxBitmapButton. It is used
40 in the implementation of dynamic toolbars.
41 */
42
43 class wxNewBitmapButton: public wxPanel
44 {
45 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
46
47 protected:
48
49 friend class wxNewBitmapButtonSerializer;
50
51 int mTextToLabelGap;
52 int mMarginX;
53 int mMarginY;
54 int mTextAlignment;
55 bool mIsSticky;
56 bool mIsFlat;
57
58 wxString mLabelText;
59 wxString mImageFileName;
60 wxBitmapType mImageFileType;
61
62 wxBitmap mDepressedBmp; // source image for rendering
63 // labels for particular state
64
65 wxBitmap mFocusedBmp; // may not be always present -
66 // only if mHasFocusedBmp is TRUE
67
68 wxBitmap* mpDepressedImg;
69 wxBitmap* mpPressedImg;
70 wxBitmap* mpDisabledImg;
71 wxBitmap* mpFocusedImg;
72
73 // button state variables;
74 bool mDragStarted;
75 bool mIsPressed;
76 bool mIsInFocus;
77
78 bool mHasFocusedBmp;
79
80 // type of event which is fired upon depression of this button
81 int mFiredEventType;
82
83 // pens for drawing decorations (borders)
84 wxPen mBlackPen;
85 wxPen mDarkPen;
86 wxPen mGrayPen;
87 wxPen mLightPen;
88
89 bool mIsCreated;
90 int mSizeIsSet;
91
92 protected:
93
94 // Internal function for destroying labels.
95 void DestroyLabels();
96
97 // Returns the label that matches the current button state.
98 virtual wxBitmap* GetStateLabel();
99
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 );
108
109 public:
110
111 // Constructor.
112 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
113 const wxString& labelText = wxT(""),
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,
118 int marginX = NB_DEFAULT_MARGIN,
119 int marginY = NB_DEFAULT_MARGIN,
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,
126 const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP,
127 const wxString& labelText = wxT(""),
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,
132 int marginX = NB_DEFAULT_MARGIN,
133 int marginY = NB_DEFAULT_MARGIN,
134 int textToLabelGap = 2,
135 bool isSticky = FALSE
136 );
137
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.
146 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = wxT("") );
147
148 // Unhide method from parents.
149
150 virtual void SetLabel(const wxString& label)
151 { wxPanel::SetLabel(label); };
152
153 // Sets the text alignment and margins.
154 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
155 int marginX = NB_DEFAULT_MARGIN,
156 int marginY = NB_DEFAULT_MARGIN,
157 int textToLabelGap = 2);
158
159 // Draws the decorations.
160 virtual void DrawDecorations( wxDC& dc );
161
162 // Draws the label.
163 virtual void DrawLabel( wxDC& dc );
164
165 // Renders the label image.
166 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
167 bool isEnabled = TRUE,
168 bool isPressed = FALSE);
169
170 // Renders label images.
171 virtual void RenderLabelImages();
172
173 // Renders label images.
174 virtual void RenderAllLabelImages();
175
176 // Enables/disables button
177 virtual bool Enable(bool enable);
178
179 // Responds to a left mouse button down event.
180 void OnLButtonDown( wxMouseEvent& event );
181
182 // Responds to a left mouse button up event.
183 void OnLButtonUp( wxMouseEvent& event );
184
185 // Responds to mouse enter to window.
186 void OnMouseEnter( wxMouseEvent& event );
187
188 // Responds to mouse leave from window.
189 void OnMouseLeave( wxMouseEvent& event );
190
191 // Responds to a size event.
192 void OnSize( wxSizeEvent& event );
193
194 // Responds to a paint event.
195 void OnPaint( wxPaintEvent& event );
196
197 // Responds to an erase background event.
198 void OnEraseBackground( wxEraseEvent& event );
199
200 // Responds to a kill focus event.
201 void OnKillFocus( wxFocusEvent& event );
202
203 DECLARE_EVENT_TABLE()
204 };
205
206 #endif /* __NEWBMPBTN_G__ */
207