Compare commits

..

2 Commits

Author SHA1 Message Date
pavlov%pavlov.net
33a0a6fec0 update to use ns_quicksort so that this branch builds
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@31772 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-15 21:56:51 +00:00
(no author)
58b1c92ba4 This commit was manufactured by cvs2svn to create branch 'FAST-GTK-GFX'.
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@28588 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-22 00:07:41 +00:00
403 changed files with 15501 additions and 16020 deletions

View File

@@ -0,0 +1,53 @@
#!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 = gfxgtk
MODULE=raptor
REQUIRES=util img xpcom raptor netlib ps
DEFINES += -D_IMPL_NS_GFXONXP
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsDrawingSurfaceGTK.cpp \
nsDeviceContextGTK.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsFontMetricsGTK.cpp \
nsGfxFactoryGTK.cpp \
nsRenderingContextGTK.cpp \
nsImageGTK.cpp \
nsRegionGTK.cpp
CSRCS = \
nsPrintdGTK.c
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,375 @@
/* -*- 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.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.
*/
#include <math.h>
#include "nspr.h"
#include "il_util.h"
#include "nsDeviceContextGTK.h"
#include "nsGfxCIID.h"
#include "../ps/nsDeviceContextPS.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
#define GDK_COLOR_TO_NS_RGB(c) \
((nscolor) NS_RGB(c.red, c.green, c.blue))
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsDeviceContextGTK::nsDeviceContextGTK()
{
NS_INIT_REFCNT();
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mNumCells = 0;
}
nsDeviceContextGTK::~nsDeviceContextGTK()
{
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextGTK, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextGTK)
NS_IMPL_RELEASE(nsDeviceContextGTK)
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
{
GdkVisual *vis;
GtkRequisition req;
GtkWidget *sb;
mWidget = aNativeWidget;
// Compute dpi of display
float screenWidth = float(::gdk_screen_width());
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
nscoord dpi = nscoord(screenWidth / screenWidthIn);
// Now for some wacky heuristics.
if (dpi < 84) dpi = 72;
else if (dpi < 108) dpi = 96;
else if (dpi < 132) dpi = 120;
mTwipsToPixels = float(dpi) / float(NSIntPointsToTwips(72));
mPixelsToTwips = 1.0f / mTwipsToPixels;
#if 0
mTwipsToPixels = ( ((float)::gdk_screen_width()) /
((float)::gdk_screen_width_mm()) * 25.4) /
(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f / mTwipsToPixels;
#endif
vis = gdk_rgb_get_visual();
mDepth = vis->depth;
sb = gtk_vscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarWidth = req.width;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
sb = gtk_hscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarHeight = req.height;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once) {
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", dpi, mTwipsToPixels, mPixelsToTwips,mDepth);
once = PR_FALSE;
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceGTK *surf;
// to call init for this, we need to have a valid nsDrawingSurfaceGTK created
pContext = new nsRenderingContextGTK();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceGTK
surf = new nsDrawingSurfaceGTK();
if (nsnull != surf)
{
GdkDrawable *win = nsnull;
// FIXME
if (GTK_IS_LAYOUT((GtkWidget*)mWidget))
win = (GdkDrawable*)gdk_window_ref(GTK_LAYOUT((GtkWidget*)mWidget)->bin_window);
else
win = (GdkDrawable*)gdk_window_ref(((GtkWidget*)mWidget)->window);
GdkGC *gc = gdk_gc_new(win);
// init the nsDrawingSurfaceGTK
rv = surf->Init(win,gc);
if (NS_OK == rv)
// Init the nsRenderingContextGTK
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = mScrollbarWidth * mPixelsToTwips;
aHeight = mScrollbarHeight * mPixelsToTwips;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
{
nsresult status = NS_OK;
GtkStyle *style = gtk_style_new(); // get the default styles
switch (anID) {
//---------
// Colors
//---------
case eSystemAttr_Color_WindowBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WindowForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_WidgetSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_Widget3DHighlight:
*aInfo->mColor = NS_RGB(0xa0,0xa0,0xa0);
break;
case eSystemAttr_Color_Widget3DShadow:
*aInfo->mColor = NS_RGB(0x40,0x40,0x40);
break;
case eSystemAttr_Color_TextBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_TextSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->text[GTK_STATE_SELECTED]);
break;
//---------
// Size
//---------
case eSystemAttr_Size_ScrollbarHeight:
aInfo->mSize = mScrollbarHeight;
break;
case eSystemAttr_Size_ScrollbarWidth:
aInfo->mSize = mScrollbarWidth;
break;
case eSystemAttr_Size_WindowTitleHeight:
aInfo->mSize = 0;
break;
case eSystemAttr_Size_WindowBorderWidth:
aInfo->mSize = style->klass->xthickness;
break;
case eSystemAttr_Size_WindowBorderHeight:
aInfo->mSize = style->klass->ythickness;
break;
case eSystemAttr_Size_Widget3DBorder:
aInfo->mSize = 4;
break;
//---------
// Fonts
//---------
case eSystemAttr_Font_Caption:
case eSystemAttr_Font_Icon:
case eSystemAttr_Font_Menu:
case eSystemAttr_Font_MessageBox:
case eSystemAttr_Font_SmallCaption:
case eSystemAttr_Font_StatusBar:
case eSystemAttr_Font_Tooltips:
case eSystemAttr_Font_Widget:
status = NS_ERROR_FAILURE;
break;
} // switch
gtk_style_unref(style);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDrawingSurface(nsIRenderingContext &aContext,
nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
aPixel = ::gdk_rgb_xpixel_from_rgb (NS_TO_GDK_RGB(aColor));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CheckFontExistence(const nsString& aFontName)
{
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == wildstring)
return NS_ERROR_UNEXPECTED;
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
char* fontName = aFontName.ToNewCString();
PR_snprintf(wildstring, namelen + 200,
"*-%s-*-*-normal--*-*-%d-%d-*-*-*",
fontName, dpi, dpi);
delete [] fontName;
fnames = ::XListFontsWithInfo(GDK_DISPLAY(), wildstring, 1, &numnames, &fonts);
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
aWidth = 1;
aHeight = 1;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
// 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)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDepth(PRUint32& aDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
gint rgb_depth = rgb_visual->depth;
aDepth = (PRUint32) rgb_depth;
return NS_OK;
}

View File

@@ -0,0 +1,79 @@
/* -*- 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.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.
*/
#ifndef nsDeviceContextGTK_h___
#define nsDeviceContextGTK_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "nsRenderingContextGTK.h"
class nsDeviceContextGTK : public DeviceContextImpl
{
public:
nsDeviceContextGTK();
virtual ~nsDeviceContextGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(void);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
private:
PRUint32 mDepth;
PRBool mWriteable;
nsPaletteInfo mPaletteInfo;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
};
#endif /* nsDeviceContextGTK_h___ */

View File

@@ -0,0 +1,77 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDeviceContextSpecFactoryG.h"
#include "nsDeviceContextSpecG.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
{
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
{
}
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
nsIDeviceContextSpec *devSpec = nsnull;
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
if (nsnull != devSpec){
if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){
aNewSpec = devSpec;
rv = NS_OK;
}
}
return rv;
}

View File

@@ -0,0 +1,41 @@
/* -*- 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.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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDeviceContextSpecFactoryG_h___
#define nsDeviceContextSpecFactoryG_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryGTK : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();
};
#endif

View File

@@ -0,0 +1,197 @@
/* -*- 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.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.
*/
#include "nsDeviceContextSpecG.h"
#include "prenv.h" /* for PR_GetEnv */
//#include "prmem.h"
//#include "plstr.h"
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecGTK
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecGTK
* @update dc 2/15/98
*/
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#if 0
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecGTK, kDeviceContextSpecIID)
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
#endif
NS_IMETHODIMP nsDeviceContextSpecGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDeviceContextSpecIID))
{
nsIDeviceContextSpec* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDeviceContextSpecPSIID))
{
nsIDeviceContextSpecPS* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDeviceContextSpec* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
{
char *path;
// XXX these settings should eventually come out of preferences
mPrData.toPrinter = PR_TRUE;
mPrData.fpf = PR_TRUE;
mPrData.grayscale = PR_FALSE;
mPrData.size = NS_LETTER_SIZE;
sprintf( mPrData.command, "lpr" );
// PWD, HOME, or fail
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
strcpy( mPrData.path, "netscape.ps" );
if ( path != (char *) NULL )
sprintf( mPrData.path, "%s/netscape.ps", path );
else
return NS_ERROR_FAILURE;
::UnixPrDialog( &mPrData );
if ( mPrData.cancel == PR_TRUE )
return NS_ERROR_FAILURE;
else
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetToPrinter( PRBool &aToPrinter )
{
aToPrinter = mPrData.toPrinter;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetFirstPageFirst ( PRBool &aFpf )
{
aFpf = mPrData.fpf;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetGrayscale ( PRBool &aGrayscale )
{
aGrayscale = mPrData.grayscale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetSize ( int &aSize )
{
aSize = mPrData.size;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetTopMargin ( float &value )
{
value = mPrData.top;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetBottomMargin ( float &value )
{
value = mPrData.bottom;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetRightMargin ( float &value )
{
value = mPrData.right;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLeftMargin ( float &value )
{
value = mPrData.left;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetCommand ( char **aCommand )
{
*aCommand = &mPrData.command[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPath ( char **aPath )
{
*aPath = &mPrData.path[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetUserCancelled( PRBool &aCancel )
{
aCancel = mPrData.cancel;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 2/15/98
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: ClosePrintManager()
{
return NS_OK;
}

View File

@@ -0,0 +1,97 @@
/* -*- 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.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.
*/
#ifndef nsDeviceContextSpecG_h___
#define nsDeviceContextSpecG_h___
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecG.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsPrintdGTK.h"
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(PRBool aQuiet);
/**
* Closes the printmanager if it is open.
* @update dc 2/13/98
* @update syd 3/20/99
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
NS_IMETHOD GetSize ( int &aSize );
NS_IMETHOD GetTopMargin ( float &value );
NS_IMETHOD GetBottomMargin ( float &value );
NS_IMETHOD GetLeftMargin ( float &value );
NS_IMETHOD GetRightMargin ( float &value );
NS_IMETHOD GetCommand ( char **aCommand );
NS_IMETHOD GetPath ( char **aPath );
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
protected:
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 2/16/98
*/
virtual ~nsDeviceContextSpecGTK();
protected:
UnixPrData mPrData;
};
#endif

View File

@@ -0,0 +1,367 @@
/* -*- 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.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.
*/
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
#define USE_SHM
#endif
//#define USE_SHM
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#ifdef USE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif /* USE_SHM */
#include "nsDrawingSurfaceGTK.h"
static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID);
static NS_DEFINE_IID(kIDrawingSurfaceGTKIID, NS_IDRAWING_SURFACE_GTK_IID);
nsDrawingSurfaceGTK :: nsDrawingSurfaceGTK()
{
NS_INIT_REFCNT();
GdkVisual *v;
mPixmap = nsnull;
mGC = nsnull;
mDepth = 0;
mWidth = mHeight = 0;
mFlags = 0;
mImage = nsnull;
mLockWidth = mLockHeight = 0;
mLockFlags = 0;
mLocked = PR_FALSE;
v = ::gdk_rgb_get_visual();
mPixFormat.mRedMask = v->red_mask;
mPixFormat.mGreenMask = v->green_mask;
mPixFormat.mBlueMask = v->blue_mask;
// FIXME
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedShift = v->red_shift;
mPixFormat.mGreenShift = v->green_shift;
mPixFormat.mBlueShift = v->blue_shift;
// FIXME
mPixFormat.mAlphaShift = 0;
mDepth = v->depth;
}
nsDrawingSurfaceGTK :: ~nsDrawingSurfaceGTK()
{
if (mPixmap)
::gdk_pixmap_unref(mPixmap);
if (mImage)
::gdk_image_destroy(mImage);
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDrawingSurfaceIID))
{
nsIDrawingSurface* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDrawingSurfaceGTKIID))
{
nsDrawingSurfaceGTK* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDrawingSurface* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDrawingSurfaceGTK);
NS_IMPL_RELEASE(nsDrawingSurfaceGTK);
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#if 0
g_print("nsDrawingSurfaceGTK::Lock() called\n" \
" aX = %i, aY = %i,\n" \
" aWidth = %i, aHeight = %i,\n" \
" aBits, aStride, aWidthBytes,\n" \
" aFlags = %i\n", aX, aY, aWidth, aHeight, aFlags);
#endif
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
#ifdef USE_SHM
if (gdk_get_use_xshm())
{
mImage = gdk_image_new(GDK_IMAGE_FASTEST,
gdk_rgb_get_visual(),
mLockWidth,
mLockHeight);
XShmGetImage(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(mPixmap),
GDK_IMAGE_XIMAGE(mImage),
mLockX, mLockY,
0xFFFFFFFF);
gdk_flush();
}
else
{
#endif /* USE_SHM */
mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
#ifdef USE_SHM
}
#endif /* USE_SHM */
*aBits = GDK_IMAGE_XIMAGE(mImage)->data;
*aWidthBytes = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
*aStride = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
#if 0
int bytes_per_line = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
//
// All this code is a an attempt to set the stride width properly.
// Needs to be cleaned up alot. For now, it will only work in the
// case where aWidthBytes and aStride are the same. One is assigned to
// the other.
//
*aWidthBytes = mImage->bpl;
*aStride = mImage->bpl;
int width_in_pixels = *aWidthBytes << 8;
int bitmap_pad = GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
int depth = GDK_IMAGE_XIMAGE(mImage)->depth;
#define RASWIDTH8(width, bpp) (width)
#define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
#define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
switch(bitmap_pad)
{
case 8:
*aStride = RASWIDTH8(aWidth,bitmap_pad);
break;
case 16:
*aStride = bytes_per_line;
*aStride = RASWIDTH16(aWidth,bitmap_pad);
break;
case 32:
*aStride = bytes_per_line;
*aStride = RASWIDTH32(aWidth,bitmap_pad);
break;
default:
NS_ASSERTION(nsnull,"something got screwed");
}
*aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
*aWidthBytes = mImage->bpl;
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
{
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
#if 0
g_print("gdk_draw_image(pixmap=%p,lockx=%d,locky=%d,lockw=%d,lockh=%d)\n",
mPixmap,
mLockX, mLockY,
mLockWidth, mLockHeight);
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
}
// FIXME if we are using shared mem, we shouldn't destroy the image...
if (mImage)
::gdk_image_destroy(mImage);
mImage = nsnull;
mLocked = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsPixelAddressable(PRBool *aAddressable)
{
// FIXME
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkDrawable *aDrawable, GdkGC *aGC)
{
mGC = aGC;
mPixmap = aDrawable;
// this is definatly going to be on the screen, as it will be the window of a
// widget or something.
mIsOffscreen = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkGC *aGC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
// ::g_return_val_if_fail (aGC != nsnull, NS_ERROR_FAILURE);
// ::g_return_val_if_fail ((aWidth > 0) && (aHeight > 0), NS_ERROR_FAILURE);
mGC = aGC;
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
mPixmap = ::gdk_pixmap_new(nsnull, mWidth, mHeight, mDepth);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetGC(GdkGC *aGC)
{
aGC = ::gdk_gc_ref(mGC);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: ReleaseGC(void)
{
::gdk_gc_unref(mGC);
return NS_OK;
}
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *nsDrawingSurfaceGTK::GetGC(void)
{
return mGC;
}
GdkDrawable *nsDrawingSurfaceGTK::GetDrawable(void)
{
return mPixmap;
}

View File

@@ -0,0 +1,85 @@
/* -*- 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.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.
*/
#ifndef nsDrawingSurfaceGTK_h___
#define nsDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceGTK.h"
#include <gtk/gtk.h>
class nsDrawingSurfaceGTK : public nsIDrawingSurface,
public nsIDrawingSurfaceGTK
{
public:
nsDrawingSurfaceGTK();
virtual ~nsDrawingSurfaceGTK();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
//nsIDrawingSurfaceGTK interface
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC);
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags);
/* get the GC and manage the GdkGC's refcount */
NS_IMETHOD GetGC(GdkGC *aGC);
NS_IMETHOD ReleaseGC(void);
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *GetGC(void);
GdkDrawable *GetDrawable(void);
private:
/* general */
GdkPixmap *mPixmap;
GdkGC *mGC;
gint mDepth;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
GdkImage *mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
/* -*- 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.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.
*/
#ifndef nsFontMetricsGTK_h__
#define nsFontMetricsGTK_h__
#include "nsIFontMetrics.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsDeviceContextGTK.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define FONT_SWITCHING
#ifdef FONT_SWITCHING
#ifdef ADD_GLYPH
#undef ADD_GLYPH
#endif
#define ADD_GLYPH(map, g) (map)[(g) >> 3] |= (1 << ((g) & 7))
#ifdef FONT_HAS_GLYPH
#undef FONT_HAS_GLYPH
#endif
#define FONT_HAS_GLYPH(map, g) (((map)[(g) >> 3] >> ((g) & 7)) & 1)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
typedef gint (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
const PRUnichar* aSrcBuf, PRUint32 aSrcLen, PRUint8* aDestBuf,
PRUint32 aDestLen);
struct nsFontCharSet;
class nsFontMetricsGTK;
struct nsFontGTK
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void LoadFont(nsFontCharSet* aCharSet, nsFontMetricsGTK* aMetrics);
GdkFont* mFont;
PRUint8* mMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
PRUint16 mSize;
PRUint16 mActualSize;
PRInt16 mBaselineAdjust;
};
struct nsFontStretch;
struct nsFontFamily;
typedef struct nsFontSearch nsFontSearch;
#endif /* FONT_SWITCHING */
class nsFontMetricsGTK : public nsIFontMetrics
{
public:
nsFontMetricsGTK();
virtual ~nsFontMetricsGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
#ifdef FONT_SWITCHING
nsFontGTK* FindFont(PRUnichar aChar);
static gint GetWidth(nsFontGTK* aFont, const PRUnichar* aString,
PRUint32 aLength);
static void DrawString(nsDrawingSurfaceGTK* aSurface, nsFontGTK* aFont,
nscoord aX, nscoord aY, const PRUnichar* aString,
PRUint32 aLength);
static void InitFonts(void);
friend void PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
nsFontCharSet* aCharSet);
friend void TryCharSet(nsFontSearch* aSearch, nsFontCharSet* aCharSet);
friend void TryFamily(nsFontSearch* aSearch, nsFontFamily* aFamily);
friend struct nsFontGTK;
nsFontGTK **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsString *mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
#endif /* FONT_SWITCHING */
protected:
char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired);
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
GdkFont *mFontHandle;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
#ifdef FONT_SWITCHING
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
#endif /* FONT_SWITCHING */
};
#endif

View File

@@ -0,0 +1,205 @@
/* -*- 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.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.
*/
#include <gtk/gtk.h>
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsGTK.h"
#include "nsRenderingContextGTK.h"
#include "nsImageGTK.h"
#include "nsDeviceContextGTK.h"
#include "nsRegionGTK.h"
#include "nsBlender.h"
#include "nsDeviceContextSpecG.h"
#include "nsDeviceContextSpecFactoryG.h"
#include "nsIDeviceContextSpecPS.h"
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_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:
// nsISupports methods
NS_IMETHOD QueryInterface(const nsIID &aIID,
void **aResult);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsGfxFactoryGTK(const nsCID &aClass);
virtual ~nsGfxFactoryGTK();
private:
nsrefcnt mRefCnt;
nsCID mClassID;
};
nsGfxFactoryGTK::nsGfxFactoryGTK(const nsCID &aClass)
{
mRefCnt = 0;
mClassID = aClass;
}
nsGfxFactoryGTK::~nsGfxFactoryGTK()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryGTK::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
AddRef(); // Increase reference count for caller
return NS_OK;
}
nsrefcnt nsGfxFactoryGTK::AddRef()
{
return ++mRefCnt;
}
nsrefcnt nsGfxFactoryGTK::Release()
{
if (--mRefCnt == 0) {
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsISupports *inst = nsnull;
if (mClassID.Equals(kCFontMetrics)) {
inst = (nsISupports *)new nsFontMetricsGTK();
}
else if (mClassID.Equals(kCDeviceContext)) {
inst = (nsISupports *)new nsDeviceContextGTK();
}
else if (mClassID.Equals(kCRenderingContext)) {
inst = (nsISupports *)new nsRenderingContextGTK();
}
else if (mClassID.Equals(kCImage)) {
inst = (nsISupports *)new nsImageGTK();
}
else if (mClassID.Equals(kCRegion)) {
inst = (nsISupports *)new nsRegionGTK();
}
else if (mClassID.Equals(kCBlender)) {
inst = (nsISupports *)new nsBlender;
}
else if (mClassID.Equals(kCDeviceContextSpec)) {
nsDeviceContextSpecGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecGTK);
inst = (nsISupports *)((nsIDeviceContextSpecPS *)dcs);
}
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
nsDeviceContextSpecFactoryGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryGTK);
inst = (nsISupports *)dcs;
}
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
// else {
// inst->Release();
// }
return res;
}
nsresult nsGfxFactoryGTK::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryGTK(aClass);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}

View File

@@ -0,0 +1,77 @@
/* -*- 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.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.
*/
#ifndef nsIDrawingSurfaceGTK_h___
#define nsIDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include <gtk/gtk.h>
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_GTK_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceGTK : public nsISupports
{
public:
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC) = 0;
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags) = 0;
/**
* Get a windows DC that represents the drawing surface.
* GetDC() must be paired with ReleaseDC(). Getting a DC
* and Lock()ing are mutually exclusive operations.
* @param aDC out parameter for HDC
* @return error status
**/
NS_IMETHOD GetGC(GdkGC *aGC) = 0;
/**
* Release a windows DC obtained by GetDC().
* ReleaseDC() must be preceded by a call to ReleaseDC().
* @return error status
**/
NS_IMETHOD ReleaseGC(void) = 0;
};
#endif // nsIDrawingSurfaceGTK_h___

View File

@@ -0,0 +1,515 @@
/* -*- 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.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.
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "nsImageGTK.h"
#include "nsRenderingContextGTK.h"
#include "nspr.h"
#define IsFlagSet(a,b) (a & b)
#undef CHEAP_PERFORMANCE_MEASURMENT
// Defining this will trace the allocation of images. This includes
// ctor, dtor and update.
#undef TRACE_IMAGE_ALLOCATION
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
//------------------------------------------------------------
nsImageGTK::nsImageGTK()
{
NS_INIT_REFCNT();
mImageBits = nsnull;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mAlphaBits = nsnull;
mAlphaPixmap = nsnull;
mImagePixmap = nsnull;
mGC = nsnull;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::nsImageGTK(this=%p)\n",
this);
#endif
}
//------------------------------------------------------------
nsImageGTK::~nsImageGTK()
{
if(nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (nsnull != mGC) {
gdk_gc_unref(mGC);
mGC = nsnull;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::~nsImageGTK(this=%p)\n",
this);
#endif
}
NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
//------------------------------------------------------------
nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth, nsMaskRequirements aMaskRequirements)
{
g_return_val_if_fail ((aWidth != 0) || (aHeight != 0), NS_ERROR_FAILURE);
if (nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (24 == aDepth) {
mNumBytesPixel = 3;
} else {
NS_ASSERTION(PR_FALSE, "unexpected image depth");
return NS_ERROR_UNEXPECTED;
}
mImageUpdated = PR_TRUE;
mWidth = aWidth;
mHeight = aHeight;
mDepth = aDepth;
mIsTopToBottom = PR_TRUE;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Init(this=%p,%d,%d,%d,%d)\n",
this,
aWidth,
aHeight,
aDepth,
aMaskRequirements);
#endif
// create the memory for the image
ComputMetrics();
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
switch(aMaskRequirements)
{
case nsMaskRequirements_kNoMask:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
break;
case nsMaskRequirements_kNeeds1Bit:
mAlphaRowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
case nsMaskRequirements_kNeeds8Bit:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
mAlphaDepth = 8;
g_print("TODO: want an 8bit mask for an image..\n");
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
}
mImagePixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
gdk_rgb_get_visual()->depth);
mGC = gdk_gc_new(mImagePixmap);
return NS_OK;
}
//------------------------------------------------------------
PRInt32 nsImageGTK::CalcBytesSpan(PRUint32 aWidth)
{
PRInt32 spanbytes;
spanbytes = (aWidth * mDepth) >> 5;
if (((PRUint32)aWidth * mDepth) & 0x1F)
spanbytes++;
spanbytes <<= 2;
return(spanbytes);
}
void nsImageGTK::ComputMetrics()
{
mRowBytes = CalcBytesSpan(mWidth);
mSizeImage = mRowBytes * mHeight;
}
PRInt32 nsImageGTK::GetHeight()
{
return mHeight;
}
PRInt32 nsImageGTK::GetWidth()
{
return mWidth;
}
PRUint8 *nsImageGTK::GetBits()
{
return mImageBits;
}
void *nsImageGTK::GetBitInfo()
{
return nsnull;
}
PRInt32 nsImageGTK::GetLineStride()
{
return mRowBytes;
}
nsColorMap *nsImageGTK::GetColorMap()
{
return nsnull;
}
PRBool nsImageGTK::IsOptimized()
{
return PR_TRUE;
}
PRUint8 *nsImageGTK::GetAlphaBits()
{
return mAlphaBits;
}
PRInt32 nsImageGTK::GetAlphaWidth()
{
return mAlphaWidth;
}
PRInt32 nsImageGTK::GetAlphaHeight()
{
return mAlphaHeight;
}
PRInt32 nsImageGTK::GetAlphaLineStride()
{
return mAlphaRowBytes;
}
nsIImage *nsImageGTK::DuplicateImage()
{
return nsnull;
}
void nsImageGTK::SetAlphaLevel(PRInt32 aAlphaLevel)
{
}
PRInt32 nsImageGTK::GetAlphaLevel()
{
return 0;
}
void nsImageGTK::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
{
}
//------------------------------------------------------------
// set up the palette to the passed in color array, RGB only in this array
void nsImageGTK::ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,
nsRect *aUpdateRect)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::ImageUpdated(this=%p,%d)\n",
this,
aFlags);
#endif
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)) {
mImageUpdated = PR_TRUE;
// FIXME do something with aUpdateRect
}
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
static PRTime gConvertTime, gStartTime, gPixmapTime, gEndTime;
#endif
// Draw the bitmap, this method has a source and destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*)aSurface;
if (mAlphaBits)
g_print("calling nsImageGTK::Draw() with alpha bits\n");
gdk_draw_rgb_image (drawing->GetDrawable(),
mGC,
aDX, aDY, aDWidth, aDHeight,
GDK_RGB_DITHER_MAX,
mImageBits + mRowBytes * aSY + 3 * aDX,
mRowBytes);
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
if ((aWidth != mWidth) || (aHeight != mHeight)) {
aWidth = mWidth;
aHeight = mHeight;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p,x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
nsDrawingSurfaceGTK* drawing = (nsDrawingSurfaceGTK*) aSurface;
XImage *x_image = nsnull;
Pixmap pixmap = 0;
Display *dpy = nsnull;
Visual *visual = nsnull;
GC gc;
XGCValues gcv;
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gStartTime = gPixmapTime = PR_Now();
#endif
// Create gc clip-mask on demand
if ((mAlphaBits) && (mImageUpdated == PR_TRUE))
{
/* get the X primitives */
dpy = GDK_WINDOW_XDISPLAY(mAlphaPixmap);
/* this is the depth of the pixmap that we are going to draw to.
It's always a bitmap. We're doing alpha here folks. */
visual = GDK_VISUAL_XVISUAL(gdk_rgb_get_visual());
// Make an image out of the alpha-bits created by the image library
x_image = XCreateImage(dpy, visual,
1, /* visual depth...1 for bitmaps */
XYPixmap,
0, /* x offset, XXX fix this */
(char *)mAlphaBits, /* cast away our sign. */
aWidth,
aHeight,
32,/* bitmap pad */
mAlphaRowBytes); /* bytes per line */
x_image->bits_per_pixel=1;
/* Image library always places pixels left-to-right MSB to LSB */
x_image->bitmap_bit_order = MSBFirst;
/* This definition doesn't depend on client byte ordering
because the image library ensures that the bytes in
bitmask data are arranged left to right on the screen,
low to high address in memory. */
x_image->byte_order = MSBFirst;
#if defined(IS_LITTLE_ENDIAN)
// no, it's still MSB XXX check on this!!
// x_image->byte_order = LSBFirst;
#elif defined (IS_BIG_ENDIAN)
x_image->byte_order = MSBFirst;
#else
#error ERROR! Endianness is unknown;
#endif
// Write into the pixemap that is underneath gdk's mAlphaPixmap
// the image we just created.
pixmap = GDK_WINDOW_XWINDOW(mAlphaPixmap);
memset(&gcv, 0, sizeof(XGCValues));
gcv.function = GXcopy;
gc = XCreateGC(dpy, pixmap, GCFunction, &gcv);
XPutImage(dpy, pixmap, gc, x_image, 0, 0, 0, 0,
aWidth, aHeight);
XFreeGC(dpy, gc);
// Now we are done with the temporary image
x_image->data = 0; /* Don't free the IL_Pixmap's bits. */
XDestroyImage(x_image);
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gPixmapTime = PR_Now();
#endif
}
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (mImageUpdated == PR_TRUE)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_pixmap_new(nsnull,width=%d,height=%d,depth=%d)\n",
this,
aWidth,
aHeight,
mDepth);
#endif
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
// Render the image bits into an off screen pixmap
gdk_draw_rgb_image (mImagePixmap,
mGC,
0, 0, aWidth, aHeight,
GDK_RGB_DITHER_MAX,
mImageBits, mRowBytes);
if (mAlphaPixmap)
{
// Setup gc to use the given alpha-pixmap for clipping
gdk_gc_set_clip_mask(mGC, mAlphaPixmap);
gdk_gc_set_clip_origin(mGC, aX, aY);
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_draw_pixmap(x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
mImageUpdated = PR_FALSE;
}
// copy our offscreen pixmap onto the window.
gdk_window_copy_area(drawing->GetDrawable(), // dest window
mGC, // gc
aX, // xsrc
aY, // ysrc
mImagePixmap, // source window
0, // xdest
0, // ydest
aWidth, // width
aHeight); // height
if (mAlphaBits)
{
// Revert gc to its old clip-mask and origin
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gEndTime = PR_Now();
printf("nsImageGTK::Draw(this=%p,w=%d,h=%d) total=%lld pixmap=%lld, cvt=%lld\n",
this,
aWidth, aHeight,
gEndTime - gStartTime,
gPixmapTime - gStartTime,
gConvertTime - gPixmapTime);
#endif
mImageUpdated = PR_FALSE;
return NS_OK;
}
//------------------------------------------------------------
nsresult nsImageGTK::Optimize(nsIDeviceContext* aContext)
{
return NS_OK;
}

View File

@@ -0,0 +1,115 @@
/* -*- 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.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.
*/
#ifndef nsImageGTK_h___
#define nsImageGTK_h___
#include "nsIImage.h"
#include "X11/Xlib.h"
#include "X11/Xutil.h"
#include <gdk/gdk.h>
#undef Bool
class nsImageGTK : public nsIImage
{
public:
nsImageGTK();
virtual ~nsImageGTK();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8* GetBits();
virtual void* GetBitInfo();
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
virtual PRInt32 GetLineStride();
virtual nsColorMap* GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized();
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits();
virtual PRInt32 GetAlphaWidth();
virtual PRInt32 GetAlphaHeight();
virtual PRInt32 GetAlphaLineStride();
virtual nsIImage* DuplicateImage();
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
virtual PRInt32 GetAlphaLevel();
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
private:
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputMetrics();
void ComputePaletteSize(PRIntn nBitCount);
private:
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mRowBytes;
PRUint8 *mImageBits;
PRUint8 *mConvertedBits;
PRInt32 mSizeImage;
PRBool mIsTopToBottom;
PRBool mImageUpdated;
PRInt8 mNumBytesPixel;
// alpha layer members
PRUint8 *mAlphaBits;
GdkPixmap *mAlphaPixmap;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
PRInt16 mAlphaWidth; // alpha layer width
PRInt16 mAlphaHeight; // alpha layer height
nsPoint mLocation; // alpha mask location
GdkPixmap *mImagePixmap;
GdkGC *mGC;
};
#endif

View File

@@ -0,0 +1,452 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* 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.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#include <gtk/gtk.h>
#include "nspr.h"
#include "nsPrintdGTK.h"
/* A structure to hold widgets that need to be referenced in callbacks. We
declare this statically in the caller entry point (as a field of
UnixPrOps, below), and pass a pointer to the structure to Gtk+ for each
signal handler registered. This avoids use of globals. */
typedef struct prwidgets {
GtkWidget *toplevel; /* should be set to toplevel window */
GtkWidget *prDialog;
GtkWidget *cmdEntry;
GtkWidget *pathEntry;
GtkWidget *browseButton;
GtkWidget *fpfToggle;
GtkWidget *greyToggle;
GtkWidget *letterToggle;
GtkWidget *legalToggle;
GtkWidget *execToggle;
GtkWidget *topSpinner;
GtkWidget *bottomSpinner;
GtkWidget *leftSpinner;
GtkWidget *rightSpinner;
GtkFileSelection *fsWidget;
} PrWidgets;
typedef struct unixprops {
UnixPrData *prData; /* pointer to caller struct */
PrWidgets widgets;
} UnixPrOps;
/* user clicked cancel. tear things down, and set cancel field in
caller data to PR_TRUE so printing will not happen */
static void
CancelPrint (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_TRUE;
}
/* user selected the Print button. Collect any remaining data from the
widgets, and set cancel field in caller data to PR_FALSE so printing
will be performed. Also, tear down dialog and exit inner main loop */
static void
DoPrint (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->command,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.cmdEntry ) ) );
strcpy( prOps->prData->path,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.pathEntry ) ) );
if ( GTK_TOGGLE_BUTTON( prOps->widgets.fpfToggle )->active == PR_TRUE )
prOps->prData->fpf = PR_TRUE;
else
prOps->prData->fpf = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.greyToggle )->active == PR_TRUE )
prOps->prData->grayscale = PR_TRUE;
else
prOps->prData->grayscale = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.letterToggle )->active == PR_TRUE )
prOps->prData->size = NS_LETTER_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
prOps->prData->size = NS_LEGAL_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
prOps->prData->size = NS_EXECUTIVE_SIZE;
else
prOps->prData->size = NS_A4_SIZE;
/* margins */
prOps->prData->top = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.topSpinner) );
prOps->prData->bottom = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.bottomSpinner) );
prOps->prData->left = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.leftSpinner) );
prOps->prData->right = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.rightSpinner) );
/* we got everything... bring down the dialog and tell caller
it's o.k. to print */
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_FALSE;
}
/* User hit ok in file selection widget brought up by the browse button.
snarf the selected file, stuff it in caller data */
static void
ModifyPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->path,
gtk_file_selection_get_filename(prOps->widgets.fsWidget) );
gtk_entry_set_text (GTK_ENTRY (prOps->widgets.pathEntry),
prOps->prData->path);
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.fsWidget) );
}
/* user selected print to printer. de-sensitize print to file fields */
static void
SwitchToPrinter (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_FALSE );
prOps->prData->toPrinter = PR_TRUE;
}
/* user selected print to file. de-sensitize print to printer fields */
static void
SwitchToFile (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_TRUE );
prOps->prData->toPrinter = PR_FALSE;
}
/* user hit the browse button. Pop up a file selection widget and grab
result */
static void
GetPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *fs;
fs = gtk_file_selection_new("Netscape: File Browser");
gtk_file_selection_set_filename( GTK_FILE_SELECTION(fs),
prOps->prData->path );
gtk_window_set_modal (GTK_WINDOW(fs),PR_TRUE);
#if 0
/* XXX not sure what the toplevel window should be. */
gtk_window_set_transient_for (GTK_WINDOW (fs),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
prOps->widgets.fsWidget = GTK_FILE_SELECTION(fs);
gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked", GTK_SIGNAL_FUNC(ModifyPrPath), prOps);
gtk_signal_connect_object (GTK_OBJECT(
GTK_FILE_SELECTION(fs)->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (fs));
gtk_widget_show(fs);
}
/* create file data dialog. XXX widget should be NULL */
static void
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
*button, *fileButton, *prButton, *table, *spinner1;
GtkAdjustment *adj;
prOps->widgets.prDialog = dialog =
gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_modal( GTK_WINDOW(dialog), PR_TRUE );
#if 0
/* not yet sure what the toplevel window should be */
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
gtk_window_set_title( GTK_WINDOW(dialog), "Netscape: Print" );
vbox = gtk_vbox_new (PR_FALSE, 0);
gtk_container_add (GTK_CONTAINER (dialog), vbox);
table = gtk_table_new (3, 3, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_TRUE, 5);
label = gtk_label_new( "Print To:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
0, GTK_EXPAND | GTK_FILL, 0, 0);
button = prButton = gtk_radio_button_new_with_label (NULL, "Printer");
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = fileButton = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "File");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
label = gtk_label_new( "Print Command:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->command);
gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.cmdEntry = entry;
label = gtk_label_new( "File Name:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->path);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.pathEntry = entry;
button = gtk_button_new_with_label ("Browse...");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (GetPrPath), prOps);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.browseButton = button;
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
table = gtk_table_new (2, 4, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "First Page First");
if ( prOps->prData->fpf == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
prOps->widgets.fpfToggle = button;
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Last Page First");
if ( prOps->prData->fpf == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "Greyscale");
prOps->widgets.greyToggle = button;
if ( prOps->prData->grayscale == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Color");
if ( prOps->prData->grayscale == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Paper Size: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL,
"Letter (8 1/2 x 11 in.)");
prOps->widgets.letterToggle = button;
if ( prOps->prData->size == NS_LETTER_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Legal (8 1/2 x 14 in.)");
prOps->widgets.legalToggle = button;
if ( prOps->prData->size == NS_LEGAL_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Executive (7 1/2 x 10 in.)");
prOps->widgets.execToggle = button;
if ( prOps->prData->size == NS_EXECUTIVE_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"A4 (210 x 297 mm)");
if ( prOps->prData->size == NS_A4_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
/* margins */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_FALSE, PR_FALSE, 5);
label = gtk_label_new( "Margins (inches):" );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_FALSE, PR_FALSE, 10);
table = gtk_table_new (1, 2, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Top: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.topSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Bottom: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.bottomSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Left: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.leftSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Right: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.rightSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_TRUE, PR_FALSE, 5);
button = gtk_button_new_with_label ("Print");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (DoPrint), prOps );
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC ( CancelPrint ), prOps);
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
/* Do this here, otherwise, upon creation the callbacks will be
triggered and the widgets these callbacks set sensitivity on
do not exist yet */
gtk_signal_connect (GTK_OBJECT (prButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToPrinter), prOps);
gtk_signal_connect (GTK_OBJECT (fileButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToFile), prOps);
gtk_widget_show_all( dialog );
gtk_main ();
}
/* public interface to print dialog. Caller passes in preferences using
argument, we return any changes and indication of whether to print
or cancel. */
void
UnixPrDialog( UnixPrData *prData )
{
static UnixPrOps prOps;
prOps.prData = prData;
DoPrintGTK( (GtkWidget *) NULL, &prOps );
}

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#ifndef nsPrintdGTK_h___
#define nsPrintdGTK_h___
#include <limits.h>
PR_BEGIN_EXTERN_C
/* stolen from nsPostScriptObj.h. needs to be put somewhere else that
both ps and gtk can see easily */
#ifndef NS_LEGAL_SIZE
#define NS_LETTER_SIZE 0
#define NS_LEGAL_SIZE 1
#define NS_EXECUTIVE_SIZE 2
#define NS_A4_SIZE 3
#endif
#ifndef PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#endif
typedef struct unixprdata {
PRBool toPrinter; /* If PR_TRUE, print to printer */
PRBool fpf; /* If PR_TRUE, first page first */
PRBool grayscale; /* If PR_TRUE, print grayscale */
int size; /* Paper size e.g., SizeLetter */
char command[ PATH_MAX ]; /* Print command e.g., lpr */
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
PRBool cancel; /* If PR_TRUE, user cancelled */
float left; /* left margin */
float right; /* right margin */
float top; /* top margin */
float bottom; /* bottom margin */
} UnixPrData;
void UnixPrDialog(UnixPrData *prData);
PR_END_EXTERN_C
#endif /* nsPrintdGTK_h___ */

View File

@@ -0,0 +1,302 @@
/* -*- 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.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.
*/
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include "nsRegionGTK.h"
#include "xregion.h"
#include "prmem.h"
static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
nsRegionGTK::nsRegionGTK()
{
NS_INIT_REFCNT();
mRegion = nsnull;
mRegionType = eRegionComplexity_empty;
}
nsRegionGTK::~nsRegionGTK()
{
if (mRegion)
::gdk_region_destroy(mRegion);
mRegion = nsnull;
}
NS_IMPL_QUERY_INTERFACE(nsRegionGTK, kRegionIID)
NS_IMPL_ADDREF(nsRegionGTK)
NS_IMPL_RELEASE(nsRegionGTK)
nsresult nsRegionGTK::Init(void)
{
NS_ADDREF_THIS();
mRegion = ::gdk_region_new();
mRegionType = eRegionComplexity_empty;
return NS_OK;
}
void nsRegionGTK::SetTo(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(const nsRegionGTK *aRegion)
{
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, aRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
SetRegionEmpty();
GdkRectangle grect;
grect.x = aX;
grect.y = aY;
grect.width = aWidth;
grect.height = aHeight;
GdkRegion *nRegion = ::gdk_region_union_with_rect(mRegion, &grect);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, tRegion);
::gdk_region_destroy(tRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_union(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
PRBool nsRegionGTK::IsEmpty(void)
{
return (::gdk_region_empty(mRegion));
}
PRBool nsRegionGTK::IsEqual(const nsIRegion &aRegion)
{
nsRegionGTK *pRegion = (nsRegionGTK *)&aRegion;
return(::gdk_region_equal(mRegion, pRegion->mRegion));
}
void nsRegionGTK::GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
GdkRectangle rect;
::gdk_region_get_clipbox(mRegion, &rect);
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;
}
void nsRegionGTK::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
::gdk_region_offset(mRegion, aXOffset, aYOffset);
}
PRBool nsRegionGTK::ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkOverlapType containment;
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
containment = ::gdk_region_rect_in(mRegion, &rect);
if (containment != GDK_OVERLAP_RECTANGLE_OUT)
return PR_TRUE;
else
return PR_FALSE;
}
NS_IMETHODIMP nsRegionGTK::GetRects(nsRegionRectSet **aRects)
{
nsRegionRectSet *rects;
GdkRegionPrivate *priv = (GdkRegionPrivate *)mRegion;
Region pRegion = priv->xregion;
int nbox;
BOX *pbox;
nsRegionRect *rect;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
//code lifted from old xfe. MMP
pbox = pRegion->rects;
nbox = pRegion->numRects;
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));
if (nsnull == buf)
{
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = nbox;
}
rects->mNumRects = nbox;
rects->mArea = 0;
rect = &rects->mRects[0];
while (nbox--)
{
rect->x = pbox->x1;
rect->width = (pbox->x2 - pbox->x1);
rect->y = pbox->y1;
rect->height = (pbox->y2 - pbox->y1);
rects->mArea += rect->width * rect->height;
pbox++;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects)
PR_Free((void *)aRects);
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
// cast to avoid const-ness problems on some compilers
if (((nsRegionGTK*)this)->IsEmpty())
aComplexity = eRegionComplexity_empty;
else
aComplexity = eRegionComplexity_complex;
return NS_OK;
}
void nsRegionGTK::SetRegionEmpty()
{
if (!IsEmpty()) {
::gdk_region_destroy(mRegion);
mRegion = ::gdk_region_new();
}
}
GdkRegion *nsRegionGTK::CreateRectRegion(PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight)
{
GdkRegion *tRegion = ::gdk_region_new();
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
GdkRegion *rRegion = ::gdk_region_union_with_rect(tRegion, &rect);
::gdk_region_destroy(tRegion);
return (rRegion);
}

