Load dialogs the proper way

This commit is contained in:
wowzaman12 2015-03-28 01:30:36 +00:00
parent 07eb6564e0
commit 1c76277272
2 changed files with 21 additions and 10 deletions

View File

@ -1970,10 +1970,17 @@ void CheckThrowXRCError(T pointer,std::string name)
wxDialog * MainFrame::LoadXRCDialog(const char * name) wxDialog * MainFrame::LoadXRCDialog(const char * name)
{ {
wxString dname = wxString::FromUTF8(name); wxString dname = wxString::FromUTF8(name);
/* using this instead of LoadDialog() allows non-wxDialog classes that */ wxDialog * dialog = wxXmlResource::Get()->LoadDialog(this, dname);
/* are derived from wxDialog (like wxPropertySheetDialog) to work */ CheckThrowXRCError(dialog,name);
return dialog;
}
wxPropertySheetDialog * MainFrame::LoadXRCropertySheetDialog(const char * name)
{
wxString dname = wxString::FromUTF8(name);
//Seems like the only way to do this
wxObject * anObject = wxXmlResource::Get()->LoadObject(this, dname, wxEmptyString); wxObject * anObject = wxXmlResource::Get()->LoadObject(this, dname, wxEmptyString);
wxDialog * dialog = wxDynamicCast(anObject, wxDialog); wxPropertySheetDialog * dialog = wxDynamicCast(anObject, wxPropertySheetDialog);
CheckThrowXRCError(dialog,name); CheckThrowXRCError(dialog,name);
/* wx-2.9.1 doesn't set parent for propertysheetdialogs for some reason */ /* wx-2.9.1 doesn't set parent for propertysheetdialogs for some reason */
@ -2633,7 +2640,7 @@ bool MainFrame::InitMore(void)
getfld(fp, n, wxFilePickerCtrl); \ getfld(fp, n, wxFilePickerCtrl); \
fp->SetValidator(wxFileDirPickerValidator(&o)); \ fp->SetValidator(wxFileDirPickerValidator(&o)); \
} while(0) } while(0)
d=LoadXRCDialog("GameBoyConfig"); d=LoadXRCropertySheetDialog("GameBoyConfig");
{ {
/// System and Peripherals /// System and Peripherals
getch("System", gbEmulatorType); getch("System", gbEmulatorType);
@ -2712,7 +2719,7 @@ bool MainFrame::InitMore(void)
} }
} }
d=LoadXRCDialog("GameBoyAdvanceConfig"); d=LoadXRCropertySheetDialog("GameBoyAdvanceConfig");
{ {
/// System and peripherals /// System and peripherals
getch("SaveType", gopts.save_type); getch("SaveType", gopts.save_type);
@ -2764,7 +2771,7 @@ bool MainFrame::InitMore(void)
vfld("OvMirroring", wxChoice); vfld("OvMirroring", wxChoice);
} }
d=LoadXRCDialog("DisplayConfig"); d=LoadXRCropertySheetDialog("DisplayConfig");
{ {
/// On-Screen Display /// On-Screen Display
getch("SpeedIndicator", gopts.osd_speed); getch("SpeedIndicator", gopts.osd_speed);
@ -2833,7 +2840,7 @@ bool MainFrame::InitMore(void)
getch("IFB", gopts.ifb); getch("IFB", gopts.ifb);
} }
d=LoadXRCDialog("SoundConfig"); d=LoadXRCropertySheetDialog("SoundConfig");
wxSlider *sl; wxSlider *sl;
#define getsl(n, o) do { \ #define getsl(n, o) do { \
getfld(sl, n, wxSlider); \ getfld(sl, n, wxSlider); \
@ -2923,7 +2930,7 @@ bool MainFrame::InitMore(void)
getdp("Recordings", gopts.recording_dir); getdp("Recordings", gopts.recording_dir);
} }
d=LoadXRCDialog("JoypadConfig"); d=LoadXRCropertySheetDialog("JoypadConfig");
wxFarRadio *r = 0; wxFarRadio *r = 0;
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
wxString pn; wxString pn;

View File

@ -1,6 +1,9 @@
#ifndef WX_WXVBAM_H #ifndef WX_WXVBAM_H
#define WX_WXVBAM_H #define WX_WXVBAM_H
#include <list>
#include <wx/propdlg.h>
#include "wxhead.h" #include "wxhead.h"
#include "wx/sdljoy.h" #include "wx/sdljoy.h"
#include "wx/joyedit.h" #include "wx/joyedit.h"
@ -9,7 +12,6 @@
#ifndef NO_FFMPEG #ifndef NO_FFMPEG
#include "../common/ffmpeg.h" #include "../common/ffmpeg.h"
#endif #endif
#include <list>
/* yeah, they aren't needed globally, but I'm too lazy to limit where needed */ /* yeah, they aren't needed globally, but I'm too lazy to limit where needed */
#include "../System.h" #include "../System.h"
@ -243,8 +245,10 @@ private:
void OnDropFile(wxDropFilesEvent&); void OnDropFile(wxDropFilesEvent&);
// pop up menu in fullscreen mode // pop up menu in fullscreen mode
void OnMenu(wxContextMenuEvent &); void OnMenu(wxContextMenuEvent &);
// Load a named wxDialog from the XRC file (also loads wxPropertySheetDialog) // Load a named wxDialog from the XRC file
wxDialog * LoadXRCDialog(const char * name); wxDialog * LoadXRCDialog(const char * name);
// Load a named wxPropertySheetDialog from the XRC file
wxPropertySheetDialog * LoadXRCropertySheetDialog(const char * name);
// Returns the link mode to set according to the options // Returns the link mode to set according to the options
LinkMode getOptionsLinkMode(); LinkMode getOptionsLinkMode();
#include "cmdhandlers.h" #include "cmdhandlers.h"