зеркало из https://github.com/mozilla/gecko-dev.git
r=mkaply, a=brendan Implement Screen and ScreenManager classes on OS/2 - not part of build yet
This commit is contained in:
Родитель
4011914be9
Коммит
9abf8f797f
|
@ -0,0 +1,112 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsScreenManagerOS2.h"
|
||||
#include "nsScreenOS2.h"
|
||||
|
||||
|
||||
nsScreenManagerOS2 :: nsScreenManagerOS2 ( )
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
// has changed.
|
||||
}
|
||||
|
||||
|
||||
nsScreenManagerOS2 :: ~nsScreenManagerOS2()
|
||||
{
|
||||
// nothing to see here.
|
||||
}
|
||||
|
||||
|
||||
// addref, release, QI
|
||||
NS_IMPL_ISUPPORTS(nsScreenManagerOS2, NS_GET_IID(nsIScreenManager))
|
||||
|
||||
|
||||
//
|
||||
// CreateNewScreenObject
|
||||
//
|
||||
// Utility routine. Creates a new screen object from the given device handle
|
||||
//
|
||||
// NOTE: For this "single-monitor" impl, we just always return the cached primary
|
||||
// screen. This should change when a multi-monitor impl is done.
|
||||
//
|
||||
nsIScreen*
|
||||
nsScreenManagerOS2 :: CreateNewScreenObject ( )
|
||||
{
|
||||
nsIScreen* retval = nsnull;
|
||||
if ( !mCachedMainScreen )
|
||||
mCachedMainScreen = new nsScreenOS2 ( );
|
||||
NS_IF_ADDREF(retval = mCachedMainScreen.get());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ScreenForRect
|
||||
//
|
||||
// Returns the screen that contains the rectangle. If the rect overlaps
|
||||
// multiple screens, it picks the screen with the greatest area of intersection.
|
||||
//
|
||||
// The coordinates are in pixels (not twips) and in screen coordinates.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerOS2 :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/,
|
||||
PRInt32 /*inHeight*/, nsIScreen **outScreen )
|
||||
{
|
||||
GetPrimaryScreen ( outScreen );
|
||||
return NS_OK;
|
||||
|
||||
} // ScreenForRect
|
||||
|
||||
|
||||
//
|
||||
// GetPrimaryScreen
|
||||
//
|
||||
// The screen with the menubar/taskbar. This shouldn't be needed very
|
||||
// often.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerOS2 :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
{
|
||||
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
||||
|
||||
//
|
||||
// GetNumberOfScreens
|
||||
//
|
||||
// Returns how many physical screens are available.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerOS2 :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
||||
{
|
||||
*aNumberOfScreens = 1;
|
||||
return NS_OK;
|
||||
|
||||
} // GetNumberOfScreens
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsScreenManagerOS2_h___
|
||||
#define nsScreenManagerOS2_h___
|
||||
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScreen.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class nsScreenManagerOS2 : public nsIScreenManager
|
||||
{
|
||||
public:
|
||||
nsScreenManagerOS2 ( );
|
||||
virtual ~nsScreenManagerOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
private:
|
||||
|
||||
nsIScreen* CreateNewScreenObject ( ) ;
|
||||
|
||||
// cache the primary screen object to avoid memory allocation every time
|
||||
nsCOMPtr<nsIScreen> mCachedMainScreen;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenManagerOS2_h___
|
|
@ -0,0 +1,101 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsScreenOS2.h"
|
||||
|
||||
#define INCL_PM
|
||||
#include <os2.h>
|
||||
|
||||
|
||||
nsScreenOS2 :: nsScreenOS2 ( )
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
// has changed.
|
||||
}
|
||||
|
||||
|
||||
nsScreenOS2 :: ~nsScreenOS2()
|
||||
{
|
||||
// nothing to see here.
|
||||
}
|
||||
|
||||
|
||||
// addref, release, QI
|
||||
NS_IMPL_ISUPPORTS(nsScreenOS2, NS_GET_IID(nsIScreen))
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
HDC hdc = WinQueryWindowDC(HWND_DESKTOP);
|
||||
LONG alArray[2];
|
||||
DevQueryCaps(hdc, CAPS_HORIZONTAL_RESOLUTION, CAPS_VERTICAL_RESOLUTION, alArray);
|
||||
|
||||
*outWidth = alArray[0];
|
||||
*outHeight = alArray[1];
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetRect
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
*outWidth = WinQuerySysValue( HWND_DESKTOP, SV_CXFULLSCREEN );
|
||||
*outHeight = WinQuerySysValue( HWND_DESKTOP, SV_CYFULLSCREEN );
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailRect
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
LONG lCap;
|
||||
HDC hdc = WinQueryWindowDC(HWND_DESKTOP);
|
||||
|
||||
DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, CAPS_COLOR_BITCOUNT, &lCap);
|
||||
|
||||
*aPixelDepth = (PRInt32)lCap;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenOS2 :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsScreenOS2_h___
|
||||
#define nsScreenOS2_h___
|
||||
|
||||
#include "nsIScreen.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
class nsScreenOS2 : public nsIScreen
|
||||
{
|
||||
public:
|
||||
nsScreenOS2 ( );
|
||||
virtual ~nsScreenOS2();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREEN
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // nsScreenOS2_h___
|
Загрузка…
Ссылка в новой задаче