View File

@@ -0,0 +1,63 @@
/* -*- 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.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.
*/
#ifndef nsRegionGTK_h___
#define nsRegionGTK_h___
#include "nsIRegion.h"
class nsRegionGTK : public nsIRegion
{
public:
nsRegionGTK();
virtual ~nsRegionGTK();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void SetTo(const nsRegionGTK *aRegion);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
GdkRegion *CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
private:
GdkRegion *mRegion;
nsRegionComplexity mRegionType;
virtual void SetRegionEmpty();
};
#endif // nsRegionGTK_h___

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,173 @@
/* -*- 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.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.
*/
#ifndef nsRenderingContextGTK_h___
#define nsRenderingContextGTK_h___
#include "nsIRenderingContext.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsImageGTK.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsDrawingSurfaceGTK.h"
#include "nsRegionGTK.h"
#include <gtk/gtk.h>
class nsRenderingContextGTK : public nsIRenderingContext
{
public:
nsRenderingContextGTK();
virtual ~nsRenderingContextGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
//locals
NS_IMETHOD CommonInit();
protected:
nsDrawingSurfaceGTK *mOffscreenSurface;
nsDrawingSurfaceGTK *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsRegionGTK *mClipRegion;
nsTransform2D *mTMatrix;
float mP2T;
GdkWChar* mDrawStringBuf;
PRUint32 mDrawStringSize;
// graphic state stack (GraphicsState)
nsVoidArray *mStateCache;
nscolor mCurrentColor;
GdkFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
};
#endif /* nsRenderingContextGTK_h___ */

