1
/**************************************************************************//**
2
* \file xh_kwxlinearmeterhandler.cpp
6
* This file is part of wxSmithKWIC.
8
* wxSmithKWIC - an add-on for wxSmith, Code::Blocks' GUI editor. \n
9
* Copyright (C) 2010 Gary Harris.
11
* wxSmithKWIC is free software: you can redistribute it and/or modify
12
* it under the terms of the KWIC License
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* KWIC License for more details.
21
* You should have received a copy of the KWIC License along with this
22
* program. If not, see <http://www.koansoftware.com/kwic/kwic-license.htm>.
24
*****************************************************************************/
25
#include "wx/xrc/xh_kwxlinearmeterhandler.h"
26
#include "wx/KWIC/LinearMeter.h"
28
// Register with wxWidgets' dynamic class subsystem.
29
IMPLEMENT_DYNAMIC_CLASS(kwxLinearMeterHandler, wxXmlResourceHandler)
31
kwxLinearMeterHandler::kwxLinearMeterHandler()
33
// this call adds support for all wxWindows class styles
34
// (e.g. wxBORDER_SIMPLE, wxBORDER_SUNKEN, wxWS_EX_* etc etc)
37
// if MyControl class supports e.g. MYCONTROL_DEFAULT_STYLE
39
// XRC_ADD_STYLE(MYCONTROL_DEFAULT_STYLE);
42
wxObject *kwxLinearMeterHandler::DoCreateResource()
44
// the following macro will init a pointer named "control"
45
// with a new instance of the MyControl class, but will NOT
47
XRC_MAKE_INSTANCE(control, kwxLinearMeter)
49
control->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize());
50
control->ShowCurrent(GetBool(wxT("show_value"), true));
51
control->SetRangeVal(GetLong(wxT("range_min"), 0), GetLong(wxT("range_max"), 100));
52
control->ShowLimits(GetBool(wxT("show_limit_value"), true));
53
control->SetOrizDirection(GetBool(wxT("horizontal"), true));
54
control->SetActiveBarColour(GetColour(wxT("bar_colour"), *wxLIGHT_GREY));
55
control->SetPassiveBarColour(GetColour(wxT("background_colour"), *wxLIGHT_GREY));
56
control->SetBorderColour(GetColour(wxT("border_colour"), *wxBLACK));
57
control->SetTxtLimitColour(GetColour(wxT("range_text_colour"), *wxLIGHT_GREY));
58
control->SetTxtValueColour(GetColour(wxT("value_text_colour"), *wxBLACK));
59
control->SetTagsColour(GetColour(wxT("tag_colour"), *wxBLACK));
62
wxString s = wxString::Format(wxT("tag_%d_value"), i);
66
control->AddTag(GetLong(s));
69
// Avoid error if the font node isn't present.
70
if(HasParam(wxT("font"))){
71
wxFont font = GetFont();
72
control->SetTxtFont(font);
74
control->SetValue(GetLong(wxT("value"), 0));
81
bool kwxLinearMeterHandler::CanHandle(wxXmlNode *node)
83
// this function tells XRC system that this handler can parse
84
// the <object class="MyControl"> tags
85
return IsOfClass(node, wxT("kwxLinearMeter"));