~ubuntu-branches/ubuntu/trusty/aegisub/trusty

« back to all changes in this revision

Viewing changes to src/dialog_paste_over.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Reichel
  • Date: 2012-03-16 22:58:00 UTC
  • Revision ID: package-import@ubuntu.com-20120316225800-yfb8h9e5n04rk46a
Tags: upstream-2.1.9
ImportĀ upstreamĀ versionĀ 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2006, Rodrigo Braz Monteiro
 
2
// All rights reserved.
 
3
//
 
4
// Redistribution and use in source and binary forms, with or without
 
5
// modification, are permitted provided that the following conditions are met:
 
6
//
 
7
//   * Redistributions of source code must retain the above copyright notice,
 
8
//     this list of conditions and the following disclaimer.
 
9
//   * Redistributions in binary form must reproduce the above copyright notice,
 
10
//     this list of conditions and the following disclaimer in the documentation
 
11
//     and/or other materials provided with the distribution.
 
12
//   * Neither the name of the Aegisub Group nor the names of its contributors
 
13
//     may be used to endorse or promote products derived from this software
 
14
//     without specific prior written permission.
 
15
//
 
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
21
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
26
// POSSIBILITY OF SUCH DAMAGE.
 
27
//
 
28
// -----------------------------------------------------------------------------
 
29
//
 
30
// AEGISUB
 
31
//
 
32
// Website: http://aegisub.cellosoft.com
 
33
// Contact: mailto:zeratul@cellosoft.com
 
34
//
 
35
 
 
36
 
 
37
///////////
 
38
// Headers
 
39
#include "config.h"
 
40
 
 
41
#include <wx/config.h>
 
42
#include <wx/stattext.h>
 
43
#include <wx/sizer.h>
 
44
#include <wx/button.h>
 
45
#include "dialog_paste_over.h"
 
46
#include "options.h"
 
47
#include "help_button.h"
 
48
 
 
49
 
 
50
///////////////
 
51
// Constructor
 
52
DialogPasteOver::DialogPasteOver (wxWindow *parent)
 
53
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
 
54
{
 
55
        // Script mode
 
56
        int mode = 1; // ASS
 
57
 
 
58
        // Label and list sizer
 
59
        wxSizer *ListSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Fields"));
 
60
        wxStaticText *label = new wxStaticText(this,-1,_("Please select the fields that you want to paste over:"),wxDefaultPosition,wxDefaultSize);
 
61
        ListSizer->Add(label,0,wxEXPAND,0);
 
62
        
 
63
        // List box
 
64
        wxArrayString choices;
 
65
        choices.Add(_("Layer"));
 
66
        choices.Add(_("Start Time"));
 
67
        choices.Add(_("End Time"));
 
68
        choices.Add(_("Style"));
 
69
        choices.Add(_("Actor"));
 
70
        choices.Add(_("Margin Left"));
 
71
        choices.Add(_("Margin Right"));
 
72
        if (mode == 1) {
 
73
                choices.Add(_("Margin Vertical"));
 
74
        }
 
75
        else {
 
76
                choices.Add(_("Margin Top"));
 
77
                choices.Add(_("Margin Bottom"));
 
78
        }
 
79
        choices.Add(_("Effect"));
 
80
        choices.Add(_("Text"));
 
81
        ListBox = new wxCheckListBox(this,-1,wxDefaultPosition,wxSize(250,170), choices);
 
82
        ListSizer->Add(ListBox,0,wxEXPAND|wxTOP,5);
 
83
 
 
84
        // Load checked items
 
85
        for (unsigned int i=0;i<choices.Count();i++) ListBox->Check(i,Options.AsBool(wxString::Format(_T("Paste Over #%i"),i)));
 
86
 
 
87
        // Top buttons
 
88
        wxSizer *TopButtonSizer = new wxBoxSizer(wxHORIZONTAL);
 
89
        TopButtonSizer->Add(new wxButton(this, Paste_Over_All, _("All")),1,0,0);
 
90
        TopButtonSizer->Add(new wxButton(this, Paste_Over_None, _("None")),1,0,0);
 
91
        TopButtonSizer->Add(new wxButton(this, Paste_Over_Times, _("Times")),1,0,0);
 
92
        TopButtonSizer->Add(new wxButton(this, Paste_Over_Text, _("Text")),1,0,0);
 
93
 
 
94
        // Buttons
 
95
        wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
 
96
        ButtonSizer->AddButton(new wxButton(this, wxID_OK));
 
97
        ButtonSizer->AddButton(new wxButton(this, wxID_CANCEL));
 
98
        ButtonSizer->AddButton(new HelpButton(this,_T("Paste Over")));
 
99
        ButtonSizer->Realize();
 
100
 
 
101
        // Main sizer
 
102
        wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
 
103
        MainSizer->Add(ListSizer,0,wxEXPAND | wxLEFT | wxRIGHT,5);
 
104
        MainSizer->Add(TopButtonSizer,0,wxLEFT | wxRIGHT | wxEXPAND,5);
 
105
        MainSizer->Add(ButtonSizer,0,wxALL | wxEXPAND,5);
 
106
        SetSizer(MainSizer);
 
107
        MainSizer->SetSizeHints(this);
 
108
        Center();
 
109
        ListBox->SetFocus();
 
110
}
 
