1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxNewBitmapButton header.
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __NEWBMPBTN_G__
13 #define __NEWBMPBTN_G__
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "newbmpbtn.h"
19 #include "wx/button.h"
20 #include "wx/string.h"
21 #include "wx/fl/fldefs.h"
24 #define NB_DEFAULT_MARGIN 2
26 // button label-text alignment types
28 #define NB_ALIGN_TEXT_RIGHT 0
29 #define NB_ALIGN_TEXT_BOTTOM 1
33 // classes declared in this header file
35 class WXDLLIMPEXP_FL wxNewBitmapButton
;
36 class WXDLLIMPEXP_FL wxBorderLessBitmapButton
;
39 This is an alternative class to wxBitmapButton. It is used
40 in the implementation of dynamic toolbars.
43 class wxNewBitmapButton
: public wxPanel
45 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton
)
49 friend class wxNewBitmapButtonSerializer
;
59 wxString mImageFileName
;
60 wxBitmapType mImageFileType
;
62 wxBitmap mDepressedBmp
; // source image for rendering
63 // labels for particular state
65 wxBitmap mFocusedBmp
; // may not be always present -
66 // only if mHasFocusedBmp is TRUE
68 wxBitmap
* mpDepressedImg
;
69 wxBitmap
* mpPressedImg
;
70 wxBitmap
* mpDisabledImg
;
71 wxBitmap
* mpFocusedImg
;
73 // button state variables;
80 // type of event which is fired upon depression of this button
83 // pens for drawing decorations (borders)
94 // Internal function for destroying labels.
97 // Returns the label that matches the current button state.
98 virtual wxBitmap
* GetStateLabel();
100 // Draws shading on the button.
101 virtual void DrawShade( int outerLevel
,
103 wxPen
& upperLeftSidePen
,
104 wxPen
& lowerRightSidePen
);
106 // Returns TRUE if the given point is in the window.
107 bool IsInWindow( int x
, int y
);
112 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
113 const wxString
& labelText
= wxT(""),
114 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
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
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
,
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
139 ~wxNewBitmapButton();
141 // This function should be called after Create. It renders the labels, having
142 // reloaded the button image if necessary.
143 virtual void Reshape();
145 // Sets the label and optionally label text.
146 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= wxT("") );
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);
154 // Draws the decorations.
155 virtual void DrawDecorations( wxDC
& dc
);
158 virtual void DrawLabel( wxDC
& dc
);
160 // Renders the label image.
161 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
162 bool isEnabled
= TRUE
,
163 bool isPressed
= FALSE
);
165 // Renders label images.
166 virtual void RenderLabelImages();
168 // Renders label images.
169 virtual void RenderAllLabelImages();
171 // Enables/disables button
172 virtual bool Enable(bool enable
);
174 // Responds to a left mouse button down event.
175 void OnLButtonDown( wxMouseEvent
& event
);
177 // Responds to a left mouse button up event.
178 void OnLButtonUp( wxMouseEvent
& event
);
180 // Responds to mouse enter to window.
181 void OnMouseEnter( wxMouseEvent
& event
);
183 // Responds to mouse leave from window.
184 void OnMouseLeave( wxMouseEvent
& event
);
186 // Responds to a size event.
187 void OnSize( wxSizeEvent
& event
);
189 // Responds to a paint event.
190 void OnPaint( wxPaintEvent
& event
);
192 // Responds to an erase background event.
193 void OnEraseBackground( wxEraseEvent
& event
);
195 // Responds to a kill focus event.
196 void OnKillFocus( wxFocusEvent
& event
);
198 DECLARE_EVENT_TABLE()
201 #endif /* __NEWBMPBTN_G__ */