~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsradiobox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of wxSmith plugin for Code::Blocks Studio
 
3
* Copyright (C) 2006-2007  Bartlomiej Swiecki
 
4
*
 
5
* wxSmith is free software; you can redistribute it and/or modify
 
6
* it under the terms of the GNU General Public License as published by
 
7
* the Free Software Foundation; either version 3 of the License, or
 
8
* (at your option) any later version.
 
9
*
 
10
* wxSmith is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
17
*
 
18
* $Revision: 4850 $
 
19
* $Id: wxsradiobox.cpp 4850 2008-01-29 21:45:49Z byo $
 
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsradiobox.cpp $
 
21
*/
 
22
 
 
23
#include <wx/defs.h> // to have wxUSE_RADIOBOX defined in the radiobox.h header
 
24
#include <wx/radiobox.h>
 
25
#include <wx/window.h> // GetParent
 
26
#include "wxsradiobox.h"
 
27
 
 
28
namespace
 
29
{
 
30
    wxsRegisterItem<wxsRadioBox> Reg(_T("RadioBox"),wxsTWidget,_T("Standard"),60);
 
31
 
 
32
    WXS_ST_BEGIN(wxsRadioBoxStyles,_T(""))
 
33
        WXS_ST_CATEGORY("wxRadioBox")
 
34
        WXS_ST(wxRA_SPECIFY_COLS)
 
35
        WXS_ST(wxRA_HORIZONTAL)
 
36
        WXS_ST(wxRA_SPECIFY_ROWS)
 
37
        WXS_ST(wxRA_VERTICAL)
 
38
        WXS_ST_DEFAULTS()
 
39
    WXS_ST_END()
 
40
 
 
41
 
 
42
    WXS_EV_BEGIN(wxsRadioBoxEvents)
 
43
        WXS_EVI(EVT_RADIOBOX,wxEVT_COMMAND_RADIOBOX_SELECTED,wxCommandEvent,Select)
 
44
    WXS_EV_END()
 
45
}
 
46
 
 
47
wxsRadioBox::wxsRadioBox(wxsItemResData* Data):
 
48
    wxsWidget(
 
49
        Data,
 
50
        &Reg.Info,
 
51
        wxsRadioBoxEvents,
 
52
        wxsRadioBoxStyles),
 
53
    Label(_("Label")),
 
54
    DefaultSelection(-1),
 
55
    Dimension(1)
 
56
{}
 
57
 
 
58
 
 
59
void wxsRadioBox::OnBuildCreatingCode()
 
60
{
 
61
    switch ( GetLanguage() )
 
62
    {
 
63
        case wxsCPP:
 
64
        {
 
65
            AddHeader(_T("<wx/radiobox.h>"),GetInfo().ClassName,hfInPCH);
 
66
 
 
67
            // wxRadioBox does not have Append Function , therefore , have to build a wxString[]
 
68
            // to pass in to the ctor
 
69
            wxString ChoicesName;
 
70
            if ( ArrayChoices.GetCount() > 0 )
 
71
            {
 
72
                ChoicesName = GetCoderContext()->GetUniqueName(_T("__wxRadioBoxChoices"));
 
73
                Codef(_T("wxString %s[%d] = \n{\n"),ChoicesName.c_str(),(int)ArrayChoices.GetCount());
 
74
                for ( size_t i = 0; i < ArrayChoices.GetCount(); ++i )
 
75
                {
 
76
                    Codef(_T("\t%t%s\n"),ArrayChoices[i].c_str(),((i!=ArrayChoices.GetCount()-1)?_T(","):_T("")));
 
77
                }
 
78
                Codef(_T("};\n"));
 
79
            }
 
80
 
 
81
            if ( Dimension < 1 ) Dimension = 1;
 
82
 
 
83
            Codef(_T("%C(%W, %I, %t, %P, %S, %d, %s, %d, %T, %V, %N);\n"),
 
84
                        Label.c_str(),ArrayChoices.GetCount(),
 
85
                        (ArrayChoices.IsEmpty()?_T("0"):ChoicesName.c_str()),
 
86
                        Dimension);
 
87
 
 
88
            if ( DefaultSelection >= 0 && DefaultSelection < (int)ArrayChoices.GetCount() )
 
89
            {
 
90
                Codef( _T("%ASetSelection(%d);\n"), DefaultSelection);
 
91
            }
 
92
            BuildSetupWindowCode();
 
93
            return;
 
94
        }
 
95
 
 
96
        default:
 
97
        {
 
98
            wxsCodeMarks::Unknown(_T("wxsRadioBox::OnBuildCreatingCode"),GetLanguage());
 
99
        }
 
100
    }
 
101
}
 
102
 
 
103
 
 
104
wxObject* wxsRadioBox::OnBuildPreview(wxWindow* Parent,long Flags)
 
105
{
 
106
    wxRadioBox* Preview = new wxRadioBox(Parent,GetId(),Label,Pos(Parent),Size(Parent),ArrayChoices, Dimension, Style());
 
107
    if ( DefaultSelection >= 0 && DefaultSelection < (int)ArrayChoices.GetCount() )
 
108
    {
 
109
        Preview->SetSelection(DefaultSelection);
 
110
    }
 
111
    return SetupWindow(Preview,Flags);
 
112
}
 
113
 
 
114
void wxsRadioBox::OnEnumWidgetProperties(long Flags)
 
115
{
 
116
    WXS_SHORT_STRING(wxsRadioBox,Label,_("Label"),_T("label"),_T(""),true)
 
117
    WXS_ARRAYSTRING(wxsRadioBox,ArrayChoices,_("Choices"),_T("content"),_T("item"))
 
118
    WXS_LONG(wxsRadioBox,DefaultSelection,_("Default"),_T("default"),0)
 
119
    WXS_LONG(wxsRadioBox,Dimension,_("Dimension"),_T("dimension"),1)
 
120
 
 
121
}