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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/lib_finder/libselectdlg.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 lib_finder plugin for Code::Blocks Studio
 
3
* Copyright (C) 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 2 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, write to the Free Software
 
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
18
*
 
19
* $Revision: 4504 $
 
20
* $Id: wxsmithpluginregistrants.cpp 4504 2007-10-02 21:52:30Z byo $
 
21
* $HeadURL: svn+ssh://byo@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/wxSmith/plugin/wxsmithpluginregistrants.cpp $
 
22
*/
 
23
 
 
24
#include "libselectdlg.h"
 
25
 
 
26
//(*InternalHeaders(LibSelectDlg)
 
27
#include <wx/sizer.h>
 
28
#include <wx/stattext.h>
 
29
#include <wx/checklst.h>
 
30
#include <wx/checkbox.h>
 
31
#include <wx/radiobut.h>
 
32
#include <wx/intl.h>
 
33
#include <wx/button.h>
 
34
#include <wx/string.h>
 
35
//*)
 
36
 
 
37
#include <manager.h>
 
38
#include <configmanager.h>
 
39
 
 
40
//(*IdInit(LibSelectDlg)
 
41
const long LibSelectDlg::ID_STATICTEXT1 = wxNewId();
 
42
const long LibSelectDlg::ID_CHECKLISTBOX1 = wxNewId();
 
43
const long LibSelectDlg::ID_RADIOBUTTON1 = wxNewId();
 
44
const long LibSelectDlg::ID_RADIOBUTTON2 = wxNewId();
 
45
const long LibSelectDlg::ID_RADIOBUTTON3 = wxNewId();
 
46
const long LibSelectDlg::ID_CHECKBOX1 = wxNewId();
 
47
//*)
 
48
 
 
49
BEGIN_EVENT_TABLE(LibSelectDlg,wxDialog)
 
50
        //(*EventTable(LibSelectDlg)
 
51
        //*)
 
52
        EVT_BUTTON(wxID_OK,LibSelectDlg::OnOk)
 
53
END_EVENT_TABLE()
 
54
 
 
55
LibSelectDlg::LibSelectDlg(wxWindow* parent,const wxArrayString& Names)
 
