1
// Copyright (c) 2007, Rodrigo Braz Monteiro
2
// All rights reserved.
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are met:
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.
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.
28
// -----------------------------------------------------------------------------
32
// Website: http://aegisub.cellosoft.com
33
// Contact: mailto:zeratul@cellosoft.com
41
#include <wx/wxprec.h>
42
#include <wx/mimetype.h>
44
#include <wx/filename.h>
46
#include "help_button.h"
48
#include "standard_paths.h"
53
HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize size)
54
: wxButton (parent,wxID_HELP,_T(""),position,size)
57
Connect(GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(HelpButton::OnPressed));
63
void HelpButton::OnPressed(wxCommandEvent &event) {
64
// Verify if the page is valid
66
wxLogMessage(_T("TODO"));
77
void HelpButton::OpenPage(const wxString pageID) {
78
// Translate ID to page filename
80
wxString page = (*pages)[pageID];
82
wxFileName docFile(StandardPaths::DecodePath(_T("?data/docs/")), page, _T("html"), wxPATH_NATIVE);
85
// If we can read a file by the constructed name, assume we have a local copy of the manual
86
if (docFile.IsFileReadable())
87
// Tested IE8, Firefox 3.5, Safari 4, Chrome 4 and Opera 10 on Windows, they all handle
88
// various variations of slashes, missing one at the start and using backslashes throughout
89
// is safe with everything everyone uses. Blame Microsoft.
90
url = wxString(_T("file://")) + docFile.GetFullPath(wxPATH_NATIVE);
92
url = wxString::Format(_T("http://docs.aegisub.org/manual/%s"),page.c_str());
94
wxLaunchDefaultBrowser(url);
100
std::map<wxString,wxString> *HelpButton::pages = NULL;
102
void HelpButton::InitStatic() {
104
pages = new std::map<wxString,wxString>;
105
std::map<wxString,wxString> &page = *pages;
106
page[_T("Attachment Manager")] = _T("Attachment_Manager");
107
page[_T("Automation Manager")] = _T("Automation_Manager");
108
page[_T("Colour Picker")] = _T("Colour_Picker");
109
page[_T("Dummy Video")] = _T("Dummy_video");
110
page[_T("Export")] = _T("Exporting");
111
page[_T("Fonts Collector")] = _T("Fonts_Collector");
112
page[_T("Kanji Timer")] = _T("Kanji_Timer");
113
page[_T("Main")] = _T("Main_Page");
114
page[_T("Options")] = _T("Options");
115
page[_T("Paste Over")] = _T("Paste_Over");
116
page[_T("Properties")] = _T("Properties");
117
page[_T("Resample resolution")] = _T("Resolution_Resampler");
118
page[_T("Shift Times")] = _T("Shift_Times");
119
page[_T("Select Lines")] = _T("Select_Lines");
120
page[_T("Spell Checker")] = _T("Spell_Checker");
121
page[_T("Style Editor")] = _T("Styles");
122
page[_T("Styles Manager")] = _T("Styles");
123
page[_T("Styling Assistant")] = _T("Styling_Assistant");
124
page[_T("Timing Processor")] = _T("Timing_Post-Processor");
125
page[_T("Translation Assistant")] = _T("Translation_Assistant");
126
page[_T("Visual Typesetting")] = _T("Visual_Typesetting");
130
void HelpButton::ClearPages() {
131
if (pages) delete pages;