Beispiel #1
0
void SvnBlameEditor::Initialize()
{
    // Initialize some styles
    SetMarginType (0, wxSTC_MARGIN_TEXT  );
    SetMarginType (1, wxSTC_MARGIN_NUMBER);
    SetMarginWidth(1, 4 + 5*TextWidth(wxSTC_STYLE_LINENUMBER, wxT("9")));
    SetMarginWidth(2, 0);
    SetMarginWidth(3, 0);
    SetMarginWidth(4, 0);
    SetTabWidth(4);
    
    // Define some colors to use
    StyleSetBackground(MARGIN_STYLE_START + 1,  DrawingUtils::LightColour(wxT("GREEN"),      7.0));
    StyleSetBackground(MARGIN_STYLE_START + 2,  DrawingUtils::LightColour(wxT("BLUE"),       7.0));
    StyleSetBackground(MARGIN_STYLE_START + 3,  DrawingUtils::LightColour(wxT("ORANGE"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 4,  DrawingUtils::LightColour(wxT("YELLOW"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 5,  DrawingUtils::LightColour(wxT("PURPLE"),     7.0));
    StyleSetBackground(MARGIN_STYLE_START + 6,  DrawingUtils::LightColour(wxT("RED"),        7.0));
    StyleSetBackground(MARGIN_STYLE_START + 7,  DrawingUtils::LightColour(wxT("BROWN"),      7.0));
    StyleSetBackground(MARGIN_STYLE_START + 8,  DrawingUtils::LightColour(wxT("LIGHT GREY"), 7.0));
    StyleSetBackground(MARGIN_STYLE_START + 9,  DrawingUtils::LightColour(wxT("SIENNA"),     7.0));

    StyleSetBackground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
    StyleSetForeground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
}
Beispiel #2
0
void IWnd_stc::UpdateMarginLineNumWidth(bool flag)
{
	BitFlags &flags(param.flags);

	if(!flags.get(FLAG_LINENUM))
	{
		if(m_nLineNumWidth==0)
		{
			return;
		}
		m_nLineNumWidth=0;
		SetMarginWidth(StcManager::LINE_NR_ID,0);
	}
	else
	{

		int _nWidth=3+(int)::log10(double(GetLineCount()));
		if(_nWidth<4) _nWidth=4;
		if(_nWidth>7) _nWidth=7;

		if(_nWidth==m_nLineNumWidth && !flag)
		{
			return;
		}
		m_nLineNumWidth=_nWidth;

		static const char* text="999999999999999";
		int wd=TextWidth (wxSTC_STYLE_LINENUMBER, wxString(text,m_nLineNumWidth));
		SetMarginWidth(StcManager::LINE_NR_ID,wd);
	}

}
Beispiel #3
0
void SourceView::setPlainMode()
{
	SetLexer (wxSTC_LEX_NULL);

	SetMarginWidth (0, 0);
	SetMarginWidth (1, 0);
}
Beispiel #4
0
/* TextEditor::setupFoldMargin
 * Sets up the code folding margin
 *******************************************************************/
void TextEditor::setupFoldMargin(TextStyle* margin_style)
{
	if (!txed_fold_enable)
	{
		SetMarginWidth(1, 0);
		return;
	}

	wxColour col_fg, col_bg;
	if (margin_style)
	{
		col_fg = WXCOL(margin_style->getForeground());
		col_bg = WXCOL(margin_style->getBackground());
	}
	else
	{
		col_fg = WXCOL(StyleSet::currentSet()->getStyle("foldmargin")->getForeground());
		col_bg = WXCOL(StyleSet::currentSet()->getStyle("foldmargin")->getBackground());
	}

	SetMarginType(1, wxSTC_MARGIN_SYMBOL);
	SetMarginWidth(1, 16);
	SetMarginSensitive(1, true);
	SetMarginMask(1, wxSTC_MASK_FOLDERS);
	SetFoldMarginColour(true, col_bg);
	SetFoldMarginHiColour(true, col_bg);
	MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, col_bg, col_fg);
	MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, col_bg, col_fg);
}
Beispiel #5
0
/* TextEditor::TextEditor
 * TextEditor class constructor
 *******************************************************************/
TextEditor::TextEditor(wxWindow* parent, int id)
	: wxStyledTextCtrl(parent, id), timer_update(this)
{
	// Init variables
	language = nullptr;
	ct_argset = 0;
	ct_function = nullptr;
	ct_start = 0;
	bm_cursor_last_pos = -1;
	panel_fr = nullptr;
	call_tip = new SCallTip(this);
	choice_jump_to = nullptr;
	jump_to_calculator = nullptr;

	// Set tab width
	SetTabWidth(txed_tab_width);

	// Line numbers by default
	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, "9999"));

	// Folding margin
	setupFoldMargin();

	// Border margin
	SetMarginWidth(2, 4);

	// Register icons for autocompletion list
	RegisterImage(1, Icons::getIcon(Icons::TEXT_EDITOR, "key"));
	RegisterImage(2, Icons::getIcon(Icons::TEXT_EDITOR, "const"));
	RegisterImage(3, Icons::getIcon(Icons::TEXT_EDITOR, "func"));

	// Init w/no language
	setLanguage(nullptr);

	// Setup various configurable properties
	setup();

	// Add to text styles editor list
	StyleSet::addEditor(this);

	// Bind events
	Bind(wxEVT_KEY_DOWN, &TextEditor::onKeyDown, this);
	Bind(wxEVT_KEY_UP, &TextEditor::onKeyUp, this);
	Bind(wxEVT_STC_CHARADDED, &TextEditor::onCharAdded, this);
	Bind(wxEVT_STC_UPDATEUI, &TextEditor::onUpdateUI, this);
	Bind(wxEVT_STC_CALLTIP_CLICK, &TextEditor::onCalltipClicked, this);
	Bind(wxEVT_STC_DWELLSTART, &TextEditor::onMouseDwellStart, this);
	Bind(wxEVT_STC_DWELLEND, &TextEditor::onMouseDwellEnd, this);
	Bind(wxEVT_LEFT_DOWN, &TextEditor::onMouseDown, this);
	Bind(wxEVT_KILL_FOCUS, &TextEditor::onFocusLoss, this);
	Bind(wxEVT_ACTIVATE, &TextEditor::onActivate, this);
	Bind(wxEVT_STC_MARGINCLICK, &TextEditor::onMarginClick, this);
	Bind(wxEVT_COMMAND_JTCALCULATOR_COMPLETED, &TextEditor::onJumpToCalculateComplete, this);
	Bind(wxEVT_STC_MODIFIED, &TextEditor::onModified, this);
	Bind(wxEVT_TIMER, &TextEditor::onUpdateTimer, this);
	Bind(wxEVT_STC_STYLENEEDED, &TextEditor::onStyleNeeded, this);
}
Beispiel #6
0
void FB_STC::LoadSettings ( ) {
    FB_Config    * Prefs  = m_Ide->GetConfig();
    Style_STC_FB * Style  = &Prefs->Style_FB;

    // Clear all styles there might be defined
    StyleClearAll(  );
    SetLexer( 0 );
    
    // Tab and indenting
    SetTabWidth             ( Prefs->TabSize );
    SetUseTabs              ( false );
    SetTabIndents           ( true );
    SetBackSpaceUnIndents   ( true );
    SetIndent               ( Prefs->TabSize );
    SetIndentationGuides    ( Prefs->IndentGuide );
    
    // Right margin
    SetEdgeMode   ( Prefs->RightMargin ? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE );
    SetEdgeColumn ( Prefs->EdgeColumn );
    
    // Line and line ending
    SetEOLMode ( 0 );
    SetViewEOL ( Prefs->DisplayEOL );
    SetViewWhiteSpace ( Prefs->WhiteSpace ? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE );
    
    // Misc
    CmdKeyClear (wxSTC_KEY_TAB, 0);
    #define _STYLE(nr) Style->Style[nr]
        wxFont font ( _STYLE(0).Size, wxMODERN, wxNORMAL, wxNORMAL, false, _STYLE(0).Font );

        StyleSetForeground (wxSTC_STYLE_DEFAULT,    Prefs->GetClr(_STYLE(0).Face));
        StyleSetBackground (wxSTC_STYLE_DEFAULT,    Prefs->GetClr(_STYLE(0).Back));
        StyleSetFont( wxSTC_STYLE_DEFAULT, font );

        StyleSetForeground (0,    Prefs->GetClr(_STYLE(0).Face));
        StyleSetBackground (0,    Prefs->GetClr(_STYLE(0).Back));
        StyleSetFont( 0, font );
        
        StyleSetForeground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberFace));
        StyleSetBackground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberBack));
        StyleSetFont( wxSTC_STYLE_LINENUMBER, font );
                    
        SetCaretForeground (Prefs->GetClr(Style->CaretFace));
        SetSelForeground(true, Prefs->GetClr(Style->SelectFace));
        SetSelBackground(true, Prefs->GetClr(Style->SelectBack));
    #undef STYLE

    int LineNrMargin = TextWidth(wxSTC_STYLE_LINENUMBER, _T("0001"));
    SetMarginWidth (0, Prefs->LineNumber ? LineNrMargin : 0);
    SetMarginWidth (1,0);

    if ( Prefs->CurrentLine )
    {
        SetCaretLineVisible( true );
        SetCaretLineBack( Prefs->GetClr( Style->CaretLine ) );
    }

}
Beispiel #7
0
TextControl::TextControl(wxWindow *parent, wxWindowID id)
    : wxStyledTextCtrl(parent, id, wxDefaultPosition, wxDefaultSize,
        wxBORDER_THEME)
{
    SetWrapMode(wxSTC_WRAP_WORD);
    // wxStyledTextCtrl uses black on white initially -> use system defaults
    resetStyles();
    // Hide margin area for line numbers and fold markers
    SetMarginWidth(1, 0);
    SetMarginWidth(0, 0);
}
Beispiel #8
0
/* TextEditor::TextEditor
 * TextEditor class constructor
 *******************************************************************/
