void LuaScriptEditorView::SetupSourceEditor()
{
   StyleSetFont(STYLE_DEFAULT, "Courier New");
   StyleSetSize(STYLE_DEFAULT, 11);
   SetEdgeColumn(100);
   SetEdgeMode(EDGE_LINE);
   SetMarginWidthN(0, 50); // margin 0 displays line numbers, but has default width 0

   StyleSetFore(0,  RGB(0x80, 0x80, 0x80));
   StyleSetFore(1,  RGB(0x00, 0x7f, 0x00));
   StyleSetFore(2,  RGB(0x00, 0x7f, 0x00));
   StyleSetFore(3,  RGB(0x7f, 0x7f, 0x7f));
   StyleSetFore(4,  RGB(0x00, 0x7f, 0x7f));
   StyleSetFore(5,  RGB(0x00, 0x00, 0x7f));
   StyleSetFore(6,  RGB(0x7f, 0x00, 0x7f));
   StyleSetFore(7,  RGB(0x7f, 0x00, 0x7f));
   StyleSetFore(8,  RGB(0x00, 0x7f, 0x7f));
   StyleSetFore(9,  RGB(0x7f, 0x7f, 0x7f));
   StyleSetFore(10, RGB(0x00, 0x00, 0x00));
   StyleSetFore(11, RGB(0x00, 0x00, 0x00));
   StyleSetBold(5,  true);
   StyleSetBold(10, true);

   SetLexer(SCLEX_LUA);

   // set Lua keywords and add RemotePhotoTool specific classes
   SetKeyWords(0,
      "and break do else elseif end for function if in "
      "local nil not or repeat return then until while "
      "App Sys Constants RemoteReleaseControl SourceDevice "
      "ImageProperty DeviceProperty ShootingMode Viewfinder "
      "BulbReleaseControl");

   SetTabWidth(3);
   SetUseTabs(true);

   // only notify about text edits in SCEN_CHANGE messages
   SetModEventMask(SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT);
}
Beispiel #2
0
void ScriptEditCtrl::Impl::PreSubclassWindow()
{
	self_->m_hWnd = m_hWnd;	// expose HWND

	SetupDirectAccess();

	// If we are running as Unicode, then use the UTF8 codepage
#ifdef _UNICODE
	SetCodePage(SC_CP_UTF8);
#endif

	SetLexer(SCLEX_LUA);
	StyleSetFont(STYLE_DEFAULT, "Lucida Console");
	StyleSetSize(STYLE_DEFAULT, 10);
	SetKeyWords(0, LuaKeywords);
	SetKeyWords(1, LuaFunctions);
	if (enable_input_attribs_)
		SetKeyWords(2, LuaUser);
	SetKeyWords(3, ConcatAttributes().c_str());

	COLORREF comment= RGB(0,128,128);
	COLORREF string= RGB(128,128,0);

	StyleSetFore(SCE_LUA_COMMENT, comment);
	StyleSetFore(SCE_LUA_COMMENTLINE, comment);
	StyleSetFore(SCE_LUA_COMMENTDOC, comment);
	StyleSetFore(SCE_LUA_NUMBER, RGB(0,0,255));
	StyleSetFore(SCE_LUA_WORD, RGB(34,78,160));		// keywords
	StyleSetFore(SCE_LUA_STRING, string);
	StyleSetFore(SCE_LUA_CHARACTER, string);
	StyleSetFore(SCE_LUA_LITERALSTRING, string);
	StyleSetFore(SCE_LUA_WORD2, RGB(53,113,202));	// functions
	StyleSetFore(SCE_LUA_WORD3, RGB(124,37,203));	// test & number
	StyleSetBack(SCE_LUA_WORD3, CalcColor(::GetSysColor(COLOR_WINDOW), RGB(0,0,255), 0.95f));
	StyleSetFore(SCE_LUA_WORD4, RGB(164,97,49));	// todo: attributes

	StyleSetFont(SCE_LUA_WORD, "Lucida Console");
	StyleSetSize(SCE_LUA_WORD, 10);
	StyleSetBold(SCE_LUA_WORD, true);

	//#define SCE_LUA_PREPROCESSOR 9
	//#define SCE_LUA_OPERATOR 10
	//#define SCE_LUA_IDENTIFIER 11
	//#define SCE_LUA_STRINGEOL 12
	//#define SCE_LUA_WORD2 13
	//#define SCE_LUA_WORD3 14
	//#define SCE_LUA_WORD4 15
	//#define SCE_LUA_WORD5 16
	//#define SCE_LUA_WORD6 17
	//#define SCE_LUA_WORD7 18
	//#define SCE_LUA_WORD8 19

	Colorize(0, -1);

	//MarkerDefine(MARKER_POINTER, SC_MARK_ARROW);
	//MarkerSetBack(MARKER_POINTER, RGB(255,255,0));

	//MarkerDefine(MARKER_BREAKPOINT, SC_MARK_ROUNDRECT);
	//MarkerSetBack(MARKER_BREAKPOINT, RGB(0,0,255));

	//MarkerDefine(MARKER_ERROR, SC_MARK_ARROW);
	//MarkerSetBack(MARKER_ERROR, RGB(255,0,0));

	int width= 0;
	SetMarginWidthN(1, width);

	SetScrollWidthTracking(true);
	SetScrollWidth(1);

	SetWrapMode(SC_WRAP_WORD);
	SetWrapVisualFlags(SC_WRAPVISUALFLAG_END);

	SetSelBack(true, CalcShade(::GetSysColor(COLOR_HIGHLIGHT), 50.0f));

	SetTabWidth(4);
	SetIndent(4);

	DWORD pixels= 1;
	::SystemParametersInfo(SPI_GETCARETWIDTH, 0, &pixels, 0);
	SetCaretWidth(pixels);

	// hwnd is attached, but message processing is not working yet, we are not yet subclassed,
	// so postpone this WM_NCCALCSIZE call:
	PostMessage(WM_APP+1234);
}
Beispiel #3
0
void CodeEdit::SetFontColorSettings(const FontColorSettings& settings)
{
    // For some reason StyleSetFont takes a (non-const) reference, so we need to make
    // a copy before passing it in.
    wxFont font = settings.GetFont();

    SetSelForeground(true, settings.GetColors(FontColorSettings::DisplayItem_Selection).foreColor);
    SetSelBackground(true, settings.GetColors(FontColorSettings::DisplayItem_Selection).backColor);

    StyleSetFont(wxSTC_STYLE_DEFAULT, font);
    StyleClearAll();

    font = settings.GetFont(FontColorSettings::DisplayItem_Default);
    StyleSetFont(wxSTC_LUA_DEFAULT,                 font);
    StyleSetFont(wxSTC_LUA_IDENTIFIER,              font);
    StyleSetForeground(wxSTC_LUA_DEFAULT,           settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor);
    StyleSetBackground(wxSTC_LUA_DEFAULT,           settings.GetColors(FontColorSettings::DisplayItem_Default).backColor);
    StyleSetForeground(wxSTC_STYLE_DEFAULT,         settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor);
    StyleSetBackground(wxSTC_STYLE_DEFAULT,         settings.GetColors(FontColorSettings::DisplayItem_Default).backColor);
    StyleSetForeground(wxSTC_LUA_IDENTIFIER,        settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor);
    StyleSetBackground(wxSTC_LUA_IDENTIFIER,        settings.GetColors(FontColorSettings::DisplayItem_Default).backColor);

    font = settings.GetFont(FontColorSettings::DisplayItem_Comment);
    StyleSetFont(wxSTC_LUA_COMMENT,                 font);
    StyleSetFont(wxSTC_LUA_COMMENTLINE,             font);
    StyleSetFont(wxSTC_LUA_COMMENTDOC,              font);
    StyleSetForeground(wxSTC_LUA_COMMENT,           settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor);
    StyleSetBackground(wxSTC_LUA_COMMENT,           settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor);
    StyleSetForeground(wxSTC_LUA_COMMENTLINE,       settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor);
    StyleSetBackground(wxSTC_LUA_COMMENTLINE,       settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor);
    StyleSetForeground(wxSTC_LUA_COMMENTDOC,        settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor);
    StyleSetBackground(wxSTC_LUA_COMMENTDOC,        settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor);

    font = settings.GetFont(FontColorSettings::DisplayItem_Keyword);
    StyleSetFont(wxSTC_LUA_WORD2,                   font);
    StyleSetForeground(wxSTC_LUA_WORD2,             settings.GetColors(FontColorSettings::DisplayItem_Keyword).foreColor);
    StyleSetBackground(wxSTC_LUA_WORD2,             settings.GetColors(FontColorSettings::DisplayItem_Keyword).backColor);

    font = settings.GetFont(FontColorSettings::DisplayItem_Operator);
    StyleSetFont(wxSTC_LUA_OPERATOR,                font);
    StyleSetForeground(wxSTC_LUA_OPERATOR,          settings.GetColors(FontColorSettings::DisplayItem_Operator).foreColor);
    StyleSetBackground(wxSTC_LUA_OPERATOR,          settings.GetColors(FontColorSettings::DisplayItem_Operator).backColor);

    font = settings.GetFont(FontColorSettings::DisplayItem_String);
    StyleSetFont(wxSTC_LUA_STRING,                  font);
    StyleSetForeground(wxSTC_LUA_STRING,            settings.GetColors(FontColorSettings::DisplayItem_String).foreColor);
    StyleSetBackground(wxSTC_LUA_STRING,            settings.GetColors(FontColorSettings::DisplayItem_String).backColor);
    StyleSetFont(wxSTC_LUA_STRINGEOL,               font);
    StyleSetForeground(wxSTC_LUA_STRINGEOL,         settings.GetColors(FontColorSettings::DisplayItem_String).foreColor);
    StyleSetBackground(wxSTC_LUA_STRINGEOL,         settings.GetColors(FontColorSettings::DisplayItem_String).backColor);
    StyleSetFont(wxSTC_LUA_LITERALSTRING,           font);
    StyleSetForeground(wxSTC_LUA_LITERALSTRING,     settings.GetColors(FontColorSettings::DisplayItem_String).foreColor);
    StyleSetBackground(wxSTC_LUA_LITERALSTRING,     settings.GetColors(FontColorSettings::DisplayItem_String).backColor);
    StyleSetFont(wxSTC_LUA_CHARACTER,               font);
    StyleSetForeground(wxSTC_LUA_CHARACTER,         settings.GetColors(FontColorSettings::DisplayItem_String).foreColor);
    StyleSetBackground(wxSTC_LUA_CHARACTER,         settings.GetColors(FontColorSettings::DisplayItem_String).backColor);

    font = settings.GetFont(FontColorSettings::DisplayItem_Number);
    StyleSetFont(wxSTC_LUA_NUMBER,                  font);
    StyleSetForeground(wxSTC_LUA_NUMBER,            settings.GetColors(FontColorSettings::DisplayItem_Number).foreColor);
    StyleSetBackground(wxSTC_LUA_NUMBER,            settings.GetColors(FontColorSettings::DisplayItem_Number).backColor);

    StyleSetSize(wxSTC_STYLE_LINENUMBER, font.GetPointSize());

    // Set the caret color as the inverse of the background color so it's always visible.
    SetCaretForeground( GetInverse(settings.GetColors(FontColorSettings::DisplayItem_Default).backColor) );


    StyleSetBackground(wxSTC_STYLE_LINENUMBER, settings.GetColors(FontColorSettings::DisplayItem_WindowMargin).backColor);
    StyleSetForeground(wxSTC_STYLE_LINENUMBER, settings.GetColors(FontColorSettings::DisplayItem_WindowMargin).foreColor);
    //SetFoldMarginHiColour(true, settings.GetColors(FontColorSettings::DisplayItem_Window).backColor);
}