]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/newbmpbtn.h
fixed typo (missing comma) in MIME test
[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
15#ifdef __GNUG__
16 #pragma interface "newbmpbtn.h"
17#endif
18
19#include "wx/button.h"
20#include "wx/string.h"
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
31class wxNewBitmapButton;
32class wxBorderLessBitmapButton;
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
JS
61 wxBitmap mFocusedBmp; // may not be always present -
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;
8e08b761 73
4cbc57f0 74 bool mHasFocusedBmp;
8e08b761 75
4cbc57f0
JS
76 // type of event which is fired upon depression of this button
77 int mFiredEventType;
8e08b761 78
4cbc57f0
JS
79 // pens for drawing decorations (borders)
80 wxPen mBlackPen;
81 wxPen mDarkPen;
82 wxPen mGrayPen;
83 wxPen mLightPen;
8e08b761 84
4cbc57f0
JS
85 bool mIsCreated;
86 int mSizeIsSet;
8e08b761
JS
87
88protected:
8e08b761 89
4cbc57f0
JS
90 // Internal function for destroying labels.
91 void DestroyLabels();
8e08b761 92
4cbc57f0
JS
93 // Returns the label that matches the current button state.
94 virtual wxBitmap* GetStateLabel();
8e08b761 95
4cbc57f0
JS
96 // Draws shading on the button.
97 virtual void DrawShade( int outerLevel,
98 wxDC& dc,
99 wxPen& upperLeftSidePen,
100 wxPen& lowerRightSidePen );
101
102 // Returns TRUE if the given point is in the window.
103 bool IsInWindow( int x, int y );
8e08b761
JS
104
105public:
106
4cbc57f0
JS
107 // Constructor.
108 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
109 const wxString& labelText = "",
110 int alignText = NB_ALIGN_TEXT_BOTTOM,
111 bool isFlat = TRUE,
112 // this is the default type of fired events
113 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
114 int marginX = 2,
115 int marginY = 2,
116 int textToLabelGap = 2,
117 bool isSticky = FALSE
118 );
119
120 // Use this constructor if buttons have to be persistant
121 wxNewBitmapButton( const wxString& bitmapFileName,
52b5ab7e
GD
122 const wxBitmapType bitmapFileType = wxBITMAP_TYPE_BMP,
123 const wxString& labelText = "",
124 int alignText = NB_ALIGN_TEXT_BOTTOM,
125 bool isFlat = TRUE,
126 // this is the default type of fired events
127 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
128 int marginX = 2,
129 int marginY = 2,
130 int textToLabelGap = 2,
131 bool isSticky = FALSE
132 );
8e08b761 133
4cbc57f0
JS
134 // Destructor.
135 ~wxNewBitmapButton();
136
137 // This function should be called after Create. It renders the labels, having
138 // reloaded the button image if necessary.
139 virtual void Reshape();
140
141 // Sets the label and optionally label text.
142 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" );
143
144 // Sets the text alignment and margins.
145 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
146 int marginX = 2,
147 int marginY = 2,
148 int textToLabelGap = 2);
149
150 // Draws the decorations.
151 virtual void DrawDecorations( wxDC& dc );
152
153 // Draws the label.
154 virtual void DrawLabel( wxDC& dc );
155
156 // Renders the label image.
157 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
158 bool isEnabled = TRUE,
159 bool isPressed = FALSE);
160
161 // Renders label images.
162 virtual void RenderLabelImages();
163
164 // Renders label images.
165 virtual void RenderAllLabelImages();
166
45da7759
JS
167 // Enables/disables button
168 virtual bool Enable(bool enable);
169
4cbc57f0
JS
170 // Responds to a left mouse button down event.
171 void OnLButtonDown( wxMouseEvent& event );
8e08b761 172
4cbc57f0
JS
173 // Responds to a left mouse button up event.
174 void OnLButtonUp( wxMouseEvent& event );
8e08b761 175
45da7759
JS
176 // Responds to a left mouse button double click.
177 void OnLButtonDClick( wxMouseEvent& event );
178
179 // Responds to mouse enter to window.
180 void OnMouseEnter( wxMouseEvent& event );
181
182 // Responds to mouse leave from window.
183 void OnMouseLeave( wxMouseEvent& event );
8e08b761 184
4cbc57f0
JS
185 // Responds to a size event.
186 void OnSize( wxSizeEvent& event );
8e08b761 187
4cbc57f0
JS
188 // Responds to a paint event.
189 void OnPaint( wxPaintEvent& event );
8e08b761 190
4cbc57f0
JS
191 // Responds to an erase background event.
192 void OnEraseBackground( wxEraseEvent& event );
8e08b761 193
4cbc57f0
JS
194 // Responds to a kill focus event.
195 void OnKillFocus( wxFocusEvent& event );
8e08b761 196
4cbc57f0 197 DECLARE_EVENT_TABLE()
8e08b761
JS
198};
199
200#endif /* __NEWBMPBTN_G__ */
201