Subject: Patch for lowered menus...

From: Andreas Ehliar <[email-masked]>
Date: Mon, 30 Sep 1996 20:24:06 +0200 (MET DST)

This is just a little patch I put together to improve (imho) the look
of the menus. 
Use the added menustyle as follows:

MenuStyle black grey blue times fvwm lowered darkgrey
the above line will give lowered menus with bg color darkgrey
for selected menu items
The patch has been tested quite a lot on Solaris 2.5.1, but I have not
been able to test it on any other OS.
I don't think there should be any problems though...
NOTE: I'm not a very experienced X-windows programmer, this was merely
a work of cut-paste-and-modify... :)

It would be really nice to have pixmaps in the background for menus
though, anyone working on that?

//Andreas Ehliar

diff -cr fvwm-2.0.43/Fvwm.tmpl fvwm-2.0.43.lm/Fvwm.tmpl
*** fvwm-2.0.43/Fvwm.tmpl	Thu Jun 27 16:57:21 1996
--- fvwm-2.0.43.lm/Fvwm.tmpl	Fri Sep 27 09:47:39 1996
***************
*** 164,170 ****
   * 
   ***************************************************************************/
  
! OPTION_DEFINES = -DSHAPE -DPIXMAP_BUTTONS 

--- 164,170 ----
   * 
   ***************************************************************************/
  
! OPTION_DEFINES = -DSHAPE -DPIXMAP_BUTTONS -DLOWERED_MENUS

diff -cr fvwm-2.0.43/fvwm/builtins.c fvwm-2.0.43.lm/fvwm/builtins.c
*** fvwm-2.0.43/fvwm/builtins.c	Thu Jun 27 16:34:19 1996
--- fvwm-2.0.43.lm/fvwm/builtins.c	Mon Sep 30 19:13:26 1996
***************
*** 1266,1271 ****
--- 1266,1274 ----
    XGCValues gcv;
    unsigned long gcm;
    char *fore=NULL, *back=NULL, *stipple = NULL, *font= NULL, *style = 0;
+ #ifdef LOWERED_MENUS
+   char *lowered = NULL, *hicol = NULL;
+ #endif
    extern char *white,*black;
    int wid,hei;
  
***************
*** 1274,1280 ****
    action = GetNextToken(action,&stipple);
    action = GetNextToken(action,&font);
    action = GetNextToken(action,&style);
! 
    if((style != NULL)&&(mystrncasecmp(style,"MWM",3)==0))
    {
      Scr.flags |= MWMMenus;
--- 1277,1291 ----
    action = GetNextToken(action,&stipple);
    action = GetNextToken(action,&font);
    action = GetNextToken(action,&style);
! #ifdef LOWERED_MENUS
!   action = GetNextToken(action,&lowered);
!   action = GetNextToken(action,&hicol);
!   if((lowered != NULL) &&(mystrncasecmp(lowered,"lowered",8)==0)){
!     Scr.flags |= LoweredMenus;
!   }else{
!     Scr.flags &= ~LoweredMenus;
!   }
! #endif
    if((style != NULL)&&(mystrncasecmp(style,"MWM",3)==0))
    {
      Scr.flags |= MWMMenus;
***************
*** 1296,1301 ****
--- 1307,1319 ----
      Scr.MenuRelief.fore  = GetHilite(Scr.MenuColors.back);
      Scr.MenuStippleColors.back = Scr.MenuColors.back;
      Scr.MenuStippleColors.fore = GetColor(stipple); 
+ #ifdef LOWERED_MENUS    
+     if(hicol != NULL){
+ 	Scr.MenuHicol = GetColor(hicol);
+     }else{
+ 	Scr.MenuHicol = GetColor(fore);
+     }
+ #endif
    }
    else
    {
***************
*** 1305,1310 ****
--- 1323,1331 ----
      Scr.MenuRelief.fore  = GetColor(white);
      Scr.MenuStippleColors.back = GetColor(white);
      Scr.MenuStippleColors.fore = GetColor(black);
+ #ifdef LOWERED_MENUS
+     Scr.MenuHicol = Scr.MenuColors.back;
+ #endif
    }
  
    if ((font == NULL)||
***************
*** 1333,1339 ****
      XFreeGC(dpy,Scr.MenuReliefGC);
    }
    Scr.MenuReliefGC = XCreateGC(dpy, Scr.Root, gcm, &gcv);  
! 
    gcv.foreground = Scr.MenuRelief.back;
    gcv.background = Scr.MenuRelief.fore;
    if(Scr.MenuShadowGC != NULL)
--- 1354,1369 ----
      XFreeGC(dpy,Scr.MenuReliefGC);
    }
    Scr.MenuReliefGC = XCreateGC(dpy, Scr.Root, gcm, &gcv);  
