#74155 - MfcEmbed needs a prefs dlg box.
         r=valeski, sr=blizzard

#71014 - arrow keys don't work inside text areas in mfcEmbed.
         r=saari, sr=blizzard
This commit is contained in:
chak%netscape.com 2001-04-01 17:49:51 +00:00
Родитель 3b8322b04c
Коммит 909fc2f316
13 изменённых файлов: 349 добавлений и 9 удалений

Просмотреть файл

@ -78,6 +78,7 @@ BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd)
ON_WM_SETFOCUS()
ON_WM_SIZE()
ON_WM_CLOSE()
ON_WM_ACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -296,3 +297,10 @@ void CBrowserFrame::Dump(CDumpContext& dc) const
#endif //_DEBUG
void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
m_wndBrowserView.Activate(nState, pWndOther, bMinimized);
}

Просмотреть файл

@ -182,6 +182,7 @@ protected:
afx_msg void OnSetFocus(CWnd *pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnClose();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

Просмотреть файл

@ -62,9 +62,6 @@
static char THIS_FILE[] = __FILE__;
#endif
// "HomePage" URL
static const char* g_HomeURL = "http://www.mozilla.org/projects/embedding";
// Register message for FindDialog communication
static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING);
@ -419,7 +416,14 @@ void CBrowserView::OnUpdateNavForward(CCmdUI* pCmdUI)
void CBrowserView::OnNavHome()
{
OpenURL(g_HomeURL);
// Get the currently configured HomePage URL
CString strHomeURL;
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(pApp)
pApp->GetHomePage(strHomeURL);
if(strHomeURL.GetLength() > 0)
OpenURL(strHomeURL);
}
void CBrowserView::OnNavReload()
@ -966,4 +970,22 @@ void CBrowserView::SetCtxMenuLinkUrl(nsAutoString& strLinkUrl)
void CBrowserView::SetCtxMenuImageSrc(nsAutoString& strImgSrc)
{
mCtxMenuImgSrc = strImgSrc;
}
}
void CBrowserView::Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(!focus)
return;
switch(nState) {
case WA_ACTIVE:
focus->Activate();
break;
case WA_INACTIVE:
focus->Deactivate();
break;
default:
break;
}
}

Просмотреть файл

@ -106,6 +106,8 @@ public:
// indicates whether we are currently printing
BOOL m_bCurrentlyPrinting;
void Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBrowserView)

Просмотреть файл