TextEditor::TextEditor(wxWindow* parent, int id)
	: wxStyledTextCtrl(parent, id)
{
	// Init variables
	language = NULL;
	ct_argset = 0;
	ct_function = NULL;
	ct_start = 0;

	// Set tab width
	SetTabWidth(txed_tab_width);

	// Line numbers by default
	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, "9999"));
	SetMarginWidth(1, 4);

	// Register icons for autocompletion list
	RegisterImage(1, getIcon("ac_key"));
	RegisterImage(2, getIcon("ac_const"));
	RegisterImage(3, getIcon("ac_func"));

	// Init w/no language
	setLanguage(NULL);

	// Find+Replace dialog
	dlg_fr = new FindReplaceDialog(this);

	// Setup various configurable properties
	setup();

	// Bind events
	Bind(wxEVT_KEY_DOWN, &TextEditor::onKeyDown, this);
	Bind(wxEVT_KEY_UP, &TextEditor::onKeyUp, this);
	Bind(wxEVT_STC_CHARADDED, &TextEditor::onCharAdded, this);
	Bind(wxEVT_STC_UPDATEUI, &TextEditor::onUpdateUI, this);
	Bind(wxEVT_STC_CALLTIP_CLICK, &TextEditor::onCalltipClicked, this);
	Bind(wxEVT_STC_DWELLSTART, &TextEditor::onMouseDwellStart, this);
	Bind(wxEVT_STC_DWELLEND, &TextEditor::onMouseDwellEnd, this);
	Bind(wxEVT_LEFT_DOWN, &TextEditor::onMouseDown, this);
	Bind(wxEVT_KILL_FOCUS, &TextEditor::onFocusLoss, this);
	Bind(wxEVT_ACTIVATE, &TextEditor::onActivate, this);
	dlg_fr->getBtnFindNext()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnFindNext, this);
	dlg_fr->getBtnReplace()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplace, this);
	dlg_fr->getBtnReplaceAll()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplaceAll, this);
	//dlg_fr->getTextFind()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnFindNext, this);
	//dlg_fr->getTextReplace()->Bind(wxEVT_BUTTON, &TextEditor::onFRDBtnReplace, this);
	dlg_fr->Bind(wxEVT_CHAR_HOOK, &TextEditor::onFRDKeyDown, this);
}
void MiniStyledTextCtrl::Init()
{
    SetMargins(0,0);
    for (unsigned int i = 0 ; i < wxSCI_MAX_MARGIN ; ++i)
        SetMarginWidth(i,0);

    SetZoom(-10); // this is the smallest allowed zoom factor

    SetUseHorizontalScrollBar(false);

    backgroundColour_ = Manager::Get()->GetColourManager()->GetColour(wxT("minidoc_background"));
    ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("editor"));
    inverseMarker_ = cfg->ReadBool(_T("/mini_doc/inverse_designator"), false);
    doScrollToPosition_ = cfg->ReadBool(_T("/mini_doc/sync_to_main_doc"), true);

    bool showVertScrollbar = cfg->ReadBool(_T("/mini_doc/show_vertical_scrollbar"), true);
    SetUseVerticalScrollBar(showVertScrollbar);

    wxColor color = Manager::Get()->GetColourManager()->GetColour(wxT("minidoc_background"));

    MarkerDeleteAll(GetOurMarkerNumber());
    MarkerSetBackground(GetOurMarkerNumber(), color);
    const int alpha = 100;
    MarkerSetAlpha(GetOurMarkerNumber(), alpha);
}
Beispiel #10
0
/*---------------------------------------------------------------------------*/
void wxSQLEditorBase::Init()
{
   m_FontName = _T("Courier New");
   m_FontSize = 10;

   SetWrapMode(wxSTC_WRAP_NONE);  // wxSTC_WRAP_WORD wxSTC_WRAP_NONE
   SetLexer(wxSTC_LEX_SQL);
   SetTabWidth(2);
   SetUseTabs(false);
   SetTabIndents (true);
   SetBackSpaceUnIndents (true);
   SetIndent(2);
   SetViewEOL(false);
   SetIndentationGuides(true);
   SetEOLMode(wxSTC_EOL_LF);

   SetEdgeColumn(200);
   SetEdgeMode(wxSTC_EDGE_LINE);   // wxSTC_EDGE_NONE wxSTC_EDGE_LINE
   SetViewWhiteSpace(wxSTC_WS_INVISIBLE);   // wxSTC_WS_VISIBLEALWAYS

   SetMarginType(1, wxSTC_MARGIN_SYMBOL);
   SetMarginWidth(1, 0);

   SetKeyWords(0, SQLWordlist1);
   SetKeyWords(1, SQLWordlist2);
   SetKeyWords(4, SQLWordlist3);
   SetKeyWords(5, SQLWordlist4);

   ReInitAllStyle();
}
Beispiel #11
0
void MiniStyledTextCtrl::Init()
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));

    SetMargins(0,0);
    for (unsigned int i = 0 ; i < wxSCI_MAX_MARGIN ; ++i)
        SetMarginWidth(i,0);

    SetZoom(-10); // smallest allowed zoom factor