! #ifdef LOWERED_MENUS
!   if(Scr.MenuHicol){
!       gcv.foreground = Scr.MenuHicol;    
!       if(Scr.MenuHicolGC)
! 	  {	      
! 	      XFreeGC(dpy,Scr.MenuHicolGC);	      
! 	  }
!       Scr.MenuHicolGC = XCreateGC(dpy, Scr.Root,gcm,&gcv);
!   }    
! #endif  
    gcv.foreground = Scr.MenuRelief.back;
    gcv.background = Scr.MenuRelief.fore;
    if(Scr.MenuShadowGC != NULL)
diff -cr fvwm-2.0.43/fvwm/fvwm.c fvwm-2.0.43.lm/fvwm/fvwm.c
*** fvwm-2.0.43/fvwm/fvwm.c	Thu Jun 27 16:08:08 1996
--- fvwm-2.0.43.lm/fvwm/fvwm.c	Fri Sep 27 09:45:32 1996
***************
*** 559,566 ****
--- 559,571 ----
    /* set up default colors, fonts, etc */
    ExecuteFunction("HilightColor black grey",NULL,&Event,C_ROOT,-1);
    ExecuteFunction("XORValue 255",NULL,&Event,C_ROOT,-1);
+ #ifdef LOWERED_MENUS
+   ExecuteFunction("MenuStyle black grey slategrey fixed fvwm lowered darkgrey",
+                   NULL,&Event,C_ROOT,-1);
+ #else
    ExecuteFunction("MenuStyle black grey slategrey fixed fvwm",
                    NULL,&Event,C_ROOT,-1);
+ #endif
    ExecuteFunction("TitleStyle Centered Raised",NULL,&Event,C_ROOT,-1);
    ExecuteFunction("IconFont fixed", NULL,&Event,C_ROOT,-1);
    ExecuteFunction("WindowFont fixed", NULL,&Event,C_ROOT,-1);
