1
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
39
#include "nsImageInspectorDialog.h"
40
#include "nsIDOMEvent.h"
41
#include "nsIXPBaseWindow.h"
42
#include "nsBrowserWindow.h"
43
#include "nsIDOMEventTarget.h"
44
#include "nsIDOMDocument.h"
46
#include "nsIDOMHTMLInputElement.h"
47
#include "nsIDOMHTMLDocument.h"
50
//-------------------------------------------------------------------------
52
// nsImageInspectorDialog constructor
54
//-------------------------------------------------------------------------
55
//-----------------------------------------------------------------
56
nsImageInspectorDialog::nsImageInspectorDialog(nsBrowserWindow * aBrowserWindow, nsIDOMDocument * aDoc) :
57
nsBaseDialog(aBrowserWindow),
63
//-----------------------------------------------------------------
64
nsImageInspectorDialog::~nsImageInspectorDialog()
68
//---------------------------------------------------------------
69
void nsImageInspectorDialog::Initialize(nsIXPBaseWindow * aWindow)
71
nsBaseDialog::Initialize(aWindow);
73
nsIDOMHTMLDocument *doc = nsnull;
74
mWindow->GetDocument(doc);
76
doc->GetElementById(NS_LITERAL_STRING("ok"), &mOKBtn);
78
// XXX: Register event listening on each dom element. We should change this so
79
// all DOM events are automatically passed through.
80
mWindow->AddEventListener(mOKBtn);
81
//SetChecked(mMatchCaseCB, PR_FALSE);
88
//-----------------------------------------------------------------
89
void nsImageInspectorDialog::GetSetupInfo(PrintSetupInfo & aPSI)
91
aPSI.mPortrait = IsChecked("portrait");
92
aPSI.mBevelLines = IsChecked("bevellines");
93
aPSI.mBlackText = IsChecked("blacktext");
94
aPSI.mBlackLines = IsChecked("blacklines");
95
aPSI.mLastPageFirst = IsChecked("lastpagefirst");
96
aPSI.mPrintBackgrounds = IsChecked("printbg");
99
GetText("toptext", str);
100
aPSI.mTopMargin = GetFloat(str);
102
GetText("lefttext", str);
103
aPSI.mLeftMargin = GetFloat(str);
105
GetText("bottomtext", str);
106
aPSI.mBottomMargin = GetFloat(str);
108
GetText("righttext", str);
109
aPSI.mRightMargin = GetFloat(str);
111
GetText("lefttext", str);
112
GetText("bottomtext", str);
113
GetText("righttext", str);
117
GetText("headertext", header);
118
GetText("footertext", footer);
119
aPSI.mHeaderText = header;
120
aPSI.mFooterText = footer;
122
//GetText("headertext", aPSI.mHeaderText);
123
//GetText("footertext", aPSI.mFooterText);
125
aPSI.mDocTitle = IsChecked("doctitle");
126
aPSI.mDocLocation = IsChecked("docloc");
127
aPSI.mPageNum = IsChecked("pagenum");
128
aPSI.mPageTotal = IsChecked("pagetotal");
129
aPSI.mDatePrinted = IsChecked("dateprinted");
133
//-----------------------------------------------------------------
134
void nsImageInspectorDialog::SetSetupInfo(const PrintSetupInfo & aPSI)
136
if (nsnull == mWindow) {
137
mPrinterSetupInfo = new PrintSetupInfo(aPSI);
139
SetSetupInfoInternal(aPSI);
143
//-----------------------------------------------------------------
144
void nsImageInspectorDialog::SetSetupInfoInternal(const PrintSetupInfo & aPSI)
146
SetChecked("portrait", aPSI.mPortrait);
147
SetChecked("bevellines", aPSI.mBevelLines);
148
SetChecked("blacktext", aPSI.mBlackText);
149
SetChecked("blacklines", aPSI.mBlackLines);
150
SetChecked("lastpagefirst", aPSI.mLastPageFirst);
151
SetChecked("printbg", aPSI.mPrintBackgrounds);
154
sprintf(str, "%5.2f", aPSI.mTopMargin);
155
SetText("toptext", str);
156
sprintf(str, "%5.2f", aPSI.mLeftMargin);
157
SetText("lefttext", str);
158
sprintf(str, "%5.2f", aPSI.mBottomMargin);
159
SetText("bottomtext", str);
160
sprintf(str, "%5.2f", aPSI.mRightMargin);
161
SetText("righttext", str);
163
SetText("headertext", aPSI.mHeaderText);
164
SetText("footertext", aPSI.mFooterText);
166
SetChecked("doctitle", aPSI.mDocTitle);
167
SetChecked("docloc", aPSI.mDocLocation);
168
SetChecked("pagenum", aPSI.mPageNum);
169
SetChecked("pagetotal", aPSI.mPageTotal);
170
SetChecked("dateprinted", aPSI.mDatePrinted);
175
//-----------------------------------------------------------------
176
void nsImageInspectorDialog::MouseClick(nsIDOMEvent* aMouseEvent, nsIXPBaseWindow * aWindow, PRBool &aStatus)
178
// Event Dispatch. This method should not contain
179
// anything but calls to methods. This idea is that this dispatch
180
// mechanism may be replaced by JavaScript EventHandlers which call the idl'ed
181
// interfaces to perform the same operation that is currently being handled by
184
nsBaseDialog::MouseClick(aMouseEvent, aWindow, aStatus);
185
if (!aStatus) { // is not consumed
186
nsCOMPtr<nsIDOMEventTarget> target;
187
aMouseEvent->GetTarget(getter_AddRefs(target));
189
nsCOMPtr<nsIDOMElement> node(do_QueryInterface(target));
190
if (node.get() == mOKBtn) {
192
GetText(NS_LITERAL_STRING("url"), str);
199
//-----------------------------------------------------------------
200
void nsImageInspectorDialog::Destroy(nsIXPBaseWindow * aWindow)
202
// Unregister event listeners that were registered in the
204
// XXX: Should change code in XPBaseWindow to automatically unregister
205
// all event listening, That way this code will not be necessary.
206
aWindow->RemoveEventListener(mOKBtn);
211
nsImageInspectorDialog::DoClose()
213
mWindow->SetVisible(PR_FALSE);