]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_bannerwindow.cpp
Further refine of #15226: wxRichTextCtrl: Implement setting properties with undo...
[wxWidgets.git] / src / xrc / xh_bannerwindow.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: srx/xrc/xh_bannerwindow.h
3 // Purpose: Implementation of wxBannerWindow XRC handler.
4 // Author: Vadim Zeitlin
5 // Created: 2011-08-16
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_BANNERWINDOW
18
19 #include "wx/xrc/xh_bannerwindow.h"
20 #include "wx/bannerwindow.h"
21
22 wxIMPLEMENT_DYNAMIC_CLASS(wxBannerWindowXmlHandler, wxXmlResourceHandler)
23
24 wxBannerWindowXmlHandler::wxBannerWindowXmlHandler()
25 : wxXmlResourceHandler()
26 {
27 AddWindowStyles();
28 }
29
30 wxObject *wxBannerWindowXmlHandler::DoCreateResource()
31 {
32 XRC_MAKE_INSTANCE(banner, wxBannerWindow)
33
34 banner->Create(m_parentAsWindow,
35 GetID(),
36 GetDirection(wxS("direction")),
37 GetPosition(),
38 GetSize(),
39 GetStyle(wxS("style")),
40 GetName());
41
42 SetupWindow(banner);
43
44 const wxColour colStart = GetColour(wxS("gradient-start"));
45 const wxColour colEnd = GetColour(wxS("gradient-end"));
46 if ( colStart.IsOk() || colEnd.IsOk() )
47 {
48 if ( !colStart.IsOk() || !colEnd.IsOk() )
49 {
50 ReportError
51 (
52 "Both start and end gradient colours must be "
53 "specified if either one is."
54 );
55 }
56 else
57 {
58 banner->SetGradient(colStart, colEnd);
59 }
60 }
61
62 wxBitmap bitmap = GetBitmap();
63 if ( bitmap.IsOk() )
64 {
65 if ( colStart.IsOk() || colEnd.IsOk() )
66 {
67 ReportError
68 (
69 "Gradient colours are ignored by wxBannerWindow "
70 "if the background bitmap is specified."
71 );
72 }
73
74 banner->SetBitmap(bitmap);
75 }
76
77 banner->SetText(GetText(wxS("title")), GetText(wxS("message")));
78
79 return banner;
80 }
81
82 bool wxBannerWindowXmlHandler::CanHandle(wxXmlNode *node)
83 {
84 return IsOfClass(node, wxS("wxBannerWindow"));
85 }
86
87 #endif // wxUSE_XRC && wxUSE_BANNERWINDOW