⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resource.cc

📁 蒙特卡洛仿真源代码很有参考价值要按照步骤进行操作
💻 CC
📖 第 1 页 / 共 3 页
字号:
//  resource.cc for bbsmount - an tool for mounting in X11////  Copyright (c) 2001 by Miroslav Jezbera, jezberam@upcase.inf.upol.cz////  This program is free software; you can redistribute it and/or modify//  it under the terms of the GNU General Public License as published by//  the Free Software Foundation; either version 2 of the License, or//  (at your option) any later version.////  This program is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU General Public License for more details.////  You should have received a copy of the GNU General Public License//  along with this program; if not, write to the Free Software//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//// (See the included file COPYING / GPL-2.0)//#if HAVE_CONFIG_H#   include "config.h"#endif /* HAVE_CONFIG_H */#ifdef    HAVE_STDARG_H#  include <stdarg.h>#endif // HAVE_STDARG_H#include <ctype.h>#include <string.h>#if HAVE_LOCALE_H#   include <locale.h>#endif /* HAVE_LOCALE_H */#include <algorithm>using namespace std;#include "resource.hh"#include "bbsmount.hh"#include "blackboxstyle.hh"#include "i18n.hh"/* Hack */#if !HAVE_STRCASESTR#   define strcasestr	strstr#endif /* !HAVE_STRCASESTR */#ifndef   FONT_ELEMENT_SIZE#define   FONT_ELEMENT_SIZE 50#endif // FONT_ELEMENT_SIZEconst int modifiers_count = 8;const unsigned int max_button_number = 5;const char *modifiers[modifiers_count] = {    "Shift",    "Lock",    "Control",    "Mod1",    "Mod2",    "Mod3",    "Mod4",    "Mod5"};const int modifiers_mask[modifiers_count] = {    ShiftMask,    LockMask,    ControlMask,    Mod1Mask,    Mod2Mask,    Mod3Mask,    Mod4Mask,    Mod5Mask};Resource::Resource(ToolWindow *toolwindow):   BaseResource(toolwindow){    mounts_count = 0;    mounts = NULL;    tooltip.font = NULL;    tooltip.fontset = NULL;    tooltip.fontset_extents = NULL;    Load();}Resource::~Resource(){    Clean();}void Resource::Clean(){    CleanMounts();    if (tooltip.font) {	XFreeFont(bbtool->getXDisplay(), tooltip.font);	tooltip.font = NULL;    }    if (tooltip.fontset) {	XFreeFontSet(bbtool->getXDisplay(), tooltip.fontset);	tooltip.fontset = NULL;    }}void Resource::CleanMounts(void) {    for (; mounts_count > 0; mounts_count--) {	free(mounts[mounts_count - 1].mount_point);	XpmFreeXpmImage(&mounts[mounts_count - 1].mounted);	XpmFreeXpmImage(&mounts[mounts_count - 1].not_mounted);    }    if (mounts) {	free(mounts);	mounts = NULL;    }}void Resource::LoadBBToolResource(void){/*    XrmValue value;    char *value_type;    if (XrmGetResource(resource_db, "bbsmount.autoConfig",		"Bbsmount.Autoconfig", &value_type, &value))	if (! strncasecmp("true", value.addr, value.size))	    style.auto_config = True;	else	    style.auto_config = False;    else	style.auto_config = False;*/    SizeAndPosition();	    Frame();    App();    ImagePrefix();    Tooltip();	    // bbsmount specific options    MountPoints();}void Resource::Frame(){    XrmValue value;    char *value_type;    readTexture("bbsmount.frame", "Bbsmount.Frame", BB_FRAME, "Toolbar", "slategrey", "darkslategrey",	    "Raised Gradient Vertical Bevel1", &frame.texture);	    if (XrmGetResource(resource_db, "bbsmount.bevelWidth","Bbsmount.BevelWidth", &value_type, &value)) {	if (sscanf(value.addr, "%u", &frame.bevelWidth) != 1)	    frame.bevelWidth = 4;	else	    if (frame.bevelWidth == 0)		frame.bevelWidth = 4;    }    else	if (XrmGetResource(resource_db, BB_BEVELWIDTH,"BevelWidth", &value_type, &value)) {	    if (sscanf(value.addr, "%u", &frame.bevelWidth) != 1)		frame.bevelWidth = 4;	    else		if (frame.bevelWidth == 0)		    frame.bevelWidth = 4;	}	else	    frame.bevelWidth = 4;}void Resource::SizeAndPosition(){	XrmValue value;	char *value_type;	unsigned int w,h;	char positionstring[11];  if (!(bbtool->withdrawn))  {  	if (XrmGetResource(resource_db, "bbsmount.withdrawn",		     "Bbsmount.Withdrawn", &value_type, &value))    {  		if (! strncasecmp("true", value.addr, value.size))	  		bbtool->withdrawn = True;	    else		  	bbtool->withdrawn = False;  	}		  else		  bbtool->withdrawn = False;  }  if (!(bbtool->shape))  {  	if (XrmGetResource(resource_db, "bbsmount.shape",		     "Bbsmount.Shape", &value_type, &value))    {  		if (! strncasecmp("true", value.addr, value.size))	  		bbtool->shape = True;	    else		  	bbtool->shape = False;  	}		  else		  bbtool->shape = bbtool->withdrawn;  }  	if (!(bbtool->position))	{		if (!(XrmGetResource(resource_db, "bbsmount.position","Bbsmount.Position",							&value_type, &value)))			strncpy(positionstring, "-0-0", 5);		else			strncpy(positionstring, value.addr, strlen(value.addr)+1);	}	else		strncpy(positionstring, bbtool->position, strlen(bbtool->position)+1);	position.mask=XParseGeometry(positionstring, &position.x, &position.y, &w, &h);	if (!(position.mask & XValue))		position.x=0;	if (!(position.mask & YValue))		position.y=0;	/* need this to compute the height *//*	const char *defaultFont = "-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*";		if (frame.font)	{    	XFreeFont(bbtool->dpy, frame.font);		frame.font = 0;	}		if (XrmGetResource(resource_db, "bbsmount.heightBy.font","Bbsmount.heightBy.Font",						&value_type, &value))	{    	if ((frame.font = XLoadQueryFont(bbtool->dpy, value.addr)) == NULL)		{    		fprintf(stderr, " blackbox: couldn't load font '%s'\n"	      					" ...  reverting to default font.", value.addr);	    	if ((frame.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)			{				fprintf(stderr,"blackbox: couldn't load default font.  please check to\n"								"make sure the necessary font is installed '%s'\n",					defaultFont);				exit(2);			}		}	}	else if (XrmGetResource(resource_db, BB_FONT,"TitleFont", &value_type, &value))	{		if ((frame.font = XLoadQueryFont(bbtool->dpy, value.addr)) == NULL)		{    		fprintf(stderr, " blackbox: couldn't load font '%s'\n"	      					" ...  reverting to default font.", value.addr);			if ((frame.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)			{				fprintf(stderr,					"blackbox: couldn't load default font.  please check to\n"					"make sure the necessary font is installed '%s'\n",					defaultFont);				exit(2);			}		}	}	else 	{    	if ((frame.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)		{			fprintf(stderr,	      			"blackbox: couldn't load default font.  please check to\n"	      			"make sure the necessary font is installed '%s'\n", defaultFont);			exit(2);		}	}*/}	//void Resource::Label(void)//{//	XrmValue value;//	char *value_type;////	/* text-label resources *///	if (XrmGetResource(resource_db, "bbsmount.label.transparent",//		     "Bbsmount.label.Transparent", &value_type, &value))//	{//		if (! strncasecmp("true", value.addr, value.size))//			label.transparent = True;//	    else//			label.transparent = False;//	}	//	else//		label.transparent = False;//	//	readDatabaseTexture("bbsmount.label", "Bbsmount.Label",BB_LABEL,"Toolbar.Label",//                      "slategrey","darkslategrey",//                      BImage_Sunken|BImage_Gradient|BImage_Vertical|//                      BImage_Bevel1,&label.texture);////		readDatabaseColor("bbsmount..textColor",//      								"Bbsmount.TextColor",//                      BB_LABEL_TEXTCOLOR, "Toolbar.TextColor",//                      "LightGrey",&label.textColor);////    //	const char *defaultFont = "-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*";//	//	if (label.font)//	{//		XFreeFont(bbtool->dpy, label.font);//		label.font = 0;//	}//	//	if (XrmGetResource(resource_db, "bbsmount.label.font", "Bbsmount.Label.Font",//						&value_type, &value))//	{//		if ((label.font = XLoadQueryFont(bbtool->dpy, value.addr)) == NULL)//		{//    	fprintf(stderr, " blackbox: couldn't load font '%s'\n"//	      							" ...  reverting to default font.", value.addr);//		    if ((label.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)//			{//				fprintf(stderr,//					"blackbox: couldn't load default font.  please check to\n"//					"make sure the necessary font is installed '%s'\n",//					defaultFont);//			exit(2);//			}//		}//	}//	else if  (XrmGetResource(resource_db, BB_FONT, "TitleFont", &value_type, &value))//	{//		if ((label.font = XLoadQueryFont(bbtool->dpy, value.addr)) == NULL)//		{//			fprintf(stderr, " blackbox: couldn't load font '%s'\n"//	      					" ...  reverting to default font.", value.addr);//			if ((label.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)//			{//				fprintf(stderr,//					"blackbox: couldn't load default font.  please check to\n"//					"make sure the necessary font is installed '%s'\n",//					defaultFont);//				exit(2);//			}//		}//	}//	else//	{//		if ((label.font = XLoadQueryFont(bbtool->dpy, defaultFont)) == NULL)//		{//			fprintf(stderr,"blackbox: couldn't load default font.  please check to\n"//				    "make sure the necessary font is installed '%s'\n", defaultFont);//			exit(2);//		}//	}//}void Resource::App(){    XrmValue value;    char *value_type;    if (XrmGetResource(resource_db, "bbsmount.columns", "Bbsmount.Columns", &value_type, &value)) {	if (sscanf(value.addr, "%u", &app.columns) != 1)	    app.columns = 1;	else	    if (app.columns == 0)		app.columns = 1;    }    else	app.columns = 1;    if (XrmGetResource(resource_db, "bbsmount.rows", "Bbsmount.Rows", &value_type, &value)) {	if (sscanf(value.addr, "%u", &app.rows) != 1)	    app.rows = 1;	else	    if (app.rows == 0)		app.rows = 1;    }    else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -