示例#1
0
void SettingsManager::save(string const& aFileName) {

	SimpleXML xml;
	xml.addTag("DCPlusPlus");
	xml.stepIn();
	xml.addTag("Settings");
	xml.stepIn();

	int i;
	string type("type"), curType("string");
	
	for(i=STR_FIRST; i<STR_LAST; i++)
	{
		if (i == INCOMING_CONNECTIONS) continue;
		if(i == CONFIG_VERSION) {
			xml.addTag(settingTags[i], m_version);
			xml.addChildAttrib(type, curType);
		} else if(isSet[i]) {
			xml.addTag(settingTags[i], get(StrSetting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}

	curType = "int";
	for(i=INT_FIRST; i<INT_LAST; i++)
	{
		if(isSet[i]) {
			xml.addTag(settingTags[i], get(IntSetting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}
	curType = "int64";
	for(i=INT64_FIRST; i<INT64_LAST; i++)
	{
		if(isSet[i])
		{
			xml.addTag(settingTags[i], get(Int64Setting(i), false));
			xml.addChildAttrib(type, curType);
		}
	}
	xml.stepOut();
	
	fire(SettingsManagerListener::Save(), xml);

	try {
		File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		BufferedOutputStream<false> f(&out);
		f.write(SimpleXML::utf8Header);
		xml.toXML(&f);
		f.flush();
		out.close();
		File::deleteFile(aFileName);
		File::renameFile(aFileName + ".tmp", aFileName);
	} catch(const FileException&) {
		// ...
	}
}
示例#2
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());

}
LRESULT PropPageTextStyles::onExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	tstring x = _T("");	
	if(WinUtil::browseFile(x, m_hWnd, true, x, types, defExt) == IDOK) {
		SimpleXML xml;
		xml.addTag("DCPlusPlus");
		xml.stepIn();
		xml.addTag("Settings");
		xml.stepIn();

		string type("type"), curType("string");
		exportData("Font", TEXT_FONT);

		curType = "int";
		exportData("BackgroundColor", BACKGROUND_COLOR);
		exportData("TextColor", TEXT_COLOR);
		exportData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
		exportData("UploadBarColor", UPLOAD_BAR_COLOR);
		exportData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
		exportData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
		exportData("TextGeneralBold", TEXT_GENERAL_BOLD);
		exportData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
		exportData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
		exportData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
		exportData("TextMyOwnBold", TEXT_MYOWN_BOLD);
		exportData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
		exportData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
		exportData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
		exportData("TextPrivateBold", TEXT_PRIVATE_BOLD);
		exportData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
		exportData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
		exportData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
		exportData("TextSystemBold", TEXT_SYSTEM_BOLD);
		exportData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
		exportData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
		exportData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
		exportData("TextServerBold", TEXT_SERVER_BOLD);
		exportData("TextServerItalic", TEXT_SERVER_ITALIC);
		exportData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
		exportData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
		exportData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
		exportData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
		exportData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
		exportData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
		exportData("TextMyNickBold", TEXT_MYNICK_BOLD);
		exportData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
		exportData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
		exportData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
		exportData("TextFavBold", TEXT_FAV_BOLD);
		exportData("TextFavItalic", TEXT_FAV_ITALIC);
		exportData("TextURLBackColor", TEXT_URL_BACK_COLOR);
		exportData("TextURLForeColor", TEXT_URL_FORE_COLOR);
		exportData("TextURLBold", TEXT_URL_BOLD);
		exportData("TextURLItalic", TEXT_URL_ITALIC);
		exportData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
		exportData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
		exportData("ErrorColor", ERROR_COLOR);
		exportData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
		exportData("MenubarTwoColors", MENUBAR_TWO_COLORS);
		exportData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
		exportData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
		exportData("MenubarBumped", MENUBAR_BUMPED);
		exportData("Progress3DDepth", PROGRESS_3DDEPTH);
		exportData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
		exportData("TextOPBackColor", TEXT_OP_BACK_COLOR);
		exportData("TextOPForeColor", TEXT_OP_FORE_COLOR);
		exportData("TextOPBold", TEXT_OP_BOLD);
		exportData("TextOPItalic", TEXT_OP_ITALIC);
		exportData("TextNormBackColor", TEXT_NORM_BACK_COLOR);
		exportData("TextNormForeColor", TEXT_NORM_FORE_COLOR);
		exportData("TextNormBold", TEXT_NORM_BOLD);
		exportData("TextNormItalic", TEXT_NORM_ITALIC);
		exportData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
		exportData("ProgressBackColor", PROGRESS_BACK_COLOR);
		exportData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
		exportData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
		exportData("ColorDone", COLOR_DONE);
		exportData("ColorDownloaded", COLOR_DOWNLOADED);
		exportData("ColorRunning", COLOR_RUNNING);
		exportData("ReservedSlotColor", RESERVED_SLOT_COLOR);
		exportData("IgnoredColor", IGNORED_COLOR);
		exportData("FavoriteColor", FAVORITE_COLOR);
		exportData("NormalColour", NORMAL_COLOUR);
		exportData("PasiveColor", PASIVE_COLOR);
		exportData("OpColor", OP_COLOR);
		exportData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
		exportData("UnderlineLinks", UNDERLINE_LINKS);
		exportData("UnderlineDupes", UNDERLINE_DUPES);
		exportData("TextDupeBackColor", TEXT_DUPE_BACK_COLOR);
		exportData("TextDupeColor", DUPE_COLOR);
		exportData("TextDupeBold", TEXT_DUPE_BOLD);
		exportData("TextDupeItalic", TEXT_DUPE_ITALIC);
		exportData("TextQueueBackColor", TEXT_QUEUE_BACK_COLOR);
		exportData("QueueColor", QUEUE_COLOR);
		exportData("TextQueueBold", TEXT_QUEUE_BOLD);
		exportData("TextQueueItalic", TEXT_QUEUE_ITALIC);
		exportData("UnderlineQueue", UNDERLINE_QUEUE);
		//tabs
		exportData("tabactivebg", TAB_ACTIVE_BG);
		exportData("TabActiveText", TAB_ACTIVE_TEXT);
		exportData("TabActiveBorder", TAB_ACTIVE_BORDER);
		exportData("TabInactiveBg", TAB_INACTIVE_BG);
		exportData("TabInactiveBgDisconnected", TAB_INACTIVE_BG_DISCONNECTED);
		exportData("TabInactiveText", TAB_INACTIVE_TEXT);
		exportData("TabInactiveBorder", TAB_INACTIVE_BORDER);
		exportData("TabInactiveBgNotify", TAB_INACTIVE_BG_NOTIFY);
		exportData("TabDirtyBlend", TAB_DIRTY_BLEND);
		exportData("BlendTabs", BLEND_TABS);
		exportData("TabSize", TAB_SIZE);
	
		xml.stepOut();
		
		if(!HighlightManager::getInstance()->emptyList())
			HighlightManager::getInstance()->save(xml);
		/*
		Don't export icon stuff, user might have absolute path for toolbars. Icon packs can be included by editing the .dctheme example.
		curType = "string";
		string empty = "";
		xml.addTag("Icons");
		xml.stepIn();
		exportData("IconPath", ICON_PATH);
		xml.addTag("ToolbarImage", empty);
		xml.addChildAttrib(curType, curType);
		xml.addTag("ToolbarHot", empty);
		xml.addChildAttrib(type, curType);
		xml.stepOut();
		*/

		try {
			File ff(Text::fromT(x) , File::WRITE, File::CREATE | File::TRUNCATE);
			BufferedOutputStream<false> f(&ff);
			f.write(SimpleXML::utf8Header);
			xml.toXML(&f);
			f.flush();
			ff.close();
		} catch(const FileException&) {
			// ...
		}
	}
	return 0;
}
void SettingsManager::save(string const& aFileName) {

    SimpleXML xml;
    xml.addTag("DCPlusPlus");
    xml.stepIn();
    xml.addTag("Settings");
    xml.stepIn();

    int i;
    string type("type"), curType("string");

    for(i=STR_FIRST; i<STR_LAST; i++)
    {
        if(i == CONFIG_VERSION) {
            xml.addTag(settingTags[i], VERSIONSTRING);
            xml.addChildAttrib(type, curType);
        } else if(isSet[i]) {
            xml.addTag(settingTags[i], get(StrSetting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }

    curType = "int";
    for(i=INT_FIRST; i<INT_LAST; i++)
    {
        if(isSet[i]) {
            xml.addTag(settingTags[i], get(IntSetting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }
    for(i=FLOAT_FIRST; i<FLOAT_LAST; i++)
    {
        if(isSet[i]) {
            xml.addTag(settingTags[i], static_cast<int>(get(FloatSetting(i), false) * 1000.));
            xml.addChildAttrib(type, curType);
        }
    }
    curType = "int64";
    for(i=INT64_FIRST; i<INT64_LAST; i++)
    {
        if(isSet[i])
        {
            xml.addTag(settingTags[i], get(Int64Setting(i), false));
            xml.addChildAttrib(type, curType);
        }
    }
    xml.stepOut();

    xml.addTag("SearchTypes");
    xml.stepIn();
    for(SearchTypesIterC i = searchTypes.begin(); i != searchTypes.end(); ++i) {
        xml.addTag("SearchType", Util::toString(";", i->second));
        xml.addChildAttrib("Id", i->first);
    }
    xml.stepOut();

    fire(SettingsManagerListener::Save(), xml);

    try {
        File out(aFileName + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
        BufferedOutputStream<false> f(&out);
        f.write(SimpleXML::utf8Header);
        xml.toXML(&f);
        f.flush();
        out.close();
        File::deleteFile(aFileName);
        File::renameFile(aFileName + ".tmp", aFileName);
    } catch(const FileException&) {
        // ...
    }
}
示例#5
0
LRESULT PropPageTextStyles::onExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	tstring x = _T("");	
	if(WinUtil::browseFile(x, m_hWnd, true, x, types, defExt) == IDOK) {
	SimpleXML xml;
	xml.addTag("DCPlusPlus");
	xml.stepIn();
	xml.addTag("Settings");
	xml.stepIn();

	string type("type"), curType("string");
	exportData("Font", TEXT_FONT);

	curType = "int";
	exportData("BackgroundColor", BACKGROUND_COLOR);
	exportData("TextColor", TEXT_COLOR);
	exportData("DownloadBarColor", DOWNLOAD_BAR_COLOR);
	exportData("UploadBarColor", UPLOAD_BAR_COLOR);
	exportData("TextGeneralBackColor", TEXT_GENERAL_BACK_COLOR);
	exportData("TextGeneralForeColor", TEXT_GENERAL_FORE_COLOR);
	exportData("TextGeneralBold", TEXT_GENERAL_BOLD);
	exportData("TextGeneralItalic", TEXT_GENERAL_ITALIC);
	exportData("TextMyOwnBackColor", TEXT_MYOWN_BACK_COLOR);
	exportData("TextMyOwnForeColor", TEXT_MYOWN_FORE_COLOR);
	exportData("TextMyOwnBold", TEXT_MYOWN_BOLD);
	exportData("TextMyOwnItalic", TEXT_MYOWN_ITALIC);
	exportData("TextPrivateBackColor", TEXT_PRIVATE_BACK_COLOR);
	exportData("TextPrivateForeColor", TEXT_PRIVATE_FORE_COLOR);
	exportData("TextPrivateBold", TEXT_PRIVATE_BOLD);
	exportData("TextPrivateItalic", TEXT_PRIVATE_ITALIC);
	exportData("TextSystemBackColor", TEXT_SYSTEM_BACK_COLOR);
	exportData("TextSystemForeColor", TEXT_SYSTEM_FORE_COLOR);
	exportData("TextSystemBold", TEXT_SYSTEM_BOLD);
	exportData("TextSystemItalic", TEXT_SYSTEM_ITALIC);
	exportData("TextServerBackColor", TEXT_SERVER_BACK_COLOR);
	exportData("TextServerForeColor", TEXT_SERVER_FORE_COLOR);
	exportData("TextServerBold", TEXT_SERVER_BOLD);
	exportData("TextServerItalic", TEXT_SERVER_ITALIC);
	exportData("TextTimestampBackColor", TEXT_TIMESTAMP_BACK_COLOR);
	exportData("TextTimestampForeColor", TEXT_TIMESTAMP_FORE_COLOR);
	exportData("TextTimestampBold", TEXT_TIMESTAMP_BOLD);
	exportData("TextTimestampItalic", TEXT_TIMESTAMP_ITALIC);
	exportData("TextMyNickBackColor", TEXT_MYNICK_BACK_COLOR);
	exportData("TextMyNickForeColor", TEXT_MYNICK_FORE_COLOR);
	exportData("TextMyNickBold", TEXT_MYNICK_BOLD);
	exportData("TextMyNickItalic", TEXT_MYNICK_ITALIC);
	exportData("TextFavBackColor", TEXT_FAV_BACK_COLOR);
	exportData("TextFavForeColor", TEXT_FAV_FORE_COLOR);
	exportData("TextFavBold", TEXT_FAV_BOLD);
	exportData("TextFavItalic", TEXT_FAV_ITALIC);
	exportData("TextURLBackColor", TEXT_URL_BACK_COLOR);
	exportData("TextURLForeColor", TEXT_URL_FORE_COLOR);
	exportData("TextURLBold", TEXT_URL_BOLD);
	exportData("TextURLItalic", TEXT_URL_ITALIC);
	exportData("BoldAuthorsMess", BOLD_AUTHOR_MESS);
	exportData("ProgressTextDown", PROGRESS_TEXT_COLOR_DOWN);
	exportData("ProgressTextUp", PROGRESS_TEXT_COLOR_UP);
	exportData("ErrorColor", ERROR_COLOR);
	exportData("ProgressOverrideColors", PROGRESS_OVERRIDE_COLORS);
	exportData("MenubarTwoColors", MENUBAR_TWO_COLORS);
	exportData("MenubarLeftColor", MENUBAR_LEFT_COLOR);
	exportData("MenubarRightColor", MENUBAR_RIGHT_COLOR);
	exportData("MenubarBumped", MENUBAR_BUMPED);
	exportData("Progress3DDepth", PROGRESS_3DDEPTH);
	exportData("ProgressOverrideColors2", PROGRESS_OVERRIDE_COLORS2);
	exportData("TextOPBackColor", TEXT_OP_BACK_COLOR);
	exportData("TextOPForeColor", TEXT_OP_FORE_COLOR);
	exportData("TextOPBold", TEXT_OP_BOLD);
	exportData("TextOPItalic", TEXT_OP_ITALIC);
	exportData("SearchAlternateColour", SEARCH_ALTERNATE_COLOUR);
	exportData("ProgressBackColor", PROGRESS_BACK_COLOR);
	exportData("ProgressCompressColor", PROGRESS_COMPRESS_COLOR);
	exportData("ProgressSegmentColor", PROGRESS_SEGMENT_COLOR);
	exportData("ColorDone", COLOR_DONE);
	exportData("ColorDownloaded", COLOR_DOWNLOADED);
	exportData("ColorRunning", COLOR_RUNNING);
	exportData("IgnoredColor", IGNORED_COLOR);
	exportData("FavoriteColor", FAVORITE_COLOR);
	exportData("NormalColour", NORMAL_COLOUR);
	exportData("PasiveColor", PASIVE_COLOR);
	exportData("OpColor", OP_COLOR);
	exportData("ProgressbaroDCStyle", PROGRESSBAR_ODC_STYLE);
	
	try {
		File ff(Text::fromT(x) , File::WRITE, File::CREATE | File::TRUNCATE);
		BufferedOutputStream<false> f(&ff);
		f.write(SimpleXML::utf8Header);
		xml.toXML(&f);
		f.flush();
		ff.close();
	} catch(const FileException&) {
		// ...
	}

	}
	return 0;
}