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
if (wxDisplay::GetCount() < 1) CentreOnParent();
else {
// Get display number
int point = wxDisplay::GetFromPoint(parent->GetScreenPosition());
if (point == wxNOT_FOUND) point = 0;
// Get display size
wxDisplay display(point);
wxRect dr = display.GetGeometry();
// Calculate position and center it there
wxRect window = GetScreenRect();
window = window.CenterIn(dr);
Move(window.GetLeft(),window.GetTop());

View file

@ -158,6 +158,15 @@ wxArrayString HunspellSpellChecker::GetLanguageList() {
////////////////
// Set language
void HunspellSpellChecker::SetLanguage(wxString language) {
// Unload
delete hunspell;
hunspell = NULL;
delete conv;
conv = NULL;
// Unloading
if (language.IsEmpty()) return;
// Get dir name
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
if (!wxFileExists(affpath) || !wxFileExists(dicpath)) return;
// Unload
delete hunspell;
hunspell = NULL;
delete conv;
conv = NULL;
// Load
hunspell = new Hunspell(affpath.mb_str(wxConvLocal),dicpath.mb_str(wxConvLocal));
conv = NULL;

View file

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

View file

@ -110,7 +110,9 @@ wxArrayString MySpellThesaurus::GetLanguageList() {
// Found match
if (curdat == dat[j]) {
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;
}
}
@ -124,6 +126,15 @@ wxArrayString MySpellThesaurus::GetLanguageList() {
////////////////
// Set language
void MySpellThesaurus::SetLanguage(wxString language) {
// Unload
delete mythes;
mythes = NULL;
delete conv;
conv = NULL;
// Unloading
if (language.IsEmpty()) return;
// Get dir name
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
if (!wxFileExists(idxpath) || !wxFileExists(datpath)) return;
// Unload
delete mythes;
mythes = NULL;
delete conv;
conv = NULL;
// Load
mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal));
conv = NULL;