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

📄 test9.c

📁 安装DDD之前
💻 C
字号:
/*From:        Joey Mukherjee <studjoey@bigfoot.com>To:          lesstif@hungry.comSubject:     Drawnbutton problems....Date:        Thu, 03 Dec 1998 13:39:56 -0600Ok, I know I've whined about drawn buttons before, but this time I havea simple way of making it fail.If you change test5 in test/Xm/drawnbutton by adding the following threelines at line 114:	XmString btn_text;        btn_text = XmStringCreateSimple ("Drawn Button");        XtSetArg(al[ac], XmNlabelString, btn_text); ac++;        XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++;You'll see the text does not show up; however, under the real Motif itdoes.For some reason under the real Motif you must also set XmNalignmentin the resize/expose widget or else you will get the pixmap on top ofthe text.  What I do is do a :    XtVaSetValues (w,        XmNalignment, XmALIGNMENT_END,        NULL);in my resize/expose widget.  After that, the pixmap is to the far leftand the text is to the right.  On LessTif, this will create the"nervous" drawn button where it will continually resize/expose itself. Adding that line to line 58 of test5.c shows the problem.  I've attached my test case to this message.  If you reply, I'd reallyappreciate a carbon copy of the email.  I'm not subscribed to the listanymore since I'm leaving for a while, but would love to know when/ifthis is resolved.Cheers!Joey (joey@swri.org)*//*** Generated by X-Designer *//***LIBS: -lXm -lXt -lX11*/#include <X11/Xatom.h>#include <X11/Intrinsic.h>#include <X11/Shell.h>#include <Xm/Xm.h>#include <Xm/DialogS.h>#include <Xm/DrawnB.h>#include <stdio.h>extern void button_resize ();extern void button_expose ();extern Boolean aardvarkConverter ();extern Boolean objStringConverter ();Widget appshell = (Widget) NULL;Widget drawnbutton = (Widget) NULL;void create_gc();GC gc=0;#define LINE_WIDTH 10void button_expose(w, client_data, call_data)	Widget          w;	XtPointer       client_data;	XtPointer       call_data;{	Dimension       width, height, shadow, highlight;	int             origin;	unsigned int    arc_width, arc_height;	/* Call a routine to create a Graphics Context */	create_gc(w);	/* First get the various dimensions */	XtVaGetValues(w,		      XmNwidth, &width,		      XmNheight, &height,		      XmNshadowThickness, &shadow,		      XmNhighlightThickness, &highlight, NULL);	origin = shadow + highlight + 1 + (LINE_WIDTH / 2);	/* Don't draw 0 or negatively sized circles. */	if (width < origin * 2	    || height < origin * 2)		return;	/* Calculate arc sizes */	arc_width = width - origin * 2;	arc_height = height - origin * 2;	/* Draw the Arc */	XDrawArc(XtDisplay(w), XtWindow(w), gc, origin, origin, arc_width,		 arc_height, 0, 360 * 64);    XtVaSetValues (w,        XmNalignment, XmALIGNMENT_END,        NULL);}void button_resize(w, client_data, call_data)	Widget          w;	XtPointer       client_data;	XtPointer       call_data;{	XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, True);}voidcreate_gc(w)	Widget          w;{	XGCValues       values;	XColor          screen_def, exact_def;	Display        *display = XtDisplay(w);	Colormap        cmap = XDefaultColormapOfScreen(XtScreen(w));	int             mask = 0;	if (gc != 0)		return;	/* Allocate read-only colour cell for colour `red' */	if (XAllocNamedColor(display, cmap, "red", &screen_def, &exact_def)	    != 0) {		/*		 * Put the pixel value for red into the GC, ready for drawing		 * operations		 */		values.foreground = screen_def.pixel;		mask = GCForeground;	}	values.line_width=LINE_WIDTH;	mask|=GCLineWidth;	gc = XCreateGC(display, XtWindow(w), mask, &values);}void create_appshell (display, app_name, app_argc, app_argv)Display *display;char *app_name;int app_argc;char **app_argv;{	Arg al[64];                    /* Arg List */	register int ac = 0;           /* Arg Count */        XmString btn_text;	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;	XtSetArg(al[ac], XmNtitle, "Drawn Button"); ac++;	XtSetArg(al[ac], XmNargc, app_argc); ac++;	XtSetArg(al[ac], XmNargv, app_argv); ac++;	appshell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac );	ac = 0;	XtSetArg(al[ac], XmNwidth, 200); ac++;	XtSetArg(al[ac], XmNheight, 200); ac++;        btn_text = XmStringCreateSimple ("Drawn Button");	XtSetArg(al[ac], XmNlabelString, btn_text); ac++;        XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++;	drawnbutton = XmCreateDrawnButton ( appshell, "drawnbutton", al, ac );	ac = 0;	XtAddCallback (drawnbutton, XmNresizeCallback, button_resize,NULL);	XtAddCallback (drawnbutton, XmNexposeCallback, button_expose,NULL);	XtManageChild ( drawnbutton);}XtAppContext app_context;Display *display;       /*  Display             */int main (argc,argv)int    argc;char            **argv;{	XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL );	XtToolkitInitialize ();	app_context = XtCreateApplicationContext ();	display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication",	                         NULL, 0, &argc, argv);	if (!display)	{	    printf("%s: can't open display, exiting...\n", argv[0]);	    exit (-1);	}	create_appshell ( display, argv[0], argc, argv );	XtRealizeWidget (appshell);	LessTifTestWaitForIt(appshell);/* Note: the following values are the result of * querying the current geometry. */{static XtWidgetGeometry Expected[] = {   CWWidth | CWHeight            ,    0,    0,  200,  200, 0,0,0, /* Button1 */};/* toplevel should be replaced with to correct applicationShell */PrintDetails(appshell, Expected);}LessTifTestMainLoop(appshell);	exit (0);}

⌨️ 快捷键说明

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