Back to index

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

#include <WindowCreator.h>

Inheritance diagram for CWindowCreator:
Inheritance graph
Collaboration diagram for CWindowCreator:
Collaboration graph

List of all members.

Public Member Functions

 CWindowCreator ()
 CWindowCreator ()
virtual ~CWindowCreator ()
nsIWebBrowserChrome createChromeWindow2 (in nsIWebBrowserChrome parent, in PRUint32 chromeFlags, in PRUint32 contextFlags, in nsIURI uri, out boolean cancel)
 Create a new window.
nsIWebBrowserChrome createChromeWindow (in nsIWebBrowserChrome parent, in PRUint32 chromeFlags)
 Create a new window.

Static Public Member Functions

Initialize ()
static LWindow * CreateWindowInternal (PRUint32 inChromeFlags, PRBool enablePrinting, PRInt32 width, PRInt32 height)

Public Attributes

const unsigned long PARENT_IS_LOADING_OR_RUNNING_TIMEOUT = 0x00000001
 Definitions for contextFlags.

Protected Member Functions

virtual ~CWindowCreator ()

Detailed Description

Definition at line 45 of file WindowCreator.h.

Constructor & Destructor Documentation

Definition at line 45 of file WindowCreator.cpp.


Here is the caller graph for this function:

CWindowCreator::~CWindowCreator ( ) [protected, virtual]

Definition at line 49 of file WindowCreator.cpp.

virtual CWindowCreator::~CWindowCreator ( ) [virtual]

Member Function Documentation

Create a new window.

Gecko will/may call this method, if made available to it, to create new windows.

parentparent window, if any. null if not. the newly created window should be made a child/dependent window of the parent, if any (and if the concept applies to the underlying OS).
chromeFlagschrome features from nsIWebBrowserChrome
the new window
nsIWebBrowserChrome nsIWindowCreator2::createChromeWindow2 ( in nsIWebBrowserChrome  parent,
in PRUint32  chromeFlags,
in PRUint32  contextFlags,
in nsIURI  uri,
out boolean  cancel 
) [inherited]

Create a new window.

Gecko will/may call this method, if made available to it, to create new windows.

parentParent window, if any. Null if not. The newly created window should be made a child/dependent window of the parent, if any (and if the concept applies to the underlying OS).
chromeFlagsChrome features from nsIWebBrowserChrome
contextFlagsFlags about the context of the window being created.
uriThe URL for which this window is intended. It can be null or zero-length. The implementation of this interface may use the URL to help determine what sort of window to open or whether to cancel window creation. It will not load the URL.
cancelReturn |true| to reject window creation. If true the implementation has determined the window should not be created at all. The caller should not default to any possible backup scheme for creating the window.
the new window. Will be null if canceled or an error occurred.
LWindow * CWindowCreator::CreateWindowInternal ( PRUint32  inChromeFlags,
PRBool  enablePrinting,
PRInt32  width,
PRInt32  height 
) [static]

