Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsPrintSetupDialog Class Reference

Implement Navigator Find Dialog. More...

#include <nsPrintSetupDialog.h>

Inheritance diagram for nsPrintSetupDialog:
Inheritance graph
[legend]
Collaboration diagram for nsPrintSetupDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPrintSetupDialog (nsBrowserWindow *aBrowserWindow)
virtual ~nsPrintSetupDialog ()
virtual void DoClose ()
virtual void MouseClick (nsIDOMEvent *aMouseEvent, nsIXPBaseWindow *aWindow, PRBool &aStatus)
 Method called when the user clicks the mouse.
virtual void Initialize (nsIXPBaseWindow *aWindow)
 Method called After the URL passed to the dialog box or window has completed loading.
virtual void Destroy (nsIXPBaseWindow *aWindow)
 Method called when dialog box or window is no longer visibleg.
virtual void GetSetupInfo (PrintSetupInfo &anInfo)
virtual void SetSetupInfo (const PrintSetupInfo &anInfo)

Protected Member Functions

void SetSetupInfoInternal (const PrintSetupInfo &anInfo)
PRBool IsChecked (const nsAString &aName)
PRBool IsChecked (nsIDOMElement *aNode)
void SetChecked (nsIDOMElement *aNode, PRBool aValue)
void SetChecked (const nsAString &aName, PRBool aValue)
void GetText (nsIDOMElement *aNode, nsAString &aStr)
void GetText (const nsAString &aName, nsAString &aStr)
float GetFloat (nsString &aStr)
void SetText (nsIDOMElement *aNode, const nsAString &aValue)
void SetText (const nsAString &aName, const nsAString &aStr)

Protected Attributes

nsIDOMElementmOKBtn
PrintSetupInfomPrinterSetupInfo
nsBrowserWindowmBrowserWindow
nsIXPBaseWindowmWindow
nsIDOMElementmCancelBtn

Detailed Description

Implement Navigator Find Dialog.

Definition at line 73 of file nsPrintSetupDialog.h.


Constructor & Destructor Documentation

Definition at line 76 of file nsPrintSetupDialog.cpp.

                                                                       :
  nsBaseDialog(aBrowserWindow),
  mOKBtn(nsnull),
  mPrinterSetupInfo(nsnull)
{
}

Definition at line 84 of file nsPrintSetupDialog.cpp.

{
}

Member Function Documentation

Method called when dialog box or window is no longer visibleg.

Parameters:
aWindowthe window which is about to be destroyed

Reimplemented from nsBaseDialog.

Definition at line 223 of file nsPrintSetupDialog.cpp.

{
  // Unregister event listeners that were registered in the
  // Initialize here. 
  // XXX: Should change code in XPBaseWindow to automatically unregister
  // all event listening, That way this code will not be necessary.
  aWindow->RemoveEventListener(mOKBtn);
}

Here is the call graph for this function:

Reimplemented from nsBaseDialog.

Definition at line 234 of file nsPrintSetupDialog.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

float nsBaseDialog::GetFloat ( nsString aStr) [protected, inherited]

Definition at line 241 of file nsBaseDialog.cpp.

{

  return (float)0.0;
}

Here is the caller graph for this function:

Definition at line 114 of file nsPrintSetupDialog.cpp.

{
  aPSI.mPortrait         = IsChecked(NS_LITERAL_STRING("portrait"));
  aPSI.mBevelLines       = IsChecked(NS_LITERAL_STRING("bevellines"));
  aPSI.mBlackText        = IsChecked(NS_LITERAL_STRING("blacktext"));
  aPSI.mBlackLines       = IsChecked(NS_LITERAL_STRING("blacklines"));
  aPSI.mLastPageFirst    = IsChecked(NS_LITERAL_STRING("lastpagefirst"));
  aPSI.mPrintBackgrounds = IsChecked(NS_LITERAL_STRING("printbg"));

  nsString str;
  GetText(NS_LITERAL_STRING("toptext"), str);
  aPSI.mTopMargin = GetFloat(str);

  GetText(NS_LITERAL_STRING("lefttext"), str);
  aPSI.mLeftMargin = GetFloat(str);

  GetText(NS_LITERAL_STRING("bottomtext"), str);
  aPSI.mBottomMargin = GetFloat(str);

  GetText(NS_LITERAL_STRING("righttext"), str);
  aPSI.mRightMargin = GetFloat(str);

  GetText(NS_LITERAL_STRING("lefttext"),   str);
  GetText(NS_LITERAL_STRING("bottomtext"), str);
  GetText(NS_LITERAL_STRING("righttext"),  str);

  nsString header;
  nsString footer;
  GetText(NS_LITERAL_STRING("headertext"),  header);
  GetText(NS_LITERAL_STRING("footertext"),  footer);
  aPSI.mHeaderText = header;
  aPSI.mFooterText = footer;

  //GetText("headertext",  aPSI.mHeaderText);
  //GetText("footertext",  aPSI.mFooterText);

  aPSI.mDocTitle    = IsChecked(NS_LITERAL_STRING("doctitle"));
  aPSI.mDocLocation = IsChecked(NS_LITERAL_STRING("docloc"));
  aPSI.mPageNum     = IsChecked(NS_LITERAL_STRING("pagenum"));
  aPSI.mPageTotal   = IsChecked(NS_LITERAL_STRING("pagetotal"));
  aPSI.mDatePrinted = IsChecked(NS_LITERAL_STRING("dateprinted"));

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsBaseDialog::GetText ( nsIDOMElement aNode,
nsAString &  aStr 
) [protected, inherited]

Definition at line 189 of file nsBaseDialog.cpp.

{
  nsIDOMHTMLInputElement * element;
  if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) {
    element->GetValue(aStr);
    NS_RELEASE(element);
  }
}

