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__
16 #pragma interface "newbmpbtn.h"
19 #include "wx/button.h"
20 #include "wx/string.h"
22 // button label-text alignment types
24 #define NB_ALIGN_TEXT_RIGHT 0
25 #define NB_ALIGN_TEXT_BOTTOM 1
29 // classes declared in this header file
31 class wxNewBitmapButton
;
32 class wxBorderLessBitmapButton
;
35 This is an alternative class to wxBitmapButton. It is used
36 in the implementation of dynamic toolbars.
39 class wxNewBitmapButton
: public wxPanel
41 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton
)
45 friend class wxNewBitmapButtonSerializer
;
55 wxString mImageFileName
;
56 wxBitmapType mImageFileType
;
58 wxBitmap mDepressedBmp
; // source image for rendering
59 // labels for particular state
61 wxBitmap mFocusedBmp
; // may not be always present -
62 // only if mHasFocusedBmp is TRUE
64 wxBitmap
* mpDepressedImg
;
65 wxBitmap
* mpPressedImg
;
66 wxBitmap
* mpDisabledImg
;
67 wxBitmap
* mpFocusedImg
;
69 // button state variables;
73 bool mPrevPressedState
;
74 bool mPrevInFocusState
;
78 // type of event which is fired upon depression of this button
81 // pens for drawing decorations (borders)
92 // Internal function for destroying labels.
95 // Returns the label that matches the current button state.
96 virtual wxBitmap
* GetStateLabel();
98 // Draws shading on the button.
99 virtual void DrawShade( int outerLevel
,
101 wxPen
& upperLeftSidePen
,
102 wxPen
& lowerRightSidePen
);
104 // Returns TRUE if the given point is in the window.
105 bool IsInWindow( int x
, int y
);
110 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
111 const wxString
& labelText
= "",
112 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
114 // this is the default type of fired events
115 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
118 int textToLabelGap
= 2,
119 bool isSticky
= FALSE
122 // Use this constructor if buttons have to be persistant
123 wxNewBitmapButton( const wxString
& bitmapFileName
,
124 const wxBitmapType bitmapFileType
= wxBITMAP_TYPE_BMP
,
125 const wxString
& labelText
= "",
126 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
128 // this is the default type of fired events
129 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
132 int textToLabelGap
= 2,
133 bool isSticky
= FALSE
137 ~wxNewBitmapButton();
139 // This function should be called after Create. It renders the labels, having
140 // reloaded the button image if necessary.
141 virtual void Reshape();
143 // Sets the label and optionally label text.
144 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= "" );
146 // Sets the text alignment and margins.
147 virtual void SetAlignments( int alignText
= NB_ALIGN_TEXT_BOTTOM
,
150 int textToLabelGap
= 2);
152 // Draws the decorations.
153 virtual void DrawDecorations( wxDC
& dc
);
156 virtual void DrawLabel( wxDC
& dc
);
158 // Renders the label image.
159 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
160 bool isEnabled
= TRUE
,
161 bool isPressed
= FALSE
);
163 // Renders label images.
164 virtual void RenderLabelImages();
166 // Renders label images.
167 virtual void RenderAllLabelImages();
169 // Responds to a left mouse button down event.
170 void OnLButtonDown( wxMouseEvent
& event
);
172 // Responds to a left mouse button up event.
173 void OnLButtonUp( wxMouseEvent
& event
);
175 // Responds to a mouse move event.
176 void OnMouseMove( wxMouseEvent
& event
);
178 // Responds to a size event.
179 void OnSize( wxSizeEvent
& event
);
181 // Responds to a paint event.
182 void OnPaint( wxPaintEvent
& event
);
184 // Responds to an erase background event.
185 void OnEraseBackground( wxEraseEvent
& event
);
187 // Responds to a kill focus event.
188 void OnKillFocus( wxFocusEvent
& event
);
190 DECLARE_EVENT_TABLE()
193 #endif /* __NEWBMPBTN_G__ */