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