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