8196
mozilla/gfx/src/gtk/u2j208.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,177 @@
/* $XConsortium: region.h,v 11.13 91/09/10 08:21:49 rws Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#ifdef TRUE
#undef TRUE
#endif
#define TRUE 1
#ifndef FALSE
#define FALSE 0
#endif
#ifndef MAXSHORT
#define MAXSHORT 32767
#endif
#ifndef MINSHORT
#define MINSHORT -MAXSHORT
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@@ -1,104 +0,0 @@
# a) Install me in public/htdocs/.htaccess, or
# b) Create a <Directory> entry in your Apache conf
# You MUST define YOURPATH/inc as an include_path!
php_value include_path /YOURPATH/v2/public/inc:.:/usr/share/pear:/YOURPATH/v2/shared/lib
# Init script to set up required libraries.
php_value auto_prepend_file init.php
# Finish script that calls $tpl->display for global Smarty object.
php_value auto_append_file finish.php
# Rewrite engine must be used to simplify URLs so they are human readable.
RewriteEngine On
RewriteBase /YOURPATH/public/htdocs
# Rewrites to be compatible with older versions of addons.
RewriteRule ^update/VersionCheck.php(.*)$ update.php$1
RewriteRule ^rss/index.php(.*)$ rss.php$1
# Send search-engine requests to search-engines.php.
RewriteRule ^search-engines[/]{0,1}$ search-engines.php [L]
# Compatibility for v1 extension and theme links.
# Old example URLs:
# /extensions/moreinfo.php?application=thunderbird&id=123
# /extensions/moreinfo.php?id=123
# /themes/moreinfo.php?id=321&application=seamonkey
# /themes/moreinfo.php?id=321
# New:
# /thunderbird/123/
# /firefox/123/
# /seamonkey/321/
# /firefox/321/
RewriteCond %{QUERY_STRING} application=(\w+)&.*id=([0-9]+)
RewriteRule ^(extensions|themes)/moreinfo.php$ %1/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} id=([0-9]+)&.*application=(\w+)
RewriteRule ^(extensions|themes)/moreinfo.php$ %2/%1/? [R=301,L]
RewriteCond %{QUERY_STRING} id=([0-9]+)
RewriteRule ^(extensions|themes)/moreinfo.php$ firefox/%1/? [R=301,L]
# Compatibility for v1 of extensions. The hardcoded URL's in the old
# browsers need this to get to the right pages: (the strings are the GUIDs)
# Old example URL:
# /extensions/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
# New:
# /extensions.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
RewriteCond %{QUERY_STRING} ^application=(.*)$
RewriteRule ^extensions/$ extensions.php?app=%1 [R=301,L]
# Compatibility for v1 of extensions. The hardcoded URL's in the old
# browsers need this to get to the right pages: (the strings are the GUIDs)
# Old example URL:
# /themes/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
# New:
# /themes.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
RewriteCond %{QUERY_STRING} ^application=(.*)$
RewriteRule ^themes/$ themes.php?app=%1 [R=301,L]
# Send rss/* to rss.php.
# Example:
# /rss/firefox/extensions/popular/ -> rss.php?app=firefox&type=extensions&list=popular
RewriteRule ^rss/(\w+)/(\w+)/(\w+)[/]{0,1}$ rss.php?app=$1&type=$2&list=$3
# Rewrite to addon.php if all we have is a numerical id after appname.
# Example:
# /firefox/220/ -> addon.php?app=firefox&id=220
RewriteRule ^(\w+)/(\d+)[/]{0,1}$ addon.php?app=$1&id=$2
# Rewrite to an addon-specific page, passing app and id.
# Example:
# /firefox/220/previews/ -> previews.php?app=firefox&id=220
RewriteRule ^(\w+)/(\d+)/(\w+)[/]{0,1}$ $3.php?app=$1&id=$2
# Rewrite to addon.php if there is a name given plus overview (special case for addon.php).
# Example:
# /firefox/flashgot/overview/ -> addon.php?app=firefox&name=flashgot
RewriteRule ^(\w+)/(\w+)/overview[/]{0,1}$ addon.php?app=$1&name=$2
# Rewrite to addon-specific page, passing app and addon name.
# Example:
# /firefox/flashgot/previews/ -> previews.php?app=firefox&name=flashgot
RewriteRule ^(\w+)/(\w+)/(\w+)[/]{0,1}$ $3.php?app=$1&name=$2
# Special rewrite for dictionaries
# Example:
# /en-US/firefox/1.5/dictionaries/ -> search.php?cat=68&app=firefox&type=E
RewriteRule ^([a-zA-Z]{2}(-[a-zA-Z]{2})?)/(\w+)/([0-9A-Za-z.-]+)/dictionaries[/]{0,1}$ search.php?cat=68&app=$2&type=E [L]
# Rewrite top-level pages.
# Examples:
# /firefox/extensions/ -> extensions.php?app=firefox
# /firefox/themes/ -> themes.php?app=firefox
RewriteRule ^(\w+)/([\w-]+)[/]{0,1}$ $2.php?app=$1
# Rewrite for main page & app.
# Example:
# /firefox/ -> /?app=firefox
RewriteRule ^(\w+)[/]{0,1}$ index.php?app=$1
# Rewrite for client blocklist requests.
# Example:
# /blocklist/1/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/1.5 -> blocklist.php?reqVersion=1&appGuid={ec8030f7-c20a-464f-9b0e-13a3a9e97384}&appVersion=1.5
RewriteRule ^blocklist/(.+)/(.+)/(.+)[/]{0,1}$ blocklist.php?reqVersion=$1&appGuid=$2&appVersion=$3

View File

@@ -1,130 +0,0 @@
<?php
/**
* Add a comment to any Addon.
*
* @package amo
* @subpackage docs
*
* Variables:
* $_GET['aid'] = Addon ID (integer)
*/
startProcessing('addcomment.tpl', null, null,'rustico');
require_once 'includes.php';
session_start();
if ((!array_key_exists('aid', $_GET)) || !is_numeric($_GET['aid'])) {
triggerError('There was an error processing your request.');
}
//This is a secure page, so we'll check the session
if (!$_auth->validSession()) {
//id is already verified to be numeric from above
header('Location: '.WEB_PATH."/login.php?dest=comment&aid={$_GET['aid']}");
exit;
}
// If there are errors, this will be populated
$_errors = array();
// This will be used in queries and the template
$addon = new AddOn($_GET['aid']);
// If the comment is added successfully, this will toggle (used in the template)
$added_comment = false;
// They're posting a comment
if (isset($_POST['c_submit'])) {
if (! (array_key_exists('c_rating', $_POST)
&& array_key_exists('c_title', $_POST)
&& array_key_exists('c_comments', $_POST))) {
//This should never happen, but hey...
triggerError('There was an error processing your request.');
}
// Check all our input to make sure something is there, and it is appropriate.
// If it isn't, make $_bad_input=true which means we'll print the form back out
// with an error message. (By using booleans here, we keep the error messages in
// the .tpl)
$_bad_input = false;
if (!is_numeric($_POST['c_rating']) || $_POST['c_rating'] < 0 || $_POST['c_rating'] > 5) {
$_errors['c_rating'] = true;
$_bad_input = true;
}
if (empty($_POST['c_title'])) {
$_errors['c_title'] = true;
$_bad_input = true;
}
if (empty($_POST['c_comments'])) {
$_errors['c_comments'] = true;
$_bad_input = true;
}
// If bad_input is true, we'll skip the rest of the processing and dump them
// back out to the from with an error.
if ($_bad_input === false) {
// I got a little carried away with the escaping, but it's not gonna hurt anything.
$_c_id = mysql_real_escape_string($addon->ID);
$_c_user_id = mysql_real_escape_string($_auth->getId());
$_c_rating = mysql_real_escape_string($_POST['c_rating']);
$_c_title = mysql_real_escape_string(strip_tags($_POST['c_title']));
$_c_comments = mysql_real_escape_string(strip_tags($_POST['c_comments']));
$_c_commentip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$_sql = "INSERT INTO `feedback`
(
`ID`,
`UserId`,
`CommentVote`,
`CommentTitle`,
`CommentNote`,
`CommentDate`,
`commentip`
) VALUES (
{$_c_id},
{$_c_user_id},
{$_c_rating},
'{$_c_title}',
'{$_c_comments}',
NOW(),
'{$_c_commentip}'
)";
$db->query($_sql);
if (!DB::isError($db->record)) {
// Calculate the lookup value in main for comment avg if our INSERT was successful.
$_ratingSql = "UPDATE `main` SET `Rating` = ROUND((SELECT AVG(`CommentVote`) FROM `feedback` WHERE `ID` = {$_c_id}),2) WHERE `ID` = {$_c_id}";
$db->query($_ratingSql);
}
// For the template
$added_comment = true;
}
}
// Put values back into the form - if something went wrong this will populate the
// form again
$c_rating_value = array_key_exists('c_rating', $_POST) ? $_POST['c_rating'] : '';
$c_title_value = array_key_exists('c_title', $_POST) ? $_POST['c_title'] : '';
$c_comments_value = array_key_exists('c_comments', $_POST) ? $_POST['c_comments'] : '';
// Assign template variables.
$tpl->assign(
array( 'title' => 'Add Comment',
'currentTab' => null,
'rate_select_value' => array('','5','4','3','2','1','0'),
'rate_select_name' => array('Rating:','5 stars', '4 stars', '3 stars', '2 stars', '1 star', '0 stars'),
'addon' => $addon,
'c_added_comment' => $added_comment,
'c_errors' => $_errors,
'c_rating_value' => $c_rating_value,
'c_title_value' => $c_title_value,
'c_comments_value' => $c_comments_value,
'sidebar' => 'inc/addon-sidebar.tpl'
)
);
?>

