Back to index

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

#include <BrowserFrame.h>

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

List of all members.

Public Member Functions

 BrowserFrame (wxWindow *aParent)
nsresult LoadURI (const char *aURI)
nsresult LoadURI (const wchar_t *aURI)
virtual nsresult CreateBrowserWindow (PRUint32 aChromeFlags, nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow)
virtual void UpdateStatusBarText (const PRUnichar *aStatusText)
virtual void UpdateCurrentURI ()
virtual void ShowContextMenu (PRUint32 aContextFlags, nsIContextMenuInfo *aContextMenuInfo)
void OnActivate (wxActivateEvent &event)
void OnEditCut (wxCommandEvent &event)
void OnUpdateEditCut (wxUpdateUIEvent &event)
void OnEditCopy (wxCommandEvent &event)
void OnUpdateEditCopy (wxUpdateUIEvent &event)
void OnEditPaste (wxCommandEvent &event)
void OnUpdateEditPaste (wxUpdateUIEvent &event)
void OnEditSelectAll (wxCommandEvent &event)
bool SetupDefaultGeckoWindow ()
bool SetupGeckoWindow (GeckoWindow *aGeckoWindow, GeckoContainerUI *aUI, nsIWebBrowser **aWebBrowser) const
void SetFocus ()
virtual void Destroy ()
virtual void Destroyed ()
virtual void KillFocus ()
virtual void UpdateBusyState (PRBool aBusy)
virtual void UpdateProgress (PRInt32 aCurrent, PRInt32 aMax)
virtual void GetResourceStringById (PRInt32 aID, char **aReturn)
virtual void ShowTooltip (PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText)
virtual void HideTooltip ()
virtual void ShowWindow (PRBool aShow)
virtual void SizeTo (PRInt32 aWidth, PRInt32 aHeight)
virtual void EnableChromeWindow (PRBool aEnabled)
virtual PRUint32 RunEventLoop (PRBool &aRunCondition)

Protected Member Functions

void OnBrowserUrl (wxCommandEvent &event)
void OnBrowserGo (wxCommandEvent &event)
void OnBrowserHome (wxCommandEvent &event)
void OnBrowserOpenLinkInNewWindow (wxCommandEvent &event)
void OnBrowserBack (wxCommandEvent &event)
void OnUpdateBrowserBack (wxUpdateUIEvent &event)
void OnBrowserForward (wxCommandEvent &event)
void OnUpdateBrowserForward (wxUpdateUIEvent &event)
void OnBrowserReload (wxCommandEvent &event)
void OnBrowserStop (wxCommandEvent &event)
void OnUpdateBrowserStop (wxUpdateUIEvent &event)
void OnFileSave (wxCommandEvent &event)
void OnFilePrint (wxCommandEvent &event)
void OnViewPageSource (wxCommandEvent &event)
void OnUpdateViewPageSource (wxUpdateUIEvent &event)

Protected Attributes

nsAutoString mContextLinkUrl
GeckoWindowmGeckoWnd
nsCOMPtr< nsIWebBrowsermWebBrowser
PRBool mBusy

Detailed Description

Definition at line 36 of file BrowserFrame.h.


Constructor & Destructor Documentation

Definition at line 61 of file BrowserFrame.cpp.

{
    wxXmlResource::Get()->LoadFrame(this, aParent, wxT("browser_frame"));

    SetIcon(wxICON(appicon));

    SetName("browser");

    SetupDefaultGeckoWindow();

    CreateStatusBar();
}

Here is the caller graph for this function:


Member Function Documentation

nsresult BrowserFrame::CreateBrowserWindow ( PRUint32  aChromeFlags,
nsIWebBrowserChrome aParent,
nsIWebBrowserChrome **  aNewWindow 
) [virtual]

Reimplemented from GeckoContainerUI.

Definition at line 241 of file BrowserFrame.cpp.

{
    // Create the main frame window
    BrowserFrame* frame = new BrowserFrame(NULL);
    if (!frame)
        return NS_ERROR_OUT_OF_MEMORY;
    frame->Show(TRUE);
    GeckoContainer *container = frame->mGeckoWnd->GetGeckoContainer();
    return container->QueryInterface(NS_GET_IID(nsIWebBrowserChrome), (void **) aNewWindow);
}

Here is the call graph for this function:

void GeckoContainerUI::Destroy ( void  ) [virtual, inherited]

Definition at line 42 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::Destroyed ( ) [virtual, inherited]

Definition at line 46 of file GeckoContainerUI.cpp.

{
}

Here is the caller graph for this function:

void GeckoContainerUI::EnableChromeWindow ( PRBool  aEnabled) [virtual, inherited]

Definition at line 99 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::GetResourceStringById ( PRInt32  aID,
char **  aReturn 
) [virtual, inherited]

Definition at line 75 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::HideTooltip ( ) [virtual, inherited]

