]>
Commit | Line | Data |
---|---|---|
8e08b761 JS |
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 | #ifdef __GNUG__ | |
16 | #pragma interface "newbmpbtn.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/button.h" | |
20 | #include "wx/string.h" | |
21 | ||
22 | // button lable-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 | // alternative class for wxBmpButton | |
35 | ||
36 | class wxNewBitmapButton: public wxPanel | |
37 | { | |
38 | DECLARE_DYNAMIC_CLASS(wxNewBitmapButton) | |
39 | ||
40 | protected: | |
41 | ||
42 | friend class wxNewBitmapButtonSerializer; | |
43 | ||
44 | int mTextToLabelGap; | |
45 | int mMarginX; | |
46 | int mMarginY; | |
47 | int mTextAlignment; | |
48 | bool mIsSticky; | |
49 | bool mIsFlat; | |
50 | ||
51 | wxString mLabelText; | |
52 | wxString mImageFileName; | |
53 | int mImageFileType; | |
54 | ||
55 | wxBitmap mDepressedBmp; // source image for rendering | |
56 | // labels for particular state | |
57 | ||
58 | wxBitmap mFocusedBmp; // may not be always present - | |
59 | // only if mHasFocusedBmp is TRUE | |
60 | ||
61 | wxBitmap* mpDepressedImg; | |
62 | wxBitmap* mpPressedImg; | |
63 | wxBitmap* mpDisabledImg; | |
64 | wxBitmap* mpFocusedImg; | |
65 | ||
66 | // button state variables; | |
67 | bool mDragStarted; | |
68 | bool mIsPressed; | |
69 | bool mIsInFocus; | |
70 | bool mPrevPressedState; | |
71 | bool mPrevInFocusState; | |
72 | ||
73 | bool mHasFocusedBmp; | |
74 | ||
75 | // type of event which is fired upon depression of this button | |
76 | int mFiredEventType; | |
77 | ||
78 | // pens for drawing decorations (borders) | |
79 | wxPen mBlackPen; | |
80 | wxPen mDarkPen; | |
81 | wxPen mGrayPen; | |
82 | wxPen mLightPen; | |
83 | ||
84 | bool mIsCreated; | |
85 | int mSizeIsSet; | |
86 | ||
87 | protected: | |
88 | void DestroyLabels(); | |
89 | ||
90 | // returns the label which match the current button state | |
91 | virtual wxBitmap* GetStateLabel(); | |
92 | ||
93 | virtual void DrawShade( int outerLevel, | |
94 | wxDC& dc, | |
95 | wxPen& upperLeftSidePen, | |
96 | wxPen& lowerRightSidePen ); | |
97 | ||
98 | bool IsInWindow( int x,int y ); | |
99 | ||
100 | public: | |
101 | ||
102 | wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap, | |
103 | const wxString& labelText = "", | |
104 | int alignText = NB_ALIGN_TEXT_BOTTOM, | |
105 | bool isFlat = TRUE, | |
106 | // this is the default type of fired events | |
107 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
108 | int marginX = 2, | |
109 | int marginY = 2, | |
110 | int textToLabelGap = 2, | |
111 | bool isSticky = FALSE | |
112 | ); | |
113 | ||
114 | // use this constructor if buttons have to be persistant | |
115 | ||
116 | wxNewBitmapButton( const wxString& bitmapFileName, | |
117 | const int bitmapFileType = wxBITMAP_TYPE_BMP, | |
118 | const wxString& labelText = "", | |
119 | int alignText = NB_ALIGN_TEXT_BOTTOM, | |
120 | bool isFlat = TRUE, | |
121 | // this is the default type of fired events | |
122 | int firedEventType = wxEVT_COMMAND_MENU_SELECTED, | |
123 | int marginX = 2, | |
124 | int marginY = 2, | |
125 | int textToLabelGap = 2, | |
126 | bool isSticky = FALSE | |
127 | ); | |
128 | ||
129 | ~wxNewBitmapButton(); | |
130 | ||
131 | // should be called after Create(); | |
132 | virtual void Reshape(); | |
133 | ||
134 | // overridables | |
135 | virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" ); | |
136 | ||
137 | virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, | |
138 | int marginX = 2, | |
139 | int marginY = 2, | |
140 | int textToLabelGap = 2); | |
141 | ||
142 | virtual void DrawDecorations( wxDC& dc ); | |
143 | virtual void DrawLabel( wxDC& dc ); | |
144 | ||
145 | virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, | |
146 | bool isEnabled = TRUE, | |
147 | bool isPressed = FALSE); | |
148 | ||
149 | virtual void RenderLabelImages(); | |
150 | virtual void RenderAllLabelImages(); | |
151 | ||
152 | // event handlers | |
153 | void OnLButtonDown( wxMouseEvent& event ); | |
154 | void OnLButtonUp( wxMouseEvent& event ); | |
155 | void OnMouseMove( wxMouseEvent& event ); | |
156 | void OnSize( wxSizeEvent& event ); | |
157 | void OnPaint( wxPaintEvent& event ); | |
158 | void OnEraseBackground( wxEraseEvent& event ); | |
159 | void OnKillFocus( wxFocusEvent& event ); | |
160 | ||
161 | DECLARE_EVENT_TABLE() | |
162 | }; | |
163 | ||
164 | #endif /* __NEWBMPBTN_G__ */ | |
165 |