Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
WebBrowserChromeUI Class Reference

#include <WebBrowserChrome.h>

List of all members.

Static Public Member Functions

static nativeWindow CreateNativeWindow (nsIWebBrowserChrome *chrome)
static void Destroy (nsIWebBrowserChrome *chrome)
static void Destroyed (nsIWebBrowserChrome *chrome)
static void SetFocus (nsIWebBrowserChrome *chrome)
static void UpdateStatusBarText (nsIWebBrowserChrome *aChrome, const PRUnichar *aStatusText)
static void UpdateCurrentURI (nsIWebBrowserChrome *aChrome)
static void UpdateBusyState (nsIWebBrowserChrome *aChrome, PRBool aBusy)
static void UpdateProgress (nsIWebBrowserChrome *aChrome, PRInt32 aCurrent, PRInt32 aMax)
static void GetResourceStringById (PRInt32 aID, char **aReturn)
static void ShowContextMenu (nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
static void ShowTooltip (nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
static void HideTooltip (nsIWebBrowserChrome *aChrome)
static void ShowWindow (nsIWebBrowserChrome *aChrome, PRBool aShow)
static void SizeTo (nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight)
static nativeWindow CreateNativeWindow (nsIWebBrowserChrome *chrome)
static void Destroy (nsIWebBrowserChrome *chrome)
static void Destroyed (nsIWebBrowserChrome *chrome)
static void SetFocus (nsIWebBrowserChrome *chrome)
static void UpdateStatusBarText (nsIWebBrowserChrome *aChrome, const PRUnichar *aStatusText)
static void UpdateCurrentURI (nsIWebBrowserChrome *aChrome)
static void UpdateBusyState (nsIWebBrowserChrome *aChrome, PRBool aBusy)
static void UpdateProgress (nsIWebBrowserChrome *aChrome, PRInt32 aCurrent, PRInt32 aMax)
static void GetResourceStringById (PRInt32 aID, char **aReturn)
static void ShowContextMenu (nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
static void ShowTooltip (nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
static void HideTooltip (nsIWebBrowserChrome *aChrome)
static void ShowWindow (nsIWebBrowserChrome *aChrome, PRBool aShow)
static void SizeTo (nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight)

Detailed Description

Definition at line 55 of file WebBrowserChrome.h.


Member Function Documentation

Definition at line 1116 of file os2Embed.cpp.

{
  // Load the browser dialog from resource
  HWND hwndDialog;
  PRUint32 chromeFlags;

  chrome->GetChromeFlags(&chromeFlags);
  if ((chromeFlags & nsIWebBrowserChrome::CHROME_ALL) == nsIWebBrowserChrome::CHROME_ALL)
    hwndDialog = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, BrowserDlgProc, ghInstanceResources, IDD_BROWSER, NULL);
  else
    hwndDialog = WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, BrowserDlgProc, ghInstanceResources, IDD_BROWSER_NC, NULL);
  if (!hwndDialog)
    return NULL;

  // Stick a menu onto it
  if (chromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR) {
    HWND hmenuDlg = WinLoadMenu(hwndDialog, 0, IDC_OS2EMBED);
    WinSendMsg(hwndDialog, WM_UPDATEFRAME, MPFROMLONG(FCF_MENU), 0);
  } else
    WinSendMsg(hwndDialog, WM_UPDATEFRAME, 0, 0);

  // Add some interesting URLs to the address drop down
  HWND hwndAddress = WinWindowFromID(hwndDialog, IDC_ADDRESS);
  if (hwndAddress) {
    for (int i = 0; i < sizeof(gDefaultURLs) / sizeof(gDefaultURLs[0]); i++)
    {
      WinSendMsg(hwndAddress, LM_INSERTITEM, (MPARAM)LIT_SORTASCENDING, (MPARAM)gDefaultURLs[i]);
    }
  }

  // Fetch the browser window handle
  HWND hwndBrowser = WinWindowFromID(hwndDialog, IDC_BROWSER);
  WinSetWindowULong(hwndBrowser, QWL_USER, (ULONG)chrome);  // save the browser LONG_PTR.
  WinSetWindowULong(hwndBrowser, QWL_STYLE, WinQueryWindowULong(hwndBrowser, QWL_STYLE) | WS_CLIPCHILDREN);

  // Activate the window
  WinPostMsg(hwndDialog, WM_ACTIVATE, MPFROMSHORT(TRUE), (MPARAM)0);

  gDialogCount++;

  return (void *)hwndBrowser;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void WebBrowserChromeUI::Destroy ( nsIWebBrowserChrome chrome) [static]

Definition at line 1165 of file os2Embed.cpp.

{
  nsCOMPtr<nsIWebBrowser> webBrowser;
  nsCOMPtr<nsIWebNavigation> webNavigation;

  chrome->GetWebBrowser(getter_AddRefs(webBrowser));
  webNavigation = do_QueryInterface(webBrowser);
  if (webNavigation)
    webNavigation->Stop(nsIWebNavigation::STOP_ALL);

  chrome->ExitModalEventLoop(NS_OK);

  HWND hwndDlg = GetBrowserDlgFromChrome(chrome);
  if (hwndDlg == NULL)
    return;

  // Explicitly destroy the embedded browser and then the chrome

  // First the browser
  nsCOMPtr<nsIWebBrowser> browser = nsnull;
  chrome->GetWebBrowser(getter_AddRefs(browser));
  nsCOMPtr<nsIBaseWindow> browserAsWin = do_QueryInterface(browser);
  if (browserAsWin)
    browserAsWin->Destroy();

      // Now the chrome
  chrome->SetWebBrowser(nsnull);
  NS_RELEASE(chrome);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1199 of file os2Embed.cpp.

{
    HWND hwndDlg = GetBrowserDlgFromChrome(chrome);
       if (hwndDlg == NULL)
       {
              return;
       }

    // Clear the window user data
    HWND hwndBrowser = WinWindowFromID(hwndDlg, IDC_BROWSER);
    WinSetWindowULong(hwndBrowser, QWL_USER, nsnull);
    WinDestroyWindow(hwndBrowser);
    WinDestroyWindow(hwndDlg);

    --gDialogCount;
    if (gDialogCount == 0)
    {
        if (gProfileSwitch)
        {
            gProfileSwitch = FALSE;
            OpenWebPage(gFirstURL);
        }
        else
        {
            // Quit when there are no more browser objects
            WinPostQueueMsg(0, WM_QUIT, 0, 0);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void WebBrowserChromeUI::GetResourceStringById ( PRInt32  aID,
char **  aReturn 
) [static]
void WebBrowserChromeUI::GetResourceStringById ( PRInt32  aID,
char **  aReturn 
) [static]

Definition at line 1387 of file os2Embed.cpp.

{
    char resBuf[MAX_LOADSTRING];
    int retval = WinLoadString((HAB)0, ghInstanceResources, aID, sizeof(resBuf), (PSZ)resBuf );
    if (retval != 0)
    {
        int resLen = strlen(resBuf);
        *aReturn = (char *)calloc(resLen+1, sizeof(char *));
        if (!*aReturn) return;
            PL_strncpy(*aReturn, (char *) resBuf, resLen);
    }
    return;
}

Here is the call graph for this function:

Definition at line 1352 of file os2Embed.cpp.

{
    // TODO code to hide a tooltip should go here
}
static void WebBrowserChromeUI::SetFocus ( nsIWebBrowserChrome chrome) [static]

Definition at line 1233 of file os2Embed.cpp.

{
    HWND hwndDlg = GetBrowserDlgFromChrome(chrome);
       if (hwndDlg == NULL)
       {
              return;
       }
    
    HWND hwndBrowser = WinWindowFromID(hwndDlg, IDC_BROWSER);
    ::WinSetFocus(HWND_DESKTOP, hwndBrowser);
}

Here is the call graph for this function:

static void WebBrowserChromeUI::ShowContextMenu ( nsIWebBrowserChrome aChrome,
PRUint32  aContextFlags,
nsIDOMEvent aEvent,
nsIDOMNode aNode 
) [static]
void WebBrowserChromeUI::ShowContextMenu ( nsIWebBrowserChrome aChrome,
PRUint32  aContextFlags,
nsIDOMEvent aEvent,
nsIDOMNode aNode 
) [static]

Definition at line 1332 of file os2Embed.cpp.

{
    // TODO code to test context flags and display a popup menu should go here
}
static void WebBrowserChromeUI::ShowTooltip ( nsIWebBrowserChrome aChrome,
PRInt32  aXCoords,
PRInt32  aYCoords,
const PRUnichar aTipText 
) [static]
void WebBrowserChromeUI::ShowTooltip ( nsIWebBrowserChrome aChrome,
PRInt32  aXCoords,
PRInt32  aYCoords,
const PRUnichar aTipText 
) [static]

Definition at line 1342 of file os2Embed.cpp.

{
    // TODO code to show a tooltip should go here
}
static void WebBrowserChromeUI::ShowWindow ( nsIWebBrowserChrome aChrome,
PRBool  aShow 
) [static]
void WebBrowserChromeUI::ShowWindow ( nsIWebBrowserChrome aChrome,
PRBool  aShow 
) [static]

Definition at line 1357 of file os2Embed.cpp.

{
  HWND win = GetBrowserDlgFromChrome(aChrome);
  ::WinShowWindow(win, aShow);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void WebBrowserChromeUI::SizeTo ( nsIWebBrowserChrome aChrome,
PRInt32  aWidth,
PRInt32  aHeight 
) [static]
void WebBrowserChromeUI::SizeTo ( nsIWebBrowserChrome aChrome,
PRInt32  aWidth,
PRInt32  aHeight 
) [static]

Definition at line 1363 of file os2Embed.cpp.

{
  HWND hchrome = GetBrowserDlgFromChrome(aChrome);
  HWND hbrowser = GetBrowserFromChrome(aChrome);
  RECTL chromeRect, browserRect;

  ::WinQueryWindowRect(hchrome,  &chromeRect);
  ::WinQueryWindowRect(hbrowser, &browserRect);

  PRInt32 decoration_x = (browserRect.xLeft - chromeRect.xLeft) + 
                         (chromeRect.xRight - browserRect.xRight);
  PRInt32 decoration_y = (chromeRect.yTop - browserRect.yTop) + 
                         (browserRect.yBottom - chromeRect.yBottom);

  ::WinSetWindowPos(hchrome, HWND_TOP, WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN)/2 - (aWidth+decoration_x)/2,
                    WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN)/2 - (aHeight+decoration_y)/2, 
                    aWidth+decoration_x, aHeight+decoration_y, SWP_SIZE | SWP_MOVE | SWP_SHOW);
}

Here is the call graph for this function:

static void WebBrowserChromeUI::UpdateBusyState ( nsIWebBrowserChrome aChrome,
PRBool  aBusy 
) [static]

Definition at line 1289 of file os2Embed.cpp.

{
    HWND hwndDlg = GetBrowserDlgFromChrome(aChrome);
    HWND button;
    button = WinWindowFromID(hwndDlg, IDC_STOP);
    if (button)
        WinEnableWindow(button, aBusy);
    button = WinWindowFromID(hwndDlg, IDC_GO);
    if (button)
        WinEnableWindow(button, !aBusy);
    UpdateUI(aChrome);
}

Here is the call graph for this function:

Definition at line 1265 of file os2Embed.cpp.

{
    nsCOMPtr<nsIWebBrowser> webBrowser;
    nsCOMPtr<nsIWebNavigation> webNavigation;
    aChrome->GetWebBrowser(getter_AddRefs(webBrowser));
    webNavigation = do_QueryInterface(webBrowser);

    nsCOMPtr<nsIURI> currentURI;
    webNavigation->GetCurrentURI(getter_AddRefs(currentURI));
    if (currentURI)
    {
        nsCAutoString uriString;
        currentURI->GetAsciiSpec(uriString);
        HWND hwndDlg = GetBrowserDlgFromChrome(aChrome);
        WinSetDlgItemText(hwndDlg, IDC_ADDRESS, uriString.get());
    }
}

Here is the call graph for this function:

static void WebBrowserChromeUI::UpdateProgress ( nsIWebBrowserChrome aChrome,
PRInt32  aCurrent,
PRInt32  aMax 
) [static]
void WebBrowserChromeUI::UpdateProgress ( nsIWebBrowserChrome aChrome,
PRInt32  aCurrent,
PRInt32  aMax 
) [static]

Definition at line 1308 of file os2Embed.cpp.

{
    HWND hwndDlg = GetBrowserDlgFromChrome(aChrome);
    HWND hwndProgress = WinWindowFromID(hwndDlg, IDC_PROGRESS);
    if (aCurrent < 0)
    {
        aCurrent = 0;
    }
    if (aCurrent > aMax)
    {
        aMax = aCurrent + 20; // What to do?
    }
    if (hwndProgress)
    {
        ULONG value = (double)aCurrent/(double)aMax*(double)100;
        WinSendMsg(hwndProgress, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), (MPARAM)(value == 100? value-1: value));
    }
}

Here is the call graph for this function:

static void WebBrowserChromeUI::UpdateStatusBarText ( nsIWebBrowserChrome aChrome,
const PRUnichar aStatusText 
) [static]

Definition at line 1250 of file os2Embed.cpp.

{
    HWND hwndDlg = GetBrowserDlgFromChrome(aChrome);
    nsCString status; 
    if (aStatusText)
        status.AssignWithConversion(aStatusText);
    WinSetDlgItemText(hwndDlg, IDC_STATUS, status.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:


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