@ -48,6 +48,7 @@
#include "BrowserImpl.h"
#include "nsIWindowWatcher.h"
#include "plstr.h"
#include "Preferences.h"
#include <io.h>
#include <fcntl.h>
@ -62,6 +63,7 @@ BEGIN_MESSAGE_MAP(CMfcEmbedApp, CWinApp)
ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser)
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
@ -71,6 +73,11 @@ CMfcEmbedApp::CMfcEmbedApp() :
m_ProfileMgr(NULL)
{
mRefCnt = 1; // Start at one - nothing is going to addref this object
m_strHomePage = "";
m_iStartupPage = 0;
}
CMfcEmbedApp theApp;
@ -262,7 +269,7 @@ void CMfcEmbedApp::OnNewBrowser()
CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame();
//Load the HomePage into the browser view
if(pBrowserFrame)
if(pBrowserFrame && (GetStartupPageMode() == 1))
pBrowserFrame->m_wndBrowserView.LoadHomePage();
}
@ -335,6 +342,34 @@ void CMfcEmbedApp::OnManageProfiles()
m_ProfileMgr->DoManageProfilesDialog(PR_FALSE);
}
void CMfcEmbedApp::OnEditPreferences()
{
CPreferences prefs(_T("Preferences"));
prefs.m_startupPage.m_iStartupPage = m_iStartupPage;
prefs.m_startupPage.m_strHomePage = m_strHomePage;
if(prefs.DoModal() == IDOK)
{
// Update our member vars with these new pref values
m_iStartupPage = prefs.m_startupPage.m_iStartupPage;
m_strHomePage = prefs.m_startupPage.m_strHomePage;
// Save these changes to disk now
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
prefs->SetIntPref("browser.startup.page", m_iStartupPage);
rv = prefs->SetCharPref("browser.startup.homepage", m_strHomePage);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile();
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");
}
}
BOOL CMfcEmbedApp::InitializeProfiles()
{
m_ProfileMgr = new CProfileMgr;
@ -387,13 +422,30 @@ nsresult CMfcEmbedApp::InitializePrefs()
rv = prefs->GetBoolPref("mfcbrowser.prefs_inited", &inited);
if (NS_FAILED(rv) || !inited)
{
m_iStartupPage = 1;
m_strHomePage = "http://www.mozilla.org/projects/embedding";
prefs->SetIntPref("browser.startup.page", m_iStartupPage);
prefs->SetCharPref("browser.startup.homepage", m_strHomePage);
prefs->SetIntPref("font.size.variable.x-western", 16);
prefs->SetIntPref("font.size.fixed.x-western", 13);
rv = prefs->SetBoolPref("mfcbrowser.prefs_inited", PR_TRUE);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile();
}
else
{
// The prefs are present, read them in
prefs->GetIntPref("browser.startup.page", &m_iStartupPage);
CString strBuf;
char *pBuf = strBuf.GetBuffer(_MAX_PATH);
prefs->CopyCharPref("browser.startup.homepage", &pBuf);
strBuf.ReleaseBuffer(-1);
if(pBuf)
m_strHomePage = pBuf;
}
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");

Просмотреть файл

@ -78,6 +78,17 @@ public:
CObList m_FrameWndLst;
CString m_strHomePage;
inline BOOL GetHomePage(CString& strHomePage) {
strHomePage = m_strHomePage;
return TRUE;
}
int m_iStartupPage; //0 = BlankPage, 1 = HomePage
inline int GetStartupPageMode() {
return m_iStartupPage;
}
// Implementation
public:
@ -85,6 +96,7 @@ public:
afx_msg void OnAppAbout();
afx_msg void OnNewBrowser();
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
@ -96,7 +108,7 @@ private:
nsresult InitializePrefs();
nsresult InitializeCachePrefs();
nsresult InitializeWindowCreator();
private:
CProfileMgr *m_ProfileMgr;
};

Просмотреть файл

@ -124,6 +124,8 @@ BEGIN
MENUITEM "&Find in This Page...\tCtrl+F", ID_EDIT_FIND
MENUITEM SEPARATOR
MENUITEM "Profiles...", ID_MANAGE_PROFILES
MENUITEM SEPARATOR
MENUITEM "Preferences...", ID_EDIT_PREFERENCES
END
POPUP "&View"
BEGIN
@ -369,6 +371,23 @@ BEGIN
LTEXT "",IDC_PPD_DOC_TXT,43,7,244,8
END
IDD_PREFS_START_PAGE DIALOG DISCARDABLE 0, 0, 284, 150
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Startup"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "MfcEmbed starts with",IDC_STATIC,6,10,271,49
CONTROL "Bla&nk Page",IDC_RADIO_BLANK_PAGE,"Button",
BS_AUTORADIOBUTTON | WS_GROUP,16,24,53,10
CONTROL "&Home Page",IDC_RADIO_HOME_PAGE,"Button",
BS_AUTORADIOBUTTON,16,40,53,10
GROUPBOX "Home Page",IDC_STATIC,6,67,271,51
LTEXT "Clicking the Home button will take you to this page",
IDC_STATIC,17,80,234,8
LTEXT "Loc&ation:",IDC_STATIC,17,98,31,8
EDITTEXT IDC_EDIT_HOMEPAGE,53,95,211,14,ES_AUTOHSCROLL
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#include "stdafx.h"
#include "Preferences.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////
// CPreferences
IMPLEMENT_DYNAMIC(CPreferences, CPropertySheet)
CPreferences::CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
AddPage(&m_startupPage);
}
CPreferences::~CPreferences()
{
}
BEGIN_MESSAGE_MAP(CPreferences, CPropertySheet)
//{{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();
// Hide the Apply button
CWnd* pApplyButton = GetDlgItem(ID_APPLY_NOW);
ASSERT(pApplyButton);
pApplyButton->ShowWindow(SW_HIDE);
return bResult;
}
/////////////////////////////////////////////////////////////////
// CStartupPrefsPage property page
IMPLEMENT_DYNCREATE(CStartupPrefsPage, CPropertyPage)
CStartupPrefsPage::CStartupPrefsPage() : CPropertyPage(CStartupPrefsPage::IDD)
{
//{{AFX_DATA_INIT(CStartupPrefsPage)
m_strHomePage = _T("");
m_iStartupPage = -1;
//}}AFX_DATA_INIT
}
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
}
BEGIN_MESSAGE_MAP(CStartupPrefsPage, CPropertyPage)
//{{AFX_MSG_MAP(CStartupPrefsPage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

