Code::Blocks  SVN r11506
editarrayorderdlg.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 10912 $
6  * $Id: editarrayorderdlg.cpp 10912 2016-09-25 16:10:13Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/editarrayorderdlg.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13  #include <wx/xrc/xmlres.h>
14  #include <wx/intl.h>
15  #include <wx/button.h>
16  #include <wx/listbox.h>
17 #endif
18 
19 #include "editarrayorderdlg.h" // class's header file
20 
21 BEGIN_EVENT_TABLE(EditArrayOrderDlg, wxScrollingDialog)
22  EVT_UPDATE_UI( -1, EditArrayOrderDlg::OnUpdateUI)
23  EVT_BUTTON(XRCID("btnMoveUp"), EditArrayOrderDlg::OnMoveUp)
24  EVT_BUTTON(XRCID("btnMoveDown"), EditArrayOrderDlg::OnMoveDown)
25 END_EVENT_TABLE()
26 
27 // class constructor
29  : m_Array(array)
30 {
31  wxXmlResource::Get()->LoadObject(this, parent, _T("dlgEditArrayOrder"),_T("wxScrollingDialog"));
32  XRCCTRL(*this, "wxID_OK", wxButton)->SetDefault();
33  DoFillList();
34 }
35 
36 // class destructor
38 {
39 }
40 
42 {
43  wxListBox* list = XRCCTRL(*this, "lstItems", wxListBox);
44  list->Clear();
45  for (unsigned int i = 0; i < m_Array.GetCount(); ++i)
46  list->Append(m_Array[i]);
47 }
48 
50 {
51  wxListBox* list = XRCCTRL(*this, "lstItems", wxListBox);
52 
53  XRCCTRL(*this, "btnMoveUp", wxButton)->Enable(list->GetSelection() > 0);
54  XRCCTRL(*this, "btnMoveDown", wxButton)->Enable(list->GetSelection() >= 0 && list->GetSelection() < (int)list->GetCount() - 1);
55 }
56 
58 {
59  wxListBox* list = XRCCTRL(*this, "lstItems", wxListBox);
60  int sel = list->GetSelection();
61 
62  if (sel > 0)
63  {
64  wxString tmp = list->GetString(sel);
65  list->Delete(sel);
66  list->InsertItems(1, &tmp, sel - 1);
67  list->SetSelection(sel - 1);
68  }
69 }
70 
72 {
73  wxListBox* list = XRCCTRL(*this, "lstItems", wxListBox);
74  int sel = list->GetSelection();
75 
76  if (sel < (int)list->GetCount() - 1)
77  {
78  wxString tmp = list->GetString(sel);
79  list->Delete(sel);
80  list->InsertItems(1, &tmp, sel + 1);
81  list->SetSelection(sel + 1);
82  }
83 }
84 
85 void EditArrayOrderDlg::EndModal(int retCode)
86 {
87  if (retCode == wxID_OK)
88  {
89  wxListBox* list = XRCCTRL(*this, "lstItems", wxListBox);
90 
91  m_Array.Clear();
92  for (int i = 0; i < (int)list->GetCount(); ++i)
93  m_Array.Add(list->GetString(i));
94  }
95 
97 }
98 
void EndModal(int retCode)
Definition: sc_dialog.cpp:112
void OnUpdateUI(wxUpdateUIEvent &event)
#define _T(string)
wxArrayString m_Array
void EndModal(int retCode) override
~EditArrayOrderDlg() override
void OnMoveDown(wxCommandEvent &event)
size_t Add(const wxString &str, size_t copies=1)
size_t GetCount() const
void OnMoveUp(wxCommandEvent &event)
static wxXmlResource * Get()
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)