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