added zooming front end.

This commit is contained in:
michaelp%netscape.com 1999-04-16 04:25:17 +00:00
parent 768d09d96e
commit 04b6780a88
5 changed files with 134 additions and 1 deletions

View File

@ -185,6 +185,8 @@ public:
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE);
NS_IMETHOD GetIsFrame(PRBool& aIsFrame);
NS_IMETHOD SetIsFrame(PRBool aIsFrame);
NS_IMETHOD SetZoom(float aZoom);
NS_IMETHOD GetZoom(float *aZoom);
// Document load api's
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
@ -365,6 +367,8 @@ protected:
nsURLReloadType aType,
const PRUint32 aLocalIP);
float mZoom;
static nsIPluginHost *mPluginHost;
static nsIPluginManager *mPluginManager;
static PRUint32 mPluginInitCnt;
@ -1279,6 +1283,55 @@ nsWebShell::SetIsFrame(PRBool aIsFrame)
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::SetZoom(float aZoom)
{
mZoom = aZoom;
if (mDeviceContext)
mDeviceContext->SetZoom(mZoom);
if (mContentViewer) {
nsIDocumentViewer* docv = nsnull;
mContentViewer->QueryInterface(kIDocumentViewerIID, (void**) &docv);
if (nsnull != docv) {
nsIPresContext* cx = nsnull;
docv->GetPresContext(cx);
if (nsnull != cx) {
nsIPresShell *shell = nsnull;
cx->GetShell(&shell);
if (nsnull != shell) {
nsIViewManager *vm = nsnull;
shell->GetViewManager(&vm);
if (nsnull != vm) {
nsIView *rootview = nsnull;
nsIScrollableView *sv = nsnull;
vm->GetRootScrollableView(&sv);
if (nsnull != sv)
sv->ComputeScrollOffsets();
vm->GetRootView(rootview);
if (nsnull != rootview)
vm->UpdateView(rootview, nsnull, 0);
NS_RELEASE(vm);
}
NS_RELEASE(shell);
}
NS_RELEASE(cx);
}
NS_RELEASE(docv);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::GetZoom(float *aZoom)
{
*aZoom = mZoom;
return NS_OK;
}
/**
* Document Load methods

View File

@ -339,11 +339,17 @@ public:
NS_IMETHOD GetDefaultCharacterSet (const PRUnichar** aDefaultCharacterSet) = 0;
NS_IMETHOD SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) = 0;
/**
* Set/Get the document scale factor
*/
NS_IMETHOD SetZoom(float aZoom) = 0;
NS_IMETHOD GetZoom(float *aZoom) = 0;
/**
* Finds text in content
*/
NS_IMETHOD FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound) = 0;
};
extern "C" NS_WEB nsresult

View File

@ -185,6 +185,8 @@ public:
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE);
NS_IMETHOD GetIsFrame(PRBool& aIsFrame);
NS_IMETHOD SetIsFrame(PRBool aIsFrame);
NS_IMETHOD SetZoom(float aZoom);
NS_IMETHOD GetZoom(float *aZoom);
// Document load api's
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
@ -365,6 +367,8 @@ protected:
nsURLReloadType aType,
const PRUint32 aLocalIP);
float mZoom;
static nsIPluginHost *mPluginHost;
static nsIPluginManager *mPluginManager;
static PRUint32 mPluginInitCnt;
@ -1279,6 +1283,55 @@ nsWebShell::SetIsFrame(PRBool aIsFrame)
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::SetZoom(float aZoom)
{
mZoom = aZoom;
if (mDeviceContext)
mDeviceContext->SetZoom(mZoom);
if (mContentViewer) {
nsIDocumentViewer* docv = nsnull;
mContentViewer->QueryInterface(kIDocumentViewerIID, (void**) &docv);
if (nsnull != docv) {
nsIPresContext* cx = nsnull;
docv->GetPresContext(cx);
if (nsnull != cx) {
nsIPresShell *shell = nsnull;
cx->GetShell(&shell);
if (nsnull != shell) {
nsIViewManager *vm = nsnull;
shell->GetViewManager(&vm);
if (nsnull != vm) {
nsIView *rootview = nsnull;
nsIScrollableView *sv = nsnull;
vm->GetRootScrollableView(&sv);
if (nsnull != sv)
sv->ComputeScrollOffsets();
vm->GetRootView(rootview);
if (nsnull != rootview)
vm->UpdateView(rootview, nsnull, 0);
NS_RELEASE(vm);
}
NS_RELEASE(shell);
}
NS_RELEASE(cx);
}
NS_RELEASE(docv);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::GetZoom(float *aZoom)
{
*aZoom = mZoom;
return NS_OK;
}
/**
* Document Load methods

View File

@ -611,6 +611,17 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
DoImageInspector();
break;
case VIEWER_ZOOM_500:
case VIEWER_ZOOM_300:
case VIEWER_ZOOM_200:
case VIEWER_ZOOM_100:
case VIEWER_ZOOM_070:
case VIEWER_ZOOM_050:
case VIEWER_ZOOM_030:
case VIEWER_ZOOM_020:
mWebShell->SetZoom((aID - VIEWER_ZOOM_BASE) / 10.0f);
break;
#ifdef ClientWallet
case PRVCY_PREFILL:
case PRVCY_QPREFILL:

View File

@ -86,6 +86,16 @@
#define VIEWER_EDIT_JOIN_CELL_RIGHT 40558
#define VIEWER_EDIT_JOIN_CELL_BELOW 40559
#define VIEWER_ZOOM_BASE 40600
#define VIEWER_ZOOM_500 40650
#define VIEWER_ZOOM_300 40630
#define VIEWER_ZOOM_200 40620
#define VIEWER_ZOOM_100 40610
#define VIEWER_ZOOM_070 40607
#define VIEWER_ZOOM_050 40605
#define VIEWER_ZOOM_030 40603
#define VIEWER_ZOOM_020 40602
// Note: must be in ascending sequential order
#define VIEWER_ONE_COLUMN 40050
#define VIEWER_TWO_COLUMN 40051