Browse Source

New skin and toolbar

import/tags/kmeleon75b1
boisso 8 years ago
parent
commit
d9a157e527
  1. 171
      k-meleon/BrowserFrm.cpp
  2. 10
      k-meleon/BrowserFrm.h
  3. 2
      k-meleon/BrowserImplCtxMenuLstnr.cpp
  4. 81
      k-meleon/Dialogs.cpp
  5. 480
      k-meleon/FavIconList.cpp
  6. 23
      k-meleon/FavIconList.h
  7. 10
      k-meleon/KMeleon.vcxproj
  8. 4
      k-meleon/KmAppInfo.cpp
  9. 17
      k-meleon/KmCommand.cpp
  10. 5
      k-meleon/KmCommand.h
  11. 577
      k-meleon/KmImage.cpp
  12. 111
      k-meleon/KmImage.h
  13. 127
      k-meleon/KmInstaller.h
  14. 325
      k-meleon/KmSkin.cpp
  15. 211
      k-meleon/KmSkin.h
  16. 227
      k-meleon/KmToolbar.cpp
  17. 135
      k-meleon/KmToolbar.h
  18. 95
      k-meleon/MfcEmbed.cpp
  19. 7
      k-meleon/MfcEmbed.h
  20. 19
      k-meleon/MfcEmbed.rc
  21. 71
      k-meleon/MozUtils.cpp
  22. 2
      k-meleon/MozUtils.h
  23. 135
      k-meleon/Plugins.cpp
  24. 1
      k-meleon/Plugins.h
  25. 41
      k-meleon/Preferences.cpp
  26. 6
      k-meleon/ProfileMgr.cpp
  27. 57
      k-meleon/TabReBar.cpp
  28. 2
      k-meleon/TabReBar.h
  29. 189
      k-meleon/ToolBarEx.cpp
  30. 8
      k-meleon/ToolBarEx.h
  31. 33
      k-meleon/UnknownContentTypeHandler.cpp
  32. 60
      k-meleon/bmp_menu/bmp_menu.cpp
  33. 4
      k-meleon/defineMap.cpp
  34. 26
      k-meleon/kmeleon_plugin.h
  35. 2
      k-meleon/login/mozilla.h
  36. 58
      k-meleon/resource.h
  37. 319
      k-meleon/toolbars/toolbars.cpp

171
k-meleon/BrowserFrm.cpp

