Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / src / common / btncmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/btncmn.cpp
3 // Purpose: implementation of wxButtonBase
4 // Author: Vadim Zeitlin
5 // Created: 2007-04-08
6 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ============================================================================
11 // declarations
12 // ============================================================================
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #if wxUSE_BUTTON
26
27 #ifndef WX_PRECOMP
28 #include "wx/button.h"
29 #include "wx/toplevel.h"
30 #endif //WX_PRECOMP
31
32 extern WXDLLEXPORT_DATA(const char) wxButtonNameStr[] = "button";
33
34 // ----------------------------------------------------------------------------
35 // XTI
36 // ----------------------------------------------------------------------------
37
38 wxDEFINE_FLAGS( wxButtonStyle )
39 wxBEGIN_FLAGS( wxButtonStyle )
40 // new style border flags, we put them first to
41 // use them for streaming out
42 wxFLAGS_MEMBER(wxBORDER_SIMPLE)
43 wxFLAGS_MEMBER(wxBORDER_SUNKEN)
44 wxFLAGS_MEMBER(wxBORDER_DOUBLE)
45 wxFLAGS_MEMBER(wxBORDER_RAISED)
46 wxFLAGS_MEMBER(wxBORDER_STATIC)
47 wxFLAGS_MEMBER(wxBORDER_NONE)
48
49 // old style border flags
50 wxFLAGS_MEMBER(wxSIMPLE_BORDER)
51 wxFLAGS_MEMBER(wxSUNKEN_BORDER)
52 wxFLAGS_MEMBER(wxDOUBLE_BORDER)
53 wxFLAGS_MEMBER(wxRAISED_BORDER)
54 wxFLAGS_MEMBER(wxSTATIC_BORDER)
55 wxFLAGS_MEMBER(wxBORDER)
56
57 // standard window styles
58 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
59 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
60 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
61 wxFLAGS_MEMBER(wxWANTS_CHARS)
62 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
63 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
64 wxFLAGS_MEMBER(wxVSCROLL)
65 wxFLAGS_MEMBER(wxHSCROLL)
66
67 wxFLAGS_MEMBER(wxBU_LEFT)
68 wxFLAGS_MEMBER(wxBU_RIGHT)
69 wxFLAGS_MEMBER(wxBU_TOP)
70 wxFLAGS_MEMBER(wxBU_BOTTOM)
71 wxFLAGS_MEMBER(wxBU_EXACTFIT)
72 wxEND_FLAGS( wxButtonStyle )
73
74 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxButton, wxControl, "wx/button.h")
75
76 wxBEGIN_PROPERTIES_TABLE(wxButton)
77 wxEVENT_PROPERTY( Click, wxEVT_BUTTON, wxCommandEvent )
78
79 wxPROPERTY( Font, wxFont, SetFont, GetFont, wxEMPTY_PARAMETER_VALUE, \
80 0 /*flags*/, wxT("The font associated with the button label"), wxT("group"))
81 wxPROPERTY( Label, wxString, SetLabel, GetLabel, wxString(), \
82 0 /*flags*/, wxT("The button label"), wxT("group") )
83
84 wxPROPERTY_FLAGS( WindowStyle, wxButtonStyle, long, SetWindowStyleFlag, \
85 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
86 wxT("The button style"), wxT("group")) // style
87 wxEND_PROPERTIES_TABLE()
88
89 wxEMPTY_HANDLERS_TABLE(wxButton)
90
91 wxCONSTRUCTOR_6( wxButton, wxWindow*, Parent, wxWindowID, Id, wxString, \
92 Label, wxPoint, Position, wxSize, Size, long, WindowStyle )
93
94
95 // ============================================================================
96 // implementation
97 // ============================================================================
98
99 wxWindow *wxButtonBase::SetDefault()
100 {
101 wxTopLevelWindow * const
102 tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
103
104 wxCHECK_MSG( tlw, NULL, wxT("button without top level window?") );
105
106 return tlw->SetDefaultItem(this);
107 }
108
109 void wxAnyButtonBase::SetBitmapPosition(wxDirection dir)
110 {
111 wxASSERT_MSG( !(dir & ~wxDIRECTION_MASK), "non-direction flag used" );
112 wxASSERT_MSG( !!(dir & wxLEFT) +
113 !!(dir & wxRIGHT) +
114 !!(dir & wxTOP) +
115 !!(dir & wxBOTTOM) == 1,
116 "exactly one direction flag must be set" );
117
118 DoSetBitmapPosition(dir);
119
120 }
121 #endif // wxUSE_BUTTON