]> git.saurik.com Git - wxWidgets.git/blame - include/wx/commandlinkbutton.h
OSX adaptions
[wxWidgets.git] / include / wx / commandlinkbutton.h
CommitLineData
3571e1ad
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/commandlinkbutton.h
3// Purpose: wxCommandLinkButtonBase and wxGenericCommandLinkButton classes
4// Author: Rickard Westerlund
5// Created: 2010-06-11
3571e1ad
VZ
6// Copyright: (c) 2010 wxWidgets team
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_COMMANDLINKBUTTON_H_
11#define _WX_COMMANDLINKBUTTON_H_
12
13#include "wx/defs.h"
14
15#if wxUSE_COMMANDLINKBUTTON
16
8fe8b421
VZ
17#include "wx/button.h"
18
3571e1ad
VZ
19// ----------------------------------------------------------------------------
20// Command link button common base class
21// ----------------------------------------------------------------------------
22
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
27// line and after it.
28
29class WXDLLIMPEXP_ADV wxCommandLinkButtonBase : public wxButton
30{
31public:
32 wxCommandLinkButtonBase() : wxButton() { }
33
34 wxCommandLinkButtonBase(wxWindow *parent,
35 wxWindowID id,
36 const wxString& mainLabel = wxEmptyString,
37 const wxString& note = wxEmptyString,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = 0,
41 const wxValidator& validator =
42 wxDefaultValidator,
43 const wxString& name = wxButtonNameStr)
44 : wxButton(parent,
45 id,
46 mainLabel + '\n' + note,
47 pos,
48 size,
49 style,
50 validator,
51 name)
52 { }
53
54 virtual void SetMainLabelAndNote(const wxString& mainLabel,
55 const wxString& note) = 0;
56
57 virtual void SetMainLabel(const wxString& mainLabel)
58 {
59 SetMainLabelAndNote(mainLabel, GetNote());
60 }
61
62 virtual void SetNote(const wxString& note)
63 {
64 SetMainLabelAndNote(GetMainLabel(), note);
65 }
66
67 virtual wxString GetMainLabel() const
68 {
69 return GetLabel().BeforeFirst('\n');
70 }
71
72 virtual wxString GetNote() const
73 {
74 return GetLabel().AfterFirst('\n');
75 }
76
77protected:
78 virtual bool HasNativeBitmap() const { return false; }
79
80private:
81 wxDECLARE_NO_COPY_CLASS(wxCommandLinkButtonBase);
82};
83
84// ----------------------------------------------------------------------------
85// Generic command link button
86// ----------------------------------------------------------------------------
87
88// Trivial generic implementation simply using a multiline label to show both
89// the main label and the note.
90
91class WXDLLIMPEXP_ADV wxGenericCommandLinkButton
92 : public wxCommandLinkButtonBase
93{
94public:
95 wxGenericCommandLinkButton() : wxCommandLinkButtonBase() { }
96
97
98 wxGenericCommandLinkButton(wxWindow *parent,
99 wxWindowID id,
100 const wxString& mainLabel = wxEmptyString,
101 const wxString& note = wxEmptyString,
102 const wxPoint& pos = wxDefaultPosition,
103 const wxSize& size = wxDefaultSize,
104 long style = 0,
105 const wxValidator& validator = wxDefaultValidator,
106 const wxString& name = wxButtonNameStr)
107 : wxCommandLinkButtonBase()
108 {
109 Create(parent, id, mainLabel, note, pos, size, style, validator, name);
110 }
111
112 bool Create(wxWindow *parent,
113 wxWindowID id,
114 const wxString& mainLabel = wxEmptyString,
115 const wxString& note = wxEmptyString,
116 const wxPoint& pos = wxDefaultPosition,
117 const wxSize& size = wxDefaultSize,
118 long style = 0,
119 const wxValidator& validator = wxDefaultValidator,
120 const wxString& name = wxButtonNameStr);
121
122 virtual void SetMainLabelAndNote(const wxString& mainLabel,
123 const wxString& note)
124 {
125 wxButton::SetLabel(mainLabel + '\n' + note);
126 }
127
128private:
129 void SetDefaultBitmap();
130
131 wxDECLARE_NO_COPY_CLASS(wxGenericCommandLinkButton);
132};
133
8220f2f1 134#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
3571e1ad
VZ
135 #include "wx/msw/commandlinkbutton.h"
136#else
137 class WXDLLIMPEXP_ADV wxCommandLinkButton : public wxGenericCommandLinkButton
138 {
139 public:
140 wxCommandLinkButton() : wxGenericCommandLinkButton() { }
141
142 wxCommandLinkButton(wxWindow *parent,
143 wxWindowID id,
144 const wxString& mainLabel = wxEmptyString,
145 const wxString& note = wxEmptyString,
146 const wxPoint& pos = wxDefaultPosition,
147 const wxSize& size = wxDefaultSize,
148 long style = 0,
149 const wxValidator& validator = wxDefaultValidator,
150 const wxString& name = wxButtonNameStr)
151 : wxGenericCommandLinkButton(parent,
152 id,
153 mainLabel,
154 note,
155 pos,
156 size,
157 style,
158 validator,
159 name)
160 { }
161
162 private:
163 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxCommandLinkButton);
164 };
165#endif // __WXMSW__/!__WXMSW__
166
167#endif // wxUSE_COMMANDLINKBUTTON
168
169#endif // _WX_COMMANDLINKBUTTON_H_