//    StyleSetSize(wxSCI_STYLE_DEFAULT, 2);
//    for (unsigned int style = 0 ; style < wxSCI_STYLE_MAX ; ++style)
//        StyleSetSize(style, 2);

    SetUseHorizontalScrollBar(false);

    bool showVertScrollbar = cfg->ReadBool(_T("/mini_doc/show_vertical_scrollbar"), true);
    SetUseVerticalScrollBar(showVertScrollbar);

    wxColor color = Manager::Get()->GetColourManager()->GetColour(wxT("minidoc_background"));

    MarkerDeleteAll(GetOurMarkerNumber());
    MarkerSetBackground(GetOurMarkerNumber(), color);
    const int alpha = 100;
    MarkerSetAlpha(GetOurMarkerNumber(), alpha);
}
Beispiel #12
0
/* TextEditor::loadEntry
 * Reads the contents of [entry] into the text area, returns false
 * if the given entry is invalid
 *******************************************************************/
bool TextEditor::loadEntry(ArchiveEntry* entry)
{
	// Clear current text
	ClearAll();

	// Check that the entry exists
	if (!entry)
	{
		Global::error = "Invalid archive entry given";
		return false;
	}

	// Check that the entry has any data, if not do nothing
	if (entry->getSize() == 0 || !entry->getData())
		return true;

	// Get character entry data
	//string text = wxString::From8BitData((const char*)entry->getData(), entry->getSize());
	string text = wxString::FromUTF8((const char*)entry->getData(), entry->getSize());
	// If opening as UTF8 failed for some reason, try again as 8-bit data
	if (text.length() == 0)
		text = wxString::From8BitData((const char*)entry->getData(), entry->getSize());

	// Load text into editor
	SetText(text);

	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	return true;
}
Beispiel #13
0
/* TextEditor::onCharAdded
 * Called when a character is added to the text
 *******************************************************************/
