Subject: FVWM: FvwmButtons background pixmap patch.

From: Patrice Fortier <[email-masked]>
Date: Tue, 17 Dec 1996 12:55:00 +0100 (MET)

A month ago I posted a (really) dirty patch to put a background
pixmap on FvwmButtons. Now that I've read the sources :), here is a
much cleaner one.

You just have to put the FvwmButtonsIconBack option:

*FvwmButtonsIconBack <pixmap>

If anybody has a better name for this option... :)

Note that the BackIcon(...) option for buttons or containers doesn't
work anymore (they don't work in jarl's version either).

You can also get this patch here:
http://www.emi.u-bordeaux.fr/~fortier/Fvwm/

Lokh.

----------------------------Cut here---------------------------------
*** FvwmButtons.h.orig	Mon Dec 16 22:45:51 1996
--- FvwmButtons.h	Sun Nov 10 17:50:50 1996
***************
*** 53,58 ****
--- 53,59 ----
  #define b_Justify   0x0800 /* Has justification info */
  #define b_Size      0x1000 /* Has a minimum size, don't guess */
  #define b_IconBack  0x2000 /* Has an icon as background */
+ #define b_IconParent 0x4000 /* Parent button has an icon as background */
  
  /* Flags for b->swallow */
  #define b_Count       0x03 /* Init counter for swallowing */
***************
*** 93,99 ****
    signed char framew;             /* b_Frame */
    XFontStruct *font;       /* b_Font */
    char *font_string;       /* b_Font */
!   char *back;              /* b_Back */
    char *fore;              /* b_Fore */
    Pixel fc;                /* b_Fore */
    Pixel bc,hc,sc;          /* b_Back && !b_IconBack */
--- 94,101 ----
    signed char framew;             /* b_Frame */
    XFontStruct *font;       /* b_Font */
    char *font_string;       /* b_Font */
!   char *back;              /* b_Back && !b_IconBack */
!   char *back_file;         /* b_Back && b_IconBack */
    char *fore;              /* b_Fore */
    Pixel fc;                /* b_Fore */
    Pixel bc,hc,sc;          /* b_Back && !b_IconBack */
*** FvwmButtons.c.orig	Mon Dec 16 22:45:43 1996
--- FvwmButtons.c	Sun Nov 10 18:49:32 1996
***************
*** 230,241 ****
      {
        if(b->flags&b_Icon)
  	DestroyPicture(Dpy,b->icon);
- /*
        if(b->flags&b_IconBack)
  	DestroyPicture(Dpy,b->backicon);
        if(b->flags&b_Container && b->c->flags&b_IconBack)
  	DestroyPicture(Dpy,b->c->backicon);
- */
      }
  
    exit(0);
--- 230,239 ----
***************
*** 817,826 ****
  	{
  	  if(b->c->flags&b_IconBack)
  	    {
! 	      if(!LoadIconFile(b->c->back,&b->c->backicon))
  		b->c->flags&=~b_Back;
  	    }
! 	  else
  	    {
  	      b->c->bc=GetColor(b->c->back);
  	      b->c->hc=GetHilite(b->c->bc);
--- 815,824 ----
  	{
  	  if(b->c->flags&b_IconBack)
  	    {
! 	      if(!LoadIconFile(b->c->back_file,&b->c->backicon))
  		b->c->flags&=~b_Back;
  	    }
! 
  	    {
  	      b->c->bc=GetColor(b->c->back);
  	      b->c->hc=GetHilite(b->c->bc);
***************
*** 1070,1075 ****
--- 1068,1076 ----
    MyWindow = XCreateSimpleWindow(Dpy,Root,mysizehints.x,mysizehints.y,
  				 mysizehints.width,mysizehints.height,
  				 1,fore_pix,back_pix);
+   if(ub->c->flags&b_IconBack)
+     XSetWindowBackgroundPixmap(Dpy,MyWindow,ub->c->backicon->picture);
+ 
  # ifdef DEBUG_INIT
    fprintf(stderr,"properties...");
  # endif
*** button.c.orig	Mon Dec 16 22:44:59 1996
--- button.c	Sun Dec 15 13:01:36 1996
***************
*** 354,360 ****
    b->c->xpos=0;
    b->c->ypos=0;
    if(b->parent != NULL)
!     b->c->flags=0;
    else /* This applies to the UberButton */
      {
        b->c->flags=b_Font|b_Padding|b_Frame|b_Back|b_Fore;
--- 354,365 ----
    b->c->xpos=0;
    b->c->ypos=0;
    if(b->parent != NULL)
!     {
!       if (b->parent->c->flags&b_IconBack || b->parent->c->flags&b_IconParent)
! 	b->c->flags=b_IconParent;
!       else
! 	b->c->flags=0;
!     }
    else /* This applies to the UberButton */
      {
        b->c->flags=b_Font|b_Padding|b_Frame|b_Back|b_Fore;
*** draw.c.orig	Mon Dec 16 22:44:35 1996
--- draw.c	Sun Dec 15 12:56:45 1996
***************
*** 119,124 ****
--- 119,128 ----
    if(!(b->flags&b_Icon) && (buttonSwallowCount(b)<3))
      return;
  
+   /* Check if parent container has an icon as background */
+   if (b->parent->c->flags&b_IconBack || b->parent->c->flags&b_IconParent)
+     b->flags|=b_IconParent;
+ 
    font = buttonFont(b);
  
    GetInternalSize(b,&ix,&iy,&iw,&ih);
***************
*** 230,236 ****
  	  if(h1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w,h1);
  	  if(h2)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1+h-h2,w,h2);
  	}
!       else 
  	XFillRectangle(Dpy,MyWindow,NormalGC,x+f,y+f,BW-2*f,BH-2*f);
      }
  
--- 234,240 ----
  	  if(h1)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1,w,h1);
  	  if(h2)XFillRectangle(Dpy,MyWindow,NormalGC,x1,y1+h-h2,w,h2);
  	}
!       else if(!(b->flags&b_IconBack) && !(b->flags&b_IconParent))
  	XFillRectangle(Dpy,MyWindow,NormalGC,x+f,y+f,BW-2*f,BH-2*f);
      }
  
*** parse.c.orig	Mon Dec 16 22:43:26 1996
--- parse.c	Sun Dec 15 12:49:19 1996
***************
*** 695,701 ****
  {
    button_info *ub=*ubb;
    char *opts[]={"geometry","font","padding","columns","rows","back","fore",
! 		  "frame","file",NULL};
    int i,j,k;
  
    switch(MatchSeveralLines(s,opts,&s))
--- 695,701 ----
  {
    button_info *ub=*ubb;
    char *opts[]={"geometry","font","padding","columns","rows","back","fore",
! 		  "frame","file","iconback",NULL};
    int i,j,k;
  
    switch(MatchSeveralLines(s,opts,&s))
***************
*** 747,752 ****
--- 747,756 ----
      case 8:/* File */
        trimleft(s);
        config_file=seekright(&s);
+       break;
+     case 9:/* IconBack */
+       CopyString(&(ub->c->back_file),s);
+       ub->c->flags|=b_IconBack;
        break;
      default:
        trimleft(s);
----------------------------Cut here---------------------------------
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].