ParamText::ParamText(wxPanel *panel, wxString pname, wxString labelname, wxString initval, int labelwid, int textwid) { wxControl::Create(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); name = pname; labelwidth = labelwid; textwidth = textwid; buttonwidth = 0; ostype = GetSystem(); textfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //textfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); if(ostype == Mac) textfont = wxFont(wxFontInfo(11).FaceName("Tahoma")); confont = textfont; sizer = new wxBoxSizer(wxHORIZONTAL); label = new wxStaticText(this, wxID_STATIC, labelname, wxDefaultPosition, wxSize(labelwidth, -1), wxALIGN_CENTRE); textbox = new wxTextCtrl(this, wxID_ANY, initval, wxDefaultPosition, wxSize(textwidth, -1), wxTE_PROCESS_ENTER); label->SetFont(textfont); textbox->SetFont(textfont); SetInitialSize(wxDefaultSize); Move(wxDefaultPosition); sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2); sizer->Add(textbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2); SetSizer(sizer); Layout(); }
ParamNum::ParamNum(wxPanel *panel, wxString pname, wxString labelname, double initval, int places) { int numheight = -1; wxControl::Create(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); name = pname; decimals = places; ostype = GetSystem(); textfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //textfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //textfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")); if(ostype == Mac) { textfont = wxFont(wxFontInfo(11).FaceName("Tahoma")); //textfont = wxFont(11, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")); numheight = 20; } sizer = new wxBoxSizer(wxHORIZONTAL); snum = numstring(initval, places); label = new wxStaticText(this, wxID_STATIC, labelname, wxDefaultPosition, wxSize(65, -1), wxALIGN_CENTRE); numbox = new wxTextCtrl(this, wxID_ANY, snum, wxDefaultPosition, wxSize(40, numheight), wxTE_PROCESS_ENTER); label->SetFont(textfont); numbox->SetFont(textfont); SetInitialSize(wxDefaultSize); Move(wxDefaultPosition); sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2); sizer->Add(numbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2); SetSizer(sizer); Layout(); }
wxFont CreateFontFromDesc(const String& fontDesc, int fontSize, int fontFamily) { wxFont font; // use the native font description if we have it if ( !fontDesc.empty() ) { wxNativeFontInfo fontInfo; if ( fontInfo.FromString(fontDesc) ) { font.SetNativeFontInfo(fontInfo); } } // if we don't, or if creating font from it failed, create the font with the // given size and family if we have [either of] them if ( !font.Ok() && (fontSize != -1 || fontFamily != wxFONTFAMILY_DEFAULT) ) { if ( fontSize == -1 ) fontSize = wxNORMAL_FONT->GetPointSize(); font = wxFontInfo(fontSize).Family(static_cast<wxFontFamily>(fontFamily)); } return font; }
ParamCon::ParamCon(ToolPanel *pan, wxString pname, wxString labelname, wxString initval, int labelwid, int numwid) // Stripped down string only version for text entry { ostype = GetSystem(); wxControl::Create(pan, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); panel = pan; name = pname; plabel = labelname; type = textcon; labelwidth = labelwid; numwidth = numwid; numheight = -1; pad = panel->controlborder; if(ostype == Mac) pad = 0; mainwin = panel->mainwin; //textfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); textfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); if(ostype == Mac) { textfont = wxFont(wxFontInfo(11).FaceName("Tahoma")); smalltextfont = wxFont(wxFontInfo(9).FaceName("Tahoma")); //textfont = wxFont(11, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //smalltextfont = wxFont(9, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); numheight = 12; } min = 0; max = 1000; // Text version needs min and max set for use with GetParams() sizer = new wxBoxSizer(wxHORIZONTAL); label = new ToolText(this, panel->toolbox, name, labelname, wxDefaultPosition, wxSize(labelwidth, -1), wxALIGN_CENTRE); numbox = new wxTextCtrl(this, wxID_ANY, initval, wxDefaultPosition, wxSize(numwidth, numheight), wxTE_PROCESS_ENTER); label->SetFont(textfont); if(ostype == Mac && labelwidth < 40) label->SetFont(smalltextfont); numbox->SetFont(textfont); SetInitialSize(wxDefaultSize); Move(wxDefaultPosition); sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, pad); sizer->Add(numbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, pad); SetSizer(sizer); Layout(); }
void ToolBox::Init() { SetPosition(); pinmode = 1; ostype = GetSystem(); diagbox = mainwin->diagbox; visible = true; status = NULL; buttonheight = 23; boxfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); confont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //boxfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //confont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); if(ostype == Mac) { buttonheight = 25; boxfont = wxFont(wxFontInfo(12).FaceName("Tahoma")); confont = wxFont(wxFontInfo(10).FaceName("Tahoma")); //boxfont = wxFont(12, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //confont = wxFont(10, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); } if(boxtype == 1) { winman = new wxAuiManager; winman->SetManagedWindow(this); panel = new ToolPanel(this, wxDefaultPosition, wxDefaultSize); // Base panel for default param file combobox panel->SetFont(boxfont); //mainbox = new wxBoxSizer(wxVERTICAL); //panel->SetSizer(mainbox); //tabpanel = new wxNotebook(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP); } else { panel = new ToolPanel(this, wxDefaultPosition, wxDefaultSize); panel->SetFont(boxfont); mainbox = new wxBoxSizer(wxVERTICAL); panel->SetSizer(mainbox); } activepanel = panel; //mod->diagbox->Write("ToolBox init\n"); Connect(wxEVT_MOVE, wxMoveEventHandler(ToolBox::OnMove)); Connect(wxEVT_SIZE, wxSizeEventHandler(ToolBox::OnSize)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(ToolBox::OnClose)); }
Edit::Edit (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; m_FoldingID = 2; // initialize language m_language = NULL; // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("WHITE")); MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("WHITE")); MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); // annotations AnnotationSetVisible(wxSTC_ANNOTATION_BOXED); // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key SetLayoutCache (wxSTC_CACHE_PAGE); UsePopUp(wxSTC_POPUP_ALL); }
wxToggleButton *ToolBox::ToggleButton(int id, wxString label, int width, wxBoxSizer *box, int point, wxPanel *pan) { if(pan == NULL) pan = activepanel; confont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //wxFont f(wxFontInfo(12).Underlined().FaceName("Courier")); //confont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); confont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //if(ostype == Mac) confont = wxFont(point, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); if(ostype == Mac) confont = wxFont(wxFontInfo(point).FaceName("Tahoma")); wxToggleButton *button = new wxToggleButton(pan, id, label, wxDefaultPosition, wxSize(width, buttonheight), 0); button->SetFont(confont); box->Add(button, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxTOP|wxBOTTOM, 1); Connect(id, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(ToolBox::OnToggle)); return button; }
wxStaticText *ToolBox::TextLabel(wxString label) { if(ostype == Mac) confont = wxFont(wxFontInfo(11).FaceName("Tahoma")); //confont = wxFont(11, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //wxStaticText *text = new (_NORMAL_BLOCK, __FILE__, __LINE__)wxStaticText(activepanel, wxID_ANY, label); wxStaticText *text = new wxStaticText(activepanel, wxID_ANY, label); text->SetFont(confont); return text; }
Console::Console(wxWindow* parent, wxWindowID id, const wxPoint &pos, const wxSize &size) : wxPanel(parent, id, pos, size) { wxBoxSizer *hbox = new wxBoxSizer(wxVERTICAL); _textctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, pos, size, wxTE_MULTILINE | wxTE_DONTWRAP | wxTE_READONLY); #ifdef __WXOSX__ wxFont font(wxFontInfo(12).FaceName("Menlo")); #elif __WXGTK__ wxFont font(wxFontInfo(9).FaceName("Roboto Mono")); #else wxFont font(wxFontInfo(9).FaceName("Consolas")); #endif _textctrl->SetFont(font); hbox->Add(_textctrl, 1, wxEXPAND | wxALL, 0); SetSizerAndFit(hbox); DisplayProcess* dp = new DisplayProcess(_textctrl); dp->Execute("git"); delete dp; }
void wxFontDataProperty::OnSetValue() { if ( !m_value.IsType("wxFontData") ) { if ( m_value.IsType("wxFont") ) { wxFont font; font << m_value; wxFontData fontData; fontData.SetChosenFont(font); if ( !m_value_wxFontData.IsNull() ) { wxFontData oldFontData; oldFontData << m_value_wxFontData; fontData.SetColour(oldFontData.GetColour()); } else { fontData.SetColour(*wxBLACK); } wxVariant variant; variant << fontData; m_value_wxFontData = variant; } else { wxFAIL_MSG("Value to wxFontDataProperty must be either wxFontData or wxFont"); } } else { // Set m_value to wxFont so that wxFontProperty methods will work // correctly. m_value_wxFontData = m_value; wxFontData fontData; fontData << m_value_wxFontData; wxFont font = fontData.GetChosenFont(); if ( !font.IsOk() ) font = wxFontInfo(10).Family(wxFONTFAMILY_SWISS); m_value = WXVARIANT(font); } }
void SourceView::setCppMode() { SetLexer (wxSTC_LEX_CPP); SetKeyWords (0, keywords.Get()); StyleClearAll (); SetMarginType (0, wxSTC_MARGIN_NUMBER); SetMarginWidth (0, 40); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour( 32, 32, 32)); StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour(192,192,192)); SetMarginType (1, wxSTC_MARGIN_RTEXT); SetMarginWidth (1, 50); StyleSetForeground (MARGIN_TEXT_STYLE, wxColour(255, 0, 0)); StyleSetBackground (MARGIN_TEXT_STYLE, wxColour(192,192,192)); StyleSetForeground (wxSTC_C_DEFAULT, wxColour(0,0,0) ); StyleSetForeground (wxSTC_C_STRING, wxColour(163,21,21)); StyleSetForeground (wxSTC_C_PREPROCESSOR, wxColour(0,0,255)); StyleSetForeground (wxSTC_C_IDENTIFIER, wxColour(0,0,0)); StyleSetForeground (wxSTC_C_WORD, wxColour(0,0,255)); StyleSetForeground (wxSTC_C_WORD2, wxColour(0,0,255)); StyleSetForeground (wxSTC_C_NUMBER, wxColour(0,0,0)); StyleSetForeground (wxSTC_C_CHARACTER, wxColour(0,0,0)); StyleSetForeground (wxSTC_C_COMMENT, wxColour(0,128,0)); StyleSetForeground (wxSTC_C_COMMENTLINE, wxColour(0,128,0)); StyleSetForeground (wxSTC_C_COMMENTDOC, wxColour(0,128,0)); StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORD, wxColour(0,128,0)); StyleSetForeground (wxSTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,128,0)); StyleSetBold(wxSTC_C_WORD, true); StyleSetBold(wxSTC_C_WORD2, true); StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); for (int i = wxSTC_C_DEFAULT; i<=wxSTC_C_PREPROCESSORCOMMENT; ++i) StyleSetFont(i, wxFont( wxFontInfo(10).FaceName("Consolas") ) ); }
wxFont LexerConf::GetFontForSyle(int styleId) const { StyleProperty::Map_t::const_iterator iter = m_properties.find(styleId); if(iter != m_properties.end()) { const StyleProperty& prop = iter->second; int fontSize(prop.GetFontSize()); wxString face = prop.GetFaceName(); if(face.IsEmpty()) { // defaults fontSize = DEFAULT_FONT_SIZE; face = DEFAULT_FACE_NAME; } wxFontInfo fontInfo = wxFontInfo(fontSize) .Family(wxFONTFAMILY_TELETYPE) .Italic(prop.GetItalic()) .Bold(prop.IsBold()) .Underlined(prop.GetUnderlined()) .FaceName(face); wxFont font(fontInfo); return font; } return wxNullFont; }
void GraphicsContextDrawingTestCase::DoFontDrawings (wxGraphicsContext *gc) { #ifdef __WXGTK__ wxGCC_WARNING_SUPPRESS(deprecated-declarations) g_type_init(); wxGCC_WARNING_RESTORE() #endif // This test is expected to treat about fonts/texts. Fonts are a bit special // because we cannot expect the same rendering by several engines, and the // dimensions of the same text in same font will vary. wxGraphicsBrush gbBackground = gc->CreateBrush( wxBrush ( wxColour ( 240, 240, 240 ) ) ); gc->SetBrush( gbBackground ); gc->DrawRectangle(0, 0, 800, 600); wxGraphicsBrush gbTextBackground = gc->CreateBrush( wxBrush ( wxColour ( 192, 192, 192 ) ) ); // set underlined font for testing gc->SetFont( wxFont(wxFontInfo(12).Family(wxFONTFAMILY_MODERN).Underlined()), *wxBLACK ); gc->DrawText( wxT("This is text"), 110, 10, gbTextBackground ); gc->DrawText( wxT("That is text"), 20, 10, wxDegToRad(-45), gbTextBackground ); // use wxSWISS_FONT and not wxNORMAL_FONT as the latter can't be rotated // under Win9x (it is not TrueType) gc->SetFont( wxFont(wxFontInfo(12).Family(wxFONTFAMILY_SWISS)), *wxBLACK ); wxString text; for ( int n = -180; n < 180; n += 30 ) { text.Printf(wxT(" %d rotated text"), n); gc->DrawText(text , 400, 400, wxDegToRad(n) ); } wxFont swissDcFont( wxFontInfo(18).Family(wxFONTFAMILY_SWISS) ); wxGraphicsFont swissFont = gc->CreateFont( swissDcFont, *wxBLACK ); gc->SetFont( swissFont ); gc->DrawText( wxT("This is Swiss 18pt text."), 110, 40 ); wxDouble length; wxDouble height; wxDouble descent; gc->GetTextExtent( wxT("This is Swiss 18pt text."), &length, &height, &descent ); text.Printf( wxT("Dimensions are length %f, height %f, descent %f"), length, height, descent ); gc->DrawText( text, 110, 80 ); // (did not find equivalent to CharHeight()) gc->SetBrush( *wxWHITE_BRUSH ); gc->DrawRectangle( 100, 40, 4, height ); // test the logical function effect wxCoord y = 150; // text drawing should ignore logical function gc->DrawText( wxT("There should be a text below"), 110, 150 ); gc->DrawRectangle( 110, y, 100, height ); y += height; gc->DrawText( wxT("Visible text"), 110, y ); gc->DrawRectangle( 110, y, 100, height ); gc->DrawText( wxT("Visible text"), 110, y ); gc->DrawRectangle( 110, y, 100, height ); y += height; gc->DrawRectangle( 110, y, 100, height ); gc->DrawText( wxT("Another visible text"), 110, y ); y += height; gc->DrawText("And\nmore\ntext on\nmultiple\nlines", 110, y); y += 5*height; gc->SetFont( swissDcFont, *wxBLUE ); gc->DrawText( "Rotated text\ncan have\nmultiple lines\nas well", 110, y, wxDegToRad(15) ); }
void dlgVSCPMsg::CreateControls() { ////@begin dlgVSCPMsg content construction dlgVSCPMsg* itemDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_TOP|wxALL, 5); itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer3->Add(itemBoxSizer6, 0, wxALIGN_TOP|wxALL, 5); wxFlexGridSizer* itemFlexGridSizer7 = new wxFlexGridSizer(2, 2, 0, 0); itemBoxSizer6->Add(itemFlexGridSizer7, 1, wxALIGN_TOP|wxALL, 1); wxStaticText* itemStaticText8 = new wxStaticText; itemStaticText8->Create( itemDialog1, wxID_STATIC, _("Class :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText8->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText8->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxArrayString m_choiceVscpClassStrings; m_choiceVscpClass = new wxComboBox; m_choiceVscpClass->Create( itemDialog1, ID_COMBOBOX2, _T(""), wxDefaultPosition, wxSize(200, -1), m_choiceVscpClassStrings, wxCB_DROPDOWN ); itemFlexGridSizer7->Add(m_choiceVscpClass, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxStaticText* itemStaticText10 = new wxStaticText; itemStaticText10->Create( itemDialog1, wxID_STATIC, _("Type :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText10->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText10->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxArrayString m_wxChoiceVscpTypeStrings; m_wxChoiceVscpType = new wxComboBox; m_wxChoiceVscpType->Create( itemDialog1, ID_COMBOBOX3, _T(""), wxDefaultPosition, wxSize(200, -1), m_wxChoiceVscpTypeStrings, wxCB_DROPDOWN ); itemFlexGridSizer7->Add(m_wxChoiceVscpType, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxStaticText* itemStaticText12 = new wxStaticText; itemStaticText12->Create( itemDialog1, wxID_STATIC, _("Priority :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText12->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText12->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText12, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxArrayString m_wxChoicePriorityStrings; m_wxChoicePriorityStrings.Add(_("0 - Highest")); m_wxChoicePriorityStrings.Add(_("1 - Even higher")); m_wxChoicePriorityStrings.Add(_("2 - Higher")); m_wxChoicePriorityStrings.Add(_("3 - Normal high")); m_wxChoicePriorityStrings.Add(_("4 - Normal low")); m_wxChoicePriorityStrings.Add(_("5 - Lower")); m_wxChoicePriorityStrings.Add(_("6 - Even lower")); m_wxChoicePriorityStrings.Add(_("7 - Lowest")); m_wxChoicePriority = new wxChoice; m_wxChoicePriority->Create( itemDialog1, ID_CHOICE, wxDefaultPosition, wxSize(120, -1), m_wxChoicePriorityStrings, 0 ); m_wxChoicePriority->SetStringSelection(_("0")); itemFlexGridSizer7->Add(m_wxChoicePriority, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 1); itemFlexGridSizer7->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_TOP|wxRIGHT|wxTOP|wxBOTTOM, 2); itemFlexGridSizer7->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_TOP|wxRIGHT|wxTOP|wxBOTTOM, 2); itemFlexGridSizer7->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_TOP|wxRIGHT|wxTOP|wxBOTTOM, 2); wxStaticText* itemStaticText17 = new wxStaticText; itemStaticText17->Create( itemDialog1, wxID_STATIC, _("GUID"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText17->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText17->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText17, 1, wxALIGN_LEFT|wxALIGN_TOP|wxALL, 0); wxStaticText* itemStaticText18 = new wxStaticText; itemStaticText18->Create( itemDialog1, wxID_STATIC, _("15 - 8 :"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText18->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText18->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText18, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL); itemFlexGridSizer7->Add(itemBoxSizer19, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 1); m_strGUID15 = new wxTextCtrl; m_strGUID15->Create( itemDialog1, ID_TEXTCTRL22, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_strGUID15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID14 = new wxTextCtrl; m_wxStrGUID14->Create( itemDialog1, ID_TEXTCTRL23, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID13 = new wxTextCtrl; m_wxStrGUID13->Create( itemDialog1, ID_TEXTCTRL24, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID12 = new wxTextCtrl; m_wxStrGUID12->Create( itemDialog1, ID_TEXTCTRL25, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID11 = new wxTextCtrl; m_wxStrGUID11->Create( itemDialog1, ID_TEXTCTRL26, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID10 = new wxTextCtrl; m_wxStrGUID10->Create( itemDialog1, ID_TEXTCTRL27, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID9 = new wxTextCtrl; m_wxStrGUID9->Create( itemDialog1, ID_TEXTCTRL28, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID8 = new wxTextCtrl; m_wxStrGUID8->Create( itemDialog1, ID_TEXTCTRL29, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer19->Add(m_wxStrGUID8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); wxStaticText* itemStaticText28 = new wxStaticText; itemStaticText28->Create( itemDialog1, wxID_STATIC, _("7 - 0 :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText28->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText28->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText28, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); wxBoxSizer* itemBoxSizer29 = new wxBoxSizer(wxHORIZONTAL); itemFlexGridSizer7->Add(itemBoxSizer29, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID7 = new wxTextCtrl; m_wxStrGUID7->Create( itemDialog1, ID_TEXTCTRL30, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID6 = new wxTextCtrl; m_wxStrGUID6->Create( itemDialog1, ID_TEXTCTRL31, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID5 = new wxTextCtrl; m_wxStrGUID5->Create( itemDialog1, ID_TEXTCTRL32, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID4 = new wxTextCtrl; m_wxStrGUID4->Create( itemDialog1, ID_TEXTCTRL33, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID3 = new wxTextCtrl; m_wxStrGUID3->Create( itemDialog1, ID_TEXTCTRL34, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID2 = new wxTextCtrl; m_wxStrGUID2->Create( itemDialog1, ID_TEXTCTRL35, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID1 = new wxTextCtrl; m_wxStrGUID1->Create( itemDialog1, ID_TEXTCTRL36, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_wxStrGUID0 = new wxTextCtrl; m_wxStrGUID0->Create( itemDialog1, ID_TEXTCTRL37, _("0"), wxDefaultPosition, wxSize(40, -1), wxTE_RIGHT ); itemBoxSizer29->Add(m_wxStrGUID0, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); wxStaticText* itemStaticText38 = new wxStaticText; itemStaticText38->Create( itemDialog1, wxID_STATIC, _("Data :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText38->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText38->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText38, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); m_strVscpData = new wxTextCtrl; m_strVscpData->Create( itemDialog1, ID_TEXTCTRL38, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); if (dlgVSCPMsg::ShowToolTips()) m_strVscpData->SetToolTip(_("You enter data for the event as a comma separated list. You can arrange the data on lines. Hexadecimal values should be preceded with '0x'.")); itemFlexGridSizer7->Add(m_strVscpData, 2, wxGROW|wxALIGN_TOP|wxALL, 1); itemFlexGridSizer7->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_TOP|wxRIGHT|wxTOP|wxBOTTOM, 2); itemFlexGridSizer7->Add(5, 5, 0, wxALIGN_LEFT|wxALIGN_TOP|wxRIGHT|wxTOP|wxBOTTOM, 2); wxStaticText* itemStaticText42 = new wxStaticText; itemStaticText42->Create( itemDialog1, wxID_STATIC, _("Note :"), wxDefaultPosition, wxDefaultSize, 0 ); #if ( ( wxMAJOR_VERSION >= 3 ) && ( wxMINOR_VERSION >= 1 ) ) itemStaticText42->SetFont(wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText42->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma"))); #endif itemFlexGridSizer7->Add(itemStaticText42, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 1); m_strNote = new wxTextCtrl; m_strNote->Create( itemDialog1, ID_TEXTCTRL39, _T(""), wxDefaultPosition, wxSize(-1, 50), 0 ); itemFlexGridSizer7->Add(m_strNote, 2, wxGROW|wxALIGN_TOP|wxALL, 1); wxBoxSizer* itemBoxSizer44 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer3->Add(itemBoxSizer44, 0, wxALIGN_BOTTOM|wxALL, 1); wxBoxSizer* itemBoxSizer45 = new wxBoxSizer(wxVERTICAL); itemBoxSizer44->Add(itemBoxSizer45, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton46 = new wxButton; itemButton46->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer45->Add(itemButton46, 0, wxALIGN_RIGHT|wxALL, 1); wxButton* itemButton47 = new wxButton; itemButton47->Create( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer45->Add(itemButton47, 0, wxALIGN_RIGHT|wxALL, 1); ////@end dlgVSCPMsg content construction }
// Create the fonts void MainWindow::CreateFonts() { m_normalFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS)); m_boldFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS).Bold()); m_italicFont = wxTheFontList->FindOrCreateFont(wxFontInfo(pointSize).Family(wxFONTFAMILY_SWISS).Italic()); }
const struct Sizes { int specified; // Size in points specified in the ctor. int expected; // Expected GetPointSize() return value, // -1 here means "same as wxNORMAL_FONT". } sizes[] = { { 9, 9 }, { 10, 10 }, { 11, 11 }, { -1, -1 }, { 70, -1 }, // 70 == wxDEFAULT, should be handled specially { 90, 90 }, // 90 == wxNORMAL, should not be handled specially }; const int sizeDefault = wxFont(wxFontInfo()).GetPointSize(); for ( size_t n = 0; n < WXSIZEOF(sizes); n++ ) { const Sizes& size = sizes[n]; // Note: use the old-style wxFont ctor as wxFontInfo doesn't implement // any compatibility hacks. const wxFont font(size.specified, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); int expected = size.expected; if ( expected == -1 ) expected = sizeDefault;
// ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- // the mask used to extract the pitch from LOGFONT::lfPitchAndFamily field static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH; // ---------------------------------------------------------------------------- // wxFontRefData - the internal description of the font // ---------------------------------------------------------------------------- class WXDLLEXPORT wxFontRefData: public wxGDIRefData { public: wxFontRefData(const wxFontInfo& info = wxFontInfo()); wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0) { Init(info, hFont); } wxFontRefData(const wxFontRefData& data) : wxGDIRefData() { Init(data.m_nativeFontInfo); } virtual ~wxFontRefData(); // operations bool Alloc();
MyFrame::MyFrame() : wxFrame(NULL, wxID_ANY, wxT("STC test"), wxDefaultPosition, wxSize(1024, 768)) { TextCtrl = new wxStyledTextCtrl(this, wxID_ANY); TextCtrl->SetFocus(); // set all of the used styles to the same font // each token type has its own 'style' that can be changed // independently. wxFont font(wxFontInfo(10).AntiAliased(true).FaceName(wxT("Courier New"))); for (int i = wxSTC_H_DEFAULT; i <= wxSTC_H_QUESTION; i++) { TextCtrl->StyleSetFont(i, font); } TextCtrl->StyleSetFont(wxSTC_H_VALUE, font); for (int i = wxSTC_HPHP_DEFAULT; i <= wxSTC_HPHP_OPERATOR; i++) { TextCtrl->StyleSetFont(i, font); } TextCtrl->StyleSetFont(wxSTC_HPHP_COMPLEX_VARIABLE, font); // the lexer that highlights PHP code is the wxSTC_LEX_HTML. this lexer can handle // HTML and any embedded server side language (PHP, ASP, Python, etc..). Because of // this, the lexer has more states than all other lexers; that's why we need // to set aside more style bits for this lexer. TextCtrl->SetLexer(wxSTC_LEX_HTML); TextCtrl->SetStyleBits(7); // make the keywords bold and blue. TextCtrl->StyleSetBold(wxSTC_HPHP_WORD, true); TextCtrl->StyleSetForeground(wxSTC_HPHP_WORD, *wxBLUE); TextCtrl->SetKeyWords(0, wxT("html body")); TextCtrl->SetKeyWords(4, wxString::FromAscii("php if else do while for foreach switch case " "break default function return public private protected class " " interface extends implements static")); // make comments dark green TextCtrl->StyleSetBold(wxSTC_HPHP_COMMENT, true); TextCtrl->StyleSetBold(wxSTC_HPHP_COMMENTLINE, true); TextCtrl->StyleSetForeground(wxSTC_HPHP_COMMENT, wxTheColourDatabase->Find(wxT("Dark Green"))); TextCtrl->StyleSetBackground(wxSTC_HPHP_COMMENTLINE, wxTheColourDatabase->Find(wxT("Dark Green"))); // intialize the markers. this marker will be used to put arrows in the // left margin const int HIT_MARKER = 1; TextCtrl->MarkerDefine(HIT_MARKER, wxSTC_MARK_ARROW, *wxRED, *wxRED); TextCtrl->SetText(wxT("<?php\r\nfunction f() {\n\n}\n\n$s = \"this is a test this \";\r\n?>")); TextCtrl->Colourise(0, -1); // 128 => 8th bit on since first 7 bits of style bits are for the lexer // this means that there is only one bit left for indicators; resulting // in only 1 indicator being avaible when using scintilla with the HTML lexer. int STYLE_FIND = 128; int INDICATOR = 0; TextCtrl->IndicatorSetStyle(INDICATOR, wxSTC_INDIC_SQUIGGLE); TextCtrl->IndicatorSetForeground(INDICATOR, *wxRED); wxString text = TextCtrl->GetText(); wxRegEx regEx(wxT("this")); if (regEx.IsValid()) { size_t matchStart, matchLength; int lastHit = 0; while (regEx.Matches(text, 0)) { if (regEx.GetMatch(&matchStart, &matchLength, 0)) { printf("hit at %ld (length: %ld)\n", (lastHit + matchStart), matchLength); TextCtrl->StartStyling(lastHit + matchStart, STYLE_FIND); TextCtrl->SetStyling(matchLength, STYLE_FIND); // careful with positions; STC positions are byte offsets while // most string functions from wxString or UnicodeString or std::string // are in characters. This means that we always need to do // conversion from chars to bytes, otherwise line numbers will be off. In this case, since the // text is ASCII it is OK. int line = TextCtrl->LineFromPosition(lastHit + matchStart); // in this demo the markes will stay forever; but in an application // we must explicitly call MarkerDelete to remove // the markers. TextCtrl->MarkerAdd(line, HIT_MARKER); } lastHit = matchStart + matchLength; text = text.substr(lastHit, -1); } TextCtrl->Colourise(0, -1); } }
void OnPaint() { wxPaintDC dc(this); auto rect = GetClientRect(); dc.SetPen(wxPen(wxColor(0x26, 0x1E, 0x00))); dc.SetBrush(wxBrush(wxColor(0x26, 0x1E, 0x00))); dc.DrawRectangle(rect); int const disp_half = rect.GetWidth() / 2; int const disp_shift = kFullKeysWidth / 2 - disp_half; auto draw_key = [&](auto note_num, auto const &prop, auto const &img) { int const octave = note_num / 12; auto key_rect = prop.rect_; key_rect.Offset(octave * kKeyWidth * 7 - disp_shift, 0); if(key_rect.GetLeft() >= rect.GetWidth()) { return; } if(key_rect.GetRight() < 0) { return; } dc.DrawBitmap(wxBitmap(img), key_rect.GetTopLeft()); // if(is_playing) { // col_pen = kKeyBorderColorPlaying; // col_brush = kPlayingNoteColor; // dc.SetPen(wxPen(col_pen)); // dc.SetBrush(wxBrush(col_brush)); // } // dc.DrawRoundedRectangle(key_rect, 2); }; for(int i = 0; i < kNumKeys; ++i) { if(IsWhiteKey(i) == false) { continue; } bool const is_playing = playing_notes_[i]; bool next_pushed = false; if(i < kNumKeys - 2) { if(IsWhiteKey(i+1) && playing_notes_[i+1]) { next_pushed = true; } else if(IsWhiteKey(i+2) && playing_notes_[i+2]) { next_pushed = true; } } auto const &img = (is_playing && next_pushed) ? img_white_pushed_contiguous_ : (is_playing ? img_white_pushed_ : img_white_); draw_key(i, kKeyPropertyList[i % 12], img); } for(int i = 0; i < kNumKeys; ++i) { if(IsBlackKey(i) == false) { continue; } bool const is_playing = playing_notes_[i]; auto const &img = (is_playing ? img_black_pushed_ : img_black_); draw_key(i, kKeyPropertyList[i % 12], img); } auto font = wxFont(wxFontInfo(wxSize(8, 10)).Family(wxFONTFAMILY_DEFAULT)); dc.SetFont(font); for(int i = 0; i < kNumKeys; i += 12) { int const octave = i / 12; dc.DrawLabel(wxString::Format("C%d", i / 12 - 2), wxBitmap(), wxRect(wxPoint(octave * kKeyWidth * 7 - disp_shift, rect.GetHeight() * 0.8), wxSize(kKeyWidth, 10)), wxALIGN_CENTER ); } }
void MyFrame::OnViewMsg(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_FILEDLG // first, choose the file static wxString s_dir, s_file; wxFileDialog dialog(this, wxT("Open an email message file"), s_dir, s_file); if ( dialog.ShowModal() != wxID_OK ) return; // save for the next time s_dir = dialog.GetDirectory(); s_file = dialog.GetFilename(); wxString filename = dialog.GetPath(); // load it and search for Content-Type header wxTextFile file(filename); if ( !file.Open() ) return; wxString charset; static const wxChar *prefix = wxT("Content-Type: text/plain; charset="); const size_t len = wxStrlen(prefix); size_t n, count = file.GetLineCount(); for ( n = 0; n < count; n++ ) { wxString line = file[n]; if ( !line ) { // if it is an email message, headers are over, no need to parse // all the file break; } if ( line.Left(len) == prefix ) { // found! const wxChar *pc = line.c_str() + len; if ( *pc == wxT('"') ) pc++; while ( *pc && *pc != wxT('"') ) { charset += *pc++; } break; } } if ( !charset ) { wxLogError(wxT("The file '%s' doesn't contain charset information."), filename.c_str()); return; } // ok, now get the corresponding encoding wxFontEncoding fontenc = wxFontMapper::Get()->CharsetToEncoding(charset); if ( fontenc == wxFONTENCODING_SYSTEM ) { wxLogError(wxT("Charset '%s' is unsupported."), charset.c_str()); return; } m_textctrl->LoadFile(filename); if ( fontenc == wxFONTENCODING_UTF8 || !wxFontMapper::Get()->IsEncodingAvailable(fontenc) ) { // try to find some similar encoding: wxFontEncoding encAlt; if ( wxFontMapper::Get()->GetAltForEncoding(fontenc, &encAlt) ) { wxEncodingConverter conv; if (conv.Init(fontenc, encAlt)) { fontenc = encAlt; m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue())); } else { wxLogWarning(wxT("Cannot convert from '%s' to '%s'."), wxFontMapper::GetEncodingDescription(fontenc).c_str(), wxFontMapper::GetEncodingDescription(encAlt).c_str()); } } else wxLogWarning(wxT("No fonts for encoding '%s' on this system."), wxFontMapper::GetEncodingDescription(fontenc).c_str()); } // and now create the correct font if ( !DoEnumerateFamilies(false, fontenc, true /* silent */) ) { wxFont font(wxFontInfo(wxNORMAL_FONT->GetPointSize()).Encoding(fontenc)); if ( font.IsOk() ) { DoChangeFont(font); } else { wxLogWarning(wxT("No fonts for encoding '%s' on this system."), wxFontMapper::GetEncodingDescription(fontenc).c_str()); } } #endif // wxUSE_FILEDLG }
bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, wxFontEncoding encoding, bool silent) { MyFontEnumerator fontEnumerator; fontEnumerator.EnumerateFacenames(encoding, fixedWidthOnly); if ( fontEnumerator.GotAny() ) { int nFacenames = fontEnumerator.GetFacenames().GetCount(); if ( !silent ) { wxLogStatus(this, wxT("Found %d %sfonts"), nFacenames, fixedWidthOnly ? wxT("fixed width ") : wxT("")); } wxString facename; if ( silent ) { // choose the first facename = fontEnumerator.GetFacenames().Item(0); } else { // let the user choose wxString *facenames = new wxString[nFacenames]; int n; for ( n = 0; n < nFacenames; n++ ) facenames[n] = fontEnumerator.GetFacenames().Item(n); n = wxGetSingleChoiceIndex ( wxT("Choose a facename"), SAMPLE_TITLE, nFacenames, facenames, this ); if ( n != -1 ) facename = facenames[n]; delete [] facenames; } if ( !facename.empty() ) { wxFont font(wxFontInfo().FaceName(facename).Encoding(encoding)); DoChangeFont(font); } return true; } else if ( !silent ) { wxLogWarning(wxT("No such fonts found.")); } return false; }
bool Edit::InitializePrefs (const wxString &name) { // initialize styles StyleClearAll(); LanguageInfo const* curInfo = NULL; // determine language bool found = false; int languageNr; for (languageNr = 0; languageNr < g_LanguagePrefsSize; languageNr++) { curInfo = &g_LanguagePrefs [languageNr]; if (curInfo->name == name) { found = true; break; } } if (!found) return false; // set lexer and language SetLexer (curInfo->lexer); m_language = curInfo; // set margin for line numbers SetMarginType (m_LineNrID, wxSTC_MARGIN_NUMBER); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); SetMarginWidth (m_LineNrID, 0); // start out not visible // annotations style StyleSetBackground(ANNOTATION_STYLE, wxColour(244, 220, 220)); StyleSetForeground(ANNOTATION_STYLE, *wxBLACK); StyleSetSizeFractional(ANNOTATION_STYLE, (StyleGetSizeFractional(wxSTC_STYLE_DEFAULT)*4)/5); // default fonts for all styles! int Nr; for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) { wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (Nr, font); } // set common styles StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (wxT("DARK GREY"))); StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); // initialize settings if (g_CommonPrefs.syntaxEnable) { int keywordnr = 0; for (Nr = 0; Nr < STYLE_TYPES_COUNT; Nr++) { if (curInfo->styles[Nr].type == -1) continue; const StyleInfo &curType = g_StylePrefs [curInfo->styles[Nr].type]; wxFont font(wxFontInfo(curType.fontsize) .Family(wxFONTFAMILY_MODERN) .FaceName(curType.fontname)); StyleSetFont (Nr, font); if (curType.foreground) { StyleSetForeground (Nr, wxColour (curType.foreground)); } if (curType.background) { StyleSetBackground (Nr, wxColour (curType.background)); } StyleSetBold (Nr, (curType.fontstyle & mySTC_STYLE_BOLD) > 0); StyleSetItalic (Nr, (curType.fontstyle & mySTC_STYLE_ITALIC) > 0); StyleSetUnderline (Nr, (curType.fontstyle & mySTC_STYLE_UNDERL) > 0); StyleSetVisible (Nr, (curType.fontstyle & mySTC_STYLE_HIDDEN) == 0); StyleSetCase (Nr, curType.lettercase); const char *pwords = curInfo->styles[Nr].words; if (pwords) { SetKeyWords (keywordnr, pwords); keywordnr += 1; } } } // set margin as unused SetMarginType (m_DividerID, wxSTC_MARGIN_SYMBOL); SetMarginWidth (m_DividerID, 0); SetMarginSensitive (m_DividerID, false); // folding SetMarginType (m_FoldingID, wxSTC_MARGIN_SYMBOL); SetMarginMask (m_FoldingID, wxSTC_MASK_FOLDERS); StyleSetBackground (m_FoldingID, *wxWHITE); SetMarginWidth (m_FoldingID, 0); SetMarginSensitive (m_FoldingID, false); if (g_CommonPrefs.foldEnable) { SetMarginWidth (m_FoldingID, curInfo->folds != 0? m_FoldingMargin: 0); SetMarginSensitive (m_FoldingID, curInfo->folds != 0); SetProperty (wxT("fold"), curInfo->folds != 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.comment"), (curInfo->folds & mySTC_FOLD_COMMENT) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.compact"), (curInfo->folds & mySTC_FOLD_COMPACT) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.preprocessor"), (curInfo->folds & mySTC_FOLD_PREPROC) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.html"), (curInfo->folds & mySTC_FOLD_HTML) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.html.preprocessor"), (curInfo->folds & mySTC_FOLD_HTMLPREP) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.comment.python"), (curInfo->folds & mySTC_FOLD_COMMENTPY) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.quotes.python"), (curInfo->folds & mySTC_FOLD_QUOTESPY) > 0? wxT("1"): wxT("0")); } SetFoldFlags (wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); // set spaces and indentation SetTabWidth (4); SetUseTabs (false); SetTabIndents (true); SetBackSpaceUnIndents (true); SetIndent (g_CommonPrefs.indentEnable? 4: 0); // others SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeColumn (80); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); return true; }
void LexerConf::Apply(wxStyledTextCtrl* ctrl, bool applyKeywords) { ctrl->SetLexer(GetLexerId()); ctrl->StyleClearAll(); ctrl->SetStyleBits(ctrl->GetStyleBitsNeeded()); OptionsConfigPtr options = EditorConfigST::Get()->GetOptions(); bool tooltip(false); const StyleProperty::Map_t& styles = GetLexerProperties(); ctrl->SetProperty(wxT("styling.within.preprocessor"), this->GetStyleWithinPreProcessor() ? wxT("1") : wxT("0")); // turn off PP tracking/updating by default ctrl->SetProperty(wxT("lexer.cpp.track.preprocessor"), wxT("0")); ctrl->SetProperty(wxT("lexer.cpp.update.preprocessor"), wxT("0")); if(GetName() == "scss") { // Enable SCSS property (will tell the lexer to search for variables) ctrl->SetProperty("lexer.css.scss.language", "1"); } ctrl->SetUseAntiAliasing(true); // Find the default style wxFont defaultFont; bool foundDefaultStyle = false; int nDefaultFontSize = DEFAULT_FONT_SIZE; StyleProperty defaultStyle; StyleProperty::Map_t::const_iterator iter = styles.begin(); for(; iter != styles.end(); ++iter) { const StyleProperty& prop = iter->second; if(prop.GetId() == 0) { defaultStyle = prop; wxString fontFace = prop.GetFaceName().IsEmpty() ? DEFAULT_FACE_NAME : prop.GetFaceName(); if(!prop.GetFaceName().IsEmpty()) { nDefaultFontSize = prop.GetFontSize(); } defaultFont = wxFont(nDefaultFontSize, wxFONTFAMILY_TELETYPE, prop.GetItalic() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL, prop.IsBold() ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL, prop.GetUnderlined(), fontFace); foundDefaultStyle = true; break; } } // Reset all colours to use the default style colour if(foundDefaultStyle) { for(int i = 0; i < 256; i++) { ctrl->StyleSetBackground(i, defaultStyle.GetBgColour()); ctrl->StyleSetForeground(i, defaultStyle.GetFgColour()); } } if(foundDefaultStyle && defaultFont.IsOk()) { for(int i = 0; i < 256; i++) { ctrl->StyleSetFont(i, defaultFont); } } iter = styles.begin(); for(; iter != styles.end(); ++iter) { StyleProperty sp = iter->second; int size = nDefaultFontSize; wxString face = sp.GetFaceName(); bool bold = sp.IsBold(); bool italic = sp.GetItalic(); bool underline = sp.GetUnderlined(); // int alpha = sp.GetAlpha(); // handle special cases switch(sp.GetId()) { case WHITE_SPACE_ATTR_ID: { // whitespace colour. We dont allow changing the background colour, only the foreground colour wxColour whitespaceColour = sp.GetFgColour(); if(whitespaceColour.IsOk()) { ctrl->SetWhitespaceForeground(true, whitespaceColour); } break; } case FOLD_MARGIN_ATTR_ID: // fold margin foreground colour ctrl->SetFoldMarginColour(true, sp.GetBgColour()); ctrl->SetFoldMarginHiColour(true, sp.GetFgColour()); break; case SEL_TEXT_ATTR_ID: { // selection colour if(wxColour(sp.GetBgColour()).IsOk()) { ctrl->SetSelBackground(true, sp.GetBgColour()); } if(IsUseCustomTextSelectionFgColour() && wxColour(sp.GetFgColour()).IsOk()) { ctrl->SetSelForeground(true, sp.GetFgColour()); } else { // provide a "dummy" selection colour (we pass 'false' so it does not matter // which colour we use here) ctrl->SetSelForeground(false, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); } break; } case CARET_ATTR_ID: { // caret colour wxColour caretColour = sp.GetFgColour(); if(!caretColour.IsOk()) { caretColour = *wxBLACK; } ctrl->SetCaretForeground(caretColour); break; } default: { wxString faceName = face; int fontSize(size); if(face.IsEmpty()) { // defaults fontSize = nDefaultFontSize; faceName = DEFAULT_FACE_NAME; } wxFontInfo fontInfo = wxFontInfo(fontSize) .Family(wxFONTFAMILY_TELETYPE) .Italic(italic) .Bold(bold) .Underlined(underline) .FaceName(faceName.IsEmpty() ? DEFAULT_FACE_NAME : faceName); wxFont font(fontInfo); if(sp.GetId() == 0) { // default ctrl->StyleSetFont(wxSTC_STYLE_DEFAULT, font); ctrl->StyleSetSize(wxSTC_STYLE_DEFAULT, size); ctrl->StyleSetForeground(wxSTC_STYLE_DEFAULT, iter->second.GetFgColour()); // Set the inactive state colours // Inactive state is greater by 64 from its counterpart wxColor inactiveColor = GetInactiveColor(defaultStyle); ctrl->StyleSetForeground(wxSTC_STYLE_DEFAULT + 64, inactiveColor); ctrl->StyleSetFont(wxSTC_STYLE_DEFAULT + 64, font); ctrl->StyleSetSize(wxSTC_STYLE_DEFAULT + 64, size); ctrl->StyleSetBackground(wxSTC_STYLE_DEFAULT + 64, iter->second.GetBgColour()); ctrl->StyleSetBackground(wxSTC_STYLE_DEFAULT, iter->second.GetBgColour()); ctrl->StyleSetSize(wxSTC_STYLE_LINENUMBER, size); } else if(sp.GetId() == wxSTC_STYLE_CALLTIP) { tooltip = true; if(sp.GetFaceName().IsEmpty()) { font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); fontSize = font.GetPointSize(); } } ctrl->StyleSetFont(sp.GetId(), font); ctrl->StyleSetSize(sp.GetId(), fontSize); ctrl->StyleSetEOLFilled(sp.GetId(), iter->second.GetEolFilled()); if(iter->second.GetId() == LINE_NUMBERS_ATTR_ID) { // Set the line number colours only if requested // otherwise, use default colours provided by scintilla if(sp.GetBgColour().IsEmpty() == false) ctrl->StyleSetBackground(sp.GetId(), sp.GetBgColour()); if(sp.GetFgColour().IsEmpty() == false) ctrl->StyleSetForeground(sp.GetId(), sp.GetFgColour()); else ctrl->StyleSetForeground(sp.GetId(), wxT("BLACK")); } else { ctrl->StyleSetForeground(sp.GetId(), sp.GetFgColour()); // Inactive state is greater by 64 from its counterpart wxColor inactiveColor = GetInactiveColor(sp); ctrl->StyleSetForeground(sp.GetId() + 64, inactiveColor); ctrl->StyleSetFont(sp.GetId() + 64, font); ctrl->StyleSetSize(sp.GetId() + 64, size); ctrl->StyleSetBackground(sp.GetId() + 64, defaultStyle.GetBgColour()); ctrl->StyleSetBackground(sp.GetId(), sp.GetBgColour()); } break; } } // switch } // set the calltip font if(!tooltip) { wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); ctrl->StyleSetFont(wxSTC_STYLE_CALLTIP, font); } if(applyKeywords) { ctrl->SetKeyWords(0, GetKeyWords(0)); ctrl->SetKeyWords(1, GetKeyWords(1)); ctrl->SetKeyWords(2, GetKeyWords(2)); ctrl->SetKeyWords(3, GetKeyWords(3)); ctrl->SetKeyWords(4, GetKeyWords(4)); } // by default indicators are set to be opaque rounded box if(DrawingUtils::IsDark(defaultStyle.GetBgColour())) { ctrl->IndicatorSetStyle(1, wxSTC_INDIC_BOX); ctrl->IndicatorSetStyle(2, wxSTC_INDIC_BOX); } else { ctrl->IndicatorSetStyle(1, wxSTC_INDIC_ROUNDBOX); ctrl->IndicatorSetStyle(2, wxSTC_INDIC_ROUNDBOX); } // Annotations markers // Warning style wxColour textColour = IsDark() ? *wxWHITE : *wxBLACK; ctrl->StyleSetBackground(ANNOTATION_STYLE_WARNING, defaultStyle.GetBgColour()); ctrl->StyleSetForeground(ANNOTATION_STYLE_WARNING, textColour); ctrl->StyleSetSizeFractional(ANNOTATION_STYLE_WARNING, (ctrl->StyleGetSizeFractional(wxSTC_STYLE_DEFAULT) * 4) / 5); // Error style ctrl->StyleSetBackground(ANNOTATION_STYLE_ERROR, defaultStyle.GetBgColour()); ctrl->StyleSetForeground(ANNOTATION_STYLE_ERROR, textColour); ctrl->StyleSetSizeFractional(ANNOTATION_STYLE_ERROR, (ctrl->StyleGetSizeFractional(wxSTC_STYLE_DEFAULT) * 4) / 5); // Code completion errors ctrl->StyleSetBackground(ANNOTATION_STYLE_CC_ERROR, defaultStyle.GetBgColour()); ctrl->StyleSetForeground(ANNOTATION_STYLE_CC_ERROR, textColour); ctrl->StyleSetSizeFractional(ANNOTATION_STYLE_CC_ERROR, (ctrl->StyleGetSizeFractional(wxSTC_STYLE_DEFAULT) * 4) / 5); // annotation style 'boxed' ctrl->AnnotationSetVisible(wxSTC_ANNOTATION_BOXED); // Define the styles for the editing margin ctrl->StyleSetBackground(CL_LINE_SAVED_STYLE, wxColour(wxT("FOREST GREEN"))); ctrl->StyleSetBackground(CL_LINE_MODIFIED_STYLE, wxColour(wxT("ORANGE"))); // Indentation ctrl->SetUseTabs(options->GetIndentUsesTabs()); ctrl->SetTabWidth(options->GetIndentWidth()); ctrl->SetIndent(options->GetIndentWidth()); }
ParamCon::ParamCon(ToolPanel *pan, int tp, wxString pname, wxString labelname, double initval, double step, int places, int labelwid, int numwid) { //mainwin = main; //wxControl::Create(panel, wxID_ANY, wxDefaultPosition, wxSize(250, 30), wxBORDER_NONE, wxDefaultValidator, name); ostype = GetSystem(); wxControl::Create(pan, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); numstep = step; name = pname; plabel = labelname; decimals = places; type = tp; labelwidth = labelwid; numwidth = numwid; panel = pan; pad = panel->controlborder; //pad = 0; if(ostype == Mac) pad = 0; mainwin = panel->mainwin; //wxFont textfont(10, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")); textfont = wxFont(wxFontInfo(8).FaceName("Tahoma")); //textfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //if(ostype == Mac) textfont = wxFont(10, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); if(ostype == Mac) { textfont = wxFont(wxFontInfo(11).FaceName("Tahoma")); smalltextfont = wxFont(wxFontInfo(9).FaceName("Tahoma")); //textfont = wxFont(11, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); //smalltextfont = wxFont(9, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma"); } //boxfont.New(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")); //wxFont textfont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); min = 0; max = 1000000; if(initval < 0) min = -1000000; if(initval < min) min = initval * 10; if(initval > max) max = initval * 100; oldvalue = initval; sizer = new wxBoxSizer(wxHORIZONTAL); snum.Printf("%.1f", initval); snum = numstring(initval, places); if(labelname == "") { label = NULL; labelwidth = 0; } else { label = new ToolText(this, panel->toolbox, name, labelname, wxDefaultPosition, wxSize(labelwidth, -1), wxALIGN_CENTRE); label->SetFont(textfont); if(ostype == Mac && labelwidth < 40) label->SetFont(smalltextfont); sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, pad); } numbox = new wxTextCtrl(this, wxID_ANY, snum, wxDefaultPosition, wxSize(numwidth, -1), wxTE_PROCESS_ENTER); numbox->SetFont(textfont); sizer->Add(numbox, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, pad); if(type == spincon) { spin = new wxSpinButton(this, wxID_ANY, wxDefaultPosition, wxSize(17, 23), wxSP_VERTICAL|wxSP_ARROW_KEYS); // 21 spin->SetRange(-1000000, 1000000); } SetInitialSize(wxDefaultSize); Move(wxDefaultPosition); if(type == spincon) sizer->Add(spin, 0, wxALIGN_CENTER_VERTICAL, 0); SetSizer(sizer); Layout(); Connect(wxEVT_SPIN_UP, wxSpinEventHandler(ParamCon::OnSpinUp)); Connect(wxEVT_SPIN_DOWN, wxSpinEventHandler(ParamCon::OnSpinDown)); Connect(wxEVT_SPIN, wxSpinEventHandler(ParamCon::OnSpin)); Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(ParamCon::OnEnter)); }
void MyFrame::OnFontDefault(wxCommandEvent& WXUNUSED(event)) { DoChangeFont(wxFont(wxFontInfo())); }
void MyPrintout::DrawPageTwo() { // You might use THIS code to set the printer DC to ROUGHLY reflect // the screen text size. This page also draws lines of actual length // 5cm on the page. // Compare this to DrawPageOne(), which uses the really convenient routines // from wxPrintout to fit the screen image onto the printed page. This page // illustrates how to do all the scaling calculations yourself, if you're so // inclined. wxDC *dc = GetDC(); // Get the logical pixels per inch of screen and printer int ppiScreenX, ppiScreenY; GetPPIScreen(&ppiScreenX, &ppiScreenY); int ppiPrinterX, ppiPrinterY; GetPPIPrinter(&ppiPrinterX, &ppiPrinterY); // This scales the DC so that the printout roughly represents the screen // scaling. The text point size _should_ be the right size but in fact is // too small for some reason. This is a detail that will need to be // addressed at some point but can be fudged for the moment. float scale = (float)((float)ppiPrinterX/(float)ppiScreenX); // Now we have to check in case our real page size is reduced (e.g. because // we're drawing to a print preview memory DC) int pageWidth, pageHeight; int w, h; dc->GetSize(&w, &h); GetPageSizePixels(&pageWidth, &pageHeight); // If printer pageWidth == current DC width, then this doesn't change. But w // might be the preview bitmap width, so scale down. float overallScale = scale * (float)(w/(float)pageWidth); dc->SetUserScale(overallScale, overallScale); // Calculate conversion factor for converting millimetres into logical // units. There are approx. 25.4 mm to the inch. There are ppi device units // to the inch. Therefore 1 mm corresponds to ppi/25.4 device units. We also // divide by the screen-to-printer scaling factor, because we need to // unscale to pass logical units to DrawLine. // Draw 50 mm by 50 mm L shape float logUnitsFactor = (float)(ppiPrinterX/(scale*25.4)); float logUnits = (float)(50*logUnitsFactor); dc->SetPen(* wxBLACK_PEN); dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250); dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits)); dc->SetBackgroundMode(wxTRANSPARENT); dc->SetBrush(*wxTRANSPARENT_BRUSH); { // GetTextExtent demo: wxString words[7] = { wxT("This "), wxT("is "), wxT("GetTextExtent "), wxT("testing "), wxT("string. "), wxT("Enjoy "), wxT("it!") }; wxCoord w, h; long x = 200, y= 250; dc->SetFont(wxFontInfo(15).Family(wxFONTFAMILY_SWISS)); for (int i = 0; i < 7; i++) { wxString word = words[i]; word.Remove( word.Len()-1, 1 ); dc->GetTextExtent(word, &w, &h); dc->DrawRectangle(x, y, w, h); dc->GetTextExtent(words[i], &w, &h); dc->DrawText(words[i], x, y); x += w; } } dc->SetFont(wxGetApp().GetTestFont()); dc->DrawText(wxT("Some test text"), 200, 300 ); // TESTING int leftMargin = 20; int rightMargin = 20; int topMargin = 20; int bottomMargin = 20; int pageWidthMM, pageHeightMM; GetPageSizeMM(&pageWidthMM, &pageHeightMM); float leftMarginLogical = (float)(logUnitsFactor*leftMargin); float topMarginLogical = (float)(logUnitsFactor*topMargin); float bottomMarginLogical = (float)(logUnitsFactor*(pageHeightMM - bottomMargin)); float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin)); dc->SetPen(* wxRED_PEN); dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical, (long)rightMarginLogical, (long)topMarginLogical); dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical, (long)rightMarginLogical, (long)bottomMarginLogical); WritePageHeader(this, dc, wxT("A header"), logUnitsFactor); }
void WizardPageCanalConfig::CreateControls() { WizardPageCanalConfig* itemWizardPage = this; wxBoxSizer* itemBoxSizer = new wxBoxSizer( wxVERTICAL ); itemWizardPage->SetSizer( itemBoxSizer ); wxStaticText* itemStaticTextHeader = new wxStaticText; itemStaticTextHeader->Create( itemWizardPage, wxID_STATIC, m_strHead, wxDefaultPosition, wxSize( DEFAULT_STOCK_TEXT_WIDTH, -1 ), 0 ); #if wxCHECK_VERSION(2, 9, 5) itemStaticTextHeader->SetFont( wxFont( wxFontInfo(16).FaceName("Tahoma").Bold() ) ); #else itemStaticTextHeader->SetFont( wxFont( 10, wxSWISS, wxNORMAL, wxBOLD, false, wxT( "Tahoma" ) ) ); #endif itemBoxSizer->Add( itemStaticTextHeader, 0, wxALIGN_LEFT | wxALL, 5 ); wxStaticText* itemStaticTextDescription = new wxStaticText; itemStaticTextDescription->Create( itemWizardPage, wxID_STATIC, m_pItem->m_description, wxDefaultPosition, wxSize( DEFAULT_STOCK_TEXT_WIDTH, -1 ), 0 ); itemBoxSizer->Add( itemStaticTextDescription, 0, wxALIGN_LEFT | wxALL, 5 ); if ( m_pItem->m_infourl.Length() ) { wxHyperlinkCtrl* intenHyperLink = new wxHyperlinkCtrl; intenHyperLink->Create( itemWizardPage, wxID_STATIC, _( "Click for more information" ), m_pItem->m_infourl ); itemBoxSizer->Add( intenHyperLink, 0, wxALIGN_LEFT | wxALL, 5 ); itemBoxSizer->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); } itemBoxSizer->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); if ( type_choice == m_pItem->m_type ) { wxArrayString wxstrings; for ( unsigned int i = 0; i < m_pItem->m_listChoice.GetCount(); i++ ) { wxstrings.Add( m_pItem->m_listChoice[ i ]->m_description ); } m_listBox = new wxListBox; m_listBox->Create( itemWizardPage, m_windowsID++, wxDefaultPosition, wxSize( 370, -1 ), wxstrings ); if ( WizardPageCanalConfig::ShowToolTips() ) { m_listBox->SetToolTip( _( "Set value for parameter" ) ); } m_listBox->SetBackgroundColour( wxColour( 255, 255, 210 ) ); unsigned long sel = 0; sel = vscp_readStringValue( m_strValue ); //m_strValue.ToCULongsel( &sel ); m_listBox->Select( sel ); itemBoxSizer->Add( m_listBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); } else if ( type_boolean == m_pItem->m_type ) { m_boolChoice = new wxCheckBox; m_boolChoice->Create( itemWizardPage, m_windowsID++, _("Value for flag"), wxDefaultPosition, wxSize( 370, -1 ) ); if ( WizardPageCanalConfig::ShowToolTips() ) { m_boolChoice->SetToolTip( _( "Set to enable" ) ); } m_boolChoice->SetBackgroundColour( wxColour( 255, 255, 210 ) ); if ( m_strValue.IsNumber() ) { unsigned long val = 0; val = vscp_readStringValue( m_strValue ); //m_strValue.ToCULong( &val ); if ( val ) m_boolChoice->SetValue( true ); } else { m_strValue.MakeUpper(); if ( m_strValue.Find( _( "TRUE" ) ) ) { m_boolChoice->SetValue( true ); } } itemBoxSizer->Add( m_boolChoice, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); } else { m_textField = new wxTextCtrl; m_textField->Create( itemWizardPage, m_windowsID++, wxEmptyString, wxDefaultPosition, wxSize( 370, -1 ) ); if ( WizardPageCanalConfig::ShowToolTips() ) { m_textField->SetToolTip( _( "Set value for parameter" ) ); } m_textField->SetBackgroundColour( wxColour( 255, 255, 210 ) ); m_textField->SetValue( m_strValue ); itemBoxSizer->Add( m_textField, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); } itemBoxSizer->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); }
void ClassListDialog::CreateControls() { wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); this->SetSizer(itemBoxSizer2); wxStaticText* itemStaticText3 = new wxStaticText( this, wxID_STATIC, _("This is the list of wxWidgets classes registered in the XTI system.\nNote that not all wxWidgets classes are registered nor all registered classes are completely _described_ using XTI metadata."), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_LEFT|wxALL, 5); // filters wxBoxSizer* filters = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(filters, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); filters->Add(new wxCheckBox(this, ID_SHOW_ONLY_XTI, "Show only classes with eXtended infos")); filters->AddSpacer(10); filters->Add(new wxCheckBox(this, ID_SHOW_PROPERTIES_RECURSIVELY, "Show properties of parent classes")); // show how many have we filtered out m_pClassCountText = new wxStaticText( this, wxID_STATIC, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", wxDefaultPosition, wxDefaultSize, 0 ); m_pClassCountText->SetFont(wxFontInfo(8).Family(wxFONTFAMILY_SWISS).Bold()); itemBoxSizer2->Add(m_pClassCountText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer5, 1, wxGROW, 5); m_pChoiceBook = new wxChoicebook( this, ID_LISTMODE, wxDefaultPosition, wxDefaultSize, wxCHB_DEFAULT ); // raw-list page wxPanel* itemPanel7 = new wxPanel( m_pChoiceBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); itemPanel7->SetSizer(itemBoxSizer8); wxArrayString m_pRawListBoxStrings; m_pRawListBox = new wxListBox( itemPanel7, ID_LISTBOX, wxDefaultPosition, wxDefaultSize, m_pRawListBoxStrings, wxLB_SINGLE ); itemBoxSizer8->Add(m_pRawListBox, 1, wxGROW, 5); m_pChoiceBook->AddPage(itemPanel7, _("Raw list")); // by-size page wxPanel* itemPanel13 = new wxPanel( m_pChoiceBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL); itemPanel13->SetSizer(itemBoxSizer14); wxArrayString m_pSizeListBoxStrings; m_pSizeListBox = new wxListBox( itemPanel13, ID_LISTBOX, wxDefaultPosition, wxDefaultSize, m_pSizeListBoxStrings, wxLB_SINGLE ); itemBoxSizer14->Add(m_pSizeListBox, 1, wxGROW, 5); m_pChoiceBook->AddPage(itemPanel13, _("Classes by size")); // tree page wxPanel* itemPanel10 = new wxPanel( m_pChoiceBook, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); itemPanel10->SetSizer(itemBoxSizer11); m_pParentTreeCtrl = new wxTreeCtrl( itemPanel10, ID_TREECTRL, wxDefaultPosition, wxSize(100, 100), wxTR_HAS_BUTTONS |wxTR_SINGLE ); itemBoxSizer11->Add(m_pParentTreeCtrl, 1, wxGROW, 5); m_pChoiceBook->AddPage(itemPanel10, _("Classes by parent")); itemBoxSizer5->Add(m_pChoiceBook, 0, wxGROW|wxALL, 5); m_pTextCtrl = new wxTextCtrl( this, ID_TEXTCTRL, "", wxDefaultPosition, wxSize(500, -1), wxTE_MULTILINE|wxTE_READONLY ); itemBoxSizer5->Add(m_pTextCtrl, 3, wxGROW|wxALL, 5); wxStdDialogButtonSizer* itemStdDialogButtonSizer17 = new wxStdDialogButtonSizer; itemBoxSizer2->Add(itemStdDialogButtonSizer17, 0, wxGROW|wxALL, 5); wxButton* itemButton18 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer17->AddButton(itemButton18); wxButton* itemButton19 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer17->AddButton(itemButton19); itemStdDialogButtonSizer17->Realize(); InitControls(); }
static wxFont get_default_font(){ return wxFont(wxFontInfo(12)); }
void DialogEditLevelIDMrow::CreateControls() { DialogEditLevelIDMrow* itemDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxStaticText* itemStaticText4 = new wxStaticText; itemStaticText4->Create( itemDialog1, wxID_STATIC, _("Decision Matrix row"), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticText4->SetForegroundColour(wxColour(0, 128, 255)); #if wxCHECK_VERSION(2, 9, 5) itemStaticText4->SetFont( wxFont( wxFontInfo(8).FaceName("Tahoma").Bold() ) ); #else itemStaticText4->SetFont( wxFont( 8, wxSWISS, wxNORMAL, wxBOLD, false, wxT( "Tahoma" ) ) ); #endif itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer5, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText6 = new wxStaticText; itemStaticText6->Create( itemDialog1, wxID_STATIC, _("Originating nickname :"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_oaddr = new wxTextCtrl; m_oaddr->Create( itemDialog1, ID_TEXTCTRL_ORIGINATING_ADDRESS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer5->Add(m_oaddr, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); itemBoxSizer5->Add(75, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_RIGHT|wxALL, 1); wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); itemBoxSizer9->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); m_chkEnableDMRow = new wxCheckBox; m_chkEnableDMRow->Create( itemDialog1, ID_CHECKBOX_ENABLE_ROW, _("Enable DM row"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); m_chkEnableDMRow->SetValue(false); itemBoxSizer10->Add(m_chkEnableDMRow, 0, wxALIGN_RIGHT|wxALL, 5); m_chkCheckOAddr = new wxCheckBox; m_chkCheckOAddr->Create( itemDialog1, ID_CHECKBOX_CHECK_OADDR, _("Check originating address"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); m_chkCheckOAddr->SetValue(false); itemBoxSizer10->Add(m_chkCheckOAddr, 0, wxALIGN_RIGHT|wxALL, 5); m_chkHardOAddr = new wxCheckBox; m_chkHardOAddr->Create( itemDialog1, ID_CHECKBOX_HARDCODED_OADDR, _("Originating address should be hardcoded"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); m_chkHardOAddr->SetValue(false); itemBoxSizer10->Add(m_chkHardOAddr, 0, wxALIGN_RIGHT|wxALL, 5); m_chkMatchZone = new wxCheckBox; m_chkMatchZone->Create( itemDialog1, ID_CHECKBOX_MATCH_ZONE, _("Zone should match"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); m_chkMatchZone->SetValue(false); itemBoxSizer10->Add(m_chkMatchZone, 0, wxALIGN_RIGHT|wxALL, 5); m_chkMatchSubzone = new wxCheckBox; m_chkMatchSubzone->Create( itemDialog1, ID_CHECKBOX_MATCH_SUBZONE, _("Subzone should match"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); m_chkMatchSubzone->SetValue(false); itemBoxSizer10->Add(m_chkMatchSubzone, 0, wxALIGN_RIGHT|wxALL, 5); itemBoxSizer9->Add(80, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer17, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText18 = new wxStaticText; itemStaticText18->Create( itemDialog1, wxID_STATIC, _("Class Mask: "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); m_classMask = new wxTextCtrl; m_classMask->Create( itemDialog1, ID_TEXTCTRL_CLASS_MASK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_classMask->SetBackgroundColour(wxColour(255, 192, 203)); itemBoxSizer17->Add(m_classMask, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); wxButton* itemButton20 = new wxButton; itemButton20->Create( itemDialog1, ID_BUTTON_SELECT_EVENTS, _("..."), wxDefaultPosition, wxSize(20, -1), 0 ); itemButton20->SetHelpText(_("Set filter/mask for events thatshould trigger the DM row")); if (DialogEditLevelIDMrow::ShowToolTips()) itemButton20->SetToolTip(_("Set filter/mask for events thatshould trigger the DM row")); itemBoxSizer17->Add(itemButton20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer17->Add(50, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer22, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText23 = new wxStaticText; itemStaticText23->Create( itemDialog1, wxID_STATIC, _("Class Filter: "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer22->Add(itemStaticText23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); m_classFilter = new wxTextCtrl; m_classFilter->Create( itemDialog1, ID_TEXTCTRL_CLASS_FILTER, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_classFilter->SetBackgroundColour(wxColour(255, 192, 203)); itemBoxSizer22->Add(m_classFilter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); itemBoxSizer22->Add(80, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer26, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText27 = new wxStaticText; itemStaticText27->Create( itemDialog1, wxID_STATIC, _("Type Mask: "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer26->Add(itemStaticText27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); m_typeMask = new wxTextCtrl; m_typeMask->Create( itemDialog1, ID_TEXTCTRL_TYPE_MASK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_typeMask->SetBackgroundColour(wxColour(144, 238, 144)); itemBoxSizer26->Add(m_typeMask, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); itemBoxSizer26->Add(80, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer30, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText31 = new wxStaticText; itemStaticText31->Create( itemDialog1, wxID_STATIC, _("Type Filter: "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer30->Add(itemStaticText31, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); m_typeFilter = new wxTextCtrl; m_typeFilter->Create( itemDialog1, ID_TEXTCTRL_TYPE_FILTER, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_typeFilter->SetBackgroundColour(wxColour(144, 238, 144)); itemBoxSizer30->Add(m_typeFilter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); itemBoxSizer30->Add(80, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer34, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText35 = new wxStaticText; itemStaticText35->Create( itemDialog1, wxID_STATIC, _("Action :"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer34->Add(itemStaticText35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); wxArrayString m_comboActionStrings; m_comboAction = new wxComboBox; m_comboAction->Create( itemDialog1, ID_COMBOCTRL_ACTION, wxEmptyString, wxDefaultPosition, wxSize(250, -1), m_comboActionStrings, wxCB_READONLY ); itemBoxSizer34->Add(m_comboAction, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer34->Add(76, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer38 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer38, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText39 = new wxStaticText; itemStaticText39->Create( itemDialog1, wxID_STATIC, _("Action parameter : "), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer38->Add(itemStaticText39, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); m_actionParam = new wxTextCtrl; m_actionParam->Create( itemDialog1, ID_TEXTCTRL_ACTION_PARAMETER, wxEmptyString, wxDefaultPosition, wxSize(100, -1), 0 ); itemBoxSizer38->Add(m_actionParam, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); itemBoxSizer38->Add(82, 1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer42 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer42, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxButton* itemButton43 = new wxButton; itemButton43->Create( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer42->Add(itemButton43, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton44 = new wxButton; itemButton44->Create( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer42->Add(itemButton44, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); }