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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxslistbox.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: wxslistbox.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/wxslistbox.cpp $
 
21
*/
 
22
 
 
23
#include "wxslistbox.h"
 
24
 
 
25
namespace
 
26
{
 
27
    wxsRegisterItem<wxsListBox> Reg(_T("ListBox"),wxsTWidget,_T("Standard"),70);
 
28
 
 
29
    WXS_ST_BEGIN(wxsListBoxStyles,_T(""))
 
30
        WXS_ST_CATEGORY("wxListBox")
 
31
        WXS_ST(wxLB_SINGLE)
 
32
        WXS_ST(wxLB_MULTIPLE)
 
33
        WXS_ST(wxLB_EXTENDED)
 
34
        WXS_ST(wxLB_HSCROLL)
 
35
        WXS_ST(wxLB_ALWAYS_SB)
 
36
        WXS_ST(wxLB_NEEDED_SB)
 
37
        WXS_ST(wxLB_SORT)
 
38
        WXS_ST_DEFAULTS()
 
39
    WXS_ST_END()
 
40
 
 
41
    WXS_EV_BEGIN(wxsListBoxEvents)
 
42
        WXS_EVI(EVT_LISTBOX,wxEVT_COMMAND_LISTBOX_SELECTED,wxCommandEvent,Select)
 
43
        WXS_EVI(EVT_LISTBOX_DCLICK,wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,wxCommandEvent,DClick)
 
44
    WXS_EV_END()
 
45
}
 
46
 
 
47
wxsListBox::wxsListBox(wxsItemResData* Data):
 
48
    wxsWidget(
 
49
        Data,
 
50
        &Reg.Info,
 
51
        wxsListBoxEvents,
 
52
        wxsListBoxStyles),
 
53
    DefaultSelection(-1)
 
54
{}
 
55
 
 
56
void wxsListBox::OnBuildCreatingCode()
 
57
{
 
58
    switch ( GetLanguage() )
 
59
    {
 
60
        case wxsCPP:
 
61
        {
 
62
            AddHeader(_T("<wx/listbox.h>"),GetInfo().ClassName,hfInPCH);
 
63
            Codef(_T("%C(%W, %I, %P, %S, 0, 0, %T, %V, %N);\n"));
 
64
            for ( size_t i = 0; i <  ArrayChoices.GetCount(); ++i )
 
65
            {
 
66
                if ( DefaultSelection == (int)i )
 
67
                {
 
68
                    Codef(_T("%ASetSelection( "));
 
69
                }
 
70
                Codef( _T("%AAppend(%t)"), ArrayChoices[i].c_str());
 
71
                if ( DefaultSelection == (int)i )
 
72
                {
 
73
                    Codef(_T(" )"));
 
74
                }
 
75
                Codef(_T(";\n"));
 
76
            }
 
77
 
 
78
            BuildSetupWindowCode();
 
79
            return;
 
80
        }
 
81
 
 
82
        default:
 
83
        {
 
84
            wxsCodeMarks::Unknown(_T("wxsListBox::OnBuildCreatingCode"),GetLanguage());
 
85
        }
 
86
    }
 
87
}
 
88
 
 
89
 
 
90
wxObject* wxsListBox::OnBuildPreview(wxWindow* Parent,long Flags)
 
91
{
 
92
    wxListBox* Preview = new wxListBox(Parent,GetId(),Pos(Parent),Size(Parent),0,0, Style());
 
93
    for ( size_t i = 0; i <  ArrayChoices.GetCount(); ++i )
 
94
    {
 
95
        int Val = Preview->Append(ArrayChoices[i]);
 
96
        if ( (int)i == DefaultSelection )
 
97
        {
 
98
            Preview->SetSelection(Val);
 
99
        }
 
100
    }
 
101
 
 
102
    return SetupWindow(Preview,Flags);
 
103
}
 
104
 
 
105
void wxsListBox::OnEnumWidgetProperties(long Flags)
 
106
{
 
107
      WXS_ARRAYSTRING(wxsListBox,ArrayChoices,_("Choices"),_T("content"),_T("item"))
 
108
      WXS_LONG(wxsListBox,DefaultSelection,_("Default"),_T("default"),0)
 
109
}