> > I  have  a   patch  lying  around  here  (for  a   few  months  now)
> > which  adds an  option  to FvwmButtons  for  customizing the  relief
> > (flat/raised/sunken) for both states. Do you suggest i polish it and
> > send it through now, or should i wait
>
> Let us have a look at the patch; then we can decide.

I'm not sure if the patch got to the mailinglist (i've been having some
e-mail problems), but since it's been a month since i posted it and
haven't got any replies on it, i'm reposting it. If it's being reviewed,
please ignore my mail ;)

This patch adds a new 'Relief' option to FvwmButtons. The syntax is
described in the man page.

cheers,
Remko


Index: modules/FvwmButtons/FvwmButtons.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.1,v
retrieving revision 1.61
diff -u -r1.61 FvwmButtons.1
--- modules/FvwmButtons/FvwmButtons.1   9 Nov 2002 15:18:52 -0000       1.61
+++ modules/FvwmButtons/FvwmButtons.1   22 Jul 2003 15:51:11 -0000
@@ -169,6 +169,12 @@
 Specifies a background pixmap to use.  Specify "none" (without the
 double quotes) for a transparent background.
 
+.IP "*FvwmButtons: ReliefStyle \fIstate\fP \fIstyle\fP"
+Specifies which style of relief to draw when the button is in the given
+state. \fIstate\fP can be either \fIUp\fP or \fIDown\fP. \fIstyle\fP 
+is one of \fIClean\fP (draws the background color), \fIRaised\fP or 
+\fISunken\fP.
+
 .IP "*FvwmButtons: Rows \fIrows\fP"
 Specifies the number of rows of buttons to be created. The default
 is 2 rows.
Index: modules/FvwmButtons/FvwmButtons.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.c,v
retrieving revision 1.181
diff -u -r1.181 FvwmButtons.c
--- modules/FvwmButtons/FvwmButtons.c   6 Jul 2003 14:34:07 -0000       1.181
+++ modules/FvwmButtons/FvwmButtons.c   22 Jul 2003 15:51:11 -0000
@@ -783,6 +783,8 @@
 
   UberButton->title   = MyName;
   UberButton->swallow = 1; /* the panel is shown */
+  UberButton->reliefstyle  = (RELIEFSTYLE_RAISED << 4) |
+                            (RELIEFSTYLE_SUNKEN); /* Default relief */
 
   /* parse module options */
   ParseConfiguration(UberButton);
Index: modules/FvwmButtons/FvwmButtons.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/FvwmButtons.h,v
retrieving revision 1.44
diff -u -r1.44 FvwmButtons.h
--- modules/FvwmButtons/FvwmButtons.h   29 Jun 2003 19:53:24 -0000      1.44
+++ modules/FvwmButtons/FvwmButtons.h   22 Jul 2003 15:51:11 -0000
@@ -75,6 +75,7 @@
                     0x02000000 /* By default this only done on Popup */
 #define b_Id         0x04000000 /* Has a user defined id for referencing */
 #define b_IconAlpha  0x08000000 /* Icon has an alpha chanel */
+#define b_ReliefStyle 0x10000000 /* Relief Style */
 
 /* Flags for b->swallow */
 #define b_Count       0x0003 /* Init counter for swallowing */
@@ -125,6 +126,7 @@
   Pixel bc,hc,sc;          /* b_Back && !b_IconBack */
   FvwmPicture *backicon;   /* b_Back && b_IconBack */
   ushort minx,miny;        /* b_Size */
+  byte reliefstyle;        /* b_ReliefStyle */
 };
 
 typedef struct
@@ -155,6 +157,10 @@
   char *back;              /* b_Back */
   char *fore;              /* b_Fore */
   int colorset;            /* b_Colorset */
+#define RELIEFSTYLE_CLEAN  0x0  /* No relief */
+#define RELIEFSTYLE_RAISED 0x1  /* Raised relief */
+#define RELIEFSTYLE_SUNKEN 0x2  /* Sunken relief */
+  byte reliefstyle;        /* b_ReliefStyle */
   byte xpad,ypad;          /* b_Padding */
   signed char framew;      /* b_Frame */
   byte justify;            /* b_Justify */
Index: modules/FvwmButtons/button.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/button.c,v
retrieving revision 1.32
diff -u -r1.32 button.c
--- modules/FvwmButtons/button.c        29 Jun 2003 19:53:24 -0000      1.32
+++ modules/FvwmButtons/button.c        22 Jul 2003 15:51:11 -0000
@@ -310,6 +310,24 @@
   return -1;
 }
 
+byte buttonReliefStyle(button_info *b)
+{
+    button_info *bb = b;
+    if (bb->flags & b_ReliefStyle) 
+        return bb->reliefstyle;
+    else if (bb->flags & b_Container && bb->c->flags & b_ReliefStyle)
+        return bb->reliefstyle;
+    while ((bb = bb->parent))
+    {
+        if (bb->c->flags & b_ReliefStyle)
+            return bb->c->reliefstyle;
+    }
+#ifdef DEBUG
+    fprintf(stderr,"%s: BUG: No relief definition?\n",MyName);
+#endif
+    return (RELIEFSTYLE_RAISED<<4) | RELIEFSTYLE_SUNKEN;
+}
+
 int buttonBackgroundButton(button_info *b, button_info **r_b)
 {
        button_info *tmpb, *pb;
@@ -516,6 +534,7 @@
     b->c->back=safestrdup("rgb:90/80/90");
     b->c->fore=safestrdup("black");
     b->c->framew=2;
+    b->c->reliefstyle= (RELIEFSTYLE_RAISED<<4) | RELIEFSTYLE_SUNKEN;
   }
 
 }
Index: modules/FvwmButtons/button.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/button.h,v
retrieving revision 1.15
diff -u -r1.15 button.h
--- modules/FvwmButtons/button.h        29 Jun 2003 19:53:24 -0000      1.15
+++ modules/FvwmButtons/button.h        22 Jul 2003 15:51:11 -0000
@@ -28,6 +28,7 @@
 Pixel buttonHilite(button_info*);
 Pixel buttonShadow(button_info*);
 int buttonColorset(button_info *b);
+byte buttonReliefStyle(button_info *b);
 int buttonBackgroundButton(button_info *b, button_info **r_b);
 byte buttonSwallow(button_info*);
 byte buttonJustify(button_info*);
Index: modules/FvwmButtons/draw.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/draw.c,v
retrieving revision 1.57
diff -u -r1.57 draw.c
--- modules/FvwmButtons/draw.c  29 Jun 2003 19:53:24 -0000      1.57
+++ modules/FvwmButtons/draw.c  22 Jul 2003 15:51:11 -0000
@@ -62,30 +62,51 @@
 *** RelieveButton()
 *** Draws the relief pattern around a window.
 **/
