зеркало из https://github.com/mozilla/gecko-dev.git
Added UNIX support for postscript printing, fixed many bugs.
Added nsIDeviceContextSpecPS interface so we can do PS on any platoform, get information from the print dialog.
This commit is contained in:
Родитель
b2439c51ae
Коммит
eba66ca1ff
|
@ -64,34 +64,12 @@ NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
|
|||
|
||||
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;
|
||||
|
||||
#ifdef DEBUG
|
||||
static PRBool once = PR_TRUE;
|
||||
if (once) {
|
||||
printf("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips);
|
||||
once = PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
mTwipsToPixels = ( ((float)::gdk_screen_width()) /
|
||||
((float)::gdk_screen_width_mm()) * 25.4) /
|
||||
// this is used for something odd. who knows
|
||||
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;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIView.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
#include "nsOldDrawingSurfaceGTK.h"
|
||||
#include "nsRenderingContextGTK.h"
|
||||
|
||||
class nsDeviceContextGTK : public DeviceContextImpl
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
// this isn't needed since we arn't useing getenv() anymore in here (pav)
|
||||
//#include "stdlib.h" // getenv() on Solaris/CC
|
||||
#include "stdlib.h" // getenv() on Solaris/CC
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecGTK
|
||||
|
@ -40,13 +38,52 @@ nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
|
|||
*/
|
||||
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
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)
|
||||
|
||||
|
@ -57,26 +94,25 @@ NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
|
|||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
|
||||
{
|
||||
gchar *path;
|
||||
|
||||
// XXX for now, neutering this per rickg until dcone can play with it
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
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 = SizeLetter;
|
||||
mPrData.stream = (FILE *) NULL;
|
||||
mPrData.size = NS_LETTER_SIZE;
|
||||
sprintf( mPrData.command, "lpr" );
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
path = g_get_home_dir();
|
||||
sprintf(mPrData.path, "%s/netscape.ps", path);
|
||||
g_free(path);
|
||||
if ( ( path = getenv( "PWD" ) ) == (char *) NULL )
|
||||
if ( ( path = 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 )
|
||||
|
@ -85,6 +121,72 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
|
|||
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
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#include "nsIDeviceContextSpecPS.h"
|
||||
|
||||
#include "nsPrintdGTK.h"
|
||||
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
|
||||
nsIDeviceContextSpecPS
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -51,10 +53,34 @@ public:
|
|||
/**
|
||||
* 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
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsRegionGTK.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);
|
||||
|
@ -146,7 +147,7 @@ nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
|
|||
else if (mClassID.Equals(kCDeviceContextSpec)) {
|
||||
nsDeviceContextSpecGTK* dcs;
|
||||
NS_NEWXPCOM(dcs, nsDeviceContextSpecGTK);
|
||||
inst = (nsISupports *)dcs;
|
||||
inst = (nsISupports *)((nsIDeviceContextSpecPS *)dcs);
|
||||
}
|
||||
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
|
||||
nsDeviceContextSpecFactoryGTK* dcs;
|
||||
|
|
|
@ -40,6 +40,10 @@ typedef struct prwidgets {
|
|||
GtkWidget *letterToggle;
|
||||
GtkWidget *legalToggle;
|
||||
GtkWidget *execToggle;
|
||||
GtkWidget *topSpinner;
|
||||
GtkWidget *bottomSpinner;
|
||||
GtkWidget *leftSpinner;
|
||||
GtkWidget *rightSpinner;
|
||||
GtkFileSelection *fsWidget;
|
||||
} PrWidgets;
|
||||
|
||||
|
@ -75,18 +79,30 @@ DoPrint (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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 = SizeLetter;
|
||||
prOps->prData->size = NS_LETTER_SIZE;
|
||||
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
|
||||
prOps->prData->size = SizeLegal;
|
||||
prOps->prData->size = NS_LEGAL_SIZE;
|
||||
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
|
||||
prOps->prData->size = SizeExecutive;
|
||||
prOps->prData->size = NS_EXECUTIVE_SIZE;
|
||||
else
|
||||
prOps->prData->size = SizeA4;
|
||||
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 */
|
||||
|
@ -171,7 +187,8 @@ static void
|
|||
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
||||
{
|
||||
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
|
||||
*button, *fileButton, *prButton, *table;
|
||||
*button, *fileButton, *prButton, *table, *spinner1;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
prOps->widgets.prDialog = dialog =
|
||||
gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
|
@ -244,7 +261,7 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 5, PR_FALSE);
|
||||
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);
|
||||
|
@ -255,7 +272,8 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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);
|
||||
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);
|
||||
|
@ -263,7 +281,8 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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_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);
|
||||
|
||||
|
@ -273,14 +292,16 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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_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_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);
|
||||
|
||||
|
@ -290,16 +311,18 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
button = gtk_radio_button_new_with_label (NULL,
|
||||
"Letter (8 1/2 x 11 in.)");
|
||||
prOps->widgets.letterToggle = button;
|
||||
if ( prOps->prData->size == SizeLetter )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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 == SizeLegal )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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);
|
||||
|
||||
|
@ -307,18 +330,82 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
|
||||
"Executive (7 1/2 x 10 in.)");
|
||||
prOps->widgets.execToggle = button;
|
||||
if ( prOps->prData->size == SizeExecutive )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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 == SizeA4 )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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);
|
||||
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
|
||||
/* 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 */
|
||||
|
||||
enum { SizeLetter, SizeLegal, SizeExecutive, SizeA4 };
|
||||
#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
|
||||
|
||||
typedef struct unixprdata {
|
||||
PRBool toPrinter; /* If PR_TRUE, print to printer */
|
||||
|
@ -35,11 +38,9 @@ typedef struct unixprdata {
|
|||
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 */
|
||||
FILE *stream; /* File or Printer */
|
||||
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___ */
|
||||
|
|
|
@ -44,5 +44,10 @@ CPPSRCS = \
|
|||
CSRCS = \
|
||||
font_metrics.c \
|
||||
|
||||
EXPORTS = \
|
||||
nsIDeviceContextSpecPS.h \
|
||||
nsPostScriptObj.h
|
||||
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -17,8 +17,45 @@
|
|||
*/
|
||||
|
||||
#include "nsAFMObject.h"
|
||||
#include "Helvetica.h"
|
||||
#include "Helvetica-Bold.h"
|
||||
#include "Helvetica-BoldOblique.h"
|
||||
#include "Helvetica-Oblique.h"
|
||||
#include "Times-Roman.h"
|
||||
#include "Times-Bold.h"
|
||||
#include "Times-BoldItalic.h"
|
||||
#include "Times-Italic.h"
|
||||
#include "Courier.h"
|
||||
#include "Courier-Bold.h"
|
||||
#include "Courier-BoldOblique.h"
|
||||
#include "Courier-Oblique.h"
|
||||
#include "Symbol.h"
|
||||
|
||||
|
||||
|
||||
// this is the basic font set supported currently
|
||||
DefFonts gSubstituteFonts[] =
|
||||
{
|
||||
{"Times-Roman","Times",400,0,&Times_RomanAFM,AFMTimes_RomanChars,-1},
|
||||
{"Times-Bold","Times",700,0,&Times_BoldAFM,AFMTimes_RomanChars,-1},
|
||||
{"Times-BoldItalic","Times",700,1,&Times_BoldItalicAFM,AFMTimes_RomanChars,-1},
|
||||
{"Times-Italic","Times",400,1,&Times_ItalicAFM,AFMTimes_RomanChars,-1},
|
||||
{"Helvetica","Helvetica",400,0,&HelveticaAFM,AFMHelveticaChars,-1},
|
||||
{"Helvetica-Bold","Helvetica",700,0,&Helvetica_BoldAFM,AFMHelveticaChars,-1},
|
||||
{"Helvetica-BoldOblique","Helvetica",700,2,&Helvetica_BoldObliqueAFM,AFMHelveticaChars,-1},
|
||||
{"Helvetica_Oblique","Helvetica",400,2,&Helvetica_ObliqueAFM,AFMHelveticaChars,-1},
|
||||
{"Courier","Courier",400,0,&CourierAFM,AFMCourierChars,-1},
|
||||
{"Courier-Bold","Courier",700,0,&Courier_BoldAFM,AFMCourierChars,-1},
|
||||
{"Courier-BoldOblique","Courier",700,2,&Courier_BoldObliqueAFM,AFMCourierChars,-1},
|
||||
{"Courier-Oblique","Courier",400,2,&Courier_ObliqueAFM,AFMCourierChars,-1},
|
||||
{"Symbol","Symbol",400,0,&SymbolAFM,AFMSymbolChars,-1}
|
||||
};
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A static structure initialized AFM font keyword definitions
|
||||
* @update 3/12/99 dwc
|
||||
*/
|
||||
static struct keyname_st
|
||||
{
|
||||
char *name;
|
||||
|
@ -124,6 +161,7 @@ static struct keyname_st
|
|||
*/
|
||||
nsAFMObject :: nsAFMObject()
|
||||
{
|
||||
mPSFontInfo = nsnull;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -133,6 +171,13 @@ nsAFMObject :: nsAFMObject()
|
|||
nsAFMObject :: ~nsAFMObject()
|
||||
{
|
||||
|
||||
if(mPSFontInfo->mAFMCharMetrics){
|
||||
delete [] mPSFontInfo->mAFMCharMetrics;
|
||||
}
|
||||
|
||||
if(mPSFontInfo){
|
||||
delete mPSFontInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -140,41 +185,119 @@ nsAFMObject :: ~nsAFMObject()
|
|||
* @update 2/25/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject :: Init(char *aFontName,PRInt32 aFontHeight)
|
||||
nsAFMObject :: Init(PRInt32 aFontHeight)
|
||||
{
|
||||
|
||||
//mFontHeight = mFont->size/20; // convert the font size to twips
|
||||
// read in the Helvetica font
|
||||
AFM_ReadFile();
|
||||
// read the file asked for
|
||||
mFontHeight = aFontHeight;
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 2/25/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject::AFM_ReadFile()
|
||||
PRInt16
|
||||
nsAFMObject::CheckBasicFonts(const nsFont &aFont,PRBool aPrimaryOnly)
|
||||
{
|
||||
PRBool done=PR_FALSE;
|
||||
PRBool bvalue;
|
||||
AFMKey key;
|
||||
double value;
|
||||
PRInt32 ivalue;
|
||||
AFMFontInformation *fontinfo;
|
||||
PRInt16 ourfont = -1;
|
||||
PRInt32 i,curIndex,score;
|
||||
nsString psfontname;
|
||||
|
||||
// have to find the correct fontfamily, weight and style
|
||||
psfontname.SetString(aFont.name);
|
||||
|
||||
// look in the font table for one of the fonts in the passed in list
|
||||
for(i=0,curIndex=-1;i<NUM_AFM_FONTS;i++){
|
||||
gSubstituteFonts[i].mIndex = psfontname.RFind((const char*)gSubstituteFonts[i].mFamily,PR_TRUE);
|
||||
|
||||
// if a font was found matching this criteria
|
||||
if((gSubstituteFonts[i].mIndex==0) || (!aPrimaryOnly && gSubstituteFonts[i].mIndex>=0)){
|
||||
// give it a score
|
||||
score = abs(aFont.weight-gSubstituteFonts[i].mWeight);
|
||||
score+= abs(aFont.style-gSubstituteFonts[i].mStyle);
|
||||
if(score == 0){
|
||||
curIndex = i;
|
||||
break;
|
||||
}
|
||||
gSubstituteFonts[i].mIndex = score;
|
||||
}
|
||||
}
|
||||
|
||||
// if its ok to look for the second best, and we did not find a perfect match
|
||||
score = 32000;
|
||||
if((PR_FALSE == aPrimaryOnly)&&(curIndex !=0)) {
|
||||
for(i=0;i<NUM_AFM_FONTS;i++){
|
||||
if((gSubstituteFonts[i].mIndex>0) && (gSubstituteFonts[i].mIndex<score)){
|
||||
score = gSubstituteFonts[i].mIndex;
|
||||
curIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(curIndex>=0){
|
||||
mPSFontInfo = new AFMFontInformation;
|
||||
memset(mPSFontInfo,0,sizeof(AFMFontInformation));
|
||||
|
||||
memcpy(mPSFontInfo,(gSubstituteFonts[curIndex].mFontInfo),sizeof(AFMFontInformation));
|
||||
mPSFontInfo->mAFMCharMetrics = new AFMscm[mPSFontInfo->mNumCharacters];
|
||||
memset(mPSFontInfo->mAFMCharMetrics,0,sizeof(AFMscm)*mPSFontInfo->mNumCharacters);
|
||||
memcpy(mPSFontInfo->mAFMCharMetrics,gSubstituteFonts[curIndex].mCharInfo,gSubstituteFonts[curIndex].mFontInfo->mNumCharacters*sizeof(AFMscm));
|
||||
ourfont = curIndex;
|
||||
}
|
||||
|
||||
return ourfont;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 2/25/99 dwc
|
||||
*/
|
||||
PRInt16
|
||||
nsAFMObject::CreateSubstituteFont(const nsFont &aFontName)
|
||||
{
|
||||
PRInt16 ourfont = 0;
|
||||
|
||||
mPSFontInfo = new AFMFontInformation;
|
||||
fontinfo = mPSFontInfo;
|
||||
memset(mPSFontInfo,0,sizeof(AFMFontInformation));
|
||||
|
||||
// Open the file
|
||||
mAFMFile = fopen("hv.afm","r");
|
||||
// put in default AFM data, can't find the correct AFM file
|
||||
memcpy(mPSFontInfo,&Times_RomanAFM,sizeof(AFMFontInformation));
|
||||
mPSFontInfo->mAFMCharMetrics = new AFMscm[mPSFontInfo->mNumCharacters];
|
||||
memset(mPSFontInfo->mAFMCharMetrics,0,sizeof(AFMscm)*mPSFontInfo->mNumCharacters);
|
||||
memcpy(mPSFontInfo->mAFMCharMetrics,AFMTimes_RomanChars,Times_RomanAFM.mNumCharacters*sizeof(AFMscm));
|
||||
return ourfont;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 2/25/99 dwc
|
||||
*/
|
||||
PRBool
|
||||
nsAFMObject::AFM_ReadFile(const nsFont &aFontName)
|
||||
{
|
||||
PRBool done=PR_FALSE;
|
||||
PRBool success = PR_FALSE;
|
||||
PRBool bvalue;
|
||||
AFMKey key;
|
||||
double value;
|
||||
PRInt32 ivalue;
|
||||
char *AFMFileName; // file we will open
|
||||
|
||||
|
||||
AFMFileName = aFontName.name.ToNewCString();
|
||||
|
||||
// Open the file
|
||||
mAFMFile = fopen(AFMFileName,"r");
|
||||
|
||||
if(nsnull != mAFMFile) {
|
||||
// create the structure to put the information in
|
||||
mPSFontInfo = new AFMFontInformation;
|
||||
memset(mPSFontInfo,0,sizeof(AFMFontInformation));
|
||||
|
||||
// Check for valid AFM file
|
||||
GetKey(&key);
|
||||
if(key == kStartFontMetrics){
|
||||
GetAFMNumber(&fontinfo->mFontVersion);
|
||||
GetAFMNumber(&mPSFontInfo->mFontVersion);
|
||||
|
||||
while(!done){
|
||||
GetKey(&key);
|
||||
|
@ -183,7 +306,7 @@ AFMFontInformation *fontinfo;
|
|||
GetLine();
|
||||
break;
|
||||
case kStartFontMetrics:
|
||||
GetAFMNumber(&fontinfo->mFontVersion);
|
||||
GetAFMNumber(&mPSFontInfo->mFontVersion);
|
||||
break;
|
||||
case kEndFontMetrics:
|
||||
done = PR_TRUE;
|
||||
|
@ -194,77 +317,77 @@ AFMFontInformation *fontinfo;
|
|||
case kEndMasterFontMetrics:
|
||||
break;
|
||||
case kFontName:
|
||||
fontinfo->mFontName = GetAFMString();
|
||||
mPSFontInfo->mFontName = GetAFMString();
|
||||
break;
|
||||
case kFullName:
|
||||
fontinfo->mFullName = GetAFMString();
|
||||
mPSFontInfo->mFullName = GetAFMString();
|
||||
break;
|
||||
case kFamilyName:
|
||||
fontinfo->mFamilyName = GetAFMString();
|
||||
mPSFontInfo->mFamilyName = GetAFMString();
|
||||
break;
|
||||
case kWeight:
|
||||
fontinfo->mWeight = GetAFMString();
|
||||
mPSFontInfo->mWeight = GetAFMString();
|
||||
break;
|
||||
case kFontBBox:
|
||||
GetAFMNumber(&fontinfo->mFontBBox_llx);
|
||||
GetAFMNumber(&fontinfo->mFontBBox_lly);
|
||||
GetAFMNumber(&fontinfo->mFontBBox_urx);
|
||||
GetAFMNumber(&fontinfo->mFontBBox_ury);
|
||||
GetAFMNumber(&mPSFontInfo->mFontBBox_llx);
|
||||
GetAFMNumber(&mPSFontInfo->mFontBBox_lly);
|
||||
GetAFMNumber(&mPSFontInfo->mFontBBox_urx);
|
||||
GetAFMNumber(&mPSFontInfo->mFontBBox_ury);
|
||||
break;
|
||||
case kVersion:
|
||||
fontinfo->mVersion = GetAFMString();
|
||||
mPSFontInfo->mVersion = GetAFMString();
|
||||
break;
|
||||
case kNotice:
|
||||
fontinfo->mNotice = GetAFMString();
|
||||
mPSFontInfo->mNotice = GetAFMString();
|
||||
// we really dont want to keep this around...
|
||||
delete [] fontinfo->mNotice;
|
||||
fontinfo->mNotice = 0;
|
||||
delete [] mPSFontInfo->mNotice;
|
||||
mPSFontInfo->mNotice = 0;
|
||||
break;
|
||||
case kEncodingScheme:
|
||||
fontinfo->mEncodingScheme = GetAFMString();
|
||||
mPSFontInfo->mEncodingScheme = GetAFMString();
|
||||
break;
|
||||
case kMappingScheme:
|
||||
GetAFMInt(&fontinfo->mMappingScheme);
|
||||
GetAFMInt(&mPSFontInfo->mMappingScheme);
|
||||
break;
|
||||
case kEscChar:
|
||||
GetAFMInt(&fontinfo->mEscChar);
|
||||
GetAFMInt(&mPSFontInfo->mEscChar);
|
||||
break;
|
||||
case kCharacterSet:
|
||||
fontinfo->mCharacterSet = GetAFMString();
|
||||
mPSFontInfo->mCharacterSet = GetAFMString();
|
||||
break;
|
||||
case kCharacters:
|
||||
GetAFMInt(&fontinfo->mCharacters);
|
||||
GetAFMInt(&mPSFontInfo->mCharacters);
|
||||
break;
|
||||
case kIsBaseFont:
|
||||
GetAFMBool (&fontinfo->mIsBaseFont);
|
||||
GetAFMBool (&mPSFontInfo->mIsBaseFont);
|
||||
break;
|
||||
case kVVector:
|
||||
GetAFMNumber(&fontinfo->mVVector_0);
|
||||
GetAFMNumber(&fontinfo->mVVector_1);
|
||||
GetAFMNumber(&mPSFontInfo->mVVector_0);
|
||||
GetAFMNumber(&mPSFontInfo->mVVector_1);
|
||||
break;
|
||||
case kIsFixedV:
|
||||
GetAFMBool (&fontinfo->mIsFixedV);
|
||||
GetAFMBool (&mPSFontInfo->mIsFixedV);
|
||||
break;
|
||||
case kCapHeight:
|
||||
GetAFMNumber(&fontinfo->mCapHeight);
|
||||
GetAFMNumber(&mPSFontInfo->mCapHeight);
|
||||
break;
|
||||
case kXHeight:
|
||||
GetAFMNumber(&fontinfo->mXHeight);
|
||||
GetAFMNumber(&mPSFontInfo->mXHeight);
|
||||
break;
|
||||
case kAscender:
|
||||
GetAFMNumber(&fontinfo->mAscender);
|
||||
GetAFMNumber(&mPSFontInfo->mAscender);
|
||||
break;
|
||||
case kDescender:
|
||||
GetAFMNumber(&fontinfo->mDescender);
|
||||
GetAFMNumber(&mPSFontInfo->mDescender);
|
||||
break;
|
||||
case kStartDirection:
|
||||
GetAFMInt(&ivalue);
|
||||
break;
|
||||
case kUnderlinePosition:
|
||||
GetAFMNumber(&fontinfo->mUnderlinePosition);
|
||||
GetAFMNumber(&mPSFontInfo->mUnderlinePosition);
|
||||
break;
|
||||
case kUnderlineThickness:
|
||||
GetAFMNumber(&fontinfo->mUnderlineThickness);
|
||||
GetAFMNumber(&mPSFontInfo->mUnderlineThickness);
|
||||
break;
|
||||
case kItalicAngle:
|
||||
GetAFMNumber(&value);
|
||||
|
@ -279,9 +402,10 @@ AFMFontInformation *fontinfo;
|
|||
case kEndDirection:
|
||||
break;
|
||||
case kStartCharMetrics:
|
||||
GetAFMInt(&ivalue); // number of charaters that follow
|
||||
fontinfo->AFMCharMetrics = new AFMscm[ivalue];
|
||||
ReadCharMetrics (fontinfo,ivalue);
|
||||
GetAFMInt(&mPSFontInfo->mNumCharacters); // number of charaters that follow
|
||||
mPSFontInfo->mAFMCharMetrics = new AFMscm[mPSFontInfo->mNumCharacters];
|
||||
memset(mPSFontInfo->mAFMCharMetrics,0,sizeof(AFMscm)*mPSFontInfo->mNumCharacters);
|
||||
ReadCharMetrics (mPSFontInfo,mPSFontInfo->mNumCharacters);
|
||||
break;
|
||||
case kStartKernData:
|
||||
break;
|
||||
|
@ -291,7 +415,17 @@ AFMFontInformation *fontinfo;
|
|||
}
|
||||
}
|
||||
fclose(mAFMFile);
|
||||
success = PR_TRUE;
|
||||
} else {
|
||||
// put in default AFM data, can't find the correct AFM file
|
||||
//memcpy(mPSFontInfo,&HelveticaAFM,sizeof(AFMFontInformation));
|
||||
// mPSFontInfo->mAFMCharMetrics = new AFMscm[mPSFontInfo->mNumCharacters];
|
||||
//memset(mPSFontInfo->mAFMCharMetrics,0,sizeof(AFMscm)*mPSFontInfo->mNumCharacters);
|
||||
//memcpy(mPSFontInfo->mAFMCharMetrics,AFMHelveticaChars,HelveticaAFM.mNumCharacters*sizeof(AFMscm));
|
||||
}
|
||||
|
||||
delete [] AFMFileName;
|
||||
return(success);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -360,9 +494,9 @@ PRBool found = PR_FALSE;
|
|||
PRInt32
|
||||
nsAFMObject::GetToken()
|
||||
{
|
||||
PRInt32 ch;
|
||||
PRInt32 i;
|
||||
PRInt32 len;
|
||||
PRInt32 ch;
|
||||
PRInt32 i;
|
||||
PRInt32 len;
|
||||
|
||||
// skip leading whitespace
|
||||
while((ch=getc(mAFMFile)) != EOF) {
|
||||
|
@ -376,9 +510,9 @@ PRInt32 len;
|
|||
ungetc(ch,mAFMFile);
|
||||
|
||||
// get name
|
||||
for(i=0,ch=getc(mAFMFile);i<sizeof(mToken) && ch!=EOF && !ISSPACE(ch);i++,ch=getc(mAFMFile)){
|
||||
len = (PRInt32)sizeof(mToken);
|
||||
mToken[i] = ch;
|
||||
len = (PRInt32)sizeof(mToken);
|
||||
for(i=0,ch=getc(mAFMFile);i<len && ch!=EOF && !ISSPACE(ch);i++,ch=getc(mAFMFile)){
|
||||
mToken[i] = ch;
|
||||
}
|
||||
|
||||
// is line longer than the AFM specifications
|
||||
|
@ -458,6 +592,8 @@ PRInt32 i = 0,ivalue,first=1;
|
|||
AFMscm *cm = NULL;
|
||||
AFMKey key;
|
||||
PRBool done = PR_FALSE;
|
||||
double notyet;
|
||||
char *name;
|
||||
|
||||
while (done!=PR_TRUE && i<aNumCharacters){
|
||||
GetKey (&key);
|
||||
|
@ -473,7 +609,7 @@ PRBool done = PR_FALSE;
|
|||
//parse_error (handle, AFM_ERROR_SYNTAX);
|
||||
}
|
||||
|
||||
cm = &(aFontInfo->AFMCharMetrics[i]);
|
||||
cm = &(aFontInfo->mAFMCharMetrics[i]);
|
||||
// character code
|
||||
GetAFMInt(&ivalue); // character code
|
||||
cm->mCharacter_Code = ivalue;
|
||||
|
@ -511,11 +647,15 @@ PRBool done = PR_FALSE;
|
|||
GetAFMNumber(&(cm->mW1y));
|
||||
break;
|
||||
case kVV:
|
||||
GetAFMNumber(&(cm->mVv_x));
|
||||
GetAFMNumber(&(cm->mVv_y));
|
||||
//GetAFMNumber(&(cm->mVv_x));
|
||||
//GetAFMNumber(&(cm->mVv_y));
|
||||
GetAFMNumber(¬yet);
|
||||
GetAFMNumber(¬yet);
|
||||
break;
|
||||
case kN:
|
||||
cm->mName = GetAFMName();
|
||||
//cm->mName = GetAFMName();
|
||||
name = GetAFMName();
|
||||
delete [] name;
|
||||
break;
|
||||
|
||||
case kB:
|
||||
|
@ -576,50 +716,132 @@ char *thestring;
|
|||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 2/1/99 dwc
|
||||
* @update 2/01/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject :: GetStringWidth(const char *aString,nscoord& aWidth,nscoord aLength)
|
||||
{
|
||||
char *cptr;
|
||||
PRInt32 i,fwidth,index;
|
||||
PRInt32 totallen=0;
|
||||
float totallen=0.0f;
|
||||
|
||||
// add up the length of the character widths, in floating to avoid roundoff
|
||||
aWidth = 0;
|
||||
cptr = (char*) aString;
|
||||
|
||||
for(i=0;i<aLength;i++,cptr++){
|
||||
index = *cptr-32;
|
||||
fwidth = mPSFontInfo->AFMCharMetrics[index].mW0x;
|
||||
totallen += (fwidth*mFontHeight)/1000;
|
||||
fwidth = (PRInt32)(mPSFontInfo->mAFMCharMetrics[index].mW0x);
|
||||
totallen += fwidth;
|
||||
}
|
||||
|
||||
aWidth = totallen;
|
||||
// total length is in points, so convert to twips, divide by the 1000 scaling of the
|
||||
// afm measurements, and round the result.
|
||||
totallen = NSFloatPointsToTwips(totallen * mFontHeight)/1000.0f;
|
||||
|
||||
aWidth = NSToIntRound(totallen);
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 2/1/99 dwc
|
||||
* @update 2/01/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject :: GetStringWidth(const PRUnichar *aString,nscoord& aWidth,nscoord aLength)
|
||||
{
|
||||
PRUint8 asciichar;
|
||||
PRUnichar *cptr;
|
||||
PRInt32 i ,fwidth,index;
|
||||
PRInt32 totallen=0;
|
||||
PRUint8 asciichar;
|
||||
PRUnichar *cptr;
|
||||
PRInt32 i ,fwidth,index;
|
||||
float totallen=0.0f;
|
||||
|
||||
//XXX This is not handle correctly yet!! DWC
|
||||
aWidth = 0;
|
||||
//XXX This needs to get the aString converted to a normal cstring DWC
|
||||
aWidth = 0;
|
||||
cptr = (PRUnichar*)aString;
|
||||
|
||||
for(i=0;i<aLength;i++,cptr++){
|
||||
asciichar = (*cptr)&0x00ff;
|
||||
index = asciichar-32;
|
||||
fwidth = mPSFontInfo->AFMCharMetrics[index].mW0x;
|
||||
totallen += (fwidth*mFontHeight)/1000;
|
||||
fwidth = (PRInt32)(mPSFontInfo->mAFMCharMetrics[index].mW0x);
|
||||
totallen += fwidth;
|
||||
}
|
||||
|
||||
aWidth = totallen;
|
||||
totallen = NSFloatPointsToTwips(totallen * mFontHeight)/1000.0f;
|
||||
aWidth = NSToIntRound(totallen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define CORRECTSTRING(d) (d?d:"")
|
||||
#define BOOLOUT(B) (mPSFontInfo->mIsBaseFont==PR_TRUE?"PR_TRUE":"PR_FALSE")
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 3/05/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject :: WriteFontHeaderInformation(FILE *aOutFile)
|
||||
{
|
||||
|
||||
// main information of the font
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mFontVersion);
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mFontName));
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mFullName));
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mFamilyName));
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mWeight));
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mFontBBox_llx);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mFontBBox_lly);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mFontBBox_urx);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mFontBBox_ury);
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mVersion));
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mNotice));
|
||||
fprintf(aOutFile,"\"%s\",\n",CORRECTSTRING(mPSFontInfo->mEncodingScheme));
|
||||
fprintf(aOutFile,"%ld,\n",mPSFontInfo->mMappingScheme);
|
||||
fprintf(aOutFile,"%ld,\n",mPSFontInfo->mEscChar);
|
||||
fprintf(aOutFile,"\"%s\",\n", CORRECTSTRING(mPSFontInfo->mCharacterSet));
|
||||
fprintf(aOutFile,"%ld,\n",mPSFontInfo->mCharacters);
|
||||
fprintf(aOutFile,"%s,\n",BOOLOUT(mPSFontInfo->mIsBaseFont));
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mVVector_0);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mVVector_1);
|
||||
fprintf(aOutFile,"%s,\n",BOOLOUT(mPSFontInfo->mIsFixedV));
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mCapHeight);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mXHeight);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mAscender);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mDescender);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mUnderlinePosition);
|
||||
fprintf(aOutFile,"%f,\n",mPSFontInfo->mUnderlineThickness);
|
||||
fprintf(aOutFile,"%ld\n",mPSFontInfo->mNumCharacters);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsAFMParser.h
|
||||
* @update 3/05/99 dwc
|
||||
*/
|
||||
void
|
||||
nsAFMObject :: WriteFontCharInformation(FILE *aOutFile)
|
||||
{
|
||||
PRInt32 i;
|
||||
|
||||
|
||||
// individual font characteristics
|
||||
for(i=0;i<mPSFontInfo->mNumCharacters;i++) {
|
||||
fprintf(aOutFile,"{\n");
|
||||
fprintf(aOutFile,"%ld, \n",mPSFontInfo->mAFMCharMetrics[i].mCharacter_Code);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mW0x);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mW0y);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mW1x);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mW1y);
|
||||
//fprintf(aOutFile,"\"%s\", \n", CORRECTSTRING(mPSFontInfo->mAFMCharMetrics[i].mName));
|
||||
//fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mVv_x);
|
||||
//fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mVv_y);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mLlx);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mLly);
|
||||
fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].mUrx);
|
||||
fprintf(aOutFile,"%f \n",mPSFontInfo->mAFMCharMetrics[i].mUry);
|
||||
//fprintf(aOutFile,"%f, \n",mPSFontInfo->mAFMCharMetrics[i].num_ligatures);
|
||||
fprintf(aOutFile,"}\n");
|
||||
if ( i != mPSFontInfo->mNumCharacters - 1 )
|
||||
fputc( ',', aOutFile );
|
||||
fputc( '\n', aOutFile );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,13 +145,13 @@ struct AFM_Single_Char_Metrics
|
|||
{
|
||||
|
||||
PRInt32 mCharacter_Code; // default charcode (-1 if not encoded)
|
||||
double mW0x; // character width x in writing direction 0
|
||||
double mW0y; // character width y in writing direction 0
|
||||
double mW1x; // character width x in writing direction 1
|
||||
double mW1y; // character width y in writing direction 1
|
||||
char *mName; // character name
|
||||
double mVv_x; // local VVector x
|
||||
double mVv_y; // local VVector y
|
||||
double mW0x; // character width x in writing direction 0,
|
||||
double mW0y; // character width y in writing direction 0
|
||||
double mW1x; // character width x in writing direction 1
|
||||
double mW1y; // character width y in writing direction 1
|
||||
//char *mName; // character name , not using currently
|
||||
//double mVv_x; // local VVector x , not using currently
|
||||
//double mVv_y; // local VVector y , not using currently
|
||||
|
||||
// character bounding box.
|
||||
double mLlx;
|
||||
|
@ -159,7 +159,7 @@ struct AFM_Single_Char_Metrics
|
|||
double mUrx;
|
||||
double mUry;
|
||||
|
||||
double num_ligatures;
|
||||
//double num_ligatures;
|
||||
|
||||
//AFMLigature *ligatures;
|
||||
};
|
||||
|
@ -169,7 +169,6 @@ typedef struct AFM_Single_Char_Metrics AFMscm;
|
|||
|
||||
|
||||
// Font information which we get from AFM files, this is needed for the PS output
|
||||
|
||||
struct fontInformation
|
||||
{
|
||||
double mFontVersion;
|
||||
|
@ -199,7 +198,8 @@ struct fontInformation
|
|||
double mUnderlinePosition;
|
||||
double mUnderlineThickness;
|
||||
|
||||
AFMscm *AFMCharMetrics;
|
||||
PRInt32 mNumCharacters;
|
||||
AFMscm *mAFMCharMetrics;
|
||||
|
||||
};
|
||||
|
||||
|
@ -227,9 +227,44 @@ public:
|
|||
* Initialize an AFMObject
|
||||
* @update 2/26/99 dwc
|
||||
* @param aFontName - A "C" string name of the font this object will get initialized to
|
||||
* @param aFontHeight -- The font size for this object
|
||||
* @param aFontHeight -- The initial font size, this can be changed with the SetFontSize method
|
||||
* @return VOID
|
||||
*/
|
||||
void Init(char *aFontName,PRInt32 aFontHeight);
|
||||
void Init(PRInt32 aFontHeight);
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Read in and parse and AFM file
|
||||
* @update 2/26/99 dwc
|
||||
* @param aFontName -- The name of the font we want to read in
|
||||
* @return VOID
|
||||
*/
|
||||
PRBool AFM_ReadFile(const nsFont &aFontName);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Check to see if this font is one of our basic fonts, if so create an AFMObject from it
|
||||
* @update 2/26/99 dwc
|
||||
* @param aFont -- The font to be constructed (family name, weight, style)
|
||||
* @param aPrimaryOnly -- if true, only looking for the first font name in aFontName
|
||||
* @return -- the font index into our table if a native font was found, -1 otherwise
|
||||
*/
|
||||
PRInt16 CheckBasicFonts(const nsFont &aFont,PRBool aPrimaryOnly=PR_FALSE);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Create a substitute Font
|
||||
* @update 2/26/99 dwc
|
||||
* @param aFont -- The font to create a substitute for (family name, weight, style)
|
||||
* @return -- the font index into our table if a native font was found, -1 otherwise
|
||||
*/
|
||||
PRInt16 CreateSubstituteFont(const nsFont &aFont);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Set the font size, which is used to calculate the distances for the font
|
||||
* @update 3/05/99 dwc
|
||||
* @param aFontSize - The size of the font for the calculation
|
||||
* @return VOID
|
||||
*/
|
||||
void SetFontSize(PRInt32 aFontHeight) { mFontHeight = aFontHeight; }
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -238,6 +273,7 @@ public:
|
|||
* @param aString - The unicharacter string to get the width for
|
||||
* @param aWidth - Where the width of the string will be put.
|
||||
* @param aLenth - The length of the passed in string
|
||||
* @return VOID
|
||||
*/
|
||||
void GetStringWidth(const PRUnichar *aString,nscoord& aWidth,nscoord aLength);
|
||||
|
||||
|
@ -250,73 +286,97 @@ public:
|
|||
*/
|
||||
void GetStringWidth(const char *aString,nscoord& aWidth,nscoord aLength);
|
||||
|
||||
protected:
|
||||
/** ---------------------------------------------------
|
||||
* Read in and parse and AFM file
|
||||
* @update 2/26/99 dwc
|
||||
* Write out the AFMFontInformation Header from the currently parsed AFM file, this will write a ASCII file
|
||||
* so you can use it as a head if need be.
|
||||
* @update 3/09/99 dwc
|
||||
* @param aOutFile -- File to write to
|
||||
* @return VOID
|
||||
*/
|
||||
void AFM_ReadFile(void);
|
||||
void WriteFontHeaderInformation(FILE *aOutFile);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Write out the AFMFontInformation character data from the currently parsed AFM file, this will write a ASCII file
|
||||
* so you can use it as a head if need be.
|
||||
* @update 3/09/99 dwc
|
||||
* @param aOutFile -- File to write to
|
||||
* @return VOID
|
||||
*/
|
||||
void WriteFontCharInformation(FILE *aOutFile);
|
||||
protected:
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a Keyword in the AFM file being parsed
|
||||
* @update 2/26/99 dwc
|
||||
* @return VOID
|
||||
*/
|
||||
void GetKey(AFMKey *aTheKey);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a token from the AFM file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- The found token
|
||||
*/
|
||||
PRInt32 GetToken(void);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* For a given token, find the keyword it represents
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- The key found
|
||||
*/
|
||||
PRInt32 MatchKey(char *aKey);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a line from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- The current line
|
||||
*/
|
||||
PRInt32 GetLine(void);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a string from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- the current string
|
||||
*/
|
||||
char* GetAFMString (void);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a word from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- a string with the name
|
||||
*/
|
||||
char* GetAFMName (void);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get an integer from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- the current integer
|
||||
*/
|
||||
void GetAFMInt (PRInt32 *aInt) {GetToken();*aInt = atoi (mToken);}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a floating point number from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @return -- the current floating point
|
||||
*/
|
||||
void GetAFMNumber (double *aFloat){GetToken();*aFloat = atof (mToken);}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Get a boolean from the currently parsed file
|
||||
* @update 2/26/99 dwc
|
||||
* @param -- The current boolean found is passed back
|
||||
*/
|
||||
void GetAFMBool (PRBool *aBool);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Read in the AFMFontInformation from the currently parsed AFM file
|
||||
* @update 2/26/99 dwc
|
||||
* @param aFontInfo -- The header structure to read the caracter info from
|
||||
* @param aNumCharacters -- The number of characters to look for
|
||||
*/
|
||||
void ReadCharMetrics (AFMFontInformation *aFontInfo,PRInt32 aNumCharacters);
|
||||
|
||||
|
||||
public:
|
||||
AFMFontInformation *mPSFontInfo;
|
||||
|
||||
|
@ -332,5 +392,31 @@ protected:
|
|||
|
||||
#define NUM_KEYS (sizeof (keynames) / sizeof (struct keyname_st) - 1)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A static structure initialized with the default fonts for postscript
|
||||
* @update 3/12/99 dwc
|
||||
* @member mFontName -- string with the substitute font name
|
||||
* @member mFontInfo -- AFM font information header created with the AFMGen program
|
||||
* @member mCharInfo -- Character information created with the AFMGen program
|
||||
* @member mIndex -- This member field is used when substituting fonts
|
||||
*/
|
||||
struct AFM_SubstituteFonts
|
||||
{
|
||||
char* mPSName;
|
||||
char* mFamily;
|
||||
PRUint16 mWeight;
|
||||
PRUint8 mStyle;
|
||||
AFMFontInformation* mFontInfo;
|
||||
AFMscm* mCharInfo;
|
||||
PRInt32 mIndex;
|
||||
};
|
||||
|
||||
typedef struct AFM_SubstituteFonts DefFonts;
|
||||
|
||||
extern DefFonts gSubstituteFonts[];
|
||||
|
||||
// number of supported default fonts
|
||||
#define NUM_AFM_FONTS 13
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "nsPostScriptObj.h"
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
|
@ -263,9 +263,16 @@ NS_IMETHODIMP nsDeviceContextPS::GetDeviceContextFor(nsIDeviceContextSpec *aDevi
|
|||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::BeginDocument(void)
|
||||
{
|
||||
nsIDeviceContextSpecPS *psSpec;
|
||||
nsresult res;
|
||||
|
||||
mPSObj = new nsPostScriptObj();
|
||||
|
||||
if ( nsnull != mSpec ) {
|
||||
mPSObj = new nsPostScriptObj();
|
||||
res = mSpec->QueryInterface(kIDeviceContextSpecPSIID, (void **) &psSpec);
|
||||
if ( res == NS_OK ) {
|
||||
mPSObj->Init(psSpec);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ nsFontMetricsPS :: ~nsFontMetricsPS()
|
|||
mFont = nsnull;
|
||||
}
|
||||
|
||||
if(nsnull != mAFMInfo){
|
||||
delete mAFMInfo;
|
||||
mAFMInfo = nsnull;
|
||||
}
|
||||
|
||||
|
||||
mDeviceContext = nsnull;
|
||||
}
|
||||
|
||||
|
@ -108,13 +114,27 @@ NS_IMPL_ISUPPORTS(nsFontMetricsPS, kIFontMetricsIID)
|
|||
NS_IMETHODIMP
|
||||
nsFontMetricsPS :: Init(const nsFont& aFont, nsIDeviceContext *aContext)
|
||||
{
|
||||
|
||||
mFont = new nsFont(aFont);
|
||||
//don't addref this to avoid circular refs
|
||||
mDeviceContext = (nsDeviceContextPS *)aContext;
|
||||
|
||||
// get the AFM information
|
||||
mAFMInfo = new nsAFMObject();
|
||||
mAFMInfo->Init("Helvetica",mFont->size/20);
|
||||
mAFMInfo->Init(mFont->size/20);
|
||||
|
||||
// first see if the primary font is available
|
||||
mFontIndex = mAFMInfo->CheckBasicFonts(aFont,PR_TRUE);
|
||||
if( mFontIndex < 0){
|
||||
// look in an AFM file for the primary font
|
||||
if (PR_FALSE == mAFMInfo->AFM_ReadFile(aFont) ) {
|
||||
// look for secondary fonts
|
||||
mFontIndex = mAFMInfo->CheckBasicFonts(aFont,PR_FALSE);
|
||||
if( mFontIndex < 0){
|
||||
mFontIndex = mAFMInfo->CreateSubstituteFont(aFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RealizeFont();
|
||||
return NS_OK;
|
||||
|
@ -137,23 +157,50 @@ nsFontMetricsPS::RealizeFont()
|
|||
{
|
||||
float fontsize;
|
||||
float dev2app;
|
||||
float offset;
|
||||
|
||||
mDeviceContext->GetDevUnitsToAppUnits(dev2app);
|
||||
nscoord onePixel = NSToCoordRound(1 * dev2app);
|
||||
|
||||
// convert the font size which is in twips to points
|
||||
fontsize = mFont->size/20.0f;
|
||||
|
||||
mXHeight = NSToCoordRound((float)((fontsize*mAFMInfo->mPSFontInfo->mXHeight)/1000.0)*dev2app);
|
||||
offset=NSFloatPointsToTwips(fontsize*mAFMInfo->mPSFontInfo->mXHeight)/1000.0f;
|
||||
mXHeight = NSToCoordRound(offset);
|
||||
//mXHeight = NSToCoordRound((float)((fontsize*mAFMInfo->mPSFontInfo->mXHeight)/1000.0)*dev2app);
|
||||
|
||||
mSuperscriptOffset = mXHeight;
|
||||
mSubscriptOffset = mXHeight;
|
||||
|
||||
mStrikeoutSize = onePixel;
|
||||
mStrikeoutOffset = (nscoord)(mXHeight / 2.0f);
|
||||
mUnderlineSize = onePixel;
|
||||
mUnderlineOffset = (nscoord)(NSToCoordRound((float)((fabs(fontsize*mAFMInfo->mPSFontInfo->mUnderlinePosition))/1000)*dev2app));
|
||||
|
||||
|
||||
offset=NSFloatPointsToTwips(fontsize*mAFMInfo->mPSFontInfo->mUnderlinePosition)/1000.0f;
|
||||
mUnderlineOffset = NSToCoordRound(offset);
|
||||
//mUnderlineOffset = (nscoord)(NSToCoordRound((float)((fabs(fontsize*mAFMInfo->mPSFontInfo->mUnderlinePosition))/1000)*dev2app));
|
||||
|
||||
//offset = mAFMInfo->mPSFontInfo->mFontBBox_ury-mAFMInfo->mPSFontInfo->mFontBBox_lly;
|
||||
//offset = NSFloatPointsToTwips(fontsize*offset)/1000.0f;
|
||||
//mHeight = NSToCoordRound(offset);
|
||||
mHeight = NSToCoordRound(fontsize * dev2app);
|
||||
mAscent = NSToCoordRound((float)((fontsize*mAFMInfo->mPSFontInfo->mAscender)/1000)*dev2app);
|
||||
mDescent = NSToCoordRound((float)((fabs(fontsize*mAFMInfo->mPSFontInfo->mDescender))/1000)*dev2app);
|
||||
|
||||
|
||||
offset=NSFloatPointsToTwips(fontsize*mAFMInfo->mPSFontInfo->mAscender)/1000.0f;
|
||||
mAscent = NSToCoordRound(offset);
|
||||
//mAscent = NSToCoordRound((float)((fontsize*mAFMInfo->mPSFontInfo->mAscender)/1000)*dev2app);
|
||||
|
||||
offset=NSFloatPointsToTwips(fontsize*mAFMInfo->mPSFontInfo->mDescender)/1000.0f;
|
||||
mDescent = NSToCoordRound(offset);
|
||||
//mDescent = NSToCoordRound((float)((fabs(fontsize*mAFMInfo->mPSFontInfo->mDescender))/1000)*dev2app);
|
||||
|
||||
offset=NSFloatPointsToTwips(fontsize*mAFMInfo->mPSFontInfo->mDescender)/1000.0f;
|
||||
mDescent = NSToCoordRound(offset);
|
||||
|
||||
//mHeight = mAscent + -mDescent;
|
||||
|
||||
|
||||
mLeading = 0;
|
||||
mMaxAscent = mAscent;
|
||||
mMaxDescent = mDescent;
|
||||
|
|
|
@ -58,6 +58,8 @@ public:
|
|||
NS_IMETHOD GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength);
|
||||
NS_IMETHOD GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength);
|
||||
|
||||
PRInt16 GetFontIndex() { return mFontIndex; }
|
||||
|
||||
protected:
|
||||
void RealizeFont();
|
||||
|
||||
|
@ -77,6 +79,9 @@ protected:
|
|||
nscoord mStrikeoutOffset;
|
||||
nscoord mUnderlineSize;
|
||||
nscoord mUnderlineOffset;
|
||||
PRInt16 mFontIndex;
|
||||
|
||||
public:
|
||||
nsAFMObject *mAFMInfo;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/* -*- 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 nsIDeviceContextSpecPS_h___
|
||||
#define nsIDeviceContextSpecPS_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_IDEVICE_CONTEXT_SPEC_PS_IID { 0xa4ef8910, 0xdd65, 0x11d2, { 0xa8, 0x32, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
|
||||
|
||||
class nsIDeviceContextSpecPS : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
/*
|
||||
* If PR_TRUE, print to printer
|
||||
* @update
|
||||
* @param aToPrinter --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetToPrinter( PRBool &aToPrinter ) = 0;
|
||||
|
||||
/*
|
||||
* If PR_TRUE, first page first
|
||||
* @update
|
||||
* @param aFpf --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf ) = 0;
|
||||
|
||||
/*
|
||||
* If PR_TRUE, print grayscale
|
||||
* @update
|
||||
* @param aGrayscale --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetGrayscale( PRBool &aGrayscale ) = 0;
|
||||
|
||||
/*
|
||||
* Paper size e.g., NS_LETTER_SIZE
|
||||
* @update
|
||||
* @param aSize --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetSize ( int &aSize ) = 0;
|
||||
|
||||
/*
|
||||
* Top margin
|
||||
* @update
|
||||
* @param aValue --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetTopMargin ( float &aValue ) = 0;
|
||||
|
||||
/*
|
||||
* Bottom margin
|
||||
* @update
|
||||
* @param aValue --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetBottomMargin ( float &aValue ) = 0;
|
||||
|
||||
/*
|
||||
* Left margin
|
||||
* @update
|
||||
* @param aValue --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetLeftMargin ( float &aValue ) = 0;
|
||||
|
||||
/*
|
||||
* Right margin
|
||||
* @update
|
||||
* @param aValue --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetRightMargin ( float &aValue ) = 0;
|
||||
|
||||
/*
|
||||
* Print command e.g., lpr
|
||||
* @update
|
||||
* @param aCommand --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetCommand ( char **aCommand ) = 0;
|
||||
|
||||
/*
|
||||
* If toPrinter = PR_FALSE, dest file
|
||||
* @update
|
||||
* @param aPath --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetPath ( char **aPath ) = 0;
|
||||
|
||||
/*
|
||||
* If PR_TRUE, user cancelled
|
||||
* @update
|
||||
* @param aCancel --
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetUserCancelled( PRBool &aCancel ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "isotab.c"
|
||||
#include "nsFont.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsAFMObject.h"
|
||||
|
||||
|
||||
extern "C" PS_FontInfo *PSFE_MaskToFI[N_FONTS]; // need fontmetrics.c
|
||||
|
@ -40,92 +41,12 @@ extern "C" PS_FontInfo *PSFE_MaskToFI[N_FONTS]; // need fontmetrics.c
|
|||
*/
|
||||
char* paper_string[]={ "Letter", "Legal", "Executive", "A4" };
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Default Constructor
|
||||
* @update 2/1/99 dwc
|
||||
*/
|
||||
nsPostScriptObj::nsPostScriptObj()
|
||||
{
|
||||
PrintInfo* pi = new PrintInfo();
|
||||
PrintSetup* ps = new PrintSetup();
|
||||
|
||||
mPrintContext = new PSContext();
|
||||
memset(mPrintContext, 0, sizeof(struct PSContext_));
|
||||
memset(ps, 0, sizeof(struct PrintSetup_));
|
||||
memset(pi, 0, sizeof(struct PrintInfo_));
|
||||
|
||||
ps->top = 0; // Margins (PostScript Only)
|
||||
ps->bottom = 0;
|
||||
ps->left = 0;
|
||||
ps->right = 0;
|
||||
ps->width = PAGE_WIDTH; // Paper size, # of cols for text xlate
|
||||
ps->height = PAGE_HEIGHT;
|
||||
ps->header = "header";
|
||||
ps->footer = "footer";
|
||||
ps->sizes = NULL;
|
||||
ps->reverse = 0; // Output order, 0 is acsending
|
||||
ps->color = TRUE; // Image output
|
||||
ps->deep_color = TRUE; // 24 bit color output
|
||||
ps->landscape = FALSE; // Rotated output
|
||||
ps->underline = TRUE; // underline links
|
||||
ps->scale_images = TRUE; // Scale unsized images which are too big
|
||||
ps->scale_pre = FALSE; // do the pre-scaling thing
|
||||
ps->dpi = 72.0f; // dpi for externally sized items
|
||||
ps->rules = 1.0f; // Scale factor for rulers
|
||||
ps->n_up = 0; // cool page combining
|
||||
ps->bigger = 1; // Used to init sizes if sizesin NULL
|
||||
ps->paper_size = NS_LEGAL_SIZE; // Paper Size(letter,legal,exec,a4)
|
||||
ps->prefix = ""; // For text xlate, prepended to each line
|
||||
ps->eol = ""; // For text translation, line terminator
|
||||
ps->bullet = "+"; // What char to use for bullets
|
||||
|
||||
URL_Struct_* url = new URL_Struct_;
|
||||
memset(url, 0, sizeof(URL_Struct_));
|
||||
ps->url = url; // url of doc being translated
|
||||
char filename[30];
|
||||
static char g_nsPostscriptFileCount = 0; //('a');
|
||||
char ext[30];
|
||||
sprintf(ext,"%d",g_nsPostscriptFileCount);
|
||||
sprintf(filename,"file%s.ps", ext);
|
||||
g_nsPostscriptFileCount++;
|
||||
ps->out = fopen(filename , "w"); // Where to send the output
|
||||
ps->filename = filename; // output file name, if any
|
||||
ps->completion = NULL; // Called when translation finished
|
||||
ps->carg = NULL; // Data saved for completion routine
|
||||
ps->status = 0; // Status of URL on completion
|
||||
// "other" font is for encodings other than iso-8859-1
|
||||
ps->otherFontName[0] = NULL;
|
||||
// name of "other" PostScript font
|
||||
ps->otherFontInfo[0] = NULL;
|
||||
// font info parsed from "other" afm file
|
||||
ps->otherFontCharSetID = 0; // charset ID of "other" font
|
||||
//ps->cx = NULL; // original context, if available
|
||||
|
||||
pi->page_height=PAGE_HEIGHT * 10; // Size of printable area on page
|
||||
pi->page_width = PAGE_WIDTH * 10; // Size of printable area on page
|
||||
pi->page_break = 0; // Current page bottom
|
||||
pi->page_topy = 0; // Current page top
|
||||
pi->phase = 0;
|
||||
|
||||
|
||||
pi->pages=NULL; // Contains extents of each page
|
||||
|
||||
pi->pt_size = 0; // Size of above table
|
||||
pi->n_pages = 0; // # of valid entries in above table
|
||||
|
||||
pi->doc_title="Test Title"; // best guess at title
|
||||
pi->doc_width = 0; // Total document width
|
||||
pi->doc_height = 0; // Total document height
|
||||
|
||||
mPrintContext->prInfo = pi;
|
||||
|
||||
// begin the document
|
||||
initialize_translation(ps);
|
||||
|
||||
begin_document();
|
||||
mPrintSetup = ps;
|
||||
mPageNumber = 1; // we are on the first page
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -134,13 +55,13 @@ PrintSetup* ps = new PrintSetup();
|
|||
*/
|
||||
nsPostScriptObj::~nsPostScriptObj()
|
||||
{
|
||||
|
||||
// end the document
|
||||
end_document();
|
||||
|
||||
finalize_translation();
|
||||
|
||||
|
||||
if ( mPrintSetup->filename != (char *) NULL )
|
||||
fclose( mPrintSetup->out );
|
||||
else
|
||||
pclose( mPrintSetup->out );
|
||||
// Cleanup things allocated along the way
|
||||
if (nsnull != mPrintContext){
|
||||
if (nsnull != mPrintContext->prInfo){
|
||||
|
@ -157,6 +78,118 @@ nsPostScriptObj::~nsPostScriptObj()
|
|||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPostScriptObj.h
|
||||
* @update 2/1/99 dwc
|
||||
*/
|
||||
nsresult
|
||||
nsPostScriptObj::Init( nsIDeviceContextSpecPS *aSpec )
|
||||
{
|
||||
PrintInfo* pi = new PrintInfo();
|
||||
PRBool isGray, isAPrinter, isFirstPageFirst;
|
||||
int printSize;
|
||||
char *buf;
|
||||
|
||||
mPrintSetup = new PrintSetup();
|
||||
memset(mPrintSetup, 0, sizeof(struct PrintSetup_));
|
||||
|
||||
mPrintSetup->color = PR_TRUE; // Image output
|
||||
mPrintSetup->deep_color = PR_TRUE; // 24 bit color output
|
||||
mPrintSetup->paper_size = NS_LEGAL_SIZE; // Paper Size(letter,legal,exec,a4)
|
||||
mPrintSetup->reverse = 0; // Output order, 0 is acsending
|
||||
if ( aSpec != nsnull ) {
|
||||
aSpec->GetGrayscale( isGray );
|
||||
if ( isGray == PR_TRUE ) {
|
||||
mPrintSetup->color = PR_FALSE;
|
||||
mPrintSetup->deep_color = PR_FALSE;
|
||||
}
|
||||
aSpec->GetFirstPageFirst( isFirstPageFirst );
|
||||
if ( isFirstPageFirst == PR_FALSE )
|
||||
mPrintSetup->reverse = 1;
|
||||
aSpec->GetSize( printSize );
|
||||
mPrintSetup->paper_size = printSize;
|
||||
aSpec->GetToPrinter( isAPrinter );
|
||||
if ( isAPrinter == PR_TRUE ) {
|
||||
aSpec->GetCommand( &buf );
|
||||
mPrintSetup->out = popen( buf, "w" );
|
||||
mPrintSetup->filename = (char *) NULL;
|
||||
} else {
|
||||
aSpec->GetPath( &buf );
|
||||
mPrintSetup->filename = buf;
|
||||
mPrintSetup->out = fopen(mPrintSetup->filename, "w");
|
||||
}
|
||||
} else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/* make sure the open worked */
|
||||
|
||||
if ( mPrintSetup->out < 0 )
|
||||
return NS_ERROR_FAILURE;
|
||||
mPrintContext = new PSContext();
|
||||
memset(mPrintContext, 0, sizeof(struct PSContext_));
|
||||
memset(pi, 0, sizeof(struct PrintInfo_));
|
||||
|
||||
mPrintSetup->top = 32; // Margins (PostScript Only)
|
||||
mPrintSetup->bottom = 0;
|
||||
mPrintSetup->left = 32;
|
||||
mPrintSetup->right = 0;
|
||||
mPrintSetup->width = PAGE_WIDTH; // Paper size, # of cols for text xlate
|
||||
mPrintSetup->height = PAGE_HEIGHT;
|
||||
mPrintSetup->header = "header";
|
||||
mPrintSetup->footer = "footer";
|
||||
mPrintSetup->sizes = NULL;
|
||||
mPrintSetup->landscape = FALSE; // Rotated output
|
||||
mPrintSetup->underline = TRUE; // underline links
|
||||
mPrintSetup->scale_images = TRUE; // Scale unsized images which are too big
|
||||
mPrintSetup->scale_pre = FALSE; // do the pre-scaling thing
|
||||
mPrintSetup->dpi = 72.0f; // dpi for externally sized items
|
||||
mPrintSetup->rules = 1.0f; // Scale factor for rulers
|
||||
mPrintSetup->n_up = 0; // cool page combining
|
||||
mPrintSetup->bigger = 1; // Used to init sizes if sizesin NULL
|
||||
mPrintSetup->prefix = ""; // For text xlate, prepended to each line
|
||||
mPrintSetup->eol = ""; // For text translation, line terminator
|
||||
mPrintSetup->bullet = "+"; // What char to use for bullets
|
||||
|
||||
URL_Struct_* url = new URL_Struct_;
|
||||
memset(url, 0, sizeof(URL_Struct_));
|
||||
mPrintSetup->url = url; // url of doc being translated
|
||||
mPrintSetup->completion = NULL; // Called when translation finished
|
||||
mPrintSetup->carg = NULL; // Data saved for completion routine
|
||||
mPrintSetup->status = 0; // Status of URL on completion
|
||||
// "other" font is for encodings other than iso-8859-1
|
||||
mPrintSetup->otherFontName[0] = NULL;
|
||||
// name of "other" PostScript font
|
||||
mPrintSetup->otherFontInfo[0] = NULL;
|
||||
// font info parsed from "other" afm file
|
||||
mPrintSetup->otherFontCharSetID = 0; // charset ID of "other" font
|
||||
//mPrintSetup->cx = NULL; // original context, if available
|
||||
|
||||
pi->page_height=PAGE_HEIGHT * 10; // Size of printable area on page
|
||||
pi->page_width = PAGE_WIDTH * 10; // Size of printable area on page
|
||||
pi->page_break = 0; // Current page bottom
|
||||
pi->page_topy = 0; // Current page top
|
||||
pi->phase = 0;
|
||||
|
||||
|
||||
pi->pages=NULL; // Contains extents of each page
|
||||
|
||||
pi->pt_size = 0; // Size of above table
|
||||
pi->n_pages = 0; // # of valid entries in above table
|
||||
|
||||
pi->doc_title="Test Title"; // best guess at title
|
||||
pi->doc_width = 0; // Total document width
|
||||
pi->doc_height = 0; // Total document height
|
||||
|
||||
mPrintContext->prInfo = pi;
|
||||
|
||||
// begin the document
|
||||
initialize_translation(mPrintSetup);
|
||||
|
||||
begin_document();
|
||||
mPageNumber = 1; // we are on the first page
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPostScriptObj.h
|
||||
* @update 2/1/99 dwc
|
||||
|
@ -164,8 +197,8 @@ nsPostScriptObj::~nsPostScriptObj()
|
|||
void
|
||||
nsPostScriptObj::finalize_translation()
|
||||
{
|
||||
XP_DELETE(mPrintContext->prSetup);
|
||||
mPrintContext->prSetup = NULL;
|
||||
XP_DELETE(mPrintContext->prSetup);
|
||||
mPrintContext->prSetup = NULL;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -257,7 +290,9 @@ char* charset_name = NULL;
|
|||
}
|
||||
|
||||
XP_FilePrintf(f, "] /isolatin1encoding exch def\n");
|
||||
|
||||
|
||||
#ifdef OLDFONTS
|
||||
// output the fonts supported here
|
||||
for (i = 0; i < N_FONTS; i++){
|
||||
XP_FilePrintf(f,
|
||||
"/F%d\n"
|
||||
|
@ -279,6 +314,26 @@ char* charset_name = NULL;
|
|||
//XP_FilePrintf(f, "/of /of1;\n", mPrintContext->prSetup->otherFontName);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for(i=0;i<NUM_AFM_FONTS;i++){
|
||||
XP_FilePrintf(f,
|
||||
"/F%d\n"
|
||||
" /%s findfont\n"
|
||||
" dup length dict begin\n"
|
||||
" {1 index /FID ne {def} {pop pop} ifelse} forall\n"
|
||||
" /Encoding isolatin1encoding def\n"
|
||||
" currentdict end\n"
|
||||
"definefont pop\n"
|
||||
"/f%d { /F%d findfont exch scalefont setfont } bind def\n",
|
||||
i, gSubstituteFonts[i].mPSName, i, i);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
XP_FilePrintf(f, "/rhc {\n");
|
||||
XP_FilePrintf(f, " {\n");
|
||||
|
@ -410,7 +465,6 @@ nsPostScriptObj::end_document()
|
|||
XP_FilePrintf(mPrintContext->prSetup->out, "%%%%EOF\n");
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPostScriptObj.h
|
||||
* @update 2/1/99 dwc
|
||||
|
@ -687,7 +741,7 @@ nsPostScriptObj::fill()
|
|||
void
|
||||
nsPostScriptObj::graphics_save()
|
||||
{
|
||||
XP_FilePrintf(mPrintContext->prSetup->out, " gsave \n");
|
||||
XP_FilePrintf(mPrintContext->prSetup->out, " gsave \n");
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -791,20 +845,29 @@ nsPostScriptObj::setcolor(nscolor aColor)
|
|||
* @update 2/1/98 dwc
|
||||
*/
|
||||
void
|
||||
nsPostScriptObj::setscriptfont(nscoord aHeight, PRUint8 aStyle,
|
||||
nsPostScriptObj::setscriptfont(PRInt16 aFontIndex,const nsString &aFamily,nscoord aHeight, PRUint8 aStyle,
|
||||
PRUint8 aVariant, PRUint16 aWeight, PRUint8 decorations)
|
||||
{
|
||||
int postscriptFont = 0;
|
||||
|
||||
XP_FilePrintf(mPrintContext->prSetup->out,"%d",NS_TWIPS_TO_POINTS(aHeight));
|
||||
|
||||
|
||||
if( aFontIndex >= 0) {
|
||||
postscriptFont = aFontIndex;
|
||||
} else {
|
||||
postscriptFont = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NOTNOW
|
||||
//XXX:PS Add bold, italic and other settings here
|
||||
switch(aStyle){
|
||||
case NS_FONT_STYLE_NORMAL :
|
||||
if (NS_IS_BOLD(aWeight)) {
|
||||
postscriptFont = 1; // NORMAL BOLD
|
||||
}else{
|
||||
postscriptFont = 0; // NORMAL
|
||||
postscriptFont = 0; // Times Normal
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -818,12 +881,13 @@ int postscriptFont = 0;
|
|||
|
||||
case NS_FONT_STYLE_OBLIQUE:
|
||||
if (NS_IS_BOLD(aWeight)) {
|
||||
postscriptFont = 7; // COURIER-BOLD OBLIQUE
|
||||
postscriptFont = 7; // COURIER-BOLD OBLIQUE
|
||||
}else{
|
||||
postscriptFont = 6; // COURIER OBLIQUE
|
||||
postscriptFont = 6; // COURIER OBLIQUE
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
XP_FilePrintf(mPrintContext->prSetup->out, " f%d\n", postscriptFont);
|
||||
|
||||
|
@ -857,4 +921,4 @@ nsPostScriptObj::comment(char *aTheComment)
|
|||
|
||||
XP_FilePrintf(mPrintContext->prSetup->out,"%%%s\n", aTheComment);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include "net.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIDeviceContextSpecPS.h"
|
||||
|
||||
class nsIImage;
|
||||
|
||||
|
@ -35,6 +37,7 @@ class nsIImage;
|
|||
#define NS_LETTER_SIZE 0
|
||||
#define NS_LEGAL_SIZE 1
|
||||
#define NS_EXECUTIVE_SIZE 2
|
||||
#define NS_A4_SIZE 3
|
||||
|
||||
#define PAGE_WIDTH 612 // Points
|
||||
#define PAGE_HEIGHT 792 //Points
|
||||
|
@ -182,8 +185,13 @@ class nsPostScriptObj
|
|||
public:
|
||||
nsPostScriptObj();
|
||||
~nsPostScriptObj();
|
||||
|
||||
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Init PostScript Object
|
||||
* @update 3/19/99 dwc
|
||||
*/
|
||||
nsresult Init( nsIDeviceContextSpecPS *aSpec);
|
||||
/** ---------------------------------------------------
|
||||
* Start a postscript page
|
||||
* @update 2/1/99 dwc
|
||||
|
@ -343,7 +351,7 @@ public:
|
|||
* Set up the font
|
||||
* @update 2/1/99 dwc
|
||||
*/
|
||||
void setscriptfont(nscoord aHeight, PRUint8 aStyle, PRUint8 aVariant, PRUint16 aWeight, PRUint8 decorations);
|
||||
void setscriptfont(PRInt16 aFontIndex,const nsString &aFamily,nscoord aHeight, PRUint8 aStyle, PRUint8 aVariant, PRUint16 aWeight, PRUint8 decorations);
|
||||
/** ---------------------------------------------------
|
||||
* output a postscript comment
|
||||
* @update 2/1/99 dwc
|
||||
|
@ -357,6 +365,7 @@ private:
|
|||
PRUint16 mPageNumber;
|
||||
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Set up the postscript
|
||||
* @update 2/1/99 dwc
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsRenderingContextPS.h"
|
||||
#include "nsFontMetricsPS.h"
|
||||
#include <math.h>
|
||||
|
@ -79,9 +78,7 @@ PS_State :: PS_State()
|
|||
* Default Constructor for the state
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
PS_State :: PS_State(PS_State &aState) :
|
||||
mMatrix(&aState.mMatrix),
|
||||
mLocalClip(aState.mLocalClip)
|
||||
PS_State :: PS_State(PS_State &aState):mMatrix(&aState.mMatrix),mLocalClip(aState.mLocalClip)
|
||||
{
|
||||
mNext = &aState;
|
||||
//mClipRegion = NULL;
|
||||
|
@ -773,7 +770,6 @@ nsRenderingContextPS :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
|||
const nsPoint* np;
|
||||
nsPoint pp;
|
||||
|
||||
|
||||
mPSObj->newpath();
|
||||
|
||||
// point np to the polypoints
|
||||
|
@ -971,7 +967,6 @@ nsRenderingContextPS :: GetWidth(const char* aString,PRUint32 aLength,nscoord& a
|
|||
|
||||
if (nsnull != mFontMetrics){
|
||||
((nsFontMetricsPS*)mFontMetrics)->GetStringWidth(aString,aWidth,aLength);
|
||||
aWidth = NSToCoordRound(float(aWidth) * mP2T);
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -999,7 +994,6 @@ nsRenderingContextPS :: GetWidth(const PRUnichar *aString,PRUint32 aLength,nscoo
|
|||
|
||||
if (nsnull != mFontMetrics){
|
||||
((nsFontMetricsPS*)mFontMetrics)->GetStringWidth(aString,aWidth,aLength);
|
||||
aWidth = NSToCoordRound(float(aWidth) * mP2T);
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1030,6 +1024,11 @@ PRInt32 y = aY;
|
|||
mTMatrix->ScaleXCoords(aSpacing, aLength, dx0);
|
||||
}
|
||||
|
||||
// substract ascent since drawing specifies baseline
|
||||
nscoord ascent = 0;
|
||||
mFontMetrics->GetMaxAscent(ascent);
|
||||
y += ascent;
|
||||
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
PostscriptTextOut(aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aLength, (const nscoord*) (aSpacing ? dx0 : NULL), FALSE);
|
||||
|
||||
|
@ -1079,12 +1078,20 @@ nsIFontMetrics *fMetrics;
|
|||
while (aString < end){
|
||||
x = aX;
|
||||
y = aY;
|
||||
// substract ascent since drawing specifies baseline
|
||||
nscoord ascent = 0;
|
||||
mFontMetrics->GetMaxAscent(ascent);
|
||||
y += ascent;
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
PostscriptTextOut((const char *)aString, 1, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aFontID, aSpacing, PR_TRUE);
|
||||
aX += *aSpacing++;
|
||||
aString++;
|
||||
}
|
||||
} else {
|
||||
// substract ascent since drawing specifies baseline
|
||||
nscoord ascent = 0;
|
||||
mFontMetrics->GetMaxAscent(ascent);
|
||||
y += ascent;
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
PostscriptTextOut((const char *)aString, aLength, NS_PIXELS_TO_POINTS(x), NS_PIXELS_TO_POINTS(y), aFontID, aSpacing, PR_TRUE);
|
||||
}
|
||||
|
@ -1208,7 +1215,6 @@ NS_IMETHODIMP nsRenderingContextPS :: CopyOffScreenBits(nsDrawingSurface aSrcSur
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 12/21/98 dwc
|
||||
|
@ -1217,24 +1223,24 @@ void
|
|||
nsRenderingContextPS :: SetupFontAndColor(void)
|
||||
{
|
||||
nscoord fontHeight = 0;
|
||||
const nsFont *font;
|
||||
nsFontHandle fontHandle; // WINDOWS ONLY
|
||||
PRInt16 fontIndex;
|
||||
const nsFont *font;
|
||||
nsFontHandle fontHandle;
|
||||
nsAutoString fontFamily;
|
||||
|
||||
mFontMetrics->GetHeight(fontHeight);
|
||||
mFontMetrics->GetFont(font);
|
||||
|
||||
|
||||
mFontMetrics->GetFontHandle(fontHandle);
|
||||
|
||||
//HFONT tfont = (HFONT)fontHandle; // WINDOWS ONLY
|
||||
//::SelectObject(((nsDeviceContextPS*)mContext)->mDC, tfont); // WINDOWS ONLY
|
||||
|
||||
//mStates->mFont = mCurrFont = tfont;
|
||||
mStates->mFontMetrics = mFontMetrics;
|
||||
|
||||
mPSObj->setscriptfont(fontHeight,font->style,font->variant,font->weight,font->decorations);
|
||||
}
|
||||
// get the fontfamily we are using, not what we want, but what we are using
|
||||
fontFamily.SetString(((nsFontMetricsPS*)mFontMetrics)->mAFMInfo->mPSFontInfo->mFamilyName);
|
||||
fontIndex = ((nsFontMetricsPS*)mFontMetrics)->GetFontIndex();
|
||||
|
||||
mPSObj->setscriptfont(fontIndex,fontFamily,fontHeight,font->style,font->variant,font->weight,font->decorations);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsRenderingContextPS.h
|
||||
|
@ -1249,13 +1255,21 @@ int ptr = 0;
|
|||
unsigned int i;
|
||||
char *buf = 0;
|
||||
nscoord fontHeight = 0,yCoord;
|
||||
const nsFont *font;
|
||||
const nsFont *font;
|
||||
|
||||
mFontMetrics->GetHeight(fontHeight);
|
||||
mFontMetrics->GetFont(font);
|
||||
|
||||
yCoord = aY + (fontHeight / 2);
|
||||
mPSObj->moveto(aX, yCoord);
|
||||
//yCoord = aY + (fontHeight / 2);
|
||||
//nscoord ascent = 0;
|
||||
//mFontMetrics->GetMaxAscent(ascent);
|
||||
// convert the ascent to points
|
||||
//ascent = ascent/20;
|
||||
|
||||
|
||||
//yCoord = aY + ascent;
|
||||
|
||||
mPSObj->moveto(aX, aY);
|
||||
if (PR_TRUE == aIsUnicode) {
|
||||
//XXX: Investigate how to really do unicode with Postscript
|
||||
// Just remove the extra byte per character and draw that instead
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
// this isn't needed since we arn't useing getenv() anymore in here (pav)
|
||||
//#include "stdlib.h" // getenv() on Solaris/CC
|
||||
#include "stdlib.h" // getenv() on Solaris/CC
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecGTK
|
||||
|
@ -40,13 +38,52 @@ nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
|
|||
*/
|
||||
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
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)
|
||||
|
||||
|
@ -57,26 +94,25 @@ NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
|
|||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
|
||||
{
|
||||
gchar *path;
|
||||
|
||||
// XXX for now, neutering this per rickg until dcone can play with it
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
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 = SizeLetter;
|
||||
mPrData.stream = (FILE *) NULL;
|
||||
mPrData.size = NS_LETTER_SIZE;
|
||||
sprintf( mPrData.command, "lpr" );
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
path = g_get_home_dir();
|
||||
sprintf(mPrData.path, "%s/netscape.ps", path);
|
||||
g_free(path);
|
||||
if ( ( path = getenv( "PWD" ) ) == (char *) NULL )
|
||||
if ( ( path = 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 )
|
||||
|
@ -85,6 +121,72 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
|
|||
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
|
||||
|
|
|
@ -21,10 +21,12 @@
|
|||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#include "nsIDeviceContextSpecPS.h"
|
||||
|
||||
#include "nsPrintdGTK.h"
|
||||
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
|
||||
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
|
||||
nsIDeviceContextSpecPS
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -51,10 +53,34 @@ public:
|
|||
/**
|
||||
* 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
|
||||
|
|
|
@ -40,6 +40,10 @@ typedef struct prwidgets {
|
|||
GtkWidget *letterToggle;
|
||||
GtkWidget *legalToggle;
|
||||
GtkWidget *execToggle;
|
||||
GtkWidget *topSpinner;
|
||||
GtkWidget *bottomSpinner;
|
||||
GtkWidget *leftSpinner;
|
||||
GtkWidget *rightSpinner;
|
||||
GtkFileSelection *fsWidget;
|
||||
} PrWidgets;
|
||||
|
||||
|
@ -75,18 +79,30 @@ DoPrint (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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 = SizeLetter;
|
||||
prOps->prData->size = NS_LETTER_SIZE;
|
||||
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
|
||||
prOps->prData->size = SizeLegal;
|
||||
prOps->prData->size = NS_LEGAL_SIZE;
|
||||
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
|
||||
prOps->prData->size = SizeExecutive;
|
||||
prOps->prData->size = NS_EXECUTIVE_SIZE;
|
||||
else
|
||||
prOps->prData->size = SizeA4;
|
||||
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 */
|
||||
|
@ -171,7 +187,8 @@ static void
|
|||
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
||||
{
|
||||
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
|
||||
*button, *fileButton, *prButton, *table;
|
||||
*button, *fileButton, *prButton, *table, *spinner1;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
prOps->widgets.prDialog = dialog =
|
||||
gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
|
@ -244,7 +261,7 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
|
||||
|
||||
table = gtk_table_new (2, 5, PR_FALSE);
|
||||
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);
|
||||
|
@ -255,7 +272,8 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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);
|
||||
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);
|
||||
|
@ -263,7 +281,8 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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_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);
|
||||
|
||||
|
@ -273,14 +292,16 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
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_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_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);
|
||||
|
||||
|
@ -290,16 +311,18 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
button = gtk_radio_button_new_with_label (NULL,
|
||||
"Letter (8 1/2 x 11 in.)");
|
||||
prOps->widgets.letterToggle = button;
|
||||
if ( prOps->prData->size == SizeLetter )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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 == SizeLegal )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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);
|
||||
|
||||
|
@ -307,18 +330,82 @@ DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
|
|||
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
|
||||
"Executive (7 1/2 x 10 in.)");
|
||||
prOps->widgets.execToggle = button;
|
||||
if ( prOps->prData->size == SizeExecutive )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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 == SizeA4 )
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), PR_TRUE);
|
||||
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);
|
||||
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
|
||||
/* 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 */
|
||||
|
||||
enum { SizeLetter, SizeLegal, SizeExecutive, SizeA4 };
|
||||
#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
|
||||
|
||||
typedef struct unixprdata {
|
||||
PRBool toPrinter; /* If PR_TRUE, print to printer */
|
||||
|
@ -35,11 +38,9 @@ typedef struct unixprdata {
|
|||
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 */
|
||||
FILE *stream; /* File or Printer */
|
||||
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___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче