Added option to let user disable spellchecker and thesaurus from right click menu, and a possible fix to splash screen.

Originally committed to SVN as r676.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-01 23:47:09 +00:00
parent af78223810
commit 9d1a3466dd
4 changed files with 81 additions and 54 deletions

View file

@ -58,10 +58,15 @@ SplashScreen::SplashScreen(wxWindow *parent)
// Center on current display // Center on current display
if (wxDisplay::GetCount() < 1) CentreOnParent(); if (wxDisplay::GetCount() < 1) CentreOnParent();
else { else {
// Get display number
int point = wxDisplay::GetFromPoint(parent->GetScreenPosition()); int point = wxDisplay::GetFromPoint(parent->GetScreenPosition());
if (point == wxNOT_FOUND) point = 0; if (point == wxNOT_FOUND) point = 0;
// Get display size
wxDisplay display(point); wxDisplay display(point);
wxRect dr = display.GetGeometry(); wxRect dr = display.GetGeometry();
// Calculate position and center it there
wxRect window = GetScreenRect(); wxRect window = GetScreenRect();
window = window.CenterIn(dr); window = window.CenterIn(dr);
Move(window.GetLeft(),window.GetTop()); Move(window.GetLeft(),window.GetTop());

View file

@ -158,6 +158,15 @@ wxArrayString HunspellSpellChecker::GetLanguageList() {
//////////////// ////////////////
// Set language // Set language
void HunspellSpellChecker::SetLanguage(wxString language) { void HunspellSpellChecker::SetLanguage(wxString language) {
// Unload
delete hunspell;
hunspell = NULL;
delete conv;
conv = NULL;
// Unloading
if (language.IsEmpty()) return;
// Get dir name // Get dir name
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/");
@ -168,12 +177,6 @@ void HunspellSpellChecker::SetLanguage(wxString language) {
// Check if language is available // Check if language is available
if (!wxFileExists(affpath) || !wxFileExists(dicpath)) return; if (!wxFileExists(affpath) || !wxFileExists(dicpath)) return;
// Unload
delete hunspell;
hunspell = NULL;
delete conv;
conv = NULL;
// Load // Load
hunspell = new Hunspell(affpath.mb_str(wxConvLocal),dicpath.mb_str(wxConvLocal)); hunspell = new Hunspell(affpath.mb_str(wxConvLocal),dicpath.mb_str(wxConvLocal));
conv = NULL; conv = NULL;

View file

@ -513,7 +513,7 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) {
// Language list // Language list
wxArrayString langs = spellchecker->GetLanguageList(); // This probably should be cached... wxArrayString langs = spellchecker->GetLanguageList(); // This probably should be cached...
if (langs.Count()) {
// Current language // Current language
wxString curLang = Options.AsText(_T("Spell checker language")); wxString curLang = Options.AsText(_T("Spell checker language"));
@ -522,16 +522,22 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) {
wxMenuItem *cur; wxMenuItem *cur;
wxString name; wxString name;
const wxLanguageInfo *info; const wxLanguageInfo *info;
// Insert "Disable"
cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS,_("Disable"));
if (curLang.IsEmpty()) cur->Check();
// Each language found
for (unsigned int i=0;i<langs.Count();i++) { for (unsigned int i=0;i<langs.Count();i++) {
info = wxLocale::FindLanguageInfo(langs[i]); info = wxLocale::FindLanguageInfo(langs[i]);
if (info) name = info->Description; if (info) name = info->Description;
else name = langs[i]; else name = langs[i];
cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS+i,name); cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS+i+1,name);
if (langs[i] == curLang) cur->Check(); if (langs[i] == curLang) cur->Check();
} }
// Append language list
menu.AppendSubMenu(languageMenu,_("Spell checker language")); menu.AppendSubMenu(languageMenu,_("Spell checker language"));
}
else menu.Append(EDIT_MENU_DIC_LANGUAGE,_("No dictionaries available"))->Enable(false);
menu.AppendSeparator(); menu.AppendSeparator();
} }
@ -590,7 +596,7 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) {
// Language list // Language list
wxArrayString langs = thesaurus->GetLanguageList(); // This probably should be cached... wxArrayString langs = thesaurus->GetLanguageList(); // This probably should be cached...
if (langs.Count()) {
// Current language // Current language
wxString curLang = Options.AsText(_T("Thesaurus language")); wxString curLang = Options.AsText(_T("Thesaurus language"));
@ -599,18 +605,22 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) {
wxMenuItem *cur; wxMenuItem *cur;
wxString name; wxString name;
const wxLanguageInfo *info; const wxLanguageInfo *info;
// Insert "Disable"
cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS,_("Disable"));
if (curLang.IsEmpty()) cur->Check();
// Each language found
for (unsigned int i=0;i<langs.Count();i++) { for (unsigned int i=0;i<langs.Count();i++) {
info = wxLocale::FindLanguageInfo(langs[i].Mid(3)); info = wxLocale::FindLanguageInfo(langs[i]);
if (info) name = info->Description; if (info) name = info->Description;
else name = langs[i]; else name = langs[i];
cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS+i,name); cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS+i+1,name);
if (langs[i].Mid(3) == curLang) cur->Check(); if (langs[i] == curLang) cur->Check();
} }
menu.AppendSubMenu(languageMenu,_("Thesaurus language"));
}
else menu.Append(EDIT_MENU_THES_LANGUAGE,_("No thesauruses available"))->Enable(false);
// Separator // Append language list
menu.AppendSubMenu(languageMenu,_("Thesaurus language"));
menu.AppendSeparator(); menu.AppendSeparator();
} }
@ -832,9 +842,11 @@ void SubsTextEditCtrl::OnSetDicLanguage(wxCommandEvent &event) {
wxArrayString langs = spellchecker->GetLanguageList(); wxArrayString langs = spellchecker->GetLanguageList();
// Set dictionary // Set dictionary
int index = event.GetId() - EDIT_MENU_DIC_LANGS; int index = event.GetId() - EDIT_MENU_DIC_LANGS - 1;
spellchecker->SetLanguage(langs[index]); wxString lang;
Options.SetText(_T("Spell checker language"),langs[index]); if (index >= 0) lang = langs[index];
spellchecker->SetLanguage(lang);
Options.SetText(_T("Spell checker language"),lang);
Options.Save(); Options.Save();
// Update styling // Update styling
@ -849,9 +861,11 @@ void SubsTextEditCtrl::OnSetThesLanguage(wxCommandEvent &event) {
wxArrayString langs = thesaurus->GetLanguageList(); wxArrayString langs = thesaurus->GetLanguageList();
// Set language // Set language
int index = event.GetId() - EDIT_MENU_THES_LANGS; int index = event.GetId() - EDIT_MENU_THES_LANGS - 1;
thesaurus->SetLanguage(langs[index]); wxString lang;
Options.SetText(_T("Thesaurus language"),langs[index]); if (index >= 0) lang = langs[index];
thesaurus->SetLanguage(lang);
Options.SetText(_T("Thesaurus language"),lang);
Options.Save(); Options.Save();
// Update styling // Update styling

View file

@ -110,7 +110,9 @@ wxArrayString MySpellThesaurus::GetLanguageList() {
// Found match // Found match
if (curdat == dat[j]) { if (curdat == dat[j]) {
wxFileName fname(curdat); wxFileName fname(curdat);
list.Add(fname.GetName()); wxString name = fname.GetName();
if (name.Left(3) == _T("th_")) name = name.Mid(3);
list.Add(name);
break; break;
} }
} }
@ -124,6 +126,15 @@ wxArrayString MySpellThesaurus::GetLanguageList() {
//////////////// ////////////////
// Set language // Set language
void MySpellThesaurus::SetLanguage(wxString language) { void MySpellThesaurus::SetLanguage(wxString language) {
// Unload
delete mythes;
mythes = NULL;
delete conv;
conv = NULL;
// Unloading
if (language.IsEmpty()) return;
// Get dir name // Get dir name
wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/");
@ -134,12 +145,6 @@ void MySpellThesaurus::SetLanguage(wxString language) {
// Check if language is available // Check if language is available
if (!wxFileExists(idxpath) || !wxFileExists(datpath)) return; if (!wxFileExists(idxpath) || !wxFileExists(datpath)) return;
// Unload
delete mythes;
mythes = NULL;
delete conv;
conv = NULL;
// Load // Load
mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal)); mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal));
conv = NULL; conv = NULL;