mirror of https://github.com/odrling/Aegisub
More menu work, and removed ancient aspell code
Originally committed to SVN as r637.
This commit is contained in:
parent
2302713ec1
commit
3a24974e0b
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 2005, Ghassan Nassar
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
///////////
|
||||
//Includes
|
||||
#include "setup.h"
|
||||
#if USE_ASPELL == 1
|
||||
#include "aspell_wrap.h"
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Aspell Constructor
|
||||
AspellWrapper::AspellWrapper(void) {
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Aspell destructor
|
||||
AspellWrapper::~AspellWrapper(void) {
|
||||
Unload();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Load Aspell-15.dll
|
||||
void AspellWrapper::Load() {
|
||||
if (!loaded) {
|
||||
hLib=LoadLibrary(L"aspell-15.dll");
|
||||
if (hLib == NULL) {
|
||||
throw L"Could not load aspell.dll";
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Unloads Aspell-15.dll
|
||||
void AspellWrapper::Unload() {
|
||||
if (loaded) {
|
||||
//delete_aspell_config();
|
||||
FreeLibrary(hLib);
|
||||
loaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// Declare global
|
||||
AspellWrapper Aspell;
|
||||
|
||||
#endif
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) 2005, Ghassan Nassar
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
#include "setup.h"
|
||||
#if USE_ASPELL == 1
|
||||
|
||||
#pragma once
|
||||
|
||||
//////////
|
||||
// Headers
|
||||
extern "C" {
|
||||
#include <aspell.h>
|
||||
}
|
||||
#include <windows.h>
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
class AspellWrapper
|
||||
{
|
||||
public:
|
||||
AspellWrapper(void);
|
||||
~AspellWrapper(void);
|
||||
void Load();
|
||||
void Unload();
|
||||
private:
|
||||
void Initiate();
|
||||
bool loaded;
|
||||
HINSTANCE hLib;
|
||||
//wxMutex AviSynthMutex; //ehhhh? Sempahores?
|
||||
|
||||
};
|
||||
|
||||
extern AspellWrapper Aspell;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,581 +0,0 @@
|
|||
// Copyright (c) 2005, Ghassan Nassar
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#include "setup.h"
|
||||
#if USE_ASPELL == 1
|
||||
#include "aspell_wrap.h"
|
||||
#include "main.h"
|
||||
#include "dialog_spellcheck.h"
|
||||
#include "aspell_wrap.h"
|
||||
#include <wx\file.h>
|
||||
#include <wx\filename.h>
|
||||
#include <wx\dir.h>
|
||||
|
||||
|
||||
DialogSpellCheck::DialogSpellCheck (wxWindow *parent, AssFile *_subs, wxArrayInt* selList, SubtitlesGrid *_grid)
|
||||
: wxDialog (parent,-1,_T("Document Spell Checker"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogSpellCheck"))
|
||||
{
|
||||
// Suggestions
|
||||
wxSizer *SuggestionBox = new wxStaticBoxSizer(wxVERTICAL,this,_T("ErrorBox"));
|
||||
Textbox = new wxTextCtrl(this, TEXTBOX_LINE, _T(""), wxDefaultPosition, wxSize(185,55), wxTE_RICH2 | wxTE_WORDWRAP, wxDefaultValidator, _T("Displayed Line"));
|
||||
SuggestionsList = new wxListBox(this, LIST_SUGGESTIONS, wxDefaultPosition, wxSize(185,95), 0, NULL, wxLB_SINGLE | wxLB_SORT, wxDefaultValidator, _T("Suggestions"));
|
||||
SuggestionBox->Add(Textbox,0,wxRIGHT,5);
|
||||
SuggestionBox->AddSpacer(5);
|
||||
SuggestionBox->Add(SuggestionsList,1,wxEXPAND | wxRIGHT | wxALIGN_RIGHT,5);
|
||||
|
||||
//// RButtons styles list
|
||||
wxSizer *RButtons = new wxStaticBoxSizer(wxVERTICAL, this, _T("Extra Commands"));
|
||||
SkipError = new wxButton(this, BUTTON_SKIP, _T("Skip this error"), wxDefaultPosition, wxSize(80,25), 0, wxDefaultValidator, _T("Skip This Error"));
|
||||
AddtoCustomDic = new wxButton(this, BUTTON_ADDCUSTOM, _T("Add to Dict."), wxDefaultPosition, wxSize(80,25), 0, wxDefaultValidator, _T("Add To Custom Dictionary"));
|
||||
Options = new wxButton(this, BUTTON_PREFERENCES, _T("Options"), wxDefaultPosition, wxSize(80,25), 0, wxDefaultValidator, _T("Preferences"));
|
||||
|
||||
RButtons->AddSpacer(20);
|
||||
RButtons->Add(SkipError,0, wxALL | wxALIGN_CENTER_VERTICAL,0);
|
||||
RButtons->AddSpacer(20);
|
||||
RButtons->Add(AddtoCustomDic,0, wxALL | wxALIGN_CENTER_VERTICAL,0);
|
||||
RButtons->AddSpacer(20);
|
||||
RButtons->Add(Options,0, wxALL | wxALIGN_CENTER_VERTICAL,0);
|
||||
RButtons->AddSpacer(20);
|
||||
|
||||
////Lower Buttons
|
||||
wxSizer *LButtons = new wxBoxSizer(wxHORIZONTAL);
|
||||
AcceptSuggestion = new wxButton(this, BUTTON_ACCEPT, _T("Accept Suggestion"), wxDefaultPosition, wxSize(100,20), 0, wxDefaultValidator, _T("Accept"));
|
||||
Exit = new wxButton(this, BUTTON_EXIT, _T("Exit"), wxDefaultPosition, wxSize(100,20), 0, wxDefaultValidator, _T("Exit"));
|
||||
|
||||
LButtons->AddSpacer(30);
|
||||
LButtons->Add(AcceptSuggestion,0, wxALL | wxALIGN_CENTER_HORIZONTAL ,0);
|
||||
LButtons->AddSpacer(30);
|
||||
LButtons->Add(Exit,0, wxALL | wxALIGN_CENTER_HORIZONTAL,0);
|
||||
LButtons->AddSpacer(30);
|
||||
|
||||
//// TOP General layout
|
||||
wxSizer *MBox = new wxBoxSizer(wxHORIZONTAL);
|
||||
MBox->Add(SuggestionBox,0,wxRIGHT,5);
|
||||
MBox->Add(RButtons,0,wxLEFT,5);
|
||||
|
||||
//wxButton *CloseButton = new wxButton(this, wxID_CLOSE, _T(""), wxDefaultPosition, wxSize(100,25), 0, wxDefaultValidator, _T("Close"));
|
||||
MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
MainSizer->Add(MBox ,0,wxEXPAND | wxLEFT | wxRIGHT | wxTOP,5);
|
||||
LButtons->AddSpacer(5);
|
||||
MainSizer->Add(LButtons,0,wxEXPAND | wxLEFT | wxRIGHT |wxTOP ,5);
|
||||
//MainSizer->Add(CloseButton,0,wxBOTTOM | wxALIGN_CENTER,5);
|
||||
|
||||
//// Set sizer
|
||||
SetSizer(MainSizer);
|
||||
MainSizer->SetSizeHints(this);
|
||||
|
||||
subs = _subs;
|
||||
grid = _grid;
|
||||
lnList = *selList;
|
||||
|
||||
aspellConfig = NULL;
|
||||
aspellSpeller = NULL;
|
||||
aspellChecker = NULL;
|
||||
|
||||
InitSpellCheck();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
DialogSpellCheck::~DialogSpellCheck(void)
|
||||
{
|
||||
if (pDictionaryChanged) {
|
||||
if (wxYES == ::wxMessageBox(_T("Would you like to save any of your changes to your personal dictionary?"), _T("Save Changes"), wxYES_NO | wxICON_QUESTION))
|
||||
aspell_speller_save_all_word_lists(aspellSpeller);
|
||||
}
|
||||
|
||||
if (aspellChecker != NULL)
|
||||
delete_aspell_document_checker(aspellChecker);
|
||||
|
||||
if (aspellConfig != NULL)
|
||||
delete_aspell_config(aspellConfig);
|
||||
|
||||
if (aspellSpeller != NULL)
|
||||
delete_aspell_speller(aspellSpeller);
|
||||
|
||||
Aspell.Unload();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DialogSpellCheck::SetOptions(wxString Option,wxString Value){
|
||||
|
||||
if (aspellConfig == NULL)
|
||||
aspellConfig = new_aspell_config();
|
||||
|
||||
if (aspellConfig == NULL)
|
||||
return FALSE;
|
||||
|
||||
aspell_config_replace(aspellConfig, Option.mb_str(wxConvUTF8), Value.mb_str(wxConvUTF8));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DialogSpellCheck::SetDefaultOptions(){
|
||||
|
||||
wxString defaultDataDir = AegisubApp::folderName;
|
||||
defaultDataDir.Append(_T("data\\"));
|
||||
wxString defaultDictDir = AegisubApp::folderName;
|
||||
defaultDictDir.Append(_T("dict\\"));
|
||||
|
||||
if (wxDir::Exists(defaultDataDir)) //&& wxDir::Exists(defaultDictDir))
|
||||
{
|
||||
|
||||
SetOptions(wxString(_T("encoding")), _T("utf-8"));
|
||||
SetOptions(wxString(_T("lang")), wxString(_T("en-US"))); //1*
|
||||
SetOptions(wxString(_T("data-dir")), defaultDataDir);
|
||||
SetOptions(wxString(_T("dict-dir")), defaultDataDir); //defaultDictDir
|
||||
SetOptions(wxString(_T("local-data-dir")), defaultDataDir);
|
||||
}
|
||||
|
||||
wxString l2Checka = defaultDataDir;
|
||||
l2Checka.Append( _T("\\en.dat"));
|
||||
wxString l2Checkb = defaultDataDir; // Set to the same place for now. It's regularily in two folders.
|
||||
l2Checkb.Append(_T("\\en_phonet.dat"));
|
||||
|
||||
if (!wxFile::Exists(l2Checka) || !wxFile::Exists(l2Checkb))
|
||||
{
|
||||
wxMessageBox(_T("The Files: \"en.dat\" and \"en_phonet.dat\", in \".\\data\" are necessary for proper execution. \nProcess will continue, but with **unpredicable** execution. \nFix: Reinstall Dictionaries."), _T("Warning"),wxICON_EXCLAMATION | wxOK | wxSTAY_ON_TOP);
|
||||
// 2
|
||||
|
||||
}
|
||||
|
||||
if (aspell_config_error(aspellConfig) != 0) {
|
||||
wxString A(aspell_config_error_message(aspellConfig),wxConvUTF8);
|
||||
wxMessageBox(wxString::Format(_T("Error: %s\n"), A) , _T("Warning"),wxICON_ERROR | wxOK | wxSTAY_ON_TOP);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DialogSpellCheck::Uninit(){
|
||||
Aspell.Unload(); // Here for when I get it dynamically linked.
|
||||
return true; // this is useless for now, but not in the future.
|
||||
}
|
||||
|
||||
void DialogSpellCheck::UILock(bool enable){
|
||||
if (enable)
|
||||
{
|
||||
SkipError->Enable(false);
|
||||
AcceptSuggestion->Enable(false);
|
||||
AddtoCustomDic->Enable(false);
|
||||
SuggestionsList->Enable(false);
|
||||
Textbox->Enable(false);
|
||||
}
|
||||
else{
|
||||
SkipError->Enable(true);
|
||||
AcceptSuggestion->Enable(true);
|
||||
AddtoCustomDic->Enable(true);
|
||||
SuggestionsList->Enable(true);
|
||||
Textbox->Enable(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogSpellCheck::LineSetUp(){
|
||||
|
||||
bool alt = false;
|
||||
if (lnList.GetCount() > 0)
|
||||
if (lnList.Item(0) == -1)
|
||||
alt = true;
|
||||
|
||||
if ((lnList.GetCount() == 0) || (alt == true)) {
|
||||
start = 0;
|
||||
end = grid->GetRows() - 1;
|
||||
curLineNumber = 0;
|
||||
current_line = grid->GetDialogue(curLineNumber);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
curLineNumber = lnList.Item(0);
|
||||
lnList.RemoveAt(0,1);
|
||||
current_line = grid->GetDialogue(curLineNumber);
|
||||
start = -1;
|
||||
end = -1;
|
||||
return;
|
||||
}
|
||||
// something went drastically wrong...
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool DialogSpellCheck::IncLines(){ // Used for lines 1+, line 0 is handled by LineSetUp
|
||||
//if (a) return false; // used as an aux check for end of line.
|
||||
|
||||
if ((start == -1) && (end == -1)){
|
||||
if (lnList.GetCount() > 0) {
|
||||
curLineNumber = lnList.Item(0);
|
||||
lnList.RemoveAt(0,1);
|
||||
current_line = grid->GetDialogue(curLineNumber);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (start == 0){
|
||||
if (curLineNumber < end){
|
||||
curLineNumber++;
|
||||
current_line = grid->GetDialogue(curLineNumber);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false; // shouldnt every really happen but vs stops yelling about it.
|
||||
}
|
||||
|
||||
|
||||
void DialogSpellCheck::Stage0(){ // Stage 0, used intially.
|
||||
LineSetUp();
|
||||
if (!LineComputation())
|
||||
return;
|
||||
LineBegin();
|
||||
Stage2();
|
||||
}
|
||||
|
||||
|
||||
void DialogSpellCheck::Stage1(){ // Stage 1, used after stage 0 is initiated.
|
||||
if (!LineComputation()){
|
||||
if (!IncLines()){
|
||||
UILock(true);//init lines.
|
||||
return;
|
||||
}
|
||||
}
|
||||
LineBegin();
|
||||
Stage2();
|
||||
}
|
||||
|
||||
void DialogSpellCheck::Stage2(){ // Stage 2, rather useless to be honest but, it makes things clear.
|
||||
Precheck(); // Repeat here till line is checked.
|
||||
}
|
||||
|
||||
void DialogSpellCheck::Stage3(){ // Stage 3: Kill things that need to be killed find next line and continue.
|
||||
LineEnd();
|
||||
Stage1();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool DialogSpellCheck::Precheck()
|
||||
{
|
||||
/* Using Document Checker and Settings previously set, find errors in the line. Also check if the word was told to be ignored.*/
|
||||
if ((token = aspell_document_checker_next_misspelling(aspellChecker), token.len != 0)){
|
||||
token.offset += nDiff;
|
||||
const wxString misspelling = current_block.Mid(token.offset, token.len);
|
||||
misspelled_word = misspelling;
|
||||
if (lIgnore.Index(misspelling) != wxNOT_FOUND) // implement button to actually DO this.
|
||||
return true;
|
||||
Populate(misspelling);
|
||||
UILock(false);
|
||||
}
|
||||
else {
|
||||
Stage3();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DialogSpellCheck::Populate(wxString misspelling){
|
||||
Textbox->Clear();
|
||||
Textbox->AppendText(current_block);
|
||||
int c_start = current_block.Find(misspelling);
|
||||
Textbox->SetStyle(c_start, c_start + misspelling.Length(), wxTextAttr(*wxRED, wxNullColour, wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, _T(""), wxFONTENCODING_DEFAULT) ));
|
||||
|
||||
SuggestionsList->Clear();
|
||||
SuggestionsList->InsertItems(GetSuggestions(misspelling),0);
|
||||
}
|
||||
|
||||
void DialogSpellCheck::LineEnd(){
|
||||
nLine = false;
|
||||
nDiff = 0;
|
||||
token.len = 0;
|
||||
token.offset = 0;
|
||||
delete_aspell_document_checker(aspellChecker);
|
||||
aspellChecker = NULL;
|
||||
UILock(true);
|
||||
}
|
||||
|
||||
bool DialogSpellCheck::LineBegin(){
|
||||
if (aspellSpeller == NULL)
|
||||
return false;
|
||||
AspellCanHaveError* ret = new_aspell_document_checker(aspellSpeller);
|
||||
if (aspell_error(ret) != 0) {
|
||||
wxString A(aspell_error_message(ret),wxConvUTF8);
|
||||
wxMessageBox(wxString::Format(_T("Error: %s\n"), A));
|
||||
return false;
|
||||
}
|
||||
aspellChecker = to_aspell_document_checker(ret);
|
||||
aspell_document_checker_process(aspellChecker , current_block.mb_str(wxConvUTF8), -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
wxArrayString DialogSpellCheck::GetSuggestions(wxString strMisspelledWord)
|
||||
{
|
||||
const char * suggest;
|
||||
const wxString * misspelling = &strMisspelledWord;
|
||||
wxArrayString wxStringList;
|
||||
const AspellWordList * suggestions = aspell_speller_suggest(aspellSpeller, misspelling->mb_str(wxConvUTF8), misspelling->Length());
|
||||
AspellStringEnumeration * elements = aspell_word_list_elements(suggestions);
|
||||
wxStringList.IsEmpty();
|
||||
while ( (suggest = aspell_string_enumeration_next(elements)) != NULL ){
|
||||
wxString StringADD(suggest,wxConvUTF8);
|
||||
wxStringList.Add(StringADD);
|
||||
}
|
||||
delete_aspell_string_enumeration(elements);
|
||||
return wxStringList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
wxArrayString DialogSpellCheck::GetWordListAsArray(){
|
||||
const char * suggested;
|
||||
wxArrayString wxStringList;
|
||||
const AspellWordList* PersonalWordList = aspell_speller_personal_word_list(aspellSpeller);
|
||||
AspellStringEnumeration* elements = aspell_word_list_elements(PersonalWordList);
|
||||
wxStringList.IsEmpty();
|
||||
while ( (suggested = aspell_string_enumeration_next(elements)) != NULL ){
|
||||
wxString StringADD(suggested,wxConvUTF8);
|
||||
wxStringList.Add(StringADD);
|
||||
}
|
||||
delete_aspell_string_enumeration(elements);
|
||||
return wxStringList;
|
||||
}
|
||||
|
||||
int DialogSpellCheck::AddWordToDictionary(wxString strWord){
|
||||
const wxString * correctterm = &strWord;
|
||||
aspell_speller_add_to_personal(aspellSpeller, correctterm->mb_str(wxConvUTF8), strWord.Length());
|
||||
pDictionaryChanged = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void DialogSpellCheck::InitSpellCheck(){
|
||||
|
||||
nLine = false;
|
||||
curLineNumber = 0;
|
||||
curBlockNumber = -1;
|
||||
start = -1;
|
||||
end = -1;
|
||||
pDictionaryChanged = false;
|
||||
token.len = 0;
|
||||
token.offset = 0;
|
||||
nDiff = 0;
|
||||
|
||||
UILock(false);
|
||||
|
||||
Aspell.Load();
|
||||
|
||||
if (aspellConfig == NULL)
|
||||
aspellConfig = new_aspell_config();
|
||||
|
||||
if (aspellConfig == NULL){
|
||||
wxMessageBox(_T("Critical Error! Config Settings Are Not Present."));
|
||||
UILock(true); // Forces the user to exit.
|
||||
return;
|
||||
|
||||
}
|
||||
SetDefaultOptions();
|
||||
|
||||
AspellCanHaveError* ret = new_aspell_speller(aspellConfig);
|
||||
if (aspell_error(ret) != 0){
|
||||
wxString A(aspell_error_message(ret),wxConvUTF8);
|
||||
wxMessageBox(wxString::Format(_T("Error: %s\n"), A));
|
||||
delete_aspell_can_have_error(ret);
|
||||
UILock(true); // Forces the user to exit.
|
||||
return;
|
||||
}
|
||||
aspellSpeller = to_aspell_speller(ret);
|
||||
Stage0();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(DialogSpellCheck, wxEvtHandler)
|
||||
EVT_BUTTON(wxID_CLOSE, DialogSpellCheck::OnClose)
|
||||
EVT_BUTTON(BUTTON_ACCEPT, DialogSpellCheck::OnAccept)
|
||||
EVT_BUTTON(BUTTON_EXIT, DialogSpellCheck::OnExit)
|
||||
EVT_BUTTON(BUTTON_PREFERENCES, DialogSpellCheck::OnOptions)
|
||||
EVT_BUTTON(BUTTON_SKIP, DialogSpellCheck::OnSkip)
|
||||
EVT_BUTTON(BUTTON_ADDCUSTOM, DialogSpellCheck::OnAdd)
|
||||
EVT_LISTBOX_DCLICK(LIST_SUGGESTIONS, DialogSpellCheck::OnListDoubleClick)
|
||||
EVT_TEXT(TEXTBOX_LINE, DialogSpellCheck::OnTextChange)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
/////////
|
||||
//EVENTS
|
||||
|
||||
void DialogSpellCheck::OnClose (wxCommandEvent &event) {
|
||||
if ((Textbox->GetValue() != current_block) && (Textbox->GetValue() != _T(""))) {
|
||||
wxMessageDialog Question(this, _T(
|
||||
"You've selected:Exit. Yet, the current line has not yet been saved. Would you like to save the changes?"),
|
||||
_T("Exit Warning"),
|
||||
wxICON_QUESTION | wxSTAY_ON_TOP | wxYES_NO | wxYES_DEFAULT,
|
||||
wxDefaultPosition);
|
||||
|
||||
int a = Question.ShowModal();
|
||||
if (a == wxID_YES){
|
||||
BlockStore();
|
||||
}
|
||||
}
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnAccept (wxCommandEvent &event) {
|
||||
if (AcceptSuggestion->GetLabel() != _T("Replace w\\ Edit?"))
|
||||
ComputeAction(ACTION_ACCEPT);
|
||||
else
|
||||
ComputeAction(ACTION_USER_CUSTOM);
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnExit (wxCommandEvent &event) {
|
||||
if ((Textbox->GetValue() != current_block) && (Textbox->GetValue() != _T(""))) {
|
||||
wxMessageDialog Question(this, _T(
|
||||
"You've selected:Exit. Yet, the current line has not yet been saved. Would you like to save the changes?"),
|
||||
_T("Exit Warning"),
|
||||
wxICON_QUESTION | wxSTAY_ON_TOP | wxYES_NO | wxYES_DEFAULT,
|
||||
wxDefaultPosition);
|
||||
|
||||
int a = Question.ShowModal();
|
||||
if (a == wxID_YES){
|
||||
BlockStore();
|
||||
}
|
||||
}
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnOptions (wxCommandEvent &event) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnSkip (wxCommandEvent &event) {
|
||||
ComputeAction(ACTION_SKIP);
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnAdd (wxCommandEvent &event) {
|
||||
ComputeAction(ACTION_ADD);
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnListDoubleClick (wxCommandEvent &event) {
|
||||
ComputeAction(ACTION_ACCEPT);
|
||||
}
|
||||
|
||||
void DialogSpellCheck::OnTextChange (wxCommandEvent &event) {
|
||||
if (Textbox->GetValue() != current_block)
|
||||
AcceptSuggestion->SetLabel(_T("Replace w\\ Edit?"));
|
||||
else
|
||||
AcceptSuggestion->SetLabel(_T("Accept Suggestion"));
|
||||
}
|
||||
|
||||
|
||||
void DialogSpellCheck::ComputeAction(int action) {
|
||||
const wxString correct_word = (SuggestionsList->GetSelection() == wxNOT_FOUND) ? _T("") : SuggestionsList->GetString(SuggestionsList->GetSelection());
|
||||
|
||||
if ((SuggestionsList->GetSelection() == wxNOT_FOUND) && (action == ACTION_ACCEPT))
|
||||
return;
|
||||
const wxString misspelling = misspelled_word;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_ACCEPT:
|
||||
nDiff += correct_word.Length() - token.len; // Let the spell checker know what the correct replacement was
|
||||
aspell_speller_store_replacement(aspellSpeller, misspelling.mb_str(wxConvUTF8), token.len, correct_word.mb_str(wxConvUTF8), correct_word.Length());
|
||||
current_block.replace(token.offset, token.len, correct_word);// Replace the misspelled word with the replacement */
|
||||
BlockStore();
|
||||
Textbox->Clear();
|
||||
Textbox->AppendText(current_block);
|
||||
UILock(true);
|
||||
break;
|
||||
case ACTION_SKIP:
|
||||
break;
|
||||
case ACTION_ADD:
|
||||
AddWordToDictionary(misspelled_word);
|
||||
break;
|
||||
case ACTION_USER_CUSTOM:
|
||||
current_block = Textbox->GetValue();
|
||||
BlockStore();
|
||||
Textbox->Clear();
|
||||
Textbox->AppendText(current_block);
|
||||
curBlockNumber--;
|
||||
token.len = 0;
|
||||
token.offset = 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Stage2();
|
||||
}
|
||||
|
||||
bool DialogSpellCheck::LineComputation() {
|
||||
AssDialogueBlockPlain *curPlain;
|
||||
current_line->ParseASSTags();
|
||||
size_t size_blocks = current_line->Blocks.size();
|
||||
for (size_t i=(curBlockNumber+1);i<size_blocks;i++) {
|
||||
curPlain = AssDialogueBlock::GetAsPlain(current_line->Blocks.at(i));
|
||||
if (curPlain) {
|
||||
current_block = curPlain->GetText();
|
||||
curBlockNumber = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
curPlain = 0;
|
||||
curBlockNumber = -1;
|
||||
current_line->ClearBlocks();
|
||||
return false;
|
||||
}
|
||||
|
||||
void DialogSpellCheck::BlockStore() {
|
||||
current_line->ParseASSTags();
|
||||
AssDialogueBlockPlain *curPlain = AssDialogueBlock::GetAsPlain(current_line->Blocks.at(curBlockNumber));
|
||||
if (curPlain) {
|
||||
curPlain->text = current_block;
|
||||
current_line->UpdateText();
|
||||
current_line->UpdateData();
|
||||
subs->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
}
|
||||
curPlain = 0;
|
||||
current_line->ClearBlocks();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,176 +0,0 @@
|
|||
// Copyright (c) 2005, Ghassan Nassar
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#include "setup.h"
|
||||
#if USE_ASPELL == 1
|
||||
|
||||
#pragma once
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
extern "C" {
|
||||
#include <aspell.h>
|
||||
}
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "subs_grid.h"
|
||||
|
||||
// Z:\SVN\Aspell\lib\libaspell-15-dll.lib
|
||||
|
||||
#ifndef DIALOG_SPELL_CHECK_H
|
||||
#define DIALOG_SPELL_CHECK_H
|
||||
|
||||
class wxArrayInt;
|
||||
|
||||
class DialogSpellCheck : public wxDialog {
|
||||
|
||||
public:
|
||||
DialogSpellCheck (wxWindow *parent, AssFile *_subs, wxArrayInt* selList, SubtitlesGrid *_grid);
|
||||
~DialogSpellCheck(void);
|
||||
private:
|
||||
|
||||
////////////
|
||||
// Privates
|
||||
|
||||
|
||||
|
||||
/////
|
||||
//UI
|
||||
wxSizer *MainSizer;
|
||||
wxTextCtrl *Textbox;
|
||||
wxListBox *SuggestionsList;
|
||||
wxButton *AddtoCustomDic; //
|
||||
wxButton *AcceptSuggestion; //
|
||||
wxButton *SkipError; //
|
||||
wxButton *Exit; //
|
||||
wxButton *Options; //
|
||||
|
||||
SubtitlesGrid *grid;
|
||||
wxArrayInt lnList;
|
||||
|
||||
// Dealing with Subs
|
||||
AssFile *subs;
|
||||
AssDialogue * current_line; //depreciated (sorta?)
|
||||
|
||||
// Aspell:
|
||||
AspellToken token;
|
||||
AspellConfig * aspellConfig;
|
||||
AspellSpeller* aspellSpeller;
|
||||
AspellDocumentChecker* aspellChecker;
|
||||
bool pDictionaryChanged;
|
||||
wxArrayString lIgnore;
|
||||
wxArrayString sList;
|
||||
wxString strReplacementText;
|
||||
wxString misspelled_word;
|
||||
|
||||
//Internals
|
||||
int start;
|
||||
int end;
|
||||
int nDiff;
|
||||
int curLineNumber;
|
||||
size_t curBlockNumber;
|
||||
bool nLine;
|
||||
wxString current_block;
|
||||
|
||||
|
||||
//
|
||||
//Functions
|
||||
//
|
||||
void Stage0();
|
||||
void Stage1();
|
||||
void Stage2();
|
||||
void Stage3();
|
||||
|
||||
bool IncLines(); /* Incremenet lines */
|
||||
void LineSetUp(); /* First Run Operation Deals With User Selection */
|
||||
bool LineComputation(); /* Returns Block Text To Edit */
|
||||
bool SetDefaultOptions(); /* Sets MY Aspell Default Options. TODO Make user able to set optinos */
|
||||
bool SetOptions(wxString Option,wxString Value); /* Sets Options Generic Function */
|
||||
void InitSpellCheck(); /* First Run Operation Deals With Variable Set up */
|
||||
bool Uninit(); /*Future Usage */
|
||||
void LineEnd(); /*Run At End Of Lines, Cleans up. */
|
||||
bool LineBegin(); /*Run At Line Begining. Sets up variables */
|
||||
bool Precheck(); /*Not Really Pre anymore, it does the work. */
|
||||
void Populate(wxString misspelling); /* Populate Gui. */
|
||||
void UILock(bool enable); /* Lock Interface */
|
||||
void ComputeAction(int action); /* Send Enum, Do Work. Does most of the On* calls. */
|
||||
int AddWordToDictionary(wxString strWord); /*Adds word to dictionary */
|
||||
wxArrayString GetSuggestions(wxString strMisspelledWord); /*Gets suggestions for misspelled word */
|
||||
wxArrayString GetWordListAsArray(); /*Same as above... legacy code marked to be removed. */
|
||||
void BlockStore(); /* Save Changes. */
|
||||
|
||||
|
||||
/////
|
||||
//Events
|
||||
void OnClose (wxCommandEvent &event);
|
||||
void OnAccept (wxCommandEvent &event);
|
||||
void OnOptions (wxCommandEvent &event);
|
||||
void OnExit (wxCommandEvent &event);
|
||||
void OnSkip (wxCommandEvent &event);
|
||||
void OnAdd (wxCommandEvent &event);
|
||||
void OnListDoubleClick (wxCommandEvent &event);
|
||||
void OnTextChange(wxCommandEvent &event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
|
||||
enum actioncodes {
|
||||
ACTION_ACCEPT = 1,
|
||||
ACTION_SKIP,
|
||||
ACTION_ADD,
|
||||
ACTION_EXIT,
|
||||
ACTION_USER_CUSTOM,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
///////
|
||||
// IDs
|
||||
enum {
|
||||
BUTTON_EXIT = 100,
|
||||
BUTTON_ACCEPT,
|
||||
BUTTON_SKIP,
|
||||
BUTTON_ADDCUSTOM,
|
||||
BUTTON_PREFERENCES,
|
||||
LIST_SUGGESTIONS,
|
||||
TEXTBOX_LINE
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -41,6 +41,7 @@
|
|||
#include <wx/mimetype.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/image.h>
|
||||
#include "subs_grid.h"
|
||||
#include "frame_main.h"
|
||||
#include "avisynth_wrap.h"
|
||||
|
@ -59,7 +60,6 @@
|
|||
#include "dialog_tip.h"
|
||||
#include "automation_filter.h"
|
||||
#include "audio_box.h"
|
||||
#include "dialog_spellcheck.h"
|
||||
#include "video_box.h"
|
||||
#include "drop.h"
|
||||
#include "hotkeys.h"
|
||||
|
@ -80,6 +80,10 @@ FrameMain::FrameMain (wxArrayString args)
|
|||
blockAudioLoad = false;
|
||||
blockAudioLoad = false;
|
||||
|
||||
// Create PNG handler
|
||||
wxPNGHandler *png = new wxPNGHandler;
|
||||
wxImage::AddHandler(png);
|
||||
|
||||
// Create menu and tool bars
|
||||
InitToolbar();
|
||||
InitMenu();
|
||||
|
@ -190,9 +194,7 @@ void FrameMain::InitToolbar () {
|
|||
Toolbar->AddTool(Menu_Tools_Fonts_Collector,_("Fonts Collector"),wxBITMAP(font_collector_button),_("Open Fonts Collector"));
|
||||
Toolbar->AddTool(Menu_Tools_Resample,_("Resample"),wxBITMAP(resample_toolbutton),_("Resample script resolution"));
|
||||
Toolbar->AddTool(Menu_Tools_Timing_Processor,_("Timing Post-Processor"),wxBITMAP(timing_processor_toolbutton),_("Open Timing Post-processor dialog"));
|
||||
#if USE_ASPELL == 1
|
||||
Toolbar->AddTool(Menu_Tools_SpellCheck,_("Spellchecker"),wxBITMAP(spellcheck_toolbutton),_("Open Spell checker"));
|
||||
#endif
|
||||
Toolbar->AddTool(Menu_Tools_SpellCheck,_("Spell Checker"),wxBITMAP(spellcheck_toolbutton),_("Open Spell checker"));
|
||||
Toolbar->AddSeparator();
|
||||
|
||||
// Misc
|
||||
|
@ -258,7 +260,35 @@ void FrameMain::InitMenu() {
|
|||
|
||||
// Create subtitles menu
|
||||
subtitlesMenu = new wxMenu();
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Edit_Select, _("&Select lines...\t") + Hotkeys.GetText(_T("Select lines")), _("Selects lines based on defined criterea"),wxBITMAP(blank_button));
|
||||
wxMenu *InsertMenu = new wxMenu;
|
||||
wxMenuItem *InsertParent = new wxMenuItem(subtitlesMenu,-1,_("&Insert Lines"),_T(""),wxITEM_NORMAL,InsertMenu);
|
||||
InsertParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE,_("&Before Current"),_T("Inserts a line before current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER,_("&After Current"),_T("Inserts a line after current"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_BEFORE_VIDEO,_("Before Current, at Video Time"),_T("Inserts a line before current, starting at video time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(InsertMenu,MENU_INSERT_AFTER_VIDEO,_("After Current, at Video Time"),_T("Inserts a line after current, starting at video time"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(InsertParent);
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE,_("&Duplicate Lines"),_T("Duplicate the selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_DUPLICATE_NEXT_FRAME,_("&Duplicate and shift by 1 frame"),_T("Duplicate lines and shift by one frame"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
wxMenu *JoinMenu = new wxMenu;
|
||||
wxMenuItem *JoinParent = new wxMenuItem(subtitlesMenu,-1,_("Join Lines"),_T(""),wxITEM_NORMAL,JoinMenu);
|
||||
JoinParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_CONCAT,_("&Concatenate"),_T("Joins selected lines in a single one, concatenating text together"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_REPLACE,_("Keep &First"),_T("Joins selected lines in a single one, keeping text of first and discarding remaining"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(JoinMenu,MENU_JOIN_AS_KARAOKE,_("As &Karaoke"),_T("Joins selected lines in a single one, as karaoke"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(JoinParent);
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SPLIT_BY_KARAOKE,_("Split Lines (by karaoke)"),_T("Uses karaoke timing to split line into multiple smaller lines"),wxBITMAP(blank_button));
|
||||
wxMenu *RecombineMenu = new wxMenu;
|
||||
wxMenuItem *RecombineParent = new wxMenuItem(subtitlesMenu,-1,_("Recombine"),_T(""),wxITEM_NORMAL,RecombineMenu);
|
||||
RecombineParent->SetBitmap(wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_1_12_RECOMBINE,_("Lines (1, 1+2) into (1, 2)"),_T("Recombine subtitles when first one is actually first plus second"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_12_2_RECOMBINE,_("Lines (1+2, 2) into (1, 2)"),_T("Recombine subtitles when second one is actually first plus second"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(RecombineMenu,MENU_1_12_2_RECOMBINE,_("Lines (1, 1+2, 2) into (1, 2)"),_T("Recombine subtitles when middle one is actually first plus second"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->Append(RecombineParent);
|
||||
subtitlesMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_SWAP,_("&Swap Lines"),_T("Swaps the two selected lines"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Edit_Select, _("&Select Lines...\t") + Hotkeys.GetText(_T("Select lines")), _("Selects lines based on defined criterea"),wxBITMAP(blank_button));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Tools_Styles_Manager, _("&Styles Manager..."), _("Open styles manager"), wxBITMAP(style_toolbutton));
|
||||
AppendBitmapMenuItem (subtitlesMenu,Menu_Tools_Styling, _("St&yling Assistant..."), _("Open styling assistant"), wxBITMAP(styling_toolbutton));
|
||||
|
@ -278,6 +308,9 @@ void FrameMain::InitMenu() {
|
|||
AppendBitmapMenuItem(timingMenu,Menu_Subs_Snap_End_To_Video, _("Snap end to video\t") + Hotkeys.GetText(_T("Set End to Video")), _("Set end of selected subtitles to current video frame"), wxBITMAP(subend_to_video));
|
||||
AppendBitmapMenuItem(timingMenu,Menu_Video_Snap_To_Scene, _("Snap to scene\t") + Hotkeys.GetText(_T("Snap to Scene")), _("Set start and end of subtitles to the keyframes around current video frame"), wxBITMAP(snap_subs_to_scene));
|
||||
AppendBitmapMenuItem(timingMenu,Menu_Video_Shift_To_Frame, _("Shift to Current Frame\t") + Hotkeys.GetText(_T("Shift by Current Time")), _("Shift selection so first selected line starts at current frame"), wxBITMAP(shift_to_frame));
|
||||
subtitlesMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_ADJOIN,_("&Make times continuous (change start)"),_T("Changes times of subs so start times begin on previous's end time"),wxBITMAP(blank_button));
|
||||
AppendBitmapMenuItem(subtitlesMenu,MENU_ADJOIN2,_("&Make times continuous (change end)"),_T("Changes times of subs so end times begin on next's start time"),wxBITMAP(blank_button));
|
||||
MenuBar->Append(timingMenu, _("&Timing"));
|
||||
|
||||
// Create video menu
|
||||
|
|
|
@ -211,6 +211,7 @@ private:
|
|||
void OnOpenTimingProcessor (wxCommandEvent &event);
|
||||
void OnOpenHotkeys (wxCommandEvent &event);
|
||||
void OnOpenOptions (wxCommandEvent &event);
|
||||
void OnGridEvent (wxCommandEvent &event);
|
||||
|
||||
void OnNextFrame(wxCommandEvent &event);
|
||||
void OnPrevFrame(wxCommandEvent &event);
|
||||
|
|
|
@ -65,8 +65,6 @@
|
|||
#include "automation_gui.h"
|
||||
#include "dialog_export.h"
|
||||
#include "audio_box.h"
|
||||
#include "aspell_wrap.h"
|
||||
#include "dialog_spellcheck.h"
|
||||
#include "dialog_selection.h"
|
||||
#include "dialog_styling_assistant.h"
|
||||
#include "dialog_resample.h"
|
||||
|
@ -123,6 +121,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
|||
EVT_MENU_RANGE(Menu_Timecodes_Recent,Menu_Timecodes_Recent+99, FrameMain::OnOpenRecentTimecodes)
|
||||
EVT_MENU_RANGE(Menu_Keyframes_Recent,Menu_Keyframes_Recent+99, FrameMain::OnOpenRecentKeyframes)
|
||||
|
||||
EVT_MENU_RANGE(MENU_GRID_START+1,MENU_GRID_END-1,FrameMain::OnGridEvent)
|
||||
EVT_MENU(Menu_File_Exit, FrameMain::OnExit)
|
||||
EVT_MENU(Menu_File_Open_Video, FrameMain::OnOpenVideo)
|
||||
EVT_MENU(Menu_File_Close_Video, FrameMain::OnCloseVideo)
|
||||
|
@ -221,6 +220,13 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
|||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// Redirect grid events to grid
|
||||
void FrameMain::OnGridEvent (wxCommandEvent &event) {
|
||||
SubsBox->AddPendingEvent(event);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////
|
||||
// Menu is being opened
|
||||
void FrameMain::OnMenuOpen (wxMenuEvent &event) {
|
||||
|
@ -812,29 +818,7 @@ void FrameMain::OnOpenTranslation(wxCommandEvent& WXUNUSED(event)) {
|
|||
// Open Spell Checker
|
||||
void FrameMain::OnOpenSpellCheck (wxCommandEvent &event) {
|
||||
videoBox->videoDisplay->Stop();
|
||||
#if USE_ASPELL == 1
|
||||
wxArrayInt selList = SubsBox->GetSelection();
|
||||
if (selList.GetCount() == 1){
|
||||
AssDialogue * a = SubsBox->GetDialogue(selList.Item(0));
|
||||
if (a->Text.IsEmpty()){
|
||||
wxMessageDialog Question(this, _T(
|
||||
"You've selected a single row with no text. Instead would you like to check the entire document?"),
|
||||
_T("Single Row Selection"),
|
||||
wxICON_QUESTION | wxSTAY_ON_TOP | wxYES_NO | wxYES_DEFAULT,
|
||||
wxDefaultPosition);
|
||||
|
||||
int a = Question.ShowModal();
|
||||
if (a == wxID_YES){
|
||||
selList.Clear();
|
||||
selList.Add(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
DialogSpellCheck SpellCheck(this,AssFile::top, &selList, SubsBox);
|
||||
SpellCheck.ShowModal();
|
||||
|
||||
SubsBox->CommitChanges();
|
||||
#endif
|
||||
wxMessageBox(_T("TODO!"),_T("Spellchecker"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,12 +61,6 @@
|
|||
#define USE_PORTAUDIO 0
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// Enable ASpell spellchecker
|
||||
// Requires: aspell ibrary
|
||||
#define USE_ASPELL 0
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// Enable Hunspell spellchecker
|
||||
#define USE_HUNSPELL 0
|
||||
|
|
|
@ -135,7 +135,8 @@ public:
|
|||
///////
|
||||
// IDs
|
||||
enum {
|
||||
MENU_INSERT_BEFORE = 1200,
|
||||
MENU_GRID_START = 1200,
|
||||
MENU_INSERT_BEFORE,
|
||||
MENU_INSERT_AFTER,
|
||||
MENU_INSERT_BEFORE_VIDEO,
|
||||
MENU_INSERT_AFTER_VIDEO,
|
||||
|
@ -159,5 +160,6 @@ enum {
|
|||
MENU_SET_END_TO_VIDEO,
|
||||
MENU_SET_VIDEO_TO_START,
|
||||
MENU_SET_VIDEO_TO_END,
|
||||
MENU_GRID_END,
|
||||
MENU_SHOW_COL = 1250
|
||||
};
|
||||
|
|
|
@ -110,10 +110,6 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
|||
nextFrame = -1;
|
||||
zoomValue = 0.5;
|
||||
|
||||
// Create PNG handler
|
||||
wxPNGHandler *png = new wxPNGHandler;
|
||||
wxImage::AddHandler(png);
|
||||
|
||||
// Set cursor
|
||||
// Bleeeh! Hate this 'solution':
|
||||
#if __WXGTK__
|
||||
|
|
Loading…
Reference in New Issue