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