Back to index

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

#include <nsXPBaseWindow.h>

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

List of all members.

Public Member Functions

NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW nsXPBaseWindow ()
virtual ~nsXPBaseWindow ()
NS_DECL_ISUPPORTS NS_IMETHOD Init (nsXPBaseWindowType aType, nsIAppShell *aAppShell, const nsString &aDialogURL, const nsString &aTitle, const nsRect &aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins=PR_TRUE)
 Initialize the window or dialog box.
NS_IMETHOD SetLocation (PRInt32 aX, PRInt32 aY)
 Set the location the window or dialog box on the screen.
NS_IMETHOD SetDimensions (PRInt32 aWidth, PRInt32 aHeight)
 Set the width and height of the window or dialog box in pixels.
NS_IMETHOD GetWindowBounds (nsRect &aBounds)
NS_IMETHOD GetBounds (nsRect &aBounds)
NS_IMETHOD SetVisible (PRBool aIsVisible)
NS_IMETHOD Close ()
NS_IMETHOD SetTitle (const PRUnichar *aTitle)
NS_IMETHOD GetTitle (const PRUnichar **aResult)
NS_IMETHOD GetDocShell (nsIDocShell *&aResult)
NS_IMETHOD GetPresShell (nsIPresShell *&aPresShell)
NS_IMETHOD LoadURL (const nsString &aURL)
void Layout (PRInt32 aWidth, PRInt32 aHeight)
void ForceRefresh ()
void SetApp (nsViewerApp *aApp)
NS_IMETHOD GetDocument (nsIDOMHTMLDocument *&aDocument)
NS_IMETHOD AddEventListener (nsIDOMNode *aNode)
NS_IMETHOD RemoveEventListener (nsIDOMNode *aNode)
NS_IMETHOD AddWindowListener (nsIWindowListener *aWindowListener)
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD MouseDown (nsIDOMEvent *aMouseEvent)
 Processes a mouse down event.
NS_IMETHOD MouseUp (nsIDOMEvent *aMouseEvent)
 Processes a mouse up event.
NS_IMETHOD MouseClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseDblClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseOver (nsIDOMEvent *aMouseEvent)
 Processes a mouse enter event.
NS_IMETHOD MouseOut (nsIDOMEvent *aMouseEvent)
 Processes a mouse leave event.
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Protected Member Functions

void GetContentRoot ()

Protected Attributes

nsIContentmContentRoot
nsViewerAppmApp
nsString mTitle
nsString mDialogURL
nsIWidgetmWindow
nsIDocShellmDocShell
nsIWindowListenermWindowListener
PRBool mDocIsLoaded
nsIAppShellmAppShell
PRBool mAllowPlugins
nsXPBaseWindowType mWindowType

Detailed Description

Definition at line 58 of file nsXPBaseWindow.h.


Constructor & Destructor Documentation


Member Function Documentation

Implements nsIXPBaseWindow.

Definition at line 367 of file nsXPBaseWindow.cpp.

