~ubuntu-branches/ubuntu/maverick/codelite/maverick

« back to all changes in this revision

Viewing changes to LiteEditor/open_resouce_dlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-04-30 02:46:27 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430024627-7xp71gerfvw00xtt
Tags: 1.0.2822+dfsg-0ubuntu1
* New upstream release (LP: #369466)
* debian/copyright:
  + Added Files section for sdk/wxpropgrid
  + Made license text RFC compliant (add . for empty lines)
* debian/control:
  + Bump Standards-Version to 3.8.1
* debian/patches/02_fix-desktop.patch,
  + Refreshed to patch cleanly
* debian/*.install,
  debian/codelite.dirs,
  debian/codelite.links,
  debian/patches/03_fix-sh.patch,
  debian/patches/04_change-installpath.patch,
  + Updated for new upstream directory structure
  + Patches dropped, no longer needed.
* debian/patches/03_cstdio-include.patch,
  + Include cstdio for C++ and stdio.h for C, since it seems to be missing
* debian/codelite.menu,
  debian/*.1,
  debian/codelite.manpages:
  + Updated to reflect change in command names
    - CodeLite    => codelite
    - le_exec     => codelite_exec
    - le_dos2unix => codelite_fix_files
    - le_killproc => codelite_kill_children
* debian/README.source,
  debian/rules,
  debian/copyright:
  + Remove sdk/curl from the list of excluded files, since it doesn't exist
    any more

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//////////////////////////////////////////////////////////////////////////////
2
 
//////////////////////////////////////////////////////////////////////////////
3
 
//
4
 
// copyright            : (C) 2008 by Eran Ifrah
5
 
// file name            : open_resouce_dlg.cpp
6
 
//
7
 
// -------------------------------------------------------------------------
8
 
// A
9
 
//              _____           _      _     _ _
10
 
//             /  __ \         | |    | |   (_) |
11
 
//             | /  \/ ___   __| | ___| |    _| |_ ___
12
 
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
13
 
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
14
 
//              \____/\___/ \__,_|\___\_____/_|\__\___|
15
 
//
16
 
//                                                  F i l e
17
 
//
18
 
//    This program is free software; you can redistribute it and/or modify
19
 
//    it under the terms of the GNU General Public License as published by
20
 
//    the Free Software Foundation; either version 2 of the License, or
21
 
//    (at your option) any later version.
22
 
//
23
 
//////////////////////////////////////////////////////////////////////////////
24
 
//////////////////////////////////////////////////////////////////////////////
25
 
///////////////////////////////////////////////////////////////////////////
26
 
// C++ code generated with wxFormBuilder (version May  5 2007)
27
 
// http://www.wxformbuilder.org/
28
 
//
29
 
// PLEASE DO "NOT" EDIT THIS FILE!
30
 
///////////////////////////////////////////////////////////////////////////
31
 
#include "editor_config.h"
32
 
 
33
 
#ifdef WX_PRECOMP
34
 
 
35
 
#include "wx/wxprec.h"
36
 
 
37
 
#ifdef __BORLANDC__
38
 
#pragma hdrstop
39
 
#endif //__BORLANDC__
40
 
 
41
 
#else
42
 
#include <wx/wx.h>
43
 
#endif //WX_PRECOMP
44
 
 
45
 
#include "open_resouce_dlg.h"
46
 
#include "macros.h"
47
 
#include "manager.h"
48
 
 
49
 
///////////////////////////////////////////////////////////////////////////
50
 
BEGIN_EVENT_TABLE(OpenResourceDlg, wxDialog)
51
 
        EVT_CHAR_HOOK(OpenResourceDlg::OnCharHook)
52
 
END_EVENT_TABLE()
53
 
 
54
 
OpenResourceDlg::OpenResourceDlg( wxWindow* parent, int id, wxString title, wxPoint pos, wxSize size, int style )
55
 
                : wxDialog( parent, id, title, pos, size, style )
56
 
{
57
 
        m_timer = new wxTimer(this);
58
 
        m_timer->Start(100);
59
 
 
60
 
        //load all files from the workspace
61
 
        ManagerST::Get()->GetWorkspaceFiles(m_files, true);
62
 
 
63
 
        this->SetSizeHints( wxDefaultSize, wxDefaultSize );
64
 
 
65
 
        wxBoxSizer* mainSizer;
66
 
        mainSizer = new wxBoxSizer( wxVERTICAL );
67
 
 
68
 
        mainPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
69
 
        wxBoxSizer* panelSizer;
70
 
        panelSizer = new wxBoxSizer( wxVERTICAL );
71
 
 
72
 
        m_staticTitle = new wxStaticText( mainPanel, wxID_ANY, wxT("Find Resource (wildcards are allowed):"), wxDefaultPosition, wxDefaultSize, 0 );
73
 
        panelSizer->Add( m_staticTitle, 0, wxALL, 5 );
74
 
 
75
 
        m_textResourceName = new wxTextCtrl(mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
76
 
        panelSizer->Add( m_textResourceName, 0, wxALL|wxEXPAND, 5 );
77
 
 
78
 
        wxStaticText *label = new wxStaticText( mainPanel, wxID_ANY, wxT("Matched resources:"), wxDefaultPosition, wxDefaultSize, 0 );
79
 
        panelSizer->Add( label, 0, wxALL, 5 );
80
 
 
81
 
        m_listShortNames = new wxListBox( mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
82
 
        panelSizer->Add( m_listShortNames, 1, wxALL|wxEXPAND, 5 );
83
 
 
84
 
        m_fullText = new wxStaticText( mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
85
 
        panelSizer->Add( m_fullText, 0, wxALL, 5 );
86
 
 
87
 
        m_checkBoxPartialMatching = new wxCheckBox( mainPanel, wxID_ANY, wxT("Allow partial matching"), wxDefaultPosition, wxDefaultSize, 0 );
88
 
        panelSizer->Add( m_checkBoxPartialMatching, 0, wxALL|wxEXPAND, 5 );
89
 
 
90
 
        long v(0);
91
 
        EditorConfigST::Get()->GetLongValue(wxT("OpenResourceAllowsPartialMatch"), v);
92
 
        m_checkBoxPartialMatching->SetValue(v == 1 ? true : false);
93
 
 
94
 
        mainPanel->SetSizer( panelSizer );
95
 
        mainPanel->Layout();
96
 
        panelSizer->Fit( mainPanel );
97
 
        mainSizer->Add( mainPanel, 1, wxEXPAND | wxALL, 5 );
98
 
 
99
 
        m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
100
 
        mainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
101
 
 
102
 
        wxBoxSizer* btnSizer;
103
 
        btnSizer = new wxBoxSizer( wxHORIZONTAL );
104
 
 
105
 
        m_btnOk = new wxButton( this, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
106
 
        btnSizer->Add( m_btnOk, 0, wxALL, 5 );
107
 
 
108
 
        m_button2 = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
109
 
        btnSizer->Add( m_button2, 0, wxALL, 5 );
110
 
 
111
 
        mainSizer->Add( btnSizer, 0, wxALIGN_RIGHT, 5 );
112
 
 
113
 
        this->SetSizer( mainSizer );
114
 
        this->Layout();
115
 
        ConnectEvents();
116
 
        Centre();
117
 
        m_textResourceName->SetFocus();
118
 
}
119
 
 
120
 
OpenResourceDlg::~OpenResourceDlg()
121
 
{
122
 
        m_timer->Stop();
123
 
        delete m_timer;
124
 
}
125
 
 
126
 
void OpenResourceDlg::ConnectEvents()
127
 
{
128
 
        ConnectButton(m_button2, OpenResourceDlg::OnButtonCancel);
129
 
        ConnectButton(m_btnOk, OpenResourceDlg::OnButtonOK);
130
 
        m_listShortNames->Connect(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler(OpenResourceDlg::OnItemActivated), NULL, this);
131
 
        Connect(m_timer->GetId(), wxEVT_TIMER, wxTimerEventHandler(OpenResourceDlg::OnTimer), NULL, this);
132
 
}
133
 
 
134
 
void OpenResourceDlg::OnTimer(wxTimerEvent &event)
135
 
{
136
 
        wxUnusedVar(event);
137
 
        wxArrayString tmpArr;
138
 
        wxString curSel = m_textResourceName->GetValue();
139
 
        if (!curSel.Trim().Trim(false).IsEmpty()) {
140
 
 
141
 
                curSel = curSel.MakeLower().Trim().Trim(false);
142
 
 
143
 
                for (size_t i=0; i<m_files.size(); i++) {
144
 
                        wxString fileName(m_files.at(i).GetFullName());
145
 
                        fileName= fileName.MakeLower();
146
 
 
147
 
                        //append wildcard at the end
148
 
                        if (!curSel.EndsWith(wxT("*"))) {
149
 
                                curSel << wxT("*");
150
 
                        }
151
 
 
152
 
                        // FR# [2008133]
153
 
                        if (m_checkBoxPartialMatching->IsChecked() && !curSel.StartsWith(wxT("*"))) {
154
 
                                curSel.Prepend(wxT("*"));
155
 
                        }
156
 
 
157
 
                        if (wxMatchWild(curSel, fileName)) {
158
 
                                tmpArr.Add(m_files[i].GetFullPath());
159
 
                        }
160
 
                }
161
 
        }
162
 
 
163
 
        // actValues represents the list of files as they appear in the ListBox
164
 
        // we need to loop over the list box, since the actual full file names
165
 
        // are stored as ClientObject
166
 
        wxArrayString actValues;
167
 
        for (unsigned int i=0; i<m_listShortNames->GetCount(); i++) {
168
 
                wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(i);
169
 
                actValues.Add(data->GetData());
170
 
        }
171
 
        // we need to sort the array
172
 
        actValues.Sort();
173
 
 
174
 
        // tmpArr contains the list of files (full paths) after filtering the typed pattern
175
 
        tmpArr.Sort();
176
 
 
177
 
        if (tmpArr == actValues)
178
 
                return;
179
 
 
180
 
        //change was done, update the file list
181
 
        Freeze();
182
 
        m_listShortNames->Clear();
183
 
        for (size_t i=0; i<tmpArr.GetCount(); i++) {
184
 
                wxFileName fn(tmpArr.Item(i));
185
 
                m_listShortNames->Append(fn.GetFullName(), new wxStringClientData(tmpArr.Item(i)));
186
 
        }
187
 
        Thaw();
188
 
        if (m_listShortNames->GetCount() > 0) {
189
 
                m_listShortNames->Select(0);
190
 
                // display the full name at the bottom static text control
191
 
                wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
192
 
                m_fullText->SetLabel(data->GetData());
193
 
        }
194
 
}
195
 
 
196
 
void OpenResourceDlg::OnButtonCancel(wxCommandEvent &event)
197
 
{
198
 
        wxUnusedVar(event);
199
 
        EndModal(wxID_CANCEL);
200
 
}
201
 
 
202
 
void OpenResourceDlg::OnButtonOK(wxCommandEvent &event)
203
 
{
204
 
        wxUnusedVar(event);
205
 
        if (UpdateFileName()) {
206
 
                EndModal(wxID_OK);
207
 
        }
208
 
}
209
 
 
210
 
void OpenResourceDlg::OnItemActivated(wxCommandEvent &event)
211
 
{
212
 
        wxUnusedVar(event);
213
 
 
214
 
        if (UpdateFileName()) {
215
 
                EndModal(wxID_OK);
216
 
        }
217
 
}
218
 
 
219
 
bool OpenResourceDlg::UpdateFileName()
220
 
{
221
 
        int idx = m_listShortNames->GetSelection();
222
 
        if (idx == wxNOT_FOUND) {
223
 
                return false;
224
 
        }
225
 
 
226
 
        m_fileName = m_fullText->GetLabelText();
227
 
 
228
 
        // save the checkbox value into the settings
229
 
        EditorConfigST::Get()->SaveLongValue(wxT("OpenResourceAllowsPartialMatch"), m_checkBoxPartialMatching->IsChecked() ? 1 : 0);
230
 
 
231
 
        return true;
232
 
}
233
 
 
234
 
void OpenResourceDlg::OnCharHook(wxKeyEvent &event)
235
 
{
236
 
        if (event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) {
237
 
                if (m_listShortNames->GetSelection() != wxNOT_FOUND) {
238
 
                        if (UpdateFileName()) {
239
 
                                EndModal(wxID_OK);
240
 
                                return;
241
 
                        }
242
 
                } else if (m_listShortNames->GetCount() == 1) {
243
 
                        m_listShortNames->SetSelection(0);
244
 
                        if (UpdateFileName()) {
245
 
                                EndModal(wxID_OK);
246
 
                                return;
247
 
                        }
248
 
                }
249
 
        } else if (event.GetKeyCode() == WXK_DOWN && m_listShortNames->GetCount() > 0) {
250
 
                //up key
251
 
                int cursel = m_listShortNames->GetSelection();
252
 
                if (cursel != wxNOT_FOUND) {
253
 
                        //there is a selection in the listbox
254
 
                        cursel++;
255
 
                        if (cursel >= (int)m_listShortNames->GetCount()) {
256
 
                                //already at last item, cant scroll anymore
257
 
                                return;
258
 
                        }
259
 
                        m_listShortNames->SetSelection(cursel);
260
 
                        m_listShortNames->Select(cursel);
261
 
                        m_listShortNames->SetFirstItem(cursel);
262
 
 
263
 
                        // display the full name at the bottom static text control
264
 
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(cursel);
265
 
                        m_fullText->SetLabel(data->GetData());
266
 
 
267
 
                } else {
268
 
                        //no selection is made
269
 
                        m_listShortNames->SetSelection(0);
270
 
                        m_listShortNames->Select(0);
271
 
 
272
 
                        // display the full name at the bottom static text control
273
 
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
274
 
                        m_fullText->SetLabel(data->GetData());
275
 
 
276
 
                        m_listShortNames->SetFirstItem(0);
277
 
                }
278
 
                return;
279
 
        } else if (event.GetKeyCode() == WXK_UP && m_listShortNames->GetCount() > 0) {
280
 
                //up key
281
 
                int cursel = m_listShortNames->GetSelection();
282
 
                if (cursel != wxNOT_FOUND) {
283
 
                        //there is a selection in the listbox
284
 
                        cursel--;
285
 
                        if (cursel < 0) {
286
 
                                //already at first item, cant scroll anymore
287
 
                                return;
288
 
                        }
289
 
                        m_listShortNames->SetSelection(cursel);
290
 
                        m_listShortNames->SetFirstItem(cursel);
291
 
 
292
 
                        // display the full name at the bottom static text control
293
 
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(cursel);
294
 
                        m_fullText->SetLabel(data->GetData());
295
 
                } else {
296
 
                        //no selection is made
297
 
                        m_listShortNames->SetSelection(0);
298
 
                        m_listShortNames->SetFirstItem(0);
299
 
 
300
 
                        // display the full name at the bottom static text control
301
 
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
302
 
                        m_fullText->SetLabel(data->GetData());
303
 
                }
304
 
                return;
305
 
        }
306
 
        event.Skip();
307
 
}
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
//////////////////////////////////////////////////////////////////////////////
 
3
//
 
4
// copyright            : (C) 2008 by Eran Ifrah
 
5
// file name            : open_resouce_dlg.cpp
 
6
//
 
7
// -------------------------------------------------------------------------
 
8
// A
 
9
//              _____           _      _     _ _
 
10
//             /  __ \         | |    | |   (_) |
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
 
15
//
 
16
//                                                  F i l e
 
17
//
 
18
//    This program is free software; you can redistribute it and/or modify
 
19
//    it under the terms of the GNU General Public License as published by
 
20
//    the Free Software Foundation; either version 2 of the License, or
 
21
//    (at your option) any later version.
 
22
//
 
23
//////////////////////////////////////////////////////////////////////////////
 
24
//////////////////////////////////////////////////////////////////////////////
 
25
///////////////////////////////////////////////////////////////////////////
 
26
// C++ code generated with wxFormBuilder (version May  5 2007)
 
27
// http://www.wxformbuilder.org/
 
28
//
 
29
// PLEASE DO "NOT" EDIT THIS FILE!
 
30
///////////////////////////////////////////////////////////////////////////
 
31
#include "editor_config.h"
 
32
 
 
33
#ifdef WX_PRECOMP
 
34
 
 
35
#include "wx/wxprec.h"
 
36
 
 
37
#ifdef __BORLANDC__
 
38
#pragma hdrstop
 
39
#endif //__BORLANDC__
 
40
 
 
41
#else
 
42
#include <wx/wx.h>
 
43
#endif //WX_PRECOMP
 
44
 
 
45
#include "open_resouce_dlg.h"
 
46
#include "macros.h"
 
47
#include "manager.h"
 
48
 
 
49
///////////////////////////////////////////////////////////////////////////
 
50
BEGIN_EVENT_TABLE(OpenResourceDlg, wxDialog)
 
51
        EVT_CHAR_HOOK(OpenResourceDlg::OnCharHook)
 
52
END_EVENT_TABLE()
 
53
 
 
54
OpenResourceDlg::OpenResourceDlg( wxWindow* parent, int id, wxString title, wxPoint pos, wxSize size, int style )
 
55
                : wxDialog( parent, id, title, pos, size, style )
 
56
{
 
57
        m_timer = new wxTimer(this);
 
58
        m_timer->Start(100);
 
59
 
 
60
        //load all files from the workspace
 
61
        ManagerST::Get()->GetWorkspaceFiles(m_files, true);
 
62
 
 
63
        this->SetSizeHints( wxDefaultSize, wxDefaultSize );
 
64
 
 
65
        wxBoxSizer* mainSizer;
 
66
        mainSizer = new wxBoxSizer( wxVERTICAL );
 
67
 
 
68
        mainPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
 
69
        wxBoxSizer* panelSizer;
 
70
        panelSizer = new wxBoxSizer( wxVERTICAL );
 
71
 
 
72
        m_staticTitle = new wxStaticText( mainPanel, wxID_ANY, wxT("Find Resource (wildcards are allowed):"), wxDefaultPosition, wxDefaultSize, 0 );
 
73
        panelSizer->Add( m_staticTitle, 0, wxALL, 5 );
 
74
 
 
75
        m_textResourceName = new wxTextCtrl(mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
 
76
        panelSizer->Add( m_textResourceName, 0, wxALL|wxEXPAND, 5 );
 
77
 
 
78
        wxStaticText *label = new wxStaticText( mainPanel, wxID_ANY, wxT("Matched resources:"), wxDefaultPosition, wxDefaultSize, 0 );
 
79
        panelSizer->Add( label, 0, wxALL, 5 );
 
80
 
 
81
        m_listShortNames = new wxListBox( mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
 
82
        panelSizer->Add( m_listShortNames, 1, wxALL|wxEXPAND, 5 );
 
83
 
 
84
        m_fullText = new wxStaticText( mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
 
85
        panelSizer->Add( m_fullText, 0, wxALL, 5 );
 
86
 
 
87
        m_checkBoxPartialMatching = new wxCheckBox( mainPanel, wxID_ANY, wxT("Allow partial matching"), wxDefaultPosition, wxDefaultSize, 0 );
 
88
        panelSizer->Add( m_checkBoxPartialMatching, 0, wxALL|wxEXPAND, 5 );
 
89
 
 
90
        long v(0);
 
91
        EditorConfigST::Get()->GetLongValue(wxT("OpenResourceAllowsPartialMatch"), v);
 
92
        m_checkBoxPartialMatching->SetValue(v == 1 ? true : false);
 
93
 
 
94
        mainPanel->SetSizer( panelSizer );
 
95
        mainPanel->Layout();
 
96
        panelSizer->Fit( mainPanel );
 
97
        mainSizer->Add( mainPanel, 1, wxEXPAND | wxALL, 5 );
 
98
 
 
99
        m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
 
100
        mainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
 
101
 
 
102
        wxBoxSizer* btnSizer;
 
103
        btnSizer = new wxBoxSizer( wxHORIZONTAL );
 
104
 
 
105
        m_btnOk = new wxButton( this, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
 
106
        btnSizer->Add( m_btnOk, 0, wxALL, 5 );
 
107
 
 
108
        m_button2 = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
 
109
        btnSizer->Add( m_button2, 0, wxALL, 5 );
 
110
 
 
111
        mainSizer->Add( btnSizer, 0, wxALIGN_RIGHT, 5 );
 
112
 
 
113
        this->SetSizer( mainSizer );
 
114
        this->Layout();
 
115
        ConnectEvents();
 
116
        Centre();
 
117
        m_textResourceName->SetFocus();
 
118
}
 
119
 
 
120
OpenResourceDlg::~OpenResourceDlg()
 
121
{
 
122
        m_timer->Stop();
 
123
        delete m_timer;
 
124
}
 
125
 
 
126
void OpenResourceDlg::ConnectEvents()
 
127
{
 
128
        ConnectButton(m_button2, OpenResourceDlg::OnButtonCancel);
 
129
        ConnectButton(m_btnOk, OpenResourceDlg::OnButtonOK);
 
130
        m_listShortNames->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(OpenResourceDlg::OnItemSelected), NULL, this);
 
131
        m_listShortNames->Connect(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler(OpenResourceDlg::OnItemActivated), NULL, this);
 
132
        Connect(m_timer->GetId(), wxEVT_TIMER, wxTimerEventHandler(OpenResourceDlg::OnTimer), NULL, this);
 
133
}
 
134
 
 
135
void OpenResourceDlg::OnTimer(wxTimerEvent &event)
 
136
{
 
137
        wxUnusedVar(event);
 
138
        wxArrayString tmpArr;
 
139
        wxString curSel = m_textResourceName->GetValue();
 
140
        if (!curSel.Trim().Trim(false).IsEmpty()) {
 
141
 
 
142
                curSel = curSel.MakeLower().Trim().Trim(false);
 
143
 
 
144
                for (size_t i=0; i<m_files.size(); i++) {
 
145
                        wxString fileName(m_files.at(i).GetFullName());
 
146
                        fileName= fileName.MakeLower();
 
147
 
 
148
                        //append wildcard at the end
 
149
                        if (!curSel.EndsWith(wxT("*"))) {
 
150
                                curSel << wxT("*");
 
151
                        }
 
152
 
 
153
                        // FR# [2008133]
 
154
                        if (m_checkBoxPartialMatching->IsChecked() && !curSel.StartsWith(wxT("*"))) {
 
155
                                curSel.Prepend(wxT("*"));
 
156
                        }
 
157
 
 
158
                        if (wxMatchWild(curSel, fileName)) {
 
159
                                tmpArr.Add(m_files[i].GetFullPath());
 
160
                        }
 
161
                }
 
162
        }
 
163
 
 
164
        // actValues represents the list of files as they appear in the ListBox
 
165
        // we need to loop over the list box, since the actual full file names
 
166
        // are stored as ClientObject
 
167
        wxArrayString actValues;
 
168
        for (unsigned int i=0; i<m_listShortNames->GetCount(); i++) {
 
169
                wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(i);
 
170
                actValues.Add(data->GetData());
 
171
        }
 
172
        // we need to sort the array
 
173
        actValues.Sort();
 
174
 
 
175
        // tmpArr contains the list of files (full paths) after filtering the typed pattern
 
176
        tmpArr.Sort();
 
177
 
 
178
        if (tmpArr == actValues)
 
179
                return;
 
180
 
 
181
        //change was done, update the file list
 
182
        Freeze();
 
183
        m_listShortNames->Clear();
 
184
        for (size_t i=0; i<tmpArr.GetCount(); i++) {
 
185
                wxFileName fn(tmpArr.Item(i));
 
186
                m_listShortNames->Append(fn.GetFullName(), new wxStringClientData(tmpArr.Item(i)));
 
187
        }
 
188
        Thaw();
 
189
        if (m_listShortNames->GetCount() > 0) {
 
190
                m_listShortNames->Select(0);
 
191
                // display the full name at the bottom static text control
 
192
                wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
 
193
                m_fullText->SetLabel(data->GetData());
 
194
        }
 
195
}
 
196
 
 
197
void OpenResourceDlg::OnButtonCancel(wxCommandEvent &event)
 
198
{
 
199
        wxUnusedVar(event);
 
200
        EndModal(wxID_CANCEL);
 
201
}
 
202
 
 
203
void OpenResourceDlg::OnButtonOK(wxCommandEvent &event)
 
204
{
 
205
        wxUnusedVar(event);
 
206
        if (UpdateFileName()) {
 
207
                EndModal(wxID_OK);
 
208
        }
 
209
}
 
210
 
 
211
void OpenResourceDlg::OnItemSelected(wxCommandEvent &event)
 
212
{
 
213
        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(event.GetSelection());
 
214
        if(data) {
 
215
        m_fullText->SetLabel(data->GetData());
 
216
        UpdateFileName();
 
217
        }
 
218
}
 
219
 
 
220
void OpenResourceDlg::OnItemActivated(wxCommandEvent &event)
 
221
{
 
222
        wxUnusedVar(event);
 
223
 
 
224
        if (UpdateFileName()) {
 
225
                EndModal(wxID_OK);
 
226
        }
 
227
}
 
228
 
 
229
bool OpenResourceDlg::UpdateFileName()
 
230
{
 
231
        int idx = m_listShortNames->GetSelection();
 
232
        if (idx == wxNOT_FOUND) {
 
233
                return false;
 
234
        }
 
235
 
 
236
        m_fileName = m_fullText->GetLabelText();
 
237
 
 
238
        // save the checkbox value into the settings
 
239
        EditorConfigST::Get()->SaveLongValue(wxT("OpenResourceAllowsPartialMatch"), m_checkBoxPartialMatching->IsChecked() ? 1 : 0);
 
240
 
 
241
        return true;
 
242
}
 
243
 
 
244
void OpenResourceDlg::OnCharHook(wxKeyEvent &event)
 
245
{
 
246
        if (event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) {
 
247
                if (m_listShortNames->GetSelection() != wxNOT_FOUND) {
 
248
                        if (UpdateFileName()) {
 
249
                                EndModal(wxID_OK);
 
250
                                return;
 
251
                        }
 
252
                } else if (m_listShortNames->GetCount() == 1) {
 
253
                        m_listShortNames->SetSelection(0);
 
254
                        if (UpdateFileName()) {
 
255
                                EndModal(wxID_OK);
 
256
                                return;
 
257
                        }
 
258
                }
 
259
        } else if (event.GetKeyCode() == WXK_DOWN && m_listShortNames->GetCount() > 0) {
 
260
                //up key
 
261
                int cursel = m_listShortNames->GetSelection();
 
262
                if (cursel != wxNOT_FOUND) {
 
263
                        //there is a selection in the listbox
 
264
                        cursel++;
 
265
                        if (cursel >= (int)m_listShortNames->GetCount()) {
 
266
                                //already at last item, cant scroll anymore
 
267
                                return;
 
268
                        }
 
269
                        m_listShortNames->SetSelection(cursel);
 
270
                        m_listShortNames->Select(cursel);
 
271
                        m_listShortNames->SetFirstItem(cursel);
 
272
 
 
273
                        // display the full name at the bottom static text control
 
274
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(cursel);
 
275
                        m_fullText->SetLabel(data->GetData());
 
276
 
 
277
                } else {
 
278
                        //no selection is made
 
279
                        m_listShortNames->SetSelection(0);
 
280
                        m_listShortNames->Select(0);
 
281
 
 
282
                        // display the full name at the bottom static text control
 
283
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
 
284
                        m_fullText->SetLabel(data->GetData());
 
285
 
 
286
                        m_listShortNames->SetFirstItem(0);
 
287
                }
 
288
                return;
 
289
        } else if (event.GetKeyCode() == WXK_UP && m_listShortNames->GetCount() > 0) {
 
290
                //up key
 
291
                int cursel = m_listShortNames->GetSelection();
 
292
                if (cursel != wxNOT_FOUND) {
 
293
                        //there is a selection in the listbox
 
294
                        cursel--;
 
295
                        if (cursel < 0) {
 
296
                                //already at first item, cant scroll anymore
 
297
                                return;
 
298
                        }
 
299
                        m_listShortNames->SetSelection(cursel);
 
300
                        m_listShortNames->SetFirstItem(cursel);
 
301
 
 
302
                        // display the full name at the bottom static text control
 
303
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(cursel);
 
304
                        m_fullText->SetLabel(data->GetData());
 
305
                } else {
 
306
                        //no selection is made
 
307
                        m_listShortNames->SetSelection(0);
 
308
                        m_listShortNames->SetFirstItem(0);
 
309
 
 
310
                        // display the full name at the bottom static text control
 
311
                        wxStringClientData *data = (wxStringClientData *)m_listShortNames->GetClientObject(0);
 
312
                        m_fullText->SetLabel(data->GetData());
 
313
                }
 
314
                return;
 
315
        }
 
316
        event.Skip();
 
317
}