View File

@@ -1,37 +0,0 @@
<?php
/**
* Addon summary page. Displays a top-down view of all Addon properties.
*
* @package amo
* @subpackage docs
*/
// Get the int value of our addon ID.
$clean['ID'] = intval($_GET['id']);
$sql['ID'] =& $clean['ID'];
startProcessing('addon.tpl',$clean['ID'],$compileId,"rustico");
require_once('includes.php');
// Create our AddOn object using the ID.
$addon = new AddOn($sql['ID']);
/* This is kind of a cheesy hack to determine how to display
download links on the addon page. If only one link is shown,
there will just be an "Install Now" link, otherwise there will
be links for each version. */
if (sizeof($addon->OsVersions) == 1) {
$multiDownloadLinks = false;
} else {
$multiDownloadLinks = true;
}
// Assign template variables.
$tpl->assign(
array( 'addon' => $addon,
'multiDownloadLinks' => $multiDownloadLinks,
'title' => $addon->Name,
'content' => 'addon.tpl',
'sidebar' => 'inc/addon-sidebar.tpl')
);
?>

View File

@@ -1,24 +0,0 @@
<?php
/**
* Author information.
* @package amo
* @subpackage docs
*/
// Get our addon ID.
$clean['UserID'] = intval($_GET['id']);
$sql['UserID'] =& $clean['UserID'];
startProcessing('author.tpl',$clean['UserID'],$compileId,'rustico');
require_once('includes.php');
$user = new User($sql['UserID']);
// Assign template variables.
$tpl->assign(
array( 'user' => $user,
'title' => $user->UserName,
'content' => 'author.tpl',
'sidebar' => 'inc/author-sidebar.tpl')
);
?>

View File

@@ -1,190 +0,0 @@
<?php
/**
* This script tells clients whether or not a given add-on is blocklisted.
*
* It should always be well-formed and won't be seen by users,
* at least initially.
*
* At some point we should consider generating an XSLT in case we want to
* publish this list.
*
* @todo stylesheet for client viewing of blocklists
* @package amo
* @subpackage pub
*/
startProcessing('blocklist.tpl', $memcacheId, $compileId, 'xml');
/**
* VARIABLES
*
* Initialize, set up and clean variables.
*/
// Required variables that we need to run the script.
$required_vars = array('reqVersion', // Used as a marker for the current URI scheme, in case it changes later.
'appGuid', // GUID of the client requesting the blocklist.
'appVersion'); // Version of the client requesting the blocklist (not used).
// Debug flag.
$debug = (isset($_GET['debug']) && $_GET['debug'] == 'true') ? true : false;
// Array to hold errors for debugging.
$errors = array();
// Iterate through required variables, and escape/assign them as necessary.
foreach ($required_vars as $var) {
if (empty($_GET[$var])) {
$errors[] = 'Required variable '.$var.' not set.'; // set debug error
}
}
// If we have all of our data, clean it up for our queries.
if (empty($errors)) {
// We will need our DB in order to perform our query.
require_once('includes.php');
// Iterate through required variables, and escape/assign them as necessary.
foreach ($required_vars as $var) {
$sql[$var] = mysql_real_escape_string($_GET[$var]);
}
/*
* QUERIES
*
* All of our variables are cleaned.
* Now attempt to retrieve blocklist information for this application.
*/
$query = "
SELECT
blitems.id as itemId,
blitems.guid as itemGuid,
blitems.min as itemMin,
blitems.max as itemMax,
blapps.id as appId,
blapps.item_id as appItemId,
blapps.guid as appGuid,
blapps.min as appMin,
blapps.max as appMax
FROM
blitems
LEFT JOIN blapps on blitems.id = blapps.item_id
WHERE
blapps.guid = '{$sql['appGuid']}'
OR blapps.guid IS NULL
ORDER BY
itemGuid, appGuid, itemMin, appMin
";
$db->query($query, SQL_ALL, SQL_ASSOC);
if (DB::isError($db->record)) {
$errors[] = 'MySQL query for blocklist failed.';
} elseif (empty($db->record)) {
$errors[] = 'No matching blocklist for given application GUID.';
} else {
$blocklist = array();
foreach ($db->record as $row) {
// If we have item itemMin/itemMax values or an appId possible ranges, we create
// hashes for each itemId and its related range.
//
// Since itemGuids can have different itemIds, they are the first hash. Each
// itemId is effectively an item's versionRange. For each one of these we create
// a corresponding array containing the range values, which could be NULL.
if (!empty($row['itemMin']) && !empty($row['itemMax']) || !empty($row['appItemId'])) {
$blocklist['items'][$row['itemGuid']][$row['itemId']] = array(
'itemMin' => $row['itemMin'],
'itemMax' => $row['itemMax']
);
// Otherwise, our items array only contains a top-level containing the itemGuid.
//
// Doing so tells our template to terminate the item with /> because there is
// nothing left to display.
} else {
$blocklist['items'][$row['itemGuid']] = null;
}
// If we retrieved non-null blapp data, store it in the apps array.
//
// These are referenced later by their foreign key relationship to items (appItemId).
if ($row['appItemId']) {
$blocklist['apps'][$row['itemGuid']][$row['appItemId']][$row['appGuid']][] = array(
'appMin' => $row['appMin'],
'appMax' => $row['appMax']
);
}
}
// Send our array to the template.
$tpl->assign('blocklist',$blocklist);
}
}
/*
* DEBUG
*
* If we get here, something went wrong. For testing purposes, we can
* optionally display errers based on $_GET['debug'].
*
* By default, no errors are ever displayed because humans do not read this
* script.
*
* Until there is some sort of API for how clients handle errors,
* things should remain this way.
*/
if ($debug == true) {
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
echo '<html lang="en">';
echo '<head>';
echo '<title>blocklist.php Debug Information</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
echo '</head>';
echo '<body>';
echo '<h1>Parameters</h1>';
echo '<pre>';
print_r($_GET);
echo '</pre>';
if (!empty($query)) {
echo '<h1>Query</h1>';
echo '<pre>';
echo $query;
echo '</pre>';
}
if (!empty($blocklist)) {
echo '<h1>Result</h1>';
echo '<pre>';
print_r($blocklist);
echo '</pre>';
}
if (!empty($errors) && is_array($errors)) {
echo '<h1>Errors Found</h1>';
echo '<pre>';
print_r($errors);
echo '</pre>';
} else {
echo '<h1>No Errors Found</h1>';
}
echo '</body>';
echo '</html>';
exit;
}
?>

