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;
76 // type of event which is fired upon depression of this button
79 // pens for drawing decorations (borders)
90 // Internal function for destroying labels.
93 // Returns the label that matches the current button state.
94 virtual wxBitmap
* GetStateLabel();
96 // Draws shading on the button.
97 virtual void DrawShade( int outerLevel
,
99 wxPen
& upperLeftSidePen
,
100 wxPen
& lowerRightSidePen
);
102 // Returns TRUE if the given point is in the window.
103 bool IsInWindow( int x
, int y
);
108 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
109 const wxString
& labelText
= "",
110 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
112 // this is the default type of fired events
113 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
116 int textToLabelGap
= 2,
117 bool isSticky
= FALSE
120 // Use this constructor if buttons have to be persistant
121 wxNewBitmapButton( const wxString
& bitmapFileName
,
122 const wxBitmapType bitmapFileType
= wxBITMAP_TYPE_BMP
,
123 const wxString
& labelText
= "",
124 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
126 // this is the default type of fired events
127 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
130 int textToLabelGap
= 2,
131 bool isSticky
= FALSE
135 ~wxNewBitmapButton();
137 // This function should be called after Create. It renders the labels, having
138 // reloaded the button image if necessary.
139 virtual void Reshape();
141 // Sets the label and optionally label text.
142 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= "" );
144 // Sets the text alignment and margins.
145 virtual void SetAlignments( int alignText
= NB_ALIGN_TEXT_BOTTOM
,
148 int textToLabelGap
= 2);
150 // Draws the decorations.
151 virtual void DrawDecorations( wxDC
& dc
);
154 virtual void DrawLabel( wxDC
& dc
);
156 // Renders the label image.
157 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
158 bool isEnabled
= TRUE
,
159 bool isPressed
= FALSE
);
161 // Renders label images.
162 virtual void RenderLabelImages();
164 // Renders label images.
165 virtual void RenderAllLabelImages();
167 // Enables/disables button
168 virtual bool Enable(bool enable
);
170 // Responds to a left mouse button down event.
171 void OnLButtonDown( wxMouseEvent
& event
);
173 // Responds to a left mouse button up event.
174 void OnLButtonUp( wxMouseEvent
& event
);
176 // Responds to a left mouse button double click.
177 void OnLButtonDClick( wxMouseEvent
& event
);
179 // Responds to mouse enter to window.
180 void OnMouseEnter( wxMouseEvent
& event
);
182 // Responds to mouse leave from window.
183 void OnMouseLeave( wxMouseEvent
& event
);
185 // Responds to a size event.
186 void OnSize( wxSizeEvent
& event
);
188 // Responds to a paint event.
189 void OnPaint( wxPaintEvent
& event
);
191 // Responds to an erase background event.
192 void OnEraseBackground( wxEraseEvent
& event
);
194 // Responds to a kill focus event.
195 void OnKillFocus( wxFocusEvent
& event
);
197 DECLARE_EVENT_TABLE()
200 #endif /* __NEWBMPBTN_G__ */