Here is the caller graph for this function:

void nsBaseDialog::GetText ( const nsAString &  aName,
nsAString &  aStr 
) [protected, inherited]

Definition at line 199 of file nsBaseDialog.cpp.

{
  nsIDOMElement      * node;
  nsIDOMHTMLDocument * doc = nsnull;
  mWindow->GetDocument(doc);
  if (nsnull != doc) {
    if (NS_OK == doc->GetElementById(aName,   &node)) {
      GetText(node, aStr);
      NS_RELEASE(node);
    }
    NS_RELEASE(doc);
  }
}

Here is the call graph for this function:

Method called After the URL passed to the dialog box or window has completed loading.

Usually it is used to set place the initial settings in form elements.

Parameters:
aWindowthe window to initialize form element settings for.

Reimplemented from nsBaseDialog.

Definition at line 89 of file nsPrintSetupDialog.cpp.

{
  nsBaseDialog::Initialize(aWindow);

  nsIDOMHTMLDocument *doc = nsnull;
  mWindow->GetDocument(doc);
  if (nsnull != doc) {
    doc->GetElementById(NS_LITERAL_STRING("ok"),       &mOKBtn);

    // XXX: Register event listening on each dom element. We should change this so
    // all DOM events are automatically passed through.
    mWindow->AddEventListener(mOKBtn);
    //SetChecked(mMatchCaseCB, PR_FALSE);
    
    NS_RELEASE(doc);

    if (nsnull != mPrinterSetupInfo) {
      SetSetupInfoInternal(*mPrinterSetupInfo);
      delete mPrinterSetupInfo;
      mPrinterSetupInfo = nsnull;
    }
  }
}

Here is the call graph for this function:

PRBool nsBaseDialog::IsChecked ( const nsAString &  aName) [protected, inherited]

Definition at line 144 of file nsBaseDialog.cpp.

{
  nsIDOMElement      * node;
  nsIDOMHTMLDocument * doc = nsnull;
  mWindow->GetDocument(doc);
  if (nsnull != doc) {
    if (NS_OK == doc->GetElementById(aName, &node)) {
      PRBool value = IsChecked(node);
      NS_RELEASE(node);
      NS_RELEASE(doc);
      return value;
    }
    NS_RELEASE(doc);
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsBaseDialog::IsChecked ( nsIDOMElement aNode) [protected, inherited]

Definition at line 130 of file nsBaseDialog.cpp.

{
  nsIDOMHTMLInputElement * element;
  if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) {
    PRBool checked;
    element->GetChecked(&checked);
    NS_RELEASE(element);
    return checked;
  }
  return PR_FALSE;
}
void nsPrintSetupDialog::MouseClick ( nsIDOMEvent aMouseEvent,
nsIXPBaseWindow aWindow,
PRBool aStatus 
) [virtual]

Method called when the user clicks the mouse.

Clicks are only generated when the mouse-up event happens over a widget.

Parameters:
aMouseEventDOM event holding mouse click info.
aWindowWindow which generated the mouse click event

Reimplemented from nsBaseDialog.

Definition at line 200 of file nsPrintSetupDialog.cpp.

{
   // Event Dispatch. This method should not contain
   // anything but calls to methods. This idea is that this dispatch
   // mechanism may be replaced by JavaScript EventHandlers which call the idl'ed
   // interfaces to perform the same operation that is currently being handled by
   // this C++ code.

  nsBaseDialog::MouseClick(aMouseEvent, aWindow, aStatus);
  if (!aStatus) { // is not consumed
    nsCOMPtr<nsIDOMEventTarget> target;
    aMouseEvent->GetTarget(getter_AddRefs(target));
    if (target) {
      nsCOMPtr<nsIDOMElement> node(do_QueryInterface(target));
      if (node.get() == mOKBtn) {
        GetSetupInfo(mBrowserWindow->mPrintSetupInfo);
        DoClose();
      } 
    }
  }
}

Here is the call graph for this function:

void nsBaseDialog::SetChecked ( nsIDOMElement aNode,
PRBool  aValue 
) [protected, inherited]

Definition at line 163 of file nsBaseDialog.cpp.

{
  nsIDOMHTMLInputElement * element;
  if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) {
    element->SetChecked(aValue);
    NS_RELEASE(element);
  }
}