Definition at line 87 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::KillFocus ( ) [virtual, inherited]

Definition at line 54 of file GeckoContainerUI.cpp.

{
}

Definition at line 93 of file BrowserFrame.cpp.

{
    wxMBConv conv;
    return LoadURI(conv.cWX2WC(aURI));
}

Here is the caller graph for this function:

nsresult BrowserFrame::LoadURI ( const wchar_t *  aURI)

Definition at line 75 of file BrowserFrame.cpp.

Here is the call graph for this function:

void GeckoFrame::OnActivate ( wxActivateEvent &  event) [inherited]

Definition at line 94 of file GeckoFrame.cpp.

{
    nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
    if (focus)
    {
        if (event.GetActive())
            focus->Activate();
        else
            focus->Deactivate();
    }
    wxFrame::OnActivate(event);
}

Here is the call graph for this function:

void BrowserFrame::OnBrowserBack ( wxCommandEvent &  event) [protected]

Definition at line 163 of file BrowserFrame.cpp.

{
    if (mWebBrowser)
    {
        nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
        webNav->GoBack();
    }
}

Here is the call graph for this function:

void BrowserFrame::OnBrowserForward ( wxCommandEvent &  event) [protected]

Definition at line 183 of file BrowserFrame.cpp.

{
    if (mWebBrowser)
    {
        nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
        webNav->GoForward();
    }
}

Here is the call graph for this function:

void BrowserFrame::OnBrowserGo ( wxCommandEvent &  event) [protected]

Definition at line 148 of file BrowserFrame.cpp.

