]> git.saurik.com Git - wxWidgets.git/blob - src/generic/commandlinkbuttong.cpp
Implement support for markup labels for wxGTK wxButton.
[wxWidgets.git] / src / generic / commandlinkbuttong.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/commandlinkbuttong.cpp
3 // Purpose: wxGenericCommandLinkButton
4 // Author: Rickard Westerlund
5 // Created: 2010-06-23
6 // RCS-ID: $Id$
7 // Copyright: (c) 2010 wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ----------------------------------------------------------------------------
12 // headers
13 // ----------------------------------------------------------------------------
14
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
17
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21
22 #if wxUSE_COMMANDLINKBUTTON
23
24 #include "wx/commandlinkbutton.h"
25 #include "wx/artprov.h"
26
27 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxCommandLinkButton, wxButton, "wx/commandlinkbutton.h")
28
29 wxDEFINE_FLAGS( wxCommandLinkButtonStyle )
30 wxBEGIN_FLAGS( wxCommandLinkButtonStyle )
31 // new style border flags, we put them first to
32 // use them for streaming out
33 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
34 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
35 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
36 wxFLAGS_MEMBER(wxBORDER_RAISED)
37 wxFLAGS_MEMBER(wxBORDER_STATIC)
38 wxFLAGS_MEMBER(wxBORDER_NONE)
39
40 // old style border flags
41 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
42 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
43 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
44 wxFLAGS_MEMBER(wxRAISED_BORDER)
45 wxFLAGS_MEMBER(wxSTATIC_BORDER)
46 wxFLAGS_MEMBER(wxBORDER)
47
48 // standard window styles
49 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
50 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
51 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
52 wxFLAGS_MEMBER(wxWANTS_CHARS)
53 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
54 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
55 wxFLAGS_MEMBER(wxVSCROLL)
56 wxFLAGS_MEMBER(wxHSCROLL)
57
58 wxFLAGS_MEMBER(wxBU_AUTODRAW)
59 wxFLAGS_MEMBER(wxBU_LEFT)
60 wxFLAGS_MEMBER(wxBU_RIGHT)
61 wxFLAGS_MEMBER(wxBU_TOP)
62 wxFLAGS_MEMBER(wxBU_BOTTOM)
63 wxEND_FLAGS( wxCommandLinkButtonStyle )
64
65 wxBEGIN_PROPERTIES_TABLE(wxCommandLinkButton)
66 wxPROPERTY( MainLabel, wxString, SetMainLabel, GetMainLabel, wxString(), \
67 0 /*flags*/, wxT("The main label"), wxT("group") )
68
69 wxPROPERTY( Note, wxString, SetNote, GetNote, wxString(), \
70 0 /*flags*/, wxT("The link URL"), wxT("group") )
71 wxPROPERTY_FLAGS( WindowStyle, wxCommandLinkButtonStyle, long, SetWindowStyleFlag, \
72 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
73 wxT("The link style"), wxT("group")) // style
74 wxEND_PROPERTIES_TABLE()
75
76 wxEMPTY_HANDLERS_TABLE(wxCommandLinkButton)
77
78 wxCONSTRUCTOR_7( wxCommandLinkButton, wxWindow*, Parent, wxWindowID, Id, wxString, \
79 MainLabel, wxString, Note, wxPoint, Position, wxSize, Size, long, WindowStyle )
80
81 // ----------------------------------------------------------------------------
82 // Generic command link button
83 // ----------------------------------------------------------------------------
84
85 bool wxGenericCommandLinkButton::Create(wxWindow *parent,
86 wxWindowID id,
87 const wxString& mainLabel,
88 const wxString& note,
89 const wxPoint& pos,
90 const wxSize& size,
91 long style,
92 const wxValidator& validator,
93 const wxString& name)
94 {
95 if ( !wxButton::Create(parent,
96 id,
97 mainLabel + '\n' + note,
98 pos,
99 size,
100 style,
101 validator,
102 name) )
103 return false;
104
105 if ( !HasNativeBitmap() )
106 SetDefaultBitmap();
107
108 return true;
109
110 }
111
112 void wxGenericCommandLinkButton::SetDefaultBitmap()
113 {
114 SetBitmap(wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_BUTTON));
115 }
116
117 #endif // wxUSE_COMMANDLINKBUTTON