[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

34.0. "Creating Icons Big and Small" by STAR::CYPRYCH () Thu Jan 26 1989 18:09

/*
Due to the number of requests for this,  I am posting this
here.   Below is an example of creating a big and small
icon.  The key is to use XChangeProperty for the small icon.

					- Nancy
*/

/*
icon.c - This is an example of creating a Big Icon Box and
a small Icon Box using dec toolkit.  With XChangeProperty
the small icon box can be set in title bar and icon box (if
"small icon" is selected)
*/

#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#include <decw$include/Xatom.h>
#include <decw$dwtdef.h>
#include <stdio.h>

/* small icon pixmap bits */

#define checker16_width 16
#define checker16_height 16
static char checker16_bits[] = {
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0};

/* big icon pixmap bits */

#define checker32_width 32
#define checker32_height 32
static char checker32_bits[] = {
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0};

int main()
{
   Display *dpy;
   Screen *screen;
   Window root, win;
   unsigned long fg, bg;
   unsigned int depth, screen_number;
   XEvent event;
   XWMHints wmhints;
   dwt$wm_hints dwmhints;
   Atom wmatom;

   dpy = XOpenDisplay(NULL);
   if (dpy == NULL) printf("Dpy is NULL!\n");
   screen_number = XDefaultScreen(dpy);
   screen = XDefaultScreenOfDisplay(dpy);
   root = XDefaultRootWindow(dpy);
   fg = XBlackPixelOfScreen(screen);
   bg = XWhitePixelOfScreen(screen);
   depth = XDefaultDepth(dpy,screen_number);
   win = XCreateSimpleWindow(dpy, root, 200, 200, 400, 400, 1, fg, bg);

/* Set the "icon pixmap" into the large icon */

   wmhints.icon_pixmap = XCreatePixmapFromBitmapData(dpy, root, checker32_bits, 
			checker32_width, checker32_height, fg, bg, depth);
   wmhints.flags = IconPixmapHint;
   XSetWMHints(dpy, win, &wmhints);  

/* Set the title bar name and the icon name */

   XStoreName(dpy, win, "Checkers");
   XSetIconName(dpy, win, "Checkers");

/* Set the "iconify pixmap" into title bar and small icon */

   wmatom = XInternAtom(dpy, "DEC_WM_HINTS", 0);
   if (wmatom != None) {
      dwmhints.dwt$l_hints_value_mask = DWT$C_DECWM_ICONIFY_PIXMAP_MASK;
      dwmhints.dwt$l_hints_iconify_pixmap = XCreatePixmapFromBitmapData(dpy, 
			root, checker16_bits, checker16_width, 
			checker16_height, fg, bg, depth);
      XChangeProperty(dpy, win, wmatom, wmatom, 32, PropModeReplace,
         (unsigned char *) &dwmhints,  dwt$wm_num_dec_wm_hints_elem);
   }
   XMapWindow(dpy, win);
   for (;;) 
      XNextEvent(dpy, &event);
}

T.RTitleUserPersonal
Name
DateLines
34.1The small icon should be 17x17GILROY::karltonWestern Software LabFri Jan 27 1989 21:1652
My recollection is that the small icon should be 17x17 and not 16x16 in size.
Otherwise, they can't be made symmetrical. It could be that the window manager
deals with both.

Also, it is possible to merely set some arguments on the top level widget
and not have to deal with changing properties directly. Here is a fragment
of some code I had lying around. No warranty is expressed or implied. It's
not completely ICCCM compliant in that it doesn't force the icon pixmap to
be of depth 1.

PK

=====================================================================
void
SetIconPixmaps(top, iconifyPixmapXImage, iconPixmapXImage, fg, bg)
    Widget top;
    XImage *iconifyPixmapXImage;        /* should be 17x17 */
    XImage * iconPixmapXImage;          /* should be 32x32 */
    Pixel fg, bg;
{
    Arg args[3];
    GC pgc;
    XGCValues gcv;
    int i = 0;

    gcv.foreground = fg;
    gcv.background = bg;
    pgc = XCreateGC(XtDisplay(top), RootWindow(XtDisplay(top), 0),
            GCForeground | GCBackground, &gcv);

    if (iconifyPixmapXImage)
    {
        XtSetArg(
            args[i],
            XtNiconifyPixmap,
            XPixmapFromXImage(XtDisplay(top), iconifyPixmapXImage, pgc));
        i++;
    }
    if (iconPixmapXImage)
    {
        XtSetArg(
            args[i],
            XtNiconPixmap,
            XPixmapFromXImage (XtDisplay(top), iconPixmapXImage, pgc));
        i++;
    }
    if (i)
        XtSetValues (top, args, i);

    XFreeGC( XtDisplay(top), pgc);
}

34.2window managerSTAR::CYPRYCHMon Jan 30 1989 10:056
    Window manager displays 16x16 fine - it is an example
    after all.  If you wish your small icon to be the same
    size as say, VUE,  then better to use 17x17.
    
    

34.3icon is smaller and less function tooCIMNET::MANGANOWed Feb 01 1989 15:2618
    I noticed that .1 said that the iconpixmap should be 32X32.  This
    and the fact that I havent been able change *only* the iconpixmap
    when the window manager is using 16X16 pixmaps tells me that its
    either a bug or 16X16 iconpixmap *only* changes are not provided
    for.
    
    Everything works as I would expect with the window manager set to
    large icons.  I can change the iconpixmap, iconifypixmap, or bothe.
    With small window manager icons, I can change the iconpixmap only
    when I change the iconifypixmap as well.  Actually doing an XtSetValues
    with XtNiconifyPixmap with change bothe for you, which renders the
    XtNiconPixmap resource useless.
    
    Anyone care to comment on this ?
    
    Thanks,
    Steve

34.4One guess on what is happeningGILROY::karltonWestern Software LabWed Feb 01 1989 19:1218
I have not seen the code (the ultimate documentation) or the spec on the
exact behavior, but I believe that this is what is happening.

The window manager picks up the "iconify" and "icon" pixmaps from the
client. It then copies those into a pixmap of the appropriate depth for
being displayed. It always makes a 17x17 and a 32x32 pixmaps as the
destination of the copies.

The window manager allows the user to specify whether the 17x17 (iconify)
pixmap or the 32x32 (icon) pixmap gets used in the icon box.

In any event you only have one small pixmap. You can't have a different
one in the corner of your application and in the icon box.

PK



34.5let's try againCIMNET::MANGANOThu Feb 02 1989 10:0322
   
    When the window manager icon style is set to large (32X32) I am
    able to have a different pattern in the iconify icon than in the
    iconbox icon and viceversa.  When i dont specify one explicitly,
    I get the default.
    
    I would like to have the analygous situation exist when the window
    manager icon style is set to small icons.  
    
    I would have to have to find out why the window manager is not 
    allowing this to exist.  Total of 104 files, 1154 blocks  of
    very compact and sparsly documneted code.  I would prefer if
    someone who definitively knows what the state of afairs is to
    say:
    		1) yea it's a bug
    		2) this function will not be provided for 
    
    bothe answers would be equally satisfactory to me.
    
    thanks for the help,
    Steve

