~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxscolourpickerctrl.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
/**  \file wxscolourpickerctrl.cpp
 
2
*
 
3
* This file is part of wxSmith plugin for Code::Blocks Studio
 
4
* Copyright (C) 2010 Gary Harris
 
5
*
 
6
* wxSmith is free software; you can redistribute it and/or modify
 
7
* it under the terms of the GNU General Public License as published by
 
8
* the Free Software Foundation; either version 3 of the License, or
 
9
* (at your option) any later version.
 
10
*
 
11
* wxSmith is distributed in the hope that it will be useful,
 
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
* GNU General Public License for more details.
 
15
*
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
18
*
 
19
*/
 
20
 
 
21
#include "wxscolourpickerctrl.h"
 
22
 
 
23
#include <wx/clrpicker.h>
 
24
 
 
25
namespace
 
26
{
 
27
    wxsRegisterItem<wxsColourPickerCtrl> Reg(_T("ColourPickerCtrl"), wxsTWidget, _T("Advanced"), 140);
 
28
 
 
29
    WXS_ST_BEGIN(wxsColourPickerCtrlStyles, _T(""))
 
30
        WXS_ST_CATEGORY("wxColourPickerCtrl")
 
31
        WXS_ST(wxCLRP_SHOW_LABEL)
 
32
        WXS_ST(wxCLRP_USE_TEXTCTRL)
 
33
    WXS_ST_END()
 
34
 
 
35
 
 
36
    WXS_EV_BEGIN(wxsColourPickerCtrlEvents)
 
37
        WXS_EVI(EVT_COLOURPICKER_CHANGED, wxEVT_COMMAND_COLOURPICKER_CHANGED, wxColourPickerEvent, ColourChanged)
 
38
    WXS_EV_END()
 
39
}
 
40
 
 
41
/*! \brief Ctor
 
42
 *
 
43
 * \param Data wxsItemResData*    The control's resource data.
 
44
 *
 
45
 */
 
46
wxsColourPickerCtrl::wxsColourPickerCtrl(wxsItemResData* Data):
 
47
    wxsWidget(
 
48
        Data,
 
49
        &Reg.Info,
 
50
        wxsColourPickerCtrlEvents,
 
51
        wxsColourPickerCtrlStyles),
 
52
        m_cdColour(*wxBLACK)
 
53
{}
 
54
 
 
55
/*! \brief Create the initial control.
 
56
 *
 
57
 * \return void
 
58
 *
 
59
 */
 
60
void wxsColourPickerCtrl::OnBuildCreatingCode()
 
61
{
 
62
    switch ( GetLanguage() )
 
63
    {
 
64
        case wxsCPP:
 
65
        {
 
66
            AddHeader(_T("<wx/clrpicker.h>"),GetInfo().ClassName,0);
 
67
 
 
68
            wxString ss = m_cdColour.BuildCode(GetCoderContext());
 
69
            Codef(_T("%C(%W, %I, %s, %P, %S, %T, %V, %N);\n"), ss.wx_str());
 
70
 
 
71
            BuildSetupWindowCode();
 
72
            return;
 
73
        }
 
74
 
 
75
        default:
 
76
        {
 
77
            wxsCodeMarks::Unknown(_T("wxsColourPickerCtrl::OnBuildCreatingCode"),GetLanguage());
 
78
        }
 
79
    }
 
80
}
 
81
 
 
82
/*! \brief    Build the control preview.
 
83
 *
 
84
 * \param parent wxWindow*    The parent window.
 
85
 * \param flags long                The control flags.
 
86
 * \return wxObject*                 The constructed control.
 
87
 *
 
88
 */
 
89
wxObject* wxsColourPickerCtrl::OnBuildPreview(wxWindow* Parent,long Flags)
 
90
{
 
91
    wxColourPickerCtrl* Preview;
 
92
    wxColour clr = m_cdColour.GetColour();
 
93
    if(clr.IsOk()){
 
94
        Preview = new wxColourPickerCtrl(Parent, GetId(), clr, Pos(Parent), Size(Parent), Style());
 
95
    }
 
96
    else{
 
97
        Preview = new wxColourPickerCtrl(Parent, GetId(), *wxBLACK, Pos(Parent), Size(Parent), Style());
 
98
    }
 
99
    return SetupWindow(Preview,Flags);
 
100
}
 
101
 
 
102
/*! \brief Enumerate the control's properties.
 
103
 *
 
104
 * \param flags long    The control flags.
 
105
 * \return void
 
106
 *
 
107
 */
 
108
void wxsColourPickerCtrl::OnEnumWidgetProperties(long Flags)
 
109
{
 
110
    WXS_COLOUR(wxsColourPickerCtrl, m_cdColour, _("Colour"), _T("colour"));
 
111
}