[WIN32K]
[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 * Timo Kreuzer (timo.kreuzer@reactos.org)
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <w32k.h>
13
14 #define NDEBUG
15 #include <debug.h>
16
17
18 static BOOL Setup = FALSE;
19
20 /* FUNCTIONS *****************************************************************/
21
22 BOOL
23 FASTCALL
24 InitMetrics(VOID)
25 {
26 INT *piSysMet;
27 ULONG Width, Height;
28
29 /* FIXME: HACK, due to missing PDEV on first init */
30 if (!pPrimarySurface)
31 {
32 Width = 640;
33 Height = 480;
34 }
35 else
36 {
37 Width = pPrimarySurface->gdiinfo.ulHorzRes;
38 Height = pPrimarySurface->gdiinfo.ulVertRes;
39 }
40
41 piSysMet = gpsi->aiSysMet;
42
43 /* Screen sizes */
44 piSysMet[SM_CXSCREEN] = Width;
45 piSysMet[SM_CYSCREEN] = Height;
46 piSysMet[SM_XVIRTUALSCREEN] = 0;
47 piSysMet[SM_YVIRTUALSCREEN] = 0;
48 piSysMet[SM_CXVIRTUALSCREEN] = Width;
49 piSysMet[SM_CYVIRTUALSCREEN] = Height;
50
51 /* NC area sizes */
52 piSysMet[SM_CYCAPTION] = gspv.ncm.iCaptionHeight + 1; // 19
53 piSysMet[SM_CYSMCAPTION] = gspv.ncm.iSmCaptionHeight + 1; // 15;
54 piSysMet[SM_CXSIZE] = gspv.ncm.iCaptionHeight; // 18;
55 piSysMet[SM_CYSIZE] = gspv.ncm.iCaptionHeight; // 18;
56 piSysMet[SM_CXSMSIZE] = gspv.ncm.iSmCaptionWidth; // 12; xp: piSysMet(SM_CYSMCAPTION) - 1
57 piSysMet[SM_CYSMSIZE] = gspv.ncm.iSmCaptionHeight; // 14;
58 piSysMet[SM_CXBORDER] = 1; // seems to be hardcoded
59 piSysMet[SM_CYBORDER] = 1; // seems to be hardcoded
60 piSysMet[SM_CXFOCUSBORDER] = 1;
61 piSysMet[SM_CYFOCUSBORDER] = 1;
62 piSysMet[SM_CXDLGFRAME] = 3;
63 piSysMet[SM_CYDLGFRAME] = 3;
64 piSysMet[SM_CXEDGE] = 2;
65 piSysMet[SM_CYEDGE] = 2;
66 piSysMet[SM_CXFRAME] = piSysMet[SM_CXDLGFRAME] + gspv.ncm.iBorderWidth; // 4
67 piSysMet[SM_CYFRAME] = piSysMet[SM_CYDLGFRAME] + gspv.ncm.iBorderWidth; // 4
68 #if (_WIN32_WINNT >= 0x0600)
69 piSysMet[SM_CXPADDEDBORDER] = 0;
70 #endif
71
72 /* Window sizes */
73 DPRINT("ncm.iCaptionWidth=%d,GetSystemMetrics(SM_CYSIZE)=%d,GetSystemMetrics(SM_CXFRAME)=%d,avcwCaption=%d \n",
74 gspv.ncm.iCaptionWidth, piSysMet[SM_CYSIZE],piSysMet[SM_CXFRAME], gspv.tmCaptionFont.tmAveCharWidth);
75
76 piSysMet[SM_CXMIN] = 3 * max(gspv.ncm.iCaptionWidth, 8) // 112
77 + piSysMet[SM_CYSIZE] + 4
78 + 4 * gspv.tmCaptionFont.tmAveCharWidth
79 + 2 * piSysMet[SM_CXFRAME];
80 piSysMet[SM_CYMIN] = piSysMet[SM_CYCAPTION] + 2 * piSysMet[SM_CYFRAME];// 27
81 piSysMet[SM_CXMAXIMIZED] = piSysMet[SM_CXSCREEN] + 2 * piSysMet[SM_CXFRAME];
82 piSysMet[SM_CYMAXIMIZED] = piSysMet[SM_CYSCREEN] - 20;
83 piSysMet[SM_CXFULLSCREEN] = piSysMet[SM_CXSCREEN];
84 piSysMet[SM_CYFULLSCREEN] = piSysMet[SM_CYMAXIMIZED] - piSysMet[SM_CYMIN];
85 piSysMet[SM_CYKANJIWINDOW] = 0;
86 piSysMet[SM_CXMINIMIZED] = gspv.mm.iWidth + 6;
87 piSysMet[SM_CYMINIMIZED] = piSysMet[SM_CYCAPTION] + 5;
88 piSysMet[SM_CXMINSPACING] = piSysMet[SM_CXMINIMIZED] + gspv.mm.iHorzGap;
89 piSysMet[SM_CYMINSPACING] = piSysMet[SM_CYMINIMIZED] + gspv.mm.iVertGap;
90 piSysMet[SM_CXMAXTRACK] = piSysMet[SM_CXVIRTUALSCREEN] + 4
91 + 2 * piSysMet[SM_CXFRAME];
92 piSysMet[SM_CYMAXTRACK] = piSysMet[SM_CYVIRTUALSCREEN] + 4
93 + 2 * piSysMet[SM_CYFRAME];
94
95 /* Icon */
96 piSysMet[SM_CXVSCROLL] = gspv.ncm.iScrollWidth; //16;
97 piSysMet[SM_CYVTHUMB] = gspv.ncm.iScrollHeight; //16;
98 piSysMet[SM_CYHSCROLL] = gspv.ncm.iScrollWidth; //16;
99 piSysMet[SM_CXHTHUMB] = gspv.ncm.iScrollHeight; //16;
100 piSysMet[SM_CYVSCROLL] = gspv.ncm.iScrollHeight; // 16
101 piSysMet[SM_CXHSCROLL] = gspv.ncm.iScrollHeight; // 16;
102 piSysMet[SM_CXICON] = 32;
103 piSysMet[SM_CYICON] = 32;
104 piSysMet[SM_CXSMICON] = 16;
105 piSysMet[SM_CYSMICON] = 16;
106 piSysMet[SM_CXICONSPACING] = gspv.im.iHorzSpacing;// 64;
107 piSysMet[SM_CYICONSPACING] = gspv.im.iVertSpacing; // 64;
108 piSysMet[SM_CXCURSOR] = 32;
109 piSysMet[SM_CYCURSOR] = 32;
110 piSysMet[SM_CXMINTRACK] = piSysMet[SM_CXMIN]; // 117
111 piSysMet[SM_CYMINTRACK] = piSysMet[SM_CYMIN]; // 27
112 piSysMet[SM_CXDRAG] = 4;
113 piSysMet[SM_CYDRAG] = 4;
114 piSysMet[SM_ARRANGE] = gspv.mm.iArrange; // 8;
115
116 /* Menu */
117 piSysMet[SM_CYMENU] = gspv.ncm.iMenuHeight + 1;//19;
118 piSysMet[SM_MENUDROPALIGNMENT] = gspv.bMenuDropAlign;
119 piSysMet[SM_CXMENUCHECK] = ((1 + gspv.tmMenuFont.tmHeight +
120 gspv.tmMenuFont.tmExternalLeading) & ~1) - 1; // 13;
121 piSysMet[SM_CYMENUCHECK] = piSysMet[SM_CXMENUCHECK];
122 piSysMet[SM_CXMENUSIZE] = gspv.ncm.iMenuWidth; //18;
123 piSysMet[SM_CYMENUSIZE] = gspv.ncm.iMenuHeight; //18;
124
125 /* Mouse */
126 piSysMet[SM_MOUSEPRESENT] = 1;
127 piSysMet[SM_MOUSEWHEELPRESENT] = 1;
128 piSysMet[SM_CMOUSEBUTTONS] = 2;
129 piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
130 piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;
131 piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;
132 #if (_WIN32_WINNT >= 0x0600)
133 piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
134 #endif
135
136 /* Version info */
137 piSysMet[SM_TABLETPC] = 0;
138 piSysMet[SM_MEDIACENTER] = 0;
139 piSysMet[SM_STARTER] = 0;
140 piSysMet[SM_SERVERR2] = 0;
141 piSysMet[SM_PENWINDOWS] = 0;
142
143 /* Other */
144 piSysMet[SM_DEBUG] = 0;
145 piSysMet[SM_NETWORK] = 3;
146 piSysMet[SM_SLOWMACHINE] = 0;
147 piSysMet[SM_SECURE] = 0;
148 piSysMet[SM_DBCSENABLED] = 0;
149 piSysMet[SM_CLEANBOOT] = 0;
150 piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
151 piSysMet[SM_MIDEASTENABLED] = 0;
152 piSysMet[SM_CMONITORS] = 1;
153 piSysMet[SM_SAMEDISPLAYFORMAT] = 1;
154 piSysMet[SM_IMMENABLED] = 0;
155
156 /* Reserved */
157 piSysMet[SM_RESERVED1] = 0;
158 piSysMet[SM_RESERVED2] = 0;
159 piSysMet[SM_RESERVED3] = 0;
160 piSysMet[SM_RESERVED4] = 0;
161 piSysMet[64] = 0;
162 piSysMet[65] = 0;
163 piSysMet[66] = 0;
164 #if (_WIN32_WINNT >= 0x0600)
165 piSysMet[90] = 0;
166 #endif
167
168 gpsi->dwSRVIFlags |= SRVINFO_METRICS;
169 Setup = TRUE;
170
171 return TRUE;
172 }
173
174 ULONG FASTCALL
175 UserGetSystemMetrics(ULONG Index)
176 {
177 ASSERT(gpsi);
178 ASSERT(Setup);
179 DPRINT("UserGetSystemMetrics(%d)\n", Index);
180
181 /* Get metrics from array */
182 if (Index < SM_CMETRICS)
183 {
184 return gpsi->aiSysMet[Index];
185 }
186
187 /* Handle special values */
188 switch (Index)
189 {
190 case SM_REMOTESESSION:
191 return 0; // FIXME
192
193 case SM_SHUTTINGDOWN:
194 return 0; // FIXME
195
196 case SM_REMOTECONTROL:
197 return 0; // FIXME
198 }
199
200 DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index);
201 return 0;
202 }
203
204
205 /* EOF */