diff -cr fvwm-2.0.43/fvwm/menus.c fvwm-2.0.43.lm/fvwm/menus.c
*** fvwm-2.0.43/fvwm/menus.c	Thu Jun 27 21:00:56 1996
--- fvwm-2.0.43.lm/fvwm/menus.c	Fri Sep 27 09:40:28 1996
***************
*** 148,158 ****
   ***********************************************************************/
  void RelieveRectangle(Window win,int x,int y,int w, int h,GC Hilite,GC Shadow)
  {
!   XDrawLine(dpy, win, Hilite, x, y, w+x-1, y);
!   XDrawLine(dpy, win, Hilite, x, y, x, h+y-1);
! 
!   XDrawLine(dpy, win, Shadow, x, h+y-1, w+x-1, h+y-1);
!   XDrawLine(dpy, win, Shadow, w+x-1, y, w+x-1, h+y-1);
  }
  
  /***********************************************************************
--- 148,166 ----
   ***********************************************************************/
  void RelieveRectangle(Window win,int x,int y,int w, int h,GC Hilite,GC Shadow)
  {
! #ifdef LOWERED_MENUS
!     XDrawLine(dpy, win, Scr.flags & LoweredMenus ? Shadow:Hilite, x, y, w+x-1, y);
!     XDrawLine(dpy, win, Scr.flags & LoweredMenus ? Shadow:Hilite , x, y, x, h+y-1);
!     
!     XDrawLine(dpy, win, Scr.flags & LoweredMenus ? Hilite:Shadow, x, h+y-1, w+x-1,h+y-1);
!     XDrawLine(dpy, win, Scr.flags & LoweredMenus ? Hilite:Shadow, w+x-1, y, w+x-1, h+y-1);
! #else
!     XDrawLine(dpy, win, Hilite, x, y, w+x-1, y);
!     XDrawLine(dpy, win, Hilite, x, y, x, h+y-1);
!     
!     XDrawLine(dpy, win, Shadow, x, h+y-1, w+x-1, h+y-1);
!     XDrawLine(dpy, win, Shadow, w+x-1, y, w+x-1, h+y-1);
! #endif
  }
  
  /***********************************************************************
***************
*** 225,233 ****
        XClearArea(dpy, mr->w, 0,y_offset,mr->width,y_height,0);
        if ((mi->state)&&(mi->func_type != F_TITLE)&&
  	  (mi->func_type != F_NOP)&&(((*mi->item)!=0)||
! 				     mi->picture || mi->lpicture ))
! 	RelieveRectangle(mr->w, 2, y_offset, mr->width-4, mi->y_height,
! 			 ReliefGC,ShadowGC);
        RelieveHalfRectangle(mr->w, 0, y_offset, mr->width,
  			   y_height, ReliefGC, ShadowGC);
      }
--- 233,247 ----
        XClearArea(dpy, mr->w, 0,y_offset,mr->width,y_height,0);
        if ((mi->state)&&(mi->func_type != F_TITLE)&&
  	  (mi->func_type != F_NOP)&&(((*mi->item)!=0)||
! 				     mi->picture || mi->lpicture )){
! #ifdef LOWERED_MENUS       
! 	   if(Scr.MenuHicolGC){
! 	       XFillRectangle(dpy,mr->w,Scr.MenuHicolGC,3,y_offset,mr->width-3,y_height);
! 	   }
! #endif
! 	   RelieveRectangle(mr->w, 2, y_offset, mr->width-4, mi->y_height,
! 			    ReliefGC,ShadowGC);
!       }
        RelieveHalfRectangle(mr->w, 0, y_offset, mr->width,
  			   y_height, ReliefGC, ShadowGC);
      }
diff -cr fvwm-2.0.43/fvwm/screen.h fvwm-2.0.43.lm/fvwm/screen.h
*** fvwm-2.0.43/fvwm/screen.h	Fri Apr  5 02:18:23 1996
--- fvwm-2.0.43.lm/fvwm/screen.h	Mon Sep 30 11:59:05 1996
***************
*** 139,145 ****
  
    name_list *TheList;		/* list of window names with attributes */
    char *DefaultIcon;            /* Icon to use when no other icons are found */
! 
    ColorPair MenuColors;
    ColorPair MenuStippleColors;
    ColorPair MenuRelief;
--- 139,147 ----
  
    name_list *TheList;		/* list of window names with attributes */
    char *DefaultIcon;            /* Icon to use when no other icons are found */
! #ifdef LOWERED_MENUS
!   Pixel MenuHicol;
! #endif
    ColorPair MenuColors;
    ColorPair MenuStippleColors;
    ColorPair MenuRelief;
***************
*** 164,169 ****
--- 166,174 ----
    GC MenuStippleGC;
    GC MenuReliefGC;
    GC MenuShadowGC;
+ #ifdef LOWERED_MENUS
+   GC MenuHicolGC;
+ #endif
    GC ScratchGC1;
    GC ScratchGC2;
    GC ScratchGC3;
***************
*** 256,259 ****
--- 261,267 ----
  #define EdgeWrapX                 (64) /* Should EdgeScroll wrap around? */
  #define EdgeWrapY                (128) 
  #define MWMMenus                (1024)
+ #ifdef LOWERED_MENUS
+ #define LoweredMenus            (2048)
+ #endif
  #endif /* _SCREEN_ */

--
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].