]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/newbmpbtn.h
Committing in .
[wxWidgets.git] / contrib / include / wx / fl / newbmpbtn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: newbmpbtn.h
3 // Purpose: wxNewBitmapButton header.
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: ??/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __NEWBMPBTN_G__
13 #define __NEWBMPBTN_G__
14
15 #ifdef __GNUG__
16 #pragma interface "newbmpbtn.h"
17 #endif
18
19 #include "wx/button.h"
20 #include "wx/string.h"
21
22 // button label-text alignment types
23
24 #define NB_ALIGN_TEXT_RIGHT 0
25 #define NB_ALIGN_TEXT_BOTTOM 1
26 #define NB_NO_TEXT 2
27 #define NB_NO_IMAGE 3
28
29 // classes declared in this header file
30
31 class wxNewBitmapButton;
32 class wxBorderLessBitmapButton;
33
34 /*
35 This is an alternative class to wxBitmapButton. It is used
36 in the implementation of dynamic toolbars.
37 */
38
39 class wxNewBitmapButton: public wxPanel
40 {
41 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
42
43 protected:
44
45 friend class wxNewBitmapButtonSerializer;
46
47 int mTextToLabelGap;
48 int mMarginX;
49 int mMarginY;
50 int mTextAlignment;
51 bool mIsSticky;
52 bool mIsFlat;
53
54 wxString mLabelText;
55 wxString mImageFileName;
56 wxBitmapType mImageFileType;
57
58 wxBitmap mDepressedBmp; // source image for rendering
59 // labels for particular state
60
61 wxBitmap mFocusedBmp; // may not be always present -
62 // only if mHasFocusedBmp is TRUE
63
64 wxBitmap* mpDepressedImg;
65 wxBitmap* mpPressedImg;
66 wxBitmap* mpDisabledImg;
67 wxBitmap* mpFocusedImg;
68
69 // button state variables;
70 bool mDragStarted;
71 bool mIsPressed;
72 bool mIsInFocus;
73 bool mPrevPressedState;
74 bool mPrevInFocusState;
75
76 bool mHasFocusedBmp;
77
78 // type of event which is fired upon depression of this button
79 int mFiredEventType;
80
81 // pens for drawing decorations (borders)
82 wxPen mBlackPen;
83 wxPen mDarkPen;
84 wxPen mGrayPen;
85 wxPen mLightPen;
86
87 bool mIsCreated;
88 int mSizeIsSet;
89
90 protected:
91
92 // Internal function for destroying labels.
93 void DestroyLabels();
94
95 // Returns the label that matches the current button state.
96 virtual wxBitmap* GetStateLabel();
97
98 // Draws shading on the button.
99 virtual void DrawShade( int outerLevel,
100 wxDC& dc,
101 wxPen& upperLeftSidePen,
102 wxPen& lowerRightSidePen );
103
104 // Returns TRUE if the given point is in the window.
105 bool IsInWindow( int x, int y );
106
107 public:
108
109 // Constructor.
110 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
111 const wxString& labelText = "",
112 int alignText = NB_ALIGN_TEXT_BOTTOM,
113 bool isFlat = TRUE,
114 // this is the default type of fired events
115 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
116 int marginX = 2,
117 int marginY = 2,
118 int textToLabelGap = 2,
119 bool isSticky = FALSE
120 );
121
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,
127 bool isFlat = TRUE,
128 // this is the default type of fired events
129 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
130 int marginX = 2,
131 int marginY = 2,
132 int textToLabelGap = 2,
133 bool isSticky = FALSE
134 );
135
136 // Destructor.
137 ~wxNewBitmapButton();
138
139 // This function should be called after Create. It renders the labels, having
140 // reloaded the button image if necessary.
141 virtual void Reshape();
142
143 // Sets the label and optionally label text.
144 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" );
145
146 // Sets the text alignment and margins.
147 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
148 int marginX = 2,
149 int marginY = 2,
150 int textToLabelGap = 2);
151
152 // Draws the decorations.
153 virtual void DrawDecorations( wxDC& dc );
154
155 // Draws the label.
156 virtual void DrawLabel( wxDC& dc );
157
158 // Renders the label image.
159 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
160 bool isEnabled = TRUE,
161 bool isPressed = FALSE);
162
163 // Renders label images.
164 virtual void RenderLabelImages();
165
166 // Renders label images.
167 virtual void RenderAllLabelImages();
168
169 // Responds to a left mouse button down event.
170 void OnLButtonDown( wxMouseEvent& event );
171
172 // Responds to a left mouse button up event.
173 void OnLButtonUp( wxMouseEvent& event );
174
175 // Responds to a mouse move event.
176 void OnMouseMove( wxMouseEvent& event );
177
178 // Responds to a size event.
179 void OnSize( wxSizeEvent& event );
180
181 // Responds to a paint event.
182 void OnPaint( wxPaintEvent& event );
183
184 // Responds to an erase background event.
185 void OnEraseBackground( wxEraseEvent& event );
186
187 // Responds to a kill focus event.
188 void OnKillFocus( wxFocusEvent& event );
189
190 DECLARE_EVENT_TABLE()
191 };
192
193 #endif /* __NEWBMPBTN_G__ */
194