34.6expected behaviorSTAR::CYPRYCHThu Feb 02 1989 15:1413
    Window Manager is using the same pixmap for
    both the small icon and the iconify icon - its
    intentional.  The thinking being that the icon "picture"
    means something basic, i.e., the application.   Therefore,
    the iconified icon "picture" is always the same as the icon box
    icon (whatever size) because they are supposed to be the
    same thing.   
    
    I suppose if you have some reasons why you must make
    the iconified icon different than the icon box icon,
    you may consider a QAR on the matter - with your
    explanation.

34.7If you want change and don't mind change on your window too...IAGO::SCHOELLERWho&#039;s on first?Thu Mar 09 1989 12:257
Or, if what you want is a changing icon in the icon box, it may not matter that
the iconify button on the window changes also.  In that case just change
the iconify pixmap and the icon pixmap to signify these state changes.  See
DECW$MAIL (dxmail for ultrix types) for an example of how this looks.

Dick

34.8MU::PORTERwhat&#039;s in a name?Thu Mar 09 1989 13:5014
Actually, it seems like a bug to me that I have to specify *two* icons
if I want to set my icon!   Let's assume that I care nothing about
iconify buttons, all I want to do is to set my icon picture.  I have
to realise that "sometimes" the DEC window manager will display
my icon, and sometimes it'll display something entirely
different -- namely an "iconify" button.

Yes, I realise that the icon_pixmap is only a hint.  I just wish that
the window manager sometimes took hints a little better.   

Perhaps it'd be nice if it would take a 17x17 (not 16x16 as popularly
believed) icon and double it up (ok, and discard the 17th row/column)
for the large case.

34.9ImpressionismIAGO::SCHOELLERWho&#039;s on first?Tue Mar 14 1989 14:1920
Remember that the capabilities of window managers vary all over the map.
Not only that but you may run into a situation where your application is
running on a server w/o a window manager.  Some window managers don't even
use icon_pixmap.  They require the client to create an icon window
into which it draws the desired icon picture.  These can be of any size.
Take a look at Xchess.  It doesn't use icon_pixmap it uses only icon_window.
X provides a situation in which the window manager can be almost brain dead
and the applications can get something out of it.  The applications need just
be aware of the relatively small set of possibilities.

This brings up an interesting possiblity, how about a library routine
to handle icon/iconify pixmaps/windows.  That way each application could avoid
the unpleasantness of duplicating the code to do each of these possibilities.

As to scaling the 17x17 up, a 32x32 pixmap usually gives you a far more
readable pixmap than the 17x17.  If you scaled up the 17x17 to 32x32 you would
just get something impressionistic  8^{).

Dick

34.10MU::PORTERwaiting for BaudotTue Mar 14 1989 17:4613
Yeah, I understand about Window Managers in general, and how they're
whimsical little entities that can do what they wish.   It's just that
I want to make my applications look as good as possible under the
DECwindows Window Manager in particular.  Thus, when I write, I include
code to set the icon pixmap and meddle with the iconify button.  It
doesn't matter to me that some WMs will ignore that stuff; it does irk
me that I have to know rather more about DEC_WM_HINTS than I think
I am entitled to know (since it's not documented).

I'm programming at the raw Xlib level, of course... I think things
are better at the widget level, but I like to learn things from the
bottom up!