all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Proposal: Windows Control Panel Colors
@ 2003-06-03 22:48 Michael Mauger
  2003-06-03 23:40 ` Miles Bader
  2003-06-05 23:29 ` Jason Rumney
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Mauger @ 2003-06-03 22:48 UTC (permalink / raw)


The following patch is intended to make NT Emacs more attractive.  The
first portion of the patch adds the colors found on the Windows
control panel to the `w32-color-map'; the second portion of the patch
modifies some of the standard Emacs faces to use these colors under
w32.  The result is that Emacs displays major frame components in
colors similar to the colors used in other applications.  Menus and
scroll bars already follow the Windows theme because they use standard
Windows controls.

This functionality is needed in Windows because Windows lacks the Xrdb
color mapping capability that permits X11 applications to enforce this
type of uniform appearance across applications.

The colors added to the color map are named using the logical color
names in the registry prefixed with "W32".  The list of color names
has been pretty constant across versions of Windows.  I use this patch
on Win2K and Win98 without problems.  The following is the list of
colors added under Win2k:

     W32ActiveBorder
     W32ActiveTitle
     W32AppWorkSpace
     W32Background
     W32ButtonAlternateFace
     W32ButtonDkShadow
     W32ButtonFace
     W32ButtonHilight
     W32ButtonLight
     W32ButtonShadow
     W32ButtonText
     W32GradientActiveTitle
     W32GradientInactiveTitle
     W32GrayText
     W32Hilight
     W32HilightText
     W32HotTrackingColor
     W32InactiveBorder
     W32InactiveTitle
     W32InactiveTitleText
     W32InfoText
     W32InfoWindow
     W32Menu
     W32MenuText
     W32Scrollbar
     W32TitleText
     W32Window
     W32WindowFrame
     W32WindowText

The colors are stored under HKEY_CURRENT_USER\Control Panel\Colors in
the registry.

The Emacs faces that are modified are:

    mode-line
	bg: W32GradientActiveTitle
	fg: W32ActiveTitleText

    mode-line-inactive
	bg: W32GradientInactiveTitle
	fg: W32InactiveTitleText

    toolbar
	bg: W32Menu
	fg: W32MenuText

    region
	bg: W32Hilight
	fg: W32HilightText

Other possibilities include tooltip (W32InfoWindow/W32InfoText)

To see the impact of this patch you can view the following web page:
<http://www.geocities.com/mmaug/emacs/cpanel-emacs.html>

Use M-x list-colors-display to see the added colors.

If it's decided that this patch should be included, please check it
in.  (I don't have access to do so, and I have submitted my copyright
assignment to GNU.)

Here's the patch:

Index: emacs/src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.216
diff -u -b -r1.216 w32fns.c
--- emacs/src/w32fns.c	24 May 2003 22:05:34 -0000	1.216
+++ emacs/src/w32fns.c	2 Jun 2003 04:24:32 -0000
@@ -1025,6 +1025,57 @@
   return (cmap);
 }

+#define W32_CPANEL_COLOR_PREFIX "W32"
+#define W32_CPANEL_COLOR_PREFIX_LEN ((sizeof W32_CPANEL_COLOR_PREFIX)-1)
+
+void
+w32_cpanel_colors (pcmap)
+     Lisp_Object* pcmap;
+{
+  HKEY hkey;
+
+  /* Lookup under the current user or local machine. */
+  if (RegOpenKeyEx (HKEY_CURRENT_USER, "Control Panel\\Colors", 0,
+		    KEY_READ, &hkey) == ERROR_SUCCESS
+      || RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Control Panel\\Colors", 0,
+		       KEY_READ, &hkey) == ERROR_SUCCESS)
+    {
+      DWORD dwIndex;
+      CHAR achName[256 + W32_CPANEL_COLOR_PREFIX_LEN];
+      DWORD cName;
+      char achRGB[64];
+      DWORD cRGB;
+      int red, green, blue;
+
+      strcpy(achName, W32_CPANEL_COLOR_PREFIX);
+
+      /* Enumerate each key and add its name and color to the color map
+	 with the color name prefix. */
+      for (dwIndex = 0;
+	   cName = ((sizeof achName) / (sizeof achName[0]))
+	         - W32_CPANEL_COLOR_PREFIX_LEN,
+	     cRGB = sizeof achRGB,
+	     RegEnumValue(hkey, dwIndex,
+			  (LPTSTR) achName + W32_CPANEL_COLOR_PREFIX_LEN,
+			  (LPDWORD) &cName,
+			  NULL, NULL,
+			  (LPBYTE) achRGB, (LPDWORD) &cRGB) == ERROR_SUCCESS;
+	   ++dwIndex)
+	{
+	  if (sscanf (achRGB, " %u %u %u", &red, &green, &blue) == 3)
+	    {
+	      *pcmap = Fcons (Fcons (build_string (achName),
+				     make_number (RGB (red, green, blue))),
+			      *pcmap);
+	    }
+	}
+
+      RegCloseKey (hkey);
+    }
+
+  return;
+}
+
 Lisp_Object
 w32_to_x_color (rgb)
      Lisp_Object rgb;
@@ -6773,6 +6828,8 @@
   }
   if (NILP (Vw32_color_map))
     Vw32_color_map = Fw32_default_color_map ();
+
+  w32_cpanel_colors (&Vw32_color_map);

   if (! NILP (xrm_string))
     xrm_option = (unsigned char *) SDATA (xrm_string);
Index: emacs/lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.279
diff -u -b -r1.279 faces.el
--- emacs/lisp/faces.el	28 May 2003 11:17:33 -0000	1.279
+++ emacs/lisp/faces.el	2 Jun 2003 04:26:50 -0000
@@ -1800,9 +1800,13 @@


 (defface mode-line
-  '((((type x w32 mac) (class color))
+  '((((type x mac) (class color))
      :box (:line-width -1 :style released-button)
      :background "grey75" :foreground "black")
+    (((type w32))
+     :box (:line-width -1 :style released-button)
+     :background "W32GradientActiveTitle"
+     :foreground "W32TitleText")
     (t
      :inverse-video t))
   "Basic mode line face for selected window."
@@ -1813,11 +1817,15 @@
 (defface mode-line-inactive
   '((t
      :inherit mode-line)
-    (((type x w32 mac) (background light) (class color))
+    (((type w32))
+     :box (:line-width -1 :color "W32InactiveTitle" :style nil)
+     :background "W32GradientInactiveTitle"
+     :foreground "W32InactiveTitleText")
+    (((type x mac) (background light) (class color))
      :weight light
      :box (:line-width -1 :color "grey75" :style nil)
      :foreground "grey20" :background "grey90")
-    (((type x w32 mac) (background dark) (class color))
+    (((type x mac) (background dark) (class color))
      :weight light
      :box (:line-width -1 :color "grey40" :style nil)
      :foreground "grey80" :background "grey30"))
@@ -1868,9 +1876,12 @@


 (defface tool-bar
-  '((((type x w32 mac) (class color))
+  '((((type x mac) (class color))
      :box (:line-width 1 :style released-button)
      :background "grey75" :foreground "black")
+    (((type w32))
+     :box nil
+     :background "W32Menu" :foreground "W32MenuText")
     (((type x) (class mono))
      :box (:line-width 1 :style released-button)
      :background "grey" :foreground "black")
@@ -1896,6 +1907,8 @@
      :background "blue" :foreground "white")
     (((type tty) (class mono))
      :inverse-video t)
+    (((type w32))
+     :background "W32Hilight" :foreground "W32HilightText")
     (((class color) (background dark))
      :background "blue3")
     (((class color) (background light))

--
Michael Mauger
http://www.geocities.com/mmaug/


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-03 22:48 Michael Mauger
@ 2003-06-03 23:40 ` Miles Bader
  2003-06-04  0:28   ` Michael Mauger
  2003-06-05 23:29 ` Jason Rumney
  1 sibling, 1 reply; 9+ messages in thread
