]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bmpbuttn.h | |
3 | // Purpose: wxBitmapButton class | |
37f214d5 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
37f214d5 | 6 | // Created: 10/13/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
37f214d5 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_BMPBUTTN_H_ | |
13 | #define _WX_BMPBUTTN_H_ | |
14 | ||
0e320a79 DW |
15 | #include "wx/button.h" |
16 | ||
17 | WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; | |
18 | ||
19 | #define wxDEFAULT_BUTTON_MARGIN 4 | |
20 | ||
21 | class WXDLLEXPORT wxBitmapButton: public wxButton | |
22 | { | |
23 | DECLARE_DYNAMIC_CLASS(wxBitmapButton) | |
24 | public: | |
25 | inline wxBitmapButton() { m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; } | |
26 | inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, | |
27 | const wxPoint& pos = wxDefaultPosition, | |
28 | const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, | |
57c4d796 DW |
29 | #if wxUSE_VALIDATORS |
30 | # if defined(__VISAGECPP__) | |
31 | const wxValidator* validator = wxDefaultValidator, | |
32 | # else | |
0e320a79 | 33 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 DW |
34 | # endif |
35 | #endif | |
0e320a79 DW |
36 | const wxString& name = wxButtonNameStr) |
37 | { | |
38 | Create(parent, id, bitmap, pos, size, style, validator, name); | |
39 | } | |
40 | ||
41 | bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, | |
42 | const wxPoint& pos = wxDefaultPosition, | |
43 | const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, | |
57c4d796 DW |
44 | #if wxUSE_VALIDATORS |
45 | # if defined(__VISAGECPP__) | |
46 | const wxValidator* validator = wxDefaultValidator, | |
47 | # else | |
0e320a79 | 48 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 DW |
49 | # endif |
50 | #endif | |
0e320a79 DW |
51 | const wxString& name = wxButtonNameStr); |
52 | ||
53 | virtual void SetLabel(const wxBitmap& bitmap) | |
54 | { | |
55 | SetBitmapLabel(bitmap); | |
56 | } | |
57 | ||
58 | virtual void SetBitmapLabel(const wxBitmap& bitmap); | |
59 | ||
37f214d5 DW |
60 | #if WXWIN_COMPATIBILITY |
61 | wxBitmap *GetBitmap() const { return (wxBitmap *) & m_buttonBitmap; } | |
62 | #endif | |
63 | ||
0e320a79 DW |
64 | inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; } |
65 | inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; } | |
66 | inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; } | |
67 | inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; } | |
68 | ||
69 | inline void SetBitmapSelected(const wxBitmap& sel) { m_buttonBitmapSelected = sel; }; | |
70 | inline void SetBitmapFocus(const wxBitmap& focus) { m_buttonBitmapFocus = focus; }; | |
71 | inline void SetBitmapDisabled(const wxBitmap& disabled) { m_buttonBitmapDisabled = disabled; }; | |
72 | ||
73 | inline void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } | |
74 | inline int GetMarginX() { return m_marginX; } | |
75 | inline int GetMarginY() { return m_marginY; } | |
76 | ||
37f214d5 DW |
77 | virtual void SetDefault(); |
78 | // virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *item); | |
0e320a79 DW |
79 | virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel ); |
80 | virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ); | |
81 | virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ); | |
0e320a79 DW |
82 | |
83 | protected: | |
84 | wxBitmap m_buttonBitmap; | |
85 | wxBitmap m_buttonBitmapSelected; | |
86 | wxBitmap m_buttonBitmapFocus; | |
87 | wxBitmap m_buttonBitmapDisabled; | |
88 | int m_marginX; | |
89 | int m_marginY; | |
90 | private: | |
54da4255 DW |
91 | virtual void SetLabel(const wxString& string) |
92 | { wxButton::SetLabel(string); }; | |
0e320a79 DW |
93 | }; |
94 | ||
95 | #endif | |
96 | // _WX_BMPBUTTN_H_ |