Definition at line 159 of file CWindowCreator.cpp.

    const SInt16 kStatusBarHeight = 16;
    const SDimension16 kMinimumWindowDimension = { 300, 150 };
    const SInt16 kStdSizeVertMargin = 100;
    LWindow         *theWindow;
    PRUint32        chromeFlags;
    if (inChromeFlags == nsIWebBrowserChrome::CHROME_DEFAULT)
        chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_RESIZE |
                      nsIWebBrowserChrome::CHROME_WINDOW_CLOSE |
                      nsIWebBrowserChrome::CHROME_TOOLBAR |
        chromeFlags = inChromeFlags;
    // Bounds - Set to an arbitrary rect - we'll size it after all the subviews are in.
    Rect globalBounds;
    globalBounds.left = 4; = 42;
    globalBounds.right = globalBounds.left + 600;
    globalBounds.bottom = + 400;
    // ProcID and attributes
    short windowDefProc;
    UInt32 windowAttrs = (windAttr_Enabled | windAttr_Targetable);
    if (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG)
        if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
            windowDefProc = kWindowMovableModalDialogProc;
            windowAttrs |= windAttr_TitleBar;
            windowDefProc = kWindowModalDialogProc;            
        if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
            windowDefProc = kWindowGrowDocumentProc;
            windowAttrs |= windAttr_Resizable;
            windowAttrs |= windAttr_Zoomable;
            windowDefProc = kWindowDocumentProc;            
        if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
            windowAttrs |= windAttr_CloseBox;

    if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)
        windowAttrs |= windAttr_Modal;
        windowAttrs |= windAttr_Regular;    
    theWindow = new CBrowserWindow(LCommander::GetTopCommander(), globalBounds, "\p", windowDefProc, windowAttrs, window_InFront);
    if (windowAttrs & windAttr_Resizable)
        Rect stdBounds, minMaxBounds;
        SDimension16 stdSize;
        stdSize.width = stdBounds.right - stdBounds.left;
        stdSize.height = stdBounds.bottom -;
        stdSize.width -= kStdSizeVertMargin; // Leave a vertical strip of desktop exposed
        minMaxBounds.left = kMinimumWindowDimension.width; = kMinimumWindowDimension.height;
        Rect  deskRect;
        ::GetRegionBounds(::GetGrayRgn(), &deskRect);
        minMaxBounds.left = kMinimumWindowDimension.width; = kMinimumWindowDimension.height;
        minMaxBounds.right = deskRect.right - deskRect.left;
        minMaxBounds.bottom = deskRect.bottom -;

    SDimension16 windowSize, toolBarSize;

    if (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)

        LView *toolBarView = static_cast<LView*>(UReanimator::ReadObjects(ResType_PPob, 131));
        toolBarView->PlaceInSuperFrameAt(0, 0, false);
        toolBarSize.width = windowSize.width;
        toolBarView->ResizeFrameTo(toolBarSize.width, toolBarSize.height, false);

    SPaneInfo aPaneInfo;
    SViewInfo aViewInfo;
    aPaneInfo.paneID = CBrowserShell::paneID_MainBrowser;
    aPaneInfo.width = windowSize.width;
    aPaneInfo.height = windowSize.height;
    if (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)
        aPaneInfo.height -= toolBarSize.height;
    if (chromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)
        aPaneInfo.height -= kStatusBarHeight - 1;
    aPaneInfo.visible = true;
    aPaneInfo.enabled = true;
    aPaneInfo.bindings.left = true; = true;
    aPaneInfo.bindings.right = true;
    aPaneInfo.bindings.bottom = true;
    aPaneInfo.left = 0; = (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR) ? toolBarSize.height : 0;
    aPaneInfo.userCon = 0;
    aPaneInfo.superView = theWindow;
    aViewInfo.imageSize.width = 0;
    aViewInfo.imageSize.height = 0;
    aViewInfo.scrollPos.h = aViewInfo.scrollPos.v = 0;
    aViewInfo.scrollUnit.h = aViewInfo.scrollUnit.v = 1;
    aViewInfo.reconcileOverhang = 0;
    CBrowserShell *aShell = new CBrowserShell(aPaneInfo, aViewInfo, chromeFlags, PR_TRUE);
    aShell->PutInside(theWindow, false);
    if (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
        nsCOMPtr<nsIWebBrowser> browser;
        nsCOMPtr<nsIWebBrowserSetup> setup(do_QueryInterface(browser));
        if (setup)
          setup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER, PR_TRUE);
    if (chromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)

        LView *statusView = static_cast<LView*>(UReanimator::ReadObjects(ResType_PPob, 130));
        statusView->PlaceInSuperFrameAt(0, windowSize.height - kStatusBarHeight + 1, false);
        statusView->ResizeFrameTo(windowSize.width - 15, kStatusBarHeight, false);

    if (enablePrinting)
        CPrintAttachment *printAttachment = new CPrintAttachment(CBrowserShell::paneID_MainBrowser);
    // Now the window is constructed...

    Rect    theBounds;
    if (width == -1)
        width = theBounds.right - theBounds.left;
    if (height == -1)
        height = theBounds.bottom -;
    theWindow->ResizeWindowTo(width, height);

    return theWindow;

Here is the call graph for this function:

Definition at line 147 of file CWindowCreator.cpp.

    // Create a CWindowCreator and give it to the WindowWatcher service
    // The WindowWatcher service will own it so we don't keep a ref.
    CWindowCreator *windowCreator = new CWindowCreator;
    if (!windowCreator) return NS_ERROR_FAILURE;
    nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
    if (!wwatch) return NS_ERROR_FAILURE;
    return wwatch->SetWindowCreator(windowCreator);

Here is the call graph for this function:

Member Data Documentation

Definitions for contextFlags.

Definition at line 64 of file nsIWindowCreator2.idl.

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