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
;
48 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
;
67 bool mPrevInFocusState
;
71 // type of event which is fired upon depression of this button
74 // pens for drawing decorations (borders)
86 // returns the label which match the current button state
87 virtual wxBitmap
* GetStateLabel();
89 virtual void DrawShade( int outerLevel
,
91 wxPen
& upperLeftSidePen
,
92 wxPen
& lowerRightSidePen
);
94 bool IsInWindow( int x
,int y
);
98 wxNewBitmapButton( const wxBitmap
& labelBitmap
= wxNullBitmap
,
99 const wxString
& labelText
= "",
100 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
102 // this is the default type of fired events
103 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
106 int textToLabelGap
= 2,
107 bool isSticky
= FALSE
110 // use this constructor if buttons have to be persistant
112 wxNewBitmapButton( const wxString
& bitmapFileName
,
113 const int bitmapFileType
= wxBITMAP_TYPE_BMP
,
114 const wxString
& labelText
= "",
115 int alignText
= NB_ALIGN_TEXT_BOTTOM
,
117 // this is the default type of fired events
118 int firedEventType
= wxEVT_COMMAND_MENU_SELECTED
,
121 int textToLabelGap
= 2,
122 bool isSticky
= FALSE
125 ~wxNewBitmapButton();
127 // should be called after Create();
128 virtual void Reshape();
131 virtual void SetLabel(const wxBitmap
& labelBitmap
, const wxString
& labelText
= "" );
133 virtual void SetAlignments( int alignText
= NB_ALIGN_TEXT_BOTTOM
,
136 int textToLabelGap
= 2);
138 virtual void DrawDecorations( wxDC
& dc
);
139 virtual void DrawLabel( wxDC
& dc
);
141 virtual void RenderLabelImage( wxBitmap
*& destBmp
, wxBitmap
* srcBmp
,
142 bool isEnabled
= TRUE
,
143 bool isPressed
= FALSE
);
145 virtual void RenderLabelImages();
146 virtual void RenderAllLabelImages();
149 void OnLButtonDown( wxMouseEvent
& event
);
150 void OnLButtonUp( wxMouseEvent
& event
);
151 void OnMouseMove( wxMouseEvent
& event
);
152 void OnSize( wxSizeEvent
& event
);
153 void OnPaint( wxPaintEvent
& event
);
154 void OnEraseBackground( wxEraseEvent
& event
);
155 void OnKillFocus( wxFocusEvent
& event
);
157 DECLARE_EVENT_TABLE()