{
    wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this);
    wxString url = txtCtrl->GetValue();
    if (!url.IsEmpty())
    {
        LoadURI(url);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void BrowserFrame::OnBrowserHome ( wxCommandEvent &  event) [protected]

Definition at line 226 of file BrowserFrame.cpp.

{
    LoadURI("http://www.mozilla.org/projects/embedding/");
}

Here is the call graph for this function:

void BrowserFrame::OnBrowserOpenLinkInNewWindow ( wxCommandEvent &  event) [protected]

Definition at line 231 of file BrowserFrame.cpp.

{
    BrowserFrame* frame = new BrowserFrame(NULL);
    frame->Show(TRUE);
    frame->LoadURI(mContextLinkUrl.get());
}

Here is the call graph for this function:

void BrowserFrame::OnBrowserReload ( wxCommandEvent &  event) [protected]

Definition at line 203 of file BrowserFrame.cpp.

Here is the call graph for this function:

void BrowserFrame::OnBrowserStop ( wxCommandEvent &  event) [protected]

Definition at line 212 of file BrowserFrame.cpp.

Here is the call graph for this function:

void BrowserFrame::OnBrowserUrl ( wxCommandEvent &  event) [protected]

Definition at line 158 of file BrowserFrame.cpp.

Here is the call graph for this function:

void GeckoFrame::OnEditCopy ( wxCommandEvent &  event) [inherited]

Definition at line 123 of file GeckoFrame.cpp.

{
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->CopySelection();
}

Here is the call graph for this function:

void GeckoFrame::OnEditCut ( wxCommandEvent &  event) [inherited]

Definition at line 107 of file GeckoFrame.cpp.

{
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->CutSelection();
}

Here is the call graph for this function:

void GeckoFrame::OnEditPaste ( wxCommandEvent &  event) [inherited]

Definition at line 139 of file GeckoFrame.cpp.

{
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->Paste();
}

Here is the call graph for this function:

void GeckoFrame::OnEditSelectAll ( wxCommandEvent &  event) [inherited]

Definition at line 155 of file GeckoFrame.cpp.

{
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->SelectAll();
}

Here is the call graph for this function:

void BrowserFrame::OnFilePrint ( wxCommandEvent &  event) [protected]

Definition at line 108 of file BrowserFrame.cpp.

{
}
void BrowserFrame::OnFileSave ( wxCommandEvent &  event) [protected]

Definition at line 104 of file BrowserFrame.cpp.

{
}
void BrowserFrame::OnUpdateBrowserBack ( wxUpdateUIEvent &  event) [protected]

Definition at line 172 of file BrowserFrame.cpp.

{
    PRBool canGoBack = PR_FALSE;
    if (mWebBrowser)
    {
        nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
        webNav->GetCanGoBack(&canGoBack);
    }
    event.Enable(canGoBack ? true : false);
}

Here is the call graph for this function:

void BrowserFrame::OnUpdateBrowserForward ( wxUpdateUIEvent &  event) [protected]

Definition at line 192 of file BrowserFrame.cpp.

{
    PRBool canGoForward = PR_FALSE;
    if (mWebBrowser)
    {
        nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
        webNav->GetCanGoForward(&canGoForward);
    }
    event.Enable(canGoForward ? true : false);
}

Here is the call graph for this function:

void BrowserFrame::OnUpdateBrowserStop ( wxUpdateUIEvent &  event) [protected]

Definition at line 221 of file BrowserFrame.cpp.

{
    event.Enable(mBusy ? true : false);
}
void GeckoFrame::OnUpdateEditCopy ( wxUpdateUIEvent &  event) [inherited]

Definition at line 130 of file GeckoFrame.cpp.

{
    PRBool canCopy = PR_FALSE;
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->CanCopySelection(&canCopy);
    event.Enable(canCopy ? true : false);
}

Here is the call graph for this function:

void GeckoFrame::OnUpdateEditCut ( wxUpdateUIEvent &  event) [inherited]

Definition at line 114 of file GeckoFrame.cpp.

{
    PRBool canCut = PR_FALSE;
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->CanCutSelection(&canCut);
    event.Enable(canCut ? true : false);
}

Here is the call graph for this function:

void GeckoFrame::OnUpdateEditPaste ( wxUpdateUIEvent &  event) [inherited]

Definition at line 146 of file GeckoFrame.cpp.

{
    PRBool canPaste = PR_FALSE;
    nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
    if(clipCmds)
        clipCmds->CanPaste(&canPaste);
    event.Enable(canPaste ? true : false);
}

Here is the call graph for this function:

void BrowserFrame::OnUpdateViewPageSource ( wxUpdateUIEvent &  event) [protected]

Definition at line 144 of file BrowserFrame.cpp.

{
}
void BrowserFrame::OnViewPageSource ( wxCommandEvent &  event) [protected]

Definition at line 112 of file BrowserFrame.cpp.

{
    nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
    if(!webNav)
        return;

    // Get the URI object whose source we want to view.
    nsresult rv = NS_OK;
    nsCOMPtr<nsIURI> currentURI;
    rv = webNav->GetCurrentURI(getter_AddRefs(currentURI));
    if(NS_FAILED(rv) || !currentURI)
        return;

    // Get the uri string associated with the nsIURI object
    nsCAutoString uriString;
    rv = currentURI->GetSpec(uriString);
    if(NS_FAILED(rv))
        return;

    // Build the view-source: url
    nsAutoString viewSrcUrl(L"view-source:");
    viewSrcUrl.AppendWithConversion(uriString.get());

    BrowserFrame *frame = new BrowserFrame(NULL);
    if (frame)
    {
        frame->Show(TRUE);
        frame->LoadURI(viewSrcUrl.get());
    }

}

Here is the call graph for this function:

PRUint32 GeckoContainerUI::RunEventLoop ( PRBool aRunCondition) [virtual, inherited]

Definition at line 103 of file GeckoContainerUI.cpp.

{
    return 0;
}
void GeckoFrame::SetFocus ( ) [virtual, inherited]

Reimplemented from GeckoContainerUI.

Definition at line 165 of file GeckoFrame.cpp.

{
    mGeckoWnd->SetFocus();
}

Definition at line 57 of file GeckoFrame.cpp.

{
    mGeckoWnd  = (GeckoWindow *) FindWindowById(XRCID("gecko"), this);
    if (!mGeckoWnd)
        return FALSE;
    return SetupGeckoWindow(mGeckoWnd, this, getter_AddRefs(mWebBrowser));
}

Here is the call graph for this function:

bool GeckoFrame::SetupGeckoWindow ( GeckoWindow aGeckoWindow,
GeckoContainerUI aUI,
nsIWebBrowser **  aWebBrowser 
) const [inherited]

Definition at line 65 of file GeckoFrame.cpp.

{
    if (!aGeckoWindow || !aUI)
        return FALSE;

    GeckoContainer *geckoContainer = new GeckoContainer(aUI);
    if (!geckoContainer)
        return FALSE;

    mGeckoWnd->SetGeckoContainer(geckoContainer);

    PRUint32 aChromeFlags = nsIWebBrowserChrome::CHROME_ALL;
    geckoContainer->SetChromeFlags(aChromeFlags);
    geckoContainer->SetParent(nsnull);
    wxSize size = mGeckoWnd->GetClientSize();

    // Insert the browser
    geckoContainer->CreateBrowser(0, 0, size.GetWidth(), size.GetHeight(),
        (nativeWindow) aGeckoWindow->GetHWND(), aWebBrowser);

    nsCOMPtr<nsIBaseWindow> webBrowserAsWin = do_QueryInterface(*aWebBrowser);
    if (webBrowserAsWin)
    {
        webBrowserAsWin->SetVisibility(PR_TRUE);
    }

    return TRUE;
}

Here is the call graph for this function:

void BrowserFrame::ShowContextMenu ( PRUint32  aContextFlags,
nsIContextMenuInfo aContextMenuInfo 
) [virtual]

Reimplemented from GeckoContainerUI.

Definition at line 278 of file BrowserFrame.cpp.

{
    nsCOMPtr<nsIDOMEvent> event;
    aContextMenuInfo->GetMouseEvent(getter_AddRefs(event));
    if (!event)
    {
        return;
    }

    mContextLinkUrl.SetLength(0);

    nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(event);
    if (mouseEvent)
    {
        PRInt32 x, y;
        mouseEvent->GetScreenX(&x);
        mouseEvent->GetScreenY(&y);

        char *menuName = NULL;

        // CONTEXT_LINK                   <A>
        // CONTEXT_IMAGE                  <IMG>
        // CONTEXT_IMAGE | CONTEXT_LINK   <IMG> with <A> as an ancestor
        // CONTEXT_INPUT                  <INPUT>
        // CONTEXT_INPUT | CONTEXT_IMAGE  <INPUT> with type=image
        // CONTEXT_TEXT                   <TEXTAREA>
        // CONTEXT_DOCUMENT               <HTML>
        // CONTEXT_BACKGROUND_IMAGE       <HTML> with background image
        
        if (aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE)
        {
            if (aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
                menuName = "context_browser_image"; // TODO
            else if (aContextFlags & nsIContextMenuListener2::CONTEXT_INPUT)
                menuName = "context_browser_image"; // TODO
            else
                menuName = "context_browser_image"; // TODO
        }
        else if (aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
        {
            menuName = "context_browser_link";

            aContextMenuInfo->GetAssociatedLink(mContextLinkUrl);
        }
        else if (aContextFlags & nsIContextMenuListener2::CONTEXT_INPUT)
        {
            menuName = "context_browser_input";
        }
        else if (aContextFlags & nsIContextMenuListener2::CONTEXT_TEXT)
        {
            menuName = "context_browser_text";
        }
        else if (aContextFlags & nsIContextMenuListener2::CONTEXT_DOCUMENT)
        {
            menuName = "context_browser_document";
        }
        else if (aContextFlags & nsIContextMenuListener2::CONTEXT_BACKGROUND_IMAGE)
        {
            menuName = "context_browser_document";
        }

        if (!menuName)
            return;

// Hack for Win32 that has a #define for LoadMenu
#undef LoadMenu
        wxMenu *menu = wxXmlResource::Get()->LoadMenu(menuName);
        if (menu)
        {
            int fX = 0, fY = 0;
            // Make screen coords relative to the frame window for accurate
            // popup menu position
            GetPosition(&fX, &fY);
            PopupMenu(menu, x - fX, y - fY);
        }
    }
}

Here is the call graph for this function:

void GeckoContainerUI::ShowTooltip ( PRInt32  aXCoords,
PRInt32  aYCoords,
const PRUnichar aTipText 
) [virtual, inherited]

Definition at line 83 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::ShowWindow ( PRBool  aShow) [virtual, inherited]

Definition at line 91 of file GeckoContainerUI.cpp.

{
}

Here is the caller graph for this function:

void GeckoContainerUI::SizeTo ( PRInt32  aWidth,
PRInt32  aHeight 
) [virtual, inherited]

Definition at line 95 of file GeckoContainerUI.cpp.

{
}
void GeckoContainerUI::UpdateBusyState ( PRBool  aBusy) [virtual, inherited]

Definition at line 66 of file GeckoContainerUI.cpp.

{
    mBusy = aBusy;
}

Reimplemented from GeckoContainerUI.

Definition at line 258 of file BrowserFrame.cpp.

{
    if (mWebBrowser)
    {
        nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(mWebBrowser);
        nsCOMPtr<nsIURI> currentURI;
        webNav->GetCurrentURI(getter_AddRefs(currentURI));
        nsCAutoString spec;
        currentURI->GetSpec(spec);

        wxTextCtrl *txtCtrl = (wxTextCtrl *) FindWindowById(XRCID("url"), this);
        if (txtCtrl)
        {
            txtCtrl->SetValue(spec.get());
        }
    }
}

Here is the call graph for this function:

void GeckoContainerUI::UpdateProgress ( PRInt32  aCurrent,
PRInt32  aMax 
) [virtual, inherited]

Definition at line 71 of file GeckoContainerUI.cpp.

{
}
void BrowserFrame::UpdateStatusBarText ( const PRUnichar aStatusText) [virtual]

Reimplemented from GeckoContainerUI.

Definition at line 253 of file BrowserFrame.cpp.

{
    SetStatusText(aStatusText);
}

Member Data Documentation

PRBool GeckoContainerUI::mBusy [protected, inherited]

Definition at line 138 of file GeckoContainer.h.

Definition at line 42 of file BrowserFrame.h.

GeckoWindow* GeckoFrame::mGeckoWnd [protected, inherited]

Definition at line 44 of file GeckoFrame.h.

Definition at line 45 of file GeckoFrame.h.


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