示例#1
0
void IWnd_stc::UpdateStyle()
{

	bool flag=param.nlang==tempp.nlang 
		&& (param.flags.get(FLAG_FOLD)==tempp.flags.get(FLAG_FOLD)) 
		&& (param.flags.get(FLAG_SYNTAX)==tempp.flags.get(FLAG_SYNTAX)) 
		&& param.nsize==tempp.nsize;

	param=tempp;	

	if(flag)
	{
		_DoUpdateStyle();
		return;
	}


	BitFlags& flags(param.flags);

	StcLangInfo& lf(StcManager::current().langs[param.nlang]);

	wxFont fontNr (param.nsize, wxMODERN, wxNORMAL, wxNORMAL,false,str2wx(param.sface));
    for (int Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++)
	{
        StyleSetFont (Nr, fontNr);
    }

	if(!flags.get(FLAG_FOLD))
	{
		ClearDocumentStyle();
	}

    StyleClearAll();
    SetLexer (lf.lexer);

    SetMarginType (StcManager::LINE_NR_ID, wxSTC_MARGIN_NUMBER);
    StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY")));
    StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE);
    SetMarginWidth (StcManager::LINE_NR_ID, 0);

    // set common styles
    StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (wxT("DARK GREY")));
    StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY")));

	SetMarginType(StcManager::DIVIDER_ID, wxSTC_MARGIN_SYMBOL);
	SetMarginMask(StcManager::DIVIDER_ID, wxSTC_MASK_FOLDERS);
    SetMarginWidth (StcManager::DIVIDER_ID, 0);
    SetMarginSensitive (StcManager::DIVIDER_ID, false);

    // folding
    SetMarginType (StcManager::FOLDING_ID, wxSTC_MARGIN_SYMBOL);
    SetMarginMask (StcManager::FOLDING_ID, wxSTC_MASK_FOLDERS);
    StyleSetBackground (StcManager::FOLDING_ID, *wxWHITE);
    SetMarginWidth (StcManager::FOLDING_ID, 0);
    SetMarginSensitive (StcManager::FOLDING_ID, false);

	if (flags.get(FLAG_FOLD)) 
	{

		SetMarginWidth (StcManager::FOLDING_ID,StcManager::FOLDING_MARGIN);
		SetMarginSensitive (StcManager::FOLDING_ID, true);

		SetPropertyEx ("fold", true);
		SetPropertyEx ("fold.comment",true);
		SetPropertyEx ("fold.compact",true);
		SetPropertyEx ("fold.preprocessor",true);
		SetPropertyEx ("fold.html", true);
		SetPropertyEx ("fold.html.preprocessor",true);
		SetPropertyEx ("fold.comment.python", true);
		SetPropertyEx ("fold.quotes.python", true);
	}
	else
	{
		SetMarginWidth (StcManager::DIVIDER_ID, StcManager::FOLDING_MARGIN);
	}

	SetFoldFlags (wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED| wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED);

	if (flags.get(FLAG_SYNTAX))
	{
		int keywordnr = 0;

		for(StcLangInfo::map_type::iterator it=lf.mapStyles.begin();it!=lf.mapStyles.end();++it)
		{
			int Nr=(*it).first;
			StcLangInfo::StyleWords& s((*it).second);
			StcStyleInfo& curType(StcManager::current().style[s.id]);

			wxFont font (param.nsize, wxMODERN, wxNORMAL, wxNORMAL, false,str2wx(curType.fontname));

			StyleSetFont (Nr, font);
			if (curType.foreground!=wxEmptyString) 
			{
				StyleSetForeground (Nr, wxColour (curType.foreground.c_str()));
			}
			if (curType.background!=wxEmptyString) 
			{
				StyleSetBackground (Nr, wxColour (curType.background.c_str()));
			}

			StyleSetBold (Nr, curType.fontstyle.get(StcManager::STYLE_BOLD));
			StyleSetItalic (Nr, curType.fontstyle.get(StcManager::STYLE_ITALIC));
			StyleSetUnderline (Nr, curType.fontstyle.get(StcManager::STYLE_UNDERL));
			StyleSetVisible (Nr, !curType.fontstyle.get(StcManager::STYLE_HIDDEN));

			//StyleSetCase (Nr, curType.lettercase);
			if (s.words!="") 
			{
				SetKeyWords (keywordnr, str2wx(s.words));
				keywordnr += 1;
			}
		}
	}

	_DoUpdateStyle();

	Colourise(0,this->GetLastPosition());

}
示例#2
0
void CodeEdit::Recolor()
{
    ClearDocumentStyle();
    int length = GetLength();
    Colourise(0, length);
}