void TextEditor::onCharAdded(wxStyledTextEvent& e)
{
	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	// Auto indent
	int currentLine = GetCurrentLine();
	if (txed_auto_indent && e.GetKey() == '\n')
	{
		// Get indentation amount
		int lineInd = 0;
		if (currentLine > 0)
			lineInd = GetLineIndentation(currentLine - 1);

		// Do auto-indent if needed
		if (lineInd != 0)
		{
			SetLineIndentation(currentLine, lineInd);

			// Skip to end of tabs
			while (1)
			{
				int chr = GetCharAt(GetCurrentPos());
				if (chr == '\t' || chr == ' ')
					GotoPos(GetCurrentPos()+1);
				else
					break;
			}
		}
	}

	// The following require a language to work
	if (language)
	{
		// Call tip
		if (e.GetKey() == '(' && txed_calltips_parenthesis)
		{
			openCalltip(GetCurrentPos());
		}

		// End call tip
		if (e.GetKey() == ')')
		{
			CallTipCancel();
		}

		// Comma, possibly update calltip
		if (e.GetKey() == ',' && txed_calltips_parenthesis)
		{
			//openCalltip(GetCurrentPos());
			//if (CallTipActive())
			updateCalltip();
		}
	}

	// Continue
	e.Skip();
}
Beispiel #14
0
ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
                   const wxString& name)
{
    Hide();
    if(!wxStyledTextCtrl::Create(parent, id, pos, size, style | wxNO_BORDER, name)) {
        return;
    }

    wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
    for(int i = 0; i < wxSTC_STYLE_MAX; ++i) {
        StyleSetBackground(i, bgColour);
    }

    znConfigItem data;
    clConfig conf("zoom-navigator.conf");
    conf.ReadItem(&data);

    SetEditable(false);
    SetUseHorizontalScrollBar(false);
    SetUseVerticalScrollBar(data.IsUseScrollbar());
    HideSelection(true);

    SetMarginWidth(1, 0);
    SetMarginWidth(2, 0);
    SetMarginWidth(3, 0);

    m_zoomFactor = data.GetZoomFactor();
    m_colour = data.GetHighlightColour();
    MarkerSetBackground(1, m_colour);
    SetZoom(m_zoomFactor);
    EventNotifier::Get()->Connect(wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL,
                                  this);
    EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this);
    MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour);

