%% options copyright owner = Dirk Krause copyright year = 2019-xxxx SPDX-License-Identifier: BSD-3-Clause %% wx-gui type = dialog contents = sizerHorizontal [wxBoxSizer sizerHorizontal] direction = horizontal contents = $space(10) contents = sizerVertical contents = $space(10) [wxBoxSizer sizerVertical] direction = vertical contents = $space(10) contents = sizerInputs centered-x contents = $space(10) contents = sizerResult centered-x contents = $space(10) contents = sizerButtons centered-x contents = $space(10) [wxGridBagSizer sizerInputs] grid = 5 5 contents = b00 0 0 1 1 left centered-y contents = b01 . +1 1 1 left centered-y contents = b02 . +1 1 1 left centered-y contents = b03 . +1 1 1 left centered-y contents = b04 +1 0 1 1 left centered-y contents = b05 . +1 1 1 left centered-y contents = b06 . +1 1 1 left centered-y contents = b07 . +1 1 1 left centered-y contents = b08 +1 0 1 1 left centered-y contents = b09 . +1 1 1 left centered-y contents = b10 . +1 1 1 left centered-y contents = $space(10) +1 0 1 1 left centered-y contents = checkboxBold +1 0 1 4 left centered-y contents = checkboxItalic +1 0 1 1 left centered-y contents = $space(10) +1 0 1 1 left centered-y [wxRadioButton b00] id = WXD_ID_FONT_00 text = pTexts[352] tip = pTexts[352] start group = yes [wxRadioButton b01] id = WXD_ID_FONT_01 text = pTexts[353] tip = pTexts[353] [wxRadioButton b02] id = WXD_ID_FONT_02 text = pTexts[354] tip = pTexts[354] [wxRadioButton b03] id = WXD_ID_FONT_03 text = pTexts[355] tip = pTexts[355] [wxRadioButton b04] id = WXD_ID_FONT_04 text = pTexts[356] tip = pTexts[356] [wxRadioButton b05] id = WXD_ID_FONT_05 text = pTexts[357] tip = pTexts[357] [wxRadioButton b06] id = WXD_ID_FONT_06 text = pTexts[358] tip = pTexts[358] [wxRadioButton b07] id = WXD_ID_FONT_07 text = pTexts[359] tip = pTexts[359] [wxRadioButton b08] id = WXD_ID_FONT_08 text = pTexts[360] tip = pTexts[360] [wxRadioButton b09] id = WXD_ID_FONT_09 text = pTexts[361] tip = pTexts[361] [wxRadioButton b10] id = WXD_ID_FONT_10 text = pTexts[362] tip = pTexts[362] [wxCheckBox checkboxBold] id = WXD_ID_FONT_BOLD text = pTexts[363] [wxCheckBox checkboxItalic] id = WXD_ID_FONT_ITALIC text = pTexts[364] [wxBoxSizer sizerResult] direction = vertical contents = labelFontname left contents = $space(5) contents = bitmapFontname centered-x [wxStaticText labelFontname] text = pTexts[352] [wxStaticBitmap bitmapFontname] bitmap = wxBitmap(pImages[0]) [wxStdDialogButtonSizer sizerButtons] contents = buttonOK contents = buttonCancel [wxButton buttonOK] id = wxID_OK text = pTexts[365] tip = pTexts[366] [wxButton buttonCancel] id = wxID_CANCEL text = pTexts[297] tip = pTexts[298] %% header start #ifndef WXDKDRAW_H_INCLUDED #include "wxdkdraw.h" #endif #ifndef WXDKDRAWFRAME_H_INCLUDED #include "WxdkdrawFrame.h" #endif %% class start /** Dialog to modify font. */ class WxdkdrawDlgFontName : public wxDialog { private: /** Events to process. */ #if wxCHECK_VERSION(3,0,0) wxDECLARE_EVENT_TABLE(); #else DECLARE_EVENT_TABLE() #endif %% class end protected: /** Applications main frame. */ WxdkdrawFrame *m_pParent; /** Object to modify. */ Wxd_object_t *m_pObject; /** Localized text fragments. */ wxChar const * const *m_pTexts; /** Images to show fonts. */ const char ** const *m_pImages; /** Original font number when opening dialog. */ uint8_t m_uOldFontnumber; /** Complete font number (family+bold+italic). */ uint8_t m_uFontnumber; /** Base font number, ignoring bold/italic. */ uint8_t m_uFontbase; /** Flag: Modify drawing object (style default object otherwise). */ bool m_bRealObj; public: /** Window IDs used in GUI. */ enum { WXD_ID_FONT_00 = (wxID_HIGHEST + 1), /**< Times. */ WXD_ID_FONT_01 , /**< AvantGarde. */ WXD_ID_FONT_02 , /**< Bookman. */ WXD_ID_FONT_03 , /**< Courier. */ WXD_ID_FONT_04 , /**< Helvetica. */ WXD_ID_FONT_05 , /**< HelveticaNarrow. */ WXD_ID_FONT_06 , /**< NewCenturySchoolbk. */ WXD_ID_FONT_07 , /**< Palatino. */ WXD_ID_FONT_08 , /**< Symbol. */ WXD_ID_FONT_09 , /**< ZapfChancery. */ WXD_ID_FONT_10 , /**< ZapfDingbats. */ WXD_ID_FONT_BOLD , /**< Bold font. */ WXD_ID_FONT_ITALIC /**< Italic font. */ }; public: /** Constructor. @param pParent Applications main frame. @param pObject Object to modify. @param bRealObj Flag: Real object (style object otherwise). @param pTexts Localized text fragments. @param pImages Images for line style buttons. */ WxdkdrawDlgFontName( WxdkdrawFrame *pParent, Wxd_object_t *pObject, bool bRealObj, wxChar const * const *pTexts, const char ** const *pImages ); /** Handler for radio button click. @param event Event to process. */ void OnFontFamily(wxCommandEvent & event); /** OK button handler. @param event Event to process. */ void OnOK(wxCommandEvent & event); /** Cancel button handler. @param event Event to process. */ void OnCancel(wxCommandEvent & event); /** Bold checkbox handler. @param event Event to process. */ void OnBold(wxCommandEvent & event); /** Italic checkbox handler. @param event Event to process. */ void OnItalic(wxCommandEvent & event); protected: /** Update UI after click on font family radio button or bold or italic checkbox. */ void UpdateFontInformation(void); }; %% header end /* vim: set ai sw=4 ts=4 : */ %% module start #ifndef WXDKDRAWDLGFONTNAME_H_INCLUDED #include "WxdkdrawDlgFontName.h" #endif $!trace-include /** Assign event handlers to window IDs. */ #if wxCHECK_VERSION(3,0,0) wxBEGIN_EVENT_TABLE(WxdkdrawDlgFontName,wxDialog) #else BEGIN_EVENT_TABLE(WxdkdrawDlgFontName,wxDialog) #endif EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_00,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_01,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_02,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_03,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_04,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_05,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_06,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_07,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_08,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_09,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_RADIOBUTTON(\ WxdkdrawDlgFontName::WXD_ID_FONT_10,\ WxdkdrawDlgFontName::OnFontFamily\ ) EVT_CHECKBOX(\ WxdkdrawDlgFontName::WXD_ID_FONT_BOLD,\ WxdkdrawDlgFontName::OnBold\ ) EVT_CHECKBOX(\ WxdkdrawDlgFontName::WXD_ID_FONT_ITALIC,\ WxdkdrawDlgFontName::OnItalic\ ) EVT_BUTTON(\ wxID_OK,\ WxdkdrawDlgFontName::OnOK\ ) EVT_BUTTON(\ wxID_CANCEL,\ WxdkdrawDlgFontName::OnCancel\ ) #if wxCHECK_VERSION(3,0,0) wxEND_EVENT_TABLE() #else END_EVENT_TABLE() #endif %% constructor start WxdkdrawDlgFontName::WxdkdrawDlgFontName( WxdkdrawFrame *pParent, Wxd_object_t *pObject, bool bRealObj, wxChar const * const *pTexts, const char ** const *pImages ) : wxDialog( pParent, wxID_ANY, pTexts[296], wxDefaultPosition, wxDefaultSize, ( (wxDEFAULT_DIALOG_STYLE) & (~(wxRESIZE_BORDER)) & (~(wxCLOSE_BOX)) & (~(wxSYSTEM_MENU)) ) ) { m_pParent = pParent; m_pObject = pObject; m_bRealObj = bRealObj; m_pTexts = pTexts; m_pImages = pImages; m_uOldFontnumber = m_uFontnumber = (pObject->det).t.find; m_uFontbase = m_uFontnumber; if (32U > m_uFontnumber) { m_uFontbase = 4U * (m_uFontbase / 4U); } %% constructor end if (dkctGUILayoutOK) { /* Fix dialog size */ wxSize minsize = GetMinSize(); SetMaxSize(minsize); /* Transfer font from drawing object to UI elements */ labelFontname->SetLabel(pTexts[299 + m_uFontnumber]); bitmapFontname->SetBitmap(wxBitmap(pImages[m_uFontnumber])); switch (m_uFontbase) { case 0 : { b00->SetValue(true); } break; case 4 : { b01->SetValue(true); } break; case 8 : { b02->SetValue(true); } break; case 12 : { b03->SetValue(true); } break; case 16 : { b04->SetValue(true); } break; case 20 : { b05->SetValue(true); } break; case 24 : { b06->SetValue(true); } break; case 28 : { b07->SetValue(true); } break; case 32 : { b08->SetValue(true); } break; case 33 : { b09->SetValue(true); } break; case 34 : { b10->SetValue(true); } break; } if (32U > m_uFontnumber) { switch (m_uFontnumber % 4U) { case 0 : { checkboxBold->SetValue(false); checkboxItalic->SetValue(false); } break; case 1 : { checkboxBold->SetValue(false); checkboxItalic->SetValue(true); } break; case 2 : { checkboxBold->SetValue(true); checkboxItalic->SetValue(false); } break; case 3 : { checkboxBold->SetValue(true); checkboxItalic->SetValue(true); } break; } } else { checkboxBold->SetValue(false); checkboxItalic->SetValue(false); checkboxBold->Enable(false); checkboxItalic->Enable(false); } } } %% module end void WxdkdrawDlgFontName::UpdateFontInformation(void) { $? "+ UpdateFontInformation" m_uFontnumber = m_uFontbase; if (32U > m_uFontnumber) { /* Fonts allowing bold/italic variants */ if (checkboxBold->GetValue()) { m_uFontnumber += 2U; } if (checkboxItalic->GetValue()) { m_uFontnumber += 1U; } checkboxBold->Enable(); checkboxItalic->Enable(); } else { /* Fonts without bold/italic variants */ checkboxBold->Enable(false); checkboxItalic->Enable(false); } /* Update dialog */ labelFontname->SetLabel(m_pTexts[299 + m_uFontnumber]); bitmapFontname->SetBitmap(m_pImages[m_uFontnumber]); Refresh(); Update(); (m_pObject->det).t.find = m_uFontnumber; /* When modifying a drawing element, update draw control */ if (m_bRealObj) { m_pParent->UpdateTextForFont(m_pObject); } $? "- UpdateFontInformation" } void WxdkdrawDlgFontName::OnFontFamily(wxCommandEvent & event) { $? "+ OnFontFamily %d", (int)(event.GetId()) m_uFontbase = 0U; switch (event.GetId()) { case WXD_ID_FONT_00 : { $? ". 00" m_uFontbase = 0U; } break; case WXD_ID_FONT_01 : { $? ". 01" m_uFontbase = 4U; } break; case WXD_ID_FONT_02 : { $? ". 02" m_uFontbase = 8U; } break; case WXD_ID_FONT_03 : { $? ". 03" m_uFontbase = 12U; } break; case WXD_ID_FONT_04 : { $? ". 04" m_uFontbase = 16U; } break; case WXD_ID_FONT_05 : { $? ". 05" m_uFontbase = 20U; } break; case WXD_ID_FONT_06 : { $? ". 06" m_uFontbase = 24U; } break; case WXD_ID_FONT_07 : { $? ". 07" m_uFontbase = 28U; } break; case WXD_ID_FONT_08 : { $? ". 08" m_uFontbase = 32U; } break; case WXD_ID_FONT_09 : { $? ". 09" m_uFontbase = 33U; } break; case WXD_ID_FONT_10 : { $? ". 10" m_uFontbase = 34U; } break; } $? ". m_uFontbase = %u", (unsigned)m_uFontbase UpdateFontInformation(); $? "- OnFontFamily" } void WxdkdrawDlgFontName::OnOK(wxCommandEvent & WXUNUSED(event)) { if (m_bRealObj) { m_pParent->RequireRedraw(WXD_REFRESH_DRAWING); } if(IsModal()) { EndModal(wxID_OK); } else { SetReturnCode(wxID_OK); Show(false); } } void WxdkdrawDlgFontName::OnCancel(wxCommandEvent & WXUNUSED(event)) { bool bDoRefresh = false; if ((m_bRealObj) && (m_uOldFontnumber != (m_pObject->det).t.find)) { bDoRefresh = true; } (m_pObject->det).t.find = m_uFontnumber = m_uOldFontnumber; if (bDoRefresh) { m_pParent->RequireRedraw(WXD_REFRESH_DRAWING); } if(IsModal()) { EndModal(wxID_CANCEL); } else { SetReturnCode(wxID_CANCEL); Show(false); } } void WxdkdrawDlgFontName::OnBold(wxCommandEvent & WXUNUSED(event)) { UpdateFontInformation(); } void WxdkdrawDlgFontName::OnItalic(wxCommandEvent & WXUNUSED(event)) { UpdateFontInformation(); } /* vim: set ai sw=4 ts=4 : */