View File

@@ -1,31 +0,0 @@
<?php
/**
* Home page for extensions, switchable on application.
*
* @package amo
* @subpackage docs
* @todo make this dynamic based on an SQL field (recommended)
*/
startProcessing('bookmarks.tpl', 'bookmarks', $compileId, 'rustico');
require_once('includes.php');
setApp();
$amo = new AMO_Object();
$primary = $amo->getAddons(array(3615));
if (is_array($primary) && !empty($primary)) {
$primary = $primary[0];
}
$other = $amo->getAddons(array(2410, 1833));
// Assign template variables.
$tpl->assign(
array( 'primary' => $primary,
'other' => $other,
'content' => 'bookmarks.tpl',
'currentTab' => 'bookmarks')
);
?>

View File

@@ -1,65 +0,0 @@
<?php
/**
* Comments listing for an addon.
*
* @package amo
* @subpackage docs
* @TODO Disallow comments for addon authors (authors should not be allowed to comment on their own addon).
* @TODO Throttle comment entry.
*/
// Get our addon id.
$clean['id'] = intval($_GET['id']);
$sql['id'] =& $clean['id'];
// Sort.
if (isset($_GET['sort'])&&ctype_alpha($_GET['sort'])) {
$clean['sort'] = $_GET['sort'];
}
// Starting point.
$page['left'] = (isset($_GET['left'])) ? intval($_GET['left']) : 0;
// Ending point.
$page['right'] = $page['left'] + 10;
// Order by.
$page['orderby'] = (!empty($_GET['orderby'])&&ctype_alpha($_GET['orderby'])) ? $_GET['orderby'] : "";
startProcessing('comments.tpl',$clean['id'],$compileId,'rustico');
require_once('includes.php');
$addon = new AddOn($sql['id']);
$addon->getComments($page['left'],10,$page['orderby']);
// Get our result count.
$db->query("SELECT FOUND_ROWS()", SQL_INIT);
$resultCount = !empty($db->record) ? $db->record[0] : $page['right'];
if ($resultCount<$page['right']) {
$page['right'] = $resultCount;
}
// Do we even have a next or previous page?
$page['previous'] = ($page['left'] >= 10) ? $page['left']-10 : null;
$page['next'] = ($page['left']+10 < $resultCount) ? $page['left']+10 : null;
$page['resultCount'] = $resultCount;
$page['leftDisplay'] = $page['left']+1;
// Build the URL based on passed arguments.
foreach ($clean as $key=>$val) {
if (!empty($val)) {
$buf[] = $key.'='.$val;
}
}
$page['url'] = implode('&amp;',$buf);
unset($buf);
// Assign template variables.
$tpl->assign(
array( 'addon' => $addon,
'title' => $addon->Name.' Comments',
'content' => 'comments.tpl',
'sidebar' => 'inc/addon-sidebar.tpl',
'page' => $page)
);
?>

View File

@@ -1,132 +0,0 @@
<?php
/**
* Create a new account
*
* @package amo
* @subpackage docs
*
*/
startProcessing('createaccount.tpl', null, null, 'rustico');
require_once 'includes.php';
// If there are problems, these will be set to true and used in the template. By
// using null/booleans, error messages are kept in the template.
$error_email_empty = null;
$error_email_malformed = null;
$error_emailconfirm_empty = null;
$error_emailconfirm_nomatch = null;
$error_email_duplicate = null;
$error_name_empty = null;
$error_password_empty = null;
$error_passwordconfirm_empty = null;
$error_passwordconfirm_nomatch = null;
$_bad_input = false; // think positive :)
$account_created = false;
if (array_key_exists('submit', $_POST) && isset($_POST['submit'])) {
/* Verify Input */
// Check email - a little long and confusing. Basically, throw an error if
// the following is not met (in order):
// $email is set, $emailconfirm is set, $email=$emailconfirm, and $email is a valid address
if (!array_key_exists('email', $_POST) || empty($_POST['email'])) {
$error_email_empty = true;
$_bad_input = true;
} else {
if (!array_key_exists('emailconfirm', $_POST) || empty($_POST['emailconfirm'])) {
$error_emailconfirm_empty = true;
$_bad_input = true;
} else {
// technically this would catch if emailconfirm was empty to, but
// waiting until here could make php throw a warning.
if ($_POST['email'] != $_POST['emailconfirm']) {
$error_emailconfirm_nomatch = true;
$_bad_input = true;
}
}
// Regex from Gavin Sharp -- thanks Gavin.
if (!preg_match('/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/',$_POST['email'])) {
$error_email_malformed = true;
$_bad_input = true;
}
}
// name is required
if (!array_key_exists('name', $_POST) || empty($_POST['name'])) {
$error_name_empty = true;
$_bad_input = true;
}
// password is required and match
if (!array_key_exists('password', $_POST) || empty($_POST['password'])) {
$error_password_empty = true;
$_bad_input = true;
} else {
if (!array_key_exists('passwordconfirm', $_POST) || empty($_POST['passwordconfirm'])) {
$error_passwordconfirm_empty = true;
$_bad_input = true;
} else {
if ($_POST['password'] != $_POST['passwordconfirm']) {
$error_passwordconfirm_nomatch = true;
$_bad_input = true;
}
}
}
// This is a little out of order because we're trying to save a query. If we
// haven't had any bad input yet, do one last check to make sure the email
// address isn't already in use.
if ($_bad_input === false) {
$_user_test = user::getUserByEmail($_POST['email']);
if (is_object($_user_test)) {
$_bad_input = true;
$error_email_duplicate = true;
}
}
// We're happy with the input, make a new account
if ($_bad_input === false) {
$_user_info = array();
$_user_info['email'] = $_POST['email'];
$_user_info['name'] = $_POST['name'];
$_user_info['website'] = $_POST['website'];
$_user_info['password'] = $_POST['password'];
$user_id = user::addUser($_user_info);
if ($user_id === false) {
triggerError('There was an error processing your request.');
}
$user = new User($user_id[0]);
// we're emailing them their plain text password
$user->sendConfirmation($_user_info['password']);
$account_created = true;
}
}
// Pull values from POST to put back in the form
$email_value = array_key_exists('email', $_POST) ? $_POST['email'] : '';
$emailconfirm_value = array_key_exists('emailconfirm', $_POST) ? $_POST['emailconfirm'] : '';
$name_value = array_key_exists('name', $_POST) ? $_POST['name'] : '';
$website_value = array_key_exists('website', $_POST) ? $_POST['website'] : '';
// Assign template variables.
$tpl->assign(
array( 'title' => 'Create an Account',
'currentTab' => null,
'account_created' => $account_created,
'bad_input' => $_bad_input,
'error_email_empty' => $error_email_empty,
'error_email_malformed' => $error_email_malformed,
'error_emailconfirm_empty' => $error_emailconfirm_empty,
'error_emailconfirm_nomatch' => $error_emailconfirm_nomatch,
'error_email_duplicate' => $error_email_duplicate,
'error_name_empty' => $error_name_empty,
'error_password_empty' => $error_password_empty,
'error_passwordconfirm_empty' => $error_passwordconfirm_empty,
'error_passwordconfirm_nomatch' => $error_passwordconfirm_nomatch,
'email_value' => $email_value,
'emailconfirm_value' => $emailconfirm_value,
'name_value' => $name_value,
'website_value' => $website_value
)
);
?>

View File

@@ -1,115 +0,0 @@
body, td, th, h3, input { /* redundant rules for bad browsers */
font-family: verdana, sans-serif;
font-size: x-small;
voice-family: "\"}\"";
voice-family: inherit;
font-size: small;
}
body {
color: #333;
line-height: 140%;
}
a:link { color: #039; }
a:visited { color: #609; }
a:hover { color: #333; }
a:active { color: #000; }
#header a:visited { color: #039; }
#header a:hover { color: #333; }
#mBody li { padding-bottom: 0.5em; }
.sidebar_content > h1,.sidebar_content > h2,.sidebar_content > h3,.sidebar_content > h4,.sidebar_content > h5,.sidebar_content > h6,.sidebar > h1,.sidebar_general > h2,.sidebar_general > h3,.sidebar_general > h4,.sidebar_general > h5,.sidebar_general > h6 {
margin-top: 0;
}
.sidebar_right {
margin-left: 65%;
}
.sidebar_general ul {
margin-left: 0;
padding-left: 20px;
}
.sidebar_general li {
padding: 0.2em 0;
}
img.imgright {
float: right;
margin: .3em .3em .3em 0;
padding: .3em .3em .3em 0;
}
img {
border: 0;
}
dt {
font-weight: bold;
}
dd {
margin: 0 0 1em 1em;
}
.skipLink {
position: absolute;
left: -1200px;
width: 990px;
}
.hide {
display: none;
}
ul.compact {
margin-left: 0;
padding-left: 20px;
}
img.rss {
float: right;
margin: 0;
padding: 4px 4px 0 0;
}
.first { margin-top: 0.2em; }
.requires img {
vertical-align: middle;
}
/* Headers */
#mainContent > h1:first-child,
#mainContent > h2:first-child,
#mainContent > h3:first-child,
#mainContent > h4:first-child,
#mainContent > h5:first-child,
#mainContent > h6:first-child,
#side > h1:first-child,
#side > h2:first-child,
#side > h3:first-child,
#side > h4:first-child,
#side > h5:first-child,
#side > h6:first-child {
margin-top: 0;
}
.appversions {
border: 1px solid #ccc;
margin: .5em 0;
}
.appversions th {
background-color: #ccc;
padding: .2em;
}
.appversions .row1 {
background-color: #eee;
}

View File

@@ -1,139 +0,0 @@
body {
min-width: 700px;
margin: 0 0 2em 0;
padding: 0;
}
#container {
width: 740px;
margin: 0 auto;
}
#mBody {
clear: both;
padding: .2em 0;
}
.sidebar_content {
width: 60%;
float: left;
}
#footer {
clear: both;
}
#side {
float: left;
width: 23%;
margin-bottom: 1em;
}
#mainContent {
margin-left: 25%;
}
.nomenu #mainContent {
margin-left: 0;
}
.bodyleft {
margin-left: 25% ! important
}
#mainContent.right {
float: left;
width: 62%;
margin-bottom: 1em;
margin-left: 0;
}
#side.right {
float: none;
width: auto;
margin-left: 65%;
}
p.security-update {
padding-left: 35px;
background: url(../../images/security-update.png) no-repeat;
margin-top: 0;
min-height: 30px;
}
/* Sidebar */
#nav:before {
line-height: 0.1;
font-size: 1px;
background: transparent url("../../images/menu_tr.gif") no-repeat top right;
margin: 0;
height: 9px;
display: block;
border-bottom: 1px solid #ddd;
content: url("../../images/key-point_tl.gif");
}
#nav {
background: #E0E9E9 url("../../images/menu_back.gif") right repeat-y;
}
#nav:after {
display: block;
padding-top: 0;
line-height: 0.1;
font-size: 1px;
content: url("../../images/key-point_bl.gif");
margin: 0 0 0 0;
height: 8px;
background: transparent url("../../images/menu_br.gif") scroll no-repeat bottom right ;
border-top: 1px solid #fff;
}
#nav, #nav ul {
margin: 0;
padding: 0;
list-style: none;
}
#nav {
margin-bottom: 1em;
}
#nav li {
display: inline;
padding: 0;
margin: 0;
}
#nav li span { /* used for un-linked menu items */
display: block;
padding: 6px 10px;
font-weight: bold;
color: #666;
}
#nav li span#configParent, #nav li span #configuration {
display: inline;
font-weight: normal;
padding: 0;
}
#nav li a {
display: block;
padding: 6px 10px;
text-decoration: none;
background: #EDF2F2;
border-bottom: 1px solid #ddd;
border-top: 1px solid #fff;
border-right: 1px solid #ddd;
}
#nav li a:hover {
background: #E0E9E9;
}
#nav ul li span,#nav ul li a {
padding: 4px 8px 4px 20px;
}
.clear-both {
clear: both;
}
.center {
text-align: center;
}

View File

