Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucbvax!isi.com!tsang From: tsang@isi.com (Kam C. Tsang) Newsgroups: comp.windows.x.motif Subject: optimization / speedups Message-ID: <9008162309.AA22763@canopus> Date: 16 Aug 90 23:09:54 GMT References: <9008160310.AA05073@alphalpha.com> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 100 > Secondly, is there anyway for my application to check and see if a > particular resource has been defined, so that it can set the resource > only if the user has not? Let me cheat and answer only the second question, because I have no clue on the first one. The call is XtGetSubresources: -------------------- start of demo program ------------------------------ #include #include #include typedef struct { } ApplicationData, *ApplicationDataPtr; ApplicationData AppData; #define XtNusername "username" #define XtCUsername "Username" #define XtNdebug "debug" #define XtCDebug "Debug" /* In intrinsic.h: typedef struct _XtResource { String resource_name; // Resource name String resource_class; // Resource class String resource_type; // Representation type desired Cardinal resource_size; // Size in bytes of representation Cardinal resource_offset;// Offset from base to put resource value String default_type; // representation type of specified default caddr_t default_addr; // Address of default resource } XtResource; */ static XtResource resources[] = { { XtNusername, XtCUsername, XmRString, sizeof(String), XtOffset(ApplicationDataPtr, username), XmRString, "Number Johnny Five", }, { XtNdebug, XtCDebug, XtRBoolean, sizeof(Boolean), XtOffset(ApplicationDataPtr, debug), XtRImmediate, (caddr_t) FALSE, } }; /* see page 88 */ /*------------------------------------------------------------- ** main - main logic for application */ void main (argc,argv) unsigned int argc; char **argv; { Display *display; /* Display */ Widget app_shell; /* ApplicationShell */ XtToolkitInitialize(); display = XtOpenDisplay (NULL, NULL, argv[0], "XMdemos", NULL, 0, &argc, argv); if (!display) { XtWarning ("xfonts: Can't open display, exiting..."); exit (0); } app_shell = XtAppCreateShell (argv[0], "XMdemos", applicationShellWidgetClass, display, NULL, 0); XtGetSubresources(app_shell, &AppData, "Bboard.Label", "bboard.label", /* extra for XtGetSubresources */ resources, XtNumber(resources), NULL, 0); printf("width: %d\n", AppData.width); printf("height: %d\n", AppData.height); } -------------------- end of demo program ------------------------------ -kam -------------------------------------------------------------- Kam Tsang User Interface Group Tel: (408) 980-1500 x275 Integrated Systems, Inc. Internet: tsang@isi.com 2500 Mission College Blvd. Voice mail: (408) 980-1590 x275 Santa Clara, CA 94054