Code::Blocks  SVN r11506
sc_util_dialogs.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: 9426 $
6  * $Id: sc_util_dialogs.cpp 9426 2013-11-02 19:42:20Z alpha0010 $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/scripting/bindings/sc_util_dialogs.cpp $
8  */
9 
10 #include <sdk_precomp.h>
11 
12 #ifndef CB_PRECOMP
13  #include <globals.h>
14  #include <cbexception.h>
15  #include <wx/string.h>
16 #endif
17 
18 #include "sc_base_types.h"
19 
20 #include <editarrayfiledlg.h>
21 #include <editarrayorderdlg.h>
22 #include <editarraystringdlg.h>
23 #include <editpairdlg.h>
24 #include <editpathdlg.h>
26 
28 
29 namespace ScriptBindings
30 {
31  SQInteger EditArrayFileDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
32  {
33  SQ_DELETE_CLASS(EditArrayFileDlg);
34  }
35 
36  SQInteger EditArrayFileDlg_Ctor(HSQUIRRELVM v)
37  {
38  // (wxWindow* parent,
39  // wxArrayString& array,
40  // bool useRelativePaths = false,
41  // const wxString& basePath = _T(""))
42  StackHandler sa(v);
43  EditArrayFileDlg* dlg = nullptr;
44 
45  if (sa.GetParamCount() > 3)
46  {
47  dlg = new EditArrayFileDlg(nullptr,
48  *SqPlus::GetInstance<wxArrayString,false>(v, 2),
49  sa.GetBool(3),
50  *SqPlus::GetInstance<wxString,false>(v, 4));
51  }
52  else if (sa.GetParamCount() > 2)
53  {
54  dlg = new EditArrayFileDlg(nullptr,
55  *SqPlus::GetInstance<wxArrayString,false>(v, 2),
56  sa.GetBool(3));
57  }
58  else if (sa.GetParamCount() > 1)
59  {
60  dlg = new EditArrayFileDlg(nullptr,
61  *SqPlus::GetInstance<wxArrayString,false>(v, 2));
62  }
63  else
64  return sa.ThrowError("EditArrayFileDlg needs at least one argument");
65 
66  return SqPlus::PostConstruct<EditArrayFileDlg>(v, dlg, EditArrayFileDlg_Dtor);
67  }
68 
69  SQInteger EditArrayOrderDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
70  {
71  SQ_DELETE_CLASS(EditArrayOrderDlg);
72  }
73 
74  SQInteger EditArrayOrderDlg_Ctor(HSQUIRRELVM v)
75  {
76  // (wxWindow* parent, const wxArrayString& array = 0L)
77  StackHandler sa(v);
78  EditArrayOrderDlg* dlg = nullptr;
79 
80  if (sa.GetParamCount() == 1)
81  dlg = new EditArrayOrderDlg(nullptr, wxArrayString());
82  else if (sa.GetParamCount() == 2)
83  dlg = new EditArrayOrderDlg(nullptr, *SqPlus::GetInstance<wxArrayString,false>(v, 2));
84  else
85  return sa.ThrowError("EditArrayOrderDlg needs at most one argument");
86 
87  return SqPlus::PostConstruct<EditArrayOrderDlg>(v, dlg, EditArrayOrderDlg_Dtor);
88  }
89 
90  SQInteger EditArrayStringDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
91  {
92  SQ_DELETE_CLASS(EditArrayStringDlg);
93  }
94 
95  SQInteger EditArrayStringDlg_Ctor(HSQUIRRELVM v)
96  {
97  // (wxWindow* parent, const wxArrayString& array)
98  StackHandler sa(v);
99  EditArrayStringDlg* dlg = nullptr;
100 
101  if (sa.GetParamCount() == 2)
102  dlg = new EditArrayStringDlg(nullptr, *SqPlus::GetInstance<wxArrayString,false>(v, 2));
103  else
104  return sa.ThrowError("EditArrayStringDlg needs one argument");
105 
106  return SqPlus::PostConstruct<EditArrayStringDlg>(v, dlg, EditArrayStringDlg_Dtor);
107  }
108 
109  SQInteger EditPairDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
110  {
111  SQ_DELETE_CLASS(EditPairDlg);
112  }
113 
114  SQInteger EditPairDlg_Ctor(HSQUIRRELVM v)
115  {
116  // (wxWindow* parent,
117  // wxString& key,
118  // wxString& value,
119  // const wxString& title = _("Edit pair"),
120  // BrowseMode allowBrowse = bmDisable);
121  StackHandler sa(v);
122  EditPairDlg* dlg = nullptr;
123 
124  if (sa.GetParamCount() > 4)
125  {
126  dlg = new EditPairDlg(nullptr,
127  *SqPlus::GetInstance<wxString,false>(v, 2),
128  *SqPlus::GetInstance<wxString,false>(v, 3),
129  *SqPlus::GetInstance<wxString,false>(v, 4),
130  (EditPairDlg::BrowseMode)sa.GetInt(5));
131  }
132  else if (sa.GetParamCount() > 3)
133  {
134  dlg = new EditPairDlg(nullptr,
135  *SqPlus::GetInstance<wxString,false>(v, 2),
136  *SqPlus::GetInstance<wxString,false>(v, 3),
137  *SqPlus::GetInstance<wxString,false>(v, 4));
138  }
139  else if (sa.GetParamCount() > 2)
140  {
141  dlg = new EditPairDlg(nullptr,
142  *SqPlus::GetInstance<wxString,false>(v, 2),
143  *SqPlus::GetInstance<wxString,false>(v, 3));
144  }
145  else
146  return sa.ThrowError("EditPairDlg needs at least two arguments");
147 
148  return SqPlus::PostConstruct<EditPairDlg>(v, dlg, EditPairDlg_Dtor);
149  }
150 
151  SQInteger EditPathDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
152  {
153  SQ_DELETE_CLASS(EditPathDlg);
154  }
155 
156  SQInteger EditPathDlg_Ctor(HSQUIRRELVM v)
157  {
158  // (wxWindow* parent,
159  // const wxString& path, // initial path
160  // const wxString& basepath, // for relative pathes
161  // const wxString& title = _("Edit Path"), // title of the dialog
162  // const wxString& message = _T(""), // message displayed in the dialogs
163  // const bool wantDir = true, // whether to open a dir or a file dialog
164  // const bool allowMultiSel = false, // whether to allow for multiple files selection
165  // const wxString& filter = _("All files(*)|*")); // wildcard for files
166  StackHandler sa(v);
167  EditPathDlg* dlg = nullptr;
168 
169  if (sa.GetParamCount() > 7)
170  {
171  dlg = new EditPathDlg(nullptr,
172  *SqPlus::GetInstance<wxString,false>(v, 2),
173  *SqPlus::GetInstance<wxString,false>(v, 3),
174  *SqPlus::GetInstance<wxString,false>(v, 4),
175  *SqPlus::GetInstance<wxString,false>(v, 5),
176  sa.GetBool(6),
177  sa.GetBool(7),
178  *SqPlus::GetInstance<wxString,false>(v, 8));
179  }
180  else if (sa.GetParamCount() > 6)
181  {
182  dlg = new EditPathDlg(nullptr,
183  *SqPlus::GetInstance<wxString,false>(v, 2),
184  *SqPlus::GetInstance<wxString,false>(v, 3),
185  *SqPlus::GetInstance<wxString,false>(v, 4),
186  *SqPlus::GetInstance<wxString,false>(v, 5),
187  sa.GetBool(6),
188  sa.GetBool(7));
189  }
190  else if (sa.GetParamCount() > 5)
191  {
192  dlg = new EditPathDlg(nullptr,
193  *SqPlus::GetInstance<wxString,false>(v, 2),
194  *SqPlus::GetInstance<wxString,false>(v, 3),
195  *SqPlus::GetInstance<wxString,false>(v, 4),
196  *SqPlus::GetInstance<wxString,false>(v, 5),
197  sa.GetBool(6));
198  }
199  else if (sa.GetParamCount() > 4)
200  {
201  dlg = new EditPathDlg(nullptr,
202  *SqPlus::GetInstance<wxString,false>(v, 2),
203  *SqPlus::GetInstance<wxString,false>(v, 3),
204  *SqPlus::GetInstance<wxString,false>(v, 4),
205  *SqPlus::GetInstance<wxString,false>(v, 5));
206  }
207  else if (sa.GetParamCount() > 3)
208  {
209  dlg = new EditPathDlg(nullptr,
210  *SqPlus::GetInstance<wxString,false>(v, 2),
211  *SqPlus::GetInstance<wxString,false>(v, 3),
212  *SqPlus::GetInstance<wxString,false>(v, 4));
213  }
214  else if (sa.GetParamCount() > 2)
215  {
216  dlg = new EditPathDlg(nullptr,
217  *SqPlus::GetInstance<wxString,false>(v, 2),
218  *SqPlus::GetInstance<wxString,false>(v, 3));
219  }
220  else
221  return sa.ThrowError("EditPathDlg needs at least two arguments");
222 
223  return SqPlus::PostConstruct<EditPathDlg>(v, dlg, EditPathDlg_Dtor);
224  }
225 
226  SQInteger GenericMultiLineNotesDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
227  {
228  SQ_DELETE_CLASS(GenericMultiLineNotesDlg);
229  }
230 
231  SQInteger GenericMultiLineNotesDlg_Ctor(HSQUIRRELVM v)
232  {
233  // (wxWindow* parent,
234  // const wxString& caption = _("Notes"),
235  // const wxString& notes = wxEmptyString,
236  // bool readOnly = true);
237  StackHandler sa(v);
238  GenericMultiLineNotesDlg* dlg = nullptr;
239 
240  if (sa.GetParamCount() > 3)
241  {
242  dlg = new GenericMultiLineNotesDlg(nullptr,
243  *SqPlus::GetInstance<wxString,false>(v, 2),
244  *SqPlus::GetInstance<wxString,false>(v, 3),
245  sa.GetBool(4));
246  }
247  else if (sa.GetParamCount() > 2)
248  {
249  dlg = new GenericMultiLineNotesDlg(nullptr,
250  *SqPlus::GetInstance<wxString,false>(v, 2),
251  *SqPlus::GetInstance<wxString,false>(v, 3));
252  }
253  else if (sa.GetParamCount() > 1)
254  {
255  dlg = new GenericMultiLineNotesDlg(nullptr,
256  *SqPlus::GetInstance<wxString,false>(v, 2));
257  }
258  else
259  dlg = new GenericMultiLineNotesDlg(nullptr);
260 
261  return SqPlus::PostConstruct<GenericMultiLineNotesDlg>(v, dlg, GenericMultiLineNotesDlg_Dtor);
262  }
263 
264  SQInteger ShowModalForDialogs(HSQUIRRELVM v)
265  {
266  StackHandler sa(v);
267  SQUserPointer up = nullptr;
268  sq_getinstanceup(v, 1, &up, nullptr);
270  return sa.Return(static_cast<SQInteger>(dlg->ShowModal()));
271  }
272 
274  {
275  SqPlus::BindConstant<SQInteger>(EditPairDlg::bmBrowseForDirectory, "bmBrowseForDirectory");
276  SqPlus::BindConstant<SQInteger>(EditPairDlg::bmBrowseForFile, "bmBrowseForFile");
277  SqPlus::BindConstant<SQInteger>(EditPairDlg::bmDisable, "bmDisable");
278 
279  SqPlus::SQClassDef<EditArrayFileDlg>("EditArrayFileDlg").
280  staticFuncVarArgs(&EditArrayFileDlg_Ctor, "constructor", "*").
281  staticFunc(&ShowModalForDialogs, "ShowModal");
282 
283  SqPlus::SQClassDef<EditArrayOrderDlg>("EditArrayOrderDlg").
284  staticFuncVarArgs(&EditArrayOrderDlg_Ctor, "constructor", "*").
285  staticFunc(&ShowModalForDialogs, "ShowModal").
286  func(&EditArrayOrderDlg::SetArray, "SetArray").
287  func(&EditArrayOrderDlg::GetArray, "GetArray");
288 
289  SqPlus::SQClassDef<EditArrayStringDlg>("EditArrayStringDlg").
290  staticFuncVarArgs(&EditArrayStringDlg_Ctor, "constructor", "*").
291  staticFunc(&ShowModalForDialogs, "ShowModal");
292 
293  SqPlus::SQClassDef<EditPairDlg>("EditPairDlg").
294  staticFuncVarArgs(&EditPairDlg_Ctor, "constructor", "*").
295  staticFunc(&ShowModalForDialogs, "ShowModal");
296 
297  SqPlus::SQClassDef<EditPathDlg>("EditPathDlg").
298  staticFuncVarArgs(&EditPathDlg_Ctor, "constructor", "*").
299  staticFunc(&ShowModalForDialogs, "ShowModal").
300  func(&EditPathDlg::GetPath, "GetPath");
301 
302  SqPlus::SQClassDef<GenericMultiLineNotesDlg>("GenericMultiLineNotesDlg").
303  staticFuncVarArgs(&GenericMultiLineNotesDlg_Ctor, "constructor", "*").
304  staticFunc(&ShowModalForDialogs, "ShowModal").
305  func(&GenericMultiLineNotesDlg::GetNotes, "GetNotes");
306  }
307 } // namespace ScriptBindings
SQInteger EditPathDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
DECLARE_ENUM_TYPE(EditPairDlg::BrowseMode)
SQInteger EditPathDlg_Ctor(HSQUIRRELVM v)
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p, SQUserPointer typetag)
Definition: sqapi.cpp:647
SQInteger EditPairDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
void SetArray(const wxArrayString &array)
SQInteger EditArrayFileDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
const wxArrayString & GetArray()
SQInteger EditArrayOrderDlg_Ctor(HSQUIRRELVM v)
SQInteger GenericMultiLineNotesDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
SQInteger EditArrayOrderDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
const wxString & GetPath()
Definition: editpathdlg.h:27
virtual int ShowModal()
SQInteger EditPairDlg_Ctor(HSQUIRRELVM v)
SQInteger EditArrayStringDlg_Dtor(SQUserPointer up, cb_unused SQInteger size)
SQInteger GenericMultiLineNotesDlg_Ctor(HSQUIRRELVM v)
SQInteger EditArrayFileDlg_Ctor(HSQUIRRELVM v)
SQInteger ShowModalForDialogs(HSQUIRRELVM v)
SQInteger EditArrayStringDlg_Ctor(HSQUIRRELVM v)