mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Added support for creating a postscript device context for printing under GTK.
Sanitized the GTK nsDeviceContextSpecFactoryG, nsRenderingContextPS, nsDeviceContextPS, and nsDeviceContextSpecG by removing WIN32 dependencies. Added checks for null widgets in nsWidget and nsScrollbar GTK implementations.
This commit is contained in:
parent
61d53b0da9
commit
59fd81ffb1
@ -75,6 +75,7 @@ gfx/Makefile
|
||||
gfx/public/Makefile
|
||||
gfx/src/Makefile
|
||||
gfx/src/gtk/Makefile
|
||||
gfx/src/ps/Makefile
|
||||
gfx/src/motif/Makefile
|
||||
gfx/src/rhapsody/Makefile
|
||||
gfx/tests/Makefile
|
||||
|
@ -24,7 +24,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = $(MOZ_TOOLKIT)
|
||||
DIRS = ps $(MOZ_TOOLKIT)
|
||||
|
||||
LIBRARY_NAME = raptorgfx
|
||||
|
||||
|
@ -28,7 +28,7 @@ LIBRARY_NAME = gfxgtk
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
REQUIRES=util img xpcom raptor netlib
|
||||
REQUIRES=util img xpcom raptor netlib ps
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXONXP
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
@ -37,6 +37,8 @@ LLIBS+=$(DIST)/lib/libxpcom.a $(DIST)/lib/libraptorbase.a $(DIST)/lib/libraptorg
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextGTK.cpp \
|
||||
nsDeviceContextSpecFactoryG.cpp \
|
||||
nsDeviceContextSpecG.cpp \
|
||||
nsFontMetricsGTK.cpp \
|
||||
nsGfxFactoryGTK.cpp \
|
||||
nsRenderingContextGTK.cpp \
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "nsDeviceContextGTK.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "../ps/nsDeviceContextPS.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
@ -277,7 +279,11 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PR
|
||||
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
// Create a Postscript device context
|
||||
aContext = new nsDeviceContextPS();
|
||||
((nsDeviceContextPS *)aContext)->SetSpec(aDevice);
|
||||
NS_ADDREF(aDevice);
|
||||
return((nsDeviceContextPS *) aContext)->Init((nsIDeviceContext*)aContext, (nsIDeviceContext*)this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(void)
|
||||
|
@ -41,9 +41,9 @@ static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTO
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryMac, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryMac)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryMac)
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the device context spec factory
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryGTK();
|
||||
virtual ~nsDeviceContextSpecFactoryGTK();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define nsDeviceContextSpecG_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextG.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
|
||||
{
|
||||
|
@ -27,7 +27,8 @@
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsDeviceContextGTK.h"
|
||||
#include "nsRegionGTK.h"
|
||||
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#include "nsDeviceContextSpecFactoryG.h"
|
||||
|
||||
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
|
||||
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
|
||||
@ -38,6 +39,10 @@ static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
|
||||
|
||||
|
||||
class nsGfxFactoryGTK : public nsIFactory
|
||||
{
|
||||
public:
|
||||
@ -138,6 +143,16 @@ nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
|
||||
else if (mClassID.Equals(kCRegion)) {
|
||||
inst = (nsISupports *)new nsRegionGTK();
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContextSpec)) {
|
||||
nsDeviceContextSpecGTK* dcs;
|
||||
NS_NEWXPCOM(dcs, nsDeviceContextSpecGTK);
|
||||
inst = (nsISupports *)dcs;
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
|
||||
nsDeviceContextSpecFactoryGTK* dcs;
|
||||
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryGTK);
|
||||
inst = (nsISupports *)dcs;
|
||||
}
|
||||
|
||||
if (inst == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
51
gfx/src/ps/Makefile.in
Normal file
51
gfx/src/ps/Makefile.in
Normal file
@ -0,0 +1,51 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = gfxps
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
REQUIRES=util img xpcom raptor netlib
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXONXP
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
|
||||
LLIBS+=$(DIST)/lib/libxpcom.a $(DIST)/lib/libraptorbase.a $(DIST)/lib/libraptorgfx.a
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextPS.cpp \
|
||||
nsFontMetricsPS.cpp \
|
||||
nsRenderingContextPS.cpp \
|
||||
nsPostScriptObj.cpp \
|
||||
|
||||
CSRCS = \
|
||||
font_metrics.c \
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -72,15 +72,13 @@ NS_IMPL_RELEASE(nsDeviceContextPS)
|
||||
* See documentation in nsDeviceContextPS.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: Init(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext, HDC aTheDC)
|
||||
NS_IMETHODIMP nsDeviceContextPS :: Init(nsIDeviceContext *aCreatingDeviceContext,nsIDeviceContext *aPrinterContext)
|
||||
{
|
||||
float origscale, newscale;
|
||||
float t2d, a2d;
|
||||
|
||||
mDepth = 1; // just for arguments sake
|
||||
|
||||
mDC = aTheDC;
|
||||
|
||||
mTwipsToPixels = (float)72.0/(float)NSIntPointsToTwips(72);
|
||||
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
||||
|
||||
@ -128,7 +126,6 @@ nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
{
|
||||
|
||||
aSupportsWidgets = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -139,9 +136,9 @@ NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidget
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
|
||||
{
|
||||
// WINDOWS CALLS, NEED TO BE THE NATIVE PLATFORMS METRICS
|
||||
aWidth = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits;
|
||||
aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits;
|
||||
//XXX: Hardcoded values for Postscript
|
||||
aWidth = 20;
|
||||
aHeight = 20;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
@ -225,7 +222,6 @@ NS_IMETHODIMP nsDeviceContextPS :: CheckFontExistence(const nsString& aFontName)
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPS :: GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
switch (anID) {
|
||||
case 0:
|
||||
|
@ -19,7 +19,9 @@
|
||||
#ifndef nsDeviceContextPS_h___
|
||||
#define nsDeviceContextPS_h___
|
||||
|
||||
#ifdef XP_PC
|
||||
#define WINTEST
|
||||
#endif
|
||||
|
||||
#ifdef WINTEST
|
||||
#include <windows.h>
|
||||
@ -76,10 +78,8 @@ public:
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics);
|
||||
NS_IMETHOD BeginDocument(void);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
|
||||
virtual void SetSpec(nsIDeviceContextSpec *aSpec);
|
||||
|
||||
protected:
|
||||
@ -101,7 +101,6 @@ public:
|
||||
HDC mDC; // this is temporary!!!
|
||||
#endif
|
||||
|
||||
|
||||
//friend nsDeviceContextWin; // need to be a friend of the class using us.
|
||||
};
|
||||
|
||||
|
@ -33,10 +33,12 @@ nsFontMetricsPS :: ~nsFontMetricsPS()
|
||||
mFont = nsnull;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (NULL != mFontHandle){
|
||||
::DeleteObject(mFontHandle);
|
||||
mFontHandle = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
mDeviceContext = nsnull;
|
||||
}
|
||||
@ -103,6 +105,7 @@ nsFontMetricsPS :: Destroy()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_PC
|
||||
static void
|
||||
MapGenericFamilyToFont(const nsString& aGenericFamily,
|
||||
nsIDeviceContext* aDC,
|
||||
@ -130,7 +133,9 @@ MapGenericFamilyToFont(const nsString& aGenericFamily,
|
||||
aFontFace.Truncate();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
struct FontEnumData {
|
||||
FontEnumData(nsIDeviceContext* aContext, TCHAR* aFaceName)
|
||||
{
|
||||
@ -140,7 +145,9 @@ struct FontEnumData {
|
||||
nsIDeviceContext* mContext;
|
||||
TCHAR* mFaceName;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
static PRBool
|
||||
FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
||||
{
|
||||
@ -162,10 +169,12 @@ FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsFontMetricsPS::RealizeFont()
|
||||
{
|
||||
#ifdef XP_PC
|
||||
// Fill in logFont structure; stolen from awt
|
||||
LOGFONT logFont;
|
||||
logFont.lfWidth = 0;
|
||||
@ -267,6 +276,7 @@ nsFontMetricsPS::RealizeFont()
|
||||
|
||||
if (NULL == mDeviceContext->mDC)
|
||||
::ReleaseDC(win, dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -351,6 +361,8 @@ nsFontMetricsPS :: GetFont(const nsFont *&aFont)
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPS::GetFontHandle(nsFontHandle &aHandle)
|
||||
{
|
||||
#ifdef XP_PC
|
||||
aHandle = mFontHandle;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
#ifndef nsFontMetricsPS_h__
|
||||
#define nsFontMetricsPS_h__
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsFont.h"
|
||||
@ -34,7 +36,7 @@ class nsFontMetricsPS : public nsIFontMetrics
|
||||
{
|
||||
public:
|
||||
nsFontMetricsPS();
|
||||
~nsFontMetricsPS();
|
||||
virtual ~nsFontMetricsPS();
|
||||
|
||||
void* operator new(size_t sz) {
|
||||
void* rv = new char[sz];
|
||||
@ -80,7 +82,9 @@ protected:
|
||||
nscoord mStrikeoutOffset;
|
||||
nscoord mUnderlineSize;
|
||||
nscoord mUnderlineOffset;
|
||||
#ifdef XP_WIN
|
||||
HFONT mFontHandle;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -100,6 +100,7 @@ GECKO_LIBS = \
|
||||
$(TOOLKIT_WIDGET_LIB) \
|
||||
-lraptorgfx \
|
||||
$(TOOLKIT_GFX_LIB) \
|
||||
-lgfxps \
|
||||
-lraptorhtml \
|
||||
$(TOOLKIT_BASE_LIB) \
|
||||
-lraptorhtmlpars \
|
||||
|
@ -106,8 +106,10 @@ nsresult nsScrollbar::QueryInterface (const nsIID & aIID, void **aInstancePtr)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange)
|
||||
{
|
||||
GTK_ADJUSTMENT (mAdjustment)->upper = (float) aEndRange;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
if (mAdjustment) {
|
||||
GTK_ADJUSTMENT (mAdjustment)->upper = (float) aEndRange;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -119,7 +121,11 @@ NS_METHOD nsScrollbar::SetMaxRange (PRUint32 aEndRange)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange)
|
||||
{
|
||||
aMaxRange = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->upper;
|
||||
if (mAdjustment)
|
||||
aMaxRange = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->upper;
|
||||
else
|
||||
aMaxRange = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -131,7 +137,8 @@ NS_METHOD nsScrollbar::GetMaxRange (PRUint32 & aMaxRange)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos)
|
||||
{
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), (float) aPos);
|
||||
if (mAdjustment)
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), (float) aPos);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -143,7 +150,11 @@ NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos)
|
||||
{
|
||||
aPos = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->value;
|
||||
if (mAdjustment)
|
||||
aPos = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->value;
|
||||
else
|
||||
aPos = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -157,9 +168,11 @@ NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize)
|
||||
{
|
||||
if (aSize > 0)
|
||||
{
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_increment = (float) aSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_size = (float) aSize;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
if (mAdjustment) {
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_increment = (float) aSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_size = (float) aSize;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -172,7 +185,11 @@ NS_METHOD nsScrollbar::SetThumbSize (PRUint32 aSize)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetThumbSize (PRUint32 & aThumbSize)
|
||||
{
|
||||
aThumbSize = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->page_size;
|
||||
if (mAdjustment)
|
||||
aThumbSize = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->page_size;
|
||||
else
|
||||
aThumbSize = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -186,8 +203,10 @@ NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement)
|
||||
{
|
||||
if (aLineIncrement > 0)
|
||||
{
|
||||
GTK_ADJUSTMENT (mAdjustment)->step_increment = (float) aLineIncrement;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
if (mAdjustment) {
|
||||
GTK_ADJUSTMENT (mAdjustment)->step_increment = (float) aLineIncrement;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (mAdjustment), "changed");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -200,7 +219,12 @@ NS_METHOD nsScrollbar::SetLineIncrement (PRUint32 aLineIncrement)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc)
|
||||
{
|
||||
aLineInc = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->step_increment;
|
||||
if (mAdjustment) {
|
||||
aLineInc = (PRUint32) GTK_ADJUSTMENT (mAdjustment)->step_increment;
|
||||
}
|
||||
else
|
||||
aLineInc = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -213,20 +237,22 @@ NS_METHOD nsScrollbar::GetLineIncrement (PRUint32 & aLineInc)
|
||||
NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize,
|
||||
PRUint32 aPosition, PRUint32 aLineIncrement)
|
||||
{
|
||||
int thumbSize = (((int) aThumbSize) > 0 ? aThumbSize : 1);
|
||||
int maxRange = (((int) aMaxRange) > 0 ? aMaxRange : 10);
|
||||
int mLineIncrement = (((int) aLineIncrement) > 0 ? aLineIncrement : 1);
|
||||
if (mAdjustment) {
|
||||
int thumbSize = (((int) aThumbSize) > 0 ? aThumbSize : 1);
|
||||
int maxRange = (((int) aMaxRange) > 0 ? aMaxRange : 10);
|
||||
int mLineIncrement = (((int) aLineIncrement) > 0 ? aLineIncrement : 1);
|
||||
|
||||
int maxPos = maxRange - thumbSize;
|
||||
int pos = ((int) aPosition) > maxPos ? maxPos - 1 : ((int) aPosition);
|
||||
int maxPos = maxRange - thumbSize;
|
||||
int pos = ((int) aPosition) > maxPos ? maxPos - 1 : ((int) aPosition);
|
||||
|
||||
GTK_ADJUSTMENT (mAdjustment)->lower = 0;
|
||||
GTK_ADJUSTMENT (mAdjustment)->upper = maxRange;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_size = thumbSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_increment = thumbSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->step_increment = mLineIncrement;
|
||||
// this will emit the changed signal for us
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), pos);
|
||||
GTK_ADJUSTMENT (mAdjustment)->lower = 0;
|
||||
GTK_ADJUSTMENT (mAdjustment)->upper = maxRange;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_size = thumbSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->page_increment = thumbSize;
|
||||
GTK_ADJUSTMENT (mAdjustment)->step_increment = mLineIncrement;
|
||||
// this will emit the changed signal for us
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (mAdjustment), pos);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ nsIWidget *nsWidget::GetParent(void)
|
||||
NS_METHOD nsWidget::Show(PRBool bState)
|
||||
{
|
||||
if (!mWidget)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_OK; // Will be null durring printing
|
||||
|
||||
if (bState)
|
||||
::gtk_widget_show(mWidget);
|
||||
@ -163,9 +163,14 @@ NS_METHOD nsWidget::Show(PRBool bState)
|
||||
|
||||
NS_METHOD nsWidget::IsVisible(PRBool &aState)
|
||||
{
|
||||
gint RealVis = GTK_WIDGET_VISIBLE(mWidget);
|
||||
aState = mShown;
|
||||
g_return_val_if_fail(RealVis == mShown, NS_ERROR_FAILURE);
|
||||
if (mWidget) {
|
||||
gint RealVis = GTK_WIDGET_VISIBLE(mWidget);
|
||||
aState = mShown;
|
||||
g_return_val_if_fail(RealVis == mShown, NS_ERROR_FAILURE);
|
||||
}
|
||||
else
|
||||
aState = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -179,7 +184,8 @@ NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY)
|
||||
{
|
||||
mBounds.x = aX;
|
||||
mBounds.y = aY;
|
||||
::gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY);
|
||||
if (mWidget)
|
||||
::gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -192,11 +198,13 @@ NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
||||
#endif
|
||||
mBounds.width = aWidth;
|
||||
mBounds.height = aHeight;
|
||||
::gtk_widget_set_usize(mWidget, aWidth, aHeight);
|
||||
if (mWidget) {
|
||||
::gtk_widget_set_usize(mWidget, aWidth, aHeight);
|
||||
|
||||
if (aRepaint)
|
||||
if (GTK_WIDGET_VISIBLE (mWidget))
|
||||
::gtk_widget_queue_draw (mWidget);
|
||||
if (aRepaint)
|
||||
if (GTK_WIDGET_VISIBLE (mWidget))
|
||||
::gtk_widget_queue_draw (mWidget);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -274,7 +282,8 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWidget::Enable(PRBool bState)
|
||||
{
|
||||
::gtk_widget_set_sensitive(mWidget, bState);
|
||||
if (mWidget)
|
||||
::gtk_widget_set_sensitive(mWidget, bState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -285,7 +294,8 @@ NS_METHOD nsWidget::Enable(PRBool bState)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWidget::SetFocus(void)
|
||||
{
|
||||
::gtk_widget_grab_focus(mWidget);
|
||||
if (mWidget)
|
||||
::gtk_widget_grab_focus(mWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -389,7 +399,7 @@ NS_METHOD nsWidget::SetCursor(nsCursor aCursor)
|
||||
NS_METHOD nsWidget::Invalidate(PRBool aIsSynchronous)
|
||||
{
|
||||
if (mWidget == nsnull) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK; // mWidget will be null during printing.
|
||||
}
|
||||
|
||||
if (!GTK_IS_WIDGET (mWidget)) {
|
||||
@ -413,7 +423,7 @@ NS_METHOD nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
||||
GdkRectangle nRect;
|
||||
|
||||
if (mWidget == nsnull) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK; // mWidget is null during printing
|
||||
}
|
||||
|
||||
if (!GTK_IS_WIDGET (mWidget)) {
|
||||
@ -441,6 +451,9 @@ NS_METHOD nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
||||
|
||||
NS_METHOD nsWidget::Update(void)
|
||||
{
|
||||
if (! mWidget)
|
||||
return NS_OK;
|
||||
|
||||
GdkRectangle foo;
|
||||
foo.width = mBounds.width;
|
||||
foo.height = mBounds.height;
|
||||
|
@ -41,9 +41,9 @@ static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTO
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryMac, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryMac)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryMac)
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the device context spec factory
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryGTK();
|
||||
virtual ~nsDeviceContextSpecFactoryGTK();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define nsDeviceContextSpecG_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextG.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ LIBS = \
|
||||
$(TOOLKIT_WIDGET_LIB)\
|
||||
-lraptorgfx \
|
||||
$(TOOLKIT_GFX_LIB)\
|
||||
-lgfxps \
|
||||
$(TOOLKIT_BASE_LIB)\
|
||||
-lreg \
|
||||
-labouturl \
|
||||
|
Loading…
Reference in New Issue
Block a user