From: Miles Bader @ 2003-06-03 23:40 UTC (permalink / raw)
  Cc: emacs-devel

Having a white-on-baby-blue mode-line by default seems likely to be an
unpopular change...  Isn't there a better windows color that could be used
for the mode-line?

-Miles
-- 
Occam's razor split hairs so well, I bought the whole argument!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-03 23:40 ` Miles Bader
@ 2003-06-04  0:28   ` Michael Mauger
  2003-06-04  4:09     ` Miles Bader
  2003-06-04  7:11     ` Jason Rumney
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Mauger @ 2003-06-04  0:28 UTC (permalink / raw)
  Cc: emacs-devel

In practice it's not too bad -- your eye filters the common color used to
identify active windows/subwindows.  In isolation, the mode-line may
appear too harsh, but in the context of other windows its not bad at all.
 In an application supporting MDI, each subwindow would use this same
color on its title bar.

The most logical alternative to W32GradientActiveTitle would be to use
W32ActiveTitle.  (Active titles fade from the ActiveTitle color to the
GradientActiveTitle color.)  I chose GradientActiveTitle because it
generally is a subtler color.

--- Miles Bader <miles@gnu.org> wrote:
> Having a white-on-baby-blue mode-line by default seems likely to be an
> unpopular change...  Isn't there a better windows color that could be
> used
> for the mode-line?
> 
> -Miles
> -- 
> Occam's razor split hairs so well, I bought the whole argument!


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-04  0:28   ` Michael Mauger
@ 2003-06-04  4:09     ` Miles Bader
  2003-06-04  7:11     ` Jason Rumney
  1 sibling, 0 replies; 9+ messages in thread