@@ -1,454 +0,0 @@
#mBody h2 {
font: 140% arial,helvetica,verdana,sans-serif;
border-bottom: 1px solid #ccc;
margin-bottom: 0;
}
#mBody h2 a {
margin: 0;
padding: 0;
text-decoration: none;
}
#mBody h3 {
font: 120% arial,helvetica,verdana,sans-serif;
border-bottom: 1px solid #ccc;
margin-bottom: 0;
}
#mBody h1 {
font: 180% arial,helvetica,sans-serif;
border-bottom: 1px solid #ccc;
margin-bottom: 0;
}
.key-point:before {
line-height: 0.1;
font-size: 1px;
background: transparent url("../../images/key-point_tr.gif") no-repeat top right;
margin: -15px -15px 0 -15px;
height: 15px;
display: block;
border: none;
content: url("../../images/key-point_tl.gif");
}
.key-point {
background: #EFF8CE url("../../images/key-point_back.gif") right repeat-y;
padding: 15px;
margin-top: 18px;
}
.key-point:after {
display: block;
padding-top: 15px;
line-height: 0.1;
font-size: 1px;
content: url("../../images/key-point_bl.gif");
margin: -15px;
height: 8px;
background: transparent url("../../images/key-point_br.gif") scroll no-repeat bottom right ;
}
#header form #submit {
font-size: 100%;
padding: 1px;
font-family: tahoma, arial, sans-serif;
}
#header form #q {
width: 10em;
font-size: 100%;
font-weight: normal;
border: 1px solid #9097A2;
padding: 2px;
font-family: tahoma, arial, sans-serif;
}
#sectionsearch {
font-size: 100%;
font-weight: normal;
font-family: tahoma, arial, sans-serif;
}
.popularlist {
font-size: 85%;
}
.popularlist span {
color: #666;
white-space: nowrap;
}
.install a {
text-decoration: none;
}
.install a strong {
text-decoration: underline;
}
.install-box {
width: 20em;
}
.key-point {
background-color:#bee6a1;
}
.install div {
background: url(../../images/install.png) no-repeat;
padding: 3px 0 8px 30px;
}
#opinions h4 {
margin: 0;
}
.opinions-info {
font-size: 85%;
margin: 0 0 0.5em 0;
}
.opinions-info a {
text-decoration: none;
color: #666;
}
.opinions-info a:hover {
text-decoration: underline;
}
.opinions-text {
margin: 0;
}
.opinions-rating img {
vertical-align: middle;
}
.rating {
float: right;
font-size: 85%;
font-weight: bold;
}
.rating img {
vertical-align: middle;
}
.more-links {
margin: 0.5em 0 0 0;
padding: 0;
}
.more-links li {
display: inline;
margin: 0;
padding: 5px;
}
.screenshot {
float: right;
background: #fff;
padding: 0 0 2em 2em;
}
.screenshot a {
text-align: center;
display: block;
}
/* Remaining Original Update Styles */
.item {
border: #D2D6D6 1px solid;
padding-left: 5px;
padding-right: 6px;
MARGIN-bottom: 10px;
-moz-border-radius: 10px;
}
.item a {
color: #00129c;
text-decoration: none;
}
.item a:visited {
color: #00129c;
text-decoration: none;
}
.item a:hover {
color: #fc5900;
}
.item h2 {
margin-top: 0.2em;
}
.recommended {
clear: both;
padding: 1em 0;
}
.recommended h2 {
padding: 1em 0 0 215px;
margin: 0;
}
.recommended p {
padding-left: 215px;
}
.recommended-download h3 {
font: small tahoma, verdana, sans-serif;
margin: 0;
background: url("../../images/download.gif") 0 100%;
font-size: small;
padding-bottom: 5px;
}
.recommended-download h3 a {
display: block;
background: url("../../images/download.gif") 0 0;
font-size: 65%;
font-weight: bold;
width: 165px;
padding: 12px 25px 5px 10px;
text-decoration: none;
color: #5A9A3B;
}
.recommended-download h3 a:hover {
text-decoration: underline;
color: #275113;
}
.recommended-download {
display: block;
width: 200px;
padding: 15px 0 0 215px;
}
.recommended-img {
border: 2px outset #eee;
float: left;
margin: 1em 1em 0 0;
}
.iconbar {
padding-right: 15px;
float: left;
width: auto;
height: 34px;
}
.iconbar img {
float:left;
}
.iconbar a {
text-decoration: none;
}
.selected a, .selected a:visited {
color: #fc5900;
}
.baseline {
clear: right;
margin-top: 5px;
border-top: #ccc 1px solid;
padding: 3px;
padding-left: 10px;
font-size: 8pt;
color: #333;
}
#opinions {
list-style-type: none;
margin: 0;
padding: 0;
}
#opinions li {
border-top: 1px solid #eee;
padding: 1em 0;
}
#opinions h4 {
clear: right;
margin: 0;
padding: .5em 0 0 0;
}
.opinions-info {
color: #666;
margin: 0;
padding: 0 0 .5em 0;
}
.opinions-info a {
text-decoration: none;
color: #666;
}
.opinions-info a:hover {
text-decoration: underline;
}
.opinions-text {
margin: .8em 0 0 0;
padding: 0;
}
.opinions-vote {
background-color: #cfc;
border: 1px solid #000;
float: left;
font-style: italic;
font-weight: bold;
font-size: x-large;
padding: 5px;
margin: 4px;
text-align: center;
}
.opinions-caption {
display: block;
font-size: x-small;
font-weight: normal;
margin: 0;
padding: 0;
}
.opinions-rating {
margin: 0;
padding: .5em 0;
}
.opinions-helpful {
font-style: italic;
border: 1px dashed #eee;
padding: .2em;
margin: .7em 0;
}
.tooltip {
cursor: help;
border-bottom: 1px dotted;
}
.pages {
color: #999;
font-weight: bold;
height: 2em;
}
.next {
border-left: 1px solid #000;
display: inline;
padding-left: 5px;
}
.prev {
display: inline;
}
.pages a {
color: blue;
text-decoration: none;
}
#comment-rate {
margin: .5em;
padding: .5em;
background-color: #eee;
border: 1px solid #999;
}
#search-block:before {
line-height: 0.1;
font-size: 1px;
background: transparent url("../../img/key-point_tr.gif") no-repeat top right;
margin: -10px -10px 0 -10px;
height: 10px;
display: block;
border: none;
content: url("../../img/key-point_tl.gif");
}
#search-block{
background: #EFF8CE url("../../img/key-point_back.gif") right repeat-y;
padding: 10px;
}
#search-block label{
font-weight: bold;
}
#search-block select {
width: 13em;
}
#search-block input[type=text] {
width: 9.2em;
}
.right #search-block select {
width: 20em;
}
.right #search-block input[type=text] {
width: 16.2em;
}
#search-block:after {
display: block;
padding-top: 10px;
line-height: 0.1;
font-size: 1px;
content: url("../../img/key-point_bl.gif");
margin: -10px;
height: 8px;
background: transparent url("../../img/key-point_br.gif") scroll no-repeat bottom right ;
}
#search-options {
display: none;
}
#hide-search-options {
display: none;
}
#show-search-options {
display: inline;
}
#comments-sort {
float: right;
}
.disclaimer {
text-align: center;
color: #ccc;
font-size: x-small;
width: 600px;
margin-left: auto;
margin-right: auto;
}
.install-thunderbird {
background-color: #eee;
border: 1px solid #ccc;
margin: .5em 0;
padding: .5em;
}
.install-thunderbird p {
font-weight: bold;
color: blue;
margin: 0;
padding: 0;
}

View File

@@ -1,317 +0,0 @@
body {
background: #fff url("../../images/body_back.gif") repeat-x;
}
#footer {
background: url("../../images/footer.gif") 0 8px no-repeat;
margin: 10px 0;
text-align: center;
}
#footer span,#footer a {
white-space: nowrap;
padding: 0 1em;
color: #666;
font-size: 85%;
}
#footer p a:hover {
color: #000;
}
#footer .switch-fx,
#footer .switch-tb,
#footer .switch-suite {
padding-left: 30px;
font-size: 100%;
background: #fff 9px 0 no-repeat;
}
#footer .switch-tb {
background-image: url("../../images/switch-tb.gif");
}
#footer .switch-suite {
background-image: url("../../images/switch-suite.gif");
}
#footer .switch-fx {
background-image: url("../../images/switch-fx.gif");
}
/* Site Header */
#header {
clear: both;
padding-top: 40px;
position: relative;
} * html #header { padding-top: 20px; }
#header h1 {
height: 46px;
margin: 0;
font-size: 2px;
position: absolute;
top: 0;
left: -4px;
border: none;
z-index: 5000;
}
#header form {
position: absolute;
right: 0;
top: 9px;
margin-left: 200px;
font-family: tahoma, arial, sans-serif;
font-size: 85%;
}
#header div#auth {
display:inline;
position:absolute;
top:11px;
right:0px;
margin-right: 200px;
}
#key-menu {
background: #B2C1C8 url("../../images/header-bottom.gif") 0 100% no-repeat;
padding: 0 0 10px 0;
overflow: auto;
margin-bottom: 1em;
}
* html #key-menu {
overflow: visible;
height: 1px;
}
#key-menu ul, #key-menu li {
margin: 0;
padding: 0;
list-style: none;
}
#key-menu ul {
padding: 14px 12px 0 12px;
background: url("../../images/header-top.gif") 0 0 no-repeat;
}
#key-menu li {
float: left;
background: url("../../images/tabs.gif") 100% -50px;
padding-right: 5px;
margin-right: 2px;
border-bottom: 1px solid #849CA4;
margin-bottom: -10px;
}
#key-menu li a, #key-menu li span {
display: block;
float: left;
padding: 3px 15px 2px 20px;
background: url("../../images/tabs.gif") 0 -50px;
color: #5A7CBA;
text-decoration: none;
}
#key-menu li:hover a {
background-position: 0 -100px;
}
#key-menu li:hover {
background-position: 100% -100px;
}
#key-menu li.current {
background: url("../../images/tabs.gif") 100% 0;
border-bottom-color: white;
}
#key-menu li.current a, #key-menu li.current span {
background: url("../../images/tabs.gif") 0 0;
color: #999;
}
#mozilla-com a {
float: right;
display: block;
text-indent: -5000em;
width: 110px;
height: 25px;
text-decoration: none;
background: url("../../images/mozilla-org.gif") no-repeat;
}
/* End Site Header */
/* Front Feature */
.split-feature {
background: url("../../images/feature-back.png") 0 100% no-repeat;
overflow: auto;
padding-bottom: 10px;
margin-right: -2px;
} * html .split-feature { overflow: visible; height: 1px; }
.split-feature-one, .split-feature-two {
padding: 15px 15px 0 15px;
float: left;
}
.split-feature-one {
width: 485px;
background: url("../../images/feature-back.png") 0 0 no-repeat;
}
.split-feature-two {
width: 185px;
padding-left: 25px;
background: url("../../images/feature-back.png") 100% 0 no-repeat;
}
.split-feature h2 {
margin: 0 0 0.2em 0;
font-family: verdana, arial, sans-serif;
font-size: 1.4em;
}
.split-feature h2 a {
text-decoration: none;
font-size: medium;
font-style: italic;
}
.split-feature-one p {
margin-left: 220px;
}
.feature-download h3 {
font: 85% tahoma, verdana, sans-serif;
margin: 5px 0 0 0;
background: url("../../images/download.gif") 0 100%;
padding-bottom: 5px;
}
.feature-download h3 a {
display: block;
background: url("../../images/download.gif") 0 0;
font-weight: bold;
width: 165px;
padding: 12px 25px 5px 10px;
text-decoration: none;
color: #5A9A3B;
}
.feature-download h3 a:hover {
text-decoration: underline;
color: #275113;
}
.feature-download {
float: left;
width: 200px;
padding-right: 20px;
}
ol.top-10, ol.top-10 li {
margin: 0;
padding: 0;
list-style: none;
}
ol.top-10 li a {
display: block;
text-align: right;
padding: 1px 0 1px 20px;
border-top: 1px solid #eee;
text-decoration: none;
width: 160px;
background: url("../../images/top-10.gif") 0 0 no-repeat;
cursor: pointer; /* for IE as it ignores floating <strong>s */
font-size: 85%;
}
ol.top-10 li a:hover strong {
text-decoration: underline;
}
ol.top-10 li.top-10-2 a { background-position: 0 -50px; }
ol.top-10 li.top-10-3 a { background-position: 0 -100px; }
ol.top-10 li.top-10-4 a { background-position: 0 -150px; }
ol.top-10 li.top-10-5 a { background-position: 0 -200px; }
ol.top-10 li.top-10-6 a { background-position: 0 -250px; }
ol.top-10 li.top-10-7 a { background-position: 0 -300px; }
ol.top-10 li.top-10-8 a { background-position: 0 -350px; }
ol.top-10 li.top-10-9 a { background-position: 0 -400px; }
ol.top-10 li.top-10-10 a { background-position: 0 -450px; }
ol.top-10 li strong {
float: left;
}
#front-search {
text-align: center;
margin: 1.5em 0 1em 0;
}
.front-section-left, .front-section-right {
width: 220px;
float: left;
color: #666;
}
.front-section-left {
padding: 5px 0 5px 190px;
}
.front-section-right {
padding: 5px 70px 5px 0;
}
.front-section-left h2, .front-section-right h2{
margin: 0;
}
.front-section-left ul, .front-section-right ul {
margin: 0;
padding: 0;
margin-bottom: 2em;
}
.front-section-left li, .front-section-right li {
padding: 0.2em 0;
margin-left: 20px;
}
.front-section {
width: 220px;
padding: 5px 0 5px 25px;
float: left;
color: #666;
}
.front-section h2 {
margin: 0;
}
.front-section ul {
margin: 0;
padding: 0;
margin-bottom: 2em;
}
.front-section li {
padding: 0.2em 0;
margin-left: 20px;
}
a.top-feature {
float: left;
background: #fff;
}
a.top-feature img {
margin: 0;
padding: 0;
}

View File

@@ -1,46 +0,0 @@
.amo-form div {
margin: 1em 0;
}
.amo-submit {
background-color: #eee;
border: 2px #999 outset;
}
.amo-submit:hover {
background-color: #fff;
cursor: pointer;
}
.amo-cancel {
}
.amo-label-large, .amo-label-medium, .amo-label-small {
border-bottom: 1px dashed #eee;
float: left;
font-weight: bold;
}
.amo-label-large {
width: 14em;
}
.amo-label-medium {
width: 10em;
}
.amo-label-small {
width: 8em;
}
.amo-label-xsmall {
width: 6em;
}
.amo-form-error {
background-color: #eee;
border: 1px dashed #c66;
color: #c00;
margin: 5px 0;
padding: .5em;
}

View File