Просмотреть файл

@ -0,0 +1,110 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
#ifndef _PREFERENCES_H_
#define _PREFERENCES_H_
#include "resource.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CStartupPrefsPage dialog
class CStartupPrefsPage : public CPropertyPage
{
DECLARE_DYNCREATE(CStartupPrefsPage)
// Construction
public:
CStartupPrefsPage();
~CStartupPrefsPage();
// Dialog 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
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CStartupPrefsPage)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CPreferences
class CPreferences : public CPropertySheet
{
DECLARE_DYNAMIC(CPreferences)
// Construction
public:
CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
// Attributes
public:
CStartupPrefsPage m_startupPage;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPreferences)
public:
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPreferences();
// Generated message map functions
protected:
//{{AFX_MSG(CPreferences)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // _PREFERENCES_H_

Просмотреть файл

@ -82,6 +82,7 @@
#include "nsWeakReference.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserFocus.h"
// Printer Includes
#include "nsIPrintOptions.h"

Просмотреть файл

@ -42,6 +42,7 @@ OBJS = \
.\$(OBJDIR)\winEmbedFileLocProvider.obj \
.\$(OBJDIR)\MostRecentUrls.obj \
.\$(OBJDIR)\PrintProgressDialog.obj \
.\$(OBJDIR)\Preferences.obj \
.\$(OBJDIR)\StdAfx.obj \
$(NULL)

Просмотреть файл

@ -130,6 +130,10 @@ SOURCE=.\MostRecentUrls.cpp
# End Source File
# Begin Source File
SOURCE=.\Preferences.cpp
# End Source File
# Begin Source File
SOURCE=.\PrintProgressDialog.cpp
# End Source File
# Begin Source File
@ -182,6 +186,10 @@ SOURCE=.\MostRecentUrls.h
# End Source File
# Begin Source File
SOURCE=.\Preferences.h
# End Source File
# Begin Source File
SOURCE=.\PrintProgressDialog.h
# End Source File
# Begin Source File

Просмотреть файл

@ -17,6 +17,7 @@
#define IDD_PROFILE_RENAME 139
#define IDD_FINDDLG 140
#define IDD_PRINT_PROGRESS_DIALOG 141
#define IDD_PREFS_START_PAGE 142
#define ID_URL_BAR 1001
#define ID_PROG_BAR 1002
#define IDC_PROMPT_ANSWER 1003
@ -42,6 +43,9 @@
#define IDC_WRAP_AROUND 1042
#define IDC_SEARCH_BACKWARDS 1043
#define IDC_FIND_EDIT 1152
#define IDC_RADIO_BLANK_PAGE 1153
#define IDC_RADIO_HOME_PAGE 1154
#define IDC_EDIT_HOMEPAGE 1155
#define ID_NAV_BACK 32773
#define ID_NAV_FORWARD 32774
#define ID_NAV_HOME 32775
@ -57,13 +61,14 @@
#define ID_SAVE_IMAGE_AS 32785
#define ID_COPY_LINK_LOCATION 32786
#define ID_MANAGE_PROFILES 32787
#define ID_EDIT_PREFERENCES 32788
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 142
#define _APS_NEXT_RESOURCE_VALUE 143
#define _APS_NEXT_COMMAND_VALUE 32789
#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101