From: Miles Bader @ 2003-06-04  4:09 UTC (permalink / raw)
  Cc: emacs-devel

Michael Mauger <mmaug@yahoo.com> writes:
> The most logical alternative to W32GradientActiveTitle would be to use
> W32ActiveTitle.  (Active titles fade from the ActiveTitle color to the
> GradientActiveTitle color.)  I chose GradientActiveTitle because it
> generally is a subtler color.

What color is W32ActiveTitle in the default theme?

-Miles
-- 
Saa, shall we dance?  (from a dance-class advertisement)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-04  0:28   ` Michael Mauger
  2003-06-04  4:09     ` Miles Bader
@ 2003-06-04  7:11     ` Jason Rumney
  1 sibling, 0 replies; 9+ messages in thread
From: Jason Rumney @ 2003-06-04  7:11 UTC (permalink / raw)
  Cc: Miles Bader

Michael Mauger <mmaug@yahoo.com> writes:

> The most logical alternative to W32GradientActiveTitle would be to use
> W32ActiveTitle.  (Active titles fade from the ActiveTitle color to the
> GradientActiveTitle color.)  I chose GradientActiveTitle because it
> generally is a subtler color.

Gradient's are only supported in recent versions of Windows. The
defaults need to be colors that exist in Windows 95 and NT 4.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
       [not found] <usmqpy2it.fsf@jasonrumney.net>
@ 2003-06-04 21:33 ` Michael Mauger
  2003-06-04 23:00   ` Jason Rumney
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Mauger @ 2003-06-04 21:33 UTC (permalink / raw)


--- Jason Rumney <jasonr@gnu.org> wrote:
> Michael Mauger <mmaug@yahoo.com> writes:
> 
> > My original implementation didn't add the colors to the
> `w32-color-map'
> > --instead it translated the color name to a COLORREF in
> `x_to_w32_color'
> > and handled the Gradient colors specially by falling back to the base
> > title colors.  The current implementation could be modified to add
> the
> > two Gradient colors to the color map if they don't exist in the
> Registry.
> > 
> > The other option would be to just default `mode-line' and
> > `mode-line-inactive' to use `W32ActiveTitle' and `W32InactiveTitle'
> as
> > background colors respectively.  I don't think that this looks as
> good
> > when the Gradient colors are available.  But that is purely
> subjective...
> 
> Having looked at your screenshots, I don't think the titlebar colors
> (especially gradient ones, which can be low contrast compared with the
> title font color) are suited for the modeline. The modeline is more
> analogous to the status area of Windows applications than a title bar.
> It may be better to leave it as now, or maybe use W32Menu for active
> modeline and calculate some intermediate value between the active
> modeline color and background color for inactive modelines.
> 

I don't entirely agree, since the mode-line does contain the only
identifying information about the window (granted, with lots 
of status info as well).  I guess the issue is far more subjective 
than I thought.  I'm probably more aware of the color issues 
because my Win98 machine has its desktop theme changed frequently
(my kids love finding new colors and fonts for the window chrome). 

