1 /* Emulate the X Resource Manager through the registry.
2 Copyright (C) 1990, 1993, 1994 Free Software Foundation.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Written by Kevin Gallo */
26 #include "blockinput.h"
31 #define REG_ROOT "SOFTWARE\\GNU\\Emacs"
33 /* Default system colors from the Display Control Panel settings. */
34 #define SYSTEM_DEFAULT_RESOURCES \
35 "emacs.foreground:SystemWindowText\0" \
36 "emacs.background:SystemWindow\0" \
37 "emacs.tooltip.attributeForeground:SystemInfoText\0" \
38 "emacs.tooltip.attributeBackground:SystemInfoWindow\0" \
39 "emacs.tool-bar.attributeForeground:SystemButtonText\0" \
40 "emacs.tool-bar.attributeBackground:SystemButtonFace\0" \
41 "emacs.menu.attributeForeground:SystemMenuText\0" \
42 "emacs.menu.attributeBackground:SystemMenu\0" \
43 "emacs.scroll-bar.attributeForeground:SystemScrollbar"
45 /* Other possibilities for default faces:
47 region: Could use SystemHilight, but interferes with our ability to
48 see most syntax highlighting through the region face.
50 modeline: Could use System(In)ActiveTitle, gradient versions (not
51 supported on 95 and NT), but modeline is more like a status bar
52 really (which don't appear to be configurable in Windows).
54 highlight: Could use SystemHotTrackingColor, but it is not supported
55 on Windows 95 or NT, and other apps only seem to use it for menus
61 w32_get_rdb_resource (rdb
, resource
)
66 int len
= strlen (resource
);
70 /* Comparison is case-insensitive because registry searches are too. */
71 if ((strnicmp (value
, resource
, len
) == 0) && (value
[len
] == ':'))
72 return xstrdup (&value
[len
+ 1]);
74 value
= strchr (value
, '\0') + 1;
81 w32_get_string_resource (name
, class, dwexptype
)
85 LPBYTE lpvalue
= NULL
;
90 HKEY hive
= HKEY_CURRENT_USER
;
96 /* Check both the current user and the local machine to see if we have
99 if (RegOpenKeyEx (hive
, REG_ROOT
, 0, KEY_READ
, &hrootkey
) == ERROR_SUCCESS
)
103 if (RegQueryValueEx (hrootkey
, name
, NULL
, &dwType
, NULL
, &cbData
) == ERROR_SUCCESS
104 && dwType
== dwexptype
)
108 else if (RegQueryValueEx (hrootkey
, class, NULL
, &dwType
, NULL
, &cbData
) == ERROR_SUCCESS
109 && dwType
== dwexptype
)
119 && (lpvalue
= (LPBYTE
) xmalloc (cbData
)) != NULL
120 && RegQueryValueEx (hrootkey
, keyname
, NULL
, NULL
, lpvalue
, &cbData
) == ERROR_SUCCESS
);
122 RegCloseKey (hrootkey
);
134 if (hive
== HKEY_CURRENT_USER
)
136 hive
= HKEY_LOCAL_MACHINE
;
140 /* Check if there are Windows specific defaults defined. */
141 return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES
, name
);
146 /* Retrieve the string resource specified by NAME with CLASS from
150 x_get_string_resource (rdb
, name
, class)
158 if (resource
= w32_get_rdb_resource (rdb
, name
))
160 if (resource
= w32_get_rdb_resource (rdb
, class))
164 return (w32_get_string_resource (name
, class, REG_SZ
));
167 /* arch-tag: 755fce25-42d7-4acb-874f-2fb42336823d
168 (do not change this comment) */