Пример #1
0
void clCxxWorkspace::SetWorkspaceEditorOptions(LocalOptionsConfigPtr opts)
{
    wxXmlNode* parent = m_doc.GetRoot();
    wxXmlNode* oldOptions = XmlUtils::FindFirstByTagName(parent, wxT("Options"));
    if(oldOptions) {
        oldOptions->GetParent()->RemoveChild(oldOptions);
        delete oldOptions;
    }
    parent->AddChild(opts->ToXml());
    SaveXmlFile();
}
Пример #2
0
bool LocalWorkspace::SetWorkspaceOptions(LocalOptionsConfigPtr opts)
{
    // Stored as:
    //	<Workspace>
    //		<LocalWorkspaceOptions something="on" something_else="off"/>
    //	</Workspace>

    if(!SanityCheck()) { return false; }

    wxXmlNode* oldOptions = GetLocalWorkspaceOptionsNode();
    if(oldOptions) {
        m_doc.GetRoot()->RemoveChild(oldOptions);
        delete oldOptions;
    }
    m_doc.GetRoot()->AddChild(opts->ToXml(NULL, wxT("LocalWorkspaceOptions")));
    return SaveXmlFile();
}
Пример #3
0
bool LocalWorkspace::SetProjectOptions(LocalOptionsConfigPtr opts, const wxString& projectname)
{
    // Stored as:
    //	<Project Name="foo">
    //		<Options something="on" something_else="off"/>
    //	</Project>

    if(!SanityCheck()) { return false; }

    // If the project node doesn't exist, create it
    wxXmlNode* project = XmlUtils::FindNodeByName(m_doc.GetRoot(), wxT("Project"), projectname);
    if(!project) {
        project = new wxXmlNode(m_doc.GetRoot(), wxXML_ELEMENT_NODE, wxT("Project"));
        project->AddProperty(wxT("Name"), projectname);
    }

    wxXmlNode* oldOptions = XmlUtils::FindFirstByTagName(project, wxT("Options"));
    if(oldOptions) {
        project->RemoveChild(oldOptions);
        delete oldOptions;
    }
    project->AddChild(opts->ToXml(NULL, wxT("Options")));
    return SaveXmlFile();
}
Пример #4
0
LocalOptionsConfig::LocalOptionsConfig(LocalOptionsConfigPtr opts, wxXmlNode* node)
{
    // Used for reading local values, which are stored in the passed empty LocalOptionsConfigPtr only if valid
    // This is the same code as the previous ctor,except opts is a *Local*OptionsConfigPtr
    // This duplication is ugly, but not as ugly as any alternatives I could think of :(
    // (The main problem is that e.g. LocalOptionsConfig::SetDisplayFoldMargin has a different prototype to
    // OptionsConfig::SetDisplayFoldMargin)
    if(node) {
        bool answer;
        wxString str;
        long l;
        if(XmlUtils::ReadBoolIfExists(node, wxT("DisplayFoldMargin"), answer)) { opts->SetDisplayFoldMargin(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("DisplayBookmarkMargin"), answer)) {
            opts->SetDisplayBookmarkMargin(answer);
        }
        if(XmlUtils::ReadBoolIfExists(node, wxT("HighlightCaretLine"), answer)) { opts->SetHighlightCaretLine(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("EditorTrimEmptyLines"), answer)) { opts->SetTrimLine(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("EditorAppendLf"), answer)) { opts->SetAppendLF(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("ShowLineNumber"), answer)) { opts->SetDisplayLineNumbers(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("IndentationGuides"), answer)) {
            opts->SetShowIndentationGuidelines(answer);
        }
        if(XmlUtils::ReadBoolIfExists(node, wxT("IndentUsesTabs"), answer)) { opts->SetIndentUsesTabs(answer); }
        if(XmlUtils::ReadBoolIfExists(node, wxT("HideChangeMarkerMargin"), answer)) {
            opts->SetHideChangeMarkerMargin(answer);
        }
        if(XmlUtils::ReadLongIfExists(node, wxT("IndentWidth"), l)) { opts->SetIndentWidth(l); }
        if(XmlUtils::ReadLongIfExists(node, wxT("TabWidth"), l)) { opts->SetTabWidth(l); }
        if(XmlUtils::ReadLongIfExists(node, wxT("ShowWhitespaces"), l)) { opts->SetShowWhitespaces(l); }
        if(XmlUtils::ReadStringIfExists(node, wxT("EOLMode"), str)) { opts->SetEolMode(str); }
        if(XmlUtils::ReadStringIfExists(node, wxT("FileFontEncoding"), str)) { opts->SetFileFontEncoding(str); }
    }
}
Пример #5
0
void EditorSettingsLocal::DisplayLocalValues( const LocalOptionsConfigPtr options )
{
	// There will be 'global' values already present for each setting
	// Override this with any valid previously-make local pref, then untick the corresponding enabling checkbox, so that item will be enabled

	if (options->IndentUsesTabsIsValid()) {
		m_indentsUsesTabs->SetValue(options->GetIndentUsesTabs());
		m_indentsUsesTabsEnable->SetValue(false);
	}
	if (options->IndentWidthIsValid()) {
		m_indentWidth->SetValue(options->GetIndentWidth());
		m_indentWidthEnable->SetValue(false);
	}

	if (options->TabWidthIsValid()) {
		m_tabWidth->SetValue(options->GetTabWidth());
		m_tabWidthEnable->SetValue(false);
	}
	if (options->DisplayLineNumbersIsValid()) {
		m_displayLineNumbers->SetValue(options->GetDisplayLineNumbers());
		m_displayLineNumbersEnable->SetValue(false);
	}
	if (options->ShowIndentationGuidelinesIsValid()) {
		m_showIndentationGuideLines->SetValue(options->GetShowIndentationGuidelines());
		m_showIndentationGuideLinesEnable->SetValue(false);
	}
	if (options->HighlightCaretLineIsValid()) {
		m_highlightCaretLine->SetValue(options->GetHighlightCaretLine());
		m_highlightCaretLineEnable->SetValue(false);
	}
	if (options->TrimLineIsValid()) {
		m_checkBoxTrimLine->SetValue(options->GetHighlightCaretLine());
		m_checkBoxTrimLineEnable->SetValue(false);
	}
	if (options->AppendLFIsValid()) {
		m_checkBoxAppendLF->SetValue(options->GetHighlightCaretLine());
		m_checkBoxAppendLFEnable->SetValue(false);
	}
	if (options->HideChangeMarkerMarginIsValid()) {
		m_checkBoxHideChangeMarkerMargin->SetValue( options->GetHideChangeMarkerMargin() );
		m_checkBoxHideChangeMarkerMarginEnable->SetValue(false);
	}
	if (options->DisplayFoldMarginIsValid()) {
		m_checkBoxDisplayFoldMargin->SetValue( options->GetDisplayFoldMargin() );
		m_checkBoxDisplayFoldMarginEnable->SetValue(false);
	}
	if (options->DisplayBookmarkMarginIsValid()) {
		m_displayBookmarkMargin->SetValue( options->GetDisplayBookmarkMargin() );
		m_displayBookmarkMarginEnable->SetValue(false);
	}

	if (options->ShowWhitespacesIsValid()) {
		switch (options->GetShowWhitespaces()) {
		case wxSTC_WS_VISIBLEALWAYS:
			m_WSstringManager.SetStringSelection(wxT("Visible always"));
			break;
		case wxSTC_WS_VISIBLEAFTERINDENT:
			m_WSstringManager.SetStringSelection(wxT("Visible after indentation"));
			break;
		default:
			m_WSstringManager.SetStringSelection(wxT("Invisible"));
			break;
		}
		m_whitespaceStyleEnable->SetValue(false);
	}

	if (options->EolModeIsValid()) {
		m_EOLstringManager.SetStringSelection( options->GetEolMode() );
		m_choiceEOLEnable->SetValue(false);
	}

	if (options->FileFontEncodingIsValid()) {
		wxArrayString entries = m_fileEncoding->GetStrings();
		for (size_t n = 0; n < entries.GetCount(); ++n) {
			if ( entries.Item(n) == wxFontMapper::GetEncodingName(options->GetFileFontEncoding()) ) {
				m_fileEncoding->SetSelection(n);
				break;
			}
		}
		m_fileEncodingEnable->SetValue(false);
	}
}