Debian Codegraph @

wxcrafter/xrc_handlers/myxh_infobar.cpp

raw
1 #include "myxh_infobar.h"
2 #include <wx/infobar.h>
3
4 MyWxInfoBarCtrlHandler::MyWxInfoBarCtrlHandler()
5 : wxXmlResourceHandler()
6 {
7 AddWindowStyles();
8 }
9
10 wxObject* MyWxInfoBarCtrlHandler::DoCreateResource()
11 {
12 if(m_class == "wxInfoBarButton") {
13 HandleButton();
14
15 } else {
16 wxASSERT_MSG(m_class == "wxInfoBar", wxT("can't handle unknown node"));
17
18 return HandleInfoBar();
19 }
20
21 return m_parentAsWindow;
22 }
23
24 bool MyWxInfoBarCtrlHandler::CanHandle(wxXmlNode* node)
25 {
26 return IsOfClass(node, "wxInfoBar") || IsOfClass(node, "wxInfoBarButton");
27 }
28
29 void MyWxInfoBarCtrlHandler::HandleButton()
30 {
31 wxInfoBar* const bar = wxDynamicCast(m_parentAsWindow, wxInfoBar);
32 wxCHECK_RET(bar, wxT("must have wxInfoBar parent"));
33
34 wxString buttonLabel = GetText("label");
35 int buttonId = GetID();
36 if(buttonId != wxNOT_FOUND) { bar->AddButton(buttonId, buttonLabel); }
37 }
38
39 wxInfoBar* MyWxInfoBarCtrlHandler::HandleInfoBar()
40 {
41 XRC_MAKE_INSTANCE(infobar, wxInfoBar)
42 infobar->Create(m_parentAsWindow, GetID());
43 infobar->SetName(GetName());
44
45 wxString message = GetText("message");
46 wxString iconId = GetText("icon-id");
47
48 int nIconId = wxICON_NONE;
49
50 if(iconId == "wxICON_NONE")
51 nIconId = wxICON_NONE;
52
53 else if(iconId == "wxICON_ERROR")
54 nIconId = wxICON_ERROR;
55
56 else if(iconId == "wxICON_INFORMATION")
57 nIconId = wxICON_INFORMATION;
58
59 else if(iconId == "wxICON_WARNING")
60 nIconId = wxICON_WARNING;
61
62 infobar->SetName(GetName());
63 SetupWindow(infobar);
64 CreateChildrenPrivately(infobar);
65 infobar->ShowMessage(message, nIconId);
66 return infobar;
67 }