]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/newbmpbtn.h
vc makefile
[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;
45
46 wxString mLabelText;
47 wxString mImageFileName;
48 int mImageFileType;
49 bool mIsFlat;
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;
67
68 bool mHasFocusedBmp;
69
70 // type of event which is fired upon depression of this button
71 int mFiredEventType;
72
73 // pens for drawing decorations (borders)
74 wxPen mBlackPen;
75 wxPen mDarkPen;
76 wxPen mGrayPen;
77 wxPen mLightPen;
78
79 bool mIsCreated;
80 int mSizeIsSet;
81
82protected:
83 void DestroyLabels();
84
85 // returns the label which match the current button state
86 virtual wxBitmap* GetStateLabel();
87
88 virtual void DrawShade( int outerLevel,
89 wxDC& dc,
90 wxPen& upperLeftSidePen,
91 wxPen& lowerRightSidePen );
92
93 bool IsInWindow( int x,int y );
94
95public:
96
97 wxNewBitmapButton( const wxBitmap& labelBitmap = wxNullBitmap,
98 const wxString& labelText = "",
99 int alignText = NB_ALIGN_TEXT_BOTTOM,
100 bool isFlat = TRUE,
101 // this is the default type of fired events
102 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
103 int marginX = 2,
104 int marginY = 2,
105 int textToLabelGap = 2,
106 bool isSticky = FALSE
107 );
108
109 // use this constructor if buttons have to be persistant
110
111 wxNewBitmapButton( const wxString& bitmapFileName,
112 const int bitmapFileType = wxBITMAP_TYPE_BMP,
113 const wxString& labelText = "",
114 int alignText = NB_ALIGN_TEXT_BOTTOM,
115 bool isFlat = TRUE,
116 // this is the default type of fired events
117 int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
118 int marginX = 2,
119 int marginY = 2,
120 int textToLabelGap = 2,
121 bool isSticky = FALSE
122 );
123
124 ~wxNewBitmapButton();
125
126 // should be called after Create();
127 virtual void Reshape();
128
129 // overridables
130 virtual void SetLabel(const wxBitmap& labelBitmap, const wxString& labelText = "" );
131
132 virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
133 int marginX = 2,
134 int marginY = 2,
135 int textToLabelGap = 2);
136
137 virtual void DrawDecorations( wxDC& dc );
138 virtual void DrawLabel( wxDC& dc );
139
140 virtual void RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp,
141 bool isEnabled = TRUE,
142 bool isPressed = FALSE);
143
144 virtual void RenderLabelImages();
145
146 // event handlers
147 void OnLButtonDown( wxMouseEvent& event );
148 void OnLButtonUp( wxMouseEvent& event );
149 void OnMouseMove( wxMouseEvent& event );
150 void OnSize( wxSizeEvent& event );
151 void OnPaint( wxPaintEvent& event );
152 void OnEraseBackground( wxEraseEvent& event );
153 void OnKillFocus( wxFocusEvent& event );
154
155 DECLARE_EVENT_TABLE()
156};
157
158#endif