home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!nems!ark1!uakari.primate.wisc.edu!samsung!cs.utexas.edu!sun-barr!newstop!sun!icky.Sony.COM
- From: dce@icky.Sony.COM (David Elliott)
- Newsgroups: comp.sources.x
- Subject: v07i091: xcmap, Patch1, Part01/01
- Message-ID: <137108@sun.Eng.Sun.COM>
- Date: 12 Jun 90 06:34:32 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 245
- Approved: argv@sun.com
-
- Submitted-by: David Elliott <dce@icky.Sony.COM>
- Posting-number: Volume 7, Issue 91
- Archive-name: xcmap/patch1
- Patch-To: xcmap: Volume XXX, Issue XXX
-
-
- I have tried to contact the author of xcmap with no success. I would
- like to see these patches go out, and I would even gladly take over
- maintenance of the program if the author doesn't want to continue.
-
- This is a set of patches to cause the icon for xcmap to be a 48x48
- view-only copy of the colormap window. I find this to be particularly
- useful since I just need to see the colormap more often than I need to
- query the color cells.
-
- This also adds a -iconic flag, but no icon geometry checking (hmm,
- maybe it should be rewritten as an Xt program...)
-
- *** xcmap.c.orig Tue Nov 7 10:08:18 1989
- --- xcmap.c Mon May 21 11:09:19 1990
- ***************
- *** 29,35 ****
- Display *theDisp;
- int theScreen, dispcells;
- Colormap theCmap;
- ! Window rootW, mainW;
- GC theGC;
- unsigned long fcol,bcol;
- Font mfont;
- --- 29,35 ----
- Display *theDisp;
- int theScreen, dispcells;
- Colormap theCmap;
- ! Window rootW, mainW, iconW;
- GC theGC;
- unsigned long fcol,bcol;
- Font mfont;
- ***************
- *** 41,46 ****
- --- 41,47 ----
- int WIDE,HIGH,cWIDE,cHIGH,nxcells,nycells, pvalup;
- XColor defs[256];
- char *cmd, tmpstr[128];
- + int initState = NormalState;
-
-
-
- ***************
- *** 86,91 ****
- --- 87,98 ----
- continue;
- }
-
- + if (!strncmp(argv[i],"-i",2)) { /* iconic */
- + i++;
- + initState = IconicState;
- + continue;
- + }
- +
- Syntax(cmd);
- }
-
- ***************
- *** 132,141 ****
- --- 139,150 ----
- XSetBackground(theDisp,theGC,bcol);
-
- CreateMainWindow(cmd,geom,argc,argv);
- + CreateIconWindow();
- Resize(WIDE,HIGH);
-
- XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask
- | StructureNotifyMask | ButtonPressMask);
- + XSelectInput(theDisp, iconW, ExposureMask);
- XMapWindow(theDisp,mainW);
-
- /**************** Main loop *****************/
- ***************
- *** 159,165 ****
- --- 168,177 ----
- if (exp_event->window==mainW)
- DrawWindow(exp_event->x,exp_event->y,
- exp_event->width, exp_event->height);
- + if (exp_event->window==iconW)
- + DrawIcon();
- }
- +
- break;
-
- case ButtonPress: {
- ***************
- *** 186,201 ****
- if (conf_event->window == mainW &&
- (conf_event->width != WIDE || conf_event->height != HIGH))
- Resize(conf_event->width, conf_event->height);
- ! }
- break;
- -
- -
- case CirculateNotify:
- case MapNotify:
- case DestroyNotify:
- case GravityNotify:
- case ReparentNotify:
- ! case UnmapNotify: break;
-
- default:
- printf("event type=%ld\n",event->type);
- --- 198,212 ----
- if (conf_event->window == mainW &&
- (conf_event->width != WIDE || conf_event->height != HIGH))
- Resize(conf_event->width, conf_event->height);
- ! }
- break;
- case CirculateNotify:
- case MapNotify:
- case DestroyNotify:
- case GravityNotify:
- case ReparentNotify:
- ! case UnmapNotify:
- ! break;
-
- default:
- printf("event type=%ld\n",event->type);
- ***************
- *** 208,214 ****
- /***********************************/
- Syntax()
- {
- ! printf("Usage: %s filename [=geometry | -geometry geom] [ [-display] display]\n",cmd);
- exit(1);
- }
-
- --- 219,225 ----
- /***********************************/
- Syntax()
- {
- ! printf("Usage: %s filename [-iconic] [=geometry | -geometry geom] [ [-display] display]\n",cmd);
- exit(1);
- }
-
- ***************
- *** 237,242 ****
- --- 248,254 ----
- XSetWindowAttributes xswa;
- unsigned int xswamask;
- XSizeHints hints;
- + XClassHint classHints;
- int i,x,y,w,h;
-
- WIDE = HIGH = 256; /* default window size */
- ***************
- *** 247,253 ****
- --- 259,267 ----
- if (i&HeightValue) HIGH = h;
-
- if (i&XValue || i&YValue) hints.flags = USPosition;
- + #ifdef notdef
- else hints.flags = PPosition;
- + #endif
-
- hints.flags |= USSize;
-
- ***************
- *** 273,283 ****
- mainW = XCreateWindow(theDisp,rootW,x,y,WIDE,HIGH,2,0,CopyFromParent,
- CopyFromParent, xswamask, &xswa);
-
- XSetStandardProperties(theDisp,mainW,"xcmap","xcmap",None,
- argv,argc,&hints);
-
- ! if (!mainW) FatalError("Can't open main window");
-
- }
-
-
- --- 287,302 ----
- mainW = XCreateWindow(theDisp,rootW,x,y,WIDE,HIGH,2,0,CopyFromParent,
- CopyFromParent, xswamask, &xswa);
-
- + if (!mainW) FatalError("Can't open main window");
- +
- XSetStandardProperties(theDisp,mainW,"xcmap","xcmap",None,
- argv,argc,&hints);
-
- ! classHints.res_name = "xcmap";
- ! classHints.res_class = "XCmap";
-
- + XSetClassHint(theDisp, mainW, &classHints);
- +
- }
-
-
- ***************
- *** 378,380 ****
- --- 397,435 ----
- }
- }
-
- + /***********************************/
- +
- + #define IWIDTH 48
- + #define IHEIGHT 48
- + CreateIconWindow()
- + {
- + XWMHints xwmh;
- +
- + iconW = XCreateSimpleWindow(theDisp, rootW, 0, 0, IWIDTH, IHEIGHT, 1,
- + fcol, bcol);
- +
- + xwmh.flags = IconWindowHint | StateHint;
- + xwmh.icon_window = iconW;
- + xwmh.initial_state = initState;
- +
- + XSetWMHints(theDisp, mainW, &xwmh);
- + }
- +
- + /***********************************/
- + DrawIcon()
- + {
- + int i,j,x1,y1,x2,y2;
- + int cwide, chigh;
- +
- + cwide = (IWIDTH + nxcells - 1) / nxcells;
- + chigh = (IHEIGHT + nycells - 1) / nycells;
- + x2 = ((IWIDTH) + cwide - 1) / cwide;
- + y2 = ((IHEIGHT) + chigh - 1) / chigh;
- +
- + for (i=0; i<y2; i++) {
- + for (j=0; j<x2; j++) {
- + XSetForeground(theDisp,theGC,(unsigned long) (i*nycells+j) );
- + XFillRectangle(theDisp,iconW,theGC,j*cwide,i*chigh,cwide,chigh);
- + }
- + }
- + }
-
- ...David Elliott
- ...dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
- ...(408)944-4073
-
-
- dan
- ----------------------------------------------------
- O'Reilly && Associates argv@sun.com / argv@ora.com
- Opinions expressed reflect those of the author only.
-