]> git.saurik.com Git - wxWidgets.git/blame - src/common/btncmn.cpp
wxMessageBox off the main thread lost result code.
[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
94aff5ff
VZ
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
28fcfbfe
VZ
25#if wxUSE_BUTTON
26
94aff5ff
VZ
27#ifndef WX_PRECOMP
28 #include "wx/button.h"
29 #include "wx/toplevel.h"
30#endif //WX_PRECOMP
31
f313deaa 32extern WXDLLEXPORT_DATA(const char) wxButtonNameStr[] = "button";
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)
ce7fe42e 77wxEVENT_PROPERTY( Click, wxEVT_BUTTON, wxCommandEvent )
28953245
SC
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
b4354db1 109void wxAnyButtonBase::SetBitmapPosition(wxDirection dir)
233f10bf
VZ
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