fixup commit for tag 'kmeleon05'

kmeleon10_branch kmeleon05
cvs2hg 21 years ago
commit 829a6cb5d3
  1. 89
      k-meleon/About.cpp
  2. 39
      k-meleon/About.h
  3. 274
      k-meleon/AccelParser.cpp
  4. 48
      k-meleon/AccelParser.h
  5. 457
      k-meleon/BrowserFrameGlue.cpp
  6. 637
      k-meleon/BrowserFrm.cpp
  7. 243
      k-meleon/BrowserFrm.h
  8. 413
      k-meleon/BrowserImpl.cpp
  9. 59
      k-meleon/BrowserImpl.h
  10. 146
      k-meleon/BrowserImplContentLstnr.cpp
  11. 39
      k-meleon/BrowserImplCtxMenuLstnr.cpp
  12. 140
      k-meleon/BrowserImplWebPrgrsLstnr.cpp
  13. 954
      k-meleon/BrowserView.cpp
  14. 209
      k-meleon/BrowserView.h
  15. 166
      k-meleon/BrowserViewFind.cpp
  16. 131
      k-meleon/BrowserViewPanning.cpp
  17. 386
      k-meleon/BrowserViewUtils.cpp
  18. 110
      k-meleon/Dialogs.cpp
  19. 53
      k-meleon/Dialogs.h
  20. 259
      k-meleon/HiddenWnd.cpp
  21. 79
      k-meleon/HiddenWnd.h
  22. 104
      k-meleon/IBrowserFrameGlue.h
  23. 340
      k-meleon/Install/GNUlicense.txt
  24. 1
      k-meleon/Install/K-MeleonUNINST.ini
  25. 916
      k-meleon/Install/License.txt
  26. BIN
      k-meleon/Install/No.bmp
  27. BIN
      k-meleon/Install/Yes.bmp
  28. 263
      k-meleon/Install/k-meleon.nsi
  29. BIN
      k-meleon/Install/makensis.exe
  30. 118
      k-meleon/Install/readme.txt
  31. 480
      k-meleon/KMeleon.dsp
  32. 161
      k-meleon/KMeleon.dsw
  33. 61
      k-meleon/KMeleonConst.h
  34. 190
      k-meleon/Log.h
  35. 205
      k-meleon/MenuParser.cpp
  36. 46
      k-meleon/MenuParser.h
  37. 882
      k-meleon/MfcEmbed.cpp
  38. 140
      k-meleon/MfcEmbed.h
  39. 732
      k-meleon/MfcEmbed.rc
  40. 116
      k-meleon/MostRecentUrls.cpp
  41. 32
      k-meleon/MostRecentUrls.h
  42. 125
      k-meleon/Parser.cpp
  43. 21
      k-meleon/Parser.h
  44. 437
      k-meleon/Plugins.cpp
  45. 53
      k-meleon/Plugins.h
  46. 376
      k-meleon/Preferences.cpp
  47. 219
      k-meleon/Preferences.h
  48. 498
      k-meleon/PreferencesDlg.cpp
  49. 246
      k-meleon/PrintProgressDialog.cpp
  50. 70
      k-meleon/PrintProgressDialog.h
  51. 221
      k-meleon/ProfileMgr.cpp
  52. 57
      k-meleon/ProfileMgr.h
  53. 298
      k-meleon/ProfilesDlg.cpp
  54. 120
      k-meleon/ProfilesDlg.h
  55. 132
      k-meleon/README.TXT
  56. 204
      k-meleon/ReBarEx.cpp
  57. 51
      k-meleon/ReBarEx.h
  58. 31
      k-meleon/StdAfx.cpp
  59. 106
      k-meleon/StdAfx.h
  60. 182
      k-meleon/ToolBarEx.cpp
  61. 45
      k-meleon/ToolBarEx.h
  62. 513
      k-meleon/UnknownContentTypeHandler.cpp
  63. 95
      k-meleon/UnknownContentTypeHandler.h
  64. 120
      k-meleon/Utils.cpp
  65. 25
      k-meleon/Utils.h
  66. 8
      k-meleon/bmp_menu/StdAfx.cpp
  67. 29
      k-meleon/bmp_menu/StdAfx.h
  68. 596
      k-meleon/bmp_menu/bmp_menu.cpp
  69. 121
      k-meleon/bmp_menu/bmp_menu.dsp
  70. 242
      k-meleon/components/Dialogs.cpp
  71. 126
      k-meleon/components/Dialogs.h
  72. 136
      k-meleon/components/Dialogs.rc
  73. 389
      k-meleon/components/PromptService.cpp
  74. 44
      k-meleon/components/PromptService.h
  75. 150
      k-meleon/components/components.dsp
  76. 26
      k-meleon/components/resource.h
  77. 45
      k-meleon/components/stdafx.h
  78. BIN
      k-meleon/default/Back.bmp
  79. BIN
      k-meleon/default/Throbber.avi
  80. BIN
      k-meleon/default/Tool1.bmp
  81. BIN
      k-meleon/default/Tool2.bmp
  82. BIN
      k-meleon/default/Tool3.bmp
  83. 50
      k-meleon/default/accel.cfg
  84. 44
      k-meleon/default/macros.cfg
  85. 31
      k-meleon/default/menuicons.cfg
  86. 212
      k-meleon/default/menus.cfg
  87. 32
      k-meleon/default/prefs.js
  88. 48
      k-meleon/defineMap.cpp
  89. 241
      k-meleon/fullscreen/fullscreen.cpp
  90. 118
      k-meleon/fullscreen/fullscreen.dsp
  91. 32
      k-meleon/fullscreen/fullscreen.h
  92. 87
      k-meleon/fullscreen/fullscreen.rc
  93. 23
      k-meleon/fullscreen/resource.h
  94. 307
      k-meleon/history/history.cpp
  95. 132
      k-meleon/history/history.dsp
  96. 36
      k-meleon/history/history.h
  97. 8
      k-meleon/ie_favorites/StdAfx.cpp
  98. 27
      k-meleon/ie_favorites/StdAfx.h
  99. 633
      k-meleon/ie_favorites/ie_favorites.cpp
  100. 131
      k-meleon/ie_favorites/ie_favorites.dsp
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,89 @@
/*
* Copyright (C) 2001 Jeff Doozan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "StdAfx.h"
#include "version.h"
#include "About.h"
#include "BrowserFrm.h"
#include "MfcEmbed.h"
extern CMfcEmbedApp theApp;
#define _QUOTE(blah) #blah
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
m_credits = _QUOTE(
\r\n
K-Meleon - Copyright 2000-2001\r\n
\r\n
Uses the Gecko rendering engine by the Mozilla Group\r\n
Based on MfcEmbed\r\n
\r\n
Current Contributors:\r\n
);
if ((int)(time(NULL)/60) %2 == 1){
bFirst = 0;
m_credits += _QUOTE(
Jeff Doozan <jeff@tcbnetworks.com>\r\n
Brian Harris <binaryc@teamreaction.com>\r\n
);
}else{
m_credits += _QUOTE(
Brian Harris <binaryc@teamreaction.com>\r\n
Jeff Doozan <jeff@tcbnetworks.com>\r\n
);
}
m_credits += _QUOTE(
Tuncer M. Ayaz <tma@users.sf.net>\r\n
\r\n
Project Documentation:\r\n
Andrew Mutch <amutch@tln.lib.mi.us>\r\n
\r\n
Past Contributors:\r\n
Sebastian Spaeth <Sebastian@SSpaeth.de>\r\n
Christophe Thibault <christophe@nullsoft.com>\r\n
Chak Nanga <chak@netscape.com>\r\n
);
m_version.Format("Version %s Build %d Compiled %s", VERSION, BUILD_NUMBER, BUILD_TIME);
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX){
DDX_Text(pDX, IDC_CREDITS, m_credits);
DDX_Text(pDX, IDC_VERSION, m_version);
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CMfcEmbedApp)
ON_COMMAND(IDC_KMELEON_HOME, OnHome)
ON_COMMAND(IDC_KMELEON_FORUM, OnForum)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAboutDlg::OnHome() {
if (theApp.m_pMostRecentBrowserFrame)
theApp.m_pMostRecentBrowserFrame->PostMessage(WM_COMMAND, ID_LINK_KMELEON_HOME);
}
void CAboutDlg::OnForum() {
if (theApp.m_pMostRecentBrowserFrame)
theApp.m_pMostRecentBrowserFrame->PostMessage(WM_COMMAND, ID_LINK_KMELEON_FORUM);
}

@ -0,0 +1,39 @@
/*
* Copyright (C) 2001 Jeff Doozan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "resource.h"
#include "BrowserView.h"
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
CString m_credits;
CString m_version;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
afx_msg void OnHome();
afx_msg void OnForum();
DECLARE_MESSAGE_MAP()
};

@ -0,0 +1,274 @@
/*
* Copyright (C) 2000 Brian Harris
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "StdAfx.h"
#include "MfcEmbed.h"
extern CMfcEmbedApp theApp;
#include "AccelParser.h"
#include "Utils.h"
#include "resource.h"
#include "Plugins.h"
#include "kmeleon_plugin.h"
#define BEGIN_VK_TEST if (0){}
#define VK_TEST(KEY) else if (stricmp(p, #KEY) == 0){ key = VK_##KEY; }
static CMap<CString, LPCSTR, int, int &> defineMap;
CAccelParser::CAccelParser()
{
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
#include "defineMap.cpp"
}
CAccelParser::CAccelParser(CString &filename)
{
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
#include "defineMap.cpp"
Load(filename);
}
CAccelParser::~CAccelParser()
{
if (accelTable){
DestroyAcceleratorTable(accelTable);
}
}
int CAccelParser::Load(CString &filename)
{
SETUP_LOG("Accel");
if (accelTable){
DestroyAcceleratorTable(accelTable);
accelTable = NULL;
numAccelerators = 0;
}
int retVal = CParser::Load(filename);
END_LOG();
return retVal;
}
int CAccelParser::Parse(char *p)
{
char *e, *s;
char *alt, *ctrl, *shift;
BYTE virt;
int command;
int key;
BOOL vkey;
// <modifiers> <key> = <command>
e = strchr(p, '=');
if (e){
*e = 0;
e++;
e = SkipWhiteSpace(e);
TrimWhiteSpace(e);
char *op = strchr(e, '(');
if (op) { // if there's an open parenthesis, we'll assume it's a plugin
char *parameter = op + 1;
char *cp = strrchr(parameter, ')');
if (cp) *cp = 0;
*op = 0;
TrimWhiteSpace(e);
kmeleonPlugin * kPlugin = theApp.plugins.Load(e);
if (kPlugin && kPlugin->loaded) {
if (kPlugin->pf->DoAccel) {
command = kPlugin->pf->DoAccel(parameter);
LOG_2("Called plugin %s with parameter %s", e, parameter);
}
else
LOG_ERROR_2( "Plugin %s has no accelerator %s", e, parameter);
}
else
LOG_ERROR_2( "Could not load plugin %s\r\n\twith parameter %s", e, parameter );
}
else if (!defineMap.Lookup(e, command)) {
command = atoi(e);
}
TrimWhiteSpace(p);
s = p;
virt = 0;
alt = strstr(s, "ALT");
if (alt){
virt |= FALT;
p = alt + 3;
}
ctrl = strstr(s, "CTRL");
if (ctrl){
virt |= FCONTROL;
if (ctrl > alt){
p = ctrl + 4;
}
}
shift = strstr(s, "SHIFT");
if (shift){
virt |= FSHIFT;
if ((shift > alt) && (shift > ctrl)){
p = shift + 5;
}
}
virt |= FVIRTKEY;
// by now, p should be past the modifiers and point to " <key>"
p = SkipWhiteSpace(p);
if (strncmp(p, "VK_", 3) == 0){
p+=3;
key = 0;
vkey = TRUE;
// these should be in order of frequency of use to speed up parsing
BEGIN_VK_TEST
VK_TEST(ESCAPE)
VK_TEST(LEFT)
VK_TEST(RIGHT)
VK_TEST(F1)
VK_TEST(F2)
VK_TEST(F3)
VK_TEST(F4)
VK_TEST(F5)
VK_TEST(F6)
VK_TEST(F7)
VK_TEST(F8)
VK_TEST(F9)
VK_TEST(F10)
VK_TEST(F11)
VK_TEST(F12)
VK_TEST(HOME)
VK_TEST(END)
VK_TEST(PRIOR) // page up
VK_TEST(NEXT) // page down
VK_TEST(UP)
VK_TEST(DOWN)
VK_TEST(INSERT)
VK_TEST(DELETE)
VK_TEST(SPACE)
VK_TEST(HELP)
VK_TEST(EXECUTE)
VK_TEST(SELECT)
VK_TEST(PRINT)
VK_TEST(SNAPSHOT) // print screen?
VK_TEST(BACK)
VK_TEST(TAB)
VK_TEST(CLEAR)
VK_TEST(RETURN)
VK_TEST(MULTIPLY)
VK_TEST(ADD)
VK_TEST(SUBTRACT)
VK_TEST(DECIMAL)
VK_TEST(DIVIDE)
VK_TEST(SEPARATOR)
VK_TEST(PAUSE)
VK_TEST(CAPITAL)
VK_TEST(MENU)
VK_TEST(KANA)
VK_TEST(JUNJA)
VK_TEST(FINAL)
VK_TEST(HANJA)
VK_TEST(KANJI)
VK_TEST(CONVERT)
VK_TEST(NONCONVERT)
VK_TEST(ACCEPT)
VK_TEST(MODECHANGE)
VK_TEST(LWIN)
VK_TEST(RWIN)
VK_TEST(APPS)
VK_TEST(NUMPAD0)
VK_TEST(NUMPAD1)
VK_TEST(NUMPAD2)
VK_TEST(NUMPAD3)
VK_TEST(NUMPAD4)
VK_TEST(NUMPAD5)
VK_TEST(NUMPAD6)
VK_TEST(NUMPAD7)
VK_TEST(NUMPAD8)
VK_TEST(NUMPAD9)
VK_TEST(F13)
VK_TEST(F14)
VK_TEST(F15)
VK_TEST(F16)
VK_TEST(F17)
VK_TEST(F18)
VK_TEST(F19)
VK_TEST(F20)
VK_TEST(F21)
VK_TEST(F22)
VK_TEST(F23)
VK_TEST(F24)
VK_TEST(NUMLOCK)
VK_TEST(SCROLL)
}
else {
// regular key...
key = (WORD)*p;
vkey = FALSE;
}
accelerators[numAccelerators].cmd = command;
accelerators[numAccelerators].fVirt = virt;
if ( vkey || ((key >= 'A') && (key <= 'Z')) || ((key >= 'a') && (key <= 'z')) )
accelerators[numAccelerators].key = key;
else
accelerators[numAccelerators].key = VkKeyScan(key);
numAccelerators++;
} // if e
return true;
}
HACCEL CAccelParser::GetTable(){
if (!accelTable){
accelTable = CreateAcceleratorTable(accelerators, numAccelerators);
}
return accelTable;
}

@ -0,0 +1,48 @@
/*
* Copyright (C) 2000 Brian Harris
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __ACCELPARSER_H__
#define __ACCELPARSER_H__
#include "StdAfx.h"
#include "Parser.h"
#define MAX_ACCEL 127
class CAccelParser : public CParser {
protected:
ACCEL accelerators[MAX_ACCEL];
int numAccelerators;
HACCEL accelTable;
int Parse(char *p);
public:
CAccelParser();
CAccelParser(CString &filename);
~CAccelParser();
int Load(CString &filename);
HACCEL GetTable();
};
#endif // __ACCELPARSER_H__

@ -0,0 +1,457 @@
/* -*- 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>
*/
// File Overview....
//
// This file has the IBrowserFrameGlueObj implementation
// This frame glue object is nested inside of the BrowserFrame
// object(See BrowserFrm.h for more info)
//
// This is the place where all the platform specific interaction
// with the browser frame window takes place in response to
// callbacks from Gecko interface methods
//
// The main purpose of this interface is to separate the cross
// platform code in BrowserImpl*.cpp from the platform specific
// code(which is in this file)
//
// You'll also notice the use of a macro named "METHOD_PROLOGUE"
// through out this file. This macro essentially makes the pointer
// to a "containing" class available inside of the class which is
// being contained via a var named "pThis". In our case, the
// BrowserFrameGlue object is contained inside of the BrowserFrame
// object so "pThis" will be a pointer to a BrowserFrame object
// Refer to MFC docs for more info on METHOD_PROLOGUE macro
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
#include "MenuParser.h"
#include "KmeleonConst.h"
extern CMfcEmbedApp theApp;
/////////////////////////////////////////////////////////////////////////////
// IBrowserFrameGlue implementation
void CBrowserFrame::BrowserFrameGlueObj::UpdateStatusBarText(const PRUnichar *aMessage)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
nsCString strStatus;
if(aMessage)
strStatus.AssignWithConversion(aMessage);
pThis->m_wndStatusBar.SetPaneText(0, strStatus.get());
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndProgressBar.SetRange32(0, aMax);
pThis->m_wndProgressBar.SetPos(aCurrent);
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Just notify the view of the busy state
// There's code in there which will take care of
// updating the STOP toolbar btn. etc
pThis->m_wndBrowserView.UpdateBusyState(aBusy);
}
// Called from the OnLocationChange() method in the nsIWebProgressListener
// interface implementation in CBrowserImpl to update the current URI
// Will get called after a URI is successfully loaded in the browser
// We use this info to update the URL bar's edit box
//
void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation){
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aLocation) {
nsXPIDLCString uriString;
aLocation->GetSpec(getter_Copies(uriString));
pThis->m_wndUrlBar.SetCurrentURL(uriString.get());
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
CString title;
pThis->GetWindowText(title);
CString appTitle;
appTitle.LoadString(AFX_IDS_APP_TITLE);
title.Replace(" (" + appTitle + ')', "");
if(!title.IsEmpty())
{
nsString nsTitle;
nsTitle.AssignWithConversion(title.GetBuffer(0));
*aTitle = nsTitle.ToNewUnicode();
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameTitle(const PRUnichar *aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CString appTitle;
appTitle.LoadString(AFX_IDS_APP_TITLE);
CString title = W2T(aTitle);
if (title.IsEmpty()){
pThis->m_wndUrlBar.GetEnteredURL(title);
}
title += " (" + appTitle + ')';
pThis->SetWindowText(title);
pThis->PostMessage(UWM_UPDATESESSIONHISTORY, 0, 0);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, 0, 0, aCX, aCY,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// first we have to figure out how much bigger the frame is than the view
RECT frameRect, viewRect;
pThis->GetWindowRect(&frameRect);
pThis->m_wndBrowserView.GetClientRect(&viewRect);
int deltax = (frameRect.right-frameRect.left)-(viewRect.right-viewRect.left);
int deltay = (frameRect.bottom-frameRect.top)-(viewRect.bottom-viewRect.top);
pThis->SetWindowPos(NULL, 0, 0, aCX+deltax, aCY+deltay,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePosition(PRInt32 aX, PRInt32 aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, aCX, aCY,
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserPositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// first we have to figure out how much bigger the frame is than the view
RECT frameRect, viewRect;
pThis->GetWindowRect(&frameRect);
pThis->m_wndBrowserView.GetClientRect(&viewRect);
int deltax = (frameRect.right-frameRect.left)-(viewRect.right-viewRect.left);
int deltay = (frameRect.bottom-frameRect.top)-(viewRect.bottom-viewRect.top);
pThis->SetWindowPos(NULL, aX, aY, aCX+deltax, aCY+(deltay/2),
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetFocus(){
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetFocus();
}
void CBrowserFrame::BrowserFrameGlueObj::FocusAvailable(PRBool *aFocusAvail)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
HWND focusWnd = ::GetFocus();
if ((focusWnd == pThis->m_hWnd) || ::IsChild(pThis->m_hWnd, focusWnd))
*aFocusAvail = PR_TRUE;
else
*aFocusAvail = PR_FALSE;
}
void CBrowserFrame::BrowserFrameGlueObj::ShowBrowserFrame(PRBool aShow)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aShow){
pThis->ShowWindow(SW_SHOW);
pThis->SetActiveWindow();
pThis->UpdateWindow();
}else{
pThis->ShowWindow(SW_HIDE);
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameVisibility(PRBool *aVisible)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Is the current BrowserFrame the active one?
if (GetActiveWindow()->m_hWnd != pThis->m_hWnd){
*aVisible = PR_FALSE;
return;
}
// We're the active one
//Return FALSE if we're minimized
WINDOWPLACEMENT wpl;
pThis->GetWindowPlacement(&wpl);
if ((wpl.showCmd == SW_RESTORE) || (wpl.showCmd == SW_MAXIMIZE))
*aVisible = PR_TRUE;
else
*aVisible = PR_FALSE;
}
PRBool CBrowserFrame::BrowserFrameGlueObj::CreateNewBrowserFrame(PRUint32 chromeMask,
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull;
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return PR_FALSE;
// Note that we're calling with the last param set to "false" i.e.
// this instructs not to show the frame window
// This is mainly needed when the window size is specified in the window.open()
// JS call. In those cases Gecko calls us to create the browser with a default
// size (all are -1) and then it calls the SizeBrowserTo() method to set
// the proper window size. If this window were to be visible then you'll see
// the window size changes on the screen causing an unappealing flicker
CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_FALSE);
if(!pFrm)
return PR_FALSE;
// At this stage we have a new CBrowserFrame and a new CBrowserView
// objects. The CBrowserView also would have an embedded browser
// object created. Get the mWebBrowser member from the CBrowserView
// and return it. (See CBrowserView's CreateBrowser() on how the
// embedded browser gets created and how it's mWebBrowser member
// gets initialized)
NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser);
return PR_TRUE;
}
void CBrowserFrame::BrowserFrameGlueObj::DestroyBrowserFrame()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->PostMessage(WM_CLOSE);
}
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
char *menuType = _T("DocumentPopup");
if(aContextFlags & nsIContextMenuListener::CONTEXT_DOCUMENT)
menuType = _T("DocumentPopup");
else if((aContextFlags & nsIContextMenuListener::CONTEXT_TEXT) || (aContextFlags & nsIContextMenuListener::CONTEXT_INPUT))
menuType = _T("TextPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
{
menuType = _T("LinkPopup");
// Since we handle all the browser menu/toolbar commands
// in the View, we basically setup the Link's URL in the
// BrowserView object. When a menu selection in the context
// menu is made, the appropriate command handler in the
// BrowserView will be invoked and the value of the URL
// will be accesible in the view
// Reset the value from the last invocation
// (A new value will be set after we determine it below)
//
nsAutoString strUrlUcs2;
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
// Get the URL from the link. This is two step process
// 1. We first get the nsIDOMHTMLAnchorElement
// 2. We then get the URL associated with the link
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv)){
nsCOMPtr<nsIDOMNode> parentNode;
aNode->GetParentNode(getter_AddRefs(parentNode));
linkElement = do_QueryInterface(parentNode, &rv);
if (NS_FAILED(rv)){
return;
}
}
rv = linkElement->GetHref(strUrlUcs2);
if(NS_FAILED(rv))
return;
// Update the view with the new LinkUrl
// Note that this string is in UCS2 format
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
}
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE) {
if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
nsAutoString strImgSrcUcs2;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Clear it
// Get the IMG SRC
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv))
return;
rv = imgElement->GetSrc(strImgSrcUcs2);
if(NS_FAILED(rv))
return;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
}
CMenu *ctxMenu = theApp.menus.GetMenu(menuType);
if(ctxMenu)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
int offset = theApp.menus.GetOffset(ctxMenu);
RECT desktopRect;
GetDesktopWindow()->GetWindowRect(&desktopRect);
if ( (int)(cursorPos.y - offset) < (int)(desktopRect.bottom - (ctxMenu->GetMenuItemCount() * GetSystemMetrics(SM_CYMENUSIZE)) + (GetSystemMetrics(SM_CYEDGE)*2)) ){
// we only do this if we're not too close to the bottom of the screen
cursorPos.y -= offset;
if (cursorPos.y < 0){
cursorPos.y = 0;
}
}
ctxMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, cursorPos.x, cursorPos.y, pThis);
}
}
HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
return pThis->m_hWnd;
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateSecurityStatus(PRInt32 aState)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->UpdateSecurityStatus(aState);
}