#ifndef __WXMSW__
    SetTwoPhaseDraw(false);
    SetBufferedDraw(false);
    SetLayoutCache(wxSTC_CACHE_DOCUMENT);
#endif
    MarkerSetAlpha(1, 10);

    m_timer = new wxTimer(this);
    Bind(wxEVT_TIMER, &ZoomText::OnTimer, this, m_timer->GetId());
    Show();
}
Beispiel #15
0
void ctlSQLBox::UpdateLineNumber()
{
    bool showlinenumber;

    settings->Read(wxT("frmQuery/ShowLineNumber"), &showlinenumber, false);
    if (showlinenumber)
    {
        long int width = TextWidth(wxSTC_STYLE_LINENUMBER,
            wxT(" ")+NumToStr((long int)GetLineCount())+wxT(" "));
        if (width != GetMarginWidth(0))
            SetMarginWidth(0, width);
    }
    else
    {
        SetMarginWidth(0, 0);
    }
}
Beispiel #16
0
bool wxSTEditorShell::Create(wxWindow *parent, wxWindowID id,
                             const wxPoint& pos, const wxSize& size,
                             long style, const wxString& name)
{
    if (!wxSTEditor::Create(parent, id, pos, size, style, name))
        return false;

    // set this up in case they don't want to bother with the preferences
    SetMarginWidth(STE_MARGIN_NUMBER,0);
    SetMarginWidth(STE_MARGIN_FOLD,0);
    SetMarginWidth(marginPrompt, 16);

    SetMarginType(marginPrompt, wxSTC_MARGIN_SYMBOL);
    SetMarginMask(marginPrompt, 1<<markerPrompt);
    // after creation you can change this to whatever prompt you prefer
    MarkerDefine(markerPrompt, wxSTC_MARK_ARROWS, *wxBLACK, wxColour(255,255,0));
    return true;
}
Beispiel #17
0
/*---------------------------------------------------------------------------*/
void wxSQLEditorBase::SetLineNumberMarginStyle(bool show, wxColour fore,
                                               wxColour back)
{
   SetMarginType(0, wxSTC_MARGIN_NUMBER);
   if (fore != wxNullColour)
      StyleSetForeground(wxSTC_STYLE_LINENUMBER, fore);
   if (back != wxNullColour)
      StyleSetBackground(wxSTC_STYLE_LINENUMBER, back);
   SetMarginWidth(0, show ? 25 : 0);
}
Beispiel #18
0
wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *parent)
{
    m_parent = parent;
    m_checked = false;

    wxSize size = wxRendererNative::Get().GetCheckBoxSize(parent);
    size.x += 2 * CHECKMARK_EXTRA_SPACE + CHECKMARK_LABEL_SPACE;

    SetMarginWidth(size.GetWidth());
    SetBackgroundColour(parent->GetBackgroundColour());
}
Beispiel #19
0
wxListBoxItem::wxListBoxItem(
  const wxString& rsStr
)
: wxOwnerDrawn( rsStr
               ,false
              )
{
    //
    // No bitmaps/checkmarks
    //
    SetMarginWidth(0);
} // end of wxListBoxItem::wxListBoxItem
Beispiel #20
0
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") ) );
}
Beispiel #21
0
void IWnd_stc::_DoUpdateMarginLineNumWidth(bool flag)
{
	BitFlags &flags(param.flags);

	if(!flags.get(FLAG_LINENUM))
	{
		if(m_nLineNumWidth==0)
		{
			return;
		}
		m_nLineNumWidth=0;
		SetMarginWidth(StcManager::LINE_NR_ID,0);
	}
	else
	{

		int _nWidth=3;
		for(int nLine = GetLineCount();nLine > 9;nLine=nLine/10)
		{
			_nWidth++;
		}

		if(_nWidth<5) _nWidth=5;
		if(_nWidth>8) _nWidth=8;


		if (!flag && _nWidth<=m_nLineNumWidth)
		{
			return;
		}

		m_nLineNumWidth=_nWidth;

		static const char* text="999999999999999";
		int wd=TextWidth (wxSTC_STYLE_LINENUMBER, wxString(text,m_nLineNumWidth));
		SetMarginWidth(StcManager::LINE_NR_ID,wd);

	}

}
Beispiel #22
0
fbtTextFile::fbtTextFile(fbtMainFrame* parent, fbtText* fp, int id)
	:   wxStyledTextCtrl(parent, FBT_WINDOW_TXT),
	    m_file(fp), m_parent(parent)
{

	SetViewEOL(false);
	SetIndentationGuides(false);
	SetEdgeMode(wxSTC_EDGE_NONE);
	SetViewWhiteSpace(wxSTC_WS_INVISIBLE);

	SetReadOnly(false);
	SetTabWidth(4);
	SetWrapMode(wxSTC_WRAP_NONE);

	wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL);
	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")));


	SetMarginType(0, wxSTC_MARGIN_NUMBER);
	SetMarginWidth(0, TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_99999")));

	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);


	SetLexer(wxSTC_LEX_CPP);

	StyleSetForeground(wxSTC_C_COMMENT,         COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTLINEDOC,  COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTLINE,     COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_COMMENTDOC,      COMMENT_COLOR);
	StyleSetForeground(wxSTC_C_NUMBER,          NUMBER_COLOR);
	StyleSetForeground(wxSTC_C_OPERATOR,        OPERATOR_COLOR);
	StyleSetForeground(wxSTC_C_WORD,            WORD_COLOR);
	StyleSetForeground(wxSTC_C_PREPROCESSOR,    WORD_COLOR);

	SetKeyWords(0, WORDS);

	SetSelBackground(true, wxColor(51, 94, 168));
	SetSelForeground(true, wxColor(255, 255, 255));

	m_file->m_textFile = this;
	m_file->m_flag |= fbtText::FILE_IS_OPEN;
}
Beispiel #23
0
/*---------------------------------------------------------------------------*/
void wxSQLEditorBase::ReInitAllStyle()
{
   SetMarginType(0, wxSTC_MARGIN_NUMBER);
   StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour(_T("BLACK")));
   StyleSetBackground(wxSTC_STYLE_LINENUMBER, wxColour(_T("GREY")));
   SetMarginWidth(0, 25);
   // default fonts for all styles!
   for (int i = wxSTC_SQL_DEFAULT; i <= wxSTC_SQL_QUOTEDIDENTIFIER; i++)
   {
      SetTypeStyle(i, false, false, false, wxSTC_CASE_MIXED,
                   wxColour(_T("BLACK")), wxColour(_T("WHITE")));
   }
}
Beispiel #24
0
ZoomText::ZoomText(wxWindow* parent,
                   wxWindowID id,
                   const wxPoint& pos,
                   const wxSize& size,
                   long style,
                   const wxString& name)
    : wxStyledTextCtrl(parent, id, pos, size, style | wxNO_BORDER, name)
{
    znConfigItem data;
    clConfig conf("zoom-navigator.conf");
    conf.ReadItem(&data);
    
    SetEditable(false);
    SetUseHorizontalScrollBar(false);
    SetUseVerticalScrollBar(data.IsUseScrollbar());
    HideSelection(true);

    SetMarginWidth(1, 0);
    SetMarginWidth(2, 0);
    SetMarginWidth(3, 0);


    m_zoomFactor = data.GetZoomFactor();
    m_colour = data.GetHighlightColour();
    MarkerSetBackground(1, m_colour);
    SetZoom(m_zoomFactor);
    EventNotifier::Get()->Connect(
        wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL, this);
    EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this);
    MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour);

