1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/commandlinkbutton.h
3 // Purpose: wxCommandLinkButtonBase and wxGenericCommandLinkButton classes
4 // Author: Rickard Westerlund
7 // Copyright: (c) 2010 wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_COMMANDLINKBUTTON_H_
12 #define _WX_COMMANDLINKBUTTON_H_
16 #if wxUSE_COMMANDLINKBUTTON
18 #include "wx/button.h"
20 // ----------------------------------------------------------------------------
21 // Command link button common base class
22 // ----------------------------------------------------------------------------
24 // This class has separate "main label" (title-like string) and (possibly
25 // multiline) "note" which can be set and queried separately but can also be
26 // set both at once by joining them with a new line and setting them as a
27 // label and queried by breaking the label into the parts before the first new
30 class WXDLLIMPEXP_ADV wxCommandLinkButtonBase
: public wxButton
33 wxCommandLinkButtonBase() : wxButton() { }
35 wxCommandLinkButtonBase(wxWindow
*parent
,
37 const wxString
& mainLabel
= wxEmptyString
,
38 const wxString
& note
= wxEmptyString
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
42 const wxValidator
& validator
=
44 const wxString
& name
= wxButtonNameStr
)
47 mainLabel
+ '\n' + note
,
55 virtual void SetMainLabelAndNote(const wxString
& mainLabel
,
56 const wxString
& note
) = 0;
58 virtual void SetMainLabel(const wxString
& mainLabel
)
60 SetMainLabelAndNote(mainLabel
, GetNote());
63 virtual void SetNote(const wxString
& note
)
65 SetMainLabelAndNote(GetMainLabel(), note
);
68 virtual wxString
GetMainLabel() const
70 return GetLabel().BeforeFirst('\n');
73 virtual wxString
GetNote() const
75 return GetLabel().AfterFirst('\n');
79 virtual bool HasNativeBitmap() const { return false; }
82 wxDECLARE_NO_COPY_CLASS(wxCommandLinkButtonBase
);
85 // ----------------------------------------------------------------------------
86 // Generic command link button
87 // ----------------------------------------------------------------------------
89 // Trivial generic implementation simply using a multiline label to show both
90 // the main label and the note.
92 class WXDLLIMPEXP_ADV wxGenericCommandLinkButton
93 : public wxCommandLinkButtonBase
96 wxGenericCommandLinkButton() : wxCommandLinkButtonBase() { }
99 wxGenericCommandLinkButton(wxWindow
*parent
,
101 const wxString
& mainLabel
= wxEmptyString
,
102 const wxString
& note
= wxEmptyString
,
103 const wxPoint
& pos
= wxDefaultPosition
,
104 const wxSize
& size
= wxDefaultSize
,
106 const wxValidator
& validator
= wxDefaultValidator
,
107 const wxString
& name
= wxButtonNameStr
)
108 : wxCommandLinkButtonBase()
110 Create(parent
, id
, mainLabel
, note
, pos
, size
, style
, validator
, name
);
113 bool Create(wxWindow
*parent
,
115 const wxString
& mainLabel
= wxEmptyString
,
116 const wxString
& note
= wxEmptyString
,
117 const wxPoint
& pos
= wxDefaultPosition
,
118 const wxSize
& size
= wxDefaultSize
,
120 const wxValidator
& validator
= wxDefaultValidator
,
121 const wxString
& name
= wxButtonNameStr
);
123 virtual void SetMainLabelAndNote(const wxString
& mainLabel
,
124 const wxString
& note
)
126 wxButton::SetLabel(mainLabel
+ '\n' + note
);
130 void SetDefaultBitmap();
132 wxDECLARE_NO_COPY_CLASS(wxGenericCommandLinkButton
);
135 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
136 #include "wx/msw/commandlinkbutton.h"
138 class WXDLLIMPEXP_ADV wxCommandLinkButton
: public wxGenericCommandLinkButton
141 wxCommandLinkButton() : wxGenericCommandLinkButton() { }
143 wxCommandLinkButton(wxWindow
*parent
,
145 const wxString
& mainLabel
= wxEmptyString
,
146 const wxString
& note
= wxEmptyString
,
147 const wxPoint
& pos
= wxDefaultPosition
,
148 const wxSize
& size
= wxDefaultSize
,
150 const wxValidator
& validator
= wxDefaultValidator
,
151 const wxString
& name
= wxButtonNameStr
)
152 : wxGenericCommandLinkButton(parent
,
164 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton
);
166 #endif // __WXMSW__/!__WXMSW__
168 #endif // wxUSE_COMMANDLINKBUTTON
170 #endif // _WX_COMMANDLINKBUTTON_H_