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