]>
git.saurik.com Git - wxWidgets.git/blob - src/common/btncmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/btncmn.cpp
3 // Purpose: implementation of wxButtonBase
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
28 #include "wx/button.h"
29 #include "wx/toplevel.h"
32 extern WXDLLEXPORT_DATA(const char) wxButtonNameStr
[] = "button";
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
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
)
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
)
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
)
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
)
74 wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxButton
, wxControl
, "wx/button.h")
76 wxBEGIN_PROPERTIES_TABLE(wxButton
)
77 wxEVENT_PROPERTY( Click
, wxEVT_BUTTON
, wxCommandEvent
)
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") )
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()
89 wxEMPTY_HANDLERS_TABLE(wxButton
)
91 wxCONSTRUCTOR_6( wxButton
, wxWindow
*, Parent
, wxWindowID
, Id
, wxString
, \
92 Label
, wxPoint
, Position
, wxSize
, Size
, long, WindowStyle
)
95 // ============================================================================
97 // ============================================================================
99 wxWindow
*wxButtonBase::SetDefault()
101 wxTopLevelWindow
* const
102 tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
104 wxCHECK_MSG( tlw
, NULL
, wxT("button without top level window?") );
106 return tlw
->SetDefaultItem(this);
109 void wxAnyButtonBase::SetBitmapPosition(wxDirection dir
)
111 wxASSERT_MSG( !(dir
& ~wxDIRECTION_MASK
), "non-direction flag used" );
112 wxASSERT_MSG( !!(dir
& wxLEFT
) +
115 !!(dir
& wxBOTTOM
) == 1,
116 "exactly one direction flag must be set" );
118 DoSetBitmapPosition(dir
);
121 #endif // wxUSE_BUTTON