]> git.saurik.com Git - wxWidgets.git/blob - src/common/btncmn.cpp
Compilation fix for PNG saving code when wxUSE_PALETTE==0.
[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 // 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
26 #if wxUSE_BUTTON
27
28 #ifndef WX_PRECOMP
29 #include "wx/button.h"
30 #include "wx/toplevel.h"
31 #endif //WX_PRECOMP
32
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_COMMAND_BUTTON_CLICKED, 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 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 }
121 #endif // wxUSE_BUTTON