/** Assign handlers for window close and URL clicked events. */ void HelpFrame::initHandlers() { // Handle URL events. myHelpPanel->aboutHtml->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(HelpFrame::followLink), NULL, this ); myHelpPanel->docHtml->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(HelpFrame::followLink), NULL, this ); myHelpPanel->creditsHtml->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(HelpFrame::followLink), NULL, this ); // Handle window close event. this->Connect(wxEVT_CLOSE_WINDOW, wxMouseEventHandler(HelpFrame::cancel), NULL, this); }
DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE() { // Disconnect Events m_htmlWindow->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this ); m_buttonClose->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnCloseButtonClick ), NULL, this ); }
// class constructor CCManager::CCManager() : m_AutocompPosition(wxSCI_INVALID_POSITION), m_CallTipActive(wxSCI_INVALID_POSITION), m_LastAutocompIndex(wxNOT_FOUND), m_LastTipPos(wxSCI_INVALID_POSITION), m_WindowBound(0), m_OwnsAutocomp(true), m_CallTipTimer(this, idCallTipTimer), m_AutoLaunchTimer(this, idAutoLaunchTimer), m_AutocompSelectTimer(this, idAutocompSelectTimer), #ifdef __WXMSW__ m_pAutocompPopup(nullptr), #endif // __WXMSW__ m_pLastEditor(nullptr), m_pLastCCPlugin(nullptr) { const wxString ctChars = wxT(",;\n()"); // default set m_CallTipChars[nullptr] = std::set<wxChar>(ctChars.begin(), ctChars.end()); const wxString alChars = wxT(".:<>\"#/"); // default set m_AutoLaunchChars[nullptr] = std::set<wxChar>(alChars.begin(), alChars.end()); m_LastACLaunchState[lsCaretStart] = wxSCI_INVALID_POSITION; m_pPopup = new UnfocusablePopupWindow(Manager::Get()->GetAppFrame()); m_pHtml = new wxHtmlWindow(m_pPopup, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE); int sizes[7] = {}; CCManagerHelper::BuildFontSizes(sizes, CCManagerHelper::GetDefaultHTMLFontSize()); m_pHtml->SetFonts(wxEmptyString, wxEmptyString, &sizes[0]); m_pHtml->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(CCManager::OnHtmlLink), nullptr, this); // wxFrame* mainFrame = Manager::Get()->GetAppFrame(); // wxMenuBar* menuBar = mainFrame->GetMenuBar(); // if (menuBar) // { // int idx = menuBar->FindMenu(wxT("&Edit")); // wxMenu* edMenu = menuBar->GetMenu(idx < 0 ? 0 : idx); // edMenu->Append(idCallTipNext, _("Next call tip\tCtrl-N")); // edMenu->Append(idCallTipPrevious, _("Previous call tip\tCtrl-P")); // } // mainFrame->Connect(idCallTipNext, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CCManager::OnMenuSelect), nullptr, this); // mainFrame->Connect(idCallTipPrevious, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CCManager::OnMenuSelect), nullptr, this); typedef cbEventFunctor<CCManager, CodeBlocksEvent> CCEvent; Manager::Get()->RegisterEventSink(cbEVT_APP_DEACTIVATED, new CCEvent(this, &CCManager::OnDeactivateApp)); Manager::Get()->RegisterEventSink(cbEVT_EDITOR_DEACTIVATED, new CCEvent(this, &CCManager::OnDeactivateEd)); Manager::Get()->RegisterEventSink(cbEVT_EDITOR_OPEN, new CCEvent(this, &CCManager::OnEditorOpen)); Manager::Get()->RegisterEventSink(cbEVT_EDITOR_CLOSE, new CCEvent(this, &CCManager::OnEditorClose)); Manager::Get()->RegisterEventSink(cbEVT_EDITOR_TOOLTIP, new CCEvent(this, &CCManager::OnEditorTooltip)); Manager::Get()->RegisterEventSink(cbEVT_SHOW_CALL_TIP, new CCEvent(this, &CCManager::OnShowCallTip)); Manager::Get()->RegisterEventSink(cbEVT_COMPLETE_CODE, new CCEvent(this, &CCManager::OnCompleteCode)); m_EditorHookID = EditorHooks::RegisterHook(new EditorHooks::HookFunctor<CCManager>(this, &CCManager::OnEditorHook)); Connect(idCallTipTimer, wxEVT_TIMER, wxTimerEventHandler(CCManager::OnTimer)); Connect(idAutoLaunchTimer, wxEVT_TIMER, wxTimerEventHandler(CCManager::OnTimer)); Connect(idAutocompSelectTimer, wxEVT_TIMER, wxTimerEventHandler(CCManager::OnTimer)); Connect(cbEVT_DEFERRED_CALLTIP_CANCEL, wxCommandEventHandler(CCManager::OnDeferredCallTipCancel)); }
// class destructor CCManager::~CCManager() { m_pHtml->Disconnect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(CCManager::OnHtmlLink), nullptr, this); m_pHtml->Destroy(); m_pPopup->Destroy(); wxFrame* mainFrame = Manager::Get()->GetAppFrame(); mainFrame->Disconnect(idCallTipNext, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CCManager::OnMenuSelect), nullptr, this); mainFrame->Disconnect(idCallTipPrevious, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CCManager::OnMenuSelect), nullptr, this); Manager::Get()->RemoveAllEventSinksFor(this); EditorHooks::UnregisterHook(m_EditorHookID, true); Disconnect(idCallTipTimer); Disconnect(idAutoLaunchTimer); Disconnect(idAutocompSelectTimer); Disconnect(cbEVT_DEFERRED_CALLTIP_CANCEL); }
void dialog_about::CreateNotebookHtmlPage( wxAuiNotebook* aParent, const wxString& aCaption, const wxBitmap& aIcon, const wxString& html ) { wxPanel* panel = new wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL ); wxString htmlPage = wxEmptyString, htmlContent = html; // to have a unique look background color for HTML pages is set to the default as it is // used for all the other widgets wxString htmlColor = ( this->GetBackgroundColour() ).GetAsString( wxC2S_HTML_SYNTAX ); // beginning of HTML structure htmlPage.Append( wxT( "<html><body bgcolor='" ) + htmlColor + wxT( "'>" ) ); htmlPage.Append( htmlContent ); // end of HTML structure indicated by closing tags htmlPage.Append( wxT( "</body></html>" ) ); // the HTML page is going to be created with previously created HTML content wxHtmlWindow* htmlWindow = new wxHtmlWindow( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxHW_NO_SELECTION ); // HTML font set to font properties as they are used for widgets to have an unique look // under different platforms with HTML wxFont font = this->GetFont(); htmlWindow->SetStandardFonts( font.GetPointSize(), font.GetFaceName(), font.GetFaceName() ); htmlWindow->SetPage( htmlPage ); // the HTML window shall not be used to open external links, thus this task is delegated // to users default browser htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( dialog_about::OnHtmlLinkClicked ), NULL, this ); // no additional space around the HTML window as it is also the case by the other notebook pages bSizer->Add( htmlWindow, 1, wxALL|wxEXPAND, 0 ); panel->SetSizer( bSizer ); panel->Layout(); bSizer->Fit( panel ); aParent->AddPage( panel, aCaption, false, aIcon ); }
DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( 400,120 ), wxDefaultSize ); wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); m_htmlWindow = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxSUNKEN_BORDER ); bMainSizer->Add( m_htmlWindow, 1, wxEXPAND, 5 ); m_buttonClose = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_buttonClose->SetDefault(); bMainSizer->Add( m_buttonClose, 0, wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); this->SetSizer( bMainSizer ); this->Layout(); // Connect Events m_htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this ); m_buttonClose->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnCloseButtonClick ), NULL, this ); }