~ubuntu-branches/ubuntu/oneiric/codeblocks/oneiric

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/properties/wxsarraystringeditordlg.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: wxsarraystringeditordlg.cpp 4850 2008-01-29 21:45:49Z byo $
 
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/properties/wxsarraystringeditordlg.cpp $
 
21
*/
 
22
 
 
23
#include "wxsarraystringeditordlg.h"
 
24
 
 
25
#include <wx/tokenzr.h>
 
26
 
 
27
//(*InternalHeaders(wxsArrayStringEditorDlg)
 
28
#include <wx/intl.h>
 
29
#include <wx/string.h>
 
30
//*)
 
31
 
 
32
//(*IdInit(wxsArrayStringEditorDlg)
 
33
const long wxsArrayStringEditorDlg::ID_TEXTCTRL1 = wxNewId();
 
34
//*)
 
35
 
 
36
BEGIN_EVENT_TABLE(wxsArrayStringEditorDlg,wxDialog)
 
37
        //(*EventTable(wxsArrayStringEditorDlg)
 
38
        //*)
 
39
END_EVENT_TABLE()
 
40
 
 
41
wxsArrayStringEditorDlg::wxsArrayStringEditorDlg(wxWindow* parent,wxArrayString& _Data,wxWindowID id):
 
42
    Data(_Data)
 
43
{
 
44
        //(*Initialize(wxsArrayStringEditorDlg)
 
45
        wxButton* Button1;
 
46
        wxBoxSizer* BoxSizer2;
 
47
        wxButton* Button2;
 
48
        wxBoxSizer* BoxSizer1;
 
49
        wxStaticBoxSizer* StaticBoxSizer1;
 
50
 
 
51
        Create(parent, id, _("Edit items"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
 
52
        BoxSizer1 = new wxBoxSizer(wxVERTICAL);
 
53
        StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Enter items (one item per line)"));
 
54
        Items = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(350,200), wxTE_MULTILINE, wxDefaultValidator, _T("ID_TEXTCTRL1"));
 
55
        StaticBoxSizer1->Add(Items, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2);
 
56
        BoxSizer1->Add(StaticBoxSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
57
        BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
 
58
        Button1 = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_OK"));
 
59
        Button1->SetDefault();
 
60
        BoxSizer2->Add(Button1, 1, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
61
        Button2 = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_CANCEL"));
 
62
        BoxSizer2->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
63
        BoxSizer1->Add(BoxSizer2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
 
64
        SetSizer(BoxSizer1);
 
65
        BoxSizer1->Fit(this);
 
66
        BoxSizer1->SetSizeHints(this);
 
67
 
 
68
        Connect(wxID_OK,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&wxsArrayStringEditorDlg::OnOK);
 
69
        Connect(wxID_CANCEL,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&wxsArrayStringEditorDlg::OnCancel);
 
70
        //*)
 
71
 
 
72
        size_t Count = Data.Count();
 
73
        for ( size_t i = 0; i<Count; i++ )
 
74
        {
 
75
            Items->AppendText(Data[i]);
 
76
            Items->AppendText(_T('\n'));
 
77
        }
 
78
}
 
79
 
 
80
wxsArrayStringEditorDlg::~wxsArrayStringEditorDlg()
 
81
{
 
82
    //(*Destroy(wxsArrayStringEditorDlg)
 
83
    //*)
 
84
}
 
85
 
 
86
 
 
87
void wxsArrayStringEditorDlg::OnOK(wxCommandEvent& event)
 
88
{
 
89
    wxStringTokenizer Tknz(Items->GetValue(),_T("\n"),wxTOKEN_RET_EMPTY);
 
90
    Data.Clear();
 
91
 
 
92
    while ( Tknz.HasMoreTokens() )
 
93
    {
 
94
        wxString Line = Tknz.GetNextToken();
 
95
        Data.Add(Line);
 
96
    }
 
97
 
 
98
    EndModal(wxID_OK);
 
99
}
 
100
 
 
101
void wxsArrayStringEditorDlg::OnCancel(wxCommandEvent& event)
 
102
{
 
103
    EndModal(wxID_CANCEL);
 
104
}