Can we get agreement on the first part of the patch (i.e., loading
the Windows control panel colors onto `w32-color-map') and leave 
the second portion of the patch (i.e., mapping specific faces to 
use the the control panel colors) off?  That way, those of us who
wish to use the control panel colors can, by customizing the faces, 
but the current defaults can stand.

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-04 21:33 ` Proposal: Windows Control Panel Colors Michael Mauger
@ 2003-06-04 23:00   ` Jason Rumney
  2003-06-05 13:54     ` Michael Mauger
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Rumney @ 2003-06-04 23:00 UTC (permalink / raw)
  Cc: emacs-devel

Michael Mauger <mmaug@yahoo.com> writes:

> Can we get agreement on the first part of the patch (i.e., loading
> the Windows control panel colors onto `w32-color-map') and leave 
> the second portion of the patch (i.e., mapping specific faces to 
> use the the control panel colors) off?  That way, those of us who
> wish to use the control panel colors can, by customizing the faces, 
> but the current defaults can stand.

My only concern with the effect of your patch is basing the modeline
face on titlebar colors. The rest of the changes do not seem likely to
cause complaints.

As far as the implementation details go, I'd like to rewrite the patch
to comply with GNU coding guidelines and reduce the complexity of the
for statement. Also, I think it would be better to use a more generic
prefix so we can have some commonality if the same thing is done on
other platforms (it may be useful for GTK, Mac and maybe even CDE
users to be able to use color names that correspond to the system
settings rather than physical colors).

If you'd like to contribute to Emacs in future, it may be worth it for
you to make these changes and arrange the neccesary copyright assignments.
Otherwise I will try to do it over the next few days.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-04 23:00   ` Jason Rumney
@ 2003-06-05 13:54     ` Michael Mauger
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Mauger @ 2003-06-05 13:54 UTC (permalink / raw)
  Cc: emacs-devel


--- Jason Rumney <jasonr@gnu.org> wrote:
> 
> As far as the implementation details go, I'd like to rewrite the patch
> to comply with GNU coding guidelines and reduce the complexity of the
> for statement. Also, I think it would be better to use a more generic
> prefix so we can have some commonality if the same thing is done on
> other platforms (it may be useful for GTK, Mac and maybe even CDE
> users to be able to use color names that correspond to the system
> settings rather than physical colors).
> 
> If you'd like to contribute to Emacs in future, it may be worth it for
> you to make these changes and arrange the neccesary copyright
> assignments.
> Otherwise I will try to do it over the next few days.
> 

I have submitted my copyright assignment related to changes I 
proposed for sql-mode.  I don't think that the paperwork has 
been processed yet.  

I do intend to contribute to Emacs in the future and would be 
willing to make refinements to the code I provided.  If you 
can give me a more concrete concept of what you think should 
be done to make this more useful, I'd be happy to pursue it.


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Proposal: Windows Control Panel Colors
  2003-06-03 22:48 Michael Mauger
  2003-06-03 23:40 ` Miles Bader
@ 2003-06-05 23:29 ` Jason Rumney
  1 sibling, 0 replies; 9+ messages in thread
From: Jason Rumney @ 2003-06-05 23:29 UTC (permalink / raw)
  Cc: emacs-devel

Michael Mauger <mmaug@yahoo.com> writes:

> the second portion of the patch modifies some of the standard Emacs
> faces to use these colors under w32.  The result is that Emacs
> displays major frame components in colors similar to the colors used
> in other applications.

I decided to implement this in the X Resource emulation code in
w32reg.c, rather than in faces.el.  This makes it act more like
System default X resources (including honoring any future
command-line option to ignore resources).

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-06-05 23:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <usmqpy2it.fsf@jasonrumney.net>
2003-06-04 21:33 ` Proposal: Windows Control Panel Colors Michael Mauger
2003-06-04 23:00   ` Jason Rumney
2003-06-05 13:54     ` Michael Mauger
2003-06-03 22:48 Michael Mauger
2003-06-03 23:40 ` Miles Bader
2003-06-04  0:28   ` Michael Mauger
2003-06-04  4:09     ` Miles Bader
2003-06-04  7:11     ` Jason Rumney
2003-06-05 23:29 ` Jason Rumney

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.