1700 GET. Changed how the help button works, and made it direct to the wiki for now. Only 4 help buttons work, so far.

Originally committed to SVN as r1700.
This commit is contained in:
Rodrigo Braz Monteiro 2008-01-13 21:05:31 +00:00
parent 58b1637bd8
commit e0f3086369
7 changed files with 46 additions and 23 deletions

View file

@ -108,7 +108,7 @@ DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid)
wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
ButtonSizer->AddButton(new wxButton(this,wxID_OK));
ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL));
ButtonSizer->AddButton(new HelpButton(this,_T("dialog_resample")));
ButtonSizer->AddButton(new HelpButton(this,_T("Resample")));
ButtonSizer->Realize();
// Main sizer

View file

@ -164,7 +164,7 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
// Buttons
wxStdDialogButtonSizer *buttonSizer = new wxStdDialogButtonSizer();
buttonSizer->SetCancelButton(new wxButton(this, wxID_CLOSE));
buttonSizer->AddButton(new HelpButton(this,_T("style_manager")));
buttonSizer->AddButton(new HelpButton(this,_T("Styles Manager")));
buttonSizer->Realize();
// General layout

View file

@ -49,6 +49,7 @@
#include "audio_box.h"
#include "hotkeys.h"
#include "utils.h"
#include "help_button.h"
///////////////
@ -114,7 +115,7 @@ wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize,
// Button sizer
wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
ButtonSizer->Add(new wxButton(this,wxID_HELP),0,wxRIGHT,0);
ButtonSizer->Add(new HelpButton(this,_T("Styling Assistant")),0,wxRIGHT,0);
ButtonSizer->AddStretchSpacer(1);
wxButton *PlayButton = new wxButton(this,BUTTON_PLAY,_("Play Audio"));
PlayButton->Enable(audio->loaded);
@ -215,7 +216,6 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
///////////////
// Event table
BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
EVT_BUTTON(wxID_HELP, DialogStyling::OnHelpButton)
EVT_BUTTON(BUTTON_PLAY, DialogStyling::OnPlayButton)
//EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter)
EVT_TEXT(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxModified)
@ -302,13 +302,6 @@ void DialogStyling::OnListClicked(wxCommandEvent &event) {
}
///////////////
// Help button
void DialogStyling::OnHelpButton(wxCommandEvent &event) {
FrameMain::OpenHelp(_T("stylingassistant2.htm"));
}
///////////////
// Play button
void DialogStyling::OnPlayButton(wxCommandEvent &event) {

View file

@ -90,7 +90,6 @@ private:
void OnStyleBoxEnter (wxCommandEvent &event);
void OnListClicked (wxCommandEvent &event);
void OnKeyDown(wxKeyEvent &event);
void OnHelpButton(wxCommandEvent &event);
void OnPlayButton(wxCommandEvent &event);
void SetStyle (wxString curName,bool jump=true);

View file

@ -71,6 +71,7 @@
#include "dialog_detached_video.h"
#include "standard_paths.h"
#include "keyframe.h"
#include "help_button.h"
#ifdef WITH_AUTOMATION
#include "auto4_base.h"
#endif
@ -1133,12 +1134,7 @@ void FrameMain::LoadVFR(wxString filename) {
/////////////
// Open help
void FrameMain::OpenHelp(wxString page) {
if (!page.IsEmpty()) page = _T("::") + page;
wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("chm"));
if (type) {
wxString command = type->GetOpenCommand(StandardPaths::DecodePath(_T("?data/Aegisub.chm")));
if (!command.empty()) wxExecute(command + page);
}
HelpButton::OpenPage(_T("Main"));
}

View file

@ -39,6 +39,7 @@
#include <wx/wxprec.h>
#include <wx/mimetype.h>
#include <wx/log.h>
#include <map>
#include "help_button.h"
#include "utils.h"
#include "standard_paths.h"
@ -49,7 +50,7 @@
HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize size)
: wxButton (parent,wxID_HELP,_T(""),position,size)
{
page = _page;
id = _page;
Connect(GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(HelpButton::OnPressed));
}
@ -58,17 +59,46 @@ HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize s
// Pressed
void HelpButton::OnPressed(wxCommandEvent &event) {
// Verify if the page is valid
if (page.IsEmpty()) {
if (id.IsEmpty()) {
wxLogMessage(_T("TODO"));
return;
}
// Open
OpenPage(id);
}
///////////////
// Open a page
void HelpButton::OpenPage(const wxString pageID) {
// Transcode
InitStatic();
wxString page = (*pages)[pageID];
// Get the file type
wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html"));
if (type) {
wxString command = type->GetOpenCommand(StandardPaths::DecodePath(wxString::Format(_T("?data/docs/%s.html"),page.c_str())));
if (!command.empty()) wxExecute(command);
wxString path = StandardPaths::DecodePath(wxString::Format(_T("http://aegisub.cellosoft.com/docs/%s"),page.c_str()));
//wxString command = type->GetOpenCommand(path);
//if (!command.empty()) wxExecute(command);
wxLaunchDefaultBrowser(path);
}
}
//////////////
// Static map
std::map<wxString,wxString> *HelpButton::pages = NULL;
void HelpButton::InitStatic() {
if (!pages) {
pages = new std::map<wxString,wxString>;
std::map<wxString,wxString> &page = *pages;
page[_T("Main")] = _T("");
page[_T("Styling Assistant")] = _T("Styling_Assistant");
page[_T("Styles Manager")] = _T("Styles");
page[_T("Kanji Timer")] = _T("Kanji_Timer");
page[_T("Resampler")] = _T("Resolution_Resampler");
}
}

View file

@ -47,9 +47,14 @@
// Browse button class
class HelpButton : public wxButton {
private:
wxString page;
wxString id;
void OnPressed(wxCommandEvent &event);
static std::map<wxString,wxString> *pages;
static void InitStatic();
public:
HelpButton(wxWindow *parent,wxString page=_T(""),wxPoint position=wxDefaultPosition,wxSize size=wxDefaultSize);
static void OpenPage(const wxString page);
};