~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxContribItems/KWIC/src/wx/xrc/xh_kwxlinearmeterhandler.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************//**
 
2
 * \file                xh_kwxlinearmeterhandler.cpp
 
3
 * \author      Gary Harris
 
4
 * \date                25/4/2010.
 
5
 *
 
6
 * This file is part of wxSmithKWIC.
 
7
 *
 
8
 * wxSmithKWIC - an add-on for wxSmith, Code::Blocks' GUI editor.                                       \n
 
9
 * Copyright (C) 2010 Gary Harris.
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 *
 
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>.
 
23
 *
 
24
 *****************************************************************************/
 
25
#include "wx/xrc/xh_kwxlinearmeterhandler.h"
 
26
#include "wx/KWIC/LinearMeter.h"
 
27
 
 
28
// Register with wxWidgets' dynamic class subsystem.
 
29
IMPLEMENT_DYNAMIC_CLASS(kwxLinearMeterHandler, wxXmlResourceHandler)
 
30
 
 
31
kwxLinearMeterHandler::kwxLinearMeterHandler()
 
32
{
 
33
    // this call adds support for all wxWindows class styles
 
34
    // (e.g. wxBORDER_SIMPLE, wxBORDER_SUNKEN, wxWS_EX_* etc etc)
 
35
    AddWindowStyles();
 
36
 
 
37
    // if MyControl class supports e.g. MYCONTROL_DEFAULT_STYLE
 
38
    // you should use:
 
39
    //     XRC_ADD_STYLE(MYCONTROL_DEFAULT_STYLE);
 
40
}
 
41
 
 
42
wxObject *kwxLinearMeterHandler::DoCreateResource()
 
43
{
 
44
    // the following macro will init a pointer named "control"
 
45
    // with a new instance of the MyControl class, but will NOT
 
46
    // Create() it!
 
47
    XRC_MAKE_INSTANCE(control, kwxLinearMeter)
 
48
 
 
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));
 
60
        int i = 1;
 
61
        while(1){
 
62
                wxString s = wxString::Format(wxT("tag_%d_value"), i);
 
63
                if(!HasParam(s)){
 
64
                        break;
 
65
                }
 
66
                control->AddTag(GetLong(s));
 
67
                i++;
 
68
        }
 
69
        // Avoid error if the font node isn't present.
 
70
        if(HasParam(wxT("font"))){
 
71
                wxFont font = GetFont();
 
72
                control->SetTxtFont(font);
 
73
        }
 
74
    control->SetValue(GetLong(wxT("value"), 0));
 
75
 
 
76
    SetupWindow(control);
 
77
 
 
78
    return control;
 
79
}
 
80
 
 
81
bool kwxLinearMeterHandler::CanHandle(wxXmlNode *node)
 
82
{
 
83
    // this function tells XRC system that this handler can parse
 
84
    // the <object class="MyControl"> tags
 
85
    return IsOfClass(node, wxT("kwxLinearMeter"));
 
86
}
 
87
 
 
88