From 3cb5199c1ce3802c7eae2a97e8f9c0bb8417d017 Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Fri, 17 Jan 2003 00:40:45 +0000 Subject: [PATCH] Add CBrowserTooltip class and support for tooltips. Detab files. b=144880 r=chak@netscape.com sr=alecf@netscape.com git-svn-id: svn://10.0.0.236/trunk@136462 18797224-902f-48f8-a5cc-f745e15eee43 --- .../tests/mfcembed/BrowserFrameGlue.cpp | 13 + .../embedding/tests/mfcembed/BrowserFrm.cpp | 287 +++--- mozilla/embedding/tests/mfcembed/BrowserFrm.h | 141 +-- .../embedding/tests/mfcembed/BrowserImpl.cpp | 146 +-- .../embedding/tests/mfcembed/BrowserImpl.h | 2 + .../mfcembed/BrowserImplCtxMenuLstnr.cpp | 6 +- .../tests/mfcembed/BrowserImplPrompt.cpp | 70 +- .../tests/mfcembed/BrowserToolTip.cpp | 147 +++ .../embedding/tests/mfcembed/BrowserToolTip.h | 87 ++ .../embedding/tests/mfcembed/BrowserView.cpp | 854 +++++++++--------- .../embedding/tests/mfcembed/BrowserView.h | 200 ++-- mozilla/embedding/tests/mfcembed/Dialogs.cpp | 88 +- mozilla/embedding/tests/mfcembed/Dialogs.h | 28 +- .../embedding/tests/mfcembed/EditorFrm.cpp | 208 ++--- mozilla/embedding/tests/mfcembed/EditorFrm.h | 64 +- .../tests/mfcembed/IBrowserFrameGlue.h | 108 +-- mozilla/embedding/tests/mfcembed/Makefile.in | 1 + mozilla/embedding/tests/mfcembed/MfcEmbed.cpp | 288 +++--- mozilla/embedding/tests/mfcembed/MfcEmbed.h | 54 +- .../tests/mfcembed/MostRecentUrls.cpp | 48 +- .../embedding/tests/mfcembed/Preferences.cpp | 38 +- .../embedding/tests/mfcembed/Preferences.h | 62 +- .../embedding/tests/mfcembed/ProfilesDlg.cpp | 98 +- .../embedding/tests/mfcembed/ProfilesDlg.h | 102 +-- mozilla/embedding/tests/mfcembed/StdAfx.h | 11 +- mozilla/embedding/tests/mfcembed/mfcembed.dsp | 8 + .../mfcembed/winEmbedFileLocProvider.cpp | 20 +- .../tests/mfcembed/winEmbedFileLocProvider.h | 26 +- 28 files changed, 1752 insertions(+), 1453 deletions(-) create mode 100644 mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp create mode 100644 mozilla/embedding/tests/mfcembed/BrowserToolTip.h diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp index 6bf6ab2ea2a..5be21f4a306 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp @@ -483,3 +483,16 @@ void CBrowserFrame::BrowserFrameGlueObj::UpdateSecurityStatus(PRInt32 aState) pThis->UpdateSecurityStatus(aState); } + +void CBrowserFrame::BrowserFrameGlueObj::ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) +{ + METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) + pThis->m_wndTooltip.SetTipText(CString(aTipText)); + pThis->m_wndTooltip.Show(&pThis->m_wndBrowserView, aXCoords, aYCoords); +} + +void CBrowserFrame::BrowserFrameGlueObj::HideTooltip() +{ + METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) + pThis->m_wndTooltip.Hide(); +} diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp index dc35d4c19c6..540892821a3 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp @@ -83,20 +83,20 @@ static char THIS_FILE[] = __FILE__; IMPLEMENT_DYNAMIC(CBrowserFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd) - //{{AFX_MSG_MAP(CBrowserFrame) - ON_WM_CREATE() - ON_WM_SETFOCUS() - ON_WM_SIZE() - ON_WM_CLOSE() - ON_WM_ACTIVATE() - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CBrowserFrame) + ON_WM_CREATE() + ON_WM_SETFOCUS() + ON_WM_SIZE() + ON_WM_CLOSE() + ON_WM_ACTIVATE() + //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { - ID_SEPARATOR, // For the Status line - ID_SEPARATOR, // For the Progress Bar - ID_SEPARATOR, // For the padlock image + ID_SEPARATOR, // For the Status line + ID_SEPARATOR, // For the Progress Bar + ID_SEPARATOR, // For the padlock image }; ///////////////////////////////////////////////////////////////////////////// @@ -104,17 +104,17 @@ static UINT indicators[] = CBrowserFrame::CBrowserFrame() { - mIsEditor = FALSE; + mIsEditor = FALSE; } CBrowserFrame::CBrowserFrame(PRUint32 chromeMask) { - // Save the chromeMask off. It'll be used - // later to determine whether this browser frame - // will have menubar, toolbar, statusbar etc. + // Save the chromeMask off. It'll be used + // later to determine whether this browser frame + // will have menubar, toolbar, statusbar etc. - m_chromeMask = chromeMask; - mIsEditor = FALSE; + m_chromeMask = chromeMask; + mIsEditor = FALSE; } CBrowserFrame::~CBrowserFrame() @@ -123,10 +123,10 @@ CBrowserFrame::~CBrowserFrame() void CBrowserFrame::OnClose() { - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - pApp->RemoveFrameFromList(this); + CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); + pApp->RemoveFrameFromList(this); - DestroyWindow(); + DestroyWindow(); } // This is where the UrlBar, ToolBar, StatusBar, ProgressBar @@ -134,38 +134,38 @@ void CBrowserFrame::OnClose() // int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; + if (CFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; - // Pass "this" to the View for later callbacks - // and/or access to any public data members, if needed - // - m_wndBrowserView.SetBrowserFrame(this); + // Pass "this" to the View for later callbacks + // and/or access to any public data members, if needed + // + m_wndBrowserView.SetBrowserFrame(this); - // Pass on the BrowserFrameGlue also to the View which - // it will use during the Init() process after creation - // of the BrowserImpl obj. Essentially, the View object - // hooks up the Embedded browser's callbacks to the BrowserFrame - // via this BrowserFrameGlue object - m_wndBrowserView.SetBrowserFrameGlue((PBROWSERFRAMEGLUE)&m_xBrowserFrameGlueObj); + // Pass on the BrowserFrameGlue also to the View which + // it will use during the Init() process after creation + // of the BrowserImpl obj. Essentially, the View object + // hooks up the Embedded browser's callbacks to the BrowserFrame + // via this BrowserFrameGlue object + m_wndBrowserView.SetBrowserFrameGlue((PBROWSERFRAMEGLUE)&m_xBrowserFrameGlueObj); - // create a view to occupy the client area of the frame - // This will be the view in which the embedded browser will - // be displayed in - // - if (!m_wndBrowserView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, - CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) - { - TRACE0("Failed to create view window\n"); - return -1; - } + // create a view to occupy the client area of the frame + // This will be the view in which the embedded browser will + // be displayed in + // + if (!m_wndBrowserView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, + CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) + { + TRACE0("Failed to create view window\n"); + return -1; + } - // create the URL bar (essentially a ComboBoxEx object) - if (!m_wndUrlBar.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 150), this, ID_URL_BAR)) - { - TRACE0("Failed to create URL Bar\n"); - return -1; // fail to create - } + // create the URL bar (essentially a ComboBoxEx object) + if (!m_wndUrlBar.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 150), this, ID_URL_BAR)) + { + TRACE0("Failed to create URL Bar\n"); + return -1; // fail to create + } // Load the Most Recently Used(MRU) Urls into the UrlBar m_wndUrlBar.LoadMRUList(); @@ -175,128 +175,131 @@ int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) // Create the toolbar with Back, Fwd, Stop, etc. buttons.. // or // Create a toolbar with the Editor toolbar buttons - Bold, Italic etc. - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(resID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(resID)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } - // Create a ReBar window to which the toolbar and UrlBar - // will be added - if (!m_wndReBar.Create(this)) - { - TRACE0("Failed to create ReBar\n"); - return -1; // fail to create - } - - //Add the ToolBar and UrlBar windows to the rebar - m_wndReBar.AddBar(&m_wndToolBar); + // Create a ReBar window to which the toolbar and UrlBar + // will be added + if (!m_wndReBar.Create(this)) + { + TRACE0("Failed to create ReBar\n"); + return -1; // fail to create + } + + //Add the ToolBar and UrlBar windows to the rebar + m_wndReBar.AddBar(&m_wndToolBar); - if (!mIsEditor) - m_wndReBar.AddBar(&m_wndUrlBar, "Enter URL:"); + if (!mIsEditor) + m_wndReBar.AddBar(&m_wndUrlBar, "Enter URL:"); - // Create the status bar with two panes - one pane for actual status - // text msgs. and the other for the progress control - if (!m_wndStatusBar.CreateEx(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } + // Create the status bar with two panes - one pane for actual status + // text msgs. and the other for the progress control + if (!m_wndStatusBar.CreateEx(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } - // Create the progress bar as a child of the status bar. - // Note that the ItemRect which we'll get at this stage - // is bogus since the status bar panes are not fully - // positioned yet i.e. we'll be passing in an invalid rect - // to the Create function below - // The actual positioning of the progress bar will be done - // in response to OnSize() - RECT rc; - m_wndStatusBar.GetItemRect (1, &rc); - if (!m_wndProgressBar.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, rc, &m_wndStatusBar, ID_PROG_BAR)) - { - TRACE0("Failed to create progress bar\n"); - return -1; // fail to create - } + // Create the progress bar as a child of the status bar. + // Note that the ItemRect which we'll get at this stage + // is bogus since the status bar panes are not fully + // positioned yet i.e. we'll be passing in an invalid rect + // to the Create function below + // The actual positioning of the progress bar will be done + // in response to OnSize() + RECT rc; + m_wndStatusBar.GetItemRect (1, &rc); + if (!m_wndProgressBar.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, rc, &m_wndStatusBar, ID_PROG_BAR)) + { + TRACE0("Failed to create progress bar\n"); + return -1; // fail to create + } - // The third pane(i.e. at index 2) of the status bar will have - // the security lock icon displayed in it. Set up it's size(16) - // and style(no border)so that the padlock icons can be properly drawn - m_wndStatusBar.SetPaneInfo(2, -1, SBPS_NORMAL|SBPS_NOBORDERS, 16); + // The third pane(i.e. at index 2) of the status bar will have + // the security lock icon displayed in it. Set up it's size(16) + // and style(no border)so that the padlock icons can be properly drawn + m_wndStatusBar.SetPaneInfo(2, -1, SBPS_NORMAL|SBPS_NOBORDERS, 16); - // Also, set the padlock icon to be the insecure icon to begin with - UpdateSecurityStatus(nsIWebProgressListener::STATE_IS_INSECURE); + // Create a tooltip window. (the MFC tooltip is not really suitable) + m_wndTooltip.Create(CWnd::GetDesktopWindow()); - // Based on the "chromeMask" we were supplied during construction - // hide any requested UI elements - statusbar, menubar etc... - // Note that the window styles (WM_RESIZE etc) are set inside - // of PreCreateWindow() + // Also, set the padlock icon to be the insecure icon to begin with + UpdateSecurityStatus(nsIWebProgressListener::STATE_IS_INSECURE); - SetupFrameChrome(); + // Based on the "chromeMask" we were supplied during construction + // hide any requested UI elements - statusbar, menubar etc... + // Note that the window styles (WM_RESIZE etc) are set inside + // of PreCreateWindow() - return 0; + SetupFrameChrome(); + + return 0; } void CBrowserFrame::SetupFrameChrome() { - if(m_chromeMask == nsIWebBrowserChrome::CHROME_ALL) - return; + if(m_chromeMask == nsIWebBrowserChrome::CHROME_ALL) + return; - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_MENUBAR) ) - SetMenu(NULL); // Hide the MenuBar + if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_MENUBAR) ) + SetMenu(NULL); // Hide the MenuBar - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR) ) - m_wndReBar.ShowWindow(SW_HIDE); // Hide the ToolBar + if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR) ) + m_wndReBar.ShowWindow(SW_HIDE); // Hide the ToolBar - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) ) - m_wndStatusBar.ShowWindow(SW_HIDE); // Hide the StatusBar + if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) ) + m_wndStatusBar.ShowWindow(SW_HIDE); // Hide the StatusBar } BOOL CBrowserFrame::PreCreateWindow(CREATESTRUCT& cs) { - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; + if( !CFrameWnd::PreCreateWindow(cs) ) + return FALSE; - cs.dwExStyle &= ~WS_EX_CLIENTEDGE; + cs.dwExStyle &= ~WS_EX_CLIENTEDGE; - // Change window style based on the chromeMask + // Change window style based on the chromeMask - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR) ) - cs.style &= ~WS_CAPTION; // No caption + if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR) ) + cs.style &= ~WS_CAPTION; // No caption - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) ) - { - // Can't resize this window - cs.style &= ~WS_SIZEBOX; - cs.style &= ~WS_THICKFRAME; - cs.style &= ~WS_MINIMIZEBOX; - cs.style &= ~WS_MAXIMIZEBOX; - } + if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) ) + { + // Can't resize this window + cs.style &= ~WS_SIZEBOX; + cs.style &= ~WS_THICKFRAME; + cs.style &= ~WS_MINIMIZEBOX; + cs.style &= ~WS_MAXIMIZEBOX; + } - cs.lpszClass = AfxRegisterWndClass(0); + cs.lpszClass = AfxRegisterWndClass(0); - return TRUE; + return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CBrowserFrame message handlers void CBrowserFrame::OnSetFocus(CWnd* pOldWnd) { - // forward focus to the view window - m_wndBrowserView.SetFocus(); + // forward focus to the view window + m_wndBrowserView.SetFocus(); } BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { - // let the view have first crack at the command - if (m_wndBrowserView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) - return TRUE; + // let the view have first crack at the command + if (m_wndBrowserView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) + return TRUE; - // otherwise, do default handling - return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); + // otherwise, do default handling + return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } // Needed to properly position/resize the progress bar @@ -304,7 +307,7 @@ BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERIN void CBrowserFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); - + // Get the ItemRect of the status bar's Pane 1 // That's where the progress bar will be located RECT rc; @@ -318,12 +321,12 @@ void CBrowserFrame::OnSize(UINT nType, int cx, int cy) #ifdef _DEBUG void CBrowserFrame::AssertValid() const { - CFrameWnd::AssertValid(); + CFrameWnd::AssertValid(); } void CBrowserFrame::Dump(CDumpContext& dc) const { - CFrameWnd::Dump(dc); + CFrameWnd::Dump(dc); } #endif //_DEBUG @@ -331,8 +334,8 @@ void CBrowserFrame::Dump(CDumpContext& dc) const void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { - CFrameWnd::OnActivate(nState, pWndOther, bMinimized); - + CFrameWnd::OnActivate(nState, pWndOther, bMinimized); + m_wndBrowserView.Activate(nState, pWndOther, bMinimized); } @@ -375,9 +378,9 @@ CMyStatusBar::~CMyStatusBar() } BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar) - //{{AFX_MSG_MAP(CMyStatusBar) - ON_WM_LBUTTONDOWN() - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CMyStatusBar) + ON_WM_LBUTTONDOWN() + //}}AFX_MSG_MAP END_MESSAGE_MAP() void CMyStatusBar::OnLButtonDown(UINT nFlags, CPoint point) @@ -394,6 +397,6 @@ void CMyStatusBar::OnLButtonDown(UINT nFlags, CPoint point) if(pFrame != NULL) pFrame->ShowSecurityInfo(); } - - CStatusBar::OnLButtonDown(nFlags, point); + + CStatusBar::OnLButtonDown(nFlags, point); } diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrm.h b/mozilla/embedding/tests/mfcembed/BrowserFrm.h index 2e48f762e73..4a08aafb879 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserFrm.h +++ b/mozilla/embedding/tests/mfcembed/BrowserFrm.h @@ -41,6 +41,7 @@ #endif // _MSC_VER > 1000 #include "BrowserView.h" +#include "BrowserToolTip.h" #include "IBrowserFrameGlue.h" #include "MostRecentUrls.h" @@ -48,24 +49,24 @@ class CUrlBar : public CComboBoxEx { public: - inline void GetEnteredURL(CString& url) { - GetEditCtrl()->GetWindowText(url); - } - inline void GetSelectedURL(CString& url) { - GetLBText(GetCurSel(), url); - } - inline void SetCurrentURL(LPCTSTR pUrl) { - SetWindowText(pUrl); - } - inline void AddURLToList(CString& url, bool bAddToMRUList = true) { - COMBOBOXEXITEM ci; - ci.mask = CBEIF_TEXT; ci.iItem = -1; - ci.pszText = (LPTSTR)(LPCTSTR)url; - InsertItem(&ci); + inline void GetEnteredURL(CString& url) { + GetEditCtrl()->GetWindowText(url); + } + inline void GetSelectedURL(CString& url) { + GetLBText(GetCurSel(), url); + } + inline void SetCurrentURL(LPCTSTR pUrl) { + SetWindowText(pUrl); + } + inline void AddURLToList(CString& url, bool bAddToMRUList = true) { + COMBOBOXEXITEM ci; + ci.mask = CBEIF_TEXT; ci.iItem = -1; + ci.pszText = (LPTSTR)(LPCTSTR)url; + InsertItem(&ci); if(bAddToMRUList) m_MRUList.AddURL((LPTSTR)(LPCTSTR)url); - } + } inline void LoadMRUList() { for (int i=0;iGetContentDOMWindow((nsIDOMWindow **) aInstancePtr); - return NS_ERROR_NOT_INITIALIZED; - } + if(aIID.Equals(NS_GET_IID(nsIDOMWindow))) + { + if (mWebBrowser) + return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr); + return NS_ERROR_NOT_INITIALIZED; + } - return QueryInterface(aIID, aInstancePtr); + return QueryInterface(aIID, aInstancePtr); } //***************************************************************************** @@ -142,12 +143,12 @@ NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr) // NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->UpdateStatusBarText(aStatus); + m_pBrowserFrameGlue->UpdateStatusBarText(aStatus); - return NS_OK; + return NS_OK; } NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser) @@ -187,27 +188,27 @@ NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask) // NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow() { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->DestroyBrowserFrame(); + m_pBrowserFrameGlue->DestroyBrowserFrame(); - return NS_OK; + return NS_OK; } // Gets called in response to set the size of a window // Ex: In response to a JavaScript Window.Open() call of // the form // -// window.open("http://www.mozilla.org", "theWin", "width=200, height=400"); +// window.open("http://www.mozilla.org", "theWin", "width=200, height=400"); // // First the CreateBrowserWindow() call will be made followed by a // call to this method to resize the window // NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd(); @@ -224,9 +225,9 @@ NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) rcNewFrame.right += rcFrame.Width() - rcClient.Width(); rcNewFrame.bottom += rcFrame.Height() - rcClient.Height(); - m_pBrowserFrameGlue->SetBrowserFrameSize(rcNewFrame.Width(), rcNewFrame.Height()); + m_pBrowserFrameGlue->SetBrowserFrameSize(rcNewFrame.Width(), rcNewFrame.Height()); - return NS_OK; + return NS_OK; } NS_IMETHODIMP CBrowserImpl::ShowAsModal(void) @@ -267,25 +268,25 @@ NS_IMETHODIMP CBrowserImpl::FocusPrevElement() NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) { - m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE); + m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE); } else { if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) { - m_pBrowserFrameGlue->SetBrowserFramePosition(x, y); + m_pBrowserFrameGlue->SetBrowserFramePosition(x, y); } if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) { - m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy); + m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy); } } @@ -294,17 +295,17 @@ NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) { - m_pBrowserFrameGlue->GetBrowserFramePosition(x, y); + m_pBrowserFrameGlue->GetBrowserFramePosition(x, y); } if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) { - m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy); + m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy); } return NS_OK; @@ -325,42 +326,42 @@ NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow) NS_IMETHODIMP CBrowserImpl::SetFocus() { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->SetFocus(); + m_pBrowserFrameGlue->SetFocus(); - return NS_OK; + return NS_OK; } NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle); - - return NS_OK; + m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle); + + return NS_OK; } NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle); - - return NS_OK; + m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle); + + return NS_OK; } NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; m_pBrowserFrameGlue->GetBrowserFrameVisibility(aVisibility); - return NS_OK; + return NS_OK; } NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility) @@ -381,3 +382,30 @@ NS_IMETHODIMP CBrowserImpl::Blur() { return NS_OK; } + + +//***************************************************************************** +// CBrowserImpl::nsITooltipListener +//***************************************************************************** + +/* void onShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */ +NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) +{ + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; + + m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText); + + return NS_OK; +} + +/* void onHideTooltip (); */ +NS_IMETHODIMP CBrowserImpl::OnHideTooltip() +{ + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; + + m_pBrowserFrameGlue->HideTooltip(); + + return NS_OK; +} diff --git a/mozilla/embedding/tests/mfcembed/BrowserImpl.h b/mozilla/embedding/tests/mfcembed/BrowserImpl.h index 891d72789a4..a5ebfd1c378 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserImpl.h +++ b/mozilla/embedding/tests/mfcembed/BrowserImpl.h @@ -42,6 +42,7 @@ class CBrowserImpl : public nsIInterfaceRequestor, public nsIEmbeddingSiteWindow2, public nsIWebProgressListener, public nsIContextMenuListener2, + public nsITooltipListener, public nsSupportsWeakReference { public: @@ -58,6 +59,7 @@ public: NS_DECL_NSIEMBEDDINGSITEWINDOW2 NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSICONTEXTMENULISTENER2 + NS_DECL_NSITOOLTIPLISTENER protected: diff --git a/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp b/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp index 8a34864fad2..db7694be24b 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp @@ -41,8 +41,8 @@ NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) { - if(m_pBrowserFrameGlue) - m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aInfo); + if(m_pBrowserFrameGlue) + m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aInfo); - return NS_OK; + return NS_OK; } \ No newline at end of file diff --git a/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp b/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp index 15905a2f29e..1f5668a74cf 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp @@ -52,25 +52,25 @@ NS_IMETHODIMP CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->Alert(dialogTitle, text); + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; + + m_pBrowserFrameGlue->Alert(dialogTitle, text); - return NS_OK; + return NS_OK; } // Invoked in the case of a JS confirm() method invocation NS_IMETHODIMP CBrowserImpl::Confirm(const PRUnichar *dialogTitle, - const PRUnichar *text, PRBool *retval) + const PRUnichar *text, PRBool *retval) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->Confirm(dialogTitle, text, retval); + m_pBrowserFrameGlue->Confirm(dialogTitle, text, retval); - return NS_OK; + return NS_OK; } NS_IMETHODIMP @@ -79,12 +79,12 @@ CBrowserImpl::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval); + m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval); - return NS_OK; + return NS_OK; } NS_IMETHODIMP @@ -93,11 +93,11 @@ CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password, - checkMsg, checkValue, _retval); + m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password, + checkMsg, checkValue, _retval); return NS_OK; } @@ -108,33 +108,33 @@ CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUn const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval) { - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; + if(! m_pBrowserFrameGlue) + return NS_ERROR_FAILURE; - m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text, - username, password, - checkMsg, checkValue, - _retval); + m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text, + username, password, + checkMsg, checkValue, + _retval); return NS_OK; } NS_IMETHODIMP CBrowserImpl::AlertCheck(const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue) + const PRUnichar *text, + const PRUnichar *checkMsg, + PRBool *checkValue) { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP CBrowserImpl::ConfirmCheck(const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, PRBool *retval) + const PRUnichar *text, + const PRUnichar *checkMsg, + PRBool *checkValue, PRBool *retval) { - return NS_ERROR_NOT_IMPLEMENTED; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -149,9 +149,9 @@ CBrowserImpl::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text, NS_IMETHODIMP CBrowserImpl::Select(const PRUnichar *dialogTitle, - const PRUnichar *text, PRUint32 count, - const PRUnichar **selectList, - PRInt32 *outSelection, PRBool *retval) + const PRUnichar *text, PRUint32 count, + const PRUnichar **selectList, + PRInt32 *outSelection, PRBool *retval) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp b/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp new file mode 100644 index 00000000000..19716573308 --- /dev/null +++ b/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp @@ -0,0 +1,147 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#include "stdafx.h" + +#include "BrowserToolTip.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBrowserToolTip + +CBrowserToolTip::CBrowserToolTip() +{ +} + +CBrowserToolTip::~CBrowserToolTip() +{ +} + + +BEGIN_MESSAGE_MAP(CBrowserToolTip, CWnd) + //{{AFX_MSG_MAP(CBrowserToolTip) + ON_WM_PAINT() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +BOOL CBrowserToolTip::Create(CWnd *pParentWnd) +{ + return CWnd::CreateEx(WS_EX_TOOLWINDOW, + AfxRegisterWndClass(CS_SAVEBITS, NULL, GetSysColorBrush(COLOR_INFOBK), NULL), + _T("ToolTip"), WS_POPUP | WS_BORDER, 0, 0, 1, 1, pParentWnd->GetSafeHwnd(), NULL); +} + +///////////////////////////////////////////////////////////////////////////// +// CBrowserToolTip message handlers + +void CBrowserToolTip::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + CRect rcClient; + GetClientRect(&rcClient); + + // Draw tip text + int oldBkMode = dc.SetBkMode(TRANSPARENT); + COLORREF oldTextColor = dc.SetTextColor(GetSysColor(COLOR_INFOTEXT)); + HGDIOBJ oldFont = dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT)); + + dc.DrawText(m_szTipText, -1, rcClient, DT_SINGLELINE | DT_VCENTER | DT_CENTER); + + dc.SetBkMode(oldBkMode); + dc.SetTextColor(oldTextColor); + dc.SelectObject(oldFont); +} + +BOOL CBrowserToolTip::PreCreateWindow(CREATESTRUCT& cs) +{ + return CWnd::PreCreateWindow(cs); +} + +void CBrowserToolTip::SetTipText(const CString &szTipText) +{ + m_szTipText = szTipText; +} + +void CBrowserToolTip::Show(CWnd *pOverWnd, long left, long top) +{ + // Calculate the client window size + CRect rcNewClient(0,0,0,0); + CDC *pdc = GetDC(); + HGDIOBJ oldFont = pdc->SelectObject(GetStockObject(DEFAULT_GUI_FONT)); + rcNewClient.bottom = pdc->DrawText(m_szTipText, -1, rcNewClient, + DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT); + pdc->SelectObject(oldFont); + ReleaseDC(pdc); + rcNewClient.right += 8; + rcNewClient.bottom += 8; + + // Adjust the tooltip to new size + AdjustWindowRectEx(rcNewClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE)); + + // Adjust the left, top position of the tooltip + CPoint ptTip(left, top); + pOverWnd->ClientToScreen(&ptTip); + + // Make sure tip is below cursor + POINT ptCursor; + GetCursorPos(&ptCursor); + long cyCursor = GetSystemMetrics(SM_CYCURSOR); + if (ptTip.y < ptCursor.y + cyCursor) + ptTip.y = ptCursor.y + cyCursor; + + // Make sure tip is fully visible + RECT rcScreen; + GetDesktopWindow()->GetClientRect(&rcScreen); + if (ptTip.x < 0) + ptTip.x = 0; + else if (ptTip.x + rcNewClient.Width() > rcScreen.right) + ptTip.x = rcScreen.right - rcNewClient.Width(); + if (ptTip.y < 0) + ptTip.y = 0; + else if (ptTip.y + rcNewClient.Height() > rcScreen.bottom) + ptTip.y = rcScreen.bottom - rcNewClient.Height(); + + // Position and show the tip + SetWindowPos(&CWnd::wndTop, ptTip.x, ptTip.y, rcNewClient.Width(), rcNewClient.Height(), + SWP_NOACTIVATE | SWP_SHOWWINDOW); +} + +void CBrowserToolTip::Hide() +{ + ShowWindow(SW_HIDE); +} diff --git a/mozilla/embedding/tests/mfcembed/BrowserToolTip.h b/mozilla/embedding/tests/mfcembed/BrowserToolTip.h new file mode 100644 index 00000000000..96483e649c1 --- /dev/null +++ b/mozilla/embedding/tests/mfcembed/BrowserToolTip.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Mozilla-sample-code 1.0 + * + * Copyright (c) 2002 Netscape Communications Corporation and + * other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this Mozilla sample software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Contributor(s): + * Adam Lock + * + * ***** END LICENSE BLOCK ***** */ + +#if !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_) +#define AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BrowserToolTip.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CBrowserToolTip window + +class CBrowserToolTip : public CWnd +{ +// Construction +public: + CBrowserToolTip(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBrowserToolTip) + protected: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + + CString m_szTipText; +// Implementation +public: + virtual ~CBrowserToolTip(); + + BOOL Create(CWnd *pParentWnd); + void SetTipText(const CString &szTipText); + void Show(CWnd *pOverWnd, long left, long top); + void Hide(); + + + // Generated message map functions +protected: + //{{AFX_MSG(CBrowserToolTip) + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.cpp b/mozilla/embedding/tests/mfcembed/BrowserView.cpp index 694abe045fc..b6ca1ef7f9e 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserView.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserView.cpp @@ -34,7 +34,7 @@ // // When the CBrowserFrm creates this View: // - CreateBrowser() is called in OnCreate() to create the -// mozilla embeddable browser +// mozilla embeddable browser // // OnSize() method handles the window resizes and calls the approriate // interface method to resize the embedded browser properly @@ -47,9 +47,9 @@ // Some important coding notes.... // // 1. Make sure we do not have the CS_HREDRAW|CS_VREDRAW in the call -// to AfxRegisterWndClass() inside of PreCreateWindow() below -// If these flags are present then you'll see screen flicker when -// you resize the frame window +// to AfxRegisterWndClass() inside of PreCreateWindow() below +// If these flags are present then you'll see screen flicker when +// you resize the frame window // // Next suggested file to look at : BrowserImpl.cpp // @@ -75,68 +75,68 @@ static char THIS_FILE[] = __FILE__; static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING); BEGIN_MESSAGE_MAP(CBrowserView, CWnd) - //{{AFX_MSG_MAP(CBrowserView) - ON_WM_CREATE() - ON_WM_DESTROY() - ON_WM_SIZE() + //{{AFX_MSG_MAP(CBrowserView) + ON_WM_CREATE() + ON_WM_DESTROY() + ON_WM_SIZE() - // UrlBar command handlers - ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar) - ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar) + // UrlBar command handlers + ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar) + ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar) - // Menu/Toolbar command handlers - ON_COMMAND(ID_FILE_OPEN, OnFileOpen) - ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) - ON_COMMAND(ID_VIEW_SOURCE, OnViewSource) - ON_COMMAND(ID_VIEW_INFO, OnViewInfo) - ON_COMMAND(ID_NAV_BACK, OnNavBack) - ON_COMMAND(ID_NAV_FORWARD, OnNavForward) - ON_COMMAND(ID_NAV_HOME, OnNavHome) - ON_COMMAND(ID_NAV_RELOAD, OnNavReload) - ON_COMMAND(ID_NAV_STOP, OnNavStop) - ON_COMMAND(ID_EDIT_CUT, OnCut) - ON_COMMAND(ID_EDIT_COPY, OnCopy) - ON_COMMAND(ID_EDIT_PASTE, OnPaste) + // Menu/Toolbar command handlers + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) + ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) + ON_COMMAND(ID_VIEW_SOURCE, OnViewSource) + ON_COMMAND(ID_VIEW_INFO, OnViewInfo) + ON_COMMAND(ID_NAV_BACK, OnNavBack) + ON_COMMAND(ID_NAV_FORWARD, OnNavForward) + ON_COMMAND(ID_NAV_HOME, OnNavHome) + ON_COMMAND(ID_NAV_RELOAD, OnNavReload) + ON_COMMAND(ID_NAV_STOP, OnNavStop) + ON_COMMAND(ID_EDIT_CUT, OnCut) + ON_COMMAND(ID_EDIT_COPY, OnCopy) + ON_COMMAND(ID_EDIT_PASTE, OnPaste) ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp) - ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll) - ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone) - ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow) - ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow) - ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation) - ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs) - ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs) - ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg) - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINTPREVIEW, OnFilePrintPreview) - ON_COMMAND(ID_FILE_PRINTSETUP, OnFilePrintSetup) - ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) - ON_COMMAND(ID_VIEW_FRAME_SOURCE, OnViewFrameSource) - ON_COMMAND(ID_OPEN_FRAME_IN_NEW_WINDOW, OnOpenFrameInNewWindow) + ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll) + ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone) + ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow) + ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow) + ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation) + ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs) + ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs) + ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg) + ON_COMMAND(ID_FILE_PRINT, OnFilePrint) + ON_COMMAND(ID_FILE_PRINTPREVIEW, OnFilePrintPreview) + ON_COMMAND(ID_FILE_PRINTSETUP, OnFilePrintSetup) + ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) + ON_COMMAND(ID_VIEW_FRAME_SOURCE, OnViewFrameSource) + ON_COMMAND(ID_OPEN_FRAME_IN_NEW_WINDOW, OnOpenFrameInNewWindow) - // Menu/Toolbar UI update handlers - ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack) - ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward) - ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop) - ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut) - ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy) - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINTSETUP, OnUpdatePrintSetup) - //}}AFX_MSG_MAP + // Menu/Toolbar UI update handlers + ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack) + ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward) + ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop) + ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut) + ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy) + ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste) + ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint) + ON_UPDATE_COMMAND_UI(ID_FILE_PRINTSETUP, OnUpdatePrintSetup) + //}}AFX_MSG_MAP END_MESSAGE_MAP() CBrowserView::CBrowserView() { - mWebBrowser = nsnull; - mBaseWindow = nsnull; - mWebNav = nsnull; + mWebBrowser = nsnull; + mBaseWindow = nsnull; + mWebNav = nsnull; - mpBrowserImpl = nsnull; - mpBrowserFrame = nsnull; - mpBrowserFrameGlue = nsnull; + mpBrowserImpl = nsnull; + mpBrowserFrame = nsnull; + mpBrowserFrameGlue = nsnull; - mbDocumentLoading = PR_FALSE; + mbDocumentLoading = PR_FALSE; m_pFindDlg = NULL; m_bUrlBarClipOp = FALSE; @@ -156,67 +156,67 @@ CBrowserView::~CBrowserView() // int CBrowserView::OnCreate(LPCREATESTRUCT lpCreateStruct) { - CreateBrowser(); + CreateBrowser(); - return 0; + return 0; } void CBrowserView::OnDestroy() { - DestroyBrowser(); + DestroyBrowser(); } // Create an instance of the Mozilla embeddable browser // HRESULT CBrowserView::CreateBrowser() -{ - // Create web shell - nsresult rv; - mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); - if(NS_FAILED(rv)) - return rv; +{ + // Create web shell + nsresult rv; + mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); + if(NS_FAILED(rv)) + return rv; - // Save off the nsIWebNavigation interface pointer - // in the mWebNav member variable which we'll use - // later for web page navigation - // - rv = NS_OK; - mWebNav = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; + // Save off the nsIWebNavigation interface pointer + // in the mWebNav member variable which we'll use + // later for web page navigation + // + rv = NS_OK; + mWebNav = do_QueryInterface(mWebBrowser, &rv); + if(NS_FAILED(rv)) + return rv; - // Create the CBrowserImpl object - this is the object - // which implements the interfaces which are required - // by an app embedding mozilla i.e. these are the interfaces - // thru' which the *embedded* browser communicates with the - // *embedding* app - // - // The CBrowserImpl object will be passed in to the - // SetContainerWindow() call below - // - // Also note that we're passing the BrowserFrameGlue pointer - // and also the mWebBrowser interface pointer via CBrowserImpl::Init() - // of CBrowserImpl object. - // These pointers will be saved by the CBrowserImpl object. - // The CBrowserImpl object uses the BrowserFrameGlue pointer to - // call the methods on that interface to update the status/progress bars - // etc. - mpBrowserImpl = new CBrowserImpl(); - if(mpBrowserImpl == nsnull) - return NS_ERROR_OUT_OF_MEMORY; + // Create the CBrowserImpl object - this is the object + // which implements the interfaces which are required + // by an app embedding mozilla i.e. these are the interfaces + // thru' which the *embedded* browser communicates with the + // *embedding* app + // + // The CBrowserImpl object will be passed in to the + // SetContainerWindow() call below + // + // Also note that we're passing the BrowserFrameGlue pointer + // and also the mWebBrowser interface pointer via CBrowserImpl::Init() + // of CBrowserImpl object. + // These pointers will be saved by the CBrowserImpl object. + // The CBrowserImpl object uses the BrowserFrameGlue pointer to + // call the methods on that interface to update the status/progress bars + // etc. + mpBrowserImpl = new CBrowserImpl(); + if(mpBrowserImpl == nsnull) + return NS_ERROR_OUT_OF_MEMORY; - // Pass along the mpBrowserFrameGlue pointer to the BrowserImpl object - // This is the interface thru' which the XP BrowserImpl code communicates - // with the platform specific code to update status bars etc. - mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser); - mpBrowserImpl->AddRef(); + // Pass along the mpBrowserFrameGlue pointer to the BrowserImpl object + // This is the interface thru' which the XP BrowserImpl code communicates + // with the platform specific code to update status bars etc. + mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser); + mpBrowserImpl->AddRef(); mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, mpBrowserImpl)); - rv = NS_OK; + rv = NS_OK; nsCOMPtr dsti = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; + if(NS_FAILED(rv)) + return rv; // If the browser window hosting chrome or content? dsti->SetItemType(((CMfcEmbedApp *)AfxGetApp())->m_bChrome ? @@ -225,71 +225,71 @@ HRESULT CBrowserView::CreateBrowser() // Create the real webbrowser window - // Note that we're passing the m_hWnd in the call below to InitWindow() - // (CBrowserView inherits the m_hWnd from CWnd) - // This m_hWnd will be used as the parent window by the embeddable browser - // - rv = NS_OK; - mBaseWindow = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; + // Note that we're passing the m_hWnd in the call below to InitWindow() + // (CBrowserView inherits the m_hWnd from CWnd) + // This m_hWnd will be used as the parent window by the embeddable browser + // + rv = NS_OK; + mBaseWindow = do_QueryInterface(mWebBrowser, &rv); + if(NS_FAILED(rv)) + return rv; - // Get the view's ClientRect which to be passed in to the InitWindow() - // call below - RECT rcLocation; - GetClientRect(&rcLocation); - if(IsRectEmpty(&rcLocation)) - { - rcLocation.bottom++; - rcLocation.top++; - } + // Get the view's ClientRect which to be passed in to the InitWindow() + // call below + RECT rcLocation; + GetClientRect(&rcLocation); + if(IsRectEmpty(&rcLocation)) + { + rcLocation.bottom++; + rcLocation.top++; + } - rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd), nsnull, - 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top); - rv = mBaseWindow->Create(); + rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd), nsnull, + 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top); + rv = mBaseWindow->Create(); // Register the BrowserImpl object to receive progress messages - // These callbacks will be used to update the status/progress bars + // These callbacks will be used to update the status/progress bars nsWeakPtr weakling( dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl)))); (void)mWebBrowser->AddWebBrowserListener(weakling, - NS_GET_IID(nsIWebProgressListener)); + NS_GET_IID(nsIWebProgressListener)); - // Finally, show the web browser window - mBaseWindow->SetVisibility(PR_TRUE); + // Finally, show the web browser window + mBaseWindow->SetVisibility(PR_TRUE); - return S_OK; + return S_OK; } HRESULT CBrowserView::DestroyBrowser() -{ - if(mBaseWindow) - { - mBaseWindow->Destroy(); +{ + if(mBaseWindow) + { + mBaseWindow->Destroy(); mBaseWindow = nsnull; - } + } - if(mpBrowserImpl) - { - mpBrowserImpl->Release(); - mpBrowserImpl = nsnull; - } + if(mpBrowserImpl) + { + mpBrowserImpl->Release(); + mpBrowserImpl = nsnull; + } - return NS_OK; + return NS_OK; } BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs) { - if (!CWnd::PreCreateWindow(cs)) - return FALSE; + if (!CWnd::PreCreateWindow(cs)) + return FALSE; - cs.dwExStyle |= WS_EX_CLIENTEDGE; - cs.style &= ~WS_BORDER; - cs.style |= WS_CLIPCHILDREN; - cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS, - ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); + cs.dwExStyle |= WS_EX_CLIENTEDGE; + cs.style &= ~WS_BORDER; + cs.style |= WS_CLIPCHILDREN; + cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS, + ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); - return TRUE; + return TRUE; } // Adjust the size of the embedded browser @@ -305,12 +305,12 @@ void CBrowserView::OnSize( UINT nType, int cx, int cy) // void CBrowserView::SetBrowserFrame(CBrowserFrame* pBrowserFrame) { - mpBrowserFrame = pBrowserFrame; + mpBrowserFrame = pBrowserFrame; } void CBrowserView::SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue) { - mpBrowserFrameGlue = pBrowserFrameGlue; + mpBrowserFrameGlue = pBrowserFrameGlue; } // A new URL was entered in the URL bar @@ -319,32 +319,32 @@ void CBrowserView::SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue) // void CBrowserView::OnNewUrlEnteredInUrlBar() { - // Get the currently entered URL - CString strUrl; - mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl); + // Get the currently entered URL + CString strUrl; + mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl); if(IsViewSourceUrl(strUrl)) OpenViewSourceWindow(strUrl.GetBuffer(0)); else - // Navigate to that URL - OpenURL(strUrl.GetBuffer(0)); + // Navigate to that URL + OpenURL(strUrl.GetBuffer(0)); - // Add what was just entered into the UrlBar - mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl); + // Add what was just entered into the UrlBar + mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl); } // A URL has been selected from the UrlBar's dropdown list // void CBrowserView::OnUrlSelectedInUrlBar() { - CString strUrl; - - mpBrowserFrame->m_wndUrlBar.GetSelectedURL(strUrl); + CString strUrl; + + mpBrowserFrame->m_wndUrlBar.GetSelectedURL(strUrl); if(IsViewSourceUrl(strUrl)) OpenViewSourceWindow(strUrl.GetBuffer(0)); else - OpenURL(strUrl.GetBuffer(0)); + OpenURL(strUrl.GetBuffer(0)); } BOOL CBrowserView::IsViewSourceUrl(CString& strUrl) @@ -354,18 +354,18 @@ BOOL CBrowserView::IsViewSourceUrl(CString& strUrl) BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl) { - // Create a new browser frame in which we'll show the document source - // Note that we're getting rid of the toolbars etc. by specifying - // the appropriate chromeFlags - PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS | - nsIWebBrowserChrome::CHROME_TITLEBAR | - nsIWebBrowserChrome::CHROME_WINDOW_RESIZE; - CBrowserFrame* pFrm = CreateNewBrowserFrame(chromeFlags); - if(!pFrm) - return FALSE; + // Create a new browser frame in which we'll show the document source + // Note that we're getting rid of the toolbars etc. by specifying + // the appropriate chromeFlags + PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS | + nsIWebBrowserChrome::CHROME_TITLEBAR | + nsIWebBrowserChrome::CHROME_WINDOW_RESIZE; + CBrowserFrame* pFrm = CreateNewBrowserFrame(chromeFlags); + if(!pFrm) + return FALSE; - // Finally, load this URI into the newly created frame - pFrm->m_wndBrowserView.OpenURL(pUrl); + // Finally, load this URI into the newly created frame + pFrm->m_wndBrowserView.OpenURL(pUrl); pFrm->BringWindowToTop(); @@ -374,21 +374,21 @@ BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl) void CBrowserView::OnViewSource() { - if(! mWebNav) - return; + if(! mWebNav) + return; - // Get the URI object whose source we want to view. + // Get the URI object whose source we want to view. nsresult rv = NS_OK; - nsCOMPtr currentURI; - rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI)); - if(NS_FAILED(rv) || !currentURI) - return; + nsCOMPtr currentURI; + rv = mWebNav->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; + // 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 nsCAutoString viewSrcUrl; @@ -400,57 +400,57 @@ void CBrowserView::OnViewSource() void CBrowserView::OnViewInfo() { - AfxMessageBox("To Be Done..."); + AfxMessageBox("To Be Done..."); } void CBrowserView::OnNavBack() { - if(mWebNav) - mWebNav->GoBack(); + if(mWebNav) + mWebNav->GoBack(); } void CBrowserView::OnUpdateNavBack(CCmdUI* pCmdUI) { - PRBool canGoBack = PR_FALSE; + PRBool canGoBack = PR_FALSE; if (mWebNav) mWebNav->GetCanGoBack(&canGoBack); - pCmdUI->Enable(canGoBack); + pCmdUI->Enable(canGoBack); } void CBrowserView::OnNavForward() { - if(mWebNav) - mWebNav->GoForward(); + if(mWebNav) + mWebNav->GoForward(); } void CBrowserView::OnUpdateNavForward(CCmdUI* pCmdUI) { - PRBool canGoFwd = PR_FALSE; + PRBool canGoFwd = PR_FALSE; if (mWebNav) mWebNav->GetCanGoForward(&canGoFwd); - pCmdUI->Enable(canGoFwd); + pCmdUI->Enable(canGoFwd); } void CBrowserView::OnNavHome() { // Get the currently configured HomePage URL CString strHomeURL; - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - if(pApp) + CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); + if(pApp) pApp->GetHomePage(strHomeURL); if(strHomeURL.GetLength() > 0) - OpenURL(strHomeURL); + OpenURL(strHomeURL); } void CBrowserView::OnNavReload() { - if(mWebNav) - mWebNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); + if(mWebNav) + mWebNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); } void CBrowserView::OnNavStop() @@ -461,7 +461,7 @@ void CBrowserView::OnNavStop() void CBrowserView::OnUpdateNavStop(CCmdUI* pCmdUI) { - pCmdUI->Enable(mbDocumentLoading); + pCmdUI->Enable(mbDocumentLoading); } void CBrowserView::OnCut() @@ -474,19 +474,19 @@ void CBrowserView::OnCut() } else { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if(clipCmds) - clipCmds->CutSelection(); + if(clipCmds) + clipCmds->CutSelection(); } } void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI) { - PRBool canCutSelection = PR_FALSE; + PRBool canCutSelection = PR_FALSE; - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if (clipCmds) + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + if (clipCmds) clipCmds->CanCutSelection(&canCutSelection); if(!canCutSelection) @@ -500,7 +500,7 @@ void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI) } } - pCmdUI->Enable(canCutSelection); + pCmdUI->Enable(canCutSelection); } void CBrowserView::OnCopy() @@ -514,18 +514,18 @@ void CBrowserView::OnCopy() else { // We need to operate on the web page content - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if(clipCmds) - clipCmds->CopySelection(); + if(clipCmds) + clipCmds->CopySelection(); } } void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI) { - PRBool canCopySelection = PR_FALSE; + PRBool canCopySelection = PR_FALSE; - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); if (clipCmds) clipCmds->CanCopySelection(&canCopySelection); @@ -540,7 +540,7 @@ void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI) } } - pCmdUI->Enable(canCopySelection); + pCmdUI->Enable(canCopySelection); } void CBrowserView::OnPaste() @@ -552,10 +552,10 @@ void CBrowserView::OnPaste() } else { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if(clipCmds) - clipCmds->Paste(); + if(clipCmds) + clipCmds->Paste(); } } @@ -567,9 +567,9 @@ void CBrowserView::OnUndoUrlBarEditOp() void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI) { - PRBool canPaste = PR_FALSE; + PRBool canPaste = PR_FALSE; - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); if (clipCmds) clipCmds->CanPaste(&canPaste); @@ -582,49 +582,49 @@ void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI) } } - pCmdUI->Enable(canPaste); + pCmdUI->Enable(canPaste); } void CBrowserView::OnSelectAll() { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if(clipCmds) - clipCmds->SelectAll(); + if(clipCmds) + clipCmds->SelectAll(); } void CBrowserView::OnSelectNone() { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); + nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if(clipCmds) - clipCmds->SelectNone(); + if(clipCmds) + clipCmds->SelectNone(); } void CBrowserView::OnFileOpen() { - char *lpszFilter = + char *lpszFilter = "HTML Files Only (*.htm;*.html)|*.htm;*.html|" "All Files (*.*)|*.*||"; - CFileDialog cf(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - CString strFullPath = cf.GetPathName(); // Will be like: c:\tmp\junk.htm - OpenURL(strFullPath); - } + CFileDialog cf(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + lpszFilter, this); + if(cf.DoModal() == IDOK) + { + CString strFullPath = cf.GetPathName(); // Will be like: c:\tmp\junk.htm + OpenURL(strFullPath); + } } void CBrowserView::GetBrowserWindowTitle(nsCString& title) { - nsXPIDLString idlStrTitle; - if(mBaseWindow) - mBaseWindow->GetTitle(getter_Copies(idlStrTitle)); + nsXPIDLString idlStrTitle; + if(mBaseWindow) + mBaseWindow->GetTitle(getter_Copies(idlStrTitle)); - title.AssignWithConversion(idlStrTitle); + title.AssignWithConversion(idlStrTitle); - // Sanitize the title of all illegal characters + // Sanitize the title of all illegal characters title.CompressWhitespace(); // Remove whitespace from the ends title.StripChars("\\*|:\"> persist(do_QueryInterface(mWebBrowser)); @@ -711,118 +711,118 @@ void CBrowserView::OpenURL(const PRUnichar* pUrl) } CBrowserFrame* CBrowserView::CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - PRBool bShowWindow) + PRInt32 x, PRInt32 y, + PRInt32 cx, PRInt32 cy, + PRBool bShowWindow) { - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - if(!pApp) - return NULL; + CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); + if(!pApp) + return NULL; - return pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, bShowWindow); + return pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, bShowWindow); } void CBrowserView::OpenURLInNewWindow(const PRUnichar* pUrl) { - if(!pUrl) - return; + if(!pUrl) + return; - CBrowserFrame* pFrm = CreateNewBrowserFrame(); - if(!pFrm) - return; + CBrowserFrame* pFrm = CreateNewBrowserFrame(); + if(!pFrm) + return; - // Load the URL into it... + // Load the URL into it... - // Note that OpenURL() is overloaded - one takes a "char *" - // and the other a "PRUniChar *". We're using the "PRUnichar *" - // version here + // Note that OpenURL() is overloaded - one takes a "char *" + // and the other a "PRUniChar *". We're using the "PRUnichar *" + // version here - pFrm->m_wndBrowserView.OpenURL(pUrl); + pFrm->m_wndBrowserView.OpenURL(pUrl); } void CBrowserView::LoadHomePage() { - OnNavHome(); + OnNavHome(); } void CBrowserView::OnCopyLinkLocation() { - if(! mCtxMenuLinkUrl.Length()) - return; + if(! mCtxMenuLinkUrl.Length()) + return; - if (! OpenClipboard()) - return; + if (! OpenClipboard()) + return; - HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, mCtxMenuLinkUrl.Length() + 1); - if(! hClipData) - return; + HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, mCtxMenuLinkUrl.Length() + 1); + if(! hClipData) + return; - char *pszClipData = (char*)::GlobalLock(hClipData); - if(!pszClipData) - return; + char *pszClipData = (char*)::GlobalLock(hClipData); + if(!pszClipData) + return; - mCtxMenuLinkUrl.ToCString(pszClipData, mCtxMenuLinkUrl.Length() + 1); + mCtxMenuLinkUrl.ToCString(pszClipData, mCtxMenuLinkUrl.Length() + 1); - GlobalUnlock(hClipData); + GlobalUnlock(hClipData); - EmptyClipboard(); - SetClipboardData(CF_TEXT, hClipData); - CloseClipboard(); + EmptyClipboard(); + SetClipboardData(CF_TEXT, hClipData); + CloseClipboard(); } void CBrowserView::OnOpenLinkInNewWindow() { - if(mCtxMenuLinkUrl.Length()) - OpenURLInNewWindow(mCtxMenuLinkUrl.get()); + if(mCtxMenuLinkUrl.Length()) + OpenURLInNewWindow(mCtxMenuLinkUrl.get()); } void CBrowserView::OnViewImageInNewWindow() { - if(mCtxMenuImgSrc.Length()) - OpenURLInNewWindow(mCtxMenuImgSrc.get()); + if(mCtxMenuImgSrc.Length()) + OpenURLInNewWindow(mCtxMenuImgSrc.get()); } void CBrowserView::OnSaveLinkAs() { - if(! mCtxMenuLinkUrl.Length()) - return; + if(! mCtxMenuLinkUrl.Length()) + return; - // Try to get the file name part from the URL - // To do that we first construct an obj which supports - // nsIRUI interface. Makes it easy to extract portions - // of a URL like the filename, scheme etc. + We'll also - // use it while saving this link to a file - nsresult rv = NS_OK; - nsCOMPtr linkURI; - rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl); - if (NS_FAILED(rv)) - return; + // Try to get the file name part from the URL + // To do that we first construct an obj which supports + // nsIRUI interface. Makes it easy to extract portions + // of a URL like the filename, scheme etc. + We'll also + // use it while saving this link to a file + nsresult rv = NS_OK; + nsCOMPtr linkURI; + rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl); + if (NS_FAILED(rv)) + return; - // Get the "path" portion (see nsIURI.h for more info - // on various parts of a URI) - nsCAutoString fileName; - linkURI->GetPath(fileName); + // Get the "path" portion (see nsIURI.h for more info + // on various parts of a URI) + nsCAutoString fileName; + linkURI->GetPath(fileName); - // The path may have the "/" char in it - strip those - fileName.StripChars("\\/"); + // The path may have the "/" char in it - strip those + fileName.StripChars("\\/"); - // Now, use this file name in a File Save As dlg... + // Now, use this file name in a File Save As dlg... - char *lpszFilter = + char *lpszFilter = "HTML Files (*.htm;*.html)|*.htm;*.html|" - "Text Files (*.txt)|*.txt|" - "All Files (*.*)|*.*||"; + "Text Files (*.txt)|*.txt|" + "All Files (*.*)|*.*||"; - const char *pFileName = fileName.Length() ? fileName.get() : NULL; + const char *pFileName = fileName.Length() ? fileName.get() : NULL; - CFileDialog cf(FALSE, "htm", pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - CString strFullPath = cf.GetPathName(); + CFileDialog cf(FALSE, "htm", pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + lpszFilter, this); + if(cf.DoModal() == IDOK) + { + CString strFullPath = cf.GetPathName(); nsCOMPtr persist(do_QueryInterface(mWebBrowser)); - if(persist) + if(persist) { nsCOMPtr file; NS_NewNativeLocalFile(nsDependentCString(strFullPath.GetBuffer(0)), TRUE, getter_AddRefs(file)); @@ -833,39 +833,39 @@ void CBrowserView::OnSaveLinkAs() void CBrowserView::OnSaveImageAs() { - if(! mCtxMenuImgSrc.Length()) - return; + if(! mCtxMenuImgSrc.Length()) + return; - // Try to get the file name part from the URL - // To do that we first construct an obj which supports - // nsIRUI interface. Makes it easy to extract portions - // of a URL like the filename, scheme etc. + We'll also - // use it while saving this link to a file - nsresult rv = NS_OK; - nsCOMPtr linkURI; - rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc); - if (NS_FAILED(rv)) - return; + // Try to get the file name part from the URL + // To do that we first construct an obj which supports + // nsIRUI interface. Makes it easy to extract portions + // of a URL like the filename, scheme etc. + We'll also + // use it while saving this link to a file + nsresult rv = NS_OK; + nsCOMPtr linkURI; + rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc); + if (NS_FAILED(rv)) + return; - // Get the "path" portion (see nsIURI.h for more info - // on various parts of a URI) - nsCAutoString path; - linkURI->GetPath(path); + // Get the "path" portion (see nsIURI.h for more info + // on various parts of a URI) + nsCAutoString path; + linkURI->GetPath(path); - // The path may have the "/" char in it - strip those - nsCAutoString fileName(path); - fileName.StripChars("\\/"); + // The path may have the "/" char in it - strip those + nsCAutoString fileName(path); + fileName.StripChars("\\/"); - // Now, use this file name in a File Save As dlg... + // Now, use this file name in a File Save As dlg... - char *lpszFilter = "All Files (*.*)|*.*||"; - const char *pFileName = fileName.Length() ? fileName.get() : NULL; + char *lpszFilter = "All Files (*.*)|*.*||"; + const char *pFileName = fileName.Length() ? fileName.get() : NULL; - CFileDialog cf(FALSE, NULL, pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - CString strFullPath = cf.GetPathName(); + CFileDialog cf(FALSE, NULL, pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + lpszFilter, this); + if(cf.DoModal() == IDOK) + { + CString strFullPath = cf.GetPathName(); nsCOMPtr persist(do_QueryInterface(mWebBrowser)); if(persist) @@ -879,80 +879,80 @@ void CBrowserView::OnSaveImageAs() void CBrowserView::OnShowFindDlg() { - // When the the user chooses the Find menu item - // and if a Find dlg. is already being shown - // just set focus to the existing dlg instead of - // creating a new one - if(m_pFindDlg) - { - m_pFindDlg->SetFocus(); - return; - } + // When the the user chooses the Find menu item + // and if a Find dlg. is already being shown + // just set focus to the existing dlg instead of + // creating a new one + if(m_pFindDlg) + { + m_pFindDlg->SetFocus(); + return; + } - CString csSearchStr; - PRBool bMatchCase = PR_FALSE; - PRBool bMatchWholeWord = PR_FALSE; - PRBool bWrapAround = PR_FALSE; - PRBool bSearchBackwards = PR_FALSE; + CString csSearchStr; + PRBool bMatchCase = PR_FALSE; + PRBool bMatchWholeWord = PR_FALSE; + PRBool bWrapAround = PR_FALSE; + PRBool bSearchBackwards = PR_FALSE; - // See if we can get and initialize the dlg box with - // the values/settings the user specified in the previous search - nsCOMPtr finder(do_GetInterface(mWebBrowser)); - if(finder) - { - nsXPIDLString stringBuf; - finder->GetSearchString(getter_Copies(stringBuf)); - csSearchStr = stringBuf.get(); + // See if we can get and initialize the dlg box with + // the values/settings the user specified in the previous search + nsCOMPtr finder(do_GetInterface(mWebBrowser)); + if(finder) + { + nsXPIDLString stringBuf; + finder->GetSearchString(getter_Copies(stringBuf)); + csSearchStr = stringBuf.get(); - finder->GetMatchCase(&bMatchCase); - finder->GetEntireWord(&bMatchWholeWord); - finder->GetWrapFind(&bWrapAround); - finder->GetFindBackwards(&bSearchBackwards); - } + finder->GetMatchCase(&bMatchCase); + finder->GetEntireWord(&bMatchWholeWord); + finder->GetWrapFind(&bWrapAround); + finder->GetFindBackwards(&bSearchBackwards); + } - m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord, - bWrapAround, bSearchBackwards, this); - m_pFindDlg->Create(TRUE, NULL, NULL, 0, this); + m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord, + bWrapAround, bSearchBackwards, this); + m_pFindDlg->Create(TRUE, NULL, NULL, 0, this); } // This will be called whenever the user pushes the Find // button in the Find dialog box // This method gets bound to the WM_FINDMSG windows msg via the // -// ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) +// ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) // -// message map entry. +// message map entry. // // WM_FINDMSG (which is registered towards the beginning of this file) // is the message via which the FindDialog communicates with this view // LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) { - nsCOMPtr finder(do_GetInterface(mWebBrowser)); - if(!finder) - return NULL; + nsCOMPtr finder(do_GetInterface(mWebBrowser)); + if(!finder) + return NULL; - // Get the pointer to the current Find dialog box - CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam); - if(!dlg) - return NULL; + // Get the pointer to the current Find dialog box + CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam); + if(!dlg) + return NULL; - // Has the user decided to terminate the dialog box? - if(dlg->IsTerminating()) - return NULL; + // Has the user decided to terminate the dialog box? + if(dlg->IsTerminating()) + return NULL; - if(dlg->FindNext()) - { - USES_CONVERSION; - finder->SetSearchString(T2W(dlg->GetFindString().GetBuffer(0))); - finder->SetMatchCase(dlg->MatchCase() ? PR_TRUE : PR_FALSE); - finder->SetEntireWord(dlg->MatchWholeWord() ? PR_TRUE : PR_FALSE); - finder->SetWrapFind(dlg->WrapAround() ? PR_TRUE : PR_FALSE); - finder->SetFindBackwards(dlg->SearchBackwards() ? PR_TRUE : PR_FALSE); + if(dlg->FindNext()) + { + USES_CONVERSION; + finder->SetSearchString(T2W(dlg->GetFindString().GetBuffer(0))); + finder->SetMatchCase(dlg->MatchCase() ? PR_TRUE : PR_FALSE); + finder->SetEntireWord(dlg->MatchWholeWord() ? PR_TRUE : PR_FALSE); + finder->SetWrapFind(dlg->WrapAround() ? PR_TRUE : PR_FALSE); + finder->SetFindBackwards(dlg->SearchBackwards() ? PR_TRUE : PR_FALSE); - PRBool didFind; - nsresult rv = finder->FindNext(&didFind); - + PRBool didFind; + nsresult rv = finder->FindNext(&didFind); + if(!didFind) { AfxMessageBox(IDS_SRCH_STR_NOT_FOUND); @@ -960,7 +960,7 @@ LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) } return (NS_SUCCEEDED(rv) && didFind); - } + } return 0; } @@ -968,8 +968,8 @@ LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) void CBrowserView::OnFilePrint() { nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { + if(print) + { if (!m_PrintSettings) { if (NS_FAILED(print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)))) { @@ -977,7 +977,7 @@ void CBrowserView::OnFilePrint() } } nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) + if(print) { print->Print(m_PrintSettings, nsnull); } @@ -988,8 +988,8 @@ void CBrowserView::OnFilePrint() void CBrowserView::OnFilePrintPreview() { nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { + if(print) + { if (!m_PrintSettings) { if (NS_FAILED(print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)))) { @@ -1027,7 +1027,7 @@ void CBrowserView::OnFilePrintPreview() void CBrowserView::OnFilePrintSetup() { nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) + if(print) { if (!m_PrintSettings) { @@ -1050,13 +1050,13 @@ void CBrowserView::OnFilePrintSetup() ///////////////////////////////////////////////////////////////////////////// void CBrowserView::OnUpdateFilePrint(CCmdUI* pCmdUI) { - pCmdUI->Enable(!m_bCurrentlyPrinting); + pCmdUI->Enable(!m_bCurrentlyPrinting); } ///////////////////////////////////////////////////////////////////////////// void CBrowserView::OnUpdatePrintSetup(CCmdUI* pCmdUI) { - pCmdUI->Enable(!m_bCurrentlyPrinting && !m_InPrintPreview); + pCmdUI->Enable(!m_bCurrentlyPrinting && !m_InPrintPreview); } @@ -1077,8 +1077,8 @@ void CBrowserView::UpdateBusyState(PRBool aBusy) if (mbDocumentLoading && !aBusy && m_InPrintPreview) { nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { + if(print) + { PRBool isDoingPP; print->GetDoingPrintPreview(&isDoingPP); if (!isDoingPP) @@ -1092,29 +1092,29 @@ void CBrowserView::UpdateBusyState(PRBool aBusy) } } } - mbDocumentLoading = aBusy; + mbDocumentLoading = aBusy; } void CBrowserView::SetCtxMenuLinkUrl(nsAutoString& strLinkUrl) { - mCtxMenuLinkUrl = strLinkUrl; + mCtxMenuLinkUrl = strLinkUrl; } void CBrowserView::SetCtxMenuImageSrc(nsAutoString& strImgSrc) { - mCtxMenuImgSrc = strImgSrc; + mCtxMenuImgSrc = strImgSrc; } void CBrowserView::SetCurrentFrameURL(nsAutoString& strCurrentFrameURL) { - mCtxMenuCurrentFrameURL = strCurrentFrameURL; + mCtxMenuCurrentFrameURL = strCurrentFrameURL; } void CBrowserView::Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { - nsCOMPtr focus(do_GetInterface(mWebBrowser)); - if(!focus) - return; + nsCOMPtr focus(do_GetInterface(mWebBrowser)); + if(!focus) + return; switch(nState) { case WA_ACTIVE: @@ -1188,6 +1188,6 @@ void CBrowserView::OnViewFrameSource() void CBrowserView::OnOpenFrameInNewWindow() { - if(mCtxMenuCurrentFrameURL.Length()) - OpenURLInNewWindow(mCtxMenuCurrentFrameURL.get()); + if(mCtxMenuCurrentFrameURL.Length()) + OpenURLInNewWindow(mCtxMenuCurrentFrameURL.get()); } diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.h b/mozilla/embedding/tests/mfcembed/BrowserView.h index 721c54dc60e..0a8a6749c31 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserView.h +++ b/mozilla/embedding/tests/mfcembed/BrowserView.h @@ -38,7 +38,7 @@ #define _BROWSERVIEW_H #if _MSC_VER > 1000 - #pragma once + #pragma once #endif #include "IBrowserFrameGlue.h" @@ -55,59 +55,59 @@ class CPrintProgressDialog; class CBrowserView : public CWnd { public: - CBrowserView(); - virtual ~CBrowserView(); + CBrowserView(); + virtual ~CBrowserView(); - // Some helper methods - HRESULT CreateBrowser(); - HRESULT DestroyBrowser(); - void OpenURL(const char* pUrl); - void OpenURL(const PRUnichar* pUrl); - CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, - PRInt32 x = -1, PRInt32 y = -1, - PRInt32 cx = -1, PRInt32 cy = -1, - PRBool bShowWindow = PR_TRUE); - void OpenURLInNewWindow(const PRUnichar* pUrl); - void LoadHomePage(); + // Some helper methods + HRESULT CreateBrowser(); + HRESULT DestroyBrowser(); + void OpenURL(const char* pUrl); + void OpenURL(const PRUnichar* pUrl); + CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, + PRInt32 x = -1, PRInt32 y = -1, + PRInt32 cx = -1, PRInt32 cy = -1, + PRBool bShowWindow = PR_TRUE); + void OpenURLInNewWindow(const PRUnichar* pUrl); + void LoadHomePage(); - void GetBrowserWindowTitle(nsCString& title); - - // Called by the CBrowserFrame after it creates the view - // Essentially a back pointer to the BrowserFrame - void SetBrowserFrame(CBrowserFrame* pBrowserFrame); - CBrowserFrame* mpBrowserFrame; + void GetBrowserWindowTitle(nsCString& title); + + // Called by the CBrowserFrame after it creates the view + // Essentially a back pointer to the BrowserFrame + void SetBrowserFrame(CBrowserFrame* pBrowserFrame); + CBrowserFrame* mpBrowserFrame; - // Called by the CBrowserFrame after it creates the view - // The view passes this on to the embedded Browser's Impl - // obj - void SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue); - PBROWSERFRAMEGLUE mpBrowserFrameGlue; + // Called by the CBrowserFrame after it creates the view + // The view passes this on to the embedded Browser's Impl + // obj + void SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue); + PBROWSERFRAMEGLUE mpBrowserFrameGlue; - // Pointer to the object which implements - // the inerfaces required by Mozilla embedders - // - CBrowserImpl* mpBrowserImpl; + // Pointer to the object which implements + // the inerfaces required by Mozilla embedders + // + CBrowserImpl* mpBrowserImpl; - // Mozilla interfaces - // - nsCOMPtr mWebBrowser; - nsCOMPtr mBaseWindow; - nsCOMPtr mWebNav; + // Mozilla interfaces + // + nsCOMPtr mWebBrowser; + nsCOMPtr mBaseWindow; + nsCOMPtr mWebNav; - void UpdateBusyState(PRBool aBusy); - PRBool mbDocumentLoading; + void UpdateBusyState(PRBool aBusy); + PRBool mbDocumentLoading; - void SetCtxMenuLinkUrl(nsAutoString& strLinkUrl); - nsAutoString mCtxMenuLinkUrl; + void SetCtxMenuLinkUrl(nsAutoString& strLinkUrl); + nsAutoString mCtxMenuLinkUrl; - void SetCtxMenuImageSrc(nsAutoString& strImgSrc); - nsAutoString mCtxMenuImgSrc; + void SetCtxMenuImageSrc(nsAutoString& strImgSrc); + nsAutoString mCtxMenuImgSrc; - void SetCurrentFrameURL(nsAutoString& strCurrentFrameURL); - nsString mCtxMenuCurrentFrameURL; + void SetCurrentFrameURL(nsAutoString& strCurrentFrameURL); + nsString mCtxMenuCurrentFrameURL; - inline void ClearFindDialog() { m_pFindDlg = NULL; } - CFindDialog* m_pFindDlg; + inline void ClearFindDialog() { m_pFindDlg = NULL; } + CFindDialog* m_pFindDlg; CPrintProgressDialog* m_pPrintProgressDlg; // When set to TRUE... // indicates that the clipboard operation needs to be @@ -134,70 +134,70 @@ public: BOOL ViewContentContainsFrames(); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBrowserView) - protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBrowserView) + protected: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL - // Generated message map functions + // Generated message map functions protected: - nsCOMPtr m_PrintSettings; + nsCOMPtr m_PrintSettings; BOOL m_InPrintPreview; - //{{AFX_MSG(CBrowserView) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnDestroy(); - afx_msg void OnSize( UINT, int, int ); - // UrlBar command handlers - // - afx_msg void OnUrlSelectedInUrlBar(); - afx_msg void OnNewUrlEnteredInUrlBar(); + //{{AFX_MSG(CBrowserView) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnDestroy(); + afx_msg void OnSize( UINT, int, int ); + // UrlBar command handlers + // + afx_msg void OnUrlSelectedInUrlBar(); + afx_msg void OnNewUrlEnteredInUrlBar(); - // ToolBar/Menu command handlers - // - afx_msg void OnFileOpen(); - afx_msg void OnFileSaveAs(); - afx_msg void OnViewSource(); - afx_msg void OnViewInfo(); - afx_msg void OnNavBack(); - afx_msg void OnNavForward(); - afx_msg void OnNavHome(); - afx_msg void OnNavReload(); - afx_msg void OnNavStop(); - afx_msg void OnCut(); - afx_msg void OnCopy(); - afx_msg void OnPaste(); + // ToolBar/Menu command handlers + // + afx_msg void OnFileOpen(); + afx_msg void OnFileSaveAs(); + afx_msg void OnViewSource(); + afx_msg void OnViewInfo(); + afx_msg void OnNavBack(); + afx_msg void OnNavForward(); + afx_msg void OnNavHome(); + afx_msg void OnNavReload(); + afx_msg void OnNavStop(); + afx_msg void OnCut(); + afx_msg void OnCopy(); + afx_msg void OnPaste(); afx_msg void OnUndoUrlBarEditOp(); - afx_msg void OnSelectAll(); - afx_msg void OnSelectNone(); - afx_msg void OnCopyLinkLocation(); - afx_msg void OnOpenLinkInNewWindow(); - afx_msg void OnViewImageInNewWindow(); - afx_msg void OnSaveLinkAs(); - afx_msg void OnSaveImageAs(); - afx_msg void OnShowFindDlg(); - afx_msg void OnFilePrint(); - afx_msg void OnFilePrintPreview(); - afx_msg void OnFilePrintSetup(); - afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI); - afx_msg void OnUpdatePrintSetup(CCmdUI* pCmdUI); - afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam); - afx_msg void OnViewFrameSource(); - afx_msg void OnOpenFrameInNewWindow(); + afx_msg void OnSelectAll(); + afx_msg void OnSelectNone(); + afx_msg void OnCopyLinkLocation(); + afx_msg void OnOpenLinkInNewWindow(); + afx_msg void OnViewImageInNewWindow(); + afx_msg void OnSaveLinkAs(); + afx_msg void OnSaveImageAs(); + afx_msg void OnShowFindDlg(); + afx_msg void OnFilePrint(); + afx_msg void OnFilePrintPreview(); + afx_msg void OnFilePrintSetup(); + afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI); + afx_msg void OnUpdatePrintSetup(CCmdUI* pCmdUI); + afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam); + afx_msg void OnViewFrameSource(); + afx_msg void OnOpenFrameInNewWindow(); - // Handlers to keep the toolbar/menu items up to date - // - afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI); - afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI); - afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI); - afx_msg void OnUpdateCut(CCmdUI* pCmdUI); - afx_msg void OnUpdateCopy(CCmdUI* pCmdUI); - afx_msg void OnUpdatePaste(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Handlers to keep the toolbar/menu items up to date + // + afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI); + afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI); + afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI); + afx_msg void OnUpdateCut(CCmdUI* pCmdUI); + afx_msg void OnUpdateCopy(CCmdUI* pCmdUI); + afx_msg void OnUpdatePaste(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; #endif //_BROWSERVIEW_H \ No newline at end of file diff --git a/mozilla/embedding/tests/mfcembed/Dialogs.cpp b/mozilla/embedding/tests/mfcembed/Dialogs.cpp index b21dd97b663..3e1b31fdc42 100644 --- a/mozilla/embedding/tests/mfcembed/Dialogs.cpp +++ b/mozilla/embedding/tests/mfcembed/Dialogs.cpp @@ -47,77 +47,77 @@ // //--------------------------------------------------------------------------// -// CFindDialog Stuff +// CFindDialog Stuff //--------------------------------------------------------------------------// CFindDialog::CFindDialog(CString& csSearchStr, PRBool bMatchCase, - PRBool bMatchWholeWord, PRBool bWrapAround, - PRBool bSearchBackwards, CBrowserView* pOwner) - : CFindReplaceDialog() + PRBool bMatchWholeWord, PRBool bWrapAround, + PRBool bSearchBackwards, CBrowserView* pOwner) + : CFindReplaceDialog() { - // Save these initial settings off in member vars - // We'll use these to initialize the controls - // in InitDialog() - m_csSearchStr = csSearchStr; - m_bMatchCase = bMatchCase; - m_bMatchWholeWord = bMatchWholeWord; - m_bWrapAround = bWrapAround; - m_bSearchBackwards = bSearchBackwards; - m_pOwner = pOwner; + // Save these initial settings off in member vars + // We'll use these to initialize the controls + // in InitDialog() + m_csSearchStr = csSearchStr; + m_bMatchCase = bMatchCase; + m_bMatchWholeWord = bMatchWholeWord; + m_bWrapAround = bWrapAround; + m_bSearchBackwards = bSearchBackwards; + m_pOwner = pOwner; - // Set up to load our customized Find dialog template - // rather than the default one MFC provides - m_fr.Flags |= FR_ENABLETEMPLATE; - m_fr.hInstance = AfxGetInstanceHandle(); - m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG); + // Set up to load our customized Find dialog template + // rather than the default one MFC provides + m_fr.Flags |= FR_ENABLETEMPLATE; + m_fr.hInstance = AfxGetInstanceHandle(); + m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG); } BOOL CFindDialog::OnInitDialog() { - CFindReplaceDialog::OnInitDialog(); + CFindReplaceDialog::OnInitDialog(); - CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT); - if(pEdit) - pEdit->SetWindowText(m_csSearchStr); + CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT); + if(pEdit) + pEdit->SetWindowText(m_csSearchStr); - CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE); - if(pChk) - pChk->SetCheck(m_bMatchCase); + CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE); + if(pChk) + pChk->SetCheck(m_bMatchCase); - pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD); - if(pChk) - pChk->SetCheck(m_bMatchWholeWord); + pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD); + if(pChk) + pChk->SetCheck(m_bMatchWholeWord); - pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); - if(pChk) - pChk->SetCheck(m_bWrapAround); + pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); + if(pChk) + pChk->SetCheck(m_bWrapAround); - pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); - if(pChk) - pChk->SetCheck(m_bSearchBackwards); + pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); + if(pChk) + pChk->SetCheck(m_bSearchBackwards); - return TRUE; + return TRUE; } -void CFindDialog::PostNcDestroy() +void CFindDialog::PostNcDestroy() { - // Let the owner know we're gone - if(m_pOwner != NULL) - m_pOwner->ClearFindDialog(); + // Let the owner know we're gone + if(m_pOwner != NULL) + m_pOwner->ClearFindDialog(); - CFindReplaceDialog::PostNcDestroy(); + CFindReplaceDialog::PostNcDestroy(); } BOOL CFindDialog::WrapAround() { - CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); + CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); - return pChk ? pChk->GetCheck() : FALSE; + return pChk ? pChk->GetCheck() : FALSE; } BOOL CFindDialog::SearchBackwards() { - CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); + CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); - return pChk ? pChk->GetCheck() : FALSE; + return pChk ? pChk->GetCheck() : FALSE; } diff --git a/mozilla/embedding/tests/mfcembed/Dialogs.h b/mozilla/embedding/tests/mfcembed/Dialogs.h index ec2ab0aeb67..6f9030687cf 100644 --- a/mozilla/embedding/tests/mfcembed/Dialogs.h +++ b/mozilla/embedding/tests/mfcembed/Dialogs.h @@ -44,26 +44,26 @@ class CBrowserView; -class CFindDialog : public CFindReplaceDialog +class CFindDialog : public CFindReplaceDialog { public: - CFindDialog(CString& csSearchStr, PRBool bMatchCase, - PRBool bMatchWholeWord, PRBool bWrapAround, - PRBool bSearchBackwards, CBrowserView* pOwner); - BOOL WrapAround(); - BOOL SearchBackwards(); + CFindDialog(CString& csSearchStr, PRBool bMatchCase, + PRBool bMatchWholeWord, PRBool bWrapAround, + PRBool bSearchBackwards, CBrowserView* pOwner); + BOOL WrapAround(); + BOOL SearchBackwards(); private: - CString m_csSearchStr; - PRBool m_bMatchCase; - PRBool m_bMatchWholeWord; - PRBool m_bWrapAround; - PRBool m_bSearchBackwards; - CBrowserView* m_pOwner; + CString m_csSearchStr; + PRBool m_bMatchCase; + PRBool m_bMatchWholeWord; + PRBool m_bWrapAround; + PRBool m_bSearchBackwards; + CBrowserView* m_pOwner; protected: - virtual BOOL OnInitDialog(); - virtual void PostNcDestroy(); + virtual BOOL OnInitDialog(); + virtual void PostNcDestroy(); }; #endif //_DIALOG_H_ diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp b/mozilla/embedding/tests/mfcembed/EditorFrm.cpp index 62ef6205589..b5d9b26c344 100644 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp +++ b/mozilla/embedding/tests/mfcembed/EditorFrm.cpp @@ -65,9 +65,9 @@ #define COLOR_BLACK "#000000" //fonts -#define FONT_ARIAL "Helvetica, Arial, sans-serif" -#define FONT_TIMES "Times New Roman, Times, serif" -#define FONT_COURIER "Courier New, Courier, monospace" +#define FONT_ARIAL "Helvetica, Arial, sans-serif" +#define FONT_TIMES "Times New Roman, Times, serif" +#define FONT_COURIER "Courier New, Courier, monospace" //align #define ALIGN_LEFT "left" @@ -76,47 +76,47 @@ //value -#define STATE_EMPTY "" +#define STATE_EMPTY "" IMPLEMENT_DYNAMIC(CEditorFrame, CBrowserFrame) BEGIN_MESSAGE_MAP(CEditorFrame, CBrowserFrame) - //{{AFX_MSG_MAP(CEditorFrame) + //{{AFX_MSG_MAP(CEditorFrame) ON_COMMAND(ID_BOLD, OnBold) ON_UPDATE_COMMAND_UI(ID_BOLD, OnUpdateBold) ON_COMMAND(ID_ITALICS, OnItalics) ON_UPDATE_COMMAND_UI(ID_ITALICS, OnUpdateItalics) ON_COMMAND(ID_UNDERLINE, OnUnderline) ON_UPDATE_COMMAND_UI(ID_UNDERLINE, OnUpdateUnderline) - ON_COMMAND(ID_INDENT, OnIndent) - ON_UPDATE_COMMAND_UI(ID_INDENT, OnUpdateIndent) - ON_COMMAND(ID_OUTDENT, OnOutdent) - ON_UPDATE_COMMAND_UI(ID_OUTDENT, OnUpdateOutdent) - ON_COMMAND(ID_FONTRED, OnFontred) - ON_UPDATE_COMMAND_UI(ID_FONTRED, OnUpdateFontred) - ON_COMMAND(ID_FONTBLACK, OnFontblack) - ON_UPDATE_COMMAND_UI(ID_FONTBLACK, OnUpdateFontblack) - ON_COMMAND(ID_BGCOLOR, OnBgcolor) - ON_UPDATE_COMMAND_UI(ID_BGCOLOR, OnUpdateBgcolor) - ON_COMMAND(ID_NOBGCOLOR, OnNobgcolor) - ON_UPDATE_COMMAND_UI(ID_NOBGCOLOR, OnUpdateNobgcolor) - ON_COMMAND(ID_FONTSIZEINCREASE, OnFontsizeincrease) - ON_COMMAND(ID_FONTSIZEDECREASE, OnFontsizedecrease) - ON_COMMAND(ID_ARIAL, OnArial) - ON_COMMAND(ID_TIMES, OnTimes) - ON_COMMAND(ID_COURIER, OnCourier) - ON_COMMAND(ID_ALIGNLEFT, OnAlignleft) - ON_UPDATE_COMMAND_UI(ID_ALIGNLEFT, OnUpdateAlignleft) - ON_COMMAND(ID_ALIGNRIGHT, OnAlignright) - ON_UPDATE_COMMAND_UI(ID_ALIGNRIGHT, OnUpdateAlignright) - ON_COMMAND(ID_ALIGNCENTER, OnAligncenter) - ON_UPDATE_COMMAND_UI(ID_ALIGNCENTER, OnUpdateAligncenter) - ON_COMMAND(ID_INSERTLINK, OnInsertlink) - ON_COMMAND(ID_EDITOR_UNDO, OnEditUndo) - ON_COMMAND(ID_EDITOR_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDITOR_REDO, OnUpdateEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDITOR_UNDO, OnUpdateEditUndo) - //}}AFX_MSG_MAP + ON_COMMAND(ID_INDENT, OnIndent) + ON_UPDATE_COMMAND_UI(ID_INDENT, OnUpdateIndent) + ON_COMMAND(ID_OUTDENT, OnOutdent) + ON_UPDATE_COMMAND_UI(ID_OUTDENT, OnUpdateOutdent) + ON_COMMAND(ID_FONTRED, OnFontred) + ON_UPDATE_COMMAND_UI(ID_FONTRED, OnUpdateFontred) + ON_COMMAND(ID_FONTBLACK, OnFontblack) + ON_UPDATE_COMMAND_UI(ID_FONTBLACK, OnUpdateFontblack) + ON_COMMAND(ID_BGCOLOR, OnBgcolor) + ON_UPDATE_COMMAND_UI(ID_BGCOLOR, OnUpdateBgcolor) + ON_COMMAND(ID_NOBGCOLOR, OnNobgcolor) + ON_UPDATE_COMMAND_UI(ID_NOBGCOLOR, OnUpdateNobgcolor) + ON_COMMAND(ID_FONTSIZEINCREASE, OnFontsizeincrease) + ON_COMMAND(ID_FONTSIZEDECREASE, OnFontsizedecrease) + ON_COMMAND(ID_ARIAL, OnArial) + ON_COMMAND(ID_TIMES, OnTimes) + ON_COMMAND(ID_COURIER, OnCourier) + ON_COMMAND(ID_ALIGNLEFT, OnAlignleft) + ON_UPDATE_COMMAND_UI(ID_ALIGNLEFT, OnUpdateAlignleft) + ON_COMMAND(ID_ALIGNRIGHT, OnAlignright) + ON_UPDATE_COMMAND_UI(ID_ALIGNRIGHT, OnUpdateAlignright) + ON_COMMAND(ID_ALIGNCENTER, OnAligncenter) + ON_UPDATE_COMMAND_UI(ID_ALIGNCENTER, OnUpdateAligncenter) + ON_COMMAND(ID_INSERTLINK, OnInsertlink) + ON_COMMAND(ID_EDITOR_UNDO, OnEditUndo) + ON_COMMAND(ID_EDITOR_REDO, OnEditRedo) + ON_UPDATE_COMMAND_UI(ID_EDITOR_REDO, OnUpdateEditRedo) + ON_UPDATE_COMMAND_UI(ID_EDITOR_UNDO, OnUpdateEditUndo) + //}}AFX_MSG_MAP END_MESSAGE_MAP() CEditorFrame::CEditorFrame(PRUint32 chromeMask) @@ -179,13 +179,13 @@ CEditorFrame::MakeCommandParams(const char *aCommand,nsICommandParams **aParams) { nsresult rv; nsCOMPtr params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); - if (NS_FAILED(rv)) - return rv; - if (!params) - return NS_ERROR_FAILURE; - *aParams = params; - NS_ADDREF(*aParams); - return rv; + if (NS_FAILED(rv)) + return rv; + if (!params) + return NS_ERROR_FAILURE; + *aParams = params; + NS_ADDREF(*aParams); + return rv; } @@ -205,11 +205,11 @@ CEditorFrame::ExecuteStyleCommand(const char *aCommand) // void CEditorFrame::UpdateStyleToolBarBtn(const char *aCommand, CCmdUI* pCmdUI) { - nsCOMPtr params; + nsCOMPtr params; nsresult rv; - rv = MakeCommandParams(aCommand,getter_AddRefs(params)); - if (NS_FAILED(rv) || !params) - return; + rv = MakeCommandParams(aCommand,getter_AddRefs(params)); + if (NS_FAILED(rv) || !params) + return; rv = GetCommandState(aCommand,params); if (NS_SUCCEEDED(rv)) { @@ -292,26 +292,26 @@ CEditorFrame::ExecuteNoParam(const char *aCommand) void CEditorFrame::OnIndent() { - // TODO: Add your command handler code here - ExecuteNoParam(INDENT_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(INDENT_COMMAND); } void CEditorFrame::OnUpdateIndent(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } void CEditorFrame::OnOutdent() { - // TODO: Add your command handler code here - ExecuteNoParam(OUTDENT_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(OUTDENT_COMMAND); } void CEditorFrame::OnUpdateOutdent(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } NS_METHOD @@ -352,94 +352,94 @@ CEditorFrame::GetAttributeParamValue(const char *aCommand, nsCString &aValue) void CEditorFrame::OnFontred() { - // TODO: Add your command handler code here - ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_RED); + // TODO: Add your command handler code here + ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_RED); } void CEditorFrame::OnUpdateFontred(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } void CEditorFrame::OnFontblack() { - // TODO: Add your command handler code here - ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_BLACK); + // TODO: Add your command handler code here + ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_BLACK); } void CEditorFrame::OnUpdateFontblack(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } void CEditorFrame::OnBgcolor() { - // TODO: Add your command handler code here - ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,COLOR_RED); - + // TODO: Add your command handler code here + ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,COLOR_RED); + } void CEditorFrame::OnUpdateBgcolor(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } void CEditorFrame::OnNobgcolor() { - // TODO: Add your command handler code here - ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,STATE_EMPTY); + // TODO: Add your command handler code here + ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,STATE_EMPTY); } void CEditorFrame::OnUpdateNobgcolor(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - + // TODO: Add your command update UI handler code here + } void CEditorFrame::OnFontsizeincrease() { - // TODO: Add your command handler code here - ExecuteNoParam(INCREASEFONT_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(INCREASEFONT_COMMAND); } void CEditorFrame::OnFontsizedecrease() { - // TODO: Add your command handler code here - ExecuteNoParam(DECREASEFONT_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(DECREASEFONT_COMMAND); } void CEditorFrame::OnArial() { - // TODO: Add your command handler code here - ExecuteAttribParam(FONTFACE_COMMAND,FONT_ARIAL); + // TODO: Add your command handler code here + ExecuteAttribParam(FONTFACE_COMMAND,FONT_ARIAL); } void CEditorFrame::OnTimes() { - // TODO: Add your command handler code here - ExecuteAttribParam(FONTFACE_COMMAND,FONT_TIMES); + // TODO: Add your command handler code here + ExecuteAttribParam(FONTFACE_COMMAND,FONT_TIMES); } void CEditorFrame::OnCourier() { - // TODO: Add your command handler code here - ExecuteAttribParam(FONTFACE_COMMAND,FONT_COURIER); + // TODO: Add your command handler code here + ExecuteAttribParam(FONTFACE_COMMAND,FONT_COURIER); } void CEditorFrame::OnAlignleft() { - // TODO: Add your command handler code here - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_LEFT); - + // TODO: Add your command handler code here + ExecuteAttribParam(ALIGN_COMMAND,ALIGN_LEFT); + } void CEditorFrame::OnUpdateAlignleft(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here nsCAutoString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); @@ -454,15 +454,15 @@ void CEditorFrame::OnUpdateAlignleft(CCmdUI* pCmdUI) void CEditorFrame::OnAlignright() { - // TODO: Add your command handler code here - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_RIGHT); - + // TODO: Add your command handler code here + ExecuteAttribParam(ALIGN_COMMAND,ALIGN_RIGHT); + } void CEditorFrame::OnUpdateAlignright(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here nsCAutoString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); if (NS_SUCCEEDED(rv)) @@ -476,15 +476,15 @@ void CEditorFrame::OnUpdateAlignright(CCmdUI* pCmdUI) void CEditorFrame::OnAligncenter() { - // TODO: Add your command handler code here - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_CENTER); - + // TODO: Add your command handler code here + ExecuteAttribParam(ALIGN_COMMAND,ALIGN_CENTER); + } void CEditorFrame::OnUpdateAligncenter(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here - // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here nsCAutoString tValue; nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); if (NS_SUCCEEDED(rv)) @@ -498,25 +498,25 @@ void CEditorFrame::OnUpdateAligncenter(CCmdUI* pCmdUI) void CEditorFrame::OnInsertlink() { - // TODO: Add your command handler code here - + // TODO: Add your command handler code here + } void CEditorFrame::OnEditUndo() { - // TODO: Add your command handler code here - ExecuteNoParam(UNDO_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(UNDO_COMMAND); } void CEditorFrame::OnEditRedo() { - // TODO: Add your command handler code here - ExecuteNoParam(REDO_COMMAND); + // TODO: Add your command handler code here + ExecuteNoParam(REDO_COMMAND); } void CEditorFrame::OnUpdateEditRedo(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here nsresult rv; nsCOMPtr params; rv = MakeCommandParams(REDO_COMMAND,getter_AddRefs(params)); @@ -535,12 +535,12 @@ void CEditorFrame::OnUpdateEditRedo(CCmdUI* pCmdUI) return; } } - pCmdUI->Enable(FALSE); + pCmdUI->Enable(FALSE); } void CEditorFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) { - // TODO: Add your command update UI handler code here + // TODO: Add your command update UI handler code here nsresult rv; nsCOMPtr params; rv = MakeCommandParams(UNDO_COMMAND,getter_AddRefs(params)); @@ -559,5 +559,5 @@ void CEditorFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) return; } } - pCmdUI->Enable(FALSE); + pCmdUI->Enable(FALSE); } diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.h b/mozilla/embedding/tests/mfcembed/EditorFrm.h index aca30bda070..4c267f07075 100644 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.h +++ b/mozilla/embedding/tests/mfcembed/EditorFrm.h @@ -38,9 +38,9 @@ #include "nsICommandManager.h" #include "nsIScriptGlobalObject.h" #include "nsISimpleEnumerator.h" - + class CEditorFrame : public CBrowserFrame -{ +{ public: CEditorFrame(PRUint32 chromeMask); virtual ~CEditorFrame(); @@ -57,42 +57,42 @@ public: // Generated message map functions protected: - //{{AFX_MSG(CEditorFrame) + //{{AFX_MSG(CEditorFrame) afx_msg void OnBold(); afx_msg void OnUpdateBold(CCmdUI* pCmdUI); afx_msg void OnItalics(); afx_msg void OnUpdateItalics(CCmdUI* pCmdUI); afx_msg void OnUnderline(); afx_msg void OnUpdateUnderline(CCmdUI* pCmdUI); - afx_msg void OnIndent(); - afx_msg void OnUpdateIndent(CCmdUI* pCmdUI); - afx_msg void OnOutdent(); - afx_msg void OnUpdateOutdent(CCmdUI* pCmdUI); - afx_msg void OnFontred(); - afx_msg void OnUpdateFontred(CCmdUI* pCmdUI); - afx_msg void OnFontblack(); - afx_msg void OnUpdateFontblack(CCmdUI* pCmdUI); - afx_msg void OnBgcolor(); - afx_msg void OnUpdateBgcolor(CCmdUI* pCmdUI); - afx_msg void OnNobgcolor(); - afx_msg void OnUpdateNobgcolor(CCmdUI* pCmdUI); - afx_msg void OnFontsizeincrease(); - afx_msg void OnFontsizedecrease(); - afx_msg void OnArial(); - afx_msg void OnTimes(); - afx_msg void OnCourier(); - afx_msg void OnAlignleft(); - afx_msg void OnUpdateAlignleft(CCmdUI* pCmdUI); - afx_msg void OnAlignright(); - afx_msg void OnUpdateAlignright(CCmdUI* pCmdUI); - afx_msg void OnAligncenter(); - afx_msg void OnUpdateAligncenter(CCmdUI* pCmdUI); - afx_msg void OnInsertlink(); - afx_msg void OnEditUndo(); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - //}}AFX_MSG + afx_msg void OnIndent(); + afx_msg void OnUpdateIndent(CCmdUI* pCmdUI); + afx_msg void OnOutdent(); + afx_msg void OnUpdateOutdent(CCmdUI* pCmdUI); + afx_msg void OnFontred(); + afx_msg void OnUpdateFontred(CCmdUI* pCmdUI); + afx_msg void OnFontblack(); + afx_msg void OnUpdateFontblack(CCmdUI* pCmdUI); + afx_msg void OnBgcolor(); + afx_msg void OnUpdateBgcolor(CCmdUI* pCmdUI); + afx_msg void OnNobgcolor(); + afx_msg void OnUpdateNobgcolor(CCmdUI* pCmdUI); + afx_msg void OnFontsizeincrease(); + afx_msg void OnFontsizedecrease(); + afx_msg void OnArial(); + afx_msg void OnTimes(); + afx_msg void OnCourier(); + afx_msg void OnAlignleft(); + afx_msg void OnUpdateAlignleft(CCmdUI* pCmdUI); + afx_msg void OnAlignright(); + afx_msg void OnUpdateAlignright(CCmdUI* pCmdUI); + afx_msg void OnAligncenter(); + afx_msg void OnUpdateAligncenter(CCmdUI* pCmdUI); + afx_msg void OnInsertlink(); + afx_msg void OnEditUndo(); + afx_msg void OnEditRedo(); + afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); + afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); + //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h b/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h index 451d3b8f60d..4f45dd29996 100644 --- a/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h +++ b/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h @@ -45,62 +45,68 @@ #define _IBROWSERFRAMEGLUE_H struct IBrowserFrameGlue { - // Progress Related Methods - virtual void UpdateStatusBarText(const PRUnichar *aMessage) = 0; - virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) = 0; - virtual void UpdateBusyState(PRBool aBusy) = 0; - virtual void UpdateCurrentURI(nsIURI *aLocation) = 0; - virtual void UpdateSecurityStatus(PRInt32 aState) = 0; + // Progress Related Methods + virtual void UpdateStatusBarText(const PRUnichar *aMessage) = 0; + virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) = 0; + virtual void UpdateBusyState(PRBool aBusy) = 0; + virtual void UpdateCurrentURI(nsIURI *aLocation) = 0; + virtual void UpdateSecurityStatus(PRInt32 aState) = 0; - // BrowserFrame Related Methods - virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - nsIWebBrowser ** aWebBrowser) = 0; - virtual void DestroyBrowserFrame() = 0; - virtual void GetBrowserFrameTitle(PRUnichar **aTitle) = 0; - virtual void SetBrowserFrameTitle(const PRUnichar *aTitle) = 0; - virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY) = 0; - virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY) = 0; - virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY) = 0; - virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY) = 0; - virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) = 0; - virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint) = 0; - virtual void ShowBrowserFrame(PRBool aShow) = 0; - virtual void SetFocus() = 0; - virtual void FocusAvailable(PRBool *aFocusAvail) = 0; - virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0; + // BrowserFrame Related Methods + virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, + PRInt32 x, PRInt32 y, + PRInt32 cx, PRInt32 cy, + nsIWebBrowser ** aWebBrowser) = 0; + virtual void DestroyBrowserFrame() = 0; + virtual void GetBrowserFrameTitle(PRUnichar **aTitle) = 0; + virtual void SetBrowserFrameTitle(const PRUnichar *aTitle) = 0; + virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY) = 0; + virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY) = 0; + virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY) = 0; + virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY) = 0; + virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) = 0; + virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint) = 0; + virtual void ShowBrowserFrame(PRBool aShow) = 0; + virtual void SetFocus() = 0; + virtual void FocusAvailable(PRBool *aFocusAvail) = 0; + virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0; - // ContextMenu Related Methods - virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) = 0; + // ContextMenu Related Methods + virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) = 0; - virtual HWND GetBrowserFrameNativeWnd() = 0; + // Tooltip methods + virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) = 0; + virtual void HideTooltip() = 0; + + virtual HWND GetBrowserFrameNativeWnd() = 0; }; -#define NS_DECL_BROWSERFRAMEGLUE \ - public: \ - virtual void UpdateStatusBarText(const PRUnichar *aMessage); \ - virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); \ - virtual void UpdateBusyState(PRBool aBusy); \ - virtual void UpdateCurrentURI(nsIURI *aLocation); \ - virtual void UpdateSecurityStatus(PRInt32 aState); \ - virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, nsIWebBrowser** aWebBrowser); \ - virtual void DestroyBrowserFrame(); \ - virtual void GetBrowserFrameTitle(PRUnichar **aTitle); \ - virtual void SetBrowserFrameTitle(const PRUnichar *aTitle); \ - virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY); \ - virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY); \ - virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY); \ - virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY); \ - virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY); \ - virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint); \ - virtual void ShowBrowserFrame(PRBool aShow); \ - virtual void SetFocus(); \ - virtual void FocusAvailable(PRBool *aFocusAvail); \ - virtual void GetBrowserFrameVisibility(PRBool *aVisible); \ - virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo); \ - virtual HWND GetBrowserFrameNativeWnd(); - +#define NS_DECL_BROWSERFRAMEGLUE \ + public: \ + virtual void UpdateStatusBarText(const PRUnichar *aMessage); \ + virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); \ + virtual void UpdateBusyState(PRBool aBusy); \ + virtual void UpdateCurrentURI(nsIURI *aLocation); \ + virtual void UpdateSecurityStatus(PRInt32 aState); \ + virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, nsIWebBrowser** aWebBrowser); \ + virtual void DestroyBrowserFrame(); \ + virtual void GetBrowserFrameTitle(PRUnichar **aTitle); \ + virtual void SetBrowserFrameTitle(const PRUnichar *aTitle); \ + virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY); \ + virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY); \ + virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY); \ + virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY); \ + virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY); \ + virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint); \ + virtual void ShowBrowserFrame(PRBool aShow); \ + virtual void SetFocus(); \ + virtual void FocusAvailable(PRBool *aFocusAvail); \ + virtual void GetBrowserFrameVisibility(PRBool *aVisible); \ + virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo); \ + virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText); \ + virtual void HideTooltip(); \ + virtual HWND GetBrowserFrameNativeWnd(); + typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE; #endif //_IBROWSERFRAMEGLUE_H diff --git a/mozilla/embedding/tests/mfcembed/Makefile.in b/mozilla/embedding/tests/mfcembed/Makefile.in index 280237e86ff..49745a7cd9b 100644 --- a/mozilla/embedding/tests/mfcembed/Makefile.in +++ b/mozilla/embedding/tests/mfcembed/Makefile.in @@ -80,6 +80,7 @@ CPPSRCS = \ BrowserImpl.cpp \ BrowserImplWebPrgrsLstnr.cpp \ BrowserImplCtxMenuLstnr.cpp \ + BrowserToolTip.cpp \ Dialogs.cpp \ ProfileMgr.cpp \ ProfilesDlg.cpp \ diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp index 81567d306a2..730033f171d 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp @@ -187,15 +187,15 @@ private: BEGIN_MESSAGE_MAP(CMfcEmbedApp, CWinApp) - //{{AFX_MSG_MAP(CMfcEmbedApp) - ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser) - ON_COMMAND(ID_NEW_EDITORWINDOW, OnNewEditor) - ON_COMMAND(ID_MANAGE_PROFILES, OnManageProfiles) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + //{{AFX_MSG_MAP(CMfcEmbedApp) + ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser) + ON_COMMAND(ID_NEW_EDITORWINDOW, OnNewEditor) + ON_COMMAND(ID_MANAGE_PROFILES, OnManageProfiles) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_EDIT_PREFERENCES, OnEditPreferences) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP END_MESSAGE_MAP() CMfcEmbedApp::CMfcEmbedApp() : @@ -362,27 +362,27 @@ BOOL CMfcEmbedApp::InitInstance() CMfcEmbedCommandLine cmdLine(*this); ParseCommandLine(cmdLine); - Enable3dControls(); + Enable3dControls(); - // - // 1. Determine the name of the dir from which the GRE based app is being run - // from [It's OK to do this even if you're not running in an GRE env] - // - // 2. Create an nsILocalFile out of it which will passed in to NS_InitEmbedding() - // - // Please see http://www.mozilla.org/projects/embedding/MRE.html - // for more info. on GRE + // + // 1. Determine the name of the dir from which the GRE based app is being run + // from [It's OK to do this even if you're not running in an GRE env] + // + // 2. Create an nsILocalFile out of it which will passed in to NS_InitEmbedding() + // + // Please see http://www.mozilla.org/projects/embedding/MRE.html + // for more info. on GRE - char curDir[_MAX_PATH+1]; - ::GetCurrentDirectory(_MAX_PATH, curDir); - nsresult rv; - nsCOMPtr mreAppDir; - rv = NS_NewNativeLocalFile(nsDependentCString(curDir), TRUE, getter_AddRefs(mreAppDir)); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create mreAppDir localfile"); + char curDir[_MAX_PATH+1]; + ::GetCurrentDirectory(_MAX_PATH, curDir); + nsresult rv; + nsCOMPtr mreAppDir; + rv = NS_NewNativeLocalFile(nsDependentCString(curDir), TRUE, getter_AddRefs(mreAppDir)); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create mreAppDir localfile"); - // Take a look at - // http://www.mozilla.org/projects/xpcom/file_locations.html - // for more info on File Locations + // Take a look at + // http://www.mozilla.org/projects/xpcom/file_locations.html + // for more info on File Locations winEmbedFileLocProvider *provider = new winEmbedFileLocProvider("MfcEmbed"); if(!provider) @@ -413,81 +413,81 @@ BOOL CMfcEmbedApp::InitInstance() return FALSE; } - if(!InitializeProfiles()) - { + if(!InitializeProfiles()) + { ASSERT(FALSE); NS_TermEmbedding(); - return FALSE; - } + return FALSE; + } if(!CreateHiddenWindow()) - { + { ASSERT(FALSE); NS_TermEmbedding(); - return FALSE; - } + return FALSE; + } - // Create the first browser frame window - OnNewBrowser(); + // Create the first browser frame window + OnNewBrowser(); - return TRUE; + return TRUE; } CBrowserFrame* CMfcEmbedApp::CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - PRBool bShowWindow, - PRBool bIsEditor - ) + PRInt32 x, PRInt32 y, + PRInt32 cx, PRInt32 cy, + PRBool bShowWindow, + PRBool bIsEditor + ) { - UINT resId = bIsEditor ? IDR_EDITOR : IDR_MAINFRAME; + UINT resId = bIsEditor ? IDR_EDITOR : IDR_MAINFRAME; - // Setup a CRect with the requested window dimensions - CRect winSize(x, y, cx, cy); + // Setup a CRect with the requested window dimensions + CRect winSize(x, y, cx, cy); - // Use the Windows default if all are specified as -1 - if(x == -1 && y == -1 && cx == -1 && cy == -1) - winSize = CFrameWnd::rectDefault; + // Use the Windows default if all are specified as -1 + if(x == -1 && y == -1 && cx == -1 && cy == -1) + winSize = CFrameWnd::rectDefault; - // Load the window title from the string resource table - CString strTitle; - strTitle.LoadString(IDR_MAINFRAME); + // Load the window title from the string resource table + CString strTitle; + strTitle.LoadString(IDR_MAINFRAME); - // Now, create the browser frame - CBrowserFrame* pFrame = bIsEditor ? ( new CEditorFrame(chromeMask) ) : - ( new CBrowserFrame(chromeMask) ); - pFrame->SetEditable(bIsEditor); + // Now, create the browser frame + CBrowserFrame* pFrame = bIsEditor ? ( new CEditorFrame(chromeMask) ) : + ( new CBrowserFrame(chromeMask) ); + pFrame->SetEditable(bIsEditor); - if (!pFrame->Create(NULL, strTitle, WS_OVERLAPPEDWINDOW, - winSize, NULL, MAKEINTRESOURCE(resId), 0L, NULL)) - { - return NULL; - } + if (!pFrame->Create(NULL, strTitle, WS_OVERLAPPEDWINDOW, + winSize, NULL, MAKEINTRESOURCE(resId), 0L, NULL)) + { + return NULL; + } - // load accelerator resource - pFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MAINFRAME)); + // load accelerator resource + pFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MAINFRAME)); - // Show the window... - if(bShowWindow) - { - pFrame->ShowWindow(SW_SHOW); - pFrame->UpdateWindow(); - } + // Show the window... + if(bShowWindow) + { + pFrame->ShowWindow(SW_SHOW); + pFrame->UpdateWindow(); + } - // Add to the list of BrowserFrame windows - m_FrameWndLst.AddHead(pFrame); + // Add to the list of BrowserFrame windows + m_FrameWndLst.AddHead(pFrame); - return pFrame; + return pFrame; } void CMfcEmbedApp::OnNewBrowser() { - CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(); + CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(); - //Load the HomePage into the browser view - if(pBrowserFrame && (GetStartupPageMode() == 1)) - pBrowserFrame->m_wndBrowserView.LoadHomePage(); + //Load the HomePage into the browser view + if(pBrowserFrame && (GetStartupPageMode() == 1)) + pBrowserFrame->m_wndBrowserView.LoadHomePage(); } void CMfcEmbedApp::OnNewEditor() @@ -513,55 +513,55 @@ void CMfcEmbedApp::OnNewEditor() // void CMfcEmbedApp::RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame/*= TRUE*/) { - POSITION pos = m_FrameWndLst.Find(pFrm); - m_FrameWndLst.RemoveAt(pos); + POSITION pos = m_FrameWndLst.Find(pFrm); + m_FrameWndLst.RemoveAt(pos); - // Send a WM_QUIT msg. to the hidden window if we've - // just closed the last browserframe window and - // if the bCloseAppOnLastFrame is TRUE. This be FALSE - // only in the case we're switching profiles - // Without this the hidden window will stick around - // i.e. the app will never die even after all the - // visible windows are gone. - if(m_FrameWndLst.GetCount() == 0 && bCloseAppOnLastFrame) - m_pMainWnd->PostMessage(WM_QUIT); + // Send a WM_QUIT msg. to the hidden window if we've + // just closed the last browserframe window and + // if the bCloseAppOnLastFrame is TRUE. This be FALSE + // only in the case we're switching profiles + // Without this the hidden window will stick around + // i.e. the app will never die even after all the + // visible windows are gone. + if(m_FrameWndLst.GetCount() == 0 && bCloseAppOnLastFrame) + m_pMainWnd->PostMessage(WM_QUIT); } int CMfcEmbedApp::ExitInstance() { - // When File/Exit is chosen and if the user - // has opened multiple browser windows shut all - // of them down properly before exiting the app + // When File/Exit is chosen and if the user + // has opened multiple browser windows shut all + // of them down properly before exiting the app - CBrowserFrame* pBrowserFrame = NULL; + CBrowserFrame* pBrowserFrame = NULL; - POSITION pos = m_FrameWndLst.GetHeadPosition(); - while( pos != NULL ) - { - pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); - if(pBrowserFrame) - { - pBrowserFrame->ShowWindow(false); - pBrowserFrame->DestroyWindow(); - } - } - m_FrameWndLst.RemoveAll(); + POSITION pos = m_FrameWndLst.GetHeadPosition(); + while( pos != NULL ) + { + pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); + if(pBrowserFrame) + { + pBrowserFrame->ShowWindow(false); + pBrowserFrame->DestroyWindow(); + } + } + m_FrameWndLst.RemoveAll(); if (m_pMainWnd) m_pMainWnd->DestroyWindow(); delete m_ProfileMgr; - NS_TermEmbedding(); + NS_TermEmbedding(); - return 1; + return 1; } BOOL CMfcEmbedApp::OnIdle(LONG lCount) { - CWinApp::OnIdle(lCount); + CWinApp::OnIdle(lCount); - return FALSE; + return FALSE; } void CMfcEmbedApp::OnManageProfiles() @@ -593,7 +593,7 @@ void CMfcEmbedApp::OnEditPreferences() rv = prefs->SavePrefFile(nsnull); } else - NS_ASSERTION(PR_FALSE, "Could not get preferences service"); + NS_ASSERTION(PR_FALSE, "Could not get preferences service"); } } @@ -603,7 +603,7 @@ BOOL CMfcEmbedApp::InitializeProfiles() if (!m_ProfileMgr) return FALSE; - nsresult rv; + nsresult rv; nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); observerService->AddObserver(this, "profile-approve-change", PR_TRUE); @@ -612,7 +612,7 @@ BOOL CMfcEmbedApp::InitializeProfiles() m_ProfileMgr->StartUp(); - return TRUE; + return TRUE; } // When the profile switch happens, all open browser windows need to be @@ -622,31 +622,31 @@ BOOL CMfcEmbedApp::InitializeProfiles() // switches BOOL CMfcEmbedApp::CreateHiddenWindow() { - CFrameWnd *hiddenWnd = new CFrameWnd; - if(!hiddenWnd) - return FALSE; + CFrameWnd *hiddenWnd = new CFrameWnd; + if(!hiddenWnd) + return FALSE; RECT bounds = { -10010, -10010, -10000, -10000 }; hiddenWnd->Create(NULL, "main", WS_DISABLED, bounds, NULL, NULL, 0, NULL); m_pMainWnd = hiddenWnd; - return TRUE; + return TRUE; } nsresult CMfcEmbedApp::InitializePrefs() { nsresult rv; nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) { - // We are using the default prefs from mozilla. If you were - // disributing your own, this would be done simply by editing - // the default pref files. - - PRBool inited; - rv = prefs->GetBoolPref("mfcbrowser.prefs_inited", &inited); - if (NS_FAILED(rv) || !inited) - { + // We are using the default prefs from mozilla. If you were + // disributing your own, this would be done simply by editing + // the default pref files. + + PRBool inited; + rv = prefs->GetBoolPref("mfcbrowser.prefs_inited", &inited); + if (NS_FAILED(rv) || !inited) + { m_iStartupPage = 1; m_strHomePage = "http://www.mozilla.org/projects/embedding"; @@ -671,10 +671,10 @@ nsresult CMfcEmbedApp::InitializePrefs() if(pBuf) m_strHomePage = pBuf; } - } - else - NS_ASSERTION(PR_FALSE, "Could not get preferences service"); - + } + else + NS_ASSERTION(PR_FALSE, "Could not get preferences service"); + return rv; } @@ -731,21 +731,21 @@ NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, c // Close all open windows. Alternatively, we could just call CBrowserWindow::Stop() // on each. Either way, we have to stop all network activity on this phase. - POSITION pos = m_FrameWndLst.GetHeadPosition(); - while( pos != NULL ) - { - CBrowserFrame *pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); - if(pBrowserFrame) - { - pBrowserFrame->ShowWindow(false); + POSITION pos = m_FrameWndLst.GetHeadPosition(); + while( pos != NULL ) + { + CBrowserFrame *pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); + if(pBrowserFrame) + { + pBrowserFrame->ShowWindow(false); - // Passing in FALSE below so that we do not - // kill the main app during a profile switch - RemoveFrameFromList(pBrowserFrame, FALSE); + // Passing in FALSE below so that we do not + // kill the main app during a profile switch + RemoveFrameFromList(pBrowserFrame, FALSE); - pBrowserFrame->DestroyWindow(); - } - } + pBrowserFrame->DestroyWindow(); + } + } } else if (nsCRT::strcmp(aTopic, "profile-after-change") == 0) { @@ -783,15 +783,15 @@ NS_IMETHODIMP CMfcEmbedApp::CreateChromeWindow(nsIWebBrowserChrome *parent, class CAboutDlg : public CDialog { public: - CAboutDlg(); + CAboutDlg(); - enum { IDD = IDD_ABOUTBOX }; + enum { IDD = IDD_ABOUTBOX }; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support protected: - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) @@ -800,7 +800,7 @@ CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) void CAboutDlg::DoDataExchange(CDataExchange* pDX) { - CDialog::DoDataExchange(pDX); + CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) @@ -809,6 +809,6 @@ END_MESSAGE_MAP() // Show the AboutDlg void CMfcEmbedApp::OnAppAbout() { - CAboutDlg aboutDlg; - aboutDlg.DoModal(); + CAboutDlg aboutDlg; + aboutDlg.DoModal(); } diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.h b/mozilla/embedding/tests/mfcembed/MfcEmbed.h index e0a0b568a6b..4918e75ac22 100644 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.h +++ b/mozilla/embedding/tests/mfcembed/MfcEmbed.h @@ -40,7 +40,7 @@ #endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH + #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols @@ -59,31 +59,31 @@ class CMfcEmbedApp : public CWinApp, public nsSupportsWeakReference { public: - CMfcEmbedApp(); - + CMfcEmbedApp(); + NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER NS_DECL_NSIWINDOWCREATOR - CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, - PRInt32 x = -1, PRInt32 y = -1, - PRInt32 cx = -1, PRInt32 cy = -1, PRBool bShowWindow = PR_TRUE, - PRBool bIsEditor=PR_FALSE); - void RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame = TRUE); + CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, + PRInt32 x = -1, PRInt32 y = -1, + PRInt32 cx = -1, PRInt32 cy = -1, PRBool bShowWindow = PR_TRUE, + PRBool bIsEditor=PR_FALSE); + void RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame = TRUE); void ShowDebugConsole(); nsresult OverrideComponents(); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMfcEmbedApp) - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - virtual BOOL OnIdle(LONG lCount); - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMfcEmbedApp) + public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + virtual BOOL OnIdle(LONG lCount); + //}}AFX_VIRTUAL - CObList m_FrameWndLst; + CObList m_FrameWndLst; BOOL m_bChrome; CString m_strHomePage; @@ -100,20 +100,20 @@ public: // Implementation public: - //{{AFX_MSG(CMfcEmbedApp) - afx_msg void OnAppAbout(); - afx_msg void OnNewBrowser(); - afx_msg void OnNewEditor(); + //{{AFX_MSG(CMfcEmbedApp) + afx_msg void OnAppAbout(); + afx_msg void OnNewBrowser(); + afx_msg void OnNewEditor(); afx_msg void OnManageProfiles(); afx_msg void OnEditPreferences(); - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() private: - BOOL InitializeProfiles(); - BOOL CreateHiddenWindow(); + BOOL InitializeProfiles(); + BOOL CreateHiddenWindow(); nsresult InitializePrefs(); nsresult InitializeWindowCreator(); diff --git a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp b/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp index 9f3d61373a6..d4722222f4e 100644 --- a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp +++ b/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp @@ -50,21 +50,21 @@ CMostRecentUrls::CMostRecentUrls() : mNumURLs(0) { - for (int i=0;i 1) { - line[strlen(line)-1] = 0; - mURLs[mNumURLs++] = _strdup(line); - } - } - fclose(fd); - } + FILE * fd = GetFD("r"); + if (fd) { + char line[512]; + while (fgets(line, 512, fd)) { + if (strlen(line) > 1) { + line[strlen(line)-1] = 0; + mURLs[mNumURLs++] = _strdup(line); + } + } + fclose(fd); + } } @@ -110,33 +110,33 @@ char * CMostRecentUrls::GetURL(int aInx) void CMostRecentUrls::AddURL(const char * aURL) { - TCHAR szTemp[512]; - strcpy(szTemp, aURL); + TCHAR szTemp[512]; + strcpy(szTemp, aURL); - // check to see if an existing url matches the one passed in - for (int i=0; i0; i--) - { + for (; i>0; i--) + { if(mURLs[i]) free(mURLs[i]); if(mURLs[i-1]) mURLs[i] = _strdup(mURLs[i-1]); - } + } - // place this url at the top + // place this url at the top if(mURLs[0]) free(mURLs[0]); mURLs[0] = _strdup(szTemp); diff --git a/mozilla/embedding/tests/mfcembed/Preferences.cpp b/mozilla/embedding/tests/mfcembed/Preferences.cpp index 4c80632cebf..3040041415e 100644 --- a/mozilla/embedding/tests/mfcembed/Preferences.cpp +++ b/mozilla/embedding/tests/mfcembed/Preferences.cpp @@ -44,7 +44,7 @@ static char THIS_FILE[] = __FILE__; IMPLEMENT_DYNAMIC(CPreferences, CPropertySheet) CPreferences::CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) - :CPropertySheet(pszCaption, pParentWnd, iSelectPage) + :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { AddPage(&m_startupPage); } @@ -54,22 +54,22 @@ CPreferences::~CPreferences() } BEGIN_MESSAGE_MAP(CPreferences, CPropertySheet) - //{{AFX_MSG_MAP(CPreferences) - // NOTE - the ClassWizard will add and remove mapping macros here. - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CPreferences) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP END_MESSAGE_MAP() BOOL CPreferences::OnInitDialog() { - BOOL bResult = CPropertySheet::OnInitDialog(); - + BOOL bResult = CPropertySheet::OnInitDialog(); + // Hide the Apply button CWnd* pApplyButton = GetDlgItem(ID_APPLY_NOW); ASSERT(pApplyButton); pApplyButton->ShowWindow(SW_HIDE); - return bResult; + return bResult; } @@ -80,10 +80,10 @@ IMPLEMENT_DYNCREATE(CStartupPrefsPage, CPropertyPage) CStartupPrefsPage::CStartupPrefsPage() : CPropertyPage(CStartupPrefsPage::IDD) { - //{{AFX_DATA_INIT(CStartupPrefsPage) - m_strHomePage = _T(""); - m_iStartupPage = -1; - //}}AFX_DATA_INIT + //{{AFX_DATA_INIT(CStartupPrefsPage) + m_strHomePage = _T(""); + m_iStartupPage = -1; + //}}AFX_DATA_INIT } CStartupPrefsPage::~CStartupPrefsPage() @@ -92,16 +92,16 @@ CStartupPrefsPage::~CStartupPrefsPage() void CStartupPrefsPage::DoDataExchange(CDataExchange* pDX) { - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CStartupPrefsPage) - DDX_Control(pDX, IDC_EDIT_HOMEPAGE, m_HomePage); - DDX_Text(pDX, IDC_EDIT_HOMEPAGE, m_strHomePage); - DDX_Radio(pDX, IDC_RADIO_BLANK_PAGE, m_iStartupPage); - //}}AFX_DATA_MAP + CPropertyPage::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CStartupPrefsPage) + DDX_Control(pDX, IDC_EDIT_HOMEPAGE, m_HomePage); + DDX_Text(pDX, IDC_EDIT_HOMEPAGE, m_strHomePage); + DDX_Radio(pDX, IDC_RADIO_BLANK_PAGE, m_iStartupPage); + //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CStartupPrefsPage, CPropertyPage) - //{{AFX_MSG_MAP(CStartupPrefsPage) - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CStartupPrefsPage) + //}}AFX_MSG_MAP END_MESSAGE_MAP() diff --git a/mozilla/embedding/tests/mfcembed/Preferences.h b/mozilla/embedding/tests/mfcembed/Preferences.h index 98407a27c64..7c20466c07b 100644 --- a/mozilla/embedding/tests/mfcembed/Preferences.h +++ b/mozilla/embedding/tests/mfcembed/Preferences.h @@ -44,35 +44,35 @@ class CStartupPrefsPage : public CPropertyPage { - DECLARE_DYNCREATE(CStartupPrefsPage) + DECLARE_DYNCREATE(CStartupPrefsPage) // Construction public: - CStartupPrefsPage(); - ~CStartupPrefsPage(); + CStartupPrefsPage(); + ~CStartupPrefsPage(); // Dialog Data - //{{AFX_DATA(CStartupPrefsPage) - enum { IDD = IDD_PREFS_START_PAGE }; - CEdit m_HomePage; - CString m_strHomePage; - int m_iStartupPage; - //}}AFX_DATA + //{{AFX_DATA(CStartupPrefsPage) + enum { IDD = IDD_PREFS_START_PAGE }; + CEdit m_HomePage; + CString m_strHomePage; + int m_iStartupPage; + //}}AFX_DATA // Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(CStartupPrefsPage) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // ClassWizard generate virtual function overrides + //{{AFX_VIRTUAL(CStartupPrefsPage) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL // Implementation protected: - // Generated message map functions - //{{AFX_MSG(CStartupPrefsPage) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Generated message map functions + //{{AFX_MSG(CStartupPrefsPage) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; @@ -81,11 +81,11 @@ protected: class CPreferences : public CPropertySheet { - DECLARE_DYNAMIC(CPreferences) + DECLARE_DYNAMIC(CPreferences) // Construction public: - CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); + CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); // Attributes public: @@ -95,22 +95,22 @@ public: public: // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPreferences) - public: - virtual BOOL OnInitDialog(); - //}}AFX_VIRTUAL + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPreferences) + public: + virtual BOOL OnInitDialog(); + //}}AFX_VIRTUAL // Implementation public: - virtual ~CPreferences(); + virtual ~CPreferences(); - // Generated message map functions + // Generated message map functions protected: - //{{AFX_MSG(CPreferences) - // NOTE - the ClassWizard will add and remove member functions here. - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + //{{AFX_MSG(CPreferences) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp index 9ba7ca093fa..60fbcd5210c 100644 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp +++ b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp @@ -82,22 +82,22 @@ static void ValidateProfileName(const CString& profileName, CDataExchange* pDX) CNewProfileDlg::CNewProfileDlg(CWnd* pParent /*=NULL*/) - : CDialog(CNewProfileDlg::IDD, pParent) + : CDialog(CNewProfileDlg::IDD, pParent) { - //{{AFX_DATA_INIT(CNewProfileDlg) - m_LocaleIndex = -1; - m_Name = _T(""); - //}}AFX_DATA_INIT + //{{AFX_DATA_INIT(CNewProfileDlg) + m_LocaleIndex = -1; + m_Name = _T(""); + //}}AFX_DATA_INIT } void CNewProfileDlg::DoDataExchange(CDataExchange* pDX) { - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CNewProfileDlg) - DDX_CBIndex(pDX, IDC_LOCALE_COMBO, m_LocaleIndex); - DDX_Text(pDX, IDC_NEW_PROF_NAME, m_Name); - //}}AFX_DATA_MAP + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CNewProfileDlg) + DDX_CBIndex(pDX, IDC_LOCALE_COMBO, m_LocaleIndex); + DDX_Text(pDX, IDC_NEW_PROF_NAME, m_Name); + //}}AFX_DATA_MAP pDX->PrepareEditCtrl(IDC_NEW_PROF_NAME); if (pDX->m_bSaveAndValidate) @@ -108,9 +108,9 @@ void CNewProfileDlg::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(CNewProfileDlg, CDialog) - //{{AFX_MSG_MAP(CNewProfileDlg) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CNewProfileDlg) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -122,20 +122,20 @@ END_MESSAGE_MAP() CRenameProfileDlg::CRenameProfileDlg(CWnd* pParent /*=NULL*/) - : CDialog(CRenameProfileDlg::IDD, pParent) + : CDialog(CRenameProfileDlg::IDD, pParent) { - //{{AFX_DATA_INIT(CRenameProfileDlg) - m_NewName = _T(""); - //}}AFX_DATA_INIT + //{{AFX_DATA_INIT(CRenameProfileDlg) + m_NewName = _T(""); + //}}AFX_DATA_INIT } void CRenameProfileDlg::DoDataExchange(CDataExchange* pDX) { - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CRenameProfileDlg) - DDX_Text(pDX, IDC_NEW_NAME, m_NewName); - //}}AFX_DATA_MAP + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CRenameProfileDlg) + DDX_Text(pDX, IDC_NEW_NAME, m_NewName); + //}}AFX_DATA_MAP pDX->PrepareEditCtrl(IDC_NEW_NAME); if (pDX->m_bSaveAndValidate) @@ -146,9 +146,9 @@ void CRenameProfileDlg::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(CRenameProfileDlg, CDialog) - //{{AFX_MSG_MAP(CRenameProfileDlg) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CRenameProfileDlg) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -160,22 +160,22 @@ END_MESSAGE_MAP() CProfilesDlg::CProfilesDlg(CWnd* pParent /*=NULL*/) - : CDialog(CProfilesDlg::IDD, pParent) + : CDialog(CProfilesDlg::IDD, pParent) { - //{{AFX_DATA_INIT(CProfilesDlg) + //{{AFX_DATA_INIT(CProfilesDlg) m_bAtStartUp = FALSE; - m_bAskAtStartUp = FALSE; - //}}AFX_DATA_INIT + m_bAskAtStartUp = FALSE; + //}}AFX_DATA_INIT } void CProfilesDlg::DoDataExchange(CDataExchange* pDX) { - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CProfilesDlg) - DDX_Control(pDX, IDC_LIST1, m_ProfileList); - DDX_Check(pDX, IDC_CHECK_ASK_AT_START, m_bAskAtStartUp); - //}}AFX_DATA_MAP + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CProfilesDlg) + DDX_Control(pDX, IDC_LIST1, m_ProfileList); + DDX_Check(pDX, IDC_CHECK_ASK_AT_START, m_bAskAtStartUp); + //}}AFX_DATA_MAP if (pDX->m_bSaveAndValidate) { @@ -193,12 +193,12 @@ void CProfilesDlg::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(CProfilesDlg, CDialog) - //{{AFX_MSG_MAP(CProfilesDlg) - ON_BN_CLICKED(IDC_PROF_NEW, OnNewProfile) - ON_BN_CLICKED(IDC_PROF_RENAME, OnRenameProfile) - ON_BN_CLICKED(IDC_PROF_DELETE, OnDeleteProfile) - ON_LBN_DBLCLK(IDC_LIST1, OnDblclkProfile) - //}}AFX_MSG_MAP + //{{AFX_MSG_MAP(CProfilesDlg) + ON_BN_CLICKED(IDC_PROF_NEW, OnNewProfile) + ON_BN_CLICKED(IDC_PROF_RENAME, OnRenameProfile) + ON_BN_CLICKED(IDC_PROF_DELETE, OnDeleteProfile) + ON_LBN_DBLCLK(IDC_LIST1, OnDblclkProfile) + //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -208,8 +208,8 @@ BOOL CProfilesDlg::OnInitDialog() { USES_CONVERSION; - CDialog::OnInitDialog(); - + CDialog::OnInitDialog(); + nsCAutoString cStr; nsXPIDLString curProfileName; @@ -238,14 +238,14 @@ BOOL CProfilesDlg::OnInitDialog() { GetDlgItem(IDCANCEL)->EnableWindow(FALSE); } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE } void CProfilesDlg::OnNewProfile() { - CNewProfileDlg dialog; + CNewProfileDlg dialog; if (dialog.DoModal() == IDOK) { @@ -258,7 +258,7 @@ void CProfilesDlg::OnNewProfile() { USES_CONVERSION; - rv = profileService->CreateNewProfile(T2W(dialog.m_Name), nsnull, nsnull, PR_FALSE); + rv = profileService->CreateNewProfile(T2W(dialog.m_Name), nsnull, nsnull, PR_FALSE); ASSERT(NS_SUCCEEDED(rv)); if (NS_SUCCEEDED(rv)) { @@ -272,7 +272,7 @@ void CProfilesDlg::OnNewProfile() void CProfilesDlg::OnRenameProfile() { - CRenameProfileDlg dialog; + CRenameProfileDlg dialog; int itemIndex = m_ProfileList.GetCurSel(); ASSERT(itemIndex != LB_ERR); @@ -295,7 +295,7 @@ void CProfilesDlg::OnRenameProfile() rv = profileService->RenameProfile(T2W(dialog.m_CurrentName), T2W(dialog.m_NewName)); ASSERT(NS_SUCCEEDED(rv)); } - } + } } void CProfilesDlg::OnDeleteProfile() @@ -324,7 +324,7 @@ void CProfilesDlg::OnDeleteProfile() if (itemCount == 0) GetDlgItem(IDOK)->EnableWindow(FALSE); } - } + } } void CProfilesDlg::OnDblclkProfile() diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h b/mozilla/embedding/tests/mfcembed/ProfilesDlg.h index 7ec2b196097..5118711c54b 100644 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h +++ b/mozilla/embedding/tests/mfcembed/ProfilesDlg.h @@ -43,31 +43,31 @@ class CNewProfileDlg : public CDialog { // Construction public: - CNewProfileDlg(CWnd* pParent = NULL); // standard constructor + CNewProfileDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data - //{{AFX_DATA(CNewProfileDlg) - enum { IDD = IDD_PROFILE_NEW }; - int m_LocaleIndex; - CString m_Name; - //}}AFX_DATA + //{{AFX_DATA(CNewProfileDlg) + enum { IDD = IDD_PROFILE_NEW }; + int m_LocaleIndex; + CString m_Name; + //}}AFX_DATA // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CNewProfileDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CNewProfileDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL // Implementation protected: - // Generated message map functions - //{{AFX_MSG(CNewProfileDlg) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Generated message map functions + //{{AFX_MSG(CNewProfileDlg) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// @@ -77,31 +77,31 @@ class CRenameProfileDlg : public CDialog { // Construction public: - CRenameProfileDlg(CWnd* pParent = NULL); // standard constructor + CRenameProfileDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data - //{{AFX_DATA(CRenameProfileDlg) - enum { IDD = IDD_PROFILE_RENAME }; - CString m_NewName; - //}}AFX_DATA + //{{AFX_DATA(CRenameProfileDlg) + enum { IDD = IDD_PROFILE_RENAME }; + CString m_NewName; + //}}AFX_DATA CString m_CurrentName; // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CRenameProfileDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CRenameProfileDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL // Implementation protected: - // Generated message map functions - //{{AFX_MSG(CRenameProfileDlg) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Generated message map functions + //{{AFX_MSG(CRenameProfileDlg) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// @@ -111,37 +111,37 @@ class CProfilesDlg : public CDialog { // Construction public: - CProfilesDlg(CWnd* pParent = NULL); // standard constructor + CProfilesDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data - //{{AFX_DATA(CProfilesDlg) - enum { IDD = IDD_PROFILES }; - CListBox m_ProfileList; + //{{AFX_DATA(CProfilesDlg) + enum { IDD = IDD_PROFILES }; + CListBox m_ProfileList; BOOL m_bAtStartUp; - BOOL m_bAskAtStartUp; - //}}AFX_DATA + BOOL m_bAskAtStartUp; + //}}AFX_DATA nsAutoString m_SelectedProfile; // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CProfilesDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CProfilesDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL // Implementation protected: - // Generated message map functions - //{{AFX_MSG(CProfilesDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnNewProfile(); - afx_msg void OnRenameProfile(); - afx_msg void OnDeleteProfile(); - afx_msg void OnDblclkProfile(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Generated message map functions + //{{AFX_MSG(CProfilesDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnNewProfile(); + afx_msg void OnRenameProfile(); + afx_msg void OnDeleteProfile(); + afx_msg void OnDblclkProfile(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} diff --git a/mozilla/embedding/tests/mfcembed/StdAfx.h b/mozilla/embedding/tests/mfcembed/StdAfx.h index fce55e5b0ea..f15bc5d7afd 100644 --- a/mozilla/embedding/tests/mfcembed/StdAfx.h +++ b/mozilla/embedding/tests/mfcembed/StdAfx.h @@ -41,7 +41,7 @@ #pragma once #endif // _MSC_VER > 1000 -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers // // These headers are very evil, as they will define DEBUG if _DEBUG is @@ -58,10 +58,10 @@ #include // MFC core and standard components #include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#include // Needed for MFC MBCS/Unicode Conversion Macros +#include // MFC support for Internet Explorer 4 Common Controls +#include // Needed for MFC MBCS/Unicode Conversion Macros #ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls +#include // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT //{{AFX_INSERT_LOCATION}} @@ -93,6 +93,7 @@ #include "nsIClipboardCommands.h" #include "nsIWebBrowserPersist.h" #include "nsIContextMenuListener2.h" +#include "nsITooltipListener.h" #include "nsIDOMNode.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLImageElement.h" @@ -101,7 +102,7 @@ #include "nsIDOMHTMLFrameSetElement.h" #include "nsReadableUtils.h" #include "nsIPrompt.h" -#include "nsEmbedAPI.h" +#include "nsEmbedAPI.h" #include "nsISHistory.h" #include "nsISHEntry.h" #include "nsIPref.h" diff --git a/mozilla/embedding/tests/mfcembed/mfcembed.dsp b/mozilla/embedding/tests/mfcembed/mfcembed.dsp index 5a0bee4424f..a0e81bb7fc4 100644 --- a/mozilla/embedding/tests/mfcembed/mfcembed.dsp +++ b/mozilla/embedding/tests/mfcembed/mfcembed.dsp @@ -110,6 +110,10 @@ SOURCE=.\BrowserImplWebPrgrsLstnr.cpp # End Source File # Begin Source File +SOURCE=.\BrowserToolTip.cpp +# End Source File +# Begin Source File + SOURCE=.\BrowserView.cpp # End Source File # Begin Source File @@ -174,6 +178,10 @@ SOURCE=.\BrowserImpl.h # End Source File # Begin Source File +SOURCE=.\BrowserToolTip.h +# End Source File +# Begin Source File + SOURCE=.\BrowserView.h # End Source File # Begin Source File diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp index 5f0909f1b11..db2e89e4eb7 100644 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp +++ b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp @@ -84,12 +84,12 @@ NS_IMPL_ISUPPORTS1(winEmbedFileLocProvider, nsIDirectoryServiceProvider) NS_IMETHODIMP winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval) { - nsCOMPtr localFile; - nsresult rv = NS_ERROR_FAILURE; + nsCOMPtr localFile; + nsresult rv = NS_ERROR_FAILURE; - *_retval = nsnull; - *persistant = PR_TRUE; - + *_retval = nsnull; + *persistant = PR_TRUE; + if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); @@ -173,10 +173,10 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile * rv = localFile->AppendRelativeNativePath(COMPONENTS_DIR_NAME); } - if (localFile && NS_SUCCEEDED(rv)) - return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); - - return rv; + if (localFile && NS_SUCCEEDED(rv)) + return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); + + return rv; } // Get the location of the GRE version we're compatible with from @@ -245,7 +245,7 @@ NS_METHOD winEmbedFileLocProvider::GetGreDirectory(nsILocalFile **aLocalFile) if(pGreDir) { nsCOMPtr tempLocal; - rv = NS_NewNativeLocalFile(nsDependentCString(pGreDir), TRUE, getter_AddRefs(tempLocal)); + rv = NS_NewNativeLocalFile(nsDependentCString(pGreDir), TRUE, getter_AddRefs(tempLocal)); if (tempLocal) { diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h index f4916853386..4997b841374 100644 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h +++ b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h @@ -41,24 +41,24 @@ class nsIFile; class winEmbedFileLocProvider : public nsIDirectoryServiceProvider { public: - // productDirName is the name (not path) of the dir - // in which the application registry and profiles live. - winEmbedFileLocProvider(const char* productDirName); + // productDirName is the name (not path) of the dir + // in which the application registry and profiles live. + winEmbedFileLocProvider(const char* productDirName); - NS_DECL_ISUPPORTS - NS_DECL_NSIDIRECTORYSERVICEPROVIDER + NS_DECL_ISUPPORTS + NS_DECL_NSIDIRECTORYSERVICEPROVIDER - static char * GetGreLocationFromRegistry(); + static char * GetGreLocationFromRegistry(); protected: - virtual ~winEmbedFileLocProvider(); + virtual ~winEmbedFileLocProvider(); - NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile); - NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile); - NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile); - NS_METHOD GetGreDirectory(nsILocalFile **aLocalFile); + NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile); + NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile); + NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile); + NS_METHOD GetGreDirectory(nsILocalFile **aLocalFile); - char mProductDirName[256]; - nsCOMPtr mMozBinDirectory; + char mProductDirName[256]; + nsCOMPtr mMozBinDirectory; };