@ -128,20 +128,22 @@ BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd)
ON_COMMAND(ID_EDIT_FIND, OnShowFindBar)
ON_COMMAND(ID_VIEW_STATUS_BAR, OnViewStatusBar)
ON_NOTIFY(RBN_LAYOUTCHANGED, AFX_IDW_REBAR, OnRbnLayoutChanged)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xffff, OnToolTipText)
ON_COMMAND(ID_EDIT_FINDNEXT, OnFindNext)
ON_COMMAND(ID_EDIT_FINDPREV, OnFindPrev)
ON_COMMAND(IDC_WRAP_AROUND, OnWrapAround)
ON_COMMAND(IDC_MATCH_CASE, OnMatchCase)
ON_COMMAND(IDC_HIGHLIGHT, OnHighlight)
ON_COMMAND(ID_WRAP_AROUND, OnWrapAround)
ON_COMMAND(ID_MATCH_CASE, OnMatchCase)
ON_COMMAND(ID_HIGHLIGHT, OnHighlight)
ON_COMMAND(ID_MAXIMIZE_WINDOW,OnMaximizeWindow)
ON_COMMAND(ID_MINIMIZE_WINDOW,OnMinimizeWindow)
ON_COMMAND(ID_RESTORE_WINDOW, OnRestoreWindow)
ON_COMMAND(ID_TOGGLE_WINDOW, OnToggleWindow)
ON_MESSAGE(TB_LBUTTONHOLD, OnToobarContextMenu)
ON_MESSAGE(TB_RBUTTONDOWN, OnToobarContextMenu)
ON_MESSAGE(TB_LBUTTONHOLD, OnToolbarContextMenu)
ON_MESSAGE(TB_RBUTTONDOWN, OnToolbarContextMenu)
ON_MESSAGE(TB_LBUTTONDOWN, OnToolbarCommand)
// ON_MESSAGE(WM_ENTERSIZEMOVE, OnEnterSizeMove)
// ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
@ -154,8 +156,6 @@ END_MESSAGE_MAP()
#define PREF_TOOLBAND_LOCKED "kmeleon.general.toolbars_locked"
CBitmap CBrowserFrame::m_bmpBack;
/////////////////////////////////////////////////////////////////////////////
// CBrowserFrame construction/destruction
@ -397,14 +397,15 @@ int CBrowserFrame::InitLayout()
// Create the animation control..
BOOL bThrobber = TRUE;
if (!m_wndAnimate.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 10, 10), this, ID_THROBBER))
if (!m_wndAnimate.Create(WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT, CRect(0, 0, 10, 10), this, ID_THROBBER))
{
TRACE0("Failed to create animation\n");
bThrobber = FALSE;
}
CString throbberPath;
theApp.FindSkinFile(throbberPath, _T("Throbber.avi"));
theApp.skin.FindSkinFile(throbberPath, _T("Throbber.avi"));
if (!m_wndAnimate.Open(throbberPath))
bThrobber = FALSE;
@ -445,8 +446,10 @@ int CBrowserFrame::InitLayout()
if (!theApp.preferences.GetBool("kmeleon.display.statusbar", TRUE))
m_wndStatusBar.ShowWindow(SW_HIDE);
if (!IsDialog())
theApp.plugins.SendMessage("*", "* OnCreate", "DoRebar", (long)m_wndReBar.GetReBarCtrl().m_hWnd);
if (!IsDialog()) {
theApp.plugins.SendMessage("*", "* OnCreate", "DoRebar", (long)m_wndReBar.GetReBarCtrl().m_hWnd);
theApp.toolbars.InitWindows(&m_wndReBar);
}
m_wndReBar.RestoreBandSizes();
//m_wndReBar.LockBars(theApp.preferences.GetBool(PREF_TOOLBAND_LOCKED, false));
@ -468,7 +471,6 @@ int CBrowserFrame::InitLayout()
theApp.plugins.SendMessage("*", "* OnCreate", "DoSidebar", (long)m_wndSideBar.m_hWnd);
#endif
LoadBackImage();
SetBackImage();
// Based on the "chromeMask" we were supplied during construction
@ -562,6 +564,9 @@ BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERIN
}
}
if (theApp.commands.IsPluginCommand(nID) && theApp.toolbars.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// Don't let MFC mess with plugin command
if (nCode == CN_UPDATE_COMMAND_UI && (theApp.commands.IsPluginCommand(nID)
|| IsMenu(COMMAND_TO_MENU(nID)))) {
@ -871,7 +876,7 @@ void CMyStatusBar::RefreshPanes()
if( pFrame!=NULL )
pFrame->m_wndProgressBar.MoveWindow(&rc);
delete indicators;
delete [] indicators;
}
BOOL CMyStatusBar::RemoveIcon(UINT nID)
@ -907,7 +912,7 @@ BOOL CMyStatusBar::SetIconInfo(UINT nID, HICON hIcon, LPCTSTR tpText)
if (tpText) GetStatusBarCtrl().SetTipText(index, tpText);
}
else {
if (ii->hIcon) DestroyIcon(ii->hIcon);
//if (ii->hIcon) DestroyIcon(ii->hIcon); // Let the owner handle it
ii->hIcon = hIcon;
// Better way to get the width ?
@ -1141,30 +1146,28 @@ void CBrowserFrame::OnSysColorChange()
//-------------------------
// Reload background image:
//-------------------------
m_bmpBack.DeleteObject();
LoadBackImage ();
SetBackImage ();
//m_bmpBack.DeleteObject();
//SetBackImage ();
}
/////////////////////////////////////////////////////////////////////////////
void CBrowserFrame::SetBackImage()
{
if (m_bmpBack.GetSafeHandle() == NULL)
return;
HBITMAP bmpBack = theApp.skin.GetBackImage();
if (!bmpBack) return;
CReBarCtrl& rc = m_wndReBar.GetReBarCtrl ();
REBARBANDINFO info;
memset (&info, 0, sizeof (REBARBANDINFO));
info.cbSize = sizeof (info);
info.hbmBack = theApp.preferences.bToolbarBackground ? (HBITMAP)m_bmpBack : NULL;
info.hbmBack = theApp.preferences.bToolbarBackground ? (HBITMAP)bmpBack : NULL;
int count = rc.GetBandCount();
for (int i = 0; i < count; i++) {
info.fMask = RBBIM_BACKGROUND;
BOOL blah = rc.SetBandInfo (i, &info);
CRect rectBand;
/* CRect rectBand;
rc.GetRect (i, rectBand);
rc.InvalidateRect (rectBand);
@ -1177,8 +1180,10 @@ void CBrowserFrame::SetBackImage()
{
::InvalidateRect (info.hwndChild, NULL, TRUE);
::UpdateWindow (info.hwndChild);
}
}*/
}
m_wndReBar.RedrawWindow(0, 0, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
#ifdef INTERNAL_SIDEBAR
// Set the backimage to the sidebar title too
CReBarCtrl& rc2 = m_wndSideBar.m_wndRebar.GetReBarCtrl();
@ -1188,24 +1193,6 @@ void CBrowserFrame::SetBackImage()
}
/////////////////////////////////////////////////////////////////////////////
void CBrowserFrame::LoadBackImage (BOOL force)
{
//------------------------------------
// Load control bars background image:
//------------------------------------
if (!force && m_bmpBack.GetSafeHandle () != NULL)
return;
CString skinFile;
if (theApp.FindSkinFile(skinFile, _T("Back.bmp")))
{
HBITMAP hbmp = (HBITMAP) ::LoadImage (NULL,
skinFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_bmpBack.DeleteObject();
m_bmpBack.Attach (hbmp);
}
}
LRESULT CBrowserFrame::RefreshMRUList(WPARAM ItemID, LPARAM unused)
{
@ -1632,23 +1619,21 @@ void CBrowserFrame::UpdateSecurityStatus(PRInt32 aState)
UINT tpTextId, iconResID;
TCHAR* icoFile;
HICON securityIcon = NULL;
if(aState & nsIWebProgressListener::STATE_IS_INSECURE) {
iconResID = IDI_SECURITY_UNLOCK;
securityIcon = theApp.skin.GetIconInsecure();
m_wndUrlBar.Highlight(0);
tpTextId = IDS_SECURITY_UNLOCK;
icoFile = _T("sinsecur.ico");
}
else if(aState & nsIWebProgressListener::STATE_IS_BROKEN) {
iconResID = IDI_SECURITY_BROKEN;
securityIcon = theApp.skin.GetIconBroken();
m_wndUrlBar.Highlight(2);
tpTextId = IDS_SECURITY_BROKEN;
icoFile = _T("sbroken.ico");
}
else if(aState & nsIWebProgressListener::STATE_IS_SECURE) {
iconResID = IDI_SECURITY_LOCK;
securityIcon = theApp.skin.GetIconSecure();
m_wndUrlBar.Highlight(1);
tpTextId = IDS_SECURITY_LOCK;
icoFile = _T("ssecur.ico");
}
else
{
@ -1658,17 +1643,7 @@ void CBrowserFrame::UpdateSecurityStatus(PRInt32 aState)
CString tpText;
tpText.LoadString(tpTextId);
HICON hTmpSecurityIcon;
CString skinFile;
if (theApp.FindSkinFile(skinFile, icoFile))
hTmpSecurityIcon = (HICON)::LoadImage(AfxGetResourceHandle(),
skinFile, IMAGE_ICON, 16,16,LR_LOADFROMFILE);
else
hTmpSecurityIcon = (HICON)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(iconResID), IMAGE_ICON, 16,16,LR_LOADMAP3DCOLORS);
m_wndStatusBar.SetIconInfo(ID_SECURITY_STATE_ICON, hTmpSecurityIcon, tpText);
m_wndStatusBar.SetIconInfo(ID_SECURITY_STATE_ICON, securityIcon, tpText);
}
void CBrowserFrame::UpdateStatus(LPCTSTR aStatus)
@ -1740,19 +1715,10 @@ void CBrowserFrame::UpdatePopupNotification(LPCTSTR uri)
{
if (uri && *uri) {
if (m_wndStatusBar.AddIcon(ID_POPUP_BLOCKED_ICON)) {
HICON hTmpPopupIcon;
CString skinFile;
if (theApp.FindSkinFile(skinFile, _T("popupblock.ico")))
hTmpPopupIcon = (HICON)::LoadImage(AfxGetResourceHandle(),
skinFile, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
else
hTmpPopupIcon = (HICON)::LoadImage(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDI_POPUP_BLOCKED), IMAGE_ICON, 16,16,LR_LOADMAP3DCOLORS);
HICON popupIcon = theApp.skin.GetIconPopupBlock();
CString tpText;
tpText.Format(IDS_POPUP_BLOCKED, uri);
m_wndStatusBar.SetIconInfo(ID_POPUP_BLOCKED_ICON, hTmpPopupIcon, tpText);
m_wndStatusBar.SetIconInfo(ID_POPUP_BLOCKED_ICON, popupIcon, tpText);
}
}
else
@ -1830,22 +1796,62 @@ void CBrowserFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
}
}
LRESULT CBrowserFrame::OnToobarContextMenu(WPARAM wParam, LPARAM lParam)
LRESULT CBrowserFrame::OnToolbarCommand(WPARAM wParam, LPARAM lParam)
{
if (wParam == ID_NAV_BACK || wParam == ID_NAV_FORWARD)
{
CRect rc;
CToolBar* toolbar = (CToolBar*)CWnd::FromHandle((HWND)lParam);
if (toolbar)
{
CToolBar* toolbar = (CToolBar*)CWnd::FromHandle((HWND)lParam);
if (!toolbar) return CWnd::Default();
KmToolbar* ktoolbar = (KmToolbar*)::GetProp(toolbar->GetSafeHwnd(), _T("kmToolbar"));
if (!ktoolbar) return CWnd::Default();
KmButton* button = ktoolbar->GetButton(wParam);
if (!button) {
CPoint p;
::GetCursorPos(&p);
if (!IsZoomed()) {
SendMessage(WM_SYSCOMMAND, SC_MOVE+1, MAKELPARAM(p.x,p.y));
return 1;
}
return CWnd::Default();
}
if (button->mAction[0] == _T('@')) {
CMenu* menu = theApp.menus.GetMenu(button->mAction.Mid(1));
if (menu) {
CRect rc;
toolbar->GetItemRect(toolbar->CommandToIndex(wParam), &rc);
CPoint pt(rc.left, rc.bottom);
toolbar->ClientToScreen(&pt);
menu->TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
}
}
return CWnd::Default();
}
LRESULT CBrowserFrame::OnToolbarContextMenu(WPARAM wParam, LPARAM lParam)
{
CToolBar* toolbar = (CToolBar*)CWnd::FromHandle((HWND)lParam);
if (toolbar) {
CPoint pt;
if (wParam) {
CRect rc;
toolbar->GetItemRect(toolbar->CommandToIndex(wParam), &rc);
pt.SetPoint(rc.left, rc.bottom);
toolbar->ClientToScreen(&pt);
} else
GetCursorPos(&pt);
if (wParam == ID_NAV_BACK || wParam == ID_NAV_FORWARD) {
CMenu menu;
menu.CreatePopupMenu();
wParam == ID_NAV_BACK ? DrawSHBackMenu(menu.GetSafeHmenu()) : DrawSHForwardMenu(menu.GetSafeHmenu());
menu.TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
} else {
KmToolbar* ktoolbar = (KmToolbar*)::GetProp(toolbar->GetSafeHwnd(), _T("kmToolbar"));
if (ktoolbar) {
KmButton* button = ktoolbar->GetButton(wParam);
CMenu* menu = button ? theApp.menus.GetMenu(button->mMenuName) : theApp.menus.GetMenu(_T("Toolbars"));
if (menu) menu->TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
}
}
}
return CWnd::Default();
@ -1853,5 +1859,14 @@ LRESULT CBrowserFrame::OnToobarContextMenu(WPARAM wParam, LPARAM lParam)
void CBrowserFrame::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
GetActiveView()->OnMenuSelect(nItemID, nFlags, hSysMenu);
if (GetActiveView()->OnMenuSelect(nItemID, nFlags, hSysMenu))
return;
CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu);
}
BOOL CBrowserFrame::OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
return CFrameWnd::OnToolTipText(id, pNMHDR, pResult);
}

10
k-meleon/BrowserFrm.h

@ -228,7 +228,6 @@ public:
CSideBar m_wndSideBar;
#endif
static CBitmap m_bmpBack;
friend CBrowserGlue;
DECLARE_DYNAMIC(CBrowserFrame);
@ -260,15 +259,14 @@ public:
INT_PTR DoModal();
HWND CreateToolbar(UINT style);
void SetBackImage ();
protected:
int InitLayout();
void SetupFrameChrome();
void LoadBackImage (BOOL force = FALSE);
void SetBackImage ();
void SaveWindowPos();
void OnFind(BOOL backward = FALSE);
#ifdef INTERNAL_SITEICONS
@ -332,6 +330,7 @@ protected:
afx_msg LRESULT OnEnterSizeMove(WPARAM, LPARAM);
afx_msg LRESULT OnExitSizeMove(WPARAM, LPARAM);
afx_msg void OnRbnLayoutChanged(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
afx_msg void OnUpdateViewStatusBar(CCmdUI* pCmdUI);
afx_msg void OnUpdateNothing(CCmdUI* pCmdUI) { pCmdUI->Enable(); };
@ -354,7 +353,8 @@ protected:
afx_msg void OnMinimizeWindow();
afx_msg void OnRestoreWindow();
afx_msg void OnToggleWindow();
afx_msg LRESULT OnToobarContextMenu(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnToolbarContextMenu(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnToolbarCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
//}}AFX_MSG

2
k-meleon/BrowserImplCtxMenuLstnr.cpp

@ -74,7 +74,7 @@ NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIContext
// Mozilla don't tell if the input is of type text or password...
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(node));
if (inputElement) {
nsEmbedString inputElemType;
nsString inputElemType;
inputElement->GetType(inputElemType);
if ((wcsicmp(inputElemType.get(), L"text") == 0) ||
(wcsicmp(inputElemType.get(), L"password") == 0))

81
k-meleon/Dialogs.cpp

@ -43,6 +43,7 @@
#include "BrowserView.h"
#include "MfcEmbed.h"
#include "resource.h"
#include "KmImage.h"
extern CMfcEmbedApp theApp;
//--------------------------------------------------------------------------//
@ -203,7 +204,7 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
::SetWindowTextW(hWnd, m_szUStr);
}else{
#endif
m_cEdit.Create(WS_CHILD|ES_AUTOHSCROLL, CRect(0,0,150,18), this, IDC_FIND_EDIT);
m_cEdit.Create(WS_CHILD|ES_AUTOHSCROLL, CRect(0,0,250,100), this, IDC_FIND_EDIT);
m_cEdit.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_cEdit.SetWindowText(m_csSearchStr);
#ifndef _UNICODE
@ -212,68 +213,34 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
str.LoadString(IDS_FIND);
AddBar(&m_cEdit, str, NULL, RBBS_NOGRIPPER);
m_cEdit.SetWindowPos(NULL, 0, 0, 250, 100, SW_NORMAL);
// Toolbar with next/Previous and options
m_cToolbar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | TBSTYLE_TOOLTIPS
);//,WS_CHILD|WS_VISIBLE|CBRS_FLYBY);
m_cToolbar.GetToolBarCtrl().SetImageList(NULL);
HDC hdcBitmap = CreateCompatibleDC(NULL);
struct {
BITMAPINFOHEADER header;
COLORREF col[256];
} bmpi = {0};
bmpi.header.biSize = sizeof(BITMAPINFOHEADER);
CString skinFile;
if (theApp.FindSkinFile(skinFile, _T("findhot.bmp")))
{
m_ilHot.Create(16, 16, ILC_MASK | ILC_COLOR32, 6, 1);
HBITMAP bitmap = (HBITMAP)LoadImage(NULL, skinFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
if (bitmap) {
GetDIBits(hdcBitmap, bitmap, 0, 0, NULL, (BITMAPINFO*)&bmpi, DIB_RGB_COLORS);
if (bmpi.header.biBitCount == 32)
ImageList_Add(m_ilHot.GetSafeHandle(), bitmap, NULL);
else
ImageList_AddMasked(m_ilHot.GetSafeHandle(), bitmap, RGB(255,0,255));
DeleteObject(bitmap);
bool useSkinList = true;
if (!theApp.skin.SetImageList(m_cToolbar.GetToolBarCtrl())) {
useSkinList = false;
KmImage img;
int cxIcon = 16;//GetSystemMetrics(SM_CXSMICON);
if (img.LoadFromSkin(_T("findhot.bmp"))) {
m_ilHot.Create(cxIcon, cxIcon, ILC_MASK | ILC_COLOR32, 6, 1);
img.AddToImageList(m_ilHot);
m_cToolbar.GetToolBarCtrl().SetHotImageList(&m_ilHot);
}
}
if (theApp.FindSkinFile(skinFile, _T("findcold.bmp")))
{
m_ilCold.Create(16, 16, ILC_MASK | ILC_COLOR32, 6, 1);
HBITMAP bitmap = (HBITMAP)LoadImage(NULL, skinFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
if (bitmap) {
GetDIBits(hdcBitmap, bitmap, 0, 0, NULL, (BITMAPINFO*)&bmpi, DIB_RGB_COLORS);
if (bmpi.header.biBitCount == 32)
ImageList_Add(m_ilCold.GetSafeHandle(), bitmap, NULL);
else
ImageList_AddMasked(m_ilCold.GetSafeHandle(), bitmap, RGB(255,0,255));
DeleteObject(bitmap);
if (img.LoadFromSkin(_T("findcold.bmp"))) {
m_ilCold.Create(cxIcon, cxIcon, ILC_MASK | ILC_COLOR32, 6, 1);
img.AddToImageList(m_ilCold);
m_cToolbar.GetToolBarCtrl().SetImageList(&m_ilCold);
}
}
if (theApp.FindSkinFile(skinFile, _T("finddead.bmp")))
{
m_ilDead.Create(16, 16, ILC_MASK | ILC_COLOR32, 6, 1);
HBITMAP bitmap = (HBITMAP)LoadImage(NULL, skinFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
if (bitmap) {
GetDIBits(hdcBitmap, bitmap, 0, 0, NULL, (BITMAPINFO*)&bmpi, DIB_RGB_COLORS);
if (bmpi.header.biBitCount == 32)
ImageList_Add(m_ilDead.GetSafeHandle(), bitmap, NULL);
else
ImageList_AddMasked(m_ilDead.GetSafeHandle(), bitmap, RGB(255,0,255));
DeleteObject(bitmap);
m_cToolbar.GetToolBarCtrl().SetImageList(&m_ilDead);
if (img.LoadFromSkin(_T("finddead.bmp"))) {
m_ilCold.Create(cxIcon, cxIcon, ILC_MASK | ILC_COLOR32, 6, 1);
img.AddToImageList(m_ilDead);
m_cToolbar.GetToolBarCtrl().SetDisabledImageList(&m_ilDead);
}
}
DeleteDC(hdcBitmap);
TBBUTTON button = {0};
button.fsState = TBSTATE_ENABLED;
@ -282,6 +249,7 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
//int stringID = toolbar->GetToolBarCtrl().AddString(IDS_FINDNEXT);
int stringID=-1;
button.idCommand = ID_EDIT_FINDNEXT;
button.iBitmap = useSkinList ? theApp.skin.GetIconIndex(ID_EDIT_FINDNEXT) : 0;
button.iString =stringID;
m_cToolbar.GetToolBarCtrl().InsertButton(0,&button);
@ -290,7 +258,7 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
//stringID = toolbar->GetToolBarCtrl().AddString(IDS_FINDPREV);
button.idCommand = ID_EDIT_FINDPREV;
button.iBitmap = 1;
button.iBitmap = useSkinList ? theApp.skin.GetIconIndex(ID_EDIT_FINDPREV) : 1;
button.iString = stringID;
m_cToolbar.GetToolBarCtrl().InsertButton(1,&button);
str.LoadString(IDS_FINDPREV);
@ -304,7 +272,7 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
/* if (m_bWrapAround)
button.fsState = TBSTATE_CHECKED;
button.idCommand = IDC_WRAP_AROUND;
button.idCommand = ID_WRAP_AROUND;
button.iBitmap = 2;
m_cToolbar.GetToolBarCtrl().InsertButton(2,&button);
str.LoadString(IDS_FIND_WRAPAROUND);
@ -316,8 +284,8 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (m_bMatchCase)
button.fsState = TBSTATE_CHECKED;
button.idCommand = IDC_MATCH_CASE;
button.iBitmap = 3;
button.idCommand = ID_MATCH_CASE;
button.iBitmap = useSkinList ? theApp.skin.GetIconIndex(ID_MATCH_CASE) : 3;
m_cToolbar.GetToolBarCtrl().InsertButton(2,&button);
str.LoadString(IDS_FIND_MATCHCASE);
m_cToolbar.SetButtonText(2, (LPCTSTR)str);
@ -327,7 +295,8 @@ int CFindRebar::OnCreate(LPCREATESTRUCT lpCreateStruct)
button.fsState = TBSTATE_ENABLED;
if (m_bHighlight)
button.fsState = TBSTATE_CHECKED;
button.idCommand = IDC_HIGHLIGHT;
button.idCommand = ID_HIGHLIGHT;
button.iBitmap = useSkinList ? theApp.skin.GetIconIndex(ID_HIGHLIGHT) : 3;
m_cToolbar.GetToolBarCtrl().InsertButton(3,&button);
str.LoadString(IDS_FIND_HIGHLIGHT);
m_cToolbar.SetButtonText(3, (LPCTSTR)str);

480
k-meleon/FavIconList.cpp

@ -172,34 +172,17 @@ void CFavIconList::LoadDefaultIcon()
{
CString szFullPath;
HICON defaultIcon = NULL;
if (theApp.FindSkinFile(szFullPath, _T("default.ico")))
{
FILE *fp = _tfopen(szFullPath, _T("r"));
if (fp) {
fclose(fp);
defaultIcon = (HICON)LoadImage(NULL, szFullPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if (defaultIcon) {
m_iDefaultIcon = Add(defaultIcon);
}
}
}
HICON defaultIcon = theApp.skin.GetIconDefault();
if (defaultIcon) m_iDefaultIcon = Add(defaultIcon);
// Add can return 0 even if it fails...
if (GetImageCount()==0)
m_iDefaultIcon = Add(theApp.GetDefaultIcon());
if (theApp.FindSkinFile(szFullPath, _T("loading.ico")))
{
FILE *fp = _tfopen(szFullPath, _T("r"));
if (fp) {
fclose(fp);
HICON loadingIcon = (HICON)LoadImage(NULL, szFullPath, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if (loadingIcon) {
m_iLoadingIcon = Add(loadingIcon);
DestroyIcon(loadingIcon);
}
}
HICON loadingIcon = theApp.skin.GetIconLoading();
if (loadingIcon) {
m_iLoadingIcon = Add(loadingIcon);
DestroyIcon(loadingIcon);
}
if (GetImageCount()==1) {
@ -220,14 +203,13 @@ BOOL CFavIconList::Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow)
if (!CImageList::Create(cx,cy,nFlags,nInitial,nGrow))
return FALSE;
mWidth = cx,
mHeight = cy;
LoadDefaultIcon();
LoadCache();
return TRUE;
}
extern nsresult NewURI(nsIURI **result, const nsAString &spec);
extern nsresult NewURI(nsIURI **result, const nsACString &spec);
void CFavIconList::AddMap(const char *uri, int index, const char* pageUri)
{
// This function is called from another thread
@ -275,29 +257,6 @@ int CFavIconList::AddIcon(const char* uri, CBitmap* icon, CBitmap* mask, const c
return index;
}
int CFavIconList::AddIcon(const char* uri, HICON icon, const char* pageUri)
{
int index = Add(icon);
AddMap(uri, index, pageUri);
return index;
}
int CFavIconList::AddDownloadedIcon(char* uri, TCHAR* file, nsresult aStatus)
{
int index = GetDefaultIcon();
if (NS_SUCCEEDED(aStatus))
{
HICON favicon = (HICON)LoadImage(NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if (favicon){
index = AddIcon(uri, favicon);
DestroyIcon(favicon);
}
}
DeleteFile(file);
return index;
}
int CFavIconList::GetIcon(const TCHAR* aUrl)
{
int index = GetDefaultIcon();
@ -398,384 +357,67 @@ void CFavIconList::ResetCache()
theApp.BroadcastMessage(UWM_NEWSITEICON, 0, -1);
}
BOOL CFavIconList::DwnFavIcon(nsIURI* iconURI, nsIURI* pageURI)
{
#ifndef PNG_SUPPORT
// Borked way to get the favicon.
imgIRequest* request = nullptr;
IconObserver* observer = new IconObserver(this);
if (NS_FAILED(observer->LoadIcon(iconURI, pageURI))) {
delete observer;
return FALSE;
}
return TRUE;
//if (NS_FAILED(mIconObserver->LoadIcon(iconURI, pageURI))) {
// return FALSE;
// }
#else
class iconObserver: public IImageObserver {
public:
iconObserver(CFavIconList* favList, nsIURI* icon, nsIURI* page) :
mFavList(favList), mIconURI(icon), mPageURI(page) {}
// Currently the favicon is downloaded like any other file
// which is bad. A nsStreamListener have to be
// implemented.
nsCOMPtr<nsIWebBrowserPersist> persist(do_CreateInstance(NS_WEBBROWSERPERSIST_CONTRACTID));
if(!persist) return FALSE;
TCHAR tempPath[MAX_PATH];
GetTempPath(MAX_PATH, tempPath);
GetTempFileName(tempPath, _T("kme"), 0, tempPath);
nsCOMPtr<nsILocalFile> file;
#ifdef _UNICODE
NS_NewLocalFile(nsDependentString(tempPath), TRUE, getter_AddRefs(file));
#else
NS_NewNativeLocalFile(nsDependentCString(tempPath), TRUE, getter_AddRefs(file));
#endif
CProgressDialog *progress = new CProgressDialog(FALSE);
//persist->SetProgressListener(progress);
progress->InitPersist(iconURI, file, persist, FALSE);
progress->SetCallBack(CFavIconList::DwnCall, this);
persist->SetPersistFlags(
nsIWebBrowserPersist::PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION|
nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES);
nsresult rv = persist->SaveURI(iconURI, nullptr, nullptr, nullptr, nullptr, file);
if (NS_FAILED(rv)) {
persist->SetProgressListener(nullptr);
return FALSE;
}
#endif
return TRUE;
}
void CFavIconList::DwnCall(char* uri, TCHAR* file, nsresult status, void* param)
{
((CFavIconList*)param)->AddDownloadedIcon(uri,file,status);
}
NS_IMPL_ISUPPORTS(IconObserver, imgINotificationObserver)
NS_IMETHODIMP IconObserver::Notify(imgIRequest *aProxy, int32_t aType, const nsIntRect *aRect)
{
if (aType == imgINotificationObserver::LOAD_COMPLETE)
{
if (!NS_SUCCEEDED(aProxy->StartDecoding()))
aProxy->Cancel(NS_OK);
}
else if (aType == imgINotificationObserver::DECODE_COMPLETE)
void ImageLoaded(HBITMAP hBitmap)
{
CreateDIB(aProxy);
aProxy->Cancel(NS_OK);
//mRequest = nullptr;
//NS_RELEASE_THIS();
}
return NS_OK;
}
struct ALPHABITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
BITMAP info;
::GetObject(hBitmap, sizeof(BITMAP), &info);
int w,h;
ImageList_GetIconSize(mFavList->GetSafeHandle(), &w, &h);
if (info.bmWidth!=w && info.bmHeight!=h) {
HDC hDC = GetDC(NULL);
HBITMAP hbmSized = ResizeIcon32(hDC, hBitmap, w, h);
if (!hbmSized) hbmSized = ResizeIcon(hDC, hBitmap, w, h);
if (hbmSized) {
DeleteObject(hBitmap);
hBitmap = hbmSized;
}
ReleaseDC(NULL, hDC);
}
CBitmap bitmap;
bitmap.Attach(hBitmap);
nsCString nsuri;
mIconURI->GetSpec(nsuri);
nsCString nsPageuri;
if (mPageURI) mPageURI->GetSpec(nsPageuri);
ALPHABITMAPINFO(LONG aWidth, LONG aHeight, WORD depth)
{
memset(&bmiHeader, 0, sizeof(bmiHeader));
bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmiHeader.biWidth = aWidth;
bmiHeader.biHeight = aHeight;
bmiHeader.biPlanes = 1;
bmiHeader.biBitCount = depth;
mFavList->AddIcon(nsuri.get(),&bitmap, (CBitmap*)NULL, nsPageuri.get());
}
/* fill in gray scale palette */
int i, npal=1<<depth; // 2^depth
BYTE fact = 255/(npal-1);
for(i=0; i < npal; i++){
BYTE color = 255-i*fact;
bmiColors[i].rgbBlue = color;
bmiColors[i].rgbGreen = color;
bmiColors[i].rgbRed = color;
bmiColors[i].rgbReserved = 0;
}
}
protected:
nsCOMPtr<nsIURI> mIconURI;
nsCOMPtr<nsIURI> mPageURI;
CFavIconList* mFavList;
};
static HBITMAP DataToBitmap(PRUint8* aImageData,
PRUint32 aWidth,
PRUint32 aHeight,
PRUint32 aDepth)
{
HDC dc = ::GetDC(NULL);
if (aDepth == 32) {
// Alpha channel. We need the new header.
BITMAPV4HEADER head = { 0 };
head.bV4Size = sizeof(head);
head.bV4Width = aWidth;
head.bV4Height = aHeight;
head.bV4Planes = 1;
head.bV4BitCount = aDepth;
head.bV4V4Compression = BI_BITFIELDS;
head.bV4SizeImage = 0; // Uncompressed
head.bV4XPelsPerMeter = 0;
head.bV4YPelsPerMeter = 0;
head.bV4ClrUsed = 0;
head.bV4ClrImportant = 0;
head.bV4RedMask = 0x00FF0000;
head.bV4GreenMask = 0x0000FF00;
head.bV4BlueMask = 0x000000FF;
head.bV4AlphaMask = 0xFF000000;
HBITMAP bmp = ::CreateDIBitmap(dc,
reinterpret_cast<CONST BITMAPINFOHEADER*>(&head),
CBM_INIT,
aImageData,
reinterpret_cast<CONST BITMAPINFO*>(&head),
DIB_RGB_COLORS);
::ReleaseDC(NULL, dc);
return bmp;
}
char reserved_space[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2];
BITMAPINFOHEADER& head = *(BITMAPINFOHEADER*)reserved_space;
head.biSize = sizeof(BITMAPINFOHEADER);
head.biWidth = aWidth;
head.biHeight = aHeight;
head.biPlanes = 1;
head.biBitCount = (WORD)aDepth;
head.biCompression = BI_RGB;
head.biSizeImage = 0; // Uncompressed
head.biXPelsPerMeter = 0;
head.biYPelsPerMeter = 0;
head.biClrUsed = 0;
head.biClrImportant = 0;
BITMAPINFO& bi = *(BITMAPINFO*)reserved_space;
if (aDepth == 1) {
RGBQUAD black = { 0, 0, 0, 0 };
RGBQUAD white = { 255, 255, 255, 0 };
bi.bmiColors[0] = white;
bi.bmiColors[1] = black;
}
HBITMAP bmp = ::CreateDIBitmap(dc, &head, CBM_INIT, aImageData, &bi, DIB_RGB_COLORS);
::ReleaseDC(NULL, dc);
return bmp;
}
static void
ConvertBGRXToBGRA(uint8_t* aData, const IntSize &aSize, int32_t aStride)
{
uint32_t* pixel = reinterpret_cast<uint32_t*>(aData);
for (int row = 0; row < aSize.height; ++row) {
for (int column = 0; column < aSize.width; ++column) {
#ifdef IS_BIG_ENDIAN
pixel[column] |= 0x000000FF;
#else
pixel[column] |= 0xFF000000;
#endif
}
pixel += (aStride/4);
}
}
static void
CopySurfaceDataToPackedArray(uint8_t* aSrc, uint8_t* aDst, IntSize aSrcSize,
int32_t aSrcStride, int32_t aBytesPerPixel)
{
MOZ_ASSERT(aBytesPerPixel > 0,
"Negative stride for aDst not currently supported");
int packedStride = aSrcSize.width * aBytesPerPixel;
if (aSrcStride == packedStride) {
// aSrc is already packed, so we can copy with a single memcpy.
memcpy(aDst, aSrc, packedStride * aSrcSize.height);
} else {
// memcpy one row at a time.
for (int row = 0; row < aSrcSize.height; ++row) {
memcpy(aDst, aSrc, packedStride);
aSrc += aSrcStride;
aDst += packedStride;
}
}
}
static uint8_t* SurfaceToPackedBGRA(DataSourceSurface *aSurface)
{
SurfaceFormat format = aSurface->GetFormat();
if (format != SurfaceFormat::B8G8R8A8 && format != SurfaceFormat::B8G8R8X8) {
return nullptr;
}
IntSize size = aSurface->GetSize();
uint8_t* imageBuffer = new (std::nothrow) uint8_t[size.width * size.height * sizeof(uint32_t)];
if (!imageBuffer) {
return nullptr;
}
DataSourceSurface::MappedSurface map;
if (!aSurface->Map(DataSourceSurface::READ, &map)) {
delete [] imageBuffer;
return nullptr;
}
CopySurfaceDataToPackedArray(map.mData, imageBuffer, size,
map.mStride, 4 * sizeof(uint8_t));
aSurface->Unmap();
if (format == SurfaceFormat::B8G8R8X8) {
// Convert BGRX to BGRA by setting a to 255.
ConvertBGRXToBGRA(reinterpret_cast<uint8_t *>(imageBuffer), size, size.width * sizeof(uint32_t));
}
return imageBuffer;
}
uint8_t* Data32BitTo1Bit(uint8_t* aImageData,
uint32_t aWidth, uint32_t aHeight)
{
// We need (aWidth + 7) / 8 bytes plus zero-padding up to a multiple of
// 4 bytes for each row (HBITMAP requirement). Bug 353553.
uint32_t outBpr = ((aWidth + 31) / 8) & ~3;
// Allocate and clear mask buffer
uint8_t* outData = (uint8_t*)calloc(outBpr, aHeight);
if (!outData)
return nullptr;
int32_t *imageRow = (int32_t*)aImageData;
for (uint32_t curRow = 0; curRow < aHeight; curRow++) {
uint8_t *outRow = outData + curRow * outBpr;
uint8_t mask = 0x80;
for (uint32_t curCol = 0; curCol < aWidth; curCol++) {
// Use sign bit to test for transparency, as alpha byte is highest byte
if (*imageRow++ < 0)
*outRow |= mask;
mask >>= 1;
if (!mask) {
outRow ++;
mask = 0x80;
}
}
}
return outData;
}
NS_IMETHODIMP IconObserver::CreateDIB(imgIRequest *aRequest)
BOOL CFavIconList::DwnFavIcon(nsIURI* iconURI, nsIURI* pageURI)
{
nsresult rv;
nsCOMPtr<imgIContainer> container;
rv = aRequest->GetImage(getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv);
#ifdef _DEBUG
// There is a problem with the linking in debug
return NS_ERROR_FAILURE;
#endif
// Get the image data
mozilla::RefPtr<SourceSurface> surface;
iconObserver* io = new iconObserver(this, iconURI, pageURI);
// Add fragment for wanted size
nsCString spec;
iconURI->GetSpec(spec);
spec.Append("#-moz-resolution=");
char tmp[34];
itoa(mWidth, tmp, 10);
spec.Append(tmp);
spec.Append(",");
itoa(mHeight, tmp, 10);
spec.Append(tmp);
surface = container->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_WANT_DATA_SURFACE );
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
surface->GetFormat();
//surface->GetDataSurface();
mozilla::RefPtr<DataSourceSurface> dataSurface;
DataSourceSurface::MappedSurface map;
bool mappedOK;
if (surface->GetFormat() != mozilla::gfx::SurfaceFormat::B8G8R8A8) {
// Convert format to SurfaceFormat::B8G8R8A8
//dataSurface = gfxUtils::CopySurfaceToDataSourceSurfaceWithFormat(surface, SurfaceFormat::B8G8R8A8);
//NS_ENSURE_TRUE(dataSurface, NULL);
//mappedOK = dataSurface->Map(mozilla::gfx::DataSourceSurface::MapType::READ, &map);
} else {
dataSurface = surface->GetDataSurface();
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
mappedOK = dataSurface->Map(mozilla::gfx::DataSourceSurface::READ, &map);
}
NS_ENSURE_TRUE(dataSurface && mappedOK, NS_ERROR_FAILURE);
//MOZ_ASSERT(dataSurface->GetFormat() == mozilla::gfx::SurfaceFormat::B8G8R8A8);
IntSize frameSize = surface->GetSize();
if (frameSize.IsEmpty()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIURI> uri;
NewURI(getter_AddRefs(uri), spec);
uint8_t* data = nullptr;
nsAutoArrayPtr<uint8_t> autoDeleteArray;
if (map.mStride == BytesPerPixel(dataSurface->GetFormat()) * frameSize.width) {
// Mapped data is already packed
data = map.mData;
} else {
// We can't use map.mData since the pixels are not packed (as required by
// CreateDIBitmap, which is called under the DataToBitmap call below).
//
// We must unmap before calling SurfaceToPackedBGRA because it needs access
// to the pixel data.
dataSurface->Unmap();
map.mData = nullptr;
data = autoDeleteArray = SurfaceToPackedBGRA(dataSurface);
NS_ENSURE_TRUE(data, NS_ERROR_FAILURE);
if (!nsImageObserver::LoadImage(io, uri)) {
delete io;
return FALSE;
}
HBITMAP hBitmap = DataToBitmap(data, frameSize.width, -frameSize.height, 32);
int32_t w = frameSize.width;
int32_t h = frameSize.height;
if (w!=16 && h!=16) {
HDC hDC = GetDC(NULL);
HBITMAP hbmSized = ResizeIcon32(hDC, hBitmap, w, h);
if (!hbmSized) hbmSized = ResizeIcon(hDC, hBitmap, w, h);
if (hbmSized) {
DeleteObject(hBitmap);
hBitmap = hbmSized;
}
ReleaseDC(NULL, hDC);
}
CBitmap bitmap;
bitmap.Attach(hBitmap);
CString uri;
nsCOMPtr<nsIURI> URI;
nsEmbedCString nsuri;
rv = aRequest->GetURI(getter_AddRefs(URI));
NS_ENSURE_SUCCESS(rv, rv);
URI->GetSpec(nsuri);
nsEmbedCString nsPageuri;
if (mPageUri) mPageUri->GetSpec(nsPageuri);
mFavList->AddIcon(nsuri.get(),&bitmap, (CBitmap*)NULL, nsPageuri.get());
return NS_OK;
}
NS_IMETHODIMP IconObserver::LoadIcon(nsIURI *iconUri, nsIURI* pageUri)
{
nsresult rv;
nsCOMPtr<imgILoader> loader = do_GetService("@mozilla.org/image/loader;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
mPageUri = pageUri;
return loader->LoadImageXPCOM(iconUri, pageUri, nullptr,
nullptr, nullptr, this, this, nsIRequest::LOAD_BYPASS_CACHE,
nullptr, nullptr, getter_AddRefs(mRequest));
}
return TRUE;
}

23
k-meleon/FavIconList.h

@ -22,30 +22,8 @@
#include "afxtempl.h"
#include "imgIRequest.h"
#include "imgINotificationObserver.h"
class CFavIconList;
class IconObserver : public imgINotificationObserver
{
NS_DECL_ISUPPORTS
NS_DECL_IMGINOTIFICATIONOBSERVER
IconObserver(CFavIconList* favlist) : mFavList(favlist) {}
virtual ~IconObserver() { }
NS_IMETHOD LoadIcon(nsIURI* iconUri, nsIURI* pageUri);
protected:
CFavIconList* mFavList;
nsCOMPtr<imgIRequest> mRequest;
nsCOMPtr<nsIURI> mPageUri;
NS_IMETHOD CreateDIB(imgIRequest *aRequest);
};
class CFavIconList : public CImageList
{
private:
@ -53,6 +31,7 @@ private:
int m_iDefaultIcon;
int m_iLoadingIcon;
int m_iOffset;
unsigned mWidth, mHeight;
//nsCOMPtr<IconObserver> mIconObserver;
void AddMap(const char *uri, int index, const char* pageUri = nullptr);

10
k-meleon/KMeleon.vcxproj

@ -173,7 +173,8 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Manifest>
<AdditionalManifestFiles>comctl6.manifest;DPIaware.manifest</AdditionalManifestFiles>
<AdditionalManifestFiles>
</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
@ -214,7 +215,10 @@
<ClCompile Include="KmAppInfo.cpp" />
<ClCompile Include="KmCommand.cpp" />
<ClCompile Include="KmFileLocProvider.cpp" />
<ClCompile Include="KmImage.cpp" />
<ClCompile Include="KmMenu.cpp" />
<ClCompile Include="KmSkin.cpp" />
<ClCompile Include="KmToolbar.cpp" />
<ClCompile Include="LangParser.cpp" />
<ClCompile Include="MenuParser.cpp" />
<ClCompile Include="MfcEmbed.cpp" />
@ -301,7 +305,11 @@
<ClInclude Include="kmeleon_plugin.h" />
<ClInclude Include="KmeleonConst.h" />
<ClInclude Include="KmFileLocProvider.h" />
<ClInclude Include="KmImage.h" />
<ClInclude Include="KmInstaller.h" />
<ClInclude Include="KmMenu.h" />
<ClInclude Include="KmSkin.h" />
<ClInclude Include="KmToolbar.h" />
<ClInclude Include="LangParser.h" />
<ClInclude Include="Log.h" />
<ClInclude Include="MenuParser.h" />

4
k-meleon/KmAppInfo.cpp

@ -58,7 +58,7 @@ NS_IMETHODIMP KmAppInfo::GetID(nsACString & aID)
/* readonly attribute ACString version; */
NS_IMETHODIMP KmAppInfo::GetVersion(nsACString & aVersion)
{
/*bool ff = false;
bool ff = false;
nsCOMPtr<nsIPrefService> m_prefservice = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (m_prefservice) {
nsCOMPtr<nsIPrefBranch> m_prefs;
@ -67,7 +67,7 @@ NS_IMETHODIMP KmAppInfo::GetVersion(nsACString & aVersion)
nsresult rv = m_prefs->GetBoolPref("kmeleon.install_firefox_extension", &ff);
}
}
aVersion = !ff ? NS_STRINGIFY(KMELEON_UVERSION) : MOZILLA_VERSION;*/
aVersion = !ff ? NS_STRINGIFY(KMELEON_UVERSION) : MOZILLA_VERSION;
aVersion = MOZILLA_VERSION;
return NS_OK;
}

17
k-meleon/KmCommand.cpp

@ -28,7 +28,7 @@ CString KmCmdService::GetDescription(LPCTSTR command)
return _T("");
UINT id = kcommand.id;
if (!theApp.commands.IsPluginCommand(id)) {
if (!IsPluginCommand(id)) {
CString str;
str.LoadString(id);
return str;
@ -38,7 +38,7 @@ CString KmCmdService::GetDescription(LPCTSTR command)
char *desc = NULL;
char *plugin, *parameter;
char *aCmd = strdup(T2CA(command));
if (theApp.commands.ParseCommand(aCmd, &plugin, &parameter))
if (ParseCommand(aCmd, &plugin, &parameter))
theApp.plugins.SendMessage(plugin, "* GetID", "GetCmd", (long)id, (long)desc);
free(aCmd);
return desc?A2T(desc):_T("");
@ -80,6 +80,11 @@ UINT KmCmdService::GetList(kmeleonCommand* cmdList, UINT size, BOOL def)
return i;
}
bool KmCmdService::GetCommand(LPCTSTR command, KmCommand& kcommand)
{
return mCommandList.Lookup(command, kcommand);
}
UINT KmCmdService::GetId(LPCTSTR command)
{
UINT id = 0;
@ -90,6 +95,10 @@ UINT KmCmdService::GetId(LPCTSTR command)
if (mCommandList.Lookup(command, kcommand))
return kcommand.id;
if (command[0] == _T('@')) { //Menu
return RegisterCommand(NULL, command);
}
char *plugin, *parameter;
USES_CONVERSION;
@ -138,7 +147,6 @@ void KmCmdService::InitDefaultCmd()
ADD_DEFCMD(saveLinkAs, ID_SAVE_LINK_AS);
mCommandList[_T("fileOpen")] = KmCommand(ID_FILE_OPEN);
mCommandList[_T("fileClose")] = KmCommand(ID_FILE_CLOSE);
mCommandList[_T("filePrint")] = KmCommand(ID_FILE_PRINT);
mCommandList[_T("filePrintPreview")] = KmCommand(ID_FILE_PRINTPREVIEW);
mCommandList[_T("filePrintSetup")] = KmCommand(ID_FILE_PRINTSETUP);
@ -154,6 +162,8 @@ void KmCmdService::InitDefaultCmd()
mCommandList[_T("editFind")] = KmCommand(ID_EDIT_FIND);
mCommandList[_T("editFindNext")] = KmCommand(ID_EDIT_FINDNEXT);
mCommandList[_T("editFindPrev")] = KmCommand(ID_EDIT_FINDPREV);
ADD_DEFCMD(editFindMatchCase, ID_MATCH_CASE)
ADD_DEFCMD(editFindHighlight, ID_HIGHLIGHT)
ADD_DEFCMD(editCopyLinkLocation, ID_COPY_LINK_LOCATION);
ADD_DEFCMD(editCopyImageLocation, ID_COPY_IMAGE_LOCATION);
ADD_DEFCMD(editCopyImage, ID_COPY_IMAGE_CONTENT);
@ -165,6 +175,7 @@ void KmCmdService::InitDefaultCmd()
ADD_DEFCMD(appExit, ID_APP_EXIT);
ADD_DEFCMD(appAbout, ID_APP_ABOUT);
ADD_DEFCMD(windowClose, ID_FILE_CLOSE);
ADD_DEFCMD(windowNew, ID_NEW_BROWSER);
ADD_DEFCMD(windowNext, ID_WINDOW_NEXT);
ADD_DEFCMD(windowPrev, ID_WINDOW_PREV);

5
k-meleon/KmCommand.h

@ -105,7 +105,7 @@ public:
mCommandList.RemoveKey(command);
}
UINT RegisterCommand(LPCTSTR plugin, LPCTSTR command, unsigned nbArgs)
UINT RegisterCommand(LPCTSTR plugin, LPCTSTR command, unsigned nbArgs = 0)
{
UINT id = AllocateId();
mCommandList[command] = KmCommand(id);