{
  nsIDOMEventReceiver * receiver;

  NS_PRECONDITION(nsnull != aNode, "adding event listener to null node");

  if (NS_OK == aNode->QueryInterface(kIDOMEventReceiverIID, (void**) &receiver)) {
    receiver->AddEventListenerByIID((nsIDOMMouseListener*)this, kIDOMMouseListenerIID);
    NS_RELEASE(receiver);
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Implements nsIXPBaseWindow.

Definition at line 397 of file nsXPBaseWindow.cpp.

{
  if (nsnull != mWindowListener) {
    return NS_ERROR_FAILURE;
  }

  mWindowListener = aWindowListener;
  if (mDocIsLoaded && nsnull != mWindowListener) {
    mWindowListener->Initialize(this);
  }
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 313 of file nsXPBaseWindow.cpp.

{
  if (nsnull != mWindowListener) {
    mWindowListener->Destroy(this);
  }

  if (mDocShell) {
    nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mDocShell));
    webShellWin->Destroy();
    NS_RELEASE(mDocShell);
  }

  if (nsnull != mWindow) {
    nsIWidget* w = mWindow;
    NS_RELEASE(w);
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 242 of file nsXPBaseWindow.cpp.

{
  nsIPresShell* shell;
  GetPresShell(shell);
  if (nsnull != shell) {
    nsIViewManager *vm = shell->GetViewManager();
    if (vm) {
      nsIView* root;
      vm->GetRootView(root);
      if (nsnull != root) {
        vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
      }
    }
    NS_RELEASE(shell);
  }
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 289 of file nsXPBaseWindow.cpp.

{
  mWindow->GetBounds(aBounds);
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 335 of file nsXPBaseWindow.cpp.

{
  NS_IF_ADDREF(aResult = mDocShell);
  return NS_OK;
}

Implements nsIXPBaseWindow.

Definition at line 412 of file nsXPBaseWindow.cpp.

{
  nsIDOMHTMLDocument *htmlDoc = nsnull;
  nsIPresShell *shell = nsnull;
  GetPresShell(shell);
  if (nsnull != shell) {
    nsIDocument *doc = shell->GetDocument();
    if (doc) {
      doc->QueryInterface(kIDOMHTMLDocumentIID,(void **)&htmlDoc);
    }
    NS_RELEASE(shell);
  }

  aDocument = htmlDoc;
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 431 of file nsXPBaseWindow.cpp.

{
  aPresShell = nsnull;

  if (mDocShell) {
    nsIContentViewer* cv = nsnull;
    mDocShell->GetContentViewer(&cv);
    if (nsnull != cv) {
      nsIDocumentViewer* docv = nsnull;
      cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
      if (nsnull != docv) {
        nsCOMPtr<nsPresContext> cx;
        docv->GetPresContext(getter_AddRefs(cx));
        if (nsnull != cx) {
          NS_IF_ADDREF(aPresShell = cx->GetPresShell());
        }
        NS_RELEASE(docv);
      }
      NS_RELEASE(cv);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIXPBaseWindow.

Definition at line 352 of file nsXPBaseWindow.cpp.

{
  *aResult = ToNewUnicode(mTitle);
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 297 of file nsXPBaseWindow.cpp.

{
  //XXX This needs to be non-client bounds when it exists.
  mWindow->GetBounds(aBounds);
  return NS_OK;
}

Here is the call graph for this function:

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.

Definition at line 460 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}
nsresult nsXPBaseWindow::Init ( nsXPBaseWindowType  aType,
nsIAppShell aAppShell,
const nsString aDialogURL,
const nsString aTitle,
const nsRect aBounds,
PRUint32  aChromeMask,
PRBool  aAllowPlugins = PR_TRUE 
) [virtual]

Initialize the window or dialog box.

Parameters:
aTypesee nsXPBaseWindowType's above
aAppShellapplication shell
aPrefPreferences
aDialogURLURL of HTML file describing the dialog or window
aTitleTitle of the dialog box or window
aBoundsx, y, width, and height of the window or dialog box XXX: aChrome is probably not needed for dialog boxes and windows, this is a holdover from the nsBrowserWindow.
aChromeChrome mask for toolbars and statusbars.
aAllowPluginsif TRUE then plugins can be referenced in the HTML file.

Implements nsIXPBaseWindow.

Definition at line 185 of file nsXPBaseWindow.cpp.

{
  mAllowPlugins = aAllowPlugins;
  mWindowType   = aType;
  mAppShell     = aAppShell;
  NS_IF_ADDREF(mAppShell);

  // Create top level window
  nsresult rv;
  rv = CallCreateInstance(kWindowCID, &mWindow);
  if (NS_FAILED(rv)) {
    return rv;
  }

  mWindow->SetClientData(this);

  nsWidgetInitData initData;
  initData.mWindowType = eWindowType_toplevel;
  initData.mBorderStyle = eBorderStyle_default;

  nsRect r(0, 0, aBounds.width, aBounds.height);
  mWindow->Create((nsIWidget*)NULL, r, HandleXPDialogEvent,
                  nsnull, aAppShell, nsnull, &initData);
  mWindow->GetBounds(r);

  // Create web shell
  rv = CallCreateInstance("@mozilla.org/webshell;1", &mDocShell);
  if (NS_FAILED(rv)) {
    return rv;
  }
  r.x = r.y = 0;
  mDocShell->SetAllowPlugins(aAllowPlugins);
  nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));

  rv = docShellWin->InitWindow(nsnull, mWindow, r.x, r.y, r.width, r.height);
  docShellWin->Create();
  docShellWin->SetVisibility(PR_TRUE);

  // Now lay it all out
  Layout(r.width, r.height);

  // Load URL to Load GUI
  mDialogURL = aDialogURL;
  LoadURL(mDialogURL);

  SetTitle(aTitle.get());

  return NS_OK;
}

Here is the call graph for this function:

void nsXPBaseWindow::Layout ( PRInt32  aWidth,
PRInt32  aHeight 
)

Definition at line 260 of file nsXPBaseWindow.cpp.

{
  nsRect rr(0, 0, aWidth, aHeight);
  nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
  docShellWin->SetPositionAndSize(rr.x, rr.y, rr.width, rr.height, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIXPBaseWindow.

Definition at line 359 of file nsXPBaseWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXPBaseWindow::MouseClick ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 478 of file nsXPBaseWindow.cpp.

{
  if (nsnull != mWindowListener) {
    PRBool status;
    mWindowListener->MouseClick(aMouseEvent, this, status);
  }
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsXPBaseWindow::MouseDblClick ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 488 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}
nsresult nsXPBaseWindow::MouseDown ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse down event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 472 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}
nsresult nsXPBaseWindow::MouseOut ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse leave event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 500 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}
nsresult nsXPBaseWindow::MouseOver ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse enter event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 494 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}
nsresult nsXPBaseWindow::MouseUp ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse up event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 466 of file nsXPBaseWindow.cpp.

{
  return NS_OK;
}

Implements nsIXPBaseWindow.

Definition at line 382 of file nsXPBaseWindow.cpp.

{
  nsIDOMEventReceiver * receiver;

  NS_PRECONDITION(nsnull != aNode, "removing event listener from null node");

  if (NS_OK == aNode->QueryInterface(kIDOMEventReceiverIID, (void**) &receiver)) {
    receiver->RemoveEventListenerByIID(this, kIDOMMouseListenerIID);
    NS_RELEASE(receiver);
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}
void nsXPBaseWindow::SetApp ( nsViewerApp aApp) [inline]

Definition at line 103 of file nsXPBaseWindow.h.

                                 {
    mApp = aApp;
  }
NS_IMETHODIMP nsXPBaseWindow::SetDimensions ( PRInt32  aWidth,
PRInt32  aHeight 
) [virtual]

Set the width and height of the window or dialog box in pixels.

Parameters:
aWidthwidth of the window or dialog box in pixels.
aHeightheight of the window or dialog box in pixels.

Implements nsIXPBaseWindow.

Definition at line 277 of file nsXPBaseWindow.cpp.

{
  NS_PRECONDITION(nsnull != mWindow, "null window");

  // XXX We want to do this in one shot
  mWindow->Resize(aWidth, aHeight, PR_FALSE);
  Layout(aWidth, aHeight);

  return NS_OK;
}

Here is the call graph for this function:

Set the location the window or dialog box on the screen.

Parameters:
aXhorizontal location of the upper left corner of the window in pixels from the screen.
aYvertical location of the upper left corner of the window in pixels from the screen.

Implements nsIXPBaseWindow.

Definition at line 268 of file nsXPBaseWindow.cpp.

{
  NS_PRECONDITION(nsnull != mWindow, "null window");
  mWindow->Move(aX, aY);
  return NS_OK;
}

Here is the call graph for this function:

Implements nsIXPBaseWindow.

Definition at line 342 of file nsXPBaseWindow.cpp.

{
  NS_PRECONDITION(nsnull != mWindow, "null window");
  mTitle = aTitle;
  nsAutoString newTitle(aTitle);
  mWindow->SetTitle(newTitle);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsXPBaseWindow::SetVisible ( PRBool  aIsVisible) [virtual]

Implements nsIXPBaseWindow.

Definition at line 305 of file nsXPBaseWindow.cpp.

{
  NS_PRECONDITION(nsnull != mWindow, "null window");
  mWindow->Show(aIsVisible);
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 143 of file nsXPBaseWindow.h.

Definition at line 130 of file nsXPBaseWindow.h.

Definition at line 142 of file nsXPBaseWindow.h.

Definition at line 126 of file nsXPBaseWindow.h.

Definition at line 133 of file nsXPBaseWindow.h.

Definition at line 139 of file nsXPBaseWindow.h.

Definition at line 136 of file nsXPBaseWindow.h.

Definition at line 132 of file nsXPBaseWindow.h.

Definition at line 135 of file nsXPBaseWindow.h.

Definition at line 138 of file nsXPBaseWindow.h.

Definition at line 145 of file nsXPBaseWindow.h.


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