Add option to STC example to select drawing technology

This commit is contained in:
Maarten Bent 2020-05-31 23:42:33 +02:00
parent 0195d82832
commit a500c60feb
4 changed files with 18 additions and 1 deletions

View File

@ -70,6 +70,8 @@ enum {
myID_MULTIPLE_SELECTIONS,
myID_MULTI_PASTE,
myID_MULTIPLE_SELECTIONS_TYPING,
myID_TECHNOLOGY_DEFAULT,
myID_TECHNOLOGY_DIRECTWRITE,
myID_CUSTOM_POPUP,
myID_USECHARSET,
myID_CHARSETANSI,

View File

@ -128,6 +128,8 @@ wxBEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl)
EVT_MENU(myID_MULTI_PASTE, Edit::OnMultiPaste)
EVT_MENU(myID_MULTIPLE_SELECTIONS_TYPING, Edit::OnMultipleSelectionsTyping)
EVT_MENU(myID_CUSTOM_POPUP, Edit::OnCustomPopup)
EVT_MENU(myID_TECHNOLOGY_DEFAULT, Edit::OnTechnology)
EVT_MENU(myID_TECHNOLOGY_DIRECTWRITE, Edit::OnTechnology)
// stc
EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick)
EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded)
@ -480,6 +482,11 @@ void Edit::OnCustomPopup(wxCommandEvent& evt)
UsePopUp(evt.IsChecked() ? wxSTC_POPUP_NEVER : wxSTC_POPUP_ALL);
}
void Edit::OnTechnology(wxCommandEvent& event)
{
SetTechnology(event.GetId() == myID_TECHNOLOGY_DIRECTWRITE ? wxSTC_TECHNOLOGY_DIRECTWRITE : wxSTC_TECHNOLOGY_DEFAULT);
}
//! misc
void Edit::OnMarginClick (wxStyledTextEvent &event) {
if (event.GetMargin() == 2) {

View File

@ -102,6 +102,7 @@ public:
void OnMultiPaste(wxCommandEvent& event);
void OnMultipleSelectionsTyping(wxCommandEvent& event);
void OnCustomPopup(wxCommandEvent& evt);
void OnTechnology(wxCommandEvent& event);
// stc
void OnMarginClick (wxStyledTextEvent &event);
void OnCharAdded (wxStyledTextEvent &event);

View File

@ -572,7 +572,14 @@ void AppFrame::CreateMenu ()
menuExtra->AppendCheckItem(myID_MULTI_PASTE, _("Toggle multi-&paste"));
menuExtra->AppendCheckItem(myID_MULTIPLE_SELECTIONS_TYPING, _("Toggle t&yping on multiple selections"));
menuExtra->AppendSeparator();
menuExtra->AppendCheckItem (myID_CUSTOM_POPUP, _("C&ustom popup menu"));
#if defined(__WXMSW__) && wxUSE_GRAPHICS_DIRECT2D
wxMenu* menuTechnology = new wxMenu;
menuTechnology->AppendRadioItem(myID_TECHNOLOGY_DEFAULT, _("&Default"));
menuTechnology->AppendRadioItem(myID_TECHNOLOGY_DIRECTWRITE, _("Direct&Write"));
menuExtra->AppendSubMenu(menuTechnology, _("&Technology"));
menuExtra->AppendSeparator();
#endif
menuExtra->AppendCheckItem (myID_CUSTOM_POPUP, _("C&ustom context menu"));
// Window menu
wxMenu *menuWindow = new wxMenu;