changeset 35277:a959d4b99e4d

(Vtool_bar_button_margin): Replaces tool_bar_button_margin. (build_desired_tool_bar_string): Handle Vtool_bar_button_margin being a pair of margins. (syms_of_xdisp): Change DEFVAR_INT of tool-bar-button-margins to DEFVAR_LISP. Extend doc.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 12 Jan 2001 15:12:10 +0000
parents 008aea836cbc
children 80050ac10dbf
files src/xdisp.c
diffstat 1 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Fri Jan 12 15:09:58 2001 +0000
+++ b/src/xdisp.c	Fri Jan 12 15:12:10 2001 +0000
@@ -239,7 +239,7 @@
 
 /* Margin around tool bar buttons in pixels.  */
 
-int tool_bar_button_margin;
+Lisp_Object Vtool_bar_button_margin;
 
 /* Thickness of shadow to draw around tool bar buttons.  */
 
@@ -7186,7 +7186,7 @@
 
       int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
       int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
-      int margin, relief, idx, end;
+      int hmargin, vmargin, relief, idx, end;
       extern Lisp_Object QCrelief, QCmargin, QCalgorithm, Qimage;
       extern Lisp_Object Qlaplace;
 
@@ -7219,7 +7219,24 @@
 
       /* Compute margin and relief to draw.  */
       relief = tool_bar_button_relief > 0 ? tool_bar_button_relief : 3;
-      margin = relief + max (0, tool_bar_button_margin);
+      hmargin = vmargin = relief;
+
+      if (INTEGERP (Vtool_bar_button_margin)
+	  && XINT (Vtool_bar_button_margin) > 0)
+	{
+	  hmargin += XFASTINT (Vtool_bar_button_margin);
+	  vmargin += XFASTINT (Vtool_bar_button_margin);
+	}
+      else if (CONSP (Vtool_bar_button_margin))
+	{
+	  if (INTEGERP (XCAR (Vtool_bar_button_margin))
+	      && XINT (XCAR (Vtool_bar_button_margin)) > 0)
+	    hmargin += XFASTINT (XCAR (Vtool_bar_button_margin));
+	  
+	  if (INTEGERP (XCDR (Vtool_bar_button_margin))
+	      && XINT (XCDR (Vtool_bar_button_margin)) > 0)
+	    vmargin += XFASTINT (XCDR (Vtool_bar_button_margin));
+	}
       
       if (auto_raise_tool_bar_buttons_p)
 	{
@@ -7228,7 +7245,8 @@
 	  if (selected_p)
 	    {
 	      plist = Fplist_put (plist, QCrelief, make_number (-relief));
-	      margin -= relief;
+	      hmargin -= relief;
+	      vmargin -= relief;
 	    }
 	}
       else
@@ -7240,12 +7258,20 @@
 			      (selected_p
 			       ? make_number (-relief)
 			       : make_number (relief)));
-	  margin -= relief;
+	  hmargin -= relief;
+	  vmargin -= relief;
 	}
 
       /* Put a margin around the image.  */
-      if (margin)
-	plist = Fplist_put (plist, QCmargin, make_number (margin));
+      if (hmargin || vmargin)
+	{
+	  if (hmargin == vmargin)
+	    plist = Fplist_put (plist, QCmargin, make_number (hmargin));
+	  else
+	    plist = Fplist_put (plist, QCmargin,
+				Fcons (make_number (hmargin),
+				       make_number (vmargin)));
+	}
 	  
       /* If button is not enabled, and we don't have special images
 	 for the disabled state, make the image appear disabled by
@@ -14088,9 +14114,13 @@
     "*Non-nil means raise tool-bar buttons when the mouse moves over them.");
   auto_raise_tool_bar_buttons_p = 1;
 
-  DEFVAR_INT ("tool-bar-button-margin", &tool_bar_button_margin,
-    "*Margin around tool-bar buttons in pixels.");
-  tool_bar_button_margin = 1;
+  DEFVAR_LISP ("tool-bar-button-margin", &Vtool_bar_button_margin,
+    "*Margin around tool-bar buttons in pixels.\n\
+If an integer, use that for both horizontal and vertical margins.\n\
+Otherwise, value should be a pair of integers `(HORZ : VERT)' with\n\
+HORZ specifying the horizontal margin, and VERT specifying the\n\
+vertical margin.");
+  Vtool_bar_button_margin = make_number (1);
 
   DEFVAR_INT ("tool-bar-button-relief", &tool_bar_button_relief,
     "Relief thickness of tool-bar buttons.");