deprecate SetLabel(const wxBitmap&)
[wxWidgets.git] / include / wx / bmpbuttn.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BMPBUTTON_H_BASE_
13 #define _WX_BMPBUTTON_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_BMPBUTTON
18
19 #include "wx/bitmap.h"
20 #include "wx/button.h"
21
22 extern WXDLLEXPORT_DATA(const wxChar*) wxButtonNameStr;
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
29 class WXDLLEXPORT wxBitmapButtonBase : public wxButton
30 {
31 public:
32 wxBitmapButtonBase()
33 {
34 m_marginX =
35 m_marginY = 0;
36 }
37
38 // set the bitmaps
39 void SetBitmapLabel(const wxBitmap& bitmap)
40 { m_bmpNormal = bitmap; OnSetBitmap(); }
41 void SetBitmapSelected(const wxBitmap& sel)
42 { m_bmpSelected = sel; OnSetBitmap(); };
43 void SetBitmapFocus(const wxBitmap& focus)
44 { m_bmpFocus = focus; OnSetBitmap(); };
45 void SetBitmapDisabled(const wxBitmap& disabled)
46 { m_bmpDisabled = disabled; OnSetBitmap(); };
47
48 // retrieve the bitmaps
49 const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; }
50 const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; }
51 const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; }
52 const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; }
53 wxBitmap& GetBitmapLabel() { return m_bmpNormal; }
54 wxBitmap& GetBitmapSelected() { return m_bmpSelected; }
55 wxBitmap& GetBitmapFocus() { return m_bmpFocus; }
56 wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; }
57
58 // set/get the margins around the button
59 virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
60 int GetMarginX() const { return m_marginX; }
61 int GetMarginY() const { return m_marginY; }
62
63 // deprecated synonym for SetBitmapLabel()
64 #if WXWIN_COMPATIBILITY_2_6
65 wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) );
66 { SetBitmapLabel(bitmap); }
67
68 // prevent virtual function hiding
69 virtual void SetLabel(const wxString& label)
70 { wxWindowBase::SetLabel(label); }
71 #endif // WXWIN_COMPATIBILITY_2_6
72
73 protected:
74 // function called when any of the bitmaps changes
75 virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
76
77 // the bitmaps for various states
78 wxBitmap m_bmpNormal,
79 m_bmpSelected,
80 m_bmpFocus,
81 m_bmpDisabled;
82
83 // the margins around the bitmap
84 int m_marginX,
85 m_marginY;
86
87
88 DECLARE_NO_COPY_CLASS(wxBitmapButtonBase)
89 };
90
91 #if WXWIN_COMPATIBILITY_2_6
92 inline void SetLabel(const wxBitmap& bitmap) { SetBitmapLabel(bitmap); }
93 #endif // WXWIN_COMPATIBILITY_2_6
94
95 #if defined(__WXUNIVERSAL__)
96 #include "wx/univ/bmpbuttn.h"
97 #elif defined(__WXMSW__)
98 #include "wx/msw/bmpbuttn.h"
99 #elif defined(__WXMOTIF__)
100 #include "wx/motif/bmpbuttn.h"
101 #elif defined(__WXGTK__)
102 #include "wx/gtk/bmpbuttn.h"
103 #elif defined(__WXMAC__)
104 #include "wx/mac/bmpbuttn.h"
105 #elif defined(__WXCOCOA__)
106 #include "wx/cocoa/bmpbuttn.h"
107 #elif defined(__WXPM__)
108 #include "wx/os2/bmpbuttn.h"
109 #endif
110
111 #endif // wxUSE_BMPBUTTON
112
113 #endif // _WX_BMPBUTTON_H_BASE_