Implemented the window.print() method

This commit is contained in:
rods%netscape.com 1999-01-27 04:15:19 +00:00
Родитель 8936038315
Коммит 0040126f4f
5 изменённых файлов: 56 добавлений и 0 удалений

Просмотреть файл

@ -108,6 +108,8 @@ public:
NS_IMETHOD Stop()=0;
NS_IMETHOD Print()=0;
NS_IMETHOD MoveTo(PRInt32 aXPos, PRInt32 aYPos)=0;
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif)=0;
@ -174,6 +176,7 @@ public:
NS_IMETHOD Forward(); \
NS_IMETHOD Home(); \
NS_IMETHOD Stop(); \
NS_IMETHOD Print(); \
NS_IMETHOD MoveTo(PRInt32 aXPos, PRInt32 aYPos); \
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif); \
NS_IMETHOD ResizeTo(PRInt32 aWidth, PRInt32 aHeight); \
@ -230,6 +233,7 @@ public:
NS_IMETHOD Forward() { return _to##Forward(); } \
NS_IMETHOD Home() { return _to##Home(); } \
NS_IMETHOD Stop() { return _to##Stop(); } \
NS_IMETHOD Print() { return _to##Print(); } \
NS_IMETHOD MoveTo(PRInt32 aXPos, PRInt32 aYPos) { return _to##MoveTo(aXPos, aYPos); } \
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif) { return _to##MoveBy(aXDif, aYDif); } \
NS_IMETHOD ResizeTo(PRInt32 aWidth, PRInt32 aHeight) { return _to##ResizeTo(aWidth, aHeight); } \

Просмотреть файл

@ -32,6 +32,7 @@
void forward();
void home();
void stop();
void print();
void moveTo(in long xPos, in long yPos);
void moveBy(in long xDif, in long yDif);

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsCRT.h"
#include "nsRect.h"
#include "nsINetSupport.h"
#include "nsIContentViewer.h"
#include "jsapi.h"
@ -756,6 +757,21 @@ GlobalWindowImpl::Stop()
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::Print()
{
nsIContentViewer *viewer = nsnull;
mWebShell->GetContentViewer(&viewer);
if (nsnull != viewer)
{
viewer->Print();
NS_RELEASE(viewer);
}
return NS_OK;
}
NS_IMETHODIMP
GlobalWindowImpl::MoveTo(PRInt32 aXPos, PRInt32 aYPos)
{

Просмотреть файл

@ -119,6 +119,7 @@ public:
NS_IMETHOD Back();
NS_IMETHOD Home();
NS_IMETHOD Stop();
NS_IMETHOD Print();
NS_IMETHOD MoveTo(PRInt32 aXPos, PRInt32 aYPos);
NS_IMETHOD MoveBy(PRInt32 aXDif, PRInt32 aYDif);
NS_IMETHOD ResizeTo(PRInt32 aWidth, PRInt32 aHeight);

Просмотреть файл

@ -857,6 +857,39 @@ WindowStop(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
}
//
// Native method Print
//
PR_STATIC_CALLBACK(JSBool)
WindowPrint(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMWindow *nativeThis = (nsIDOMWindow*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Print()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function print requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method MoveTo
//
@ -1452,6 +1485,7 @@ static JSFunctionSpec WindowMethods[] =
{"forward", WindowForward, 0},
{"home", WindowHome, 0},
{"stop", WindowStop, 0},
{"print", WindowPrint, 0},
{"moveTo", WindowMoveTo, 2},
{"moveBy", WindowMoveBy, 2},
{"resizeTo", WindowResizeTo, 2},