Removed yet another macro from src/wx/guiinit.cpp

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1275 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
wowzaman12 2015-03-28 14:34:44 +00:00
parent 6630953605
commit 9b15908afa
1 changed files with 48 additions and 50 deletions

View File

@ -2266,14 +2266,12 @@ bool MainFrame::InitMore(void)
wxDialog *d = NULL; wxDialog *d = NULL;
#define vfld(dialog_pointer, name, type) SafeXRCCTRL<type>(dialog_pointer,name)
//// displayed during run //// displayed during run
d=LoadXRCDialog("GBPrinter"); d=LoadXRCDialog("GBPrinter");
// just verify preview window & mag sel present // just verify preview window & mag sel present
{ {
wxPanel *prev; wxPanel *prev;
prev=vfld(d, "Preview", wxPanel); prev=SafeXRCCTRL<wxPanel>(d, "Preview");
if(!wxDynamicCast(prev->GetParent(), wxScrolledWindow)) if(!wxDynamicCast(prev->GetParent(), wxScrolledWindow))
throw std::runtime_error("Unable to load a dialog control from the builtin xrc file: Preview"); throw std::runtime_error("Unable to load a dialog control from the builtin xrc file: Preview");
SafeXRCCTRL<wxControlWithItems>(d, "Magnification"); SafeXRCCTRL<wxControlWithItems>(d, "Magnification");
@ -2284,7 +2282,7 @@ bool MainFrame::InitMore(void)
LoadXRCDialog("GBAROMInfo"); LoadXRCDialog("GBAROMInfo");
// just verify fields present // just verify fields present
wxControl *lab; wxControl *lab;
#define getlab(n) lab=vfld(d, n, wxControl) #define getlab(n) lab=SafeXRCCTRL<wxControl>(d, n)
getlab("Title"); getlab("Title");
getlab("GameCode"); getlab("GameCode");
getlab("MakerCode"); getlab("MakerCode");
@ -2314,14 +2312,14 @@ bool MainFrame::InitMore(void)
d=LoadXRCDialog("CodeSelect"); d=LoadXRCDialog("CodeSelect");
// just verify list present // just verify list present
vfld(d, "CodeList", wxControlWithItems); SafeXRCCTRL<wxControlWithItems>(d, "CodeList");
d->Fit(); d->Fit();
d=LoadXRCDialog("ExportSPS"); d=LoadXRCDialog("ExportSPS");
// just verify text fields present // just verify text fields present
vfld(d, "Title", wxTextCtrl); SafeXRCCTRL<wxTextCtrl>(d, "Title");
vfld(d, "Description", wxTextCtrl); SafeXRCCTRL<wxTextCtrl>(d, "Description");
vfld(d, "Notes", wxTextCtrl); SafeXRCCTRL<wxTextCtrl>(d, "Notes");
d->Fit(); d->Fit();
//// Emulation menu //// Emulation menu
@ -2330,21 +2328,21 @@ bool MainFrame::InitMore(void)
#endif #endif
wxRadioButton *rb; wxRadioButton *rb;
#define getrbi(n, o, v) do { \ #define getrbi(n, o, v) do { \
rb=vfld(d, n, wxRadioButton); \ rb=SafeXRCCTRL<wxRadioButton>(d, n); \
rb->SetValidator(wxBoolIntValidator(&o, v)); \ rb->SetValidator(wxBoolIntValidator(&o, v)); \
} while(0) } while(0)
#define getrbb(n, o) do { \ #define getrbb(n, o) do { \
rb=vfld(d, n, wxRadioButton); \ rb=SafeXRCCTRL<wxRadioButton>(d, n); \
rb->SetValidator(wxGenericValidator(&o)); \ rb->SetValidator(wxGenericValidator(&o)); \
} while(0) } while(0)
#define getrbbr(n, o) do { \ #define getrbbr(n, o) do { \
rb=vfld(d, n, wxRadioButton); \ rb=SafeXRCCTRL<wxRadioButton>(d, n); \
rb->SetValidator(wxBoolRevValidator(&o)); \ rb->SetValidator(wxBoolRevValidator(&o)); \
} while(0) } while(0)
wxBoolEnValidator *benval; wxBoolEnValidator *benval;
wxBoolEnHandler *ben; wxBoolEnHandler *ben;
#define getbe(n, o, cv, t, wt) do { \ #define getbe(n, o, cv, t, wt) do { \
cv=vfld(d, n, t); \ cv=SafeXRCCTRL<t>(d, n); \
cv->SetValidator(wxBoolEnValidator(&o)); \ cv->SetValidator(wxBoolEnValidator(&o)); \
benval = wxStaticCast(cv->GetValidator(), wxBoolEnValidator); \ benval = wxStaticCast(cv->GetValidator(), wxBoolEnValidator); \
static wxBoolEnHandler _ben; \ static wxBoolEnHandler _ben; \
@ -2355,7 +2353,7 @@ bool MainFrame::InitMore(void)
// of checkboxes. A lot of work for little benefit. // of checkboxes. A lot of work for little benefit.
wxBoolRevEnValidator *brenval; wxBoolRevEnValidator *brenval;
#define getbre(n, o, cv, t, wt) do { \ #define getbre(n, o, cv, t, wt) do { \
cv=vfld(d, n, t); \ cv=SafeXRCCTRL<t>(d, n); \
cv->SetValidator(wxBoolRevEnValidator(&o)); \ cv->SetValidator(wxBoolRevEnValidator(&o)); \
brenval = wxStaticCast(cv->GetValidator(), wxBoolRevEnValidator); \ brenval = wxStaticCast(cv->GetValidator(), wxBoolRevEnValidator); \
wx##wt##BoolEnHandlerConnect(rb, wxID_ANY, *ben); \ wx##wt##BoolEnHandlerConnect(rb, wxID_ANY, *ben); \
@ -2383,7 +2381,7 @@ bool MainFrame::InitMore(void)
#define getrbbd(n, o) getbre(n, o, rb, wxRadioButton, RBD) #define getrbbd(n, o) getbre(n, o, rb, wxRadioButton, RBD)
wxTextCtrl *tc; wxTextCtrl *tc;
#define gettc(n, o) do { \ #define gettc(n, o) do { \
tc=vfld(d, n, wxTextCtrl); \ tc=SafeXRCCTRL<wxTextCtrl>(d, n); \
tc->SetValidator(wxTextValidator(wxFILTER_NONE, &o)); \ tc->SetValidator(wxTextValidator(wxFILTER_NONE, &o)); \
} while(0) } while(0)
#ifndef NO_LINK #ifndef NO_LINK
@ -2428,7 +2426,7 @@ bool MainFrame::InitMore(void)
cheat_list_handler.dlg = d; cheat_list_handler.dlg = d;
d->SetEscapeId(wxID_OK); d->SetEscapeId(wxID_OK);
wxCheckedListCtrl *cl; wxCheckedListCtrl *cl;
cl=vfld(d, "Cheats", wxCheckedListCtrl); cl=SafeXRCCTRL<wxCheckedListCtrl>(d, "Cheats");
if(!cl->Init()) if(!cl->Init())
throw std::runtime_error("Unable to initialize the Cheats dialog control from the builtin xrc file!"); throw std::runtime_error("Unable to initialize the Cheats dialog control from the builtin xrc file!");
cheat_list_handler.list = cl; cheat_list_handler.list = cl;
@ -2501,7 +2499,7 @@ bool MainFrame::InitMore(void)
d=LoadXRCDialog("CheatEdit"); d=LoadXRCDialog("CheatEdit");
wxChoice *ch; wxChoice *ch;
#define getch(pointer, name, validator)\ #define getch(pointer, name, validator)\
ch=vfld(pointer, name, wxChoice); \ ch=SafeXRCCTRL<wxChoice>(pointer, name); \
ch->SetValidator(wxGenericValidator(&validator)); ch->SetValidator(wxGenericValidator(&validator));
{ {
// d->Reparent(cheat_list_handler.dlg); // broken // d->Reparent(cheat_list_handler.dlg); // broken
@ -2519,7 +2517,7 @@ bool MainFrame::InitMore(void)
cheat_find_handler.dlg = d; cheat_find_handler.dlg = d;
d->SetEscapeId(wxID_OK); d->SetEscapeId(wxID_OK);
CheatListCtrl *list; CheatListCtrl *list;
list=vfld(d, "CheatList", CheatListCtrl); list=SafeXRCCTRL<CheatListCtrl>(d, "CheatList");
cheat_find_handler.list = list; cheat_find_handler.list = list;
list->SetValidator(CheatFindFill()); list->SetValidator(CheatFindFill());
list->InsertColumn(0, _("Address")); list->InsertColumn(0, _("Address"));
@ -2566,7 +2564,7 @@ bool MainFrame::InitMore(void)
wxCommandEventHandler(CheatFind_t::f), \ wxCommandEventHandler(CheatFind_t::f), \
NULL, &cheat_find_handler); NULL, &cheat_find_handler);
#define cf_enbutton(n, v) do { \ #define cf_enbutton(n, v) do { \
cheat_find_handler.v=vfld(d, n, wxButton); \ cheat_find_handler.v=SafeXRCCTRL<wxButton>(d, n); \
cheat_find_handler.v->Disable(); \ cheat_find_handler.v->Disable(); \
} while(0) } while(0)
cf_button("Search", Search); cf_button("Search", Search);
@ -2607,12 +2605,12 @@ bool MainFrame::InitMore(void)
d=LoadXRCDialog("GeneralConfig"); d=LoadXRCDialog("GeneralConfig");
wxCheckBox *cb; wxCheckBox *cb;
#define getcbb(n, o) do { \ #define getcbb(n, o) do { \
cb=vfld(d, n, wxCheckBox); \ cb=SafeXRCCTRL<wxCheckBox>(d, n); \
cb->SetValidator(wxGenericValidator(&o)); \ cb->SetValidator(wxGenericValidator(&o)); \
} while(0) } while(0)
wxSpinCtrl *sc; wxSpinCtrl *sc;
#define getsc(n, o) do { \ #define getsc(n, o) do { \
sc=vfld(d, n, wxSpinCtrl); \ sc=SafeXRCCTRL<wxSpinCtrl>(d, n); \
sc->SetValidator(wxGenericValidator(&o)); \ sc->SetValidator(wxGenericValidator(&o)); \
} while(0) } while(0)
{ {
@ -2623,7 +2621,7 @@ bool MainFrame::InitMore(void)
getsc("RewindInterval", gopts.rewind_interval); getsc("RewindInterval", gopts.rewind_interval);
getsc("Throttle", gopts.throttle); getsc("Throttle", gopts.throttle);
throttle_ctrl.thr = sc; throttle_ctrl.thr = sc;
throttle_ctrl.thrsel=vfld(d, "ThrottleSel", wxChoice); throttle_ctrl.thrsel=SafeXRCCTRL<wxChoice>(d, "ThrottleSel");
throttle_ctrl.thr-> throttle_ctrl.thr->
Connect(wxEVT_COMMAND_SPINCTRL_UPDATED, Connect(wxEVT_COMMAND_SPINCTRL_UPDATED,
wxSpinEventHandler(ThrottleCtrl_t::SetThrottleSel), wxSpinEventHandler(ThrottleCtrl_t::SetThrottleSel),
@ -2640,7 +2638,7 @@ bool MainFrame::InitMore(void)
#define getcbbe(n, o) getbe(n, o, cb, wxCheckBox, CB) #define getcbbe(n, o) getbe(n, o, cb, wxCheckBox, CB)
wxBoolIntEnValidator *bienval; wxBoolIntEnValidator *bienval;
#define getbie(n, o, v, cv, t, wt) do { \ #define getbie(n, o, v, cv, t, wt) do { \
cv=vfld(d, n, t); \ cv=SafeXRCCTRL<t>(d, n); \
cv->SetValidator(wxBoolIntEnValidator(&o, v, v)); \ cv->SetValidator(wxBoolIntEnValidator(&o, v, v)); \
bienval = wxStaticCast(cv->GetValidator(), wxBoolIntEnValidator); \ bienval = wxStaticCast(cv->GetValidator(), wxBoolIntEnValidator); \
static wxBoolEnHandler _ben; \ static wxBoolEnHandler _ben; \
@ -2660,7 +2658,7 @@ bool MainFrame::InitMore(void)
#define getcbie(n, o, v) getbie(n, o, v, cb, wxCheckBox, CB) #define getcbie(n, o, v) getbie(n, o, v, cb, wxCheckBox, CB)
wxFilePickerCtrl *fp; wxFilePickerCtrl *fp;
#define getfp(n, o) do { \ #define getfp(n, o) do { \
fp=vfld(d, n, wxFilePickerCtrl); \ fp=SafeXRCCTRL<wxFilePickerCtrl>(d, n); \
fp->SetValidator(wxFileDirPickerValidator(&o)); \ fp->SetValidator(wxFileDirPickerValidator(&o)); \
} while(0) } while(0)
d=LoadXRCropertySheetDialog("GameBoyConfig"); d=LoadXRCropertySheetDialog("GameBoyConfig");
@ -2670,7 +2668,7 @@ bool MainFrame::InitMore(void)
// "Display borders" corresponds to 2 variables, so it is handled // "Display borders" corresponds to 2 variables, so it is handled
// in command handler. Plus making changes might require resizing // in command handler. Plus making changes might require resizing
// game area. Validation only here. // game area. Validation only here.
vfld(d, "Borders", wxChoice); SafeXRCCTRL<wxChoice>(d, "Borders");
getcbbe("Printer", gopts.gbprint); getcbbe("Printer", gopts.gbprint);
getcbb("PrintGather", gopts.print_auto_page); getcbb("PrintGather", gopts.print_auto_page);
addbe(cb); addbe(cb);
@ -2707,21 +2705,21 @@ bool MainFrame::InitMore(void)
// "Unable to load dialog GameBoyConfig from resources", this is // "Unable to load dialog GameBoyConfig from resources", this is
// probably the reason. // probably the reason.
pn.Printf(wxT("cp%d"), i + 1); pn.Printf(wxT("cp%d"), i + 1);
wxWindow *w = vfld(d, ToString(pn).c_str(), wxWindow); wxWindow *w = SafeXRCCTRL<wxWindow>(d, ToString(pn).c_str());
GBColorConfigHandler[i].p = w; GBColorConfigHandler[i].p = w;
GBColorConfigHandler[i].pno = i; GBColorConfigHandler[i].pno = i;
wxFarRadio *cb = vfld(w, "UsePalette", wxFarRadio); wxFarRadio *cb = SafeXRCCTRL<wxFarRadio>(w, "UsePalette");
if(r) if(r)
cb->SetGroup(r); cb->SetGroup(r);
else else
r = cb; r = cb;
cb->SetValidator(wxBoolIntValidator(&gbPaletteOption, i)); cb->SetValidator(wxBoolIntValidator(&gbPaletteOption, i));
ch=vfld(w, "ColorSet", wxChoice); ch=SafeXRCCTRL<wxChoice>(w, "ColorSet");
GBColorConfigHandler[i].c = ch; GBColorConfigHandler[i].c = ch;
for(int j = 0; j < 8; j++) { for(int j = 0; j < 8; j++) {
wxString s; wxString s;
s.Printf(wxT("Color%d"), j); s.Printf(wxT("Color%d"), j);
wxColourPickerCtrl *cp = vfld(w, ToString(s).c_str(), wxColourPickerCtrl); wxColourPickerCtrl *cp = SafeXRCCTRL<wxColourPickerCtrl>(w, ToString(s).c_str());
GBColorConfigHandler[i].cp[j] = cp; GBColorConfigHandler[i].cp[j] = cp;
cp->SetValidator(wxColorValidator(&systemGbPalette[i * 8 + j])); cp->SetValidator(wxColorValidator(&systemGbPalette[i * 8 + j]));
} }
@ -2783,11 +2781,11 @@ bool MainFrame::InitMore(void)
/// Game Overrides /// Game Overrides
getgbaw("GameSettings"); getgbaw("GameSettings");
// the rest must be filled in by command handler; just validate // the rest must be filled in by command handler; just validate
vfld(d, "Comment", wxTextCtrl); SafeXRCCTRL<wxTextCtrl>(d, "Comment");
vfld(d, "OvRTC", wxChoice); SafeXRCCTRL<wxChoice>(d, "OvRTC");
vfld(d, "OvSaveType", wxChoice); SafeXRCCTRL<wxChoice>(d, "OvSaveType");
vfld(d, "OvFlashSize", wxChoice); SafeXRCCTRL<wxChoice>(d, "OvFlashSize");
vfld(d, "OvMirroring", wxChoice); SafeXRCCTRL<wxChoice>(d, "OvMirroring");
d->Fit(); d->Fit();
} }
@ -2806,7 +2804,7 @@ bool MainFrame::InitMore(void)
getsc("MaxScale", gopts.max_scale); getsc("MaxScale", gopts.max_scale);
// fs modes should be filled in at popup time // fs modes should be filled in at popup time
// since they may change based on what screen is current // since they may change based on what screen is current
vfld(d, "FullscreenMode", wxChoice); SafeXRCCTRL<wxChoice>(d, "FullscreenMode");
getcbb("Fullscreen", gopts.fullscreen); getcbb("Fullscreen", gopts.fullscreen);
/// Advanced /// Advanced
@ -2827,7 +2825,7 @@ bool MainFrame::InitMore(void)
getcbb("VSync", gopts.vsync); getcbb("VSync", gopts.vsync);
// FIXME: make cb disabled when not GL or d3d // FIXME: make cb disabled when not GL or d3d
#define getcbi(n, o, v) do { \ #define getcbi(n, o, v) do { \
cb=vfld(d, n, wxCheckBox); \ cb=SafeXRCCTRL<wxCheckBox>(d, n); \
cb->SetValidator(wxBoolIntValidator(&o, v)); \ cb->SetValidator(wxBoolIntValidator(&o, v)); \
} while(0) } while(0)
int mthr = wxThread::GetCPUCount(); int mthr = wxThread::GetCPUCount();
@ -2841,15 +2839,15 @@ bool MainFrame::InitMore(void)
#ifdef MMX #ifdef MMX
getcbb("MMX", cpu_mmx); getcbb("MMX", cpu_mmx);
#else #else
cb=vfld(d, "MMX", wxCheckBox); cb=SafeXRCCTRL<wxCheckBox>(d, "MMX");
cb->Hide(); cb->Hide();
#endif #endif
getch(d, "Filter", gopts.filter); getch(d, "Filter", gopts.filter);
// these two are filled and/or hidden at dialog load time // these two are filled and/or hidden at dialog load time
wxControl *pll; wxControl *pll;
wxChoice *pl; wxChoice *pl;
pll=vfld(d, "PluginLab", wxControl); pll=SafeXRCCTRL<wxControl>(d, "PluginLab");
pl=vfld(d, "Plugin", wxChoice); pl=SafeXRCCTRL<wxChoice>(d, "Plugin");
pll->SetValidator(PluginEnabler()); pll->SetValidator(PluginEnabler());
pl->SetValidator(PluginListFiller(d, pll, ch)); pl->SetValidator(PluginListFiller(d, pll, ch));
PluginEnableHandler.lab = pll; PluginEnableHandler.lab = pll;
@ -2864,7 +2862,7 @@ bool MainFrame::InitMore(void)
d=LoadXRCropertySheetDialog("SoundConfig"); d=LoadXRCropertySheetDialog("SoundConfig");
wxSlider *sl; wxSlider *sl;
#define getsl(n, o) do { \ #define getsl(n, o) do { \
sl=vfld(d, n, wxSlider); \ sl=SafeXRCCTRL<wxSlider>(d, n); \
sl->SetValidator(wxGenericValidator(&o)); \ sl->SetValidator(wxGenericValidator(&o)); \
} while(0) } while(0)
{ {
@ -2896,7 +2894,7 @@ bool MainFrame::InitMore(void)
#if !defined(__WXMSW__) || defined(NO_XAUDIO2) #if !defined(__WXMSW__) || defined(NO_XAUDIO2)
rb->Hide(); rb->Hide();
#endif #endif
sound_config_handler.dev=vfld(d, "Device", wxChoice); sound_config_handler.dev=SafeXRCCTRL<wxChoice>(d, "Device");
sound_config_handler.dev->SetValidator(SoundConfigLoad()); sound_config_handler.dev->SetValidator(SoundConfigLoad());
getcbb("Upmix", gopts.upmix); getcbb("Upmix", gopts.upmix);
sound_config_handler.umix = cb; sound_config_handler.umix = cb;
@ -2925,7 +2923,7 @@ bool MainFrame::InitMore(void)
getcbb("GBDeclicking", gopts.gb_declick); getcbb("GBDeclicking", gopts.gb_declick);
getcbbe("GBEnhanceSound", gb_effects_config.enabled); getcbbe("GBEnhanceSound", gb_effects_config.enabled);
wxPanel *p; wxPanel *p;
p=vfld(d, "GBEnhanceSoundDep", wxPanel); p=SafeXRCCTRL<wxPanel>(d, "GBEnhanceSoundDep");
addbe(p); addbe(p);
getcbb("GBSurround", gb_effects_config.surround); getcbb("GBSurround", gb_effects_config.surround);
getsl("GBEcho", gopts.gb_echo); getsl("GBEcho", gopts.gb_echo);
@ -2939,7 +2937,7 @@ bool MainFrame::InitMore(void)
wxDirPickerCtrl *dp; wxDirPickerCtrl *dp;
#define getdp(n, o) do { \ #define getdp(n, o) do { \
dp=vfld(d, n, wxDirPickerCtrl); \ dp=SafeXRCCTRL<wxDirPickerCtrl>(d, n); \
dp->SetValidator(wxFileDirPickerValidator(&o)); \ dp->SetValidator(wxFileDirPickerValidator(&o)); \
} while(0) } while(0)
d=LoadXRCDialog("DirectoriesConfig"); d=LoadXRCDialog("DirectoriesConfig");
@ -2964,9 +2962,9 @@ bool MainFrame::InitMore(void)
// "Unable to load dialog JoypadConfig from resources", this is // "Unable to load dialog JoypadConfig from resources", this is
// probably the reason. // probably the reason.
pn.Printf(wxT("joy%d"), i + 1); pn.Printf(wxT("joy%d"), i + 1);
wxWindow *w = vfld(joyDialog, ToString(pn).c_str(), wxWindow); wxWindow *w = SafeXRCCTRL<wxWindow>(joyDialog, ToString(pn).c_str());
wxFarRadio *cb; wxFarRadio *cb;
cb=vfld(w, "DefaultConfig", wxFarRadio); cb=SafeXRCCTRL<wxFarRadio>(w, "DefaultConfig");
if(r) if(r)
cb->SetGroup(r); cb->SetGroup(r);
else else
@ -3015,15 +3013,15 @@ bool MainFrame::InitMore(void)
d=LoadXRCDialog("AccelConfig"); d=LoadXRCDialog("AccelConfig");
{ {
wxTreeCtrl *tc; wxTreeCtrl *tc;
tc=vfld(d, "Commands", wxTreeCtrl); tc=SafeXRCCTRL<wxTreeCtrl>(d, "Commands");
accel_config_handler.tc = tc; accel_config_handler.tc = tc;
wxControlWithItems *lb; wxControlWithItems *lb;
lb=vfld(d, "Current", wxControlWithItems); lb=SafeXRCCTRL<wxControlWithItems>(d, "Current");
accel_config_handler.lb = lb; accel_config_handler.lb = lb;
accel_config_handler.asb=vfld(d, "Assign", wxButton); accel_config_handler.asb=SafeXRCCTRL<wxButton>(d, "Assign");
accel_config_handler.remb=vfld(d, "Remove", wxButton); accel_config_handler.remb=SafeXRCCTRL<wxButton>(d, "Remove");
accel_config_handler.key=vfld(d, "Shortcut", wxKeyTextCtrl); accel_config_handler.key=SafeXRCCTRL<wxKeyTextCtrl>(d, "Shortcut");
accel_config_handler.curas=vfld(d, "AlreadyThere", wxControl); accel_config_handler.curas=SafeXRCCTRL<wxControl>(d, "AlreadyThere");
accel_config_handler.key->MoveBeforeInTabOrder(accel_config_handler.asb); accel_config_handler.key->MoveBeforeInTabOrder(accel_config_handler.asb);
accel_config_handler.key->SetMultikey(0); accel_config_handler.key->SetMultikey(0);
accel_config_handler.key->SetClearable(false); accel_config_handler.key->SetClearable(false);