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