]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/newbmpbtn.h
wxPalette unified. Source cleaning.
[wxWidgets.git] / contrib / include / wx / fl / newbmpbtn.h
CommitLineData
8e08b761 1/////////////////////////////////////////////////////////////////////////////
4cbc57f0
JS
2// Name: newbmpbtn.h
3// Purpose: wxNewBitmapButton header.
8e08b761
JS
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: ??/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
4cbc57f0 9// Licence: wxWindows licence
8e08b761
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __NEWBMPBTN_G__
13#define __NEWBMPBTN_G__
14
8e08b761
JS
15#include "wx/button.h"
16#include "wx/string.h"
2b5f62a0 17#include "wx/fl/fldefs.h"
8e08b761 18
65e50848
JS
19// defaults
20#define NB_DEFAULT_MARGIN 2
21
4cbc57f0 22// button label-text alignment types
8e08b761
JS
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
510b9edb
VS
31class WXDLLIMPEXP_FL wxNewBitmapButton;
32class WXDLLIMPEXP_FL wxBorderLessBitmapButton;
8e08b761 33
4cbc57f0
JS
34/*
35This is an alternative class to wxBitmapButton. It is used
36in the implementation of dynamic toolbars.
37*/
8e08b761
JS
38
39class wxNewBitmapButton: public wxPanel
40{
4cbc57f0 41 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
8e08b761
JS
42
43protected:
44
4cbc57f0 45 friend class wxNewBitmapButtonSerializer;
8e08b761 46
4cbc57f0
JS
47 int mTextToLabelGap;
48 int mMarginX;
49 int mMarginY;
50 int mTextAlignment;
51 bool mIsSticky;
52 bool mIsFlat;
8e08b761 53
4cbc57f0
JS
54 wxString mLabelText;
55 wxString mImageFileName;
56 wxBitmapType mImageFileType;
8e08b761 57
4cbc57f0
JS
58 wxBitmap mDepressedBmp; // source image for rendering
59 // labels for particular state
8e08b761 60
4cbc57f0 61 wxBitmap mFocusedBmp; // may not be always present -
c82c42d4 62 // only if mHasFocusedBmp is true
8e08b761 63
4cbc57f0
JS
64 wxBitmap* mpDepressedImg;
65 wxBitmap* mpPressedImg;
66 wxBitmap* mpDisabledImg;
67 wxBitmap* mpFocusedImg;
8e08b761 68
4cbc57f0
JS
69 // button state variables;
70 bool mDragStarted;
71 bool mIsPressed;
72 bool mIsInFocus;
ab839dff 73 bool mIsToggled;
8e08b761 74
4cbc57f0 75 bool mHasFocusedBmp;
8e08b761 76
4cbc57f0
JS
77 // type of event which is fired upon depression of this button
78 int mFiredEventType;
8e08b761 79
4cbc57f0
JS
80 // pens for drawing decorations (borders)
81 wxPen mBlackPen;
82 wxPen mDarkPen;
83 wxPen mGrayPen;
84 wxPen mLightPen;
8e08b761 85
4cbc57f0
JS
86 bool mIsCreated;
87 int mSizeIsSet;
8e08b761
JS
88
89protected:
8e08b761 90
4cbc57f0
JS
91 // Internal function for destroying labels.
92 void DestroyLabels();
8e08b761 93
4cbc57f0
JS
94 // Returns the label that matches the current button state.
95 virtual wxBitmap* GetStateLabel();
8e08b761 96
4cbc57f0
JS
97 // Draws shading on the button.
98 virtual void DrawShade( int outerLevel,
99 wxDC& dc,
100 wxPen& upperLeftSidePen,
101 wxPen& lowerRightSidePen );
102
c82c42d4 103 // Returns true if the given point is in the window.
4cbc57f0 104 bool IsInWindow( int x, int y );
8e08b761 105
ab839dff
JS
106 virtual void OnIdle(wxIdleEvent& event);
107 // (EVT_UPDATE_UI handler)
108 virtual void DoButtonUpdate();
109
8e08b761
JS
110public:
111
4cbc57f0
JS
112 // Constructor.
113 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
873a543b 114 const wxString& labelText = wxT(""),
4cbc57f0 115 int alignText = NB_ALIGN_TEXT_BOTTOM,
c82c42d4 116 bool isFlat = true,
4cbc57f0
JS
117 // this is the default type of fired events
118 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
65e50848
JS
119 int marginX = NB_DEFAULT_MARGIN,
120 int marginY = NB_DEFAULT_MARGIN,
4cbc57f0 121 int textToLabelGap = 2,
c82c42d4 122 bool isSticky = false
4cbc57f0
JS
123 );
124
125 // Use this constructor if buttons have to be persistant
126 wxNewBitmapButton( const wxString& bitmapFileName,
52b5ab7e 127 const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP,
873a543b 128 const wxString& labelText = wxT(""),
52b5ab7e 129 int alignText = NB_ALIGN_TEXT_BOTTOM,
c82c42d4 130 bool isFlat = true,
52b5ab7e
GD
131 // this is the default type of fired events
132 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
65e50848
JS
133 int marginX = NB_DEFAULT_MARGIN,
134 int marginY = NB_DEFAULT_MARGIN,
52b5ab7e 135 int textToLabelGap = 2,
c82c42d4 136 bool isSticky = false
52b5ab7e 137 );
8e08b761 138
4cbc57f0
JS
139 // Destructor.
140 ~wxNewBitmapButton();
141
142 // This function should be called after Create. It renders the labels, having
143 // reloaded the button image if necessary.
144 virtual void Reshape();
145
146 // Sets the label and optionally label text.
873a543b 147 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = wxT("") );
4cbc57f0 148
8552e6f0
MB
149 // Unhide method from parents.
150
151 virtual void SetLabel(const wxString& label)
152 { wxPanel::SetLabel(label); };
153
4cbc57f0
JS
154 // Sets the text alignment and margins.
155 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
65e50848
JS
156 int marginX = NB_DEFAULT_MARGIN,
157 int marginY = NB_DEFAULT_MARGIN,
4cbc57f0
JS
158 int textToLabelGap = 2);
159
160 // Draws the decorations.
161 virtual void DrawDecorations( wxDC& dc );
162
163 // Draws the label.
164 virtual void DrawLabel( wxDC& dc );
165
166 // Renders the label image.
167 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
c82c42d4
WS
168 bool isEnabled = true,
169 bool isPressed = false);
4cbc57f0
JS
170
171 // Renders label images.
172 virtual void RenderLabelImages();
173
174 // Renders label images.
175 virtual void RenderAllLabelImages();
176
45da7759
JS
177 // Enables/disables button
178 virtual bool Enable(bool enable);
179
ab839dff
JS
180 // Depress button
181 virtual bool Toggle(bool enable);
182
4cbc57f0
JS
183 // Responds to a left mouse button down event.
184 void OnLButtonDown( wxMouseEvent& event );
8e08b761 185
4cbc57f0
JS
186 // Responds to a left mouse button up event.
187 void OnLButtonUp( wxMouseEvent& event );
8e08b761 188
45da7759
JS
189 // Responds to mouse enter to window.
190 void OnMouseEnter( wxMouseEvent& event );
191
192 // Responds to mouse leave from window.
193 void OnMouseLeave( wxMouseEvent& event );
8e08b761 194
4cbc57f0
JS
195 // Responds to a size event.
196 void OnSize( wxSizeEvent& event );
8e08b761 197
4cbc57f0
JS
198 // Responds to a paint event.
199 void OnPaint( wxPaintEvent& event );
8e08b761 200
4cbc57f0
JS
201 // Responds to an erase background event.
202 void OnEraseBackground( wxEraseEvent& event );
8e08b761 203
4cbc57f0
JS
204 // Responds to a kill focus event.
205 void OnKillFocus( wxFocusEvent& event );
8e08b761 206
4cbc57f0 207 DECLARE_EVENT_TABLE()
8e08b761
JS
208};
209
210#endif /* __NEWBMPBTN_G__ */
211