1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/commandlinkbutton.h
3 // Purpose: wxCommandLinkButtonBase and wxGenericCommandLinkButton classes
4 // Author: Rickard Westerlund
6 // Copyright: (c) 2010 wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_COMMANDLINKBUTTON_H_
11 #define _WX_COMMANDLINKBUTTON_H_
15 #if wxUSE_COMMANDLINKBUTTON
17 #include "wx/button.h"
19 // ----------------------------------------------------------------------------
20 // Command link button common base class
21 // ----------------------------------------------------------------------------
23 // This class has separate "main label" (title-like string) and (possibly
24 // multiline) "note" which can be set and queried separately but can also be
25 // set both at once by joining them with a new line and setting them as a
26 // label and queried by breaking the label into the parts before the first new
29 class WXDLLIMPEXP_ADV wxCommandLinkButtonBase
: public wxButton
32 wxCommandLinkButtonBase() : wxButton() { }
34 wxCommandLinkButtonBase(wxWindow
*parent
,
36 const wxString
& mainLabel
= wxEmptyString
,
37 const wxString
& note
= wxEmptyString
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
41 const wxValidator
& validator
=
43 const wxString
& name
= wxButtonNameStr
)
46 mainLabel
+ '\n' + note
,
54 virtual void SetMainLabelAndNote(const wxString
& mainLabel
,
55 const wxString
& note
) = 0;
57 virtual void SetMainLabel(const wxString
& mainLabel
)
59 SetMainLabelAndNote(mainLabel
, GetNote());
62 virtual void SetNote(const wxString
& note
)
64 SetMainLabelAndNote(GetMainLabel(), note
);
67 virtual wxString
GetMainLabel() const
69 return GetLabel().BeforeFirst('\n');
72 virtual wxString
GetNote() const
74 return GetLabel().AfterFirst('\n');
78 virtual bool HasNativeBitmap() const { return false; }
81 wxDECLARE_NO_COPY_CLASS(wxCommandLinkButtonBase
);
84 // ----------------------------------------------------------------------------
85 // Generic command link button
86 // ----------------------------------------------------------------------------
88 // Trivial generic implementation simply using a multiline label to show both
89 // the main label and the note.
91 class WXDLLIMPEXP_ADV wxGenericCommandLinkButton
92 : public wxCommandLinkButtonBase
95 wxGenericCommandLinkButton() : wxCommandLinkButtonBase() { }
98 wxGenericCommandLinkButton(wxWindow
*parent
,
100 const wxString
& mainLabel
= wxEmptyString
,
101 const wxString
& note
= wxEmptyString
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
105 const wxValidator
& validator
= wxDefaultValidator
,
106 const wxString
& name
= wxButtonNameStr
)
107 : wxCommandLinkButtonBase()
109 Create(parent
, id
, mainLabel
, note
, pos
, size
, style
, validator
, name
);
112 bool Create(wxWindow
*parent
,
114 const wxString
& mainLabel
= wxEmptyString
,
115 const wxString
& note
= wxEmptyString
,
116 const wxPoint
& pos
= wxDefaultPosition
,
117 const wxSize
& size
= wxDefaultSize
,
119 const wxValidator
& validator
= wxDefaultValidator
,
120 const wxString
& name
= wxButtonNameStr
);
122 virtual void SetMainLabelAndNote(const wxString
& mainLabel
,
123 const wxString
& note
)
125 wxButton::SetLabel(mainLabel
+ '\n' + note
);
129 void SetDefaultBitmap();
131 wxDECLARE_NO_COPY_CLASS(wxGenericCommandLinkButton
);
134 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
135 #include "wx/msw/commandlinkbutton.h"
137 class WXDLLIMPEXP_ADV wxCommandLinkButton
: public wxGenericCommandLinkButton
140 wxCommandLinkButton() : wxGenericCommandLinkButton() { }
142 wxCommandLinkButton(wxWindow
*parent
,
144 const wxString
& mainLabel
= wxEmptyString
,
145 const wxString
& note
= wxEmptyString
,
146 const wxPoint
& pos
= wxDefaultPosition
,
147 const wxSize
& size
= wxDefaultSize
,
149 const wxValidator
& validator
= wxDefaultValidator
,
150 const wxString
& name
= wxButtonNameStr
)
151 : wxGenericCommandLinkButton(parent
,
163 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton
);
165 #endif // __WXMSW__/!__WXMSW__
167 #endif // wxUSE_COMMANDLINKBUTTON
169 #endif // _WX_COMMANDLINKBUTTON_H_