@ -0,0 +1,637 @@
/* -*- 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>
*/
// File Overview....
//
// The typical MFC View, toolbar, statusbar creation done
// in CBrowserFrame::OnCreate()
//
// Code to update the Status/Tool bars in response to the
// Web page loading progress(called from methods in CBrowserImpl)
//
// SetupFrameChrome() determines what, if any, UI elements this Frame
// will sport based on the current "chromeMask"
//
// Also take a look at OnClose() which gets used when you close a browser
// window. This needs to be overrided mainly to handle supporting multiple
// browser frame windows via the "New Browser Window" menu item
// Without this being overridden the MFC framework handles the OnClose and
// shutsdown the complete application when a frame window is closed.
// In our case, we want the app to shutdown when the File/Exit menu is chosen
//
// Another key functionality this object implements is the IBrowserFrameGlue
// interface - that's the interface the Gecko embedding interfaces call
// upong to update the status bar etc.
// (Take a look at IBrowserFrameGlue.h for the interface definition and
// the BrowserFrm.h to see how we implement this interface - as a nested
// class)
// We pass this Glue object pointer to the CBrowserView object via the
// SetBrowserFrameGlue() method. The CBrowserView passes this on to the
// embedding interface implementaion
//
// Please note the use of the macro METHOD_PROLOGUE in the implementation
// of the nested BrowserFrameGlue object. Essentially what this macro does
// is to get you access to the outer (or the object which is containing the
// nested object) object via the pThis pointer.
// Refer to the AFXDISP.H file in VC++ include dirs
//
// Next suggested file to look at : BrowserView.cpp
#include "stdafx.h"
#include "BrowserFrm.h"
#include "BrowserView.h"
#include "ToolBarEx.h"
#include "KmeleonConst.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame
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()
ON_WM_SYSCOLORCHANGE()
ON_MESSAGE(UWM_REFRESHTOOLBARITEM, RefreshToolBarItem)
ON_COMMAND_RANGE(TOOLBAR_MENU_START_ID, TOOLBAR_MENU_END_ID, ToggleToolBar)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // For the Status line
ID_PROG_BAR, // For the Progress Bar
ID_SEPARATOR
};
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame construction/destruction
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.
m_chromeMask = chromeMask;
m_created = FALSE;
}
CBrowserFrame::~CBrowserFrame()
{
}
void CBrowserFrame::OnClose()
{
// if we don't do this, then our menu will be destroyed when the first window is.
// that's bad because our menu is shared between all windows
SetMenu(NULL);
// Make sure we don't leave screen residue
if (m_wndBrowserView.mWebNav)
m_wndBrowserView.mWebNav->Stop(nsIWebNavigation::STOP_ALL);
// the browserframeglue will be deleted soon, so we set it to null so it won't try to access it after it's deleted.
m_wndBrowserView.SetBrowserFrameGlue(NULL);
m_wndReBar.SaveBandSizes();
if (theApp.m_pMostRecentBrowserFrame == this) {
CBrowserFrame* pFrame;
POSITION pos = theApp.m_FrameWndLst.Find(this);
theApp.m_FrameWndLst.GetPrev(pos);
if (pos) pFrame = (CBrowserFrame *) theApp.m_FrameWndLst.GetPrev(pos); // previous frame
else pFrame = (CBrowserFrame *) theApp.m_FrameWndLst.GetTail(); // last frame
if (pFrame != this) theApp.m_pMostRecentBrowserFrame = pFrame;
else theApp.m_pMostRecentBrowserFrame = NULL;
// if no other browser views exist, nullify the pointer
}
DestroyWindow();
theApp.RemoveFrameFromList(this);
}
// This is where the UrlBar, ToolBar, StatusBar, ProgressBar
// get created
//
int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// tell all our plugins that we were created
theApp.plugins.OnCreate(this->m_hWnd);
// 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);
// 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
}
// Load the Most Recently Used(MRU) Urls into the UrlBar
m_wndUrlBar.LoadMRUList();
// Create the toolbar with Back, Fwd, Stop, etc. buttons..
if (!m_wndToolBar.CreateEx (this, 0x40 | /*CCS_NOPARENTALIGN | CCS_NORESIZE | */ TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE | TBSTYLE_TOOLTIPS) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// back, forward, stop, reload, home, search, print
UINT buttons[7] = {
ID_NAV_BACK,
ID_NAV_FORWARD,
ID_NAV_STOP,
ID_NAV_RELOAD,
ID_NAV_HOME,
ID_NAV_SEARCH,
ID_FILE_PRINT
};
HBITMAP bitmap;
m_toolbarColdImageList.Create(16, 16, ILC_MASK, 16, 32);
bitmap = (HBITMAP)LoadImage(NULL, theApp.preferences.settingsDir + "Tool1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
ImageList_AddMasked(m_toolbarColdImageList.m_hImageList, bitmap, RGB(192, 192, 192));
DeleteObject(bitmap);
m_wndToolBar.GetToolBarCtrl().SetImageList(&m_toolbarColdImageList);
m_toolbarHotImageList.Create(16, 16, ILC_MASK, 16, 32);
bitmap = (HBITMAP)LoadImage(NULL, theApp.preferences.settingsDir + "Tool2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
ImageList_AddMasked(m_toolbarHotImageList.m_hImageList, bitmap, RGB(192, 192, 192));
DeleteObject(bitmap);
m_wndToolBar.GetToolBarCtrl().SetHotImageList(&m_toolbarHotImageList);
m_wndToolBar.SetButtons(buttons, 7);
m_wndUrlBar.SetImageList(&m_toolbarHotImageList);
// Create the animation control..
if (!m_wndAnimate.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 10, 10), this, AFX_IDW_TOOLBAR + 2))
{
TRACE0("Failed to create animation\n");
return -1; // fail to create
}
if (!m_wndAnimate.Open(theApp.preferences.settingsDir + "Throbber.avi")){
m_wndAnimate.Open("Throbber.avi");
}
// 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, NULL);
m_wndReBar.AddBar(&m_wndUrlBar, "URL:");
m_wndReBar.AddBar(&m_wndAnimate, NULL, NULL, RBBS_FIXEDSIZE | RBBS_FIXEDBMP);
m_wndReBar.RegisterBand(m_wndToolBar.m_hWnd, "Tool Bar", true);
m_wndReBar.RegisterBand(m_wndUrlBar.m_hWnd, "URL Bar", true);
// m_wndReBar.RegisterBand(m_wndAnimate.m_hWnd, "Throbber");
//--------------------------------------------------------------
// Set up min/max sizes and ideal sizes for pieces of the rebar:
//--------------------------------------------------------------
CReBarCtrl *rebarControl = &m_wndReBar.GetReBarCtrl();
// Address Bar
CRect rectAddress;
m_wndUrlBar.GetEditCtrl()->GetWindowRect(&rectAddress);
REBARBANDINFO rbbi;
rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE;
rbbi.cxMinChild = 0;
rbbi.cyMinChild = rectAddress.Height() + 7;
rbbi.cxIdeal = 200;
rbbi.cx = 200;
rebarControl->SetBandInfo (1, &rbbi);
// Toolbar
CRect rectToolBar;
m_wndToolBar.GetItemRect(0, &rectToolBar);
rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE;
rbbi.cxMinChild = 0;
rbbi.cyMinChild = rectToolBar.Height();
rbbi.cxIdeal = rectToolBar.Width() * m_wndToolBar.GetCount();
rbbi.cx = rbbi.cxIdeal + 10;
rebarControl->SetBandInfo (0, &rbbi);
theApp.plugins.DoRebars(m_wndReBar.GetReBarCtrl().m_hWnd);
m_wndReBar.RestoreBandSizes();
LoadBackImage();
SetBackImage();
// 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
}
m_wndStatusBar.SetPaneStyle(m_wndStatusBar.CommandToIndex(ID_SEPARATOR), SBPS_STRETCH);
// 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 (m_wndStatusBar.CommandToIndex(ID_PROG_BAR), &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);
// Also, set the padlock icon to be the insecure icon to begin with
UpdateSecurityStatus(nsIWebProgressListener::STATE_IS_INSECURE);
// 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()
SetupFrameChrome();
return 0;
}
void CBrowserFrame::SetupFrameChrome()
{
if(m_chromeMask == nsIWebBrowserChrome::CHROME_ALL){
return;
}
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_STATUSBAR) )
m_wndStatusBar.ShowWindow(SW_HIDE); // Hide the StatusBar
}
BOOL CBrowserFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
// Change window style based on the chromeMask
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;
}
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame message handlers
void CBrowserFrame::OnSetFocus(CWnd* pOldWnd)
{
if (theApp.m_pMostRecentBrowserFrame != this) {
theApp.m_pMostRecentBrowserFrame = this;
// update session history for the current window
PostMessage(UWM_UPDATESESSIONHISTORY, 0, 0);
}
// forward focus to the browser window
m_wndBrowserView.SetFocus();
}
void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) {
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
m_wndBrowserView.Activate(nState, pWndOther, bMinimized);
}
#define IS_SECURE(state) ((state & 0xFFFF) == nsIWebProgressListener::STATE_IS_SECURE)
void CBrowserFrame::UpdateSecurityStatus(PRInt32 aState)
{
int iResID = nsIWebProgressListener::STATE_IS_INSECURE;
if(IS_SECURE(aState)) {
iResID = IDR_SECURITY_LOCK;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_SECURE;
}
else if(aState == nsIWebProgressListener::STATE_IS_INSECURE) {
iResID = IDR_SECURITY_UNLOCK;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_INSECURE;
}
else if(aState == nsIWebProgressListener::STATE_IS_BROKEN) {
iResID = IDR_SECURITY_BROKEN;
m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_BROKEN;
}
CStatusBarCtrl& sb = m_wndStatusBar.GetStatusBarCtrl();
sb.SetIcon(2, //2 is the pane index of the status bar where the lock icon will be shown
(HICON)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(iResID), IMAGE_ICON, 16,16,0));
}
void CBrowserFrame::ShowSecurityInfo()
{
m_wndBrowserView.ShowSecurityInfo();
}
// CMyStatusBar Class
CMyStatusBar::CMyStatusBar() {}
CMyStatusBar::~CMyStatusBar() {}
BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar)
//{{AFX_MSG_MAP(CMyStatusBar)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
{
// Check to see if the mouse click was within the
// padlock icon pane(at pane index 2) of the status bar...
RECT rc;
GetItemRect(2, &rc );
if(PtInRect(&rc, point)) {
CBrowserFrame *pFrame = (CBrowserFrame *)GetParent();
if(pFrame != NULL)
pFrame->ShowSecurityInfo();
}
CStatusBar::OnLButtonDown(nFlags, point);
}
BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (nCode == CN_COMMAND){
if (pHandlerInfo && theApp.plugins.OnUpdate(nID)){
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);
}
// Needed to properly position/resize the progress bar
//
void CBrowserFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);