1 /* Emulate the X Resource Manager through the registry.
2 Copyright (C) 1990, 1993, 1994, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 /* Written by Kevin Gallo */
25 #include "blockinput.h"
30 #define REG_ROOT "SOFTWARE\\GNU\\Emacs"
32 /* Default system colors from the Display Control Panel settings. */
33 #define SYSTEM_DEFAULT_RESOURCES \
34 "emacs.foreground:SystemWindowText\0" \
35 "emacs.background:SystemWindow\0" \
36 "emacs.tooltip.attributeForeground:SystemInfoText\0" \
37 "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \
38 "emacs.tool-bar.attributeForeground:SystemButtonText\0" \
39 "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \
40 "emacs.menu.attributeForeground:SystemMenuText\0" \
41 "emacs.menu.attributeBackground:SystemMenu\0" \
42 "emacs.scroll-bar.attributeForeground:SystemScrollbar\0"
44 /* Other possibilities for default faces:
46 region: Could use SystemHilight, but interferes with our ability to
47 see most syntax highlighting through the region face.
49 modeline: Could use System(In)ActiveTitle, gradient versions (not
50 supported on 95 and NT), but modeline is more like a status bar
51 really (which don't appear to be configurable in Windows).
53 highlight: Could use SystemHotTrackingColor, but it is not supported
54 on Windows 95 or NT, and other apps only seem to use it for menus
60 w32_get_rdb_resource (rdb
, resource
)
65 int len
= strlen (resource
);
69 /* Comparison is case-insensitive because registry searches are too. */
70 if ((strnicmp (value
, resource
, len
) == 0) && (value
[len
] == ':'))
71 return xstrdup (&value
[len
+ 1]);
73 value
= strchr (value
, '\0') + 1;
80 w32_get_string_resource (name
, class, dwexptype
)
84 LPBYTE lpvalue
= NULL
;
89 HKEY hive
= HKEY_CURRENT_USER
;
95 /* Check both the current user and the local machine to see if we have
98 if (RegOpenKeyEx (hive
, REG_ROOT
, 0, KEY_READ
, &hrootkey
) == ERROR_SUCCESS
)
102 if (RegQueryValueEx (hrootkey
, name
, NULL
, &dwType
, NULL
, &cbData
) == ERROR_SUCCESS
103 && dwType
== dwexptype
)
107 else if (RegQueryValueEx (hrootkey
, class, NULL
, &dwType
, NULL
, &cbData
) == ERROR_SUCCESS
108 && dwType
== dwexptype
)
118 && (lpvalue
= (LPBYTE
) xmalloc (cbData
)) != NULL
119 && RegQueryValueEx (hrootkey
, keyname
, NULL
, NULL
, lpvalue
, &cbData
) == ERROR_SUCCESS
);
121 RegCloseKey (hrootkey
);
133 if (hive
== HKEY_CURRENT_USER
)
135 hive
= HKEY_LOCAL_MACHINE
;
139 /* Check if there are Windows specific defaults defined. */
140 return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES
, name
);
145 /* Retrieve the string resource specified by NAME with CLASS from
149 x_get_string_resource (rdb
, name
, class)
157 if (resource
= w32_get_rdb_resource (rdb
, name
))
159 if (resource
= w32_get_rdb_resource (rdb
, class))
163 return (w32_get_string_resource (name
, class, REG_SZ
));
166 /* arch-tag: 755fce25-42d7-4acb-874f-2fb42336823d
167 (do not change this comment) */