]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/newbmpbtn.h
Changed to use new wxWindow->Reparent call to allow build with current cvs
[wxWidgets.git] / utils / framelayout / src / newbmpbtn.h
CommitLineData
bd9396d5
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: ??/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __NEWBMPBTN_G__
13#define __NEWBMPBTN_G__
14
15#include "wx/button.h"
16#include "wx/string.h"
17
18// button lable-text alignment types
19
20#define NB_ALIGN_TEXT_RIGHT 0
21#define NB_ALIGN_TEXT_BOTTOM 1
22#define NB_NO_TEXT 2
23#define NB_NO_IMAGE 3
24
25// classes declared in this header file
26
27class wxNewBitmapButton;
28class wxBorderLessBitmapButton;
29
30// alternative class for wxBmpButton
31
32class wxNewBitmapButton: public wxPanel
33{
34 DECLARE_DYNAMIC_CLASS(wxNewBitmapButton)
35
36protected:
37
38 friend class wxNewBitmapButtonSerializer;
39
40 int mTextToLabelGap;
41 int mMarginX;
42 int mMarginY;
43 int mTextAlignment;
44 bool mIsSticky;
af11388a 45 bool mIsFlat;
bd9396d5
HH
46
47 wxString mLabelText;
48 wxString mImageFileName;
49 int mImageFileType;
bd9396d5
HH
50
51 wxBitmap mDepressedBmp; // source image for rendering
52 // labels for particular state
53
54 wxBitmap mFocusedBmp; // may not be always present -
55 // only if mHasFocusedBmp is TRUE
56
57 wxBitmap* mpDepressedImg;
58 wxBitmap* mpPressedImg;
59 wxBitmap* mpDisabledImg;
60 wxBitmap* mpFocusedImg;
61
62 // button state variables;
63 bool mDragStarted;
64 bool mIsPressed;
65 bool mIsInFocus;
66 bool mPrevPressedState;
af11388a 67 bool mPrevInFocusState;
bd9396d5
HH
68
69 bool mHasFocusedBmp;
70
71 // type of event which is fired upon depression of this button
72 int mFiredEventType;
73
74 // pens for drawing decorations (borders)
75 wxPen mBlackPen;
76 wxPen mDarkPen;
77 wxPen mGrayPen;
78 wxPen mLightPen;
79
80 bool mIsCreated;
81 int mSizeIsSet;
82
83protected:
84 void DestroyLabels();
85
86 // returns the label which match the current button state
87 virtual wxBitmap* GetStateLabel();
88
89 virtual void DrawShade( int outerLevel,
90 wxDC& dc,
91 wxPen& upperLeftSidePen,
92 wxPen& lowerRightSidePen );
93
94 bool IsInWindow( int x,int y );
95
96public:
97
98 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
99 const wxString& labelText = "",
100 int alignText = NB_ALIGN_TEXT_BOTTOM,
101 bool isFlat = TRUE,
102 // this is the default type of fired events
103 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
104 int marginX = 2,
105 int marginY = 2,
106 int textToLabelGap = 2,
107 bool isSticky = FALSE
108 );
109
110 // use this constructor if buttons have to be persistant
111
112 wxNewBitmapButton( const wxString& bitmapFileName,
113 const int bitmapFileType = wxBITMAP_TYPE_BMP,
114 const wxString& labelText = "",
115 int alignText = NB_ALIGN_TEXT_BOTTOM,
116 bool isFlat = TRUE,
117 // this is the default type of fired events
118 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
119 int marginX = 2,
120 int marginY = 2,
121 int textToLabelGap = 2,
122 bool isSticky = FALSE
123 );
124
125 ~wxNewBitmapButton();
126
127 // should be called after Create();
128 virtual void Reshape();
129
130 // overridables
131 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" );
132
133 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
134 int marginX = 2,
135 int marginY = 2,
136 int textToLabelGap = 2);
137
138 virtual void DrawDecorations( wxDC& dc );
139 virtual void DrawLabel( wxDC& dc );
140
141 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
142 bool isEnabled = TRUE,
143 bool isPressed = FALSE);
144
145 virtual void RenderLabelImages();
af11388a 146 virtual void RenderAllLabelImages();
bd9396d5
HH
147
148 // event handlers
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 );
156
157 DECLARE_EVENT_TABLE()
158};
159
160#endif