1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
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 lable-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
;
34 // alternative class for wxBmpButton
36 class wxNewBitmapButton
: public wxPanel
38 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton
)
42 friend class wxNewBitmapButtonSerializer
;
52 wxString mImageFileName
;
53 wxBitmapType mImageFileType
;
55 wxBitmap mDepressedBmp
; // source image for rendering
56 // labels for particular state
58 wxBitmap mFocusedBmp
; // may not be always present -
59 // only if mHasFocusedBmp is TRUE
61 wxBitmap
* mpDepressedImg
;
62 wxBitmap
* mpPressedImg
;
63 wxBitmap
* mpDisabledImg
;
64 wxBitmap
* mpFocusedImg
;
66 // button state variables;
70 bool mPrevPressedState
;
71 bool mPrevInFocusState
;
75 // type of event which is fired upon depression of this button
78 // pens for drawing decorations (borders)
90 // returns the label which match the current button state
91 virtual wxBitmap
* GetStateLabel();
93 virtual void DrawShade( int outerLevel
,
95 wxPen
& upperLeftSidePen
,
96 wxPen
& lowerRightSidePen
);
98 bool IsInWindow( int x
,int y
);
102 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
103 const wxString
& labelText
= "",
104 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
106 // this is the default type of fired events
107 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
110 int textToLabelGap
= 2,
111 bool isSticky
= FALSE
114 // use this constructor if buttons have to be persistant
116 wxNewBitmapButton( const wxString
& bitmapFileName
,
117 const wxBitmapType bitmapFileType
= wxBITMAP_TYPE_BMP
,
118 const wxString
& labelText
= "",
119 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
121 // this is the default type of fired events
122 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
125 int textToLabelGap
= 2,
126 bool isSticky
= FALSE
129 ~wxNewBitmapButton();
131 // should be called after Create();
132 virtual void Reshape();
135 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= "" );
137 virtual void SetAlignments( int alignText
= NB_ALIGN_TEXT_BOTTOM
,
140 int textToLabelGap
= 2);
142 virtual void DrawDecorations( wxDC
& dc
);
143 virtual void DrawLabel( wxDC
& dc
);
145 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
146 bool isEnabled
= TRUE
,
147 bool isPressed
= FALSE
);
149 virtual void RenderLabelImages();
150 virtual void RenderAllLabelImages();
153 void OnLButtonDown( wxMouseEvent
& event
);
154 void OnLButtonUp( wxMouseEvent
& event
);
155 void OnMouseMove( wxMouseEvent
& event
);
156 void OnSize( wxSizeEvent
& event
);
157 void OnPaint( wxPaintEvent
& event
);
158 void OnEraseBackground( wxEraseEvent
& event
);
159 void OnKillFocus( wxFocusEvent
& event
);
161 DECLARE_EVENT_TABLE()
164 #endif /* __NEWBMPBTN_G__ */