The real, definitive, Visual C++ support branch. Accept no substitutes
[reactos.git] / subsystems / win32 / win32k / ntuser / metric.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Window classes
5 * FILE: subsys/win32k/ntuser/metric.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISION HISTORY:
8 * 06-06-2001 CSH Created
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #include <w32k.h>
14
15 #define NDEBUG
16 #include <debug.h>
17
18
19 static BOOL Setup = FALSE;
20
21 /* FUNCTIONS *****************************************************************/
22
23 // FIXME: These are only win xp default values, mostly hardcoded. They should be
24 // read from the registry. It must be possible to change or reinitialize the
25 // values, for example desk.cpl
26 BOOL
27 FASTCALL
28 InitMetrics(VOID)
29 {
30 NTSTATUS Status;
31 PWINSTATION_OBJECT WinStaObject;
32 ULONG Width = 640, Height = 480;
33 PSYSTEM_CURSORINFO CurInfo;
34 HDC hScreenDC;
35 PDC pScreenDC;
36
37 hScreenDC = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE);
38 if (hScreenDC)
39 {
40 pScreenDC = DC_LockDc(hScreenDC);
41 if (pScreenDC)
42 {
43 Width = ((PGDIDEVICE)pScreenDC->pPDev)->GDIInfo.ulHorzRes;
44 Height = ((PGDIDEVICE)pScreenDC->pPDev)->GDIInfo.ulVertRes;
45 DC_UnlockDc(pScreenDC);
46 }
47 NtGdiDeleteObjectApp(hScreenDC);
48 }
49
50 Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
51 KernelMode,
52 0,
53 &WinStaObject);
54 if (NT_SUCCESS(Status))
55 {
56 CurInfo = IntGetSysCursorInfo(WinStaObject);
57 }
58 else
59 {
60 CurInfo = NULL;
61 }
62
63 gpsi->SystemMetrics[SM_CXSCREEN] = Width;
64 gpsi->SystemMetrics[SM_CYSCREEN] = Height;
65 gpsi->SystemMetrics[SM_CXVSCROLL] = 16;
66 gpsi->SystemMetrics[SM_CYHSCROLL] = 16;
67 /* FIXME: "reg://Control Panel/Desktop/WindowMetrics/CaptionHeight" + 1 */
68 gpsi->SystemMetrics[SM_CYCAPTION] = 19;
69 gpsi->SystemMetrics[SM_CXBORDER] = 1;
70 gpsi->SystemMetrics[SM_CYBORDER] = 1;
71 gpsi->SystemMetrics[SM_CXDLGFRAME] = 3;
72 gpsi->SystemMetrics[SM_CYDLGFRAME] = 3;
73 gpsi->SystemMetrics[SM_CYVTHUMB] = 16;
74 gpsi->SystemMetrics[SM_CXHTHUMB] = 16;
75 gpsi->SystemMetrics[SM_CXICON] = 32;
76 gpsi->SystemMetrics[SM_CYICON] = 32;
77 gpsi->SystemMetrics[SM_CXCURSOR] = 32;
78 gpsi->SystemMetrics[SM_CYCURSOR] = 32;
79 gpsi->SystemMetrics[SM_CYMENU] = 19;
80 /* FIXME: shouldn't we take borders etc into account??? */
81 gpsi->SystemMetrics[SM_CXFULLSCREEN] = gpsi->SystemMetrics[SM_CXSCREEN];
82 gpsi->SystemMetrics[SM_CYFULLSCREEN] = gpsi->SystemMetrics[SM_CYSCREEN];
83 gpsi->SystemMetrics[SM_CYKANJIWINDOW] = 0;
84 gpsi->SystemMetrics[SM_MOUSEPRESENT] = 1;
85 gpsi->SystemMetrics[SM_CYVSCROLL] = 16;
86 gpsi->SystemMetrics[SM_CXHSCROLL] = 16;
87 gpsi->SystemMetrics[SM_DEBUG] = 0;
88 gpsi->SystemMetrics[SM_SWAPBUTTON] = CurInfo ? CurInfo->SwapButtons : 0;
89 gpsi->SystemMetrics[SM_RESERVED1] = 0;
90 gpsi->SystemMetrics[SM_RESERVED2] = 0;
91 gpsi->SystemMetrics[SM_RESERVED3] = 0;
92 gpsi->SystemMetrics[SM_RESERVED4] = 0;
93 gpsi->SystemMetrics[SM_CXMIN] = 112;
94 gpsi->SystemMetrics[SM_CYMIN] = 27;
95 gpsi->SystemMetrics[SM_CXSIZE] = 18;
96 gpsi->SystemMetrics[SM_CYSIZE] = 18;
97 gpsi->SystemMetrics[SM_CXFRAME] = 4;
98 gpsi->SystemMetrics[SM_CYFRAME] = 4;
99 gpsi->SystemMetrics[SM_CXMINTRACK] = 112;
100 gpsi->SystemMetrics[SM_CYMINTRACK] = 27;
101 gpsi->SystemMetrics[SM_CXDOUBLECLK] = CurInfo ? CurInfo->DblClickWidth : 4;
102 gpsi->SystemMetrics[SM_CYDOUBLECLK] = CurInfo ? CurInfo->DblClickWidth : 4;
103 gpsi->SystemMetrics[SM_CXICONSPACING] = 64;
104 gpsi->SystemMetrics[SM_CYICONSPACING] = 64;
105 gpsi->SystemMetrics[SM_MENUDROPALIGNMENT] = 0;
106 gpsi->SystemMetrics[SM_PENWINDOWS] = 0;
107 gpsi->SystemMetrics[SM_DBCSENABLED] = 0;
108 gpsi->SystemMetrics[SM_CMOUSEBUTTONS] = 2;
109 gpsi->SystemMetrics[SM_SECURE] = 0;
110 gpsi->SystemMetrics[SM_CXEDGE] = 2;
111 gpsi->SystemMetrics[SM_CYEDGE] = 2;
112 gpsi->SystemMetrics[SM_CXMINSPACING] = 160;
113 gpsi->SystemMetrics[SM_CYMINSPACING] = 24;
114 gpsi->SystemMetrics[SM_CXSMICON] = 16;
115 gpsi->SystemMetrics[SM_CYSMICON] = 16;
116 gpsi->SystemMetrics[SM_CYSMCAPTION] = 15;
117 gpsi->SystemMetrics[SM_CXSMSIZE] = 12;
118 gpsi->SystemMetrics[SM_CYSMSIZE] = 14;
119 gpsi->SystemMetrics[SM_CXMENUSIZE] = 18;
120 gpsi->SystemMetrics[SM_CYMENUSIZE] = 18;
121 gpsi->SystemMetrics[SM_ARRANGE] = 8;
122 gpsi->SystemMetrics[SM_CXMINIMIZED] = 160;
123 gpsi->SystemMetrics[SM_CYMINIMIZED] = 24;
124 gpsi->SystemMetrics[SM_CXMAXTRACK] = gpsi->SystemMetrics[SM_CYSCREEN] + 12;
125 gpsi->SystemMetrics[SM_CYMAXTRACK] = gpsi->SystemMetrics[SM_CYSCREEN] + 12;
126 /* This seems to be 8 pixels greater than the screen width */
127 gpsi->SystemMetrics[SM_CXMAXIMIZED] = gpsi->SystemMetrics[SM_CXSCREEN] + 8;
128 /* This seems to be 20 pixels less than the screen height, taskbar maybe? */
129 gpsi->SystemMetrics[SM_CYMAXIMIZED] = gpsi->SystemMetrics[SM_CYSCREEN] - 20;
130 gpsi->SystemMetrics[SM_NETWORK] = 3;
131 gpsi->SystemMetrics[64] = 0;
132 gpsi->SystemMetrics[65] = 0;
133 gpsi->SystemMetrics[66] = 0;
134 gpsi->SystemMetrics[SM_CLEANBOOT] = 0;
135 gpsi->SystemMetrics[SM_CXDRAG] = 4;
136 gpsi->SystemMetrics[SM_CYDRAG] = 4;
137 gpsi->SystemMetrics[SM_SHOWSOUNDS] = 0;
138 gpsi->SystemMetrics[SM_CXMENUCHECK] = 13;
139 gpsi->SystemMetrics[SM_CYMENUCHECK] = 13;
140 gpsi->SystemMetrics[SM_SLOWMACHINE] = 0;
141 gpsi->SystemMetrics[SM_MIDEASTENABLED] = 0;
142 gpsi->SystemMetrics[SM_MOUSEWHEELPRESENT] = 1;
143 gpsi->SystemMetrics[SM_XVIRTUALSCREEN] = 0;
144 gpsi->SystemMetrics[SM_YVIRTUALSCREEN] = 0;
145 gpsi->SystemMetrics[SM_CXVIRTUALSCREEN] = Width;
146 gpsi->SystemMetrics[SM_CYVIRTUALSCREEN] = Height;
147 gpsi->SystemMetrics[SM_CMONITORS] = 1;
148 gpsi->SystemMetrics[SM_SAMEDISPLAYFORMAT] = 1;
149 gpsi->SystemMetrics[SM_IMMENABLED] = 0;
150 gpsi->SystemMetrics[SM_CXFOCUSBORDER] = 1;
151 gpsi->SystemMetrics[SM_CYFOCUSBORDER] = 1;
152 gpsi->SystemMetrics[SM_TABLETPC] = 0;
153 gpsi->SystemMetrics[SM_MEDIACENTER] = 0;
154 gpsi->SystemMetrics[SM_STARTER] = 0;
155 gpsi->SystemMetrics[SM_SERVERR2] = 0;
156 #if (_WIN32_WINNT >= 0x0600)
157 gpsi->SystemMetrics[90] = 0;
158 gpsi->SystemMetrics[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
159 gpsi->SystemMetrics[SM_CXPADDEDBORDER] = 0;
160 #endif
161
162 gpsi->SRVINFO_Flags |= SRVINFO_METRICS;
163 Setup = TRUE;
164
165 if (NT_SUCCESS(Status))
166 {
167 ObDereferenceObject(WinStaObject);
168 }
169
170 return TRUE;
171 }
172
173 ULONG FASTCALL
174 UserGetSystemMetrics(ULONG Index)
175 {
176 ASSERT(gpsi);
177 DPRINT("UserGetSystemMetrics(%d)\n", Index);
178
179 // FIXME: Do this when loading
180 if (!Setup)
181 {
182 InitMetrics();
183 }
184
185 /* Get metrics from array */
186 if (Index < SM_CMETRICS)
187 {
188 return gpsi->SystemMetrics[Index];
189 }
190
191 /* Handle special values */
192 switch (Index)
193 {
194 case SM_REMOTESESSION:
195 return 0; // FIXME
196
197 case SM_SHUTTINGDOWN:
198 return 0; // FIXME
199
200 case SM_REMOTECONTROL:
201 return 0; // FIXME
202 }
203
204 DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index);
205 return 0;
206 }
207
208
209 /* EOF */