diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index e98ae362e..92bcf2254 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -355,9 +355,8 @@ struct subtitle_spellcheck : public Command { STR_HELP("Open spell checker.") void operator()(agi::Context *c) { -//XXX: This is obscene, requires refactoring the spellchecker. c->videoContext->Stop(); - new DialogSpellChecker(wxGetApp().frame); + new DialogSpellChecker(c); } }; diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index 703a7daae..b5c95dc2c 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -34,8 +34,6 @@ /// @ingroup unused spelling /// -/////////// -// Headers #include "config.h" #ifndef AGI_PRE @@ -46,10 +44,10 @@ #include "ass_file.h" #include "compat.h" #include "dialog_spellchecker.h" -#include "frame_main.h" #include "help_button.h" #include "libresrc/libresrc.h" #include "main.h" +#include "include/aegisub/context.h" #include "include/aegisub/spellchecker.h" #include "selection_controller.h" #include "subs_edit_box.h" @@ -90,8 +88,9 @@ enum { /// @param parent /// @return /// -DialogSpellChecker::DialogSpellChecker(wxFrame *parent) -: wxDialog(parent, -1, _("Spell Checker"), wxDefaultPosition, wxDefaultSize) +DialogSpellChecker::DialogSpellChecker(agi::Context *context) +: wxDialog(context->parent, -1, _("Spell Checker"), wxDefaultPosition, wxDefaultSize) +, context(context) { // Set icon SetIcon(BitmapToIcon(GETIMAGE(spellcheck_toolbutton_24))); @@ -197,7 +196,7 @@ bool DialogSpellChecker::FindNext(int startLine,int startPos) { if (startPos != -1) lastPos = 0; // Get grid - SubtitlesGrid *grid = ((FrameMain*)GetParent())->SubsGrid; + SubtitlesGrid *grid = context->SubsGrid; int rows = grid->GetRows(); // Loop through lines @@ -270,7 +269,7 @@ void DialogSpellChecker::SetWord(wxString word) { for (size_t i=0;iAppend(sugs[i]); // Show word on the main program interface - SubtitlesGrid *grid = ((FrameMain*)GetParent())->SubsGrid; + SubtitlesGrid *grid = context->SubsGrid; int line = lastLine % grid->GetRows(); grid->SelectRow(line,false); grid->MakeCellVisible(line,0); @@ -383,7 +382,7 @@ bool DialogSpellChecker::FindOrDie() { /// void DialogSpellChecker::Replace() { // Get dialog - SubtitlesGrid *grid = ((FrameMain*)GetParent())->SubsGrid; + SubtitlesGrid *grid = context->SubsGrid; AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows()); // Replace @@ -436,7 +435,7 @@ void DialogSpellChecker::OnTakeSuggestion(wxCommandEvent &event) { /// bool DialogSpellChecker::GetFirstMatch() { // Get selection - SubtitlesGrid *grid = ((FrameMain*)GetParent())->SubsGrid; + SubtitlesGrid *grid = context->SubsGrid; wxArrayInt sel = grid->GetSelection(); firstLine = (sel.Count()>0) ? sel[0] : 0; bool hasTypos = FindNext(firstLine,0); diff --git a/aegisub/src/dialog_spellchecker.h b/aegisub/src/dialog_spellchecker.h index 2a20fcda6..417af4790 100644 --- a/aegisub/src/dialog_spellchecker.h +++ b/aegisub/src/dialog_spellchecker.h @@ -34,9 +34,6 @@ /// @ingroup unused spelling /// - -/////////// -// Headers #ifndef AGI_PRE #include @@ -46,20 +43,16 @@ #include #endif - -////////////// -// Prototypes +namespace agi { struct Context; } class SpellChecker; - - /// DOCME /// @class DialogSpellChecker /// @brief DOCME /// /// DOCME class DialogSpellChecker : public wxDialog { -private: + agi::Context *context; /// DOCME SpellChecker *spellchecker; @@ -121,7 +114,7 @@ private: void OnAdd(wxCommandEvent &event); public: - DialogSpellChecker(wxFrame *parent); + DialogSpellChecker(agi::Context *context); ~DialogSpellChecker(); DECLARE_EVENT_TABLE()