From b91f1a051160e688b2d65f85d39c17c6d1253261 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 21 Apr 2007 23:16:38 +0000 Subject: [PATCH] Replaced wxScintilla with the more sane (and standard) wxStyledTextCtrl. Originally committed to SVN as r1104. --- aegisub/changelog.txt | 2 +- aegisub/dialog_about.cpp | 2 +- aegisub/setup.cpp | 35 +++-------------------------------- aegisub/stdwx.h | 2 +- aegisub/subs_edit_box.cpp | 22 +++++++++++----------- aegisub/subs_edit_box.h | 12 ++++++------ aegisub/subs_edit_ctrl.cpp | 28 ++++++++++++++-------------- aegisub/subs_edit_ctrl.h | 4 ++-- 8 files changed, 39 insertions(+), 68 deletions(-) diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index ff0bccacd..28d6c3b68 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -61,7 +61,7 @@ Please visit http://aegisub.net to download latest version - Fonts collector can now collect fonts directly to a zipped archive; also, fixed behavior of the Escape key in it. (AMZ) - Added support for DirectShowSource2 if avss.dll is on Aegisub's folder. (AMZ) - Added DirectSound audio output, to avoid using PortAudio under Win32. (AMZ) -- Replaced wxTextCtrl with wxScintilla, to solve many issues related to the Rich Text edit control. (AMZ) +- Replaced wxTextCtrl with wxStyledTextCtrl, to solve many issues related to the Rich Text edit control. (AMZ) - Improved Syntax Highlighter to include more features of ASS. (AMZ) - Added an inline Hunspell-based Spell Checker. (AMZ) - Added an inline MyThes-based Thesaurus. (AMZ) diff --git a/aegisub/dialog_about.cpp b/aegisub/dialog_about.cpp index 3b94ab6b3..3fb70b0d0 100644 --- a/aegisub/dialog_about.cpp +++ b/aegisub/dialog_about.cpp @@ -60,7 +60,7 @@ AboutScreen::AboutScreen(wxWindow *parent) // Generate library string wxString libString = _("This build of Aegisub uses the following C/C++ libraries:\n"); libString += _T("wxWidgets - Copyright (c) 1998-2006 Julian Smart, Robert Roebling et al;\n"); - libString += _T("wxScintilla - Copyright (c) 2004 wxCode;\n"); + libString += _T("wxStyledTextCtrl - Copyright (c) 2004 wxCode;\n"); libString += _T("Lua - Copyright (c) 1994-2006 Lua.org, PUC-Rio;\n"); #if USE_HUNSPELL == 1 libString += _T("Hunspell - Copyright (c) Kevin Hendricks;\n"); diff --git a/aegisub/setup.cpp b/aegisub/setup.cpp index 892662293..90f9be437 100644 --- a/aegisub/setup.cpp +++ b/aegisub/setup.cpp @@ -64,6 +64,7 @@ #pragma comment(lib, "wxmsw28ud_core.lib") #pragma comment(lib, "wxmsw28ud_adv.lib") #pragma comment(lib, "wxmsw28ud_gl.lib") +#pragma comment(lib, "wxmsw28ud_stc.lib") #else #pragma comment(lib, "wxregexu.lib") #pragma comment(lib, "wxbase28u.lib") @@ -72,40 +73,12 @@ #pragma comment(lib, "wxmsw28u_core.lib") #pragma comment(lib, "wxmsw28u_adv.lib") #pragma comment(lib, "wxmsw28u_gl.lib") +#pragma comment(lib, "wxmsw28u_stc.lib") #endif #else -#if wxCHECK_VERSION(2, 7, 0) -#ifdef __WXDEBUG__ -#pragma comment(lib, "wxregexud.lib") -#pragma comment(lib, "wxbase27ud.lib") -#pragma comment(lib, "wxmsw27ud_media.lib") -#pragma comment(lib, "wxmsw27ud_core.lib") -#pragma comment(lib, "wxmsw27ud_adv.lib") -#else -#pragma comment(lib, "wxregexu.lib") -#pragma comment(lib, "wxbase27u.lib") -#pragma comment(lib, "wxmsw27u_media.lib") -#pragma comment(lib, "wxmsw27u_core.lib") -#pragma comment(lib, "wxmsw27u_adv.lib") -#endif -#else if wxCHECK_VERSION(2, 6, 0) -#ifdef __WXDEBUG__ -#pragma comment(lib, "wxregexud.lib") -#pragma comment(lib, "wxbase26ud.lib") -#pragma comment(lib, "wxmsw26ud_media.lib") -#pragma comment(lib, "wxmsw26ud_core.lib") -#pragma comment(lib, "wxmsw26ud_adv.lib") -#else -#pragma comment(lib, "wxregexu.lib") -#pragma comment(lib, "wxbase26u.lib") -#pragma comment(lib, "wxmsw26u_media.lib") -#pragma comment(lib, "wxmsw26u_core.lib") -#pragma comment(lib, "wxmsw26u_adv.lib") -#endif - -#endif +#error "Aegisub requires wxWidgets 2.8.0 or superior" #endif // wxWidgets @@ -113,9 +86,7 @@ ///////////// // Scintilla #ifdef __WXDEBUG__ -#pragma comment(lib, "wxscintillaud.lib") #else -#pragma comment(lib, "wxscintillau.lib") #endif diff --git a/aegisub/stdwx.h b/aegisub/stdwx.h index 7a144c839..a9b992ccd 100644 --- a/aegisub/stdwx.h +++ b/aegisub/stdwx.h @@ -77,7 +77,7 @@ #include #include #include -#include +#include #include //#include #include diff --git a/aegisub/subs_edit_box.cpp b/aegisub/subs_edit_box.cpp index 0e4a57bd5..27e50af46 100644 --- a/aegisub/subs_edit_box.cpp +++ b/aegisub/subs_edit_box.cpp @@ -346,11 +346,11 @@ void SubsEditBox::SetToLine(int n,bool weak) { /////////////// // Event table BEGIN_EVENT_TABLE(SubsEditBox, wxPanel) - EVT_SCI_MODIFIED(EDIT_BOX,SubsEditBox::OnEditText) - EVT_SCI_STYLENEEDED(EDIT_BOX,SubsEditBox::OnNeedStyle) - EVT_SCI_KEY(EDIT_BOX,SubsEditBox::OnKeyDown) - EVT_SCI_CHARADDED(EDIT_BOX,SubsEditBox::OnCharAdded) - EVT_SCI_UPDATEUI(EDIT_BOX,SubsEditBox::OnUpdateUI) + EVT_STC_MODIFIED(EDIT_BOX,SubsEditBox::OnEditText) + EVT_STC_STYLENEEDED(EDIT_BOX,SubsEditBox::OnNeedStyle) + EVT_STC_KEY(EDIT_BOX,SubsEditBox::OnKeyDown) + EVT_STC_CHARADDED(EDIT_BOX,SubsEditBox::OnCharAdded) + EVT_STC_UPDATEUI(EDIT_BOX,SubsEditBox::OnUpdateUI) EVT_CHECKBOX(SYNTAX_BOX, SubsEditBox::OnSyntaxBox) EVT_RADIOBUTTON(RADIO_TIME_BY_FRAME, SubsEditBox::OnFrameRadio) @@ -392,9 +392,9 @@ void SubsEditBox::OnSize(wxSizeEvent &event) { ///////////////////// // Text edited event -void SubsEditBox::OnEditText(wxScintillaEvent &event) { +void SubsEditBox::OnEditText(wxStyledTextEvent &event) { int modType = event.GetModificationType(); - if (modType == (wxSCI_MOD_INSERTTEXT | wxSCI_PERFORMED_USER) || modType == (wxSCI_MOD_DELETETEXT | wxSCI_PERFORMED_USER)) { + if (modType == (wxSTC_MOD_INSERTTEXT | wxSTC_PERFORMED_USER) || modType == (wxSTC_MOD_DELETETEXT | wxSTC_PERFORMED_USER)) { //TextEdit->UpdateCallTip(); } } @@ -402,14 +402,14 @@ void SubsEditBox::OnEditText(wxScintillaEvent &event) { ////////////////////////// // User Interface updated -void SubsEditBox::OnUpdateUI(wxScintillaEvent &event) { +void SubsEditBox::OnUpdateUI(wxStyledTextEvent &event) { TextEdit->UpdateCallTip(); } ////////////// // Need style -void SubsEditBox::OnNeedStyle(wxScintillaEvent &event) { +void SubsEditBox::OnNeedStyle(wxStyledTextEvent &event) { // Check if it needs to fix text wxString text = TextEdit->GetText(); if (text.Contains(_T("\n")) || text.Contains(_T("\r"))) { @@ -423,14 +423,14 @@ void SubsEditBox::OnNeedStyle(wxScintillaEvent &event) { /////////////////// // Character added -void SubsEditBox::OnCharAdded(wxScintillaEvent &event) { +void SubsEditBox::OnCharAdded(wxStyledTextEvent &event) { //int character = event.GetKey(); } //////////// // Key down -void SubsEditBox::OnKeyDown(wxScintillaEvent &event) { +void SubsEditBox::OnKeyDown(wxStyledTextEvent &event) { } diff --git a/aegisub/subs_edit_box.h b/aegisub/subs_edit_box.h index fd7d97ddb..06d10ea62 100644 --- a/aegisub/subs_edit_box.h +++ b/aegisub/subs_edit_box.h @@ -50,7 +50,7 @@ class TimeEdit; class SubsEditBox; class AudioDisplay; class HiliModTextCtrl; -class wxScintilla; +class wxStyledTextCtrl; ////////////////// @@ -107,10 +107,10 @@ private: int BlockAtPos(int pos); - void OnEditText(wxScintillaEvent &event); - void OnNeedStyle(wxScintillaEvent &event); - void OnCharAdded(wxScintillaEvent &event); - void OnUpdateUI(wxScintillaEvent &event); + void OnEditText(wxStyledTextEvent &event); + void OnNeedStyle(wxStyledTextEvent &event); + void OnCharAdded(wxStyledTextEvent &event); + void OnUpdateUI(wxStyledTextEvent &event); void OnButtonColor1(wxCommandEvent &event); void OnButtonColor2(wxCommandEvent &event); @@ -125,7 +125,7 @@ private: void OnSyntaxBox(wxCommandEvent &event); void OnFrameRadio(wxCommandEvent &event); void OnTimeRadio(wxCommandEvent &event); - void OnKeyDown(wxScintillaEvent &event); + void OnKeyDown(wxStyledTextEvent &event); void OnStyleChange(wxCommandEvent &event); void OnActorChange(wxCommandEvent &event); void OnLayerChange(wxCommandEvent &event); diff --git a/aegisub/subs_edit_ctrl.cpp b/aegisub/subs_edit_ctrl.cpp index 98010c4f7..24b4ba555 100644 --- a/aegisub/subs_edit_ctrl.cpp +++ b/aegisub/subs_edit_ctrl.cpp @@ -48,25 +48,25 @@ //////////////////////// // Edit box constructor SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& wsize, long style, const wxValidator& validator, const wxString& name) -: wxScintilla(parent, id, pos, wsize, 0, value) +: wxStyledTextCtrl(parent, id, pos, wsize, 0, value) { // Set properties - SetWrapMode(wxSCI_WRAP_WORD); + SetWrapMode(wxSTC_WRAP_WORD); SetMarginWidth(1,0); UsePopUp(false); SetStyles(); // Set hotkeys - CmdKeyClear(wxSCI_KEY_RETURN,wxSCI_SCMOD_CTRL); - CmdKeyClear(wxSCI_KEY_RETURN,wxSCI_SCMOD_NULL); - CmdKeyClear(wxSCI_KEY_TAB,wxSCI_SCMOD_NULL); - CmdKeyClear(wxSCI_KEY_TAB,wxSCI_SCMOD_SHIFT); - CmdKeyClear('D',wxSCI_SCMOD_CTRL); - CmdKeyClear('L',wxSCI_SCMOD_CTRL); - CmdKeyClear('L',wxSCI_SCMOD_CTRL | wxSCI_SCMOD_SHIFT); - CmdKeyClear('T',wxSCI_SCMOD_CTRL); - CmdKeyClear('T',wxSCI_SCMOD_CTRL | wxSCI_SCMOD_SHIFT); - CmdKeyClear('U',wxSCI_SCMOD_CTRL); + CmdKeyClear(wxSTC_KEY_RETURN,wxSTC_SCMOD_CTRL); + CmdKeyClear(wxSTC_KEY_RETURN,wxSTC_SCMOD_NORM); + CmdKeyClear(wxSTC_KEY_TAB,wxSTC_SCMOD_NORM); + CmdKeyClear(wxSTC_KEY_TAB,wxSTC_SCMOD_SHIFT); + CmdKeyClear('D',wxSTC_SCMOD_CTRL); + CmdKeyClear('L',wxSTC_SCMOD_CTRL); + CmdKeyClear('L',wxSTC_SCMOD_CTRL | wxSTC_SCMOD_SHIFT); + CmdKeyClear('T',wxSTC_SCMOD_CTRL); + CmdKeyClear('T',wxSTC_SCMOD_CTRL | wxSTC_SCMOD_SHIFT); + CmdKeyClear('U',wxSTC_SCMOD_CTRL); // Set spellchecker spellchecker = SpellChecker::GetSpellChecker(); @@ -140,7 +140,7 @@ SubsTextEditCtrl::~SubsTextEditCtrl() { /////////////////////// // Control event table -BEGIN_EVENT_TABLE(SubsTextEditCtrl,wxScintilla) +BEGIN_EVENT_TABLE(SubsTextEditCtrl,wxStyledTextCtrl) EVT_MOUSE_EVENTS(SubsTextEditCtrl::OnMouseEvent) EVT_KILL_FOCUS(SubsTextEditCtrl::OnLoseFocus) @@ -215,7 +215,7 @@ void SubsTextEditCtrl::SetStyles() { StyleSetForeground(6,Options.AsColour(_T("Syntax Highlight Line Break"))); // Misspelling indicator - IndicatorSetStyle(0,wxSCI_INDIC_SQUIGGLE); + IndicatorSetStyle(0,wxSTC_INDIC_SQUIGGLE); IndicatorSetForeground(0,wxColour(255,0,0)); } diff --git a/aegisub/subs_edit_ctrl.h b/aegisub/subs_edit_ctrl.h index bab4d7299..b47496788 100644 --- a/aegisub/subs_edit_ctrl.h +++ b/aegisub/subs_edit_ctrl.h @@ -40,7 +40,7 @@ //////////// // Includes #include -#include +#include #include "spellchecker.h" #include "thesaurus.h" @@ -52,7 +52,7 @@ class SubsEditBox; //////////////////// // SubsTextEditCtrl -class SubsTextEditCtrl : public wxScintilla { +class SubsTextEditCtrl : public wxStyledTextCtrl { private: SpellChecker *spellchecker; Thesaurus *thesaurus;