%% options copyright owner = Dirk Krause copyright year = 2014 license = bsd %% wx-gui type = frame contents = mainSizer icon = wxdkhtb_icon status bar = 1 sTexts[8] menu bar = mbMain [wxMenuBar mbMain] contents = menuFile contents = menuHelp [wxMenu menuFile] text = sTexts[0] contents = miFileExit [wxMenuItem miFileExit] id = DkWxHtbFrame_Quit text = sTexts[1] tip = sTexts[2] [wxMenu menuHelp] text = sTexts[3] contents = miHelpAbout contents = miHelpContents [wxMenuItem miHelpAbout] id = DkWxHtbFrame_Help_About text = sTexts[4] tip = sTexts[5] [wxMenuItem miHelpContents] id = DkWxHtbFrame_Help_Contents text = sTexts[6] tip = sTexts[7] [wxBoxSizer mainSizer] direction = horizontal contents = $space(10) contents = verticalSizer contents = $space(10) [wxBoxSizer verticalSizer] direction = vertical grow = yes proportion = 1 contents = $space(10) contents = contentsSizer contents = $space(10) [wxGridBagSizer contentsSizer] grid = 5 5 # __CHANGE__ 015: The dummy label was added to have at least # one GUI element in the sizer. # Remove lDummy (next 4 lines) and add the real # window contents here. contents = lDummy 0 0 1 1 left [wxStaticText lDummy] text = sTexts[13] %% header start %% class start class DkWxHtbFrame : public DkWxFrame { private: /** Event table for frame. */ DECLARE_EVENT_TABLE() protected: /** Localized texts. */ wxChar const * const *sTexts; /** Non-localized texts. */ wxChar const * const *sNlWx; /** Non-localized texts. */ dkChar const * const *sNlDk; /** Help controller for htb file. */ wxHtmlHelpController *htbController; /** Status from help viewer creation. */ int iStatus; /** Flag: Can start to run. */ bool bCanRun; /** Mutex to protect access to bCanRun. */ wxMutex mProtectCanRun; %% class end public: /** Constructor. @param wxid Window ID. @param applicationHelper Application helper object. @param hc Help controller for online help. @param argc Number of command line arguments. @param argv Command line arguments array. @param localizedTexts Localized wxChar texts. @param nlWx Non-localized wxChar texts. @param nlDk Non-localized dkChar texts. @param is Status from help viewer creation. */ DkWxHtbFrame( int wxid, DkWxAppHelper *applicationHelper, wxHtmlHelpController *hc, int argc, wxChar **argv, wxChar const * const *localizedTexts, wxChar const * const *nlWx, dkChar const * const *nlDk, int is ); /** Destructor. */ ~DkWxHtbFrame(); /** Check whether we can close the window. @param isLast Flag: Last main window to close. */ bool canClose(bool isLast); /** Handler for File/Exit. @param event Event to process. */ void OnQuit(wxCommandEvent & event); /** Handler for Help/About. @param event Event to process. */ void OnAbout(wxCommandEvent & event); /** Handler for Help/Contents. @param event Event to process. */ void OnHelpContents(wxCommandEvent & event); /** Handler for idle events. */ void OnIdle(wxIdleEvent & event); /* __CHANGE__ 014: Add further methods. */ }; %% header end %% module start #include "wxdkhtb.h" #if !defined(__WXMSW__) #include "dkicon.xpm" #endif $!trace-include BEGIN_EVENT_TABLE(DkWxHtbFrame, wxFrame) EVT_MENU(DkWxHtbFrame_Quit, DkWxHtbFrame::OnQuit) EVT_MENU(DkWxHtbFrame_Help_About, DkWxHtbFrame::OnAbout) EVT_MENU(DkWxHtbFrame_Help_Contents, DkWxHtbFrame::OnHelpContents) EVT_IDLE(DkWxHtbFrame::OnIdle) END_EVENT_TABLE() /** Version number for version information. */ static wxChar const wxdkhtb_versnumber[] = { DKT_WXCHAR_VERSION }; %% constructor start DkWxHtbFrame::DkWxHtbFrame( int wxid, DkWxAppHelper *applicationHelper, wxHtmlHelpController *hc, int argc, wxChar **argv, wxChar const * const *localizedTexts, wxChar const * const *nlWx, dkChar const * const *nlDk, int is ) : DkWxFrame(nlWx[0], applicationHelper, NULL, wxid) { bCanRun = true; htbController = hc; iStatus = is; sTexts = localizedTexts; sNlWx = nlWx; sNlDk = nlDk; #if defined(__WXMSW__) wxIcon wxdkhtb_icon(sNlWx[4]); #else wxIcon wxdkhtb_icon(xpm_dkicon); #endif %% constructor end if(dkctGUILayoutOK) { SetTitle(nlWx[0]); restorePosition(); } } %% module end DkWxHtbFrame::~DkWxHtbFrame() { } bool DkWxHtbFrame::canClose(bool isLast) { bool back = true; return back; } void DkWxHtbFrame::OnQuit(wxCommandEvent & event) { Close(); } void DkWxHtbFrame::OnAbout(wxCommandEvent & event) { wxString text(wxT("")); wxString title(wxT("")); /* Construct message text. */ text.Append(sNlWx[0]); text.Append(sNlWx[7]); #if 0 text.Append(sNlWx[1]); #else text.append(wxdkhtb_versnumber); #endif text.Append(sNlWx[8]); text.Append(sTexts[9]); text.Append(sNlWx[2]); text.Append(sNlWx[8]); text.Append(sNlWx[8]); text.Append(sTexts[11]); text.Append(sNlWx[8]); text.Append(sNlWx[9]); text.Append(sNlWx[8]); text.Append(sNlWx[8]); text.Append(sTexts[12]); text.Append(sNlWx[8]); text.Append(sNlWx[10]); text.Append(sNlWx[8]); text.Append(sNlWx[11]); text.Append(sNlWx[8]); text.Append(sNlWx[12]); text.Append(sNlWx[8]); text.Append(sNlWx[13]); text.Append(sNlWx[8]); text.Append(sNlWx[14]); text.Append(sNlWx[8]); text.Append(sNlWx[15]); text.Append(sNlWx[8]); /* Construct dialog box title. */ title.Append(sTexts[10]); title.Append(sNlWx[0]); /* Show dialog box. */ wxMessageBox(text, title); /* __CHANGE__ 019: Create better about box. */ } void DkWxHtbFrame::OnHelpContents(wxCommandEvent & event) { #if 0 openHelp(); #endif if (htbController) { htbController->DisplayContents(); } } void DkWxHtbFrame::OnIdle(wxIdleEvent & event) { bool bRun = false; { wxMutexLocker lock(mProtectCanRun); bRun = bCanRun; bCanRun = false; } if (bRun) { switch (iStatus) { case 3: { if (htbController) { htbController->DisplayContents(); } else { wxMessageBox(sTexts[14], sTexts[15], (wxICON_ERROR | wxOK), this); Show(false); Close(); } } break; case 2: { /* Failed to create controller, not enough memory */ wxMessageBox(sTexts[18], sTexts[15], (wxICON_ERROR | wxOK), this); Show(false); Close(); } break; case 1: { /* File does not exist */ wxMessageBox(sTexts[17], sTexts[15], (wxICON_ERROR | wxOK), this); Show(false); Close(); } break; case 0: { /* No file specified */ wxMessageBox(sTexts[16], sTexts[15], (wxICON_ERROR | wxOK), this); Show(false); Close(); } break; } } /* event.RequestMore(); */ event.Skip(); }