]>
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 | ||
1e6feb95 VZ |
19 | #include "wx/button.h" |
20 | ||
c37dd6da | 21 | // FIXME: right now only wxMSW and wxGTK implement bitmap support in wxButton |
a6fd73d3 VZ |
22 | // itself, this shouldn't be used for the other platforms neither |
23 | // when all of them do it | |
ca3b3fbb | 24 | #if (defined(__WXMSW__) || defined(__WXGTK20__)) && !defined(__WXUNIVERSAL__) |
a6fd73d3 VZ |
25 | #define wxHAS_BUTTON_BITMAP |
26 | #endif | |
1e6feb95 VZ |
27 | |
28 | // ---------------------------------------------------------------------------- | |
29 | // wxBitmapButton: a button which shows bitmaps instead of the usual string. | |
30 | // It has different bitmaps for different states (focused/disabled/pressed) | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
53a2db12 | 33 | class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton |
1e6feb95 VZ |
34 | { |
35 | public: | |
6463b9f5 | 36 | wxBitmapButtonBase() |
6b5a2b6f | 37 | { |
a6fd73d3 | 38 | #ifndef wxHAS_BUTTON_BITMAP |
6b5a2b6f VZ |
39 | m_marginX = |
40 | m_marginY = 0; | |
a6fd73d3 | 41 | #endif // wxHAS_BUTTON_BITMAP |
6b5a2b6f | 42 | } |
1e6feb95 | 43 | |
1e6feb95 | 44 | // set/get the margins around the button |
a6fd73d3 VZ |
45 | virtual void SetMargins(int x, int y) |
46 | { | |
47 | DoSetBitmapMargins(x, y); | |
48 | } | |
49 | ||
50 | int GetMarginX() const { return DoGetBitmapMargins().x; } | |
51 | int GetMarginY() const { return DoGetBitmapMargins().y; } | |
1e6feb95 | 52 | |
6b5a2b6f VZ |
53 | // deprecated synonym for SetBitmapLabel() |
54 | #if WXWIN_COMPATIBILITY_2_6 | |
eebe696e VZ |
55 | wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap), |
56 | SetBitmapLabel(bitmap); ) | |
6b5a2b6f VZ |
57 | |
58 | // prevent virtual function hiding | |
59 | virtual void SetLabel(const wxString& label) | |
faa49bfd | 60 | { wxWindow::SetLabel(label); } |
6b5a2b6f VZ |
61 | #endif // WXWIN_COMPATIBILITY_2_6 |
62 | ||
1e6feb95 | 63 | protected: |
a6fd73d3 | 64 | #ifndef wxHAS_BUTTON_BITMAP |
1e6feb95 | 65 | // function called when any of the bitmaps changes |
c46b98da | 66 | virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); } |
1e6feb95 | 67 | |
2352862a VZ |
68 | virtual wxBitmap DoGetBitmap(State which) const { return m_bitmaps[which]; } |
69 | virtual void DoSetBitmap(const wxBitmap& bitmap, State which) | |
70 | { m_bitmaps[which] = bitmap; OnSetBitmap(); } | |
71 | ||
a6fd73d3 VZ |
72 | virtual wxSize DoGetBitmapMargins() const |
73 | { | |
74 | return wxSize(m_marginX, m_marginY); | |
75 | } | |
76 | ||
77 | virtual void DoSetBitmapMargins(int x, int y) | |
78 | { | |
79 | m_marginX = x; | |
80 | m_marginY = y; | |
81 | } | |
82 | ||
1e6feb95 | 83 | // the bitmaps for various states |
2352862a | 84 | wxBitmap m_bitmaps[State_Max]; |
1e6feb95 VZ |
85 | |
86 | // the margins around the bitmap | |
87 | int m_marginX, | |
88 | m_marginY; | |
a6fd73d3 | 89 | #endif // !wxHAS_BUTTON_BITMAP |
fc7a2a60 | 90 | |
c0c133e1 | 91 | wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase); |
1e6feb95 VZ |
92 | }; |
93 | ||
94 | #if defined(__WXUNIVERSAL__) | |
95 | #include "wx/univ/bmpbuttn.h" | |
96 | #elif defined(__WXMSW__) | |
97 | #include "wx/msw/bmpbuttn.h" | |
2049ba38 | 98 | #elif defined(__WXMOTIF__) |
1e6feb95 | 99 | #include "wx/motif/bmpbuttn.h" |
1be7a35c | 100 | #elif defined(__WXGTK20__) |
1e6feb95 | 101 | #include "wx/gtk/bmpbuttn.h" |
1be7a35c MR |
102 | #elif defined(__WXGTK__) |
103 | #include "wx/gtk1/bmpbuttn.h" | |
34138703 | 104 | #elif defined(__WXMAC__) |
ef0e9220 | 105 | #include "wx/osx/bmpbuttn.h" |
e64df9bc DE |
106 | #elif defined(__WXCOCOA__) |
107 | #include "wx/cocoa/bmpbuttn.h" | |
1777b9bb | 108 | #elif defined(__WXPM__) |
1e6feb95 | 109 | #include "wx/os2/bmpbuttn.h" |
9b4da627 VZ |
110 | #elif defined(__WXPALMOS__) |
111 | #include "wx/palmos/bmpbuttn.h" | |
c801d85f KB |
112 | #endif |
113 | ||
1e6feb95 VZ |
114 | #endif // wxUSE_BMPBUTTON |
115 | ||
116 | #endif // _WX_BMPBUTTON_H_BASE_ |