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__
15 #include "wx/button.h"
16 #include "wx/string.h"
18 // button lable-text alignment types
20 #define NB_ALIGN_TEXT_RIGHT 0
21 #define NB_ALIGN_TEXT_BOTTOM 1
25 // classes declared in this header file
27 class wxNewBitmapButton
;
28 class wxBorderLessBitmapButton
;
30 // alternative class for wxBmpButton
32 class wxNewBitmapButton
: public wxPanel
34 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton
)
38 friend class wxNewBitmapButtonSerializer
;
47 wxString mImageFileName
;
51 wxBitmap mDepressedBmp
; // source image for rendering
52 // labels for particular state
54 wxBitmap mFocusedBmp
; // may not be always present -
55 // only if mHasFocusedBmp is TRUE
57 wxBitmap
* mpDepressedImg
;
58 wxBitmap
* mpPressedImg
;
59 wxBitmap
* mpDisabledImg
;
60 wxBitmap
* mpFocusedImg
;
62 // button state variables;
66 bool mPrevPressedState
;
70 // type of event which is fired upon depression of this button
73 // pens for drawing decorations (borders)
85 // returns the label which match the current button state
86 virtual wxBitmap
* GetStateLabel();
88 virtual void DrawShade( int outerLevel
,
90 wxPen
& upperLeftSidePen
,
91 wxPen
& lowerRightSidePen
);
93 bool IsInWindow( int x
,int y
);
97 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
98 const wxString
& labelText
= "",
99 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
101 // this is the default type of fired events
102 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
105 int textToLabelGap
= 2,
106 bool isSticky
= FALSE
109 // use this constructor if buttons have to be persistant
111 wxNewBitmapButton( const wxString
& bitmapFileName
,
112 const int bitmapFileType
= wxBITMAP_TYPE_BMP
,
113 const wxString
& labelText
= "",
114 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
116 // this is the default type of fired events
117 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
120 int textToLabelGap
= 2,
121 bool isSticky
= FALSE
124 ~wxNewBitmapButton();
126 // should be called after Create();
127 virtual void Reshape();
130 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= "" );
132 virtual void SetAlignments( int alignText
= NB_ALIGN_TEXT_BOTTOM
,
135 int textToLabelGap
= 2);
137 virtual void DrawDecorations( wxDC
& dc
);
138 virtual void DrawLabel( wxDC
& dc
);
140 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
141 bool isEnabled
= TRUE
,
142 bool isPressed
= FALSE
);
144 virtual void RenderLabelImages();
147 void OnLButtonDown( wxMouseEvent
& event
);
148 void OnLButtonUp( wxMouseEvent
& event
);
149 void OnMouseMove( wxMouseEvent
& event
);
150 void OnSize( wxSizeEvent
& event
);
151 void OnPaint( wxPaintEvent
& event
);
152 void OnEraseBackground( wxEraseEvent
& event
);
153 void OnKillFocus( wxFocusEvent
& event
);
155 DECLARE_EVENT_TABLE()