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(); wxStdDialogButtonSizer *ButtonSizer = new wxStdDialogButtonSizer();
ButtonSizer->AddButton(new wxButton(this,wxID_OK)); ButtonSizer->AddButton(new wxButton(this,wxID_OK));
ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL)); ButtonSizer->AddButton(new wxButton(this,wxID_CANCEL));
ButtonSizer->AddButton(new HelpButton(this,_T("dialog_resample"))); ButtonSizer->AddButton(new HelpButton(this,_T("Resample")));
ButtonSizer->Realize(); ButtonSizer->Realize();
// Main sizer // Main sizer

View File

@ -164,7 +164,7 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
// Buttons // Buttons
wxStdDialogButtonSizer *buttonSizer = new wxStdDialogButtonSizer(); wxStdDialogButtonSizer *buttonSizer = new wxStdDialogButtonSizer();
buttonSizer->SetCancelButton(new wxButton(this, wxID_CLOSE)); 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(); buttonSizer->Realize();
// General layout // General layout

View File

@ -49,6 +49,7 @@
#include "audio_box.h" #include "audio_box.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "utils.h" #include "utils.h"
#include "help_button.h"
/////////////// ///////////////
@ -114,7 +115,7 @@ wxDialog (parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize,
// Button sizer // Button sizer
wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL); 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); ButtonSizer->AddStretchSpacer(1);
wxButton *PlayButton = new wxButton(this,BUTTON_PLAY,_("Play Audio")); wxButton *PlayButton = new wxButton(this,BUTTON_PLAY,_("Play Audio"));
PlayButton->Enable(audio->loaded); PlayButton->Enable(audio->loaded);
@ -215,7 +216,6 @@ void DialogStyling::SetStyle (wxString curName, bool jump) {
/////////////// ///////////////
// Event table // Event table
BEGIN_EVENT_TABLE(DialogStyling,wxDialog) BEGIN_EVENT_TABLE(DialogStyling,wxDialog)
EVT_BUTTON(wxID_HELP, DialogStyling::OnHelpButton)
EVT_BUTTON(BUTTON_PLAY, DialogStyling::OnPlayButton) EVT_BUTTON(BUTTON_PLAY, DialogStyling::OnPlayButton)
//EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter) //EVT_TEXT_ENTER(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxEnter)
EVT_TEXT(ENTER_STYLE_BOX, DialogStyling::OnStyleBoxModified) 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 // Play button
void DialogStyling::OnPlayButton(wxCommandEvent &event) { void DialogStyling::OnPlayButton(wxCommandEvent &event) {

View File

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

View File

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

View File

@ -39,6 +39,7 @@
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include <wx/mimetype.h> #include <wx/mimetype.h>
#include <wx/log.h> #include <wx/log.h>
#include <map>
#include "help_button.h" #include "help_button.h"
#include "utils.h" #include "utils.h"
#include "standard_paths.h" #include "standard_paths.h"
@ -49,7 +50,7 @@
HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize size) HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize size)
: wxButton (parent,wxID_HELP,_T(""),position,size) : wxButton (parent,wxID_HELP,_T(""),position,size)
{ {
page = _page; id = _page;
Connect(GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(HelpButton::OnPressed)); Connect(GetId(),wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(HelpButton::OnPressed));
} }
@ -58,17 +59,46 @@ HelpButton::HelpButton(wxWindow *parent,wxString _page,wxPoint position,wxSize s
// Pressed // Pressed
void HelpButton::OnPressed(wxCommandEvent &event) { void HelpButton::OnPressed(wxCommandEvent &event) {
// Verify if the page is valid // Verify if the page is valid
if (page.IsEmpty()) { if (id.IsEmpty()) {
wxLogMessage(_T("TODO")); wxLogMessage(_T("TODO"));
return; return;
} }
// Open
OpenPage(id);
}
///////////////
// Open a page
void HelpButton::OpenPage(const wxString pageID) {
// Transcode
InitStatic();
wxString page = (*pages)[pageID];
// Get the file type // Get the file type
wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html")); wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html"));
if (type) { if (type) {
wxString command = type->GetOpenCommand(StandardPaths::DecodePath(wxString::Format(_T("?data/docs/%s.html"),page.c_str()))); wxString path = StandardPaths::DecodePath(wxString::Format(_T("http://aegisub.cellosoft.com/docs/%s"),page.c_str()));
if (!command.empty()) wxExecute(command); //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 // Browse button class
class HelpButton : public wxButton { class HelpButton : public wxButton {
private: private:
wxString page; wxString id;
void OnPressed(wxCommandEvent &event); void OnPressed(wxCommandEvent &event);
static std::map<wxString,wxString> *pages;
static void InitStatic();
public: public:
HelpButton(wxWindow *parent,wxString page=_T(""),wxPoint position=wxDefaultPosition,wxSize size=wxDefaultSize); HelpButton(wxWindow *parent,wxString page=_T(""),wxPoint position=wxDefaultPosition,wxSize size=wxDefaultSize);
static void OpenPage(const wxString page);
}; };