2
* This file is part of wxSmith plugin for Code::Blocks Studio
3
* Copyright (C) 2006-2007 Bartlomiej Swiecki
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.
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.
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/>.
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 $
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"
30
wxsRegisterItem<wxsRadioBox> Reg(_T("RadioBox"),wxsTWidget,_T("Standard"),60);
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)
42
WXS_EV_BEGIN(wxsRadioBoxEvents)
43
WXS_EVI(EVT_RADIOBOX,wxEVT_COMMAND_RADIOBOX_SELECTED,wxCommandEvent,Select)
47
wxsRadioBox::wxsRadioBox(wxsItemResData* Data):
59
void wxsRadioBox::OnBuildCreatingCode()
61
switch ( GetLanguage() )
65
AddHeader(_T("<wx/radiobox.h>"),GetInfo().ClassName,hfInPCH);
67
// wxRadioBox does not have Append Function , therefore , have to build a wxString[]
68
// to pass in to the ctor
70
if ( ArrayChoices.GetCount() > 0 )
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 )
76
Codef(_T("\t%t%s\n"),ArrayChoices[i].c_str(),((i!=ArrayChoices.GetCount()-1)?_T(","):_T("")));
81
if ( Dimension < 1 ) Dimension = 1;
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()),
88
if ( DefaultSelection >= 0 && DefaultSelection < (int)ArrayChoices.GetCount() )
90
Codef( _T("%ASetSelection(%d);\n"), DefaultSelection);
92
BuildSetupWindowCode();
98
wxsCodeMarks::Unknown(_T("wxsRadioBox::OnBuildCreatingCode"),GetLanguage());
104
wxObject* wxsRadioBox::OnBuildPreview(wxWindow* Parent,long Flags)
106
wxRadioBox* Preview = new wxRadioBox(Parent,GetId(),Label,Pos(Parent),Size(Parent),ArrayChoices, Dimension, Style());
107
if ( DefaultSelection >= 0 && DefaultSelection < (int)ArrayChoices.GetCount() )
109
Preview->SetSelection(DefaultSelection);
111
return SetupWindow(Preview,Flags);
114
void wxsRadioBox::OnEnumWidgetProperties(long Flags)
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)