dbrooks@osf.org (09/20/90)
This is a slightly edited, and motified, version of the routine that xrn uses to set the application icon: /* This file defines "bits", "width" and "height" */ #include "standard.bitmap.file" void xmIconCreate() { Pixmap icon_pixmap = (Pixmap) 0; Arg arg; /* Check if the user defined an icon already */ XtSetArg(arg, XmNiconPixmap, &icon_pixmap); XtGetValues(TopLevel, &arg, 1); /* User didn't, so set it */ if (icon_pixmap == (Pixmap) 0) { XtSetArg(arg, XmNiconPixmap, XCreateBitmapFromData(XtDisplay(TopLevel), XtScreen(TopLevel)->root, bits, width, height)); XtSetValues(TopLevel, &arg, 1); } /* Did the user set the "iconGeometry" resource? */ if (app_resources.iconGeometry != NIL(char)) { int scr, x, y, junk; Arg args[2]; /* Find the appropriate screen and set the geometry */ for(scr = 0; /* yyuucchh */ XtScreen(TopLevel) != ScreenOfDisplay(XtDisplay(TopLevel), scr); scr++); XGeometry(XtDisplay(TopLevel), scr, app_resources.iconGeometry, "", 0, 0, 0, 0, 0, &x, &y, &junk, &junk); XtSetArg(args[0], XmNiconX, x); XtSetArg(args[1], XmNiconY, y); XtSetValues(TopLevel, args, XtNumber(args)); } } -- David Brooks dbrooks@osf.org Systems Engineering, OSF uunet!osf.org!dbrooks Experience Hackvergnuegen!
bob@odi.com (Bob Miner) (09/20/90)
I'm sure this has been discussed here before but I can't seem to find any record of it. Does anyone have a working example of setting the application icon from within the application? -kee In Motif, create a single plane bitmap of the proper size (usually 48x48, but technically one should call XGetIconSizes to determine the sizes which the window manager wants) and then set the XmNiconPixmap resource of your application's shell widget. In my code this looks something like: creating bitmap: Display* display; Drawable rootWin; unsigned int width; unsigned int height; char* iconBits; // the output from 'bitmap' Pixmap iconPixmap; iconPixmap = XCreateBitmapFromData( display, rootWin, iconBits, width, height); creating shell widget: XtSetArg( argList[i], XmNiconPixmap, iconPixmap); i++; appShell = XtAppCreateShell( (String) appName, (String) appClass, applicationShellWidgetClass, display, argList, i); Sorry that this isn't a working example, but I had to cut these code fragments out of a larger C++ program and I don't have time to paste them all together. Bob Miner ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OOOOOOO ~ Bob Miner OOOO OOOO ~ Object Design, Inc. OOOOO OOOOO ~ 1 New England Executive Park OOOOO OOOOO ~ Burlington, MA 01803 USA OOOO OOOO ~ bob@odi.com or uunet!odi!bob OOOOOOO bject Design Inc. ~ voice: (617) 270-9797 FAX: (617) 270-3509 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "From there to here, from here to there, funny things are everywhere." - Dr. Seuss ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
grp@unify.COM (Greg Pasquariello) (09/20/90)
Kee Hinckley writes: >I'm sure this has been discussed here before but I can't seem to find >any record of it. Does anyone have a working example of setting the >application icon from within the application? > > -kee I've got an example of setting the icon window, but not the icon bitmap. If that is what you are interested in, I could post it. -Greg Pasquariello grp@unify.com
grp@unify.COM (Greg Pasquariello) (09/20/90)
Bob Miner writes: > > I'm sure this has been discussed here before but I can't seem to find > any record of it. Does anyone have a working example of setting the > application icon from within the application? > > -kee > >In Motif, create a single plane bitmap of the proper size (usually 48x48, >but technically one should call XGetIconSizes to determine the sizes which >the window manager wants) and then set the XmNiconPixmap resource of your >application's shell widget. > One thing that is not immediately obvious (to me) but which is important, is the second paragraph of section 4.1.2 of the ICCCM. This paragraph indicates that certain properties of the window are examined by the window manager when the window is mapped. This recently bit me, as it means the icon stuff must be set before toplevel window is mapped. Hopefully the motif toolkit will work correctly, but if you use XSetWMHints instead, make sure the window is realized but not yet mapped. -Greg Pasquariello grp@unify.com
jan@ECHO.CANBERRA.EDU.AU (Jan Newmarch) (09/21/90)
> > I'm sure this has been discussed here before but I can't seem to find > any record of it. Does anyone have a working example of setting the > application icon from within the application? I followed the code in Nye & O'Reilly vol 4 X Toolkit Intrinsics Programming Manual p.278 and it worked fine. At least it did on a 32x32 icon. On a 16x16 icon I only got the default icon. This was mwm version 1.0, running on an Apollo using both the Apollo and a 386 for servers. The bits were created using bitmap. #include "ruler.bits" Pixmap icon_pixmap; Widget toplevel; toplevel = XtInitialise(...); icon_pixmap = XCreateBitmapFromData(XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), ruler_bits, ruler_width, ruler_height); XtSetArg(args[0], XmNiconPixmap, icon_pixmap); XtSetValues(toplevel, args, 1); +----------------------+---+ Jan Newmarch, Information Science and Engineering, University of Canberra, PO Box 1, Belconnen, Act 2616 Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999 ACSnet: jan@ise.canberra.edu.au ARPA: jan%ise.canberra.edu.au@uunet.uu.net UUCP: {uunet,ukc}!munnari!ise.canberra.edu.au!jan JANET: jan%au.edu.canberra.ise@EAN-RELAY +--------------------------+