/*---------------------------------------------------------------------------*/ void wxSQLEditorBase::SetTypeStyle(int type, bool bold, bool italic, bool underline, int lettercase, wxColour fore, wxColour back) { if (type < wxSTC_SQL_DEFAULT || type > wxSTC_SQL_QUOTEDIDENTIFIER) return; StyleSetFontAttr(type, m_FontSize, m_FontName, bold, italic, underline); if (fore != wxNullColour) StyleSetForeground(type, fore); if (back != wxNullColour) StyleSetBackground(type, back); StyleSetBold(type, bold); // true / false StyleSetItalic(type, italic); StyleSetUnderline(type, underline); // wxSTC_CASE_MIXED wxSTC_CASE_UPPER wxSTC_CASE_LOWER (0 1 2) if (lettercase < 0 || lettercase > 2) lettercase = 0; StyleSetCase(type, lettercase); }
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 ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) { wxStyledTextCtrl::Create(parent, id , pos, size, style); // Clear all styles StyleClearAll(); // Font extern sysSettings *settings; wxFont fntSQLBox = settings->GetSQLFont(); wxColour bgColor = settings->GetSQLBoxColourBackground(); if (settings->GetSQLBoxUseSystemBackground()) { bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); } wxColour frColor = settings->GetSQLBoxColourForeground(); if (settings->GetSQLBoxUseSystemForeground()) { frColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); } StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor); StyleSetForeground(wxSTC_STYLE_DEFAULT, frColor); StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox); SetSelBackground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); SetSelForeground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); SetCaretForeground(settings->GetSQLColourCaret()); SetMarginWidth(1, 0); SetTabWidth(settings->GetIndentSpaces()); SetUseTabs(!settings->GetSpacesForTabs()); // Setup the different highlight colurs for (int i = 0; i < 34; ++ i ) { if (i > 0 && i < 12) StyleSetForeground(i, settings->GetSQLBoxColour(i)); else StyleSetForeground(i, frColor); StyleSetBackground(i, bgColor); StyleSetFont(i, fntSQLBox); } // Keywords in uppercase? if (settings->GetSQLKeywordsInUppercase()) StyleSetCase(5, wxSTC_CASE_UPPER); // Margin style StyleSetBackground(wxSTC_STYLE_LINENUMBER, settings->GetSQLMarginBackgroundColour()); // Brace maching styles StyleSetBackground(34, wxColour(0x99, 0xF9, 0xFF)); StyleSetBackground(35, wxColour(0xFF, 0xCF, 0x27)); StyleSetFont(34, fntSQLBox); StyleSetFont(35, fntSQLBox); // SQL Lexer and keywords. if (sqlKeywords.IsEmpty()) FillKeywords(sqlKeywords); SetLexer(wxSTC_LEX_SQL); SetKeyWords(0, sqlKeywords + plpgsqlKeywords + ftsKeywords + pgscriptKeywords); // Enable folding SetMarginSensitive(2, true); SetMarginType(2, wxSTC_MARGIN_SYMBOL); // margin 2 for symbols SetMarginMask(2, wxSTC_MASK_FOLDERS); // set up mask for folding symbols SetMarginSensitive(2, true); // this one needs to be mouse-aware SetMarginWidth(2, 16); // set margin 2 16 px wide MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, *wxWHITE, *wxBLACK); SetProperty(wxT("fold"), wxT("1")); SetFoldFlags(16); // Setup accelerators wxAcceleratorEntry entries[2]; entries[0].Set(wxACCEL_CTRL, (int)'F', MNU_FIND); entries[1].Set(wxACCEL_CTRL, (int)' ', MNU_AUTOCOMPLETE); wxAcceleratorTable accel(2, entries); SetAcceleratorTable(accel); // Autocompletion configuration AutoCompSetSeparator('\t'); AutoCompSetChooseSingle(true); AutoCompSetIgnoreCase(true); AutoCompSetFillUps(wxT(" \t")); AutoCompSetDropRestOfWord(true); SetEOLMode(settings->GetLineEndingType()); }