2006-12-17 20:41:52 +01:00
|
|
|
// Copyright (c) 2006, 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/
|
|
|
|
|
|
|
|
/// @file dialog_paste_over.cpp
|
|
|
|
/// @brief Paste Over set-up dialogue box
|
|
|
|
/// @ingroup secondary_ui
|
|
|
|
///
|
2006-12-17 20:41:52 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-01-27 00:21:19 +01:00
|
|
|
#include "dialog_paste_over.h"
|
|
|
|
|
2012-09-25 01:35:27 +02:00
|
|
|
#include <functional>
|
2012-01-27 00:21:19 +01:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/button.h>
|
2012-01-27 00:21:19 +01:00
|
|
|
#include <wx/checklst.h>
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/sizer.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <wx/stattext.h>
|
|
|
|
|
2008-01-14 00:34:38 +01:00
|
|
|
#include "help_button.h"
|
2013-01-07 02:50:09 +01:00
|
|
|
#include "options.h"
|
2006-12-17 20:41:52 +01:00
|
|
|
|
2012-01-27 00:21:19 +01:00
|
|
|
DialogPasteOver::DialogPasteOver(wxWindow *parent)
|
|
|
|
: wxDialog (parent, -1, _("Select Fields to Paste Over"))
|
2006-12-17 20:41:52 +01:00
|
|
|
{
|
2007-09-24 19:40:03 +02:00
|
|
|
// Label and list sizer
|
2012-01-27 00:21:19 +01:00
|
|
|
wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Fields"));
|
|
|
|
ListSizer->Add(new wxStaticText(this, -1, _("Please select the fields that you want to paste over:")), wxSizerFlags());
|
2012-03-25 06:05:06 +02:00
|
|
|
|
2006-12-17 20:41:52 +01:00
|
|
|
// List box
|
|
|
|
wxArrayString choices;
|
2007-07-05 17:23:31 +02:00
|
|
|
choices.Add(_("Layer"));
|
|
|
|
choices.Add(_("Start Time"));
|
|
|
|
choices.Add(_("End Time"));
|
|
|
|
choices.Add(_("Style"));
|
|
|
|
choices.Add(_("Actor"));
|
|
|
|
choices.Add(_("Margin Left"));
|
|
|
|
choices.Add(_("Margin Right"));
|
2012-01-27 00:21:19 +01:00
|
|
|
choices.Add(_("Margin Vertical"));
|
2007-07-05 17:23:31 +02:00
|
|
|
choices.Add(_("Effect"));
|
|
|
|
choices.Add(_("Text"));
|
2012-01-27 00:23:41 +01:00
|
|
|
ListBox = new wxCheckListBox(this, -1, wxDefaultPosition, wxDefaultSize, choices);
|
2012-01-27 00:21:19 +01:00
|
|
|
ListSizer->Add(ListBox, wxSizerFlags(0).Expand().Border(wxTOP));
|
|
|
|
|
|
|
|
std::vector<bool> options = OPT_GET("Tool/Paste Lines Over/Fields")->GetListBool();
|
|
|
|
if (options.size() != choices.size())
|
|
|
|
options.resize(choices.size(), false);
|
2006-12-17 20:41:52 +01:00
|
|
|
|
2012-01-27 00:21:19 +01:00
|
|
|
for (size_t i = 0; i < choices.size(); ++i)
|
|
|
|
ListBox->Check(i, options[i]);
|
2006-12-17 20:41:52 +01:00
|
|
|
|
|
|
|
// Top buttons
|
2012-01-27 00:21:19 +01:00
|
|
|
wxButton *btn;
|
2006-12-17 20:41:52 +01:00
|
|
|
wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
2012-01-27 00:21:19 +01:00
|
|
|
|
|
|
|
TopButtonSizer->Add(btn = new wxButton(this, -1, _("&All")), wxSizerFlags(1));
|
2013-12-12 03:25:13 +01:00
|
|
|
btn->Bind(wxEVT_BUTTON, std::bind(&DialogPasteOver::CheckAll, this, true));
|
2012-01-27 00:21:19 +01:00
|
|
|
TopButtonSizer->Add(btn = new wxButton(this, -1, _("&None")), wxSizerFlags(1));
|
2013-12-12 03:25:13 +01:00
|
|
|
btn->Bind(wxEVT_BUTTON, std::bind(&DialogPasteOver::CheckAll, this, false));
|
2012-01-27 00:21:19 +01:00
|
|
|
TopButtonSizer->Add(btn = new wxButton(this, -1, _("&Times")), wxSizerFlags(1));
|
2013-12-12 03:25:13 +01:00
|
|
|
btn->Bind(wxEVT_BUTTON, &DialogPasteOver::OnTimes, this);
|
2012-01-27 00:21:19 +01:00
|
|
|
TopButtonSizer->Add(btn = new wxButton(this, -1, _("T&ext")), wxSizerFlags(1));
|
2013-12-12 03:25:13 +01:00
|
|
|
btn->Bind(wxEVT_BUTTON, &DialogPasteOver::OnText, this);
|
2006-12-17 20:41:52 +01:00
|
|
|
|
|
|
|
// Buttons
|
2012-01-27 00:21:19 +01:00
|
|
|
wxStdDialogButtonSizer *ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP);
|
2013-12-12 03:25:13 +01:00
|
|
|
Bind(wxEVT_BUTTON, &DialogPasteOver::OnOK, this, wxID_OK);
|
|
|
|
Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Paste Over"), wxID_HELP);
|
2006-12-17 20:41:52 +01:00
|
|
|
|
|
|
|
// Main sizer
|
|
|
|
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5);
|
|
|
|
MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5);
|
|
|
|
MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5);
|
2012-01-27 00:21:19 +01:00
|
|
|
SetSizerAndFit(MainSizer);
|
|
|
|
CenterOnParent();
|
2006-12-17 20:41:52 +01:00
|
|
|
}
|
|
|
|
|
2010-06-22 02:03:16 +02:00
|
|
|
void DialogPasteOver::OnOK(wxCommandEvent &) {
|
2012-01-27 00:21:19 +01:00
|
|
|
std::vector<bool> options;
|
|
|
|
for (size_t i = 0; i < ListBox->GetCount(); ++i)
|
|
|
|
options.push_back(ListBox->IsChecked(i));
|
2010-06-22 02:03:16 +02:00
|
|
|
OPT_SET("Tool/Paste Lines Over/Fields")->SetListBool(options);
|
2006-12-17 20:41:52 +01:00
|
|
|
|
|
|
|
EndModal(0);
|
|
|
|
}
|
|
|
|
|
2010-06-22 02:03:16 +02:00
|
|
|
void DialogPasteOver::OnText(wxCommandEvent &) {
|
2012-01-27 00:21:19 +01:00
|
|
|
CheckAll(false);
|
|
|
|
ListBox->Check(9, true);
|
2006-12-17 20:41:52 +01:00
|
|
|
}
|
|
|
|
|
2010-06-22 02:03:16 +02:00
|
|
|
void DialogPasteOver::OnTimes(wxCommandEvent &) {
|
2012-01-27 00:21:19 +01:00
|
|
|
CheckAll(false);
|
|
|
|
ListBox->Check(1, true);
|
|
|
|
ListBox->Check(2, true);
|
2006-12-17 20:41:52 +01:00
|
|
|
}
|
|
|
|
|
2012-01-27 00:21:19 +01:00
|
|
|
void DialogPasteOver::CheckAll(bool check) {
|
|
|
|
for (size_t i = 0; i < ListBox->GetCount(); ++i)
|
|
|
|
ListBox->Check(i, check);
|
2006-12-17 20:41:52 +01:00
|
|
|
}
|