diff options
Diffstat (limited to 'rbutil/rbutilCtrls.cpp')
-rw-r--r-- | rbutil/rbutilCtrls.cpp | 628 |
1 files changed, 0 insertions, 628 deletions
diff --git a/rbutil/rbutilCtrls.cpp b/rbutil/rbutilCtrls.cpp deleted file mode 100644 index fdede634d3..0000000000 --- a/rbutil/rbutilCtrls.cpp +++ /dev/null | |||
@@ -1,628 +0,0 @@ | |||
1 | |||
2 | #include "rbutilCtrls.h" | ||
3 | #include "bootloaders.h" | ||
4 | #include "autodetection.h" | ||
5 | |||
6 | ///////////////////////////////////////////////////////////// | ||
7 | //// Controls | ||
8 | //////////////////////////////////////////////////////////////// | ||
9 | |||
10 | ///////////////////////////////////////////// | ||
11 | //// Image Ctrl | ||
12 | ////////////////////////////////////////////// | ||
13 | |||
14 | BEGIN_EVENT_TABLE(ImageCtrl, wxControl) | ||
15 | EVT_PAINT(ImageCtrl::OnPaint) | ||
16 | END_EVENT_TABLE() | ||
17 | |||
18 | IMPLEMENT_DYNAMIC_CLASS(ImageCtrl, wxControl) | ||
19 | |||
20 | bool ImageCtrl::Create(wxWindow* parent, wxWindowID id, | ||
21 | const wxPoint& pos, const wxSize& size, long style, | ||
22 | const wxValidator& validator) | ||
23 | { | ||
24 | if (!wxControl::Create(parent, id, pos, size, style, validator)) return false; | ||
25 | |||
26 | return true; | ||
27 | } | ||
28 | |||
29 | void ImageCtrl::OnPaint(wxPaintEvent& event) | ||
30 | { | ||
31 | wxPaintDC dc(this); | ||
32 | dc.DrawBitmap(m_bitmap,0,0,false); | ||
33 | } | ||
34 | |||
35 | void ImageCtrl::SetBitmap(wxBitmap bmp) | ||
36 | { | ||
37 | m_bitmap = bmp; | ||
38 | Refresh(); | ||
39 | |||
40 | } | ||
41 | |||
42 | wxSize ImageCtrl::DoGetBestSize() const | ||
43 | { | ||
44 | wxSize bestsize; | ||
45 | bestsize.x = m_bitmap.GetWidth(); | ||
46 | bestsize.y = m_bitmap.GetHeight(); | ||
47 | return bestsize; | ||
48 | } | ||
49 | |||
50 | |||
51 | |||
52 | ///////////////////////////////////////////// | ||
53 | //// Theme Control | ||
54 | ////////////////////////////////////////////// | ||
55 | |||
56 | BEGIN_EVENT_TABLE(ThemeCtrl, wxPanel) | ||
57 | EVT_LISTBOX(ID_THEME_LST, ThemeCtrl::OnThemesLst) | ||
58 | EVT_BUTTON(ID_THEME_SELECT_ALL, ThemeCtrl::OnSelectAll) | ||
59 | END_EVENT_TABLE() | ||
60 | |||
61 | IMPLEMENT_DYNAMIC_CLASS(ThemeCtrl, wxPanel) | ||
62 | |||
63 | bool ThemeCtrl::Create(wxWindow* parent, wxWindowID id, | ||
64 | const wxPoint& pos, const wxSize& size, long style, | ||
65 | const wxString title ) | ||
66 | { | ||
67 | if (!wxPanel::Create(parent, id, pos, size, style, title)) return false; | ||
68 | |||
69 | CreateControls(); | ||
70 | |||
71 | GetSizer()->Fit(this); | ||
72 | |||
73 | GetSizer()->SetSizeHints(this); | ||
74 | return true; | ||
75 | } | ||
76 | |||
77 | void ThemeCtrl::CreateControls() | ||
78 | { | ||
79 | // A top-level sizer | ||
80 | wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); | ||
81 | this->SetSizer(topSizer); | ||
82 | |||
83 | wxBoxSizer* horizontalSizer = new wxBoxSizer(wxHORIZONTAL); | ||
84 | topSizer->Add(horizontalSizer, 0, wxALIGN_LEFT|wxALL, 5); | ||
85 | |||
86 | //Device Selection | ||
87 | wxBoxSizer* wxBoxSizer7 = new wxBoxSizer(wxVERTICAL); | ||
88 | horizontalSizer->Add(wxBoxSizer7,0,wxGROW | wxALL,0); | ||
89 | |||
90 | wxStaticText* m_desc = new wxStaticText( this, wxID_STATIC, | ||
91 | wxT("Select one or more Themes to install"), wxDefaultPosition, | ||
92 | wxDefaultSize, 0 ); | ||
93 | wxBoxSizer7->Add(m_desc, 0, wxALIGN_LEFT|wxALL, 5); | ||
94 | |||
95 | m_themeList = new wxListBox(this,ID_THEME_LST,wxDefaultPosition, | ||
96 | wxDefaultSize,0,NULL,wxLB_EXTENDED); | ||
97 | wxBoxSizer7->Add(m_themeList, 0, wxALIGN_LEFT|wxALL, 5); | ||
98 | |||
99 | m_selectAllThemes = new wxButton(this, ID_THEME_SELECT_ALL, | ||
100 | wxT("Select All")); | ||
101 | wxBoxSizer7->Add(m_selectAllThemes, 0, wxALIGN_LEFT|wxALL, 5); | ||
102 | |||
103 | // Preview Picture | ||
104 | wxBoxSizer* wxBoxSizer9 = new wxBoxSizer(wxVERTICAL); | ||
105 | horizontalSizer->Add(wxBoxSizer9,0,wxGROW | wxALL,0); | ||
106 | |||
107 | wxStaticText* preview_desc= new wxStaticText(this,wxID_ANY,wxT("Preview:")); | ||
108 | wxBoxSizer9->Add(preview_desc,0,wxGROW | wxALL,5); | ||
109 | |||
110 | m_PreviewBitmap = new ImageCtrl(this,ID_PREVIEW_BITMAP ); | ||
111 | wxBoxSizer9->Add(m_PreviewBitmap,0,wxALIGN_LEFT | wxALL,5); | ||
112 | |||
113 | wxStaticBox* groupbox= new wxStaticBox(this,wxID_ANY,wxT("Selected Theme:")); | ||
114 | wxStaticBoxSizer* styleSizer = new wxStaticBoxSizer( groupbox, wxVERTICAL ); | ||
115 | topSizer->Add(styleSizer,0,wxGROW|wxALL,0); | ||
116 | |||
117 | // horizontal sizer | ||
118 | wxBoxSizer* wxBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); | ||
119 | styleSizer->Add(wxBoxSizer8,0,wxGROW | wxALL,0); | ||
120 | |||
121 | // File size | ||
122 | wxStaticText* size_desc= new wxStaticText(this,wxID_ANY,wxT("Filesize:")); | ||
123 | wxBoxSizer8->Add(size_desc,0,wxGROW | wxALL,5); | ||
124 | |||
125 | m_size= new wxStaticText(this,ID_FILESIZE,wxT("")); | ||
126 | wxBoxSizer8->Add(m_size,0,wxGROW | wxALL,5); | ||
127 | |||
128 | // Description | ||
129 | wxStaticText* desc_desc= new wxStaticText(this,wxID_ANY,wxT("Description:")); | ||
130 | styleSizer->Add(desc_desc,0,wxGROW | wxALL,5); | ||
131 | |||
132 | m_themedesc= new wxTextCtrl(this,ID_DESC,wxT(""),wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY); | ||
133 | styleSizer->Add(m_themedesc,0,wxGROW | wxALL,5); | ||
134 | |||
135 | topSizer->Fit(this); | ||
136 | topSizer->SetSizeHints(this); | ||
137 | Layout(); | ||
138 | |||
139 | } | ||
140 | |||
141 | void ThemeCtrl::Init() | ||
142 | { | ||
143 | m_Themes.Clear(); | ||
144 | m_Themes_path.Clear(); | ||
145 | m_Themes_size.Clear(); | ||
146 | m_Themes_image.Clear(); | ||
147 | m_Themes_desc.Clear(); | ||
148 | |||
149 | } | ||
150 | |||
151 | void ThemeCtrl::setDevice(wxString device) | ||
152 | { | ||
153 | |||
154 | int index = gv->plat_id.Index(device); | ||
155 | if(index == -1) return; | ||
156 | |||
157 | if(gv->plat_resolution[index] == m_currentResolution) | ||
158 | return; | ||
159 | else | ||
160 | m_currentResolution = gv->plat_resolution[index]; | ||
161 | |||
162 | // load the themelist | ||
163 | Init(); | ||
164 | m_size->SetLabel(wxT("")); | ||
165 | m_themedesc->SetValue(wxT("")); | ||
166 | m_themeList->Clear(); | ||
167 | |||
168 | //get correct Themes list | ||
169 | wxString src,dest,err; | ||
170 | |||
171 | src = gv->themes_url + wxT("rbutil.php?res=") + m_currentResolution; | ||
172 | dest = gv->stdpaths->GetUserDataDir() + wxT("" PATH_SEP "download" PATH_SEP) | ||
173 | + m_currentResolution + wxT(".list"); | ||
174 | |||
175 | if(DownloadURL(src, dest)) | ||
176 | { | ||
177 | MESG_DIALOG(wxT("Unable to download themes list.")); | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | //read and parse Themes list | ||
182 | wxString themelistraw; | ||
183 | wxFFile themefile; | ||
184 | if(!themefile.Open(dest)) //open file | ||
185 | { | ||
186 | MESG_DIALOG(wxT("Unable to open themes list.")); | ||
187 | return; | ||
188 | } | ||
189 | if(!themefile.ReadAll(&themelistraw)) //read complete file | ||
190 | { | ||
191 | MESG_DIALOG(wxT("Unable to read themes list.")); | ||
192 | return; | ||
193 | } | ||
194 | wxRegEx reAll(wxT("<body >(.+)</body>")); //extract body part | ||
195 | if(! reAll.Matches(themelistraw)) | ||
196 | { | ||
197 | MESG_DIALOG(wxT("Themes list is in wrong Format.")); | ||
198 | return; | ||
199 | } | ||
200 | wxString lines = reAll.GetMatch(themelistraw,1); | ||
201 | |||
202 | // prepare text | ||
203 | lines.Replace(wxT("<br />"),wxT(""),true); //replace <br /> with nothing | ||
204 | lines.Replace(wxT("\n"),wxT(""),true); //replace \n with nothing | ||
205 | lines.Trim(true); //strip WS at end | ||
206 | lines.Trim(false); //strip WS at beginning | ||
207 | wxStringTokenizer tkz(lines,wxT("|")); //tokenize it | ||
208 | |||
209 | while ( tkz.HasMoreTokens() ) // read all entrys | ||
210 | { | ||
211 | m_Themes.Add(tkz.GetNextToken()); //Theme name | ||
212 | m_Themes_path.Add(tkz.GetNextToken()); //Theme path | ||
213 | m_Themes_size.Add(tkz.GetNextToken()); //File size | ||
214 | m_Themes_image.Add(tkz.GetNextToken()); //Screenshot | ||
215 | m_Themes_desc.Add(tkz.GetNextToken()); //Description | ||
216 | |||
217 | m_themeList->Append(m_Themes.Last()); | ||
218 | } | ||
219 | |||
220 | this->GetSizer()->Layout(); | ||
221 | this->GetSizer()->Fit(this); | ||
222 | this->GetSizer()->SetSizeHints(this); | ||
223 | m_parent->GetSizer()->Layout(); | ||
224 | m_parent->GetSizer()->Fit(m_parent); | ||
225 | m_parent->GetSizer()->SetSizeHints(m_parent); | ||
226 | } | ||
227 | |||
228 | |||
229 | void ThemeCtrl::OnThemesLst(wxCommandEvent& event) | ||
230 | { | ||
231 | ThemePreview(); | ||
232 | } | ||
233 | |||
234 | void ThemeCtrl::ThemePreview() | ||
235 | { | ||
236 | // wxCriticalSectionLocker locker(m_ThemeSelectSection); | ||
237 | |||
238 | wxArrayInt selected; | ||
239 | int numSelected = m_themeList->GetSelections(selected); | ||
240 | if(numSelected == 0) return; | ||
241 | |||
242 | int index = selected[0]; | ||
243 | |||
244 | m_size->SetLabel(m_Themes_size[index]); | ||
245 | m_themedesc->SetValue(m_Themes_desc[index]); | ||
246 | // m_themedesc->Wrap(200); // wrap desc | ||
247 | |||
248 | wxString src,dest; | ||
249 | |||
250 | int pos = m_Themes_image[index].Find('/',true); | ||
251 | wxString filename = m_Themes_image[index](pos+1,m_Themes_image[index].Length()); | ||
252 | |||
253 | dest = gv->stdpaths->GetUserDataDir() | ||
254 | + wxT("" PATH_SEP "download" PATH_SEP) | ||
255 | + m_currentResolution; | ||
256 | |||
257 | if(!wxDirExists(dest)) | ||
258 | wxMkdir(dest); | ||
259 | |||
260 | //this is a URL no PATH_SEP | ||
261 | src = gv->themes_url + wxT("/data/") + m_currentResolution + wxT("/") | ||
262 | + filename; | ||
263 | dest = gv->stdpaths->GetUserDataDir() + wxT("" PATH_SEP "download" PATH_SEP) | ||
264 | + m_currentResolution + wxT("" PATH_SEP) + filename; | ||
265 | |||
266 | if(!wxFileExists(dest)) | ||
267 | { | ||
268 | if(DownloadURL(src, dest)) | ||
269 | { | ||
270 | MESG_DIALOG(wxT("Unable to download image.")); | ||
271 | return; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | m_currentimage = dest; | ||
276 | wxBitmap bmp; | ||
277 | bmp.LoadFile(m_currentimage,wxBITMAP_TYPE_PNG); | ||
278 | m_PreviewBitmap->SetBitmap(bmp); | ||
279 | |||
280 | Refresh(); | ||
281 | this->GetSizer()->Layout(); | ||
282 | this->GetSizer()->Fit(this); | ||
283 | this->GetSizer()->SetSizeHints(this); | ||
284 | |||
285 | m_parent->GetSizer()->Layout(); | ||
286 | m_parent->GetSizer()->Fit(m_parent); | ||
287 | m_parent->GetSizer()->SetSizeHints(m_parent); | ||
288 | |||
289 | } | ||
290 | |||
291 | void ThemeCtrl::OnSelectAll(wxCommandEvent& event) | ||
292 | { | ||
293 | for(unsigned int i=0; i < m_themeList->GetCount(); i++) | ||
294 | m_themeList->Select(i); | ||
295 | ThemePreview(); | ||
296 | } | ||
297 | |||
298 | wxArrayString ThemeCtrl::getThemesToInstall() | ||
299 | { | ||
300 | wxArrayString themes; | ||
301 | wxArrayInt selected; | ||
302 | int numSelected = m_themeList->GetSelections(selected); | ||
303 | |||
304 | for(int i=0; i < numSelected; i++) | ||
305 | { | ||
306 | themes.Add(m_Themes_path[selected[i]]); | ||
307 | } | ||
308 | return themes; | ||
309 | |||
310 | } | ||
311 | |||
312 | ///////////////////////////////////////////// | ||
313 | //// Ok Cancel Control | ||
314 | ////////////////////////////////////////////// | ||
315 | |||
316 | BEGIN_EVENT_TABLE(OkCancelCtrl, wxPanel) | ||
317 | |||
318 | END_EVENT_TABLE() | ||
319 | |||
320 | IMPLEMENT_DYNAMIC_CLASS(OkCancelCtrl, wxPanel) | ||
321 | |||
322 | bool OkCancelCtrl::Create(wxWindow* parent, wxWindowID id, | ||
323 | const wxPoint& pos, const wxSize& size, long style, | ||
324 | const wxString title) | ||
325 | { | ||
326 | if (!wxPanel::Create(parent, id, pos, size, style, title)) return false; | ||
327 | |||
328 | CreateControls(); | ||
329 | GetSizer()->Fit(this); | ||
330 | GetSizer()->SetSizeHints(this); | ||
331 | return true; | ||
332 | } | ||
333 | |||
334 | void OkCancelCtrl::CreateControls() | ||
335 | { | ||
336 | // A top-level sizer | ||
337 | wxBoxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL); | ||
338 | this->SetSizer(topSizer); | ||
339 | |||
340 | // The OK button | ||
341 | m_OkBtn = new wxButton ( this, wxID_OK, wxT("&OK"), | ||
342 | wxDefaultPosition, wxDefaultSize, 0 ); | ||
343 | topSizer->Add(m_OkBtn, 0, wxALL, 5); | ||
344 | // The Cancel button | ||
345 | m_CancelBtn = new wxButton ( this, wxID_CANCEL, | ||
346 | wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); | ||
347 | topSizer->Add(m_CancelBtn, 0, wxALL, 5); | ||
348 | |||
349 | Layout(); | ||
350 | |||
351 | } | ||
352 | |||
353 | |||
354 | ///////////////////////////////////////////// | ||
355 | //// Device Selector | ||
356 | ////////////////////////////////////////////// | ||
357 | |||
358 | BEGIN_EVENT_TABLE(DeviceSelectorCtrl, wxPanel) | ||
359 | EVT_BUTTON(ID_AUTODETECT_BTN, DeviceSelectorCtrl::OnAutoDetect) | ||
360 | EVT_COMBOBOX(ID_DEVICE_CBX,DeviceSelectorCtrl::OnComboBox) | ||
361 | END_EVENT_TABLE() | ||
362 | |||
363 | IMPLEMENT_DYNAMIC_CLASS(DeviceSelectorCtrl, wxPanel) | ||
364 | |||
365 | bool DeviceSelectorCtrl::Create(wxWindow* parent, wxWindowID id, | ||
366 | const wxPoint& pos, const wxSize& size, long style, | ||
367 | const wxString title) | ||
368 | { | ||
369 | if (!wxPanel::Create(parent, id, pos, size, style, title)) return false; | ||
370 | |||
371 | CreateControls(); | ||
372 | GetSizer()->Fit(this); | ||
373 | GetSizer()->SetSizeHints(this); | ||
374 | return true; | ||
375 | } | ||
376 | |||
377 | void DeviceSelectorCtrl::CreateControls() | ||
378 | { | ||
379 | // A top-level sizer | ||
380 | wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); | ||
381 | this->SetSizer(topSizer); | ||
382 | |||
383 | //Device Selection | ||
384 | wxBoxSizer* horizontalSizer = new wxBoxSizer(wxHORIZONTAL); | ||
385 | topSizer->Add(horizontalSizer, 0, wxALIGN_LEFT|wxALL, 5); | ||
386 | m_desc = new wxStaticText( this, wxID_STATIC, | ||
387 | wxT("Device:"), wxDefaultPosition, | ||
388 | wxDefaultSize, 0 ); | ||
389 | horizontalSizer->Add(m_desc, 0, wxALIGN_LEFT|wxALL, 5); | ||
390 | |||
391 | m_deviceCbx = new wxComboBox(this, ID_DEVICE_CBX,wxT("Select your Device"), | ||
392 | wxDefaultPosition,wxDefaultSize,gv->plat_name,wxCB_READONLY); | ||
393 | |||
394 | m_deviceCbx->SetToolTip(wxT("Select your Device.")); | ||
395 | m_deviceCbx->SetHelpText(wxT("Select your Device.")); | ||
396 | |||
397 | horizontalSizer->Add(m_deviceCbx, 0, wxALIGN_LEFT|wxALL, 5); | ||
398 | |||
399 | wxButton* m_autodetectBtn = new wxButton(this, ID_AUTODETECT_BTN, wxT("Autodetect"), | ||
400 | wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, | ||
401 | wxT("AutodetectBtn")); | ||
402 | |||
403 | m_autodetectBtn->SetToolTip(wxT("Click here to autodetect your Device.")); | ||
404 | m_autodetectBtn->SetHelpText(wxT("Autodetection of the Device.")); | ||
405 | // m_autodetectBtn->SetFocus(); | ||
406 | |||
407 | horizontalSizer->Add(m_autodetectBtn,0,wxGROW | wxALL,5); | ||
408 | Layout(); | ||
409 | |||
410 | } | ||
411 | |||
412 | wxString DeviceSelectorCtrl::getDevice() | ||
413 | { | ||
414 | return m_currentDevice; | ||
415 | } | ||
416 | |||
417 | void DeviceSelectorCtrl::setDefault() | ||
418 | { | ||
419 | int index = gv->plat_id.Index(gv->curplat); | ||
420 | if(index == -1) return; | ||
421 | m_deviceCbx->SetValue(gv->plat_name[index]); | ||
422 | } | ||
423 | |||
424 | void DeviceSelectorCtrl::OnComboBox(wxCommandEvent& event) | ||
425 | { | ||
426 | int index = gv->plat_name.Index(m_deviceCbx->GetValue()); | ||
427 | |||
428 | if(index == -1) | ||
429 | { | ||
430 | m_currentDevice = wxT(""); | ||
431 | return; | ||
432 | } | ||
433 | |||
434 | gv->curplat = gv->plat_id[index]; | ||
435 | } | ||
436 | |||
437 | void DeviceSelectorCtrl::OnAutoDetect(wxCommandEvent& event) | ||
438 | { | ||
439 | if(!AutoDetect()) | ||
440 | { | ||
441 | WARN_DIALOG(wxT("No Device detected. If you have a Device connected, select the correct one manually."), | ||
442 | wxT("Detecting a Device")); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | |||
447 | bool DeviceSelectorCtrl::AutoDetect() | ||
448 | { | ||
449 | UsbDeviceInfo device; | ||
450 | |||
451 | if(detectDevices(&device)) | ||
452 | { | ||
453 | |||
454 | if(device.status == DEVICEFOUND) | ||
455 | { | ||
456 | m_deviceCbx->SetValue(gv->plat_name[device.device_index]); | ||
457 | gv->curplat=gv->plat_id[device.device_index]; | ||
458 | |||
459 | if(device.path != wxT("")) | ||
460 | { | ||
461 | gv->curdestdir = device.path; | ||
462 | } | ||
463 | return true; | ||
464 | } | ||
465 | else if(device.status == TOMANYDEVICES) | ||
466 | { | ||
467 | WARN_DIALOG(wxT("More then one device detected, please connect only One"), | ||
468 | wxT("Detecting a Device")); | ||
469 | return true; | ||
470 | } | ||
471 | } | ||
472 | return false; | ||
473 | } | ||
474 | |||
475 | ///////////////////////////////////////////// | ||
476 | //// DevicePosition Selector | ||
477 | ////////////////////////////////////////////// | ||
478 | |||
479 | BEGIN_EVENT_TABLE(DevicePositionCtrl, wxPanel) | ||
480 | EVT_BUTTON(ID_BROWSE_BTN, DevicePositionCtrl::OnBrowseBtn) | ||
481 | END_EVENT_TABLE() | ||
482 | |||
483 | IMPLEMENT_DYNAMIC_CLASS(DevicePositionCtrl, wxPanel) | ||
484 | |||
485 | bool DevicePositionCtrl::Create(wxWindow* parent, wxWindowID id, | ||
486 | const wxPoint& pos, const wxSize& size, long style, | ||
487 | const wxString title) | ||
488 | { | ||
489 | if (!wxPanel::Create(parent, id, pos, size, style, title)) return false; | ||
490 | |||
491 | CreateControls(); | ||
492 | GetSizer()->Fit(this); | ||
493 | GetSizer()->SetSizeHints(this); | ||
494 | return true; | ||
495 | } | ||
496 | |||
497 | void DevicePositionCtrl::CreateControls() | ||
498 | { | ||
499 | // A top-level sizer | ||
500 | wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); | ||
501 | this->SetSizer(topSizer); | ||
502 | |||
503 | //Device Selection | ||
504 | m_desc = new wxStaticText( this, wxID_STATIC, | ||
505 | wxT("Select your Device in the Filesystem"), wxDefaultPosition, | ||
506 | wxDefaultSize, 0 ); | ||
507 | topSizer->Add(m_desc, 0, wxALIGN_LEFT|wxALL, 5); | ||
508 | |||
509 | wxBoxSizer* horizontalSizer = new wxBoxSizer(wxHORIZONTAL); | ||
510 | topSizer->Add(horizontalSizer, 0, wxGROW|wxALL, 5); | ||
511 | |||
512 | m_devicePos = new wxTextCtrl(this,wxID_ANY,gv->curdestdir); | ||
513 | m_devicePos->SetToolTip(wxT("Type the folder where your Device is here")); | ||
514 | m_devicePos->SetHelpText(wxT("Type the folder where your Device is here")); | ||
515 | horizontalSizer->Add(m_devicePos,0,wxGROW | wxALL,5); | ||
516 | |||
517 | m_browseBtn = new wxButton(this, ID_BROWSE_BTN, wxT("Browse"), | ||
518 | wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, | ||
519 | wxT("BrowseBtn")); | ||
520 | m_browseBtn->SetToolTip(wxT("Browse for your Device")); | ||
521 | m_browseBtn->SetHelpText(wxT("Browse for your Device")); | ||
522 | horizontalSizer->Add(m_browseBtn,0,wxGROW | wxALL,5); | ||
523 | |||
524 | topSizer->Fit(this); | ||
525 | Layout(); | ||
526 | |||
527 | } | ||
528 | |||
529 | wxString DevicePositionCtrl::getDevicePos() | ||
530 | { | ||
531 | return m_devicePos->GetValue(); | ||
532 | |||
533 | } | ||
534 | |||
535 | void DevicePositionCtrl::setDefault() | ||
536 | { | ||
537 | m_devicePos->SetValue(gv->curdestdir); | ||
538 | } | ||
539 | |||
540 | void DevicePositionCtrl::OnBrowseBtn(wxCommandEvent& event) | ||
541 | { | ||
542 | const wxString& temp = wxDirSelector( | ||
543 | wxT("Please select the location of your audio device"), gv->curdestdir, | ||
544 | 0, wxDefaultPosition, this); | ||
545 | |||
546 | if (!temp.empty()) | ||
547 | { | ||
548 | m_devicePos->SetValue(temp); | ||
549 | } | ||
550 | |||
551 | } | ||
552 | |||
553 | ///////////////////////////////////////////// | ||
554 | //// FirmwarePosition Selector | ||
555 | ////////////////////////////////////////////// | ||
556 | |||
557 | BEGIN_EVENT_TABLE(FirmwarePositionCtrl, wxPanel) | ||
558 | EVT_BUTTON(ID_BROWSE_BTN, FirmwarePositionCtrl::OnBrowseBtn) | ||
559 | END_EVENT_TABLE() | ||
560 | |||
561 | IMPLEMENT_DYNAMIC_CLASS(FirmwarePositionCtrl, wxControl) | ||
562 | |||
563 | bool FirmwarePositionCtrl::Create(wxWindow* parent, wxWindowID id, | ||
564 | const wxPoint& pos, const wxSize& size, long style, | ||
565 | const wxString title) | ||
566 | { | ||
567 | if (!wxPanel::Create(parent, id, pos, size, style, title)) return false; | ||
568 | |||
569 | CreateControls(); | ||
570 | GetSizer()->Fit(this); | ||
571 | GetSizer()->SetSizeHints(this); | ||
572 | return true; | ||
573 | } | ||
574 | |||
575 | void FirmwarePositionCtrl::CreateControls() | ||
576 | { | ||
577 | // A top-level sizer | ||
578 | wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); | ||
579 | this->SetSizer(topSizer); | ||
580 | |||
581 | //Device Selection | ||
582 | m_desc = new wxStaticText( this, wxID_STATIC, | ||
583 | wxT("Select original Firmware from the Manufacturer"), wxDefaultPosition, | ||
584 | wxDefaultSize, 0 ); | ||
585 | topSizer->Add(m_desc, 0, wxALIGN_LEFT|wxALL, 5); | ||
586 | |||
587 | wxBoxSizer* horizontalSizer = new wxBoxSizer(wxHORIZONTAL); | ||
588 | topSizer->Add(horizontalSizer, 0, wxALIGN_LEFT|wxALL, 5); | ||
589 | |||
590 | m_firmwarePos = new wxTextCtrl(this,wxID_ANY,gv->curdestdir); | ||
591 | m_firmwarePos->SetToolTip(wxT("Type the folder where the original Firmware is here")); | ||
592 | m_firmwarePos->SetHelpText(wxT("Type the folder where the original Firmware is here")); | ||
593 | horizontalSizer->Add(m_firmwarePos,0,wxGROW | wxALL,5); | ||
594 | |||
595 | m_browseBtn = new wxButton(this, ID_BROWSE_BTN, wxT("Browse"), | ||
596 | wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, | ||
597 | wxT("BrowseBtn")); | ||
598 | m_browseBtn->SetToolTip(wxT("Browse for the original Firmware")); | ||
599 | m_browseBtn->SetHelpText(wxT("Browse for the original Firmware")); | ||
600 | horizontalSizer->Add(m_browseBtn,0,wxGROW | wxALL,5); | ||
601 | |||
602 | Layout(); | ||
603 | |||
604 | } | ||
605 | |||
606 | wxString FirmwarePositionCtrl::getFirmwarePos() | ||
607 | { | ||
608 | return m_firmwarePos->GetValue(); | ||
609 | |||
610 | } | ||
611 | |||
612 | void FirmwarePositionCtrl::setDefault() | ||
613 | { | ||
614 | m_firmwarePos->SetValue(gv->curfirmware); | ||
615 | } | ||
616 | |||
617 | void FirmwarePositionCtrl::OnBrowseBtn(wxCommandEvent& event) | ||
618 | { | ||
619 | wxString temp = wxFileSelector( | ||
620 | wxT("Please select the location of the original Firmware"), gv->curdestdir,wxT(""),wxT(""),wxT("*.hex")); | ||
621 | |||
622 | if (!temp.empty()) | ||
623 | { | ||
624 | m_firmwarePos->SetValue(temp); | ||
625 | } | ||
626 | |||
627 | } | ||
628 | |||