111
 
 
112
 
 
113
//////////////
 
114
// Destructor
 
115
DialogPasteOver::~DialogPasteOver() {
 
116
}
 
117
 
 
118
 
 
119
///////////////
 
120
// Event table
 
121
BEGIN_EVENT_TABLE(DialogPasteOver, wxDialog)
 
122
        EVT_BUTTON(wxID_OK,DialogPasteOver::OnOK)
 
123
        EVT_BUTTON(wxID_CANCEL,DialogPasteOver::OnCancel)
 
124
        EVT_BUTTON(Paste_Over_All,DialogPasteOver::OnAll)
 
125
        EVT_BUTTON(Paste_Over_None,DialogPasteOver::OnNone)
 
126
        EVT_BUTTON(Paste_Over_Text,DialogPasteOver::OnText)
 
127
        EVT_BUTTON(Paste_Over_Times,DialogPasteOver::OnTimes)
 
128
END_EVENT_TABLE()
 
129
 
 
130
 
 
131
//////////////
 
132
// OK pressed
 
133
void DialogPasteOver::OnOK(wxCommandEvent &event) {
 
134
        // Set options
 
135
        options.SetCount(10);
 
136
        for (int i=0;i<10;i++) {
 
137
                options[i] = ListBox->IsChecked(i) ? 1 : 0;
 
138
                Options.SetBool(wxString::Format(_T("Paste Over #%i"),i),options[i]==1);
 
139
        }
 
140
        Options.Save();
 
141
 
 
142
        // End
 
143
        EndModal(1);
 
144
}
 
145
 
 
146
 
 
147
//////////////////
 
148
// Cancel pressed
 
149
void DialogPasteOver::OnCancel(wxCommandEvent &event) {
 
150
        EndModal(0);
 
151
}
 
152
 
 
153
 
 
154
///////////////
 
155
// Select Text
 
156
void DialogPasteOver::OnText(wxCommandEvent &event) {
 
157
        for (int i=0;i<9;i++) ListBox->Check(i,false);
 
158
        ListBox->Check(9,true);
 
159
}
 
160
 
 
161
 
 
162
////////////////
 
163
// Select Times
 
164
void DialogPasteOver::OnTimes(wxCommandEvent &event) {
 
165
        for (int i=0;i<10;i++) ListBox->Check(i,false);
 
166
        ListBox->Check(1,true);
 
167
        ListBox->Check(2,true);
 
168
}
 
169
 
 
170
 
 
171
//////////////
 
172
// Select All
 
173
void DialogPasteOver::OnAll(wxCommandEvent &event) {
 
174
        for (int i=0;i<10;i++) ListBox->Check(i,true);
 
175
}
 
176
 
 
177
 
 
178
///////////////
 
179
// Select None
 
180
void DialogPasteOver::OnNone(wxCommandEvent &event) {
 
181
        for (int i=0;i<10;i++) ListBox->Check(i,false);
 
182
}
 
183
 
 
184
 
 
185
////////////////
 
186
// Get options
 
187
wxArrayInt DialogPasteOver::GetOptions() {
 
188
        return options;
 
189
}