update for HEAD-2003091401
[reactos.git] / subsys / win32k / ntuser / metric.c
1 /*
2  *  ReactOS W32 Subsystem
3  *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:        See COPYING in the top level directory
22  * PROJECT:          ReactOS kernel
23  * PURPOSE:          Window classes
24  * FILE:             subsys/win32k/ntuser/metric.c
25  * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
26  * REVISION HISTORY:
27  *       06-06-2001  CSH  Created
28  */
29
30 /* INCLUDES ******************************************************************/
31
32 #include <ddk/ntddk.h>
33 #include <win32k/win32k.h>
34 #include <win32k/userobj.h>
35 #include <include/class.h>
36 #include <include/error.h>
37 #include <include/winsta.h>
38 #include <include/msgqueue.h>
39 #include <include/window.h>
40
41 #define NDEBUG
42 #include <debug.h>
43
44 /* FUNCTIONS *****************************************************************/
45
46 /* FIXME:  Alot of thse values should NOT be hardcoded but they are */
47 ULONG STDCALL
48 NtUserGetSystemMetrics(ULONG Index)
49 {
50   NTSTATUS Status;
51   PWINSTATION_OBJECT WinStaObject;
52   PWINDOW_OBJECT DesktopWindow;
53   ULONG Width, Height, Result;
54
55   Result = 0;
56   switch (Index)
57     {
58     case SM_ARRANGE:
59       return(8);
60     case SM_CLEANBOOT:
61       return(0);
62     case SM_CMOUSEBUTTONS:
63       return(2);
64     case SM_CXBORDER:
65     case SM_CYBORDER:
66       return(1);
67     case SM_CXCURSOR:
68     case SM_CYCURSOR:
69       return(32);
70     case SM_CXDLGFRAME:
71     case SM_CYDLGFRAME:
72       return(3);
73     case SM_CXDOUBLECLK:
74     case SM_CYDOUBLECLK:
75     case SM_SWAPBUTTON:
76       Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
77                                            KernelMode,
78                                            0,
79                                            &WinStaObject);
80       if (!NT_SUCCESS(Status))
81         return 0xFFFFFFFF;
82       
83       switch(Index)
84       {
85         case SM_CXDOUBLECLK:
86           Result = WinStaObject->SystemCursor.DblClickWidth;
87           break;
88         case SM_CYDOUBLECLK:
89           Result = WinStaObject->SystemCursor.DblClickWidth;
90           break;
91         case SM_SWAPBUTTON:
92           Result = (UINT)WinStaObject->SystemCursor.SwapButtons;
93           break;
94       }
95       
96       ObDereferenceObject(WinStaObject);
97       return Result;
98
99     case SM_CXDRAG:
100     case SM_CYDRAG:
101       return(2);
102     case SM_CXEDGE:
103     case SM_CYEDGE:
104       return(2);
105     case SM_CXFRAME:
106     case SM_CYFRAME:
107       return(4);
108     case SM_CXFULLSCREEN:
109       /* FIXME: shouldn't we take borders etc into account??? */
110       return NtUserGetSystemMetrics(SM_CXSCREEN);
111     case SM_CYFULLSCREEN:
112       return NtUserGetSystemMetrics(SM_CYSCREEN);
113     case SM_CXHSCROLL:
114     case SM_CYHSCROLL:
115       return(16);
116     case SM_CYVTHUMB:
117     case SM_CXHTHUMB:
118       return(16);
119     case SM_CXICON:
120     case SM_CYICON:
121       return(32);
122     case SM_CXICONSPACING:
123     case SM_CYICONSPACING:
124       return(44);
125     case SM_CXMAXIMIZED:
126       return(NtUserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
127                                                           pixels greater than
128                                                           the screen width */
129     case SM_CYMAXIMIZED:
130       return(NtUserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
131                                                            pixels less than 
132                                                            the screen height, 
133                                                            taskbar maybe? */
134     case SM_CXMAXTRACK:
135       return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12);
136     case SM_CYMAXTRACK:
137       return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12);
138     case SM_CXMENUCHECK:
139     case SM_CYMENUCHECK:
140       return(13);
141     case SM_CXMENUSIZE:
142     case SM_CYMENUSIZE:
143       return(18);
144     case SM_CXMIN:
145       return(112);
146     case SM_CYMIN:
147       return(27);
148     case SM_CXMINIMIZED:
149       return(160);
150     case SM_CYMINIMIZED:
151       return(24);
152     case SM_CXMINSPACING:
153       return(160);
154     case SM_CYMINSPACING:
155       return(24);
156     case SM_CXMINTRACK:
157       return(112);
158     case SM_CYMINTRACK:
159       return(27);
160     case SM_CXSCREEN:
161     case SM_CYSCREEN:
162       DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
163       if (NULL != DesktopWindow)
164           {
165             Width = DesktopWindow->WindowRect.right;
166             Height = DesktopWindow->WindowRect.bottom;
167           }
168       else
169           {
170             Width = 640;
171             Height = 480;
172           }
173       IntReleaseWindowObject(DesktopWindow);
174       return SM_CXSCREEN == Index ? Width : Height;
175     case SM_CXSIZE:
176     case SM_CYSIZE:
177       return(18);
178     case SM_CXSMICON:
179     case SM_CYSMICON:
180       return(16);
181     case SM_CXSMSIZE:
182       return(12);
183     case SM_CYSMSIZE:
184       return(15);
185     case SM_CXVSCROLL:
186     case SM_CYVSCROLL:
187       return(16);
188     case SM_CYCAPTION:
189       return(19);
190     case SM_CYKANJIWINDOW:
191       return 0;
192     case SM_CYMENU:
193       return(19);
194     case SM_CYSMCAPTION:
195       return(16);
196     case SM_DBCSENABLED:
197     case SM_DEBUG:
198     case SM_MENUDROPALIGNMENT: 
199     case SM_MIDEASTENABLED:
200       return(0);
201     case SM_MOUSEPRESENT:      
202       return(1);
203     case SM_NETWORK:           
204       return(3);
205     case SM_PENWINDOWS:        
206     case SM_SECURE:            
207     case SM_SHOWSOUNDS:        
208     case SM_SLOWMACHINE:       
209       return(0);
210     default:
211       return(0xFFFFFFFF);
212     }
213 }
214
215 /* EOF */