1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2000
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 // We have to do this in order to have access to the multiple-monitor
40 // APIs that are only defined when WINVER is >= 0x0500. Don't worry,
41 // these won't actually be called unless they are present.
46 #define _WIN32_WINNT 0x0500
48 #include "nsScreenWin.h"
51 #ifdef WINCE_WINDOWS_MOBILE
54 #define GetMonitorInfoW GetMonitorInfo
58 nsScreenWin :: nsScreenWin ( void* inScreen
)
62 HDC hDCScreen
= ::GetDC(nsnull
);
63 NS_ASSERTION(hDCScreen
,"GetDC Failure");
64 NS_ASSERTION ( ::GetDeviceCaps(hDCScreen
, TECHNOLOGY
) == DT_RASDISPLAY
, "Not a display screen");
65 ::ReleaseDC(nsnull
,hDCScreen
);
68 // nothing else to do. I guess we could cache a bunch of information
69 // here, but we want to ask the device at runtime in case anything
74 nsScreenWin :: ~nsScreenWin()
76 // nothing to see here.
80 // addref, release, QI
81 NS_IMPL_ISUPPORTS1(nsScreenWin
, nsIScreen
)
85 nsScreenWin :: GetRect(PRInt32
*outLeft
, PRInt32
*outTop
, PRInt32
*outWidth
, PRInt32
*outHeight
)
91 info
.cbSize
= sizeof(MONITORINFO
);
92 success
= ::GetMonitorInfoW( (HMONITOR
)mScreen
, &info
);
94 *outLeft
= info
.rcMonitor
.left
;
95 *outTop
= info
.rcMonitor
.top
;
96 *outWidth
= info
.rcMonitor
.right
- info
.rcMonitor
.left
;
97 *outHeight
= info
.rcMonitor
.bottom
- info
.rcMonitor
.top
;
102 HDC hDCScreen
= ::GetDC(nsnull
);
103 NS_ASSERTION(hDCScreen
,"GetDC Failure");
105 *outTop
= *outLeft
= 0;
106 *outWidth
= ::GetDeviceCaps(hDCScreen
, HORZRES
);
107 *outHeight
= ::GetDeviceCaps(hDCScreen
, VERTRES
);
109 ::ReleaseDC(nsnull
, hDCScreen
);
117 nsScreenWin :: GetAvailRect(PRInt32
*outLeft
, PRInt32
*outTop
, PRInt32
*outWidth
, PRInt32
*outHeight
)
119 BOOL success
= FALSE
;
120 #ifdef WINCE_WINDOWS_MOBILE
122 memset(&sipInfo
, 0, sizeof(SIPINFO
));
123 sipInfo
.cbSize
= sizeof(SIPINFO
);
124 if (SipGetInfo(&sipInfo
) && !(sipInfo
.fdwFlags
& SIPF_OFF
)) {
125 *outLeft
= sipInfo
.rcVisibleDesktop
.left
;
126 *outTop
= sipInfo
.rcVisibleDesktop
.top
;
127 *outWidth
= sipInfo
.rcVisibleDesktop
.right
- sipInfo
.rcVisibleDesktop
.left
;
128 *outHeight
= sipInfo
.rcVisibleDesktop
.bottom
- sipInfo
.rcVisibleDesktop
.top
;
136 info
.cbSize
= sizeof(MONITORINFO
);
137 success
= ::GetMonitorInfoW( (HMONITOR
)mScreen
, &info
);
139 *outLeft
= info
.rcWork
.left
;
140 *outTop
= info
.rcWork
.top
;
141 *outWidth
= info
.rcWork
.right
- info
.rcWork
.left
;
142 *outHeight
= info
.rcWork
.bottom
- info
.rcWork
.top
;
148 ::SystemParametersInfo(SPI_GETWORKAREA
, 0, &workArea
, 0);
149 *outLeft
= workArea
.left
;
150 *outTop
= workArea
.top
;
151 *outWidth
= workArea
.right
- workArea
.left
;
152 *outHeight
= workArea
.bottom
- workArea
.top
;
162 nsScreenWin :: GetPixelDepth(PRInt32
*aPixelDepth
)
164 //XXX not sure how to get this info for multiple monitors, this might be ok...
165 HDC hDCScreen
= ::GetDC(nsnull
);
166 NS_ASSERTION(hDCScreen
,"GetDC Failure");
168 PRInt32 depth
= ::GetDeviceCaps(hDCScreen
, BITSPIXEL
);
170 // If a device uses 32 bits per pixel, it's still only using 8 bits
171 // per color component, which is what our callers want to know.
172 // (Some devices report 32 and some devices report 24.)
175 *aPixelDepth
= depth
;
177 ::ReleaseDC(nsnull
, hDCScreen
);
184 nsScreenWin :: GetColorDepth(PRInt32
*aColorDepth
)
186 return GetPixelDepth(aColorDepth
);