@@ -1,114 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/rss">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><xsl:value-of select="channel/title"/></title>
<meta name="keywords" content="mozilla update, mozilla extensions, mozilla plugins, thunderbird themes, thunderbird extensions, firefox extensions, firefox themes" />
<link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/css/base/content.css" media="all" />
<link rel="stylesheet" type="text/css" href="/css/cavendish/content.css" title="Cavendish" media="all" />
<link rel="stylesheet" type="text/css" href="/css/base/template.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/cavendish/template.css" title="Cavendish" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/forms.css" media="screen" />
<link rel="home" title="Home" href="https://addons.mozilla.org/" />
<link rel="alternate" type="application/rss+xml" href="{self}" title="{title}" />
<link rel="shortcut icon" href="{channel/image/url}" />
</head>
<body>
<div id="container">
<p class="skipLink"><a href="#firefox-feature" accesskey="2">Skip to main content</a></p>
<div id="mozilla-com"><a href="http://www.mozilla.com/">Visit Mozilla.com</a></div>
<div id="header">
<div id="key-title">
<h1>
<a href="/firefox/" title="Return to home page" accesskey="1">
<img src="/images/title-firefox.gif" width="276" height="54" alt="Firefox Add-ons Beta" />
</a>
</h1>
<script type="text/javascript">
//<![CDATA[
addUsernameToHeader();
//]]>
</script>
<form id="search" method="get" action="/search.php" title="Search Mozilla Update">
<div>
<label for="q" title="Search Mozilla Update">search:</label>
<input type="text" id="q" name="q" accesskey="s" size="10" />
<input type="hidden" name="app" value="firefox" />
<input type="submit" id="submit" value="Go" />
</div>
</form>
</div>
<div id="key-menu">
<ul id="menu-firefox">
<li><a href="/firefox/">Home</a></li>
<li><a href="/firefox/extensions/">Extensions</a></li>
<li><a href="/firefox/plugins/">Plugins</a></li>
<li><a href="/firefox/search-engines/">Search Engines</a></li>
<li><a href="/firefox/themes/">Themes</a></li>
</ul>
</div>
<!-- end key-menu -->
</div>
<!-- end header -->
<hr class="hide" />
<div id="mBody">
<h1><xsl:value-of select="channel/title"/></h1>
<p>
This is an RSS feed designed to be read by an RSS reader. Which you aren't.
</p>
<p>
<strong>What's an RSS Feed?</strong><br />
<acronym title="Really Simple Syndication">RSS</acronym> feeds
allow you to take the latest content from our site and view it in other places
such as a feed reader, your browser or your website. Feeds make it easy and
convenient to stay on top of the latest from Mozilla Add-ons.
</p>
<p>
<strong>How do I use this feed?</strong><br/>
To add this feed as a live bookmark in Firefox, simply click on the orange icon
(<img src="/images/rss.png" alt="RSS" />) in the address bar. Otherwise, take the
URL of this feed and add it to your favorite RSS reader.
</p>
<p>Preview of this feed:</p>
<ul>
<xsl:for-each select="channel/item">
<li>
<strong><a href="{link}"><xsl:value-of select="title"/></a></strong>
</li>
</xsl:for-each>
</ul>
</div>
<hr class="hide" />
<div id="footer">
<p><a href="/firefox/" class="switch-fx">Firefox Add-ons </a><a href="/thunderbird/" class="switch-tb">Thunderbird Add-ons </a><a href="/mozilla/" class="switch-suite">Mozilla Suite Add-ons </a></p>
<p><a href="/faq.php">FAQ</a> <a href="/feeds.php">Feeds/RSS</a> <a href="/login.php">Log In</a> <a href="/logout.php">Logout</a> <a href="/createaccount.php">Register</a></p>
<p><a href="http://www.mozilla.org/privacy-policy.html">Privacy Policy</a> <a href="http://www.mozilla.org/foundation/donate.html">Donate to Mozilla</a> <a href="http://mozilla.org/">The Mozilla Organization</a></p>
<p><span>Copyright &#169; 2004-2006</span> <a href="http://www.xramp.com/">256-bit SSL Encryption provided by XRamp</a></p>
</div>
</div>
<!-- close container -->
<div class="disclaimer">
Mozilla is providing links to these applications as a courtesy, and makes no representations
regarding the applications or any information related thereto. Any questions, complaints or
claims regarding the applications must be directed to the appropriate software vendor. See
our <a href="/support.php">Support Page</a> for support information and contacts.
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,740 +0,0 @@
/* General Structure */
/* copied from Mozilla.com */
body, td, th, input { /* redundant rules for bad browsers */
font-family: verdana, sans-serif;
font-size: x-small;
voice-family: "\"}\"";
voice-family: inherit;
font-size: small;
}
body {
background: #fff;
color: #333;
min-width: 610px;
margin: 0 0 1em 0;
padding: 0; /* need for Opera */
}
h1, h2, h3, h4, h5, h6 {
font-family: arial, verdana, sans-serif;
margin: 1em 0 0.2em 0;
}
li h1, li h2, li h3, li h4, li h5, li h6 {
border: none;
}
#header h1 { border: 0; }
h1 { font-size: 160%; font-weight: normal; }
h2 { font-size: 150%; font-weight: normal; }
h3 { font-size: 120%; }
h4 { font-size: 100%; }
h5 { font-size: 90%; }
h6 { font-size: 90%; border: 0; }
/* Navigation */
:link { color: #039; }
:visited { color: #636; }
:link:hover, :visited:hover { color: #333; }
:link:active, :link:active { color: #000; }
/* header copied from Mozilla.com */
#header {
background: #33415d url("../../images/rustico/header/header-background.png") top repeat-x;
position: relative;
height: 38px;
padding: 0 50px;
border-bottom: 1px solid #a1a6b1;
z-index: 1;
}
#header div {
position: relative;
max-width: 900px;
margin: 0 auto;
}
#header h1 { margin: 0; }
#header h1 img {
font-weight: bold;
color: #7f7c45;
}
#header ul {
position: absolute;
top: 0;
right: 0;
list-style: none;
margin: 0;
padding: 0;
border-left: 1px solid #576178;
border-right: 1px solid #1f2635;
} * html #header ul { right: 50px; }
#header li {
float: left;
margin: 0;
padding: 0;
}
#header ul span, #header ul a:link, #header ul a:visited {
display: block;
float: left;
padding: 10px 15px;
text-decoration: none;
border-right: 1px solid #576178;
border-left: 1px solid #1f2635;
color: #dee0e5;
height: 36px;
voice-family: "\"}\"";
voice-family: inherit;
height: 16px;
} #ignored {}
#header ul li span,
#header ul li a.current,
#header ul li a:hover {
background: #475470;
color: #fff;
text-decoration: underline;
}
#header ul li span,
#header ul li a.current {
text-decoration: none;
}
/* page title */
#page-title {
background: url("../../images/rustico/common/bg-header-small.jpg") repeat-x 50% 0;
}
#page-title div, #container {
max-width: 750px;
margin: 0 auto;
padding: 0 50px;
}
#page-title div {
background: url("../../images/rustico/common/firefox-addons-hdr.jpg") no-repeat 50% 0;
height: 170px;
} body>#page-title div { height: auto; min-height: 170px; }
#page-title div h2 {
margin: 0;
padding: 40px 0;
border: 0;
}
#page-title div h2 img {
border: 0;
}
/* mainContent */
#mainContent {
color: #3c475b;
line-height: 150%;
margin-left: 180px;
}
#mainContent hr {
margin: 2em;
}
#mainContent h3 {
font-weight: normal;
}
/* front page features */
.frontpage-intro {
margin-top: 0;
}
#top-extensions,
.front-recommended {
float: left;
width: 45%;
margin-right: 4%;
}
#home-rec-link img {
border: none;
float: right;
text-decoration: none;
margin-left: 10px;
}
.front-recommended img {
float: right;
margin: 0 20px;
}
.newest-extensions h3,
.top-extensions h3,
.front-recommended h3 {
padding-top: 5px;
}
.front-search-container {
float: left;
width: 45%;
}
.front-search-container img {
float: left;
}
.front-search-container h3 {
margin-left: 40px;
padding-top: 5px;
}
/* addon features */
.divider-bottom,
.bookmarkaddon-feature {
background: url(../../images/rustico/firefox-featured-divider.png) no-repeat bottom center;
margin-bottom: 1.5em;
padding-bottom: 10px;
}
#primary-feature {
margin-top: 2em;
}
.addon-feature h2 {
font-weight: bold;
margin: 0 0 5px 0;
}
.eula {
font-size: 75%;
}
.addon-feature h2 span {
font-weight: normal;
font-size: 80%;
}
.addon-feature h3,
.bookmarkaddon-feature h3 {
margin: 0 0 10px 0;
}
.addon-feature h4,
.bookmarkaddon-feature h4 {
margin: 0 0 10px 0;
}
.addon-feature h4 span,
.bookmarkaddon-feature h4 span {
font-weight: normal;
}
.addon-feature h1 span {
font-size: small;
}
.addon-feature h1 span.author {
font-size: smaller;
}
.addon-feature .search-result-image {
float: right;
margin: 10px 0 5px 10px;
}
.addon-feature .addon-feature-image,
.bookmarkaddon-feature .addon-feature-image {
float: left;
margin: 0 10px 0 0;
}
.preview-image a {
text-decoration: none;
text-align: center;
display: block;
font-size: smaller;
}
.addon-display .preview-image {
float: right;
}
.addon-display .version-and-date {
font-size: smaller;
}
.addon-feature .addon-feature-text { margin-left: 220px; }
.bookmarkaddon-feature .addon-feature-text { margin-left: 190px; }
.addon-feature a, .bookmarkaddon-feature a { color: #f7941d; }
.addon-feature a:visited, .bookmarkaddon-feature a:visited { color: #f7941d; }
.addon-feature a:hover, .bookmarkaddon-feature a:hover { color: #333; }
.recommended a, .recommended a:visited { color: #f7941d; }
.recommended a:hover { color: #333; }
.bookmarkstitle {
background: url(../../images/rustico/bookmarks/firefox-bm-puzzle-ico.png) no-repeat top left;
height: 27px;
padding: 5px 0 0 35px;
}
/* install button */
.install-button,
p.install-button {
width: 230px;
margin: 0;
}
span.install-button-text {
padding-right: 30px;
}
.install-button a:link span.install-green-button,
.install-button a:visited span.install-green-button,
.install-button a:hover span.install-green-button,
.install-button a:active span.install-green-button {
background: url(../../images/rustico/install-button.png) no-repeat bottom left;
display: block;
min-height: 20px;
padding: 10px;
}
* html .install-button a:link span.install-green-button,
* html .install-button a:visited span.install-green-button,
* html .install-button a:hover span.install-green-button,
* html .install-button a:active span.install-green-button { height: 20px; }
.install-button a:link,
.install-button a:visited,
.install-button a:hover,
.install-button a:active {
background: #a8ed2d url(../../images/rustico/install-button.png) no-repeat top left;
display: block;
color: #005825;
text-decoration: none;
}
.install-button a:hover span.install-green-button,
.install-button a:active span.install-green-button {
background: url(../../images/rustico/install-button.png) no-repeat bottom right;
}
.install-button a:hover,
.install-button a:active {
background: #89dc29 url(../../images/rustico/install-button.png) no-repeat top right;
color: #000;
cursor: hand;
}
/* corner box */
.corner-box {
background: url(../../images/rustico/left-top-corner-box.jpg) top left no-repeat;
margin: 0 0 10px 0;
padding: 12px 0 12px 15px;
}
.corner-box h3 {
margin-top: 0;
}
/* front page search */
#front-search {
margin-top: 1.5em;
}
#front-search label {
float: left;
width: 25%;
}
#front-search div {
float: left;
width: 70%
}
#front-search div .keywords {
margin-bottom: 0.5em;
}
/* search box */
.search-container img {
float: left;
}
.search-container h3 {
margin-left: 40px;
padding-top: 5px;
}
#extensions-search {
margin-top: 1.5em;
}
#extensions-search .keywords {
width: 40%;
}
#hide-search-options,
#search-options {
display: none;
}
#search-results .desc p {
margin-bottom: 0px;
}
#search-results h2 {
font-weight: bold;
}
#search-results h2 span {
font-weight: normal;
font-size: 80%;
}
#pages #next-page {
float: right;
}
/* various lists */
.compact-list {
font-size: 80%;
font-weight: bold;
}
.category-list {
padding-left: 3em;
font-weight: bold;
font-size: 90%;
}
.category-list td,
.compact-list td {
font-size: inherit;
}
.category-list td {
padding: 0 1.5em 0 1.5em;
}
.category-list a:link,
.category-list a:visited,
.compact-list a:link,
.compact-list a:visited {
text-decoration: none;
}
.compact-list span {
font-size: smaller;
}
/* menu box */
#menu-box {
float: left;
background: url(../../images/rustico/menu-box/menu-box-top.png) top left no-repeat;
font-size: 80%;
font-weight: bold;
width: 160px;
}
#menu-box ul {
background: url(../../images/rustico/menu-box/menu-box-bottom.png) bottom left no-repeat;
list-style-type: none;
margin: 0;
padding: 4px 0;
}
#menu-box ul li a:link,
#menu-box ul li a:visited,
#menu-box ul li span {
background: url(../../images/rustico/menu-box/menu-box-background.png) 0 0 no-repeat;
display: block;
width: 136px;
margin: 0;
padding: 8px 12px;
text-decoration: none;
}
#menu-box ul li span {
background: url(../../images/rustico/menu-box/menu-box-background.png) -400px 0 no-repeat;
}
#menu-box ul li a:hover,
#menu-box ul li a:active {
background: url(../../images/rustico/menu-box/menu-box-background.png) -200px 0 no-repeat;
}
/* footer */
#doc-links a,
#switch-links a,
#tool-links a {
padding: 0 1em;
}
#footer {
clear: both;
color: #888;
text-align: center;
margin: 0;
padding: 1em 0;
}
#footer ul {
margin: 1.5em 0;
}
#footer ul li {
display: inline;
margin: 0 0.5em;
}
#footer-addons-menu {
font-size: 110%;
padding: 0;
}
#footer-addons-menu li {
white-space: nowrap;
padding: 10px 0 5px 25px;
}
#footer-addons-menu li.firefox { background: url(../../images/rustico/footer/footer-icon-firefox.png) no-repeat center left; }
#footer-addons-menu li.thunderbird { background: url(../../images/rustico/footer/footer-icon-thunderbird.png) no-repeat center left; }
#footer-addons-menu li.mozilla { background: url(../../images/rustico/footer/footer-icon-mozilla.png) no-repeat center left; }
/* disclaimer */
#disclaimer {
clear: both;
background: url(../../images/rustico/footer/disclaimer.png) top repeat-x;
}
#disclaimer form {
float: right;
margin: 1em 50px 2em 25px;
}
#disclaimer form select {
font-size: 80%;
}
#disclaimer p {
max-width: 750px;
font-size: 80%;
margin: 0 auto;
padding: 10px 50px 20px 50px;
}
#disclaimer a { color: #f7941d; }
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {display: inline-block;}
/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */
table {
border-collapse: collapse;
border: none;
margin: 1em 0;
}
table.dalvay-table {
border-collapse: separate;
}
table.dalvay-table thead th {
background: none;
}
table.dalvay-table thead td,
table.dalvay-table thead th {
background: #f9fafa url(/img/dalvay/table/header.png) top repeat-x;
border: 0;
}
table.dalvay-table thead .top-left {
background: url(/img/dalvay/table/top-left.png) top left no-repeat;
}
table.dalvay-table thead .top-right {
background: url(/img/dalvay/table/top-right.png) top right no-repeat;
}
td.left { border-left: 1px solid #d7d7d7; }
td.right { border-right: 1px solid #d7d7d7; }
table.dalvay-table tfoot td {
background: #f9fafa url(/img/dalvay/table/footer.png) bottom repeat-x;
border: 0;
}
table.dalvay-table tfoot .bottom-left {
background: url(/img/dalvay/table/bottom-left.png) bottom left no-repeat;
}
table.dalvay-table tfoot .bottom-right {
background: url(/img/dalvay/table/bottom-right.png) bottom right no-repeat;
}
table.dalvay-table tfoot td { height: 12px; }
table.dalvay-table tr.odd td { background: #fff; }
table.dalvay-table tr.even td { background: #eee; }
table.dalvay-table tr:target td { background: yellow; }
table.dalvay-table td.curVersion { font-weight: bold; }
table.dalvay-table td.nya { text-align: center; }
table.dalvay-table td,
table.dalvay-table th {
margin: 0;
padding: 0.5em;
}
table.dalvay-table td.dl,
table.dalvay-table th.dl {
white-space: nowrap;
}
table.dalvay-table th {
text-align: left;
}
/* search-engines */
.front-section {
width: 220px;
padding: 5px 0 5px 25px;
float: left;
color: #666;
}
#switch-links {
align: right;
padding-left: 5em;
}
#switch-links .switch-tb,
#switch-links .switch-suite {
padding: 1px 0 1px 30px;
font-size: 100%;
background: #fff 9px 0 no-repeat;
}
#switch-links .switch-tb {
background-image: url("../../images/switch-tb.gif");
}
#switch-links .switch-suite {
background-image: url("../../images/switch-suite.gif");
}
/* ported from cavendish */
.item {
border: #D2D6D6 1px solid;
padding-left: 5px;
padding-right: 6px;
MARGIN-bottom: 10px;
-moz-border-radius: 10px;
}
.item a {
color: #00129c;
text-decoration: none;
}
.item a:visited {
color: #00129c;
text-decoration: none;
}
.item a:hover {
color: #fc5900;
}
.item h2 {
margin-top: 0.2em;
}
.iconbar {
padding-right: 15px;
float: left;
width: auto;
height: 34px;
}
.iconbar img {
float:left;
}
.iconbar a {
text-decoration: none;
}
/* user comments */
div.averagerating {
float:right;
font-size:85%;
font-weight:bold;
}
div.usercomment {
border-top: 1px solid #eee;
}
p.commenttext {
margin-left: 2em;
}
p.commentmeta {
font-size: smaller;
}
.pages {
color: #999;
font-weight: bold;
height: 2em;
}
.next {
border-left: 1px solid #000;
display: inline;
padding-left: 5px;
}
.prev {
display: inline;
}
#comments-sort {
float: right;
}

