summaryrefslogtreecommitdiff
path: root/rbutil/wizard_pages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/wizard_pages.cpp')
-rw-r--r--rbutil/wizard_pages.cpp76
1 files changed, 63 insertions, 13 deletions
diff --git a/rbutil/wizard_pages.cpp b/rbutil/wizard_pages.cpp
index 4ef463a2ec..10a511de47 100644
--- a/rbutil/wizard_pages.cpp
+++ b/rbutil/wizard_pages.cpp
@@ -145,6 +145,7 @@ bool wxPlatformPage::TransferDataFromWindow()
145//////////////// ThemeImage Dialog ///////////////// 145//////////////// ThemeImage Dialog /////////////////
146BEGIN_EVENT_TABLE(wxThemeImageDialog,wxDialog) 146BEGIN_EVENT_TABLE(wxThemeImageDialog,wxDialog)
147 EVT_PAINT(wxThemeImageDialog::OnPaint) 147 EVT_PAINT(wxThemeImageDialog::OnPaint)
148 EVT_CLOSE(wxThemeImageDialog::OnClose)
148END_EVENT_TABLE(); 149END_EVENT_TABLE();
149wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString title,wxBitmap bmp) : 150wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString title,wxBitmap bmp) :
150 wxDialog(parent, id, title) 151 wxDialog(parent, id, title)
@@ -152,7 +153,7 @@ wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString t
152 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); 153 wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
153 m_bitmap = bmp; 154 m_bitmap = bmp;
154 155
155 sizerTop->SetMinSize(m_bitmap.GetWidth(),m_bitmap.GetHeight()); 156 sizerTop->SetMinSize(64,64);
156 157
157 SetSizer(sizerTop); 158 SetSizer(sizerTop);
158 159
@@ -161,6 +162,21 @@ wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString t
161 162
162} 163}
163 164
165void wxThemeImageDialog::OnClose(wxCloseEvent& event)
166{
167 event.Veto();
168 this->Show(false);
169}
170
171void wxThemeImageDialog::SetImage(wxBitmap bmp)
172{
173 m_bitmap = bmp;
174 this->GetSizer()->SetMinSize(m_bitmap.GetWidth(),m_bitmap.GetHeight());
175 this->GetSizer()->Fit(this);
176 Layout();
177 Refresh();
178}
179
164void wxThemeImageDialog::OnPaint(wxPaintEvent& WXUNUSED(event)) 180void wxThemeImageDialog::OnPaint(wxPaintEvent& WXUNUSED(event))
165{ 181{
166 wxPaintDC dc( this ); 182 wxPaintDC dc( this );
@@ -179,6 +195,10 @@ END_EVENT_TABLE();
179wxThemesPage::wxThemesPage(wxWizard *parent) : wxWizardPageSimple(parent) 195wxThemesPage::wxThemesPage(wxWizard *parent) : wxWizardPageSimple(parent)
180{ 196{
181 m_parent = parent; 197 m_parent = parent;
198
199 myImageDialog = new wxThemeImageDialog(this,wxID_ANY,wxT("Preview"),NULL);
200 myImageDialog->Show(false);
201
182 wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); 202 wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
183 203
184 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY, 204 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
@@ -189,7 +209,7 @@ wxThemesPage::wxThemesPage(wxWizard *parent) : wxWizardPageSimple(parent)
189 // create theme listbox 209 // create theme listbox
190 wxArrayString list; 210 wxArrayString list;
191 for(int i = 0; i< 35;i++) 211 for(int i = 0; i< 35;i++)
192 list.Add(""); 212 list.Add(wxT(""));
193 ThemesListBox= new wxListBox(this, ID_LISTBOX, wxDefaultPosition, 213 ThemesListBox= new wxListBox(this, ID_LISTBOX, wxDefaultPosition,
194 wxDefaultSize,list, wxLB_SINGLE); 214 wxDefaultSize,list, wxLB_SINGLE);
195 mainSizer->Add(ThemesListBox,10,wxGROW | wxALL,5); 215 mainSizer->Add(ThemesListBox,10,wxGROW | wxALL,5);
@@ -289,6 +309,35 @@ void wxThemesPage::OnListBox(wxCommandEvent& event)
289 309
290 this->GetSizer()->Layout(); 310 this->GetSizer()->Layout();
291 311
312 if(myImageDialog->IsShown())
313 {
314 wxString src,dest;
315
316 int pos = m_Themes_image[index].Find('/',true);
317 wxString filename = m_Themes_image[index](pos+1,m_Themes_image[index].Length());
318
319 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s"),
320 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str());
321
322 if(!wxDirExists(dest))
323 wxMkdir(dest);
324
325 //this is a URL no PATH_SEP
326 src.Printf("%s/data/%s/%s",gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str());
327 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s" PATH_SEP "%s"),
328 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str(),filename.c_str());
329
330 if(DownloadURL(src, dest))
331 {
332 MESG_DIALOG(wxT("Unable to download image."));
333 return;
334 }
335
336 wxBitmap bmp;
337 bmp.LoadFile(dest,wxBITMAP_TYPE_PNG);
338 myImageDialog->SetImage(bmp);
339 }
340
292} 341}
293 342
294void wxThemesPage::OnPreviewBtn(wxCommandEvent& event) 343void wxThemesPage::OnPreviewBtn(wxCommandEvent& event)
@@ -310,7 +359,7 @@ void wxThemesPage::OnPreviewBtn(wxCommandEvent& event)
310 wxMkdir(dest); 359 wxMkdir(dest);
311 360
312 //this is a URL no PATH_SEP 361 //this is a URL no PATH_SEP
313 src.Printf("%s/data/%s/%s",gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str()); 362 src.Printf(wxT("%s/data/%s/%s"),gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str());
314 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s" PATH_SEP "%s"), 363 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s" PATH_SEP "%s"),
315 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str(),filename.c_str()); 364 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str(),filename.c_str());
316 365
@@ -323,8 +372,9 @@ void wxThemesPage::OnPreviewBtn(wxCommandEvent& event)
323 wxBitmap bmp; 372 wxBitmap bmp;
324 bmp.LoadFile(dest,wxBITMAP_TYPE_PNG); 373 bmp.LoadFile(dest,wxBITMAP_TYPE_PNG);
325 374
326 wxThemeImageDialog dlg(this,wxID_ANY,wxT("Preview"),bmp); 375 myImageDialog->SetImage(bmp);
327 dlg.ShowModal(); 376
377 myImageDialog->Show(true);
328 378
329} 379}
330 380
@@ -344,7 +394,7 @@ void wxThemesPage::OnPageShown(wxWizardEvent& event)
344 //get correct Themes list 394 //get correct Themes list
345 wxString src,dest,err; 395 wxString src,dest,err;
346 396
347 src.Printf("%srbutil.php?res=%s",gv->themes_url.c_str(),gv->curresolution.c_str()); 397 src.Printf(wxT("%srbutil.php?res=%s"),gv->themes_url.c_str(),gv->curresolution.c_str());
348 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s.list"), 398 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s.list"),
349 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str()); 399 gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str());
350 400
@@ -419,7 +469,7 @@ wxIpodLocationPage::wxIpodLocationPage(wxWizard* parent) : wxWizardPageSimple(pa
419 WxBoxSizer1->Add(WxBoxSizer3,0, 469 WxBoxSizer1->Add(WxBoxSizer3,0,
420 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5); 470 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
421 471
422 IpodLocationText = new wxStaticText(this, wxID_ANY, "", 472 IpodLocationText = new wxStaticText(this, wxID_ANY, wxT(""),
423 wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); 473 wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
424 WxBoxSizer3->Add(IpodLocationText,1, 474 WxBoxSizer3->Add(IpodLocationText,1,
425 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5); 475 wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
@@ -477,8 +527,8 @@ void wxIpodLocationPage::OnIpodLocationBtn(wxCommandEvent& event)
477 else if( n==1) 527 else if( n==1)
478 { 528 {
479 gv->curbootloader=wxT("bootloader-"); 529 gv->curbootloader=wxT("bootloader-");
480 gv->curbootloader.Append(ipod.targetname); 530 gv->curbootloader.Append(wxString(ipod.targetname, wxConvUTF8));
481 IpodLocationText->SetLabel(ipod.modelstr); 531 IpodLocationText->SetLabel(wxString(ipod.modelstr, wxConvUTF8));
482 } 532 }
483 else 533 else
484 IpodLocationText->SetLabel(wxT("More than 1 Ipod found")); 534 IpodLocationText->SetLabel(wxT("More than 1 Ipod found"));
@@ -571,7 +621,7 @@ void wxBootLocationPage::OnPageShown(wxWizardEvent& event)
571 } 621 }
572 else 622 else
573 { 623 {
574 BootLocationInfo->SetLabel(""); 624 BootLocationInfo->SetLabel(wxT(""));
575 } 625 }
576 626
577} 627}
@@ -667,7 +717,7 @@ void wxFirmwareLocationPage::OnWizardPageChanging(wxWizardEvent& event)
667void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event) 717void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event)
668{ 718{
669 wxString temp = wxFileSelector( 719 wxString temp = wxFileSelector(
670 wxT("Please select the location of the original Firmware"), gv->curdestdir,"","","*.hex"); 720 wxT("Please select the location of the original Firmware"), gv->curdestdir,wxT(""),wxT(""),wxT("*.hex"));
671 wxLogVerbose(wxT("=== begin wxFirmwareLocationPage::OnFirmwareFilenameBtn(event)")); 721 wxLogVerbose(wxT("=== begin wxFirmwareLocationPage::OnFirmwareFilenameBtn(event)"));
672 if (!temp.empty()) 722 if (!temp.empty())
673 { 723 {
@@ -675,7 +725,7 @@ void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event)
675 if(temp.Length() > 30) 725 if(temp.Length() > 30)
676 { 726 {
677 temp.Remove(0, temp.Length()-30); 727 temp.Remove(0, temp.Length()-30);
678 temp.Prepend("..."); 728 temp.Prepend(wxT("..."));
679 } 729 }
680 FirmwareLocationFilename->SetLabel(temp); 730 FirmwareLocationFilename->SetLabel(temp);
681 } 731 }
@@ -737,7 +787,7 @@ void wxLocationPage::OnPageShown(wxWizardEvent& event)
737 } 787 }
738 else 788 else
739 { 789 {
740 LocationInfo->SetLabel(""); 790 LocationInfo->SetLabel(wxT(""));
741 } 791 }
742 792
743 793