Back to index

lightning-sunbird  0.9+nobinonly
nsScreenOS2.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsScreenOS2.h"
00039 #include "nsGfxDefs.h"
00040 
00041 nsScreenOS2 :: nsScreenOS2 (  )
00042 {
00043   // nothing else to do. I guess we could cache a bunch of information
00044   // here, but we want to ask the device at runtime in case anything
00045   // has changed.
00046 }
00047 
00048 
00049 nsScreenOS2 :: ~nsScreenOS2()
00050 {
00051   // nothing to see here.
00052 }
00053 
00054 
00055 // addref, release, QI
00056 NS_IMPL_ISUPPORTS1(nsScreenOS2, nsIScreen)
00057 
00058 
00059 NS_IMETHODIMP
00060 nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
00061 {
00062   LONG alArray[2];
00063 
00064   HPS hps = ::WinGetScreenPS( HWND_DESKTOP);
00065   HDC hdc = GFX (::GpiQueryDevice (hps), HDC_ERROR);
00066   ::DevQueryCaps(hdc, CAPS_WIDTH, 2, alArray);
00067   ::WinReleasePS(hps);
00068 
00069   *outTop = 0;
00070   *outLeft = 0;
00071   *outWidth = alArray[0];
00072   *outHeight = alArray[1];
00073 
00074 
00075   return NS_OK;
00076   
00077 } // GetRect
00078 
00079 
00080 NS_IMETHODIMP
00081 nsScreenOS2 :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
00082 {
00083   static APIRET rc = 0;
00084   static BOOL (APIENTRY * pfnQueryDesktopWorkArea)(HWND hwndDesktop, PWRECT pwrcWorkArea) = NULL;
00085 
00086   GetRect(outLeft, outTop, outWidth, outHeight);
00087 
00088   // This height is different based on whether or not 
00089   // "Show on top of maximed windows" is checked
00090   LONG lWorkAreaHeight = *outHeight;
00091 
00092   if ( !rc && !pfnQueryDesktopWorkArea )
00093   {
00094       HMODULE hmod = 0;
00095       rc = DosLoadModule( NULL, 0, "PMMERGE", &hmod );
00096       if ( !rc )
00097       {
00098           rc = DosQueryProcAddr( hmod, 5469, NULL, (PFN*) &pfnQueryDesktopWorkArea ); // WinQueryDesktopWorkArea
00099           DosFreeModule(hmod);
00100       }
00101   }
00102   if ( pfnQueryDesktopWorkArea && !rc )
00103   {
00104       RECTL rectl;
00105       pfnQueryDesktopWorkArea( HWND_DESKTOP, &rectl );
00106       lWorkAreaHeight = rectl.yTop - rectl.yBottom;
00107   }
00108 
00109   HWND hwndWarpCenter = WinWindowFromID( HWND_DESKTOP, 0x555 );
00110   if (hwndWarpCenter) {
00111     /* If "Show on top of maximized windows is checked" */
00112     if (lWorkAreaHeight != *outHeight) {
00113       SWP swp;
00114       WinQueryWindowPos( hwndWarpCenter, &swp );
00115       if (swp.y != 0) {
00116          /* WarpCenter is at the top */
00117          *outTop += swp.cy;
00118       }
00119       *outHeight -= swp.cy;
00120     }
00121   }
00122 
00123   return NS_OK;
00124   
00125 } // GetAvailRect
00126 
00127 
00128 NS_IMETHODIMP 
00129 nsScreenOS2 :: GetPixelDepth(PRInt32 *aPixelDepth)
00130 {
00131   LONG lCap;
00132 
00133   HPS hps = ::WinGetScreenPS( HWND_DESKTOP);
00134   HDC hdc = GFX (::GpiQueryDevice (hps), HDC_ERROR);
00135 
00136   GFX (::DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, &lCap), FALSE);
00137 
00138   *aPixelDepth = (PRInt32)lCap;
00139 
00140   
00141   ::WinReleasePS(hps);
00142 
00143   return NS_OK;
00144 
00145 } // GetPixelDepth
00146 
00147 
00148 NS_IMETHODIMP 
00149 nsScreenOS2 :: GetColorDepth(PRInt32 *aColorDepth)
00150 {
00151   return GetPixelDepth ( aColorDepth );
00152 
00153 } // GetColorDepth
00154 
00155