View File

@@ -1,24 +0,0 @@
<?php
/**
* Dictionaries page.
*
* @package amo
* @subpackage docs
*/
startProcessing('dictionaries.tpl', 'dictionaries', $compileId, 'rustico');
require_once('includes.php');
setApp();
$amo = new AMO_Object();
$dicts = $amo->getDictionaries();
// Assign template variables.
$tpl->assign(
array( 'dicts' => $dicts,
'content' => 'dictionaries.tpl',
'currentTab' => 'dictionaries')
);
?>

View File

@@ -1,10 +0,0 @@
<?php
require_once(LIB.'/error.php');
$error = 'Test Error<br>';
$error .= 'Generated: '.date("r");
$error .= '<pre>'.print_r($_SERVER, true).'</pre>';
triggerError($error, 'site-down.tpl');
?>

View File

@@ -1,59 +0,0 @@
<?php
/**
* Home page for extensions, switchable on application. Since v1 used GUIDs, the
* flow on this page is a little confusing (we need to support both name and GUID.
*
* @package amo
* @subpackage docs
*/
$currentTab = 'extensions';
startProcessing('extensions.tpl', 'extensions', $compileId, "rustico");
require_once('includes.php');
$_app = array_key_exists('app', $_GET) ? $_GET['app'] : null;
// Determine our application.
switch( $_app ) {
case 'mozilla':
$clean['app'] = 'Mozilla';
break;
case 'thunderbird':
$clean['app'] = 'Thunderbird';
break;
case 'sunbird':
$clean['app'] = 'Sunbird';
break;
case 'firefox':
default:
$clean['app'] = 'Firefox';
break;
}
$amo = new AMO_Object();
// Despite what $clean holds, GUIDs were used in v1 so we have to support them
if (preg_match('/^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[a-z0-9-\._]*\@[a-z0-9-\._]+)$/i',$_app)) {
$newestExtensions = $amo->getNewestAddonsByGuid($_app,'E',10);
$popularExtensions = $amo->getPopularAddonsByGuid($_app,'E',10);
/* This is a bit of a cheesy hack because of the way the templates are written.
* It's looking for the name of the app in $_GET, so here we are...*/
$_GET['app'] = strtolower($amo->getAppNameFromGuid($_app));
} else {
$newestExtensions = $amo->getNewestAddons($clean['app'],'E',10);
$popularExtensions = $amo->getPopularAddons($clean['app'],'E',10);
}
// Assign template variables.
$tpl->assign(
array( 'newestExtensions' => $newestExtensions,
'popularExtensions' => $popularExtensions,
'title' => 'Add-ons',
'currentTab' => $currentTab,
'content' => 'extensions.tpl',
'sidebar' => 'inc/category-sidebar.tpl',
'cats' => $amo->getCats('E'),
'type' => 'E')
);
?>

View File

@@ -1,73 +0,0 @@
<?php
/**
* FAQ page.
*
* @package amo
* @subpackage docs
*
* @todo FAQ search?
*/
startProcessing('faq.tpl','faq',$compileId, "rustico");
require_once('includes.php');
$db->query("
SELECT
`title`,
`text`
FROM
`faq`
WHERE
`active` = 'YES'
ORDER BY
`index` ASC,
`title` ASC
",SQL_ALL, SQL_ASSOC);
$faq = $db->record;
$sql = "
SELECT
`AppName`,
`GUID`,
`Version`
FROM
`applications`
WHERE
`public_ver`='YES'
ORDER BY
Appname, Version
";
$db->query($sql,SQL_ALL,SQL_ASSOC);
if (is_array($db->record)) {
foreach ($db->record as $row) {
$appVersions[] = array(
'displayVersion' => $row['Version'],
'appName' => $row['AppName'],
'guid' => $row['GUID']
);
}
}
$links = array(
array( 'href' => './faq.php',
'title' => 'Frequently Asked Questions',
'text' => 'FAQ'),
array( 'href' => './policy.php',
'title' => 'Addons Policies',
'text' => 'Policy')
);
// Send FAQ data to Smarty object.
$tpl->assign(
array( 'faq' => $faq,
'links' => $links,
'sidebar' => 'inc/nav.tpl',
'content' => 'faq.tpl',
'title' => 'Frequently Asked Questions',
'appVersions' => $appVersions )
);
?>

View File

@@ -1,17 +0,0 @@
<?php
/**
* Home page for extensions, switchable on application.
*
* @package amo
* @subpackage docs
*/
startProcessing('feeds.tpl', null, $compileId,'rustico');
require_once('includes.php');
// Assign template variables.
$tpl->assign(
array( 'title' => 'Feeds',
'content' => 'feeds.tpl')
);
?>

View File

@@ -1,175 +0,0 @@
<?php
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
//
// The contents of this file are subject to the Mozilla 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/MPL/
//
// 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 Update.
//
// The Initial Developer of the Original Code is
// Chris "Wolf" Crews.
// Portions created by the Initial Developer are Copyright (C) 2004
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
//
// Alternatively, the contents of this file may be used under the terms of
// either the GNU General Public License Version 2 or later (the "GPL"), or
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
// in which case the provisions of the GPL or the LGPL are applicable instead
// of those above. If you wish to allow use of your version of this file only
// under the terms of either the GPL or the LGPL, and not to allow others to
// use your version of this file under the terms of the MPL, indicate your
// decision by deleting the provisions above and replace them with the notice
// and other provisions required by the GPL or the LGPL. If you do not delete
// the provisions above, a recipient may use your version of this file under
// the terms of any one of the MPL, the GPL or the LGPL.
//
// ***** END LICENSE BLOCK *****
startProcessing('finalists.tpl',null,$compileId,'nonav');
require_once('includes.php');
/**
* Setting up variables.
*/
$guids = array(
'{34274bf4-1d97-a289-e984-17e546307e4f}',
'{097d3191-e6fa-4728-9826-b533d755359d}',
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}',
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}',
'{89506680-e3f4-484c-a2c0-ed711d481eda}',
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}',
'{268ad77e-cff8-42d7-b479-da60a7b93305}',
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}',
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}',
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}',
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}',
'Reveal@sourmilk.net',
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}',
'{53A03D43-5363-4669-8190-99061B2DEBA5}',
'separe@m4ng0.lilik.it',
'xpose@viamatic.com',
'{c45c406e-ab73-11d8-be73-000a95be3b12}',
'{D5EDC062-A372-4936-B782-BD611DD18D86}'
);
$guids_tmp = array();
foreach ($guids as $guid) {
$guids_tmp[] = "'".$guid."'";
}
$guids_imploded = implode(',',$guids_tmp);
$descriptions = array(
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>"Block ads including Flash ads from their source. Right click on an ad and select Adblock to block ads. Hit the status-element and see what has or hasn't been blocked.",
'{097d3191-e6fa-4728-9826-b533d755359d}'=>"Manage Extensions, Themes, Downloads, and more including Web content via Firefoxs sidebar.",
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}'=>"Blog directly within Firefox to LiveJournal, WordPress or Blogger. Select Deepest Sender from the Tools menu.",
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>"DownThemAll lets you filter and download all the links contained in any web-page, and lets you pause and resume downloads from previous Firefox sessions.",
'{89506680-e3f4-484c-a2c0-ed711d481eda}'=>"View open Tabs and Windows with Showcase. You can use it in two ways: global mode (F12) or local mode (Shift + F12). In global mode, a new window will be opened with thumbnails of the pages you've opened in all windows. In local mode, only content in tabs of your current window will be shown.
You can also right click in those thumbnails to perform the most usual operations on them. Mouse middle button can be used to zoom a thumbnail, although other actions can be assigned to it.",
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}'=>"Get international weather forecasts and display it in any toolbar or status bar.",
'{268ad77e-cff8-42d7-b479-da60a7b93305}'=>"Select from several of your favorite toolbars including including Google, Yahoo, Ask Jeeves, Teoma, Amazon, Download.com and others with one toolbar. The entire toolbar reconfigures when you select a different engine and it includes many advanced features found in each engine.
You can also easily repeat your search on all engines included in toolbar.",
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>"View pages with in Internet Explorer with IE Tab. Select the Firefox icon on the bottom right of the browser to switch to using the Internet Explorer engine or Firefox to switch to IE.",
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}'=>"Allows sticky notes to be added to any web page, and viewed upon visiting the Web page again. You can also share sticky notes. Requires account.",
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}'=>"PDF Download Extension allows you to choose if you want to view a PDF file inside the browser (as PDF or HTML), if you want to view it outside Firefox with your default or custom PDF reader, or if you want to download it.",
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}'=>"Platypus is a Firefox extension which lets you modify a Web page from your browser -- \"What You See Is What You Get\" -- and then save those changes as a GreaseMonkey script so that they'll be repeated the next time you visit the page.",
'Reveal@sourmilk.net'=>"Reveal allows you to see thumbnails of pages in your history by mousing over the back and forward buttons. With many tabs open, quickly find the page you want, by pressing F2. Reveal also has a rectangular magnifying glass you can use to zoom in on areas of any web page. Comes with a quick tour of all the features. ",
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>"A lightweight RSS and Atom feed aggregator. Alt+S to open Sage in the Sidebar to start reading feed content.",
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>"Highlight text, create sticky notes, and more to Web pages and Web sites that are saved to your desktop. Scrapbook Includes full text search and quick filtering of saved pages.",
'separe@m4ng0.lilik.it'=>"Manage tabs by creating a tab separator. Right click on a Tab to add a new Tab separator. Click on the Tab separator to view thumbnail images of web sites that are to the left and right of the Tab separator.",
'xpose@viamatic.com'=>"Click on the icon in the status bar to view all Web pages in Tabbed windows as thumbnail images. Press F8 to activate foXpose.",
'{c45c406e-ab73-11d8-be73-000a95be3b12}'=>"Web developer toolbar includes various development tools such as window resizing, form and image debugging, links to page validation and optimization tools and much more.",
'{D5EDC062-A372-4936-B782-BD611DD18D86}'=>"RSS news reader with integrated with services such as Feedster and weather information. Includes online help documentation."
);
$screenshots = array(
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>'adblock-mini.png',
'{097d3191-e6fa-4728-9826-b533d755359d}'=>'all-in-one-mini.png',
'{B9DAB69C-460E-4085-AE6C-F95B0D858581}'=>'deepest-sender-mini.png',
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>'downthemall-small.png',
'{89506680-e3f4-484c-a2c0-ed711d481eda}'=>'firefox-showcase.png',
'{3CE993BF-A3D9-4fd2-B3B6-768CBBC337F8}'=>'forecastfoxenhanced-small.png',
'{268ad77e-cff8-42d7-b479-da60a7b93305}'=>'groowe-small.png',
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>'IE-Tab.png',
'{bbc21d30-1cff-11da-8cd6-0800200c9a66}'=>'stickies-small.png',
'{37E4D8EA-8BDA-4831-8EA1-89053939A250}'=>'pdf-download.png',
'{a089fffd-e0cb-431b-8d3a-ebb8afb26dcf}'=>'platypus.png',
'Reveal@sourmilk.net'=>'reveal.png',
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>'sage.png',
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>'scrapbook-final.png',
'separe@m4ng0.lilik.it'=>'separe.png',
'xpose@viamatic.com'=>'xpose-small.png',
'{c45c406e-ab73-11d8-be73-000a95be3b12}'=>'web-developer-toolbar-small.png',
'{D5EDC062-A372-4936-B782-BD611DD18D86}'=>'wizz-small.png'
);
$authors = array(
'{34274bf4-1d97-a289-e984-17e546307e4f}'=>'Ben Karel (and the Adblock Crew)',
'{DDC359D1-844A-42a7-9AA1-88A850A938A8}'=>'Federico Parodi',
'{a6ca9b3b-5e52-4f47-85d8-cca35bb57596}'=>'Peter Andrews (and the Sage Team)',
'{53A03D43-5363-4669-8190-99061B2DEBA5}'=>'Taiga Gomibuchi',
'separe@m4ng0.lilik.it'=>'Massimo Mangoni',
'{77b819fa-95ad-4f2c-ac7c-486b356188a9}'=>'yuoo2k and Hong Jen Yee (PCMan)'
);
$finalists = array();
// Get data for GUIDs.
$finalists_sql = "
SELECT
m.guid,
m.id,
m.name,
m.downloadcount,
m.homepage,
v.dateupdated,
v.uri,
v.size,
v.version,
(
SELECT u.username
FROM userprofiles u
JOIN authorxref a ON u.userid = a.userid
WHERE a.id = m.id
ORDER BY u.userid DESC
LIMIT 1
) as username
FROM
main m
JOIN version v ON m.id = v.id
WHERE
v.vid = (SELECT max(vid) FROM version WHERE id=m.id AND approved='YES') AND
type = 'E' AND
m.guid IN({$guids_imploded})
ORDER BY
LTRIM(m.name)
";
$db->query($finalists_sql, SQL_ALL, SQL_ASSOC);
foreach ($db->record as $var => $val) {
$val['author'] = !empty($authors[$val['guid']]) ? $authors[$val['guid']] : $val['username'];
$finalists[] = $val;
}
// Assign template variables.
$tpl->assign(
array(
'title' => 'Extend Firefox Contest Finalists',
'screenshots' => $screenshots,
'descriptions' => $descriptions,
'finalists' => $finalists,
'content' => 'finalists.tpl')
);
?>

View File

@@ -1,30 +0,0 @@
<?php
/**
* Addon history page. Displays all the previous releases for a particular
* addon or theme
*
* @package amo
* @subpackage docs
*
* @todo break this into a simpler design, probably a smaller table with an abbreviated desc.
* @todo do we still want to allow users access to old versions?
*/
// Get our addon ID.
$clean['ID'] = intval($_GET['id']);
$sql['ID'] =& $clean['ID'];
startProcessing('history.tpl',$clean['ID'],$compileId, 'rustico');
require_once('includes.php');
$addon = new AddOn($sql['ID']);
$addon->getHistory();
// Assign template variables.
$tpl->assign(
array( 'addon' => $addon,
'title' => $addon->Name.' Version History',
'content' => 'history.tpl',
'sidebar' => 'inc/addon-sidebar.tpl')
);
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

Some files were not shown because too many files have changed in this diff Show More