]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/newbmpbtn.h
setter by ref for
[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 // Sets the text alignment and margins.
149 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
150 int marginX = NB_DEFAULT_MARGIN,
151 int marginY = NB_DEFAULT_MARGIN,
152 int textToLabelGap = 2);
153
154 // Draws the decorations.
155 virtual void DrawDecorations( wxDC& dc );
156
157 // Draws the label.
158 virtual void DrawLabel( wxDC& dc );
159
160 // Renders the label image.
161 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
162 bool isEnabled = TRUE,
163 bool isPressed = FALSE);
164
165 // Renders label images.
166 virtual void RenderLabelImages();
167
168 // Renders label images.
169 virtual void RenderAllLabelImages();
170
171 // Enables/disables button
172 virtual bool Enable(bool enable);
173
174 // Responds to a left mouse button down event.
175 void OnLButtonDown( wxMouseEvent& event );
176
177 // Responds to a left mouse button up event.
178 void OnLButtonUp( wxMouseEvent& event );
179
180 // Responds to mouse enter to window.
181 void OnMouseEnter( wxMouseEvent& event );
182
183 // Responds to mouse leave from window.
184 void OnMouseLeave( wxMouseEvent& event );
185
186 // Responds to a size event.
187 void OnSize( wxSizeEvent& event );
188
189 // Responds to a paint event.
190 void OnPaint( wxPaintEvent& event );
191
192 // Responds to an erase background event.
193 void OnEraseBackground( wxEraseEvent& event );
194
195 // Responds to a kill focus event.
196 void OnKillFocus( wxFocusEvent& event );
197
198 DECLARE_EVENT_TABLE()
199 };
200
201 #endif /* __NEWBMPBTN_G__ */
202