]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bmpbuttn.h
Remove RPM .spec files from the repository.
[wxWidgets.git] / include / wx / bmpbuttn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/bmpbuttn.h
3 // Purpose: wxBitmapButton class interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 25.08.00
7 // Copyright: (c) 2000 Vadim Zeitlin
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_BMPBUTTON_H_BASE_
12 #define _WX_BMPBUTTON_H_BASE_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_BMPBUTTON
17
18 #include "wx/button.h"
19
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
25 #endif
26
27 class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
28
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 // ----------------------------------------------------------------------------
33
34 class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton
35 {
36 public:
37 wxBitmapButtonBase()
38 {
39 #ifndef wxHAS_BUTTON_BITMAP
40 m_marginX =
41 m_marginY = 0;
42 #endif // wxHAS_BUTTON_BITMAP
43 }
44
45 bool Create(wxWindow *parent,
46 wxWindowID winid,
47 const wxPoint& pos,
48 const wxSize& size,
49 long style,
50 const wxValidator& validator,
51 const wxString& name)
52 {
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
57 // one we need.
58 //
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, "",
63 pos, size,
64 style | wxBU_NOTEXT | wxBU_EXACTFIT,
65 validator, name);
66 }
67
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
70 // platform.
71 static wxBitmapButton* NewCloseButton(wxWindow* parent, wxWindowID winid);
72
73
74 // set/get the margins around the button
75 virtual void SetMargins(int x, int y)
76 {
77 DoSetBitmapMargins(x, y);
78 }
79
80 int GetMarginX() const { return DoGetBitmapMargins().x; }
81 int GetMarginY() const { return DoGetBitmapMargins().y; }
82
83 // deprecated synonym for SetBitmapLabel()
84 #if WXWIN_COMPATIBILITY_2_6
85 wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap),
86 SetBitmapLabel(bitmap); )
87
88 // prevent virtual function hiding
89 virtual void SetLabel(const wxString& label)
90 { wxWindow::SetLabel(label); }
91 #endif // WXWIN_COMPATIBILITY_2_6
92
93 protected:
94 #ifndef wxHAS_BUTTON_BITMAP
95 // function called when any of the bitmaps changes
96 virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
97
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(); }
101
102 virtual wxSize DoGetBitmapMargins() const
103 {
104 return wxSize(m_marginX, m_marginY);
105 }
106
107 virtual void DoSetBitmapMargins(int x, int y)
108 {
109 m_marginX = x;
110 m_marginY = y;
111 }
112
113 // the bitmaps for various states
114 wxBitmap m_bitmaps[State_Max];
115
116 // the margins around the bitmap
117 int m_marginX,
118 m_marginY;
119 #endif // !wxHAS_BUTTON_BITMAP
120
121 wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase);
122 };
123
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"
140 #endif
141
142 #endif // wxUSE_BMPBUTTON
143
144 #endif // _WX_BMPBUTTON_H_BASE_