]> git.saurik.com Git - wxWidgets.git/blame - src/common/btncmn.cpp
Remove "safety margin" from wxControl::Ellipsize().
[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
f313deaa 33extern WXDLLEXPORT_DATA(const char) wxButtonNameStr[] = "button";
28953245
SC
34
35// ----------------------------------------------------------------------------
36// XTI
37// ----------------------------------------------------------------------------
38
39wxDEFINE_FLAGS( wxButtonStyle )
40wxBEGIN_FLAGS( wxButtonStyle )
41// new style border flags, we put them first to
42// use them for streaming out
43wxFLAGS_MEMBER(wxBORDER_SIMPLE)
44wxFLAGS_MEMBER(wxBORDER_SUNKEN)
45wxFLAGS_MEMBER(wxBORDER_DOUBLE)
46wxFLAGS_MEMBER(wxBORDER_RAISED)
47wxFLAGS_MEMBER(wxBORDER_STATIC)
48wxFLAGS_MEMBER(wxBORDER_NONE)
49
50// old style border flags
51wxFLAGS_MEMBER(wxSIMPLE_BORDER)
52wxFLAGS_MEMBER(wxSUNKEN_BORDER)
53wxFLAGS_MEMBER(wxDOUBLE_BORDER)
54wxFLAGS_MEMBER(wxRAISED_BORDER)
55wxFLAGS_MEMBER(wxSTATIC_BORDER)
56wxFLAGS_MEMBER(wxBORDER)
57
58// standard window styles
59wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
60wxFLAGS_MEMBER(wxCLIP_CHILDREN)
61wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
62wxFLAGS_MEMBER(wxWANTS_CHARS)
63wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
64wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
65wxFLAGS_MEMBER(wxVSCROLL)
66wxFLAGS_MEMBER(wxHSCROLL)
67
68wxFLAGS_MEMBER(wxBU_LEFT)
69wxFLAGS_MEMBER(wxBU_RIGHT)
70wxFLAGS_MEMBER(wxBU_TOP)
71wxFLAGS_MEMBER(wxBU_BOTTOM)
72wxFLAGS_MEMBER(wxBU_EXACTFIT)
73wxEND_FLAGS( wxButtonStyle )
74
75wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxButton, wxControl, "wx/button.h")
76
77wxBEGIN_PROPERTIES_TABLE(wxButton)
78wxEVENT_PROPERTY( Click, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent )
79
80wxPROPERTY( Font, wxFont, SetFont, GetFont, wxEMPTY_PARAMETER_VALUE, \
81 0 /*flags*/, wxT("The font associated with the button label"), wxT("group"))
82wxPROPERTY( Label, wxString, SetLabel, GetLabel, wxString(), \
83 0 /*flags*/, wxT("The button label"), wxT("group") )
84
85wxPROPERTY_FLAGS( WindowStyle, wxButtonStyle, long, SetWindowStyleFlag, \
86 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
87 wxT("The button style"), wxT("group")) // style
88wxEND_PROPERTIES_TABLE()
89
90wxEMPTY_HANDLERS_TABLE(wxButton)
91
92wxCONSTRUCTOR_6( wxButton, wxWindow*, Parent, wxWindowID, Id, wxString, \
93 Label, wxPoint, Position, wxSize, Size, long, WindowStyle )
94
95
94aff5ff
VZ
96// ============================================================================
97// implementation
98// ============================================================================
99
100wxWindow *wxButtonBase::SetDefault()
101{
102 wxTopLevelWindow * const
103 tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
104
9a83f860 105 wxCHECK_MSG( tlw, NULL, wxT("button without top level window?") );
94aff5ff
VZ
106
107 return tlw->SetDefaultItem(this);
108}
109
233f10bf
VZ
110void wxButtonBase::SetBitmapPosition(wxDirection dir)
111{
112 wxASSERT_MSG( !(dir & ~wxDIRECTION_MASK), "non-direction flag used" );
113 wxASSERT_MSG( !!(dir & wxLEFT) +
114 !!(dir & wxRIGHT) +
115 !!(dir & wxTOP) +
116 !!(dir & wxBOTTOM) == 1,
117 "exactly one direction flag must be set" );
118
119 DoSetBitmapPosition(dir);
120
121}
28fcfbfe 122#endif // wxUSE_BUTTON