#ifndef __WXMSW__
    SetTwoPhaseDraw(false);
    SetBufferedDraw(false);
    SetLayoutCache(wxSTC_CACHE_DOCUMENT);
#endif
    MarkerSetAlpha(1, 10);
    wxTheApp->Bind(wxEVT_IDLE, &ZoomText::OnIdle, this);
}
Beispiel #25
0
void CodeEdit::SetEditorSettings(const EditorSettings& settings)
{
    m_indentationSize = settings.GetIndentSize();

    SetIndent(m_indentationSize);
    SetTabWidth(m_indentationSize);
    
    bool useTabs = settings.GetUseTabs();
    bool showWhiteSpace = settings.GetShowWhiteSpace();

    SetUseTabs(useTabs);
    SetTabIndents(useTabs);
    SetBackSpaceUnIndents(useTabs);
    SetViewWhiteSpace(showWhiteSpace);
    SetMultipleSelection(true);
    SetAdditionalSelectionTyping(true);
    SetMultiPaste(1);
    SetVirtualSpaceOptions(1);

    if (settings.GetShowLineNumbers())
    {

        // Figure out how wide the margin needs to be do display
        // the most number of linqes we'd reasonbly have.
        int marginSize = TextWidth(wxSTC_STYLE_LINENUMBER, "_99999");
        SetMarginWidth(0, marginSize);

        SetMarginType(0,wxSTC_MARGIN_NUMBER);

    }
    else
    {
        SetMarginWidth(0, 0);
    }    

    m_enableAutoComplete = settings.GetEnableAutoComplete();

}    
Beispiel #26
0
wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox* pParent, size_t nIndex)
                   :wxOwnerDrawn( wxEmptyString, true /* checkable */ )
{
    m_bChecked = false;
    m_pParent  = pParent;
    m_nIndex   = nIndex;

    //
    // We don't initialize m_nCheckHeight/Width vars because it's
    // done in OnMeasure while they are used only in OnDraw and we
    // know that there will always be OnMeasure before OnDraw
    //
    SetMarginWidth(CHECK_MARK_WIDTH);
} // end of wxCheckListBoxItem::wxCheckListBoxItem
Beispiel #27
0
void AsmEditor::InitializePrefs()
{
    SetMarginWidth (MARGIN_LINE_NUMBERS, 40);
    StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (75, 75, 75) );
    StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (220, 220, 220));
    SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);

    SetWrapMode (wxSTC_WRAP_NONE); //wxSTC_WRAP_WORD); // other choice is wxSCI_WRAP_NONE

    StyleClearAll();
    SetLexer(wxSTC_LEX_CPP); // we want to use CPP format -- not ASM
    wxFont f(10, wxFONTFAMILY_DEFAULT, wxNORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Consolas"));

    for( int i=0; i < wxSTC_STYLE_LASTPREDEFINED; ++i )
        StyleSetFont( i, f );
    
    StyleSetForeground( mySTC_C_DEFAULT,                wxColour(0,0,0) ); 
    StyleSetForeground( mySTC_C_COMMENT,                wxColour(0,0,0) ); // /* */ comment
    StyleSetForeground( mySTC_C_COMMENTLINE,            wxColour(0,128,0) );   // // comment
    StyleSetForeground( mySTC_C_COMMENTDOC,             wxColour(0,0,0) ); // /** */ comment
    StyleSetForeground( mySTC_C_NUMBER,                 wxColour(90,90,90) );
    StyleSetForeground( mySTC_C_WORD,                   wxColour(40,86,165) ); // custom 0
    StyleSetForeground( mySTC_C_STRING,                 wxColour(163,21,21) );
    StyleSetForeground( mySTC_C_CHARACTER,              wxColour(163,21,21) );
    StyleSetForeground( mySTC_C_UUID,                   wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_PREPROCESSOR,           wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_OPERATOR,               wxColour(150,0,0) );
    StyleSetForeground( mySTC_C_IDENTIFIER,             wxColour(0,0,0) );
    StyleSetForeground( mySTC_C_STRINGEOL,              wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_VERBATIM,               wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_REGEX,                  wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_COMMENTLINEDOC,         wxColour(0,128,0) );
    StyleSetForeground( mySTC_C_WORD2,                  wxColour(150,0,150) ); // custom 1
    StyleSetForeground( mySTC_C_COMMENTDOCKEYWORD,      wxColour(0,0,0) ); // needs color
    StyleSetForeground( mySTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,0,0) );
    StyleSetForeground( mySTC_C_GLOBALCLASS,            wxColour(0,0,0) ); // custom 3
    
    StyleSetBold( mySTC_C_NUMBER, true );
    StyleSetBold( mySTC_C_WORD2,  true );
    StyleSetBold( mySTC_C_WORD,   true );
    StyleSetFont( mySTC_C_COMMENT, f );
    StyleSetFont( mySTC_C_COMMENTDOC, f );
}
Beispiel #28
0
wxCheckListBoxItem::wxCheckListBoxItem (
  wxCheckListBox*                   pParent
, size_t                            nIndex
)
: wxOwnerDrawn( wxEmptyString
               ,TRUE // checkable
              )
{
    m_bChecked = FALSE;
    m_pParent  = pParent;
    m_nIndex   = nIndex;

    //
    // We don't initialize m_nCheckHeight/Width vars because it's
    // done in OnMeasure while they are used only in OnDraw and we
    // know that there will always be OnMeasure before OnDraw
    //
    SetMarginWidth(GetDefaultMarginWidth());
} // end of wxCheckListBoxItem::wxCheckListBoxItem
Beispiel #29
0
void wxMenuItem::Init()
{
#if  wxUSE_OWNER_DRAWN

    // when the color is not valid, wxOwnerDraw takes the default ones.
    // If we set the colors here and they are changed by the user during
    // the execution, then the colors are not updated until the application
    // is restarted and our menus look bad
    SetTextColour(wxNullColour);
    SetBackgroundColour(wxNullColour);

    // setting default colors switched ownerdraw on: switch it off again
    SetOwnerDrawn(false);

    //  switch ownerdraw back on if using a non default margin
    if ( !IsSeparator() )
        SetMarginWidth(GetMarginWidth());

#endif // wxUSE_OWNER_DRAWN
}
Beispiel #30
0
void SvnBlameEditor::SetText(const wxString& text)
{
    // Define some colors
    int xx, yy;
    int marginWidth(0);

    int s_style(MARGIN_FIRST_STYLE);
    std::map<wxString, int> authorsColorsMap;

    wxFont defFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxFont font(defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);

    wxArrayString lines = wxStringTokenize(text, wxT("\n"), wxTOKEN_RET_DELIMS);
    for (size_t i=0; i<lines.GetCount(); i++) {
        wxString revision;
        wxString author;
        wxString text;

        wxString line = lines.Item(i);
        line.Trim(false);

        revision = line.BeforeFirst(wxT(' '));
        revision.Trim().Trim(false);
        line = line.AfterFirst(wxT(' '));
        line.Trim(false);

        author = line.BeforeFirst(wxT(' '));
        author.Trim().Trim(false);

        int style;
        std::map<wxString, int>::iterator iter = authorsColorsMap.find(author);
        if (iter != authorsColorsMap.end()) {
            // Create new random color and use it
            style = (*iter).second;
        } else {
            style = s_style;
            s_style ++;
            if (s_style > (MARGIN_STYLE_START+9) )
                s_style = MARGIN_FIRST_STYLE;
            authorsColorsMap[author] = style;
        }

        line = line.AfterFirst(wxT(' '));

        wxString marginText = wxString::Format(wxT("% 8s: %s"), revision.c_str(), author.c_str());
        wxWindow::GetTextExtent(marginText, &xx, &yy, NULL, NULL, &font);

        marginWidth = wxMax(marginWidth, xx);
        AppendText(line);
        MarginSetText((int)i, marginText);
        MarginSetStyle((int)i, style);

        // Keep the revision on in array
        BlameLineInfo info;
        info.revision = revision;
        info.style    = style;
        m_lineInfo.push_back(info);
    }

    SetMarginWidth(0, marginWidth);
    SetReadOnly(true);
}