1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        src/xrc/xh_bmpbt.cpp
3 // Purpose:     XRC resource for bitmap buttons
4 // Author:      Brian Gavin
5 // Created:     2000/09/09
6 // RCS-ID:      $Id: xh_bmpbt.cpp 44510 2007-02-16 08:16:37Z JS $
7 // Copyright:   (c) 2000 Brian Gavin
8 // Licence:     wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10 
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13 
14 #ifdef __BORLANDC__
15     #pragma hdrstop
16 #endif
17 
18 #if wxUSE_XRC && wxUSE_BMPBUTTON
19 
20 #include "wx/xrc/xh_bmpbt.h"
21 
22 #ifndef WX_PRECOMP
23     #include "wx/bmpbuttn.h"
24 #endif
25 
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler,wxXmlResourceHandler)26 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButtonXmlHandler, wxXmlResourceHandler)
27 
28 wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
29 : wxXmlResourceHandler()
30 {
31     XRC_ADD_STYLE(wxBU_AUTODRAW);
32     XRC_ADD_STYLE(wxBU_LEFT);
33     XRC_ADD_STYLE(wxBU_RIGHT);
34     XRC_ADD_STYLE(wxBU_TOP);
35     XRC_ADD_STYLE(wxBU_BOTTOM);
36     XRC_ADD_STYLE(wxBU_EXACTFIT);
37     AddWindowStyles();
38 }
39 
DoCreateResource()40 wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
41 {
42     XRC_MAKE_INSTANCE(button, wxBitmapButton)
43 
44     button->Create(m_parentAsWindow,
45                    GetID(),
46                    GetBitmap(wxT("bitmap"), wxART_BUTTON),
47                    GetPosition(), GetSize(),
48                    GetStyle(wxT("style"), wxBU_AUTODRAW),
49                    wxDefaultValidator,
50                    GetName());
51     if (GetBool(wxT("default"), 0))
52         button->SetDefault();
53     SetupWindow(button);
54 
55     if (GetParamNode(wxT("selected")))
56         button->SetBitmapSelected(GetBitmap(wxT("selected")));
57     if (GetParamNode(wxT("focus")))
58         button->SetBitmapFocus(GetBitmap(wxT("focus")));
59     if (GetParamNode(wxT("disabled")))
60         button->SetBitmapDisabled(GetBitmap(wxT("disabled")));
61     if (GetParamNode(wxT("hover")))
62         button->SetBitmapHover(GetBitmap(wxT("hover")));
63 
64     return button;
65 }
66 
CanHandle(wxXmlNode * node)67 bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node)
68 {
69     return IsOfClass(node, wxT("wxBitmapButton"));
70 }
71 
72 #endif // wxUSE_XRC && wxUSE_BMPBUTTON
73