]>
Commit | Line | Data |
---|---|---|
78d14f80 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f1e01716 | 2 | // Name: src/xrc/xh_bttn.cpp |
b5d6954b | 3 | // Purpose: XRC resource for buttons |
78d14f80 VS |
4 | // Author: Vaclav Slavik |
5 | // Created: 2000/03/05 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2000 Vaclav Slavik | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
f80ea77b | 10 | |
78d14f80 VS |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
dd47af27 | 18 | #if wxUSE_XRC && wxUSE_BUTTON |
a1e4ec87 | 19 | |
78d14f80 | 20 | #include "wx/xrc/xh_bttn.h" |
f1e01716 WS |
21 | |
22 | #ifndef WX_PRECOMP | |
23 | #include "wx/button.h" | |
24 | #endif | |
78d14f80 | 25 | |
854e189f | 26 | IMPLEMENT_DYNAMIC_CLASS(wxButtonXmlHandler, wxXmlResourceHandler) |
78d14f80 | 27 | |
f80ea77b WS |
28 | wxButtonXmlHandler::wxButtonXmlHandler() |
29 | : wxXmlResourceHandler() | |
78d14f80 | 30 | { |
544fee32 VS |
31 | XRC_ADD_STYLE(wxBU_LEFT); |
32 | XRC_ADD_STYLE(wxBU_RIGHT); | |
33 | XRC_ADD_STYLE(wxBU_TOP); | |
34 | XRC_ADD_STYLE(wxBU_BOTTOM); | |
27ce9aef | 35 | XRC_ADD_STYLE(wxBU_EXACTFIT); |
78d14f80 VS |
36 | AddWindowStyles(); |
37 | } | |
38 | ||
78d14f80 | 39 | wxObject *wxButtonXmlHandler::DoCreateResource() |
f80ea77b | 40 | { |
544fee32 | 41 | XRC_MAKE_INSTANCE(button, wxButton) |
f2588180 VS |
42 | |
43 | button->Create(m_parentAsWindow, | |
44 | GetID(), | |
45 | GetText(wxT("label")), | |
46 | GetPosition(), GetSize(), | |
47 | GetStyle(), | |
48 | wxDefaultValidator, | |
49 | GetName()); | |
50 | ||
544fee32 VS |
51 | if (GetBool(wxT("default"), 0)) |
52 | button->SetDefault(); | |
18b9d1a1 VZ |
53 | |
54 | if ( GetParamNode("bitmap") ) | |
55 | { | |
56 | wxDirection dir; | |
57 | const wxString dirstr = GetParamValue("direction"); | |
58 | if ( dirstr.empty() || dirstr == "wxLEFT" ) | |
59 | dir = wxLEFT; | |
60 | else if ( dirstr == "wxRIGHT" ) | |
61 | dir = wxRIGHT; | |
62 | else if ( dirstr == "wxTOP" ) | |
63 | dir = wxTOP; | |
64 | else if ( dirstr == "wxBOTTOM" ) | |
65 | dir = wxBOTTOM; | |
66 | else | |
67 | { | |
68 | ReportError | |
69 | ( | |
70 | GetParamNode("bitmapposition"), | |
71 | wxString::Format | |
72 | ( | |
73 | "Invalid bitmap position \"%s\": must be one of " | |
74 | "wxLEFT|wxRIGHT|wxTOP|wxBOTTOM.", | |
75 | dirstr | |
76 | ) | |
77 | ); | |
78 | ||
79 | dir = wxLEFT; | |
80 | } | |
81 | ||
82 | button->SetBitmap(GetBitmap("bitmap", wxART_BUTTON), dir); | |
83 | } | |
84 | ||
78d14f80 | 85 | SetupWindow(button); |
f80ea77b | 86 | |
78d14f80 VS |
87 | return button; |
88 | } | |
89 | ||
78d14f80 VS |
90 | bool wxButtonXmlHandler::CanHandle(wxXmlNode *node) |
91 | { | |
92 | return IsOfClass(node, wxT("wxButton")); | |
93 | } | |
a1e4ec87 | 94 | |
dd47af27 | 95 | #endif // wxUSE_XRC && wxUSE_BUTTON |