Menu

[r135]: / src / exportdialog.cpp  Maximize  Restore  History

Download this file

245 lines (220 with data), 8.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* Copyright 2005-2007 Gerald Schmidt.
*
* This file is part of Xml Copy Editor.
*
* Xml Copy Editor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* Xml Copy Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xml Copy Editor; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <memory>
#include <wx/hyperlink.h>
#include <wx/sizer.h>
#include "exportdialog.h"
BEGIN_EVENT_TABLE ( ExportDialog, wxDialog )
EVT_BUTTON ( wxID_OK, ExportDialog::OnOk )
EVT_HELP ( wxID_OK, ExportDialog::OnContextHelp )
EVT_HELP ( wxID_CANCEL, ExportDialog::OnContextHelp )
EVT_HELP ( ID_URL, ExportDialog::OnContextHelp )
EVT_HELP ( ID_FOLDER, ExportDialog::OnContextHelp )
EVT_HELP ( ID_QUIET, ExportDialog::OnContextHelp )
EVT_HELP ( ID_MP3, ExportDialog::OnContextHelp )
EVT_UPDATE_UI ( wxID_OK, ExportDialog::OnUpdateOk )
END_EVENT_TABLE()
ExportDialog::ExportDialog (
wxWindow *parent,
const wxString& urlParameter,
const wxString& folderParameter,
bool quietParameter,
bool suppressOptionalParameter,
bool htmlParameter,
bool epubParameter,
bool rtfParameter,
bool docParameter,
bool fullDaisyParameter,
bool mp3AlbumParameter,
bool downloadLinkParameter) :
wxDialog(),
url ( urlParameter ),
folder ( folderParameter ),
quiet ( quietParameter ),
suppressOptional ( suppressOptionalParameter ),
html ( htmlParameter ),
epub ( epubParameter ),
rtf ( rtfParameter ),
doc ( docParameter ),
fullDaisy ( fullDaisyParameter ),
mp3Album ( mp3AlbumParameter ),
downloadLink ( downloadLinkParameter )
{
SetExtraStyle ( wxDIALOG_EX_CONTEXTHELP );
Create (
parent,
wxID_ANY,
wxString ( _ ( "DAISY export" ) ),
wxDefaultPosition,
wxSize ( 250, -1 ),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
wxBoxSizer *dialogSizer = new wxBoxSizer ( wxVERTICAL );
wxString labelText = _ ( "&Stylesheet for conversion to canonical XHTML (optional):" );
// pad with whitespace
labelText += _T(" ");
wxStaticText *urlLabel =
new wxStaticText ( this, wxID_ANY, labelText);
urlCtrl = new wxFilePickerCtrl ( this, ID_URL, url );
#ifndef __WXMSW__
urlCtrl->SetPath ( url );
#endif
wxStaticText *folderLabel =
new wxStaticText ( this, wxID_ANY, _ ( "&Output folder:" ) );
dirPicker = new wxDirPickerCtrl (
this,
ID_FOLDER,
folder,
_T("Select a folder"),
wxDefaultPosition,
wxSize ( 300, urlCtrl->GetSize().GetHeight() )
);
wxStaticBoxSizer *prodnoteSizer = new wxStaticBoxSizer ( wxVERTICAL, this, _T("Production notes") );
quietCheckbox = new wxCheckBox ( this, ID_QUIET, _ ( "&De-emphasize production notes" ) );
quietCheckbox->SetValue ( quiet );
suppressOptionalCheckbox = new wxCheckBox ( this, ID_SUPPRESS_OPTIONAL, _ ( "&Suppress optional production notes" ) );
suppressOptionalCheckbox->SetValue ( suppressOptional );
wxStaticBoxSizer *outputSizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Outputs") );
fullDaisyCheckbox = new wxCheckBox ( this, ID_FULL_DAISY, _ ( "&Full DAISY 2.02 and 3.0 Talking Books" ) );
fullDaisyCheckbox->SetValue ( fullDaisy );
htmlCheckbox = new wxCheckBox ( this, ID_HTML, _ ( "&HTML" ) );
htmlCheckbox->SetValue ( html );
epubCheckbox = new wxCheckBox ( this, ID_EPUB, _ ( "&ePub ebook" ) );
epubCheckbox->SetValue ( epub );
rtfCheckbox = new wxCheckBox ( this, ID_EPUB, _ ( "&RTF document" ) );
rtfCheckbox->SetValue ( rtf );
docCheckbox = new wxCheckBox ( this, ID_DOC, _ ( "&Word document" ) );
docCheckbox->SetValue ( doc );
mp3AlbumCheckbox = new wxCheckBox ( this, ID_MP3, _ ( "&MP3 album" ) );
mp3AlbumCheckbox->SetValue ( mp3Album );
dialogSizer->Add ( urlLabel, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
dialogSizer->Add ( urlCtrl, 0, wxALL | wxALIGN_LEFT | wxEXPAND, 5 );
dialogSizer->Add ( folderLabel, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
dialogSizer->Add ( dirPicker, 0, wxALL | wxALIGN_LEFT | wxEXPAND, 5 );
prodnoteSizer->Add ( quietCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
prodnoteSizer->Add ( suppressOptionalCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( fullDaisyCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( htmlCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( epubCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( rtfCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( docCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
outputSizer->Add ( mp3AlbumCheckbox, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
dialogSizer->Add ( prodnoteSizer, 0, wxTOP | wxLEFT | wxALIGN_LEFT | wxEXPAND, 5 );
dialogSizer->Add ( outputSizer, 0, wxTOP | wxLEFT | wxALIGN_LEFT | wxEXPAND, 5 );
if ( downloadLink )
{
wxHyperlinkCtrl *downloadCtrl = new wxHyperlinkCtrl (
this,
wxID_ANY,
_ ( "Download DAISY extension" ),
#ifdef __WXMSW__
_T ( "https://sourceforge.net/projects/xml-copy-editor/files/xmlcopyeditor-daisy/xmlcopyeditor-daisy-1.0.1.exe/download" )
#else
_T ( "http://xml-copy-editor.sourceforge.net" )
#endif
);
dialogSizer->AddSpacer ( 5 );
dialogSizer->Add ( downloadCtrl, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 5 );
}
dialogSizer->AddSpacer ( 5 );
dialogSizer->Add (
CreateButtonSizer ( wxOK | wxCANCEL ), 0, wxTOP | wxBOTTOM | wxALIGN_RIGHT, 5 );
this->SetSizer ( dialogSizer );
dialogSizer->SetSizeHints ( this );
urlCtrl->SetFocus();
}
ExportDialog::~ExportDialog()
{ }
void ExportDialog::OnOk ( wxCommandEvent& e )
{
std::string urlUtf8, urlParamsUtf8;
#ifdef __WXMSW__
url = urlCtrl->GetTextCtrlValue();
#else
url = urlCtrl->GetPath();
#endif
folder = dirPicker->GetPath();
quiet = quietCheckbox->IsChecked();
mp3Album = mp3AlbumCheckbox->IsChecked();
suppressOptional = suppressOptionalCheckbox->IsChecked();
html = htmlCheckbox->IsChecked();
epub = epubCheckbox->IsChecked();
rtf = rtfCheckbox->IsChecked();
doc = docCheckbox->IsChecked();
fullDaisy = fullDaisyCheckbox->IsChecked();
urlUtf8 = ( const char * ) url.mb_str ( wxConvUTF8 );
e.Skip();
}
void ExportDialog::OnContextHelp ( wxHelpEvent& e )
{
wxTipWindow *tw;
int id = e.GetId();
if ( id == ID_URL )
tw = new wxTipWindow (
this,
_ ( "Provides a space for you to enter or select a stylesheet for conversion to canonical XHTML" ) );
if ( id == ID_FOLDER )
tw = new wxTipWindow (
this,
_ ( "Provides a space for you to enter or select the output folder" ) );
else if ( id == wxID_OK )
tw = new wxTipWindow (
this,
_ ( "Starts the export" ) );
else if ( id == wxID_CANCEL )
tw = new wxTipWindow (
this,
_ ( "Closes the dialog box without exporting the file" ) );
else
{ }
e.Skip();
}
void ExportDialog::OnUpdateOk ( wxUpdateUIEvent& e )
{
bool enable = true;
if (
dirPicker->GetPath().empty() ||
downloadLink )
enable = false;
e.Enable ( enable );
}
wxString ExportDialog::getUrlString()
{
return url;
}
wxString ExportDialog::getFolderString()
{
return folder;
}
bool ExportDialog::getQuiet()
{
return quiet;
}
bool ExportDialog::getMp3Album()
{
return mp3Album;
}
bool ExportDialog::getSuppressOptional() { return suppressOptional; }
bool ExportDialog::getHtml() { return html; }
bool ExportDialog::getEpub() { return epub; }
bool ExportDialog::getRtf() { return rtf; }
bool ExportDialog::getDoc() { return doc; }
bool ExportDialog::getFullDaisy() { return fullDaisy; }
void ExportDialog::OnFolderBrowse ( wxCommandEvent& e )
{
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.