-void RelieveButton(Window wn,int width,int x,int y,int w,int h,Pixel relief,
-                  Pixel shadow,int rev)
+void RelieveButton(Window wn,int width,int x,int y,int w,int h,Pixel backgr,
+           Pixel relief, Pixel shadow,int buttonstate, byte reliefstyle)
 {
-  XGCValues gcv;
-  GC swapGC, reliefGC, shadowGC;
+  XGCValues reliefGCV,shadowGCV;
+  GC reliefGC, shadowGC, swapGC;
+  byte reliefStyle;
 
   if(!width)
     return;
 
-  gcv.foreground=relief;
-  XChangeGC(Dpy,NormalGC,GCForeground,&gcv);
+  reliefStyle = (buttonstate ? reliefstyle & 0xf          /* Button down */
+                             : (reliefstyle & 0xf0)>>4 ); /* Button up */
+  
+  switch (reliefStyle) {
+      case RELIEFSTYLE_RAISED:
+          reliefGCV.foreground = relief;
+          shadowGCV.foreground = shadow;
+          break;
+      case RELIEFSTYLE_SUNKEN:
+          reliefGCV.foreground = shadow;
+          shadowGCV.foreground = relief;
+          break;
+      case RELIEFSTYLE_CLEAN:
+          reliefGCV.foreground = backgr;
+          shadowGCV.foreground = backgr;
+          break;
+      default:
+          /* Shouldnt happen */
+          #ifdef DEBUG
+          fprintf(stderr,"%s: BUG: Illegal reliefstyle: %x\n",MyName,
+                                                                reliefStyle);
+          #endif
+          reliefGCV.foreground = backgr;
+          shadowGCV.foreground = backgr;
+  }
+
+  XChangeGC(Dpy,NormalGC,GCForeground,&reliefGCV);
   reliefGC=NormalGC;
 
-  gcv.foreground=shadow;
-  XChangeGC(Dpy,ShadowGC,GCForeground,&gcv);
+  XChangeGC(Dpy,ShadowGC,GCForeground,&shadowGCV);
   shadowGC=ShadowGC;
-
+  
   if(width<0)
   {
     width=-width;
-    rev = !rev;
-  }
-  if(rev)
-  {
     swapGC=reliefGC;
     reliefGC=shadowGC;
     shadowGC=swapGC;
@@ -619,7 +640,8 @@
        }
 
        /* relief */
-       RelieveButton(MyWindow,of,x,y,BW,BH,hc,sc,rev ^ rev_xor);
+       RelieveButton(MyWindow,of,x,y,BW,BH,bc,hc,sc,rev ^ rev_xor, 
+                  buttonReliefStyle(b));
 }
 
 /**
Index: modules/FvwmButtons/draw.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/draw.h,v
retrieving revision 1.12
diff -u -r1.12 draw.h
--- modules/FvwmButtons/draw.h  29 Jun 2003 19:53:24 -0000      1.12
+++ modules/FvwmButtons/draw.h  22 Jul 2003 15:51:11 -0000
@@ -19,7 +19,7 @@
 #define DRAW_FORCE       3
 #define DRAW_DESK_RELIEF 4
 
-void RelieveButton(Window,int,int,int,int,int,Pixel,Pixel,int);
+void RelieveButton(Window,int,int,int,int,int,Pixel,Pixel,Pixel,int,byte);
 void MakeButton(button_info*);
 void RedrawButton(button_info*, int draw, XEvent *pev);
 void DrawTitle(
Index: modules/FvwmButtons/output.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/output.c,v
retrieving revision 1.14
diff -u -r1.14 output.c
--- modules/FvwmButtons/output.c        29 Jun 2003 19:53:24 -0000      1.14
+++ modules/FvwmButtons/output.c        22 Jul 2003 15:51:12 -0000
@@ -69,6 +69,8 @@
     fprintf(stderr,"Title(%s) ",b->title);
   if(b->flags&b_Icon)
     fprintf(stderr,"Icon(%s,%i) ",b->icon_file,(int)b->IconWin);
+  if(b->flags&b_ReliefStyle) 
+        fprintf(stderr,"Relief(%x) ",b->reliefstyle); 
   if(b->flags&b_Icon)
     fprintf(stderr,"Panelw(%i) ",(int)b->PanelWin);
   if(b->flags&b_Action)
@@ -131,6 +133,18 @@
     fprintf(stderr,"Frame %i ",b->framew);
   if(b->flags&b_Padding)
     fprintf(stderr,"Padding %i %i ",b->xpad,b->ypad);
+  if(b->flags&b_ReliefStyle) {
+    switch((b->reliefstyle & 0xf0)>>4) {
+        case RELIEFSTYLE_CLEAN: fprintf(stderr,"Relief up clean "); break;
+        case RELIEFSTYLE_SUNKEN: fprintf(stderr,"Relief up sunken "); break;
+        case RELIEFSTYLE_RAISED: fprintf(stderr,"Relief up raised "); break;
+    }
+    switch((b->reliefstyle & 0xf)) {
+        case RELIEFSTYLE_CLEAN: fprintf(stderr,"Relief down clean "); break;
+        case RELIEFSTYLE_SUNKEN: fprintf(stderr,"Relief down sunken "); break;
+        case RELIEFSTYLE_RAISED: fprintf(stderr,"Relief down raised "); break;
+    }
+  }
   if(b->flags&b_Title)
   {
     fprintf(stderr,"Title ");
@@ -244,6 +258,18 @@
        fprintf(stderr,"Frame %i ",b->c->framew);
       if(b->c->flags&b_Padding)
        fprintf(stderr,"Padding %i %i ",b->c->xpad,b->c->ypad);
+      if(b->c->flags&b_ReliefStyle) {
+        switch((b->c->reliefstyle & 0xf0)>>4) {
+          case RELIEFSTYLE_CLEAN: fprintf(stderr,"Relief up clean "); break;
+          case RELIEFSTYLE_SUNKEN: fprintf(stderr,"Relief up sunken "); break;
+          case RELIEFSTYLE_RAISED: fprintf(stderr,"Relief up raised "); break;
+        }
+        switch((b->c->reliefstyle & 0xf)) {
+          case RELIEFSTYLE_CLEAN: fprintf(stderr,"Relief down clean "); break;
+          case RELIEFSTYLE_SUNKEN: fprintf(stderr,"Relief down sunken "); 
break;
+          case RELIEFSTYLE_RAISED: fprintf(stderr,"Relief down raised "); 
break;
+        }
+      }
       if(b->c->flags&b_Justify)
       {
        fprintf(stderr,"Title (");
Index: modules/FvwmButtons/parse.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmButtons/parse.c,v
retrieving revision 1.83
diff -u -r1.83 parse.c
--- modules/FvwmButtons/parse.c 29 Jun 2003 19:53:24 -0000      1.83
+++ modules/FvwmButtons/parse.c 22 Jul 2003 15:51:12 -0000
@@ -243,6 +243,84 @@
   *ss=s;
 }
 
+static void ParseReliefStyle(char **ss, button_info *b,
+                        byte *reliefstyle, unsigned long *flags)
+{
+    char *stateopts[] =
+    {
+      "up",
+      "down",
+      NULL
+    };
+    char *styleopts[] =
+    {
+      "clean",
+      "raised",
+      "sunken",
+      NULL
+    };
+    char *t,*s=*ss;
+    int state; 
+    byte style;
+    
+    /* Parse state */
+    s = trimleft(s);
+    state = GetTokenIndex(s,stateopts,-1,&s);
+    if (state < 0)  {
+            t = seekright(&s);
+            fprintf(stderr,"%s: Illegal relief state \"%s\"\n",
+                                                        MyName,(t)?t:""); 
+            s = trimleft(s);
+            t = seekright(&s);
+            if (t) free (t);
+            if (*s) s++;
+            *ss=s;
+            return;
+    }
+
+    /* Parse style */
+    s = trimleft(s);
+    switch (GetTokenIndex(s,styleopts,-1,&s)) 
+    {
+        case 0: /* Clean */
+            style = RELIEFSTYLE_CLEAN;
+            break;
+        case 1: /* Raised */
+            style = RELIEFSTYLE_RAISED;
+            break;
+        case 2: /* Sunken */
+            style = RELIEFSTYLE_SUNKEN;
+            break;
+        default:
+            t = seekright(&s);
+            fprintf(stderr,"%s: Illegal relief style \"%s\"\n",
+                                                        MyName,(t)?t:""); 
+            if(t) free (t);
+            if (*s) s++;
+            *ss=s;
+            return;
+    }
+    
+    /* Initialize defaults */
+    if (!(*flags & b_ReliefStyle)) {
+        *reliefstyle = buttonReliefStyle(b);
+        *flags |= b_ReliefStyle;
+    }
+
+    /* Set relief style */
+    switch (state) {
+        case 0: /* Up */
+            *reliefstyle = (*reliefstyle & ~0xf0) | style << 4;
+            break;
+        case 1: /* Down */
+            *reliefstyle = (*reliefstyle & ~0xf) | style;
+            break;
+    }
+
+    if (*s) s++;
+    *ss=s;
+}
+
 /**
 *** ParseSwallow()
 *** Parses the options possible to Swallow
@@ -577,6 +655,7 @@
     "size",
     "boxsize",
     "colorset",
+    "reliefstyle",
     NULL
   };
   char *t,*o,*s=*ss;
@@ -749,6 +828,10 @@
       }
       break;
 
+    case 13: /* Relief Style */
+        ParseReliefStyle(&s,b,&b->c->reliefstyle,&b->c->flags);
+        break;
+
     default:
       t=seekright(&s);
       fprintf(stderr,"%s: Illegal container option \"%s\"\n",MyName,
@@ -803,6 +886,7 @@
       "colorset",
       "action",
       "id",
+      "reliefstyle",
       NULL
     };
     s = trimleft(s);
@@ -1251,6 +1335,10 @@
        }
        break;
 
+      case 21: /* ReliefStyle */
+           ParseReliefStyle(&s,b,&b->reliefstyle,&b->flags);
+        break;
+        
       default:
        t=seekright(&s);
        fprintf(stderr,"%s: Illegal button option \"%s\"\n",MyName,
@@ -1349,6 +1437,7 @@
   return;
 }
 
+
 /**
 *** ParseConfigLine
 **/
@@ -1370,6 +1459,7 @@
     "pixmap",
     "boxsize",
     "colorset",
+    "reliefstyle",
     NULL
   };
   int i,j,k;
@@ -1468,6 +1558,11 @@
       ub->c->flags &= ~b_Colorset;
     }
     break;
+ 
+  case 13: /* Relief */ 
+    ParseReliefStyle(&s,ub,&ub->c->reliefstyle,&ub->c->flags);
+    break;
+  
   default:
     s = trimleft(s);
     ParseButton(ubb,s);
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to