]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/bmpbutton.h | |
3 | // Purpose: wxBitmapButton class interface | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 25.08.00 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2000 Vadim Zeitlin | |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_BMPBUTTON_H_BASE_ |
13 | #define _WX_BMPBUTTON_H_BASE_ | |
c801d85f | 14 | |
997176a3 VZ |
15 | #include "wx/defs.h" |
16 | ||
1e6feb95 VZ |
17 | #if wxUSE_BMPBUTTON |
18 | ||
19 | #include "wx/bitmap.h" | |
20 | #include "wx/button.h" | |
21 | ||
53a2db12 | 22 | extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[]; |
1e6feb95 VZ |
23 | |
24 | // ---------------------------------------------------------------------------- | |
25 | // wxBitmapButton: a button which shows bitmaps instead of the usual string. | |
26 | // It has different bitmaps for different states (focused/disabled/pressed) | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
53a2db12 | 29 | class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton |
1e6feb95 VZ |
30 | { |
31 | public: | |
6463b9f5 | 32 | wxBitmapButtonBase() |
6b5a2b6f VZ |
33 | { |
34 | m_marginX = | |
35 | m_marginY = 0; | |
36 | } | |
1e6feb95 VZ |
37 | |
38 | // set the bitmaps | |
5f1f21d2 | 39 | virtual void SetBitmapLabel(const wxBitmap& bitmap) |
1e6feb95 | 40 | { m_bmpNormal = bitmap; OnSetBitmap(); } |
5f1f21d2 | 41 | virtual void SetBitmapSelected(const wxBitmap& sel) |
47b378bd | 42 | { m_bmpSelected = sel; OnSetBitmap(); } |
5f1f21d2 | 43 | virtual void SetBitmapFocus(const wxBitmap& focus) |
47b378bd | 44 | { m_bmpFocus = focus; OnSetBitmap(); } |
5f1f21d2 | 45 | virtual void SetBitmapDisabled(const wxBitmap& disabled) |
47b378bd | 46 | { m_bmpDisabled = disabled; OnSetBitmap(); } |
5f1f21d2 | 47 | virtual void SetBitmapHover(const wxBitmap& hover) |
1fdc16ad | 48 | { m_bmpHover = hover; OnSetBitmap(); } |
1e6feb95 VZ |
49 | |
50 | // retrieve the bitmaps | |
51 | const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; } | |
52 | const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; } | |
53 | const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; } | |
54 | const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } | |
1fdc16ad | 55 | const wxBitmap& GetBitmapHover() const { return m_bmpHover; } |
1e6feb95 VZ |
56 | wxBitmap& GetBitmapLabel() { return m_bmpNormal; } |
57 | wxBitmap& GetBitmapSelected() { return m_bmpSelected; } | |
58 | wxBitmap& GetBitmapFocus() { return m_bmpFocus; } | |
59 | wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; } | |
1fdc16ad | 60 | wxBitmap& GetBitmapHover() { return m_bmpHover; } |
1e6feb95 VZ |
61 | |
62 | // set/get the margins around the button | |
63 | virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } | |
64 | int GetMarginX() const { return m_marginX; } | |
65 | int GetMarginY() const { return m_marginY; } | |
66 | ||
6b5a2b6f VZ |
67 | // deprecated synonym for SetBitmapLabel() |
68 | #if WXWIN_COMPATIBILITY_2_6 | |
69 | wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) ); | |
6b5a2b6f VZ |
70 | |
71 | // prevent virtual function hiding | |
72 | virtual void SetLabel(const wxString& label) | |
faa49bfd | 73 | { wxWindow::SetLabel(label); } |
6b5a2b6f VZ |
74 | #endif // WXWIN_COMPATIBILITY_2_6 |
75 | ||
1e6feb95 VZ |
76 | protected: |
77 | // function called when any of the bitmaps changes | |
c46b98da | 78 | virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); } |
1e6feb95 VZ |
79 | |
80 | // the bitmaps for various states | |
81 | wxBitmap m_bmpNormal, | |
82 | m_bmpSelected, | |
83 | m_bmpFocus, | |
1fdc16ad VZ |
84 | m_bmpDisabled, |
85 | m_bmpHover; | |
1e6feb95 VZ |
86 | |
87 | // the margins around the bitmap | |
88 | int m_marginX, | |
89 | m_marginY; | |
fc7a2a60 | 90 | |
fc7a2a60 VZ |
91 | |
92 | DECLARE_NO_COPY_CLASS(wxBitmapButtonBase) | |
1e6feb95 VZ |
93 | }; |
94 | ||
6b5a2b6f | 95 | #if WXWIN_COMPATIBILITY_2_6 |
6aad0c70 VZ |
96 | inline void wxBitmapButtonBase::SetLabel(const wxBitmap& bitmap) |
97 | { | |
98 | SetBitmapLabel(bitmap); | |
99 | } | |
6b5a2b6f VZ |
100 | #endif // WXWIN_COMPATIBILITY_2_6 |
101 | ||
1e6feb95 VZ |
102 | #if defined(__WXUNIVERSAL__) |
103 | #include "wx/univ/bmpbuttn.h" | |
104 | #elif defined(__WXMSW__) | |
105 | #include "wx/msw/bmpbuttn.h" | |
2049ba38 | 106 | #elif defined(__WXMOTIF__) |
1e6feb95 | 107 | #include "wx/motif/bmpbuttn.h" |
1be7a35c | 108 | #elif defined(__WXGTK20__) |
1e6feb95 | 109 | #include "wx/gtk/bmpbuttn.h" |
1be7a35c MR |
110 | #elif defined(__WXGTK__) |
111 | #include "wx/gtk1/bmpbuttn.h" | |
34138703 | 112 | #elif defined(__WXMAC__) |
1e6feb95 | 113 | #include "wx/mac/bmpbuttn.h" |
e64df9bc DE |
114 | #elif defined(__WXCOCOA__) |
115 | #include "wx/cocoa/bmpbuttn.h" | |
1777b9bb | 116 | #elif defined(__WXPM__) |
1e6feb95 | 117 | #include "wx/os2/bmpbuttn.h" |
9b4da627 VZ |
118 | #elif defined(__WXPALMOS__) |
119 | #include "wx/palmos/bmpbuttn.h" | |
c801d85f KB |
120 | #endif |
121 | ||
1e6feb95 VZ |
122 | #endif // wxUSE_BMPBUTTON |
123 | ||
124 | #endif // _WX_BMPBUTTON_H_BASE_ |