56
{
 
57
        //(*Initialize(LibSelectDlg)
 
58
        wxBoxSizer* BoxSizer1;
 
59
        wxStaticBoxSizer* StaticBoxSizer1;
 
60
        wxStdDialogButtonSizer* StdDialogButtonSizer1;
 
61
 
 
62
        Create(parent, wxID_ANY, _("Setting up libraries"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
 
63
        BoxSizer1 = new wxBoxSizer(wxVERTICAL);
 
64
        StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Select libraries You want to set up:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
 
65
        BoxSizer1->Add(StaticText1, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
66
        m_Libraries = new wxCheckListBox(this, ID_CHECKLISTBOX1, wxDefaultPosition, wxSize(361,251), 0, 0, 0, wxDefaultValidator, _T("ID_CHECKLISTBOX1"));
 
67
        BoxSizer1->Add(m_Libraries, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
68
        StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Previous settings"));
 
69
        m_DontClear = new wxRadioButton(this, ID_RADIOBUTTON1, _("Do not clear previous results (but remove duplicates)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxDefaultValidator, _T("ID_RADIOBUTTON1"));
 
70
        StaticBoxSizer1->Add(m_DontClear, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
71
        m_ClearSelected = new wxRadioButton(this, ID_RADIOBUTTON2, _("Clear previous results for selected libraries"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON2"));
 
72
        m_ClearSelected->SetValue(true);
 
73
        StaticBoxSizer1->Add(m_ClearSelected, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
74
        m_ClearAll = new wxRadioButton(this, ID_RADIOBUTTON3, _("Clear all previous libraries settings"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON3"));
 
75
        StaticBoxSizer1->Add(m_ClearAll, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
76
        BoxSizer1->Add(StaticBoxSizer1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
77
        m_SetupGlobalVars = new wxCheckBox(this, ID_CHECKBOX1, _("Set up Global Variables"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
 
78
        m_SetupGlobalVars->SetValue(true);
 
79
        BoxSizer1->Add(m_SetupGlobalVars, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
80
        StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
 
81
        StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
 
82
        StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_CANCEL, wxEmptyString));
 
83
        StdDialogButtonSizer1->Realize();
 
84
        BoxSizer1->Add(StdDialogButtonSizer1, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10);
 
85
        SetSizer(BoxSizer1);
 
86
        BoxSizer1->Fit(this);
 
87
        BoxSizer1->SetSizeHints(this);
 
88
        Center();
 
89
        //*)
 
90
 
 
91
        m_Libraries->Append(Names);
 
92
 
 
93
        ConfigManager* Cfg = Manager::Get()->GetConfigManager(_T("lib_finder"));
 
94
        switch ( Cfg->ReadInt(_T("libselect/previous"),1) )
 
95
        {
 
96
            case 0: m_DontClear->SetValue(true); break;
 
97
            case 2: m_ClearAll->SetValue(true); break;
 
98
            case 1:
 
99
            default: m_ClearSelected->SetValue(true); break;
 
100
        }
 
101
        m_SetupGlobalVars->SetValue(Cfg->ReadBool(_T("libselect/setup_global_vars"),true));
 
102
}
 
103
 
 
104
LibSelectDlg::~LibSelectDlg()
 
105
{
 
106
        //(*Destroy(LibSelectDlg)
 
107
        //*)
 
108
}
 
109
 
 
110
void LibSelectDlg::SetSelections(const wxArrayInt& Selections)
 
111
{
 
112
    m_Libraries->Freeze();
 
113
 
 
114
    // First clear all
 
115
    for ( size_t i=0; i<m_Libraries->GetCount(); i++ )
 
116
    {
 
117
        m_Libraries->Check(i,false);
 
118
    }
 
119
 
 
120
    // Next select only those which are on the list
 
121
    for ( size_t i=0; i<Selections.Count(); i++ )
 
122
    {
 
123
        m_Libraries->Check(Selections[i],true);
 
124
    }
 
125
 
 
126
    m_Libraries->Thaw();
 
127
}
 
128
 
 
129
wxArrayInt LibSelectDlg::GetSelections()
 
130
{
 
131
    wxArrayInt Ret;
 
132
    for ( size_t i=0; i<m_Libraries->GetCount(); i++ )
 
133
    {
 
134
        if ( m_Libraries->IsChecked(i) )
 
135
        {
 
136
            Ret.Add((int)i);
 
137
        }
 
138
    }
 
139
    return Ret;
 
140
}
 
141
 
 
142
bool LibSelectDlg::GetSetupGlobalVars()
 
143
{
 
144
    return m_SetupGlobalVars->GetValue();
 
145
}
 
146
 
 
147
bool LibSelectDlg::GetDontClearPrevious()
 
148
{
 
149
    return m_DontClear->GetValue();
 
150
}
 
151
 
 
152
bool LibSelectDlg::GetClearSelectedPrevious()
 
153
{
 
154
    return m_ClearSelected->GetValue();
 
155
}
 
156
 
 
157
bool LibSelectDlg::GetClearAllPrevious()
 
158
{
 
159
    return m_ClearAll->GetValue();
 
160
}
 
161
 
 
162
void LibSelectDlg::OnOk(wxCommandEvent& event)
 
163
{
 
164
        ConfigManager* Cfg = Manager::Get()->GetConfigManager(_T("lib_finder"));
 
165
        if ( m_DontClear->GetValue()     ) Cfg->Write(_T("libselect/previous"),0);
 
166
        if ( m_ClearSelected->GetValue() ) Cfg->Write(_T("libselect/previous"),1);
 
167
        if ( m_ClearAll->GetValue()      ) Cfg->Write(_T("libselect/previous"),2);
 
168
        Cfg->Write(_T("libselect/setup_global_vars"),m_SetupGlobalVars->GetValue());
 
169
    event.Skip();
 
170
}