2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file dialog_translation.cpp
|
|
|
|
/// @brief Translation Assistant dialogue box and logic
|
|
|
|
/// @ingroup tools_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
///////////
|
|
|
|
// Headers
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include <wx/wxprec.h>
|
|
|
|
#include <wx/settings.h>
|
|
|
|
#include "dialog_translation.h"
|
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_file.h"
|
|
|
|
#include "subs_grid.h"
|
|
|
|
#include "video_display.h"
|
2008-05-09 05:43:47 +02:00
|
|
|
#include "video_context.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "subs_edit_box.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "audio_display.h"
|
|
|
|
#include "frame_main.h"
|
|
|
|
#include "hotkeys.h"
|
2007-07-05 01:09:40 +02:00
|
|
|
#include "utils.h"
|
2008-01-13 23:25:26 +01:00
|
|
|
#include "help_button.h"
|
2009-07-24 02:08:25 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2009-07-25 18:15:13 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
/// @param parent
|
|
|
|
/// @param _subs
|
|
|
|
/// @param _grid
|
|
|
|
/// @param startrow
|
|
|
|
/// @param preview
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
DialogTranslation::DialogTranslation (wxWindow *parent,AssFile *_subs,SubtitlesGrid *_grid,int startrow,bool preview)
|
|
|
|
: wxDialog(parent, -1, _("Translation Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX, _T("TranslationAssistant"))
|
|
|
|
{
|
2007-07-05 01:09:40 +02:00
|
|
|
// Set icon
|
2009-07-25 06:49:59 +02:00
|
|
|
SetIcon(BitmapToIcon(GETIMAGE(translation_toolbutton_24)));
|
2007-07-05 01:09:40 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Set variables
|
|
|
|
enablePreview = preview;
|
|
|
|
main = parent;
|
|
|
|
subs = _subs;
|
|
|
|
grid = _grid;
|
2007-01-21 07:30:19 +01:00
|
|
|
audio = VideoContext::Get()->audio;
|
2008-05-09 05:43:47 +02:00
|
|
|
video = video->Get();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2007-06-23 02:25:03 +02:00
|
|
|
// Translation controls
|
2008-05-09 05:43:47 +02:00
|
|
|
OrigText = new ScintillaTextCtrl(this,TEXT_ORIGINAL,_T(""),wxDefaultPosition,wxSize(320,80));
|
2007-06-23 02:25:03 +02:00
|
|
|
OrigText->SetWrapMode(wxSTC_WRAP_WORD);
|
|
|
|
OrigText->SetMarginWidth(1,0);
|
|
|
|
OrigText->StyleSetForeground(1,wxColour(10,60,200));
|
|
|
|
OrigText->SetReadOnly(true);
|
|
|
|
//OrigText->PushEventHandler(new DialogTranslationEvent(this));
|
2008-05-09 05:43:47 +02:00
|
|
|
TransText = new ScintillaTextCtrl(this,TEXT_TRANS,_T(""),wxDefaultPosition,wxSize(320,80));
|
2007-06-23 02:25:03 +02:00
|
|
|
TransText->SetWrapMode(wxSTC_WRAP_WORD);
|
|
|
|
TransText->SetMarginWidth(1,0);
|
|
|
|
TransText->PushEventHandler(new DialogTranslationEvent(this));
|
|
|
|
TransText->SetFocus();
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Translation box
|
|
|
|
wxSizer *TranslationSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
wxSizer *OriginalTransSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Original"));
|
|
|
|
wxSizer *TranslatedSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Translation"));
|
|
|
|
LineCount = new wxStaticText(this,-1,_("Current line: ?"));
|
|
|
|
OriginalTransSizer->Add(LineCount,0,wxBOTTOM,5);
|
|
|
|
OriginalTransSizer->Add(OrigText,1,wxEXPAND,0);
|
|
|
|
TranslatedSizer->Add(TransText,1,wxEXPAND,0);
|
|
|
|
TranslationSizer->Add(OriginalTransSizer,1,wxEXPAND,0);
|
|
|
|
TranslationSizer->Add(TranslatedSizer,1,wxTOP|wxEXPAND,5);
|
|
|
|
|
|
|
|
// Hotkeys
|
|
|
|
wxSizer *KeysSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Keys"));
|
|
|
|
wxSizer *KeysInnerSizer = new wxGridSizer(2,0,5);
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Accept")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Accept changes")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Preview")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Preview changes")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Prev")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Previous line")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Next")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Next line")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Insert Original")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Insert original")));
|
2008-05-09 05:43:47 +02:00
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Play Video")) + _T(": ")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Play Video")));
|
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Translation Assistant Play Audio")) + _T(": ")));
|
2006-01-16 22:02:54 +01:00
|
|
|
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Play Audio")));
|
|
|
|
PreviewCheck = new wxCheckBox(this,PREVIEW_CHECK,_("Enable preview"));
|
|
|
|
PreviewCheck->SetValue(preview);
|
2009-06-11 10:13:54 +02:00
|
|
|
PreviewCheck->PushEventHandler(new DialogTranslationEvent(this));
|
2006-01-16 22:02:54 +01:00
|
|
|
KeysSizer->Add(KeysInnerSizer,0,wxEXPAND,0);
|
|
|
|
KeysSizer->Add(PreviewCheck,0,wxTOP,5);
|
2008-05-09 05:43:47 +02:00
|
|
|
|
|
|
|
// Tool sizer
|
|
|
|
wxStaticBoxSizer *ToolSizer = new wxStaticBoxSizer(wxVERTICAL,this, _("Actions"));
|
|
|
|
wxButton *PlayVideoButton = new wxButton(this,BUTTON_TRANS_PLAY_VIDEO,_("Play Video"));
|
|
|
|
wxButton *PlayAudioButton = new wxButton(this,BUTTON_TRANS_PLAY_AUDIO,_("Play Audio"));
|
|
|
|
PlayVideoButton->Enable(video->IsLoaded());
|
|
|
|
PlayAudioButton->Enable(audio->loaded);
|
|
|
|
ToolSizer->Add(PlayAudioButton,0,wxALL,5);
|
|
|
|
ToolSizer->Add(PlayVideoButton,0,wxLEFT | wxRIGHT | wxBOTTOM,5);
|
|
|
|
|
|
|
|
// Hotkeys + Tool sizer
|
|
|
|
wxBoxSizer *HTSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
HTSizer->Add(KeysSizer,1,wxRIGHT | wxEXPAND,5);
|
|
|
|
HTSizer->Add(ToolSizer,0);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Button sizer
|
2008-01-13 23:25:26 +01:00
|
|
|
wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
|
|
|
|
ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL));
|
|
|
|
ButtonSizer->AddButton(new HelpButton(this,_T("Translation Assistant")));
|
|
|
|
ButtonSizer->Realize();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// General layout
|
|
|
|
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
MainSizer->Add(TranslationSizer,1,wxALL | wxEXPAND,5);
|
2008-05-09 05:43:47 +02:00
|
|
|
MainSizer->Add(HTSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5);
|
2006-01-16 22:02:54 +01:00
|
|
|
MainSizer->Add(ButtonSizer,0,wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT,5);
|
|
|
|
|
|
|
|
// Set sizer
|
|
|
|
SetSizer(MainSizer);
|
|
|
|
MainSizer->SetSizeHints(this);
|
|
|
|
|
|
|
|
// Position window
|
|
|
|
if (lastx == -1 && lasty == -1) {
|
|
|
|
CenterOnParent();
|
|
|
|
} else {
|
|
|
|
Move(lastx, lasty);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set subs/grid
|
|
|
|
JumpToLine(startrow,0);
|
|
|
|
UpdatePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Jumps to line at block
|
|
|
|
/// @param n
|
|
|
|
/// @param block
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
bool DialogTranslation::JumpToLine(int n,int block) {
|
|
|
|
using std::vector;
|
2006-02-19 04:10:03 +01:00
|
|
|
AssDialogue *nextLine;
|
2006-01-16 22:02:54 +01:00
|
|
|
try {
|
2006-02-19 04:10:03 +01:00
|
|
|
nextLine = grid->GetDialogue(n);
|
2006-01-16 22:02:54 +01:00
|
|
|
} catch (...) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-19 04:10:03 +01:00
|
|
|
if (!nextLine) return false;
|
|
|
|
current = nextLine;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Count blocks
|
|
|
|
int nblocks = 0;
|
2006-02-21 04:13:35 +01:00
|
|
|
current->ParseASSTags();
|
2006-01-16 22:02:54 +01:00
|
|
|
size_t size_blocks = current->Blocks.size();
|
|
|
|
for (size_t i=0;i<size_blocks;i++) {
|
2008-01-14 01:30:00 +01:00
|
|
|
if (current->Blocks.at(i)->GetType() == BLOCK_PLAIN) nblocks++;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap around
|
|
|
|
if (block == 0xFFFF) block = nblocks-1;
|
|
|
|
if (block < 0) {
|
|
|
|
block = 0xFFFF;
|
|
|
|
n--;
|
|
|
|
return JumpToLine(n,block);
|
|
|
|
}
|
|
|
|
if (block >= nblocks) {
|
|
|
|
block = 0;
|
|
|
|
n++;
|
|
|
|
return JumpToLine(n,block);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set current
|
|
|
|
curline = n;
|
|
|
|
current = grid->GetDialogue(n);
|
|
|
|
curblock = block;
|
|
|
|
LineCount->SetLabel(wxString::Format(_("Current line: %i/%i"),curline+1,grid->GetRows()));
|
|
|
|
|
|
|
|
// Update grid
|
|
|
|
grid->BeginBatch();
|
|
|
|
grid->SelectRow(curline);
|
|
|
|
grid->MakeCellVisible(curline,0);
|
|
|
|
grid->editBox->SetToLine(curline);
|
|
|
|
grid->EndBatch();
|
|
|
|
|
|
|
|
// Adds blocks
|
2007-06-23 02:25:03 +02:00
|
|
|
OrigText->SetReadOnly(false);
|
|
|
|
OrigText->ClearAll();
|
2006-01-16 22:02:54 +01:00
|
|
|
AssDialogueBlock *curBlock;
|
|
|
|
bool found = false;
|
|
|
|
int pos=-1;
|
|
|
|
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
|
|
|
curBlock = *cur;
|
2008-01-14 01:30:00 +01:00
|
|
|
if (curBlock->GetType() == BLOCK_PLAIN) {
|
2006-01-16 22:02:54 +01:00
|
|
|
pos++;
|
2008-11-09 02:18:15 +01:00
|
|
|
int curLen = OrigText->GetReverseUnicodePosition(OrigText->GetLength());
|
2007-06-23 02:25:03 +02:00
|
|
|
OrigText->AppendText(curBlock->text);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (pos == block) {
|
2007-06-23 02:25:03 +02:00
|
|
|
OrigText->StartUnicodeStyling(curLen);
|
|
|
|
OrigText->SetUnicodeStyling(curLen,curBlock->text.Length(),1);
|
2006-01-16 22:02:54 +01:00
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 01:30:00 +01:00
|
|
|
else if (curBlock->GetType() == BLOCK_OVERRIDE) OrigText->AppendText(_T("{") + curBlock->text + _T("}"));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2006-02-21 04:13:35 +01:00
|
|
|
current->ClearBlocks();
|
2007-06-23 02:25:03 +02:00
|
|
|
OrigText->SetReadOnly(true);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Updates video preview
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslation::UpdatePreview () {
|
|
|
|
if (enablePreview) {
|
|
|
|
try {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsLoaded()) {
|
2006-01-16 22:02:54 +01:00
|
|
|
AssDialogue *cur = grid->GetDialogue(curline);
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->JumpToTime(cur->Start.GetMS());
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(DialogTranslation, wxDialog)
|
2009-06-11 04:33:21 +02:00
|
|
|
EVT_BUTTON(wxID_CANCEL,DialogTranslation::OnClose)
|
2008-05-09 05:43:47 +02:00
|
|
|
EVT_BUTTON(BUTTON_TRANS_PLAY_VIDEO,DialogTranslation::OnPlayVideoButton)
|
|
|
|
EVT_BUTTON(BUTTON_TRANS_PLAY_AUDIO,DialogTranslation::OnPlayAudioButton)
|
2006-01-16 22:02:54 +01:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////
|
|
|
|
// Event handler
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
/// @param ctrl
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
DialogTranslationEvent::DialogTranslationEvent(DialogTranslation *ctrl) {
|
|
|
|
control = ctrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(DialogTranslationEvent, wxEvtHandler)
|
|
|
|
EVT_KEY_DOWN(DialogTranslationEvent::OnTransBoxKey)
|
|
|
|
EVT_CHECKBOX(PREVIEW_CHECK, DialogTranslationEvent::OnPreviewCheck)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Redirects
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslationEvent::OnPreviewCheck(wxCommandEvent &event) { control->enablePreview = event.IsChecked(); }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslationEvent::OnTransBoxKey(wxKeyEvent &event) { control->OnTransBoxKey(event); }
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Key pressed event
|
|
|
|
/// @param event
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslation::OnTransBoxKey(wxKeyEvent &event) {
|
2007-09-22 17:16:48 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
Hotkeys.SetPressed(event.GetKeyCode(),event.m_metaDown,event.m_altDown,event.m_shiftDown);
|
|
|
|
#else
|
2006-01-16 22:02:54 +01:00
|
|
|
Hotkeys.SetPressed(event.GetKeyCode(),event.m_controlDown,event.m_altDown,event.m_shiftDown);
|
2007-09-22 17:16:48 +02:00
|
|
|
#endif
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Previous
|
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Prev"))) {
|
|
|
|
bool ok = JumpToLine(curline,curblock-1);
|
|
|
|
if (ok) {
|
2007-06-23 02:25:03 +02:00
|
|
|
TransText->ClearAll();
|
2006-01-16 22:02:54 +01:00
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatePreview();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next
|
2006-02-20 22:32:58 +01:00
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Next")) || (Hotkeys.IsPressed(_T("Translation Assistant Accept")) && TransText->GetValue().IsEmpty())) {
|
2006-01-16 22:02:54 +01:00
|
|
|
bool ok = JumpToLine(curline,curblock+1);
|
|
|
|
if (ok) {
|
2007-06-23 02:25:03 +02:00
|
|
|
TransText->ClearAll();
|
2006-01-16 22:02:54 +01:00
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdatePreview();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Accept (enter)
|
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Accept")) || Hotkeys.IsPressed(_T("Translation Assistant Preview"))) {
|
|
|
|
// Store
|
|
|
|
AssDialogue *cur = grid->GetDialogue(curline);
|
2006-02-21 04:13:35 +01:00
|
|
|
cur->ParseASSTags();
|
2006-01-16 22:02:54 +01:00
|
|
|
int nblock = -1;
|
|
|
|
for (unsigned int i=0;i<cur->Blocks.size();i++) {
|
2008-01-14 01:30:00 +01:00
|
|
|
if (cur->Blocks.at(i)->GetType() == BLOCK_PLAIN) nblock++;
|
2006-01-16 22:02:54 +01:00
|
|
|
if (nblock == curblock) {
|
|
|
|
cur->Blocks.at(i)->text = TransText->GetValue();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update line
|
|
|
|
cur->UpdateText();
|
|
|
|
cur->UpdateData();
|
2006-02-21 04:13:35 +01:00
|
|
|
cur->ClearBlocks();
|
2007-01-26 01:47:42 +01:00
|
|
|
subs->FlagAsModified(_("translation assistant"));
|
2006-01-16 22:02:54 +01:00
|
|
|
grid->CommitChanges();
|
|
|
|
((FrameMain*)main)->UpdateTitle();
|
|
|
|
UpdatePreview();
|
|
|
|
|
|
|
|
// Next
|
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Accept"))) {
|
2008-06-15 14:20:51 +02:00
|
|
|
// JumpToLine() returns false if the requested line doesn't exist.
|
|
|
|
// Assume that means we were on the last line.
|
|
|
|
if (!JumpToLine(curline,curblock+1)) {
|
|
|
|
wxMessageBox(_("No more lines to translate."));
|
|
|
|
EndModal(1);
|
|
|
|
return;
|
|
|
|
}
|
2007-06-23 02:25:03 +02:00
|
|
|
TransText->ClearAll();
|
2006-01-16 22:02:54 +01:00
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
2007-01-24 04:54:32 +01:00
|
|
|
else JumpToLine(curline,curblock);
|
2006-01-16 22:02:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert original text (insert)
|
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Insert Original"))) {
|
|
|
|
using std::vector;
|
|
|
|
AssDialogueBlock *curBlock;
|
|
|
|
int pos = -1;
|
2006-02-21 04:13:35 +01:00
|
|
|
current->ParseASSTags();
|
2006-01-16 22:02:54 +01:00
|
|
|
for (vector<AssDialogueBlock*>::iterator cur=current->Blocks.begin();cur!=current->Blocks.end();cur++) {
|
|
|
|
curBlock = *cur;
|
2008-01-14 01:30:00 +01:00
|
|
|
if (curBlock->GetType() == BLOCK_PLAIN) {
|
2006-01-16 22:02:54 +01:00
|
|
|
pos++;
|
|
|
|
if (pos == curblock) {
|
2007-06-23 02:25:03 +02:00
|
|
|
TransText->AddText(curBlock->text);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-21 04:13:35 +01:00
|
|
|
current->ClearBlocks();
|
2006-01-16 22:02:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-09 05:43:47 +02:00
|
|
|
// Play video
|
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Play Video"))) {
|
|
|
|
if (video->IsLoaded()) {
|
|
|
|
video->PlayLine();
|
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Play audio
|
2008-05-09 05:43:47 +02:00
|
|
|
if (Hotkeys.IsPressed(_T("Translation Assistant Play Audio"))) {
|
|
|
|
if (audio->loaded) {
|
|
|
|
audio->Play(current->Start.GetMS(),current->End.GetMS());
|
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-07 00:21:03 +01:00
|
|
|
// Close
|
2007-07-16 05:17:11 +02:00
|
|
|
if (event.GetKeyCode() == WXK_ESCAPE) EndModal(1);
|
|
|
|
|
2008-03-07 00:21:03 +01:00
|
|
|
// Ignore enter
|
|
|
|
if (event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) return;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Skip anything else
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Play video button
|
|
|
|
/// @param event
|
|
|
|
///
|
2008-05-09 05:43:47 +02:00
|
|
|
void DialogTranslation::OnPlayVideoButton(wxCommandEvent &event) {
|
|
|
|
video->PlayLine();
|
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Play audio button
|
|
|
|
/// @param event
|
|
|
|
///
|
2008-05-09 05:43:47 +02:00
|
|
|
void DialogTranslation::OnPlayAudioButton(wxCommandEvent &event) {
|
|
|
|
audio->Play(current->Start.GetMS(),current->End.GetMS());
|
2006-01-16 22:02:54 +01:00
|
|
|
TransText->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Close
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslation::OnClose (wxCommandEvent &event) {
|
|
|
|
GetPosition(&lastx, &lasty);
|
2009-06-11 04:33:21 +02:00
|
|
|
TransText->PopEventHandler(true);
|
|
|
|
PreviewCheck->PopEventHandler(true);
|
|
|
|
EndModal(0);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Minimize
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void DialogTranslation::OnMinimize (wxIconizeEvent &event) {
|
|
|
|
//Iconize(true);
|
|
|
|
if (main) ((wxFrame*)main)->Iconize(true);
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-01-16 22:02:54 +01:00
|
|
|
int DialogTranslation::lastx = -1;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-01-16 22:02:54 +01:00
|
|
|
int DialogTranslation::lasty = -1;
|
2009-07-29 07:43:02 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|