1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxBitmapButton class interface
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_BMPBUTTON_H_BASE_
12 #define _WX_BMPBUTTON_H_BASE_
18 #include "wx/button.h"
20 // FIXME: right now only wxMSW, wxGTK and wxOSX implement bitmap support in wxButton
21 // itself, this shouldn't be used for the other platforms neither
22 // when all of them do it
23 #if (defined(__WXMSW__) || defined(__WXGTK20__) || defined(__WXOSX__)) && !defined(__WXUNIVERSAL__)
24 #define wxHAS_BUTTON_BITMAP
27 class WXDLLIMPEXP_FWD_CORE wxBitmapButton
;
29 // ----------------------------------------------------------------------------
30 // wxBitmapButton: a button which shows bitmaps instead of the usual string.
31 // It has different bitmaps for different states (focused/disabled/pressed)
32 // ----------------------------------------------------------------------------
34 class WXDLLIMPEXP_CORE wxBitmapButtonBase
: public wxButton
39 #ifndef wxHAS_BUTTON_BITMAP
42 #endif // wxHAS_BUTTON_BITMAP
45 bool Create(wxWindow
*parent
,
50 const wxValidator
& validator
,
53 // We use wxBU_NOTEXT to let the base class Create() know that we are
54 // not going to show the label: this is a hack needed for wxGTK where
55 // we can show both label and bitmap only with GTK 2.6+ but we always
56 // can show just one of them and this style allows us to choose which
59 // And we also use wxBU_EXACTFIT to avoid being resized up to the
60 // standard button size as this doesn't make sense for bitmap buttons
61 // which are not standard anyhow and should fit their bitmap size.
62 return wxButton::Create(parent
, winid
, "",
64 style
| wxBU_NOTEXT
| wxBU_EXACTFIT
,
68 // Special creation function for a standard "Close" bitmap. It allows to
69 // simply create a close button with the image appropriate for the common
71 static wxBitmapButton
* NewCloseButton(wxWindow
* parent
, wxWindowID winid
);
74 // set/get the margins around the button
75 virtual void SetMargins(int x
, int y
)
77 DoSetBitmapMargins(x
, y
);
80 int GetMarginX() const { return DoGetBitmapMargins().x
; }
81 int GetMarginY() const { return DoGetBitmapMargins().y
; }
83 // deprecated synonym for SetBitmapLabel()
84 #if WXWIN_COMPATIBILITY_2_6
85 wxDEPRECATED_INLINE( void SetLabel(const wxBitmap
& bitmap
),
86 SetBitmapLabel(bitmap
); )
88 // prevent virtual function hiding
89 virtual void SetLabel(const wxString
& label
)
90 { wxWindow::SetLabel(label
); }
91 #endif // WXWIN_COMPATIBILITY_2_6
94 #ifndef wxHAS_BUTTON_BITMAP
95 // function called when any of the bitmaps changes
96 virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
98 virtual wxBitmap
DoGetBitmap(State which
) const { return m_bitmaps
[which
]; }
99 virtual void DoSetBitmap(const wxBitmap
& bitmap
, State which
)
100 { m_bitmaps
[which
] = bitmap
; OnSetBitmap(); }
102 virtual wxSize
DoGetBitmapMargins() const
104 return wxSize(m_marginX
, m_marginY
);
107 virtual void DoSetBitmapMargins(int x
, int y
)
113 // the bitmaps for various states
114 wxBitmap m_bitmaps
[State_Max
];
116 // the margins around the bitmap
119 #endif // !wxHAS_BUTTON_BITMAP
121 wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase
);
124 #if defined(__WXUNIVERSAL__)
125 #include "wx/univ/bmpbuttn.h"
126 #elif defined(__WXMSW__)
127 #include "wx/msw/bmpbuttn.h"
128 #elif defined(__WXMOTIF__)
129 #include "wx/motif/bmpbuttn.h"
130 #elif defined(__WXGTK20__)
131 #include "wx/gtk/bmpbuttn.h"
132 #elif defined(__WXGTK__)
133 #include "wx/gtk1/bmpbuttn.h"
134 #elif defined(__WXMAC__)
135 #include "wx/osx/bmpbuttn.h"
136 #elif defined(__WXCOCOA__)
137 #include "wx/cocoa/bmpbuttn.h"
138 #elif defined(__WXPM__)
139 #include "wx/os2/bmpbuttn.h"
142 #endif // wxUSE_BMPBUTTON
144 #endif // _WX_BMPBUTTON_H_BASE_