1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/btncmn.cpp
3 // Purpose: implementation of wxButtonBase
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
29 #include "wx/button.h"
30 #include "wx/toplevel.h"
33 extern WXDLLEXPORT_DATA(const char) wxButtonNameStr
[] = "button";
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 wxDEFINE_FLAGS( wxButtonStyle
)
40 wxBEGIN_FLAGS( wxButtonStyle
)
41 // new style border flags, we put them first to
42 // use them for streaming out
43 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
44 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
45 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
46 wxFLAGS_MEMBER(wxBORDER_RAISED
)
47 wxFLAGS_MEMBER(wxBORDER_STATIC
)
48 wxFLAGS_MEMBER(wxBORDER_NONE
)
50 // old style border flags
51 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
52 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
53 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
54 wxFLAGS_MEMBER(wxRAISED_BORDER
)
55 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
56 wxFLAGS_MEMBER(wxBORDER
)
58 // standard window styles
59 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
60 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
61 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
62 wxFLAGS_MEMBER(wxWANTS_CHARS
)
63 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
64 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
65 wxFLAGS_MEMBER(wxVSCROLL
)
66 wxFLAGS_MEMBER(wxHSCROLL
)
68 wxFLAGS_MEMBER(wxBU_LEFT
)
69 wxFLAGS_MEMBER(wxBU_RIGHT
)
70 wxFLAGS_MEMBER(wxBU_TOP
)
71 wxFLAGS_MEMBER(wxBU_BOTTOM
)
72 wxFLAGS_MEMBER(wxBU_EXACTFIT
)
73 wxEND_FLAGS( wxButtonStyle
)
75 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxButton
, wxControl
, "wx/button.h")
77 wxBEGIN_PROPERTIES_TABLE(wxButton
)
78 wxEVENT_PROPERTY( Click
, wxEVT_COMMAND_BUTTON_CLICKED
, wxCommandEvent
)
80 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, wxEMPTY_PARAMETER_VALUE
, \
81 0 /*flags*/, wxT("The font associated with the button label"), wxT("group"))
82 wxPROPERTY( Label
, wxString
, SetLabel
, GetLabel
, wxString(), \
83 0 /*flags*/, wxT("The button label"), wxT("group") )
85 wxPROPERTY_FLAGS( WindowStyle
, wxButtonStyle
, long, SetWindowStyleFlag
, \
86 GetWindowStyleFlag
, wxEMPTY_PARAMETER_VALUE
, 0 /*flags*/, \
87 wxT("The button style"), wxT("group")) // style
88 wxEND_PROPERTIES_TABLE()
90 wxEMPTY_HANDLERS_TABLE(wxButton
)
92 wxCONSTRUCTOR_6( wxButton
, wxWindow
*, Parent
, wxWindowID
, Id
, wxString
, \
93 Label
, wxPoint
, Position
, wxSize
, Size
, long, WindowStyle
)
96 // ============================================================================
98 // ============================================================================
100 wxWindow
*wxButtonBase::SetDefault()
102 wxTopLevelWindow
* const
103 tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
105 wxCHECK_MSG( tlw
, NULL
, wxT("button without top level window?") );
107 return tlw
->SetDefaultItem(this);
110 void wxAnyButtonBase::SetBitmapPosition(wxDirection dir
)
112 wxASSERT_MSG( !(dir
& ~wxDIRECTION_MASK
), "non-direction flag used" );
113 wxASSERT_MSG( !!(dir
& wxLEFT
) +
116 !!(dir
& wxBOTTOM
) == 1,
117 "exactly one direction flag must be set" );
119 DoSetBitmapPosition(dir
);
122 #endif // wxUSE_BUTTON