Here is the caller graph for this function:

void nsBaseDialog::SetChecked ( const nsAString &  aName,
PRBool  aValue 
) [protected, inherited]

Definition at line 174 of file nsBaseDialog.cpp.

{
  nsIDOMElement      * node;
  nsIDOMHTMLDocument * doc = nsnull;
  mWindow->GetDocument(doc);
  if (nsnull != doc) {
    if (NS_OK == doc->GetElementById(aName,   &node)) {
      SetChecked(node, aValue);
      NS_RELEASE(node);
    }
    NS_RELEASE(doc);
  }
}

Here is the call graph for this function:

Definition at line 159 of file nsPrintSetupDialog.cpp.

{
  if (nsnull == mWindow) {
    mPrinterSetupInfo = new PrintSetupInfo(aPSI);
  } else {
    SetSetupInfoInternal(aPSI);
  }
}

Here is the call graph for this function:

Definition at line 169 of file nsPrintSetupDialog.cpp.

{
  SetChecked(NS_LITERAL_STRING("portrait"),      aPSI.mPortrait);
  SetChecked(NS_LITERAL_STRING("bevellines"),    aPSI.mBevelLines);
  SetChecked(NS_LITERAL_STRING("blacktext"),     aPSI.mBlackText);
  SetChecked(NS_LITERAL_STRING("blacklines"),    aPSI.mBlackLines);
  SetChecked(NS_LITERAL_STRING("lastpagefirst"), aPSI.mLastPageFirst);
  SetChecked(NS_LITERAL_STRING("printbg"),       aPSI.mPrintBackgrounds);

  char str[64];
  sprintf(str, "%5.2f", aPSI.mTopMargin);
  SetText(NS_LITERAL_STRING("toptext"), NS_ConvertASCIItoUCS2(str));
  sprintf(str, "%5.2f", aPSI.mLeftMargin);
  SetText(NS_LITERAL_STRING("lefttext"), NS_ConvertASCIItoUCS2(str));
  sprintf(str, "%5.2f", aPSI.mBottomMargin);
  SetText(NS_LITERAL_STRING("bottomtext"), NS_ConvertASCIItoUCS2(str));
  sprintf(str, "%5.2f", aPSI.mRightMargin);
  SetText(NS_LITERAL_STRING("righttext"),  NS_ConvertASCIItoUCS2(str));

  SetText(NS_LITERAL_STRING("headertext"),  aPSI.mHeaderText);
  SetText(NS_LITERAL_STRING("footertext"),  aPSI.mFooterText);

  SetChecked(NS_LITERAL_STRING("doctitle"),    aPSI.mDocTitle);
  SetChecked(NS_LITERAL_STRING("docloc"),      aPSI.mDocLocation);
  SetChecked(NS_LITERAL_STRING("pagenum"),     aPSI.mPageNum);
  SetChecked(NS_LITERAL_STRING("pagetotal"),   aPSI.mPageTotal);
  SetChecked(NS_LITERAL_STRING("dateprinted"), aPSI.mDatePrinted);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsBaseDialog::SetText ( nsIDOMElement aNode,
const nsAString &  aValue 
) [protected, inherited]

Definition at line 215 of file nsBaseDialog.cpp.

{
  nsIDOMHTMLInputElement * element;
  if (NS_OK == aNode->QueryInterface(kIDOMHTMLInputElementIID, (void**) &element)) {
    element->SetValue(aValue);
    NS_RELEASE(element);
  }
}

Here is the caller graph for this function:

void nsBaseDialog::SetText ( const nsAString &  aName,
const nsAString &  aStr 
) [protected, inherited]

Definition at line 226 of file nsBaseDialog.cpp.

{
  nsIDOMElement      * node;
  nsIDOMHTMLDocument * doc = nsnull;
  mWindow->GetDocument(doc);
  if (nsnull != doc) {
    if (NS_OK == doc->GetElementById(aName,   &node)) {
      SetText(node, aStr);
      NS_RELEASE(node);
    }
    NS_RELEASE(doc);
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 78 of file nsBaseDialog.h.

nsIDOMElement* nsBaseDialog::mCancelBtn [protected, inherited]

Definition at line 80 of file nsBaseDialog.h.

Definition at line 95 of file nsPrintSetupDialog.h.

Definition at line 96 of file nsPrintSetupDialog.h.

nsIXPBaseWindow* nsBaseDialog::mWindow [protected, inherited]

Definition at line 79 of file nsBaseDialog.h.


The documentation for this class was generated from the following files: