mirror of https://github.com/roytam1/kmeleon.git
parent
b6a56cbf2b
commit
271991364a
5 changed files with 811 additions and 691 deletions
@ -0,0 +1,166 @@ |
||||
/*
|
||||
* Copyright (C) 2000 Christophe Thibault, Brian Harris, 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. |
||||
*/ |
||||
|
||||
/*
|
||||
This code handles the Find... dialog box stuff |
||||
*/ |
||||
|
||||
#include "stdafx.h" |
||||
|
||||
#include "MfcEmbed.h" |
||||
extern CMfcEmbedApp theApp; |
||||
|
||||
#include "Dialogs.h" |
||||
#include "BrowserFrm.h" |
||||
#include "BrowserView.h" |
||||
|
||||
void CBrowserView::OnShowFindDlg() { |
||||
|
||||
// When the the user chooses the Find menu item
|
||||
// and if a Find dlg. is already being shown
|
||||
// just set focus to the existing dlg instead of
|
||||
// creating a new one
|
||||
if(m_pFindDlg) { |
||||
m_pFindDlg->SetFocus(); |
||||
return; |
||||
} |
||||
|
||||
CString csSearchStr; |
||||
PRBool bMatchCase = PR_FALSE; |
||||
PRBool bMatchWholeWord = PR_FALSE; |
||||
PRBool bWrapAround = PR_TRUE; |
||||
PRBool bSearchBackwards = PR_FALSE; |
||||
|
||||
// See if we can get and initialize the dlg box with
|
||||
// the values/settings the user specified in the previous search
|
||||
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser)); |
||||
if(finder) { |
||||
nsXPIDLString stringBuf; |
||||
finder->GetSearchString(getter_Copies(stringBuf)); |
||||
csSearchStr = stringBuf.get(); |
||||
|
||||
if (csSearchStr != "") { |
||||
finder->GetMatchCase(&bMatchCase); |
||||
finder->GetEntireWord(&bMatchWholeWord); |
||||
finder->GetWrapFind(&bWrapAround); |
||||
finder->GetFindBackwards(&bSearchBackwards);
|
||||
} |
||||
else { |
||||
csSearchStr = theApp.preferences.findSearchStr; |
||||
bMatchCase = theApp.preferences.bFindMatchCase; |
||||
bMatchWholeWord = theApp.preferences.bFindMatchWholeWord; |
||||
bWrapAround = theApp.preferences.bFindWrapAround; |
||||
bSearchBackwards = theApp.preferences.bFindSearchBackwards; |
||||
} |
||||
} |
||||
|
||||
m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord, bWrapAround, bSearchBackwards, this); |
||||
m_pFindDlg->Create(TRUE, NULL, NULL, 0, this); |
||||
} |
||||
|
||||
void CBrowserView::OnFindNext() { |
||||
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser)); |
||||
|
||||
if(!finder) return; |
||||
|
||||
nsXPIDLString stringBuf; |
||||
finder->GetSearchString(getter_Copies(stringBuf)); |
||||
if (stringBuf.get()[0]) { |
||||
|
||||
PRBool didFind; |
||||
finder->FindNext(&didFind); |
||||
} |
||||
else { |
||||
OnShowFindDlg(); |
||||
} |
||||
} |
||||
|
||||
void CBrowserView::OnFindPrev() { |
||||
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser)); |
||||
|
||||
if(!finder) return; |
||||
|
||||
PRBool rv; |
||||
|
||||
finder->GetFindBackwards(&rv); |
||||
finder->SetFindBackwards(rv^2); // reverse the find direction
|
||||
|
||||
nsXPIDLString stringBuf; |
||||
finder->GetSearchString(getter_Copies(stringBuf)); |
||||
if (stringBuf.get()[0]) { |
||||
PRBool didFind; |
||||
finder->FindNext(&didFind); |
||||
} |
||||
else { |
||||
OnShowFindDlg(); |
||||
} |
||||
|
||||
finder->GetFindBackwards(&rv); |
||||
finder->SetFindBackwards(rv^2); // reset the initial find direction
|
||||
} |
||||
|
||||
// This will be called whenever the user pushes the Find
|
||||
// button in the Find dialog box
|
||||
// This method gets bound to the WM_FINDMSG windows msg via the
|
||||
//
|
||||
// ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
|
||||
//
|
||||
// message map entry.
|
||||
//
|
||||
// WM_FINDMSG (which is registered towards the beginning of this file)
|
||||
// is the message via which the FindDialog communicates with this view
|
||||
//
|
||||
LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) { |
||||
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser)); |
||||
|
||||
if(!finder) return NULL; |
||||
|
||||
// Get the pointer to the current Find dialog box
|
||||
CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam); |
||||
if(!dlg) return NULL; |
||||
|
||||
// Has the user decided to terminate the dialog box?
|
||||
if(dlg->IsTerminating()) return NULL; |
||||
|
||||
if(dlg->FindNext()) { |
||||
|
||||
// save the find settings
|
||||
theApp.preferences.findSearchStr = dlg->GetFindString().GetBuffer(0); |
||||
theApp.preferences.bFindMatchCase = dlg->MatchCase(); |
||||
theApp.preferences.bFindMatchWholeWord = dlg->MatchWholeWord(); |
||||
theApp.preferences.bFindWrapAround = dlg->WrapAround(); |
||||
theApp.preferences.bFindSearchBackwards = dlg->SearchBackwards(); |
||||
|
||||
|
||||
// create the find query
|
||||
nsString searchString; |
||||
searchString.AssignWithConversion(theApp.preferences.findSearchStr.GetBuffer(0)); |
||||
finder->SetSearchString(searchString.get()); |
||||
|
||||
finder->SetMatchCase((theApp.preferences.bFindMatchCase) ? PR_TRUE : PR_FALSE); |
||||
finder->SetEntireWord((theApp.preferences.bFindMatchWholeWord) ? PR_TRUE : PR_FALSE); |
||||
finder->SetWrapFind((theApp.preferences.bFindWrapAround) ? PR_TRUE : PR_FALSE); |
||||
finder->SetFindBackwards((theApp.preferences.bFindSearchBackwards) ? PR_TRUE : PR_FALSE); |
||||
|
||||
PRBool didFind; |
||||
nsresult rv = finder->FindNext(&didFind); |
||||
|
||||
return (NS_SUCCEEDED(rv) && didFind); |
||||
} |
||||
return 0; |
||||
} |
@ -0,0 +1,122 @@ |
||||
/*
|
||||
* Copyright (C) 2000 Christophe Thibault, Brian Harris, 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 "MfcEmbed.h" |
||||
extern CMfcEmbedApp theApp; |
||||
|
||||
#include "BrowserView.h" |
||||
|
||||
|
||||
/*
|
||||
** Middle button panning shit |
||||
*/ |
||||
int CBrowserView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { |
||||
switch (message) { |
||||
case WM_MBUTTONDOWN: |
||||
if(m_panning) StopPanning(); |
||||
else StartPanning(); |
||||
return TRUE; |
||||
case WM_MBUTTONUP: |
||||
{ |
||||
} |
||||
return TRUE; |
||||
} |
||||
|
||||
return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); |
||||
} |
||||
|
||||
void CBrowserView::OnTimer(UINT nIDEvent){ |
||||
switch(nIDEvent){ |
||||
case 0x1: |
||||
if(m_panning) { |
||||
nsCOMPtr<nsIScrollable> s(do_QueryInterface(mWebBrowser)); |
||||
|
||||
if(!s) return; |
||||
|
||||
POINT p; |
||||
GetCursorPos(&p); |
||||
|
||||
int scroll_x,scroll_y; |
||||
|
||||
s->GetCurScrollPos(s->ScrollOrientation_X,&scroll_x); |
||||
s->GetCurScrollPos(s->ScrollOrientation_Y,&scroll_y); |
||||
|
||||
if(abs(p.y-m_panningPoint.y)>4){ |
||||
if(p.y>m_panningPoint.y) scroll_y+=(p.y-m_panningPoint.y)*2; |
||||
else scroll_y-=(m_panningPoint.y-p.y)*2; |
||||
} |
||||
|
||||
if(abs(p.x-m_panningPoint.x)>4){ |
||||
if(p.x>m_panningPoint.x) scroll_x+=(p.x-m_panningPoint.x)*2; |
||||
else scroll_x-=(m_panningPoint.x-p.x)*2; |
||||
} |
||||
|
||||
s->SetCurScrollPosEx(scroll_x,scroll_y); |
||||
|
||||
int cursorx=p.x-m_panningPoint.x,cursory=p.y-m_panningPoint.y; |
||||
int cursor=IDC_PAN; |
||||
if(cursory<-4) cursor=IDC_PAN_UP; |
||||
if(cursory>4) cursor=IDC_PAN_DOWN; |
||||
if(cursorx<-4) |
||||
{ |
||||
if(cursor==IDC_PAN_UP) cursor=IDC_PAN_UPLEFT; |
||||
else if(cursor==IDC_PAN_DOWN) cursor=IDC_PAN_DOWNLEFT; |
||||
else cursor=IDC_PAN_LEFT; |
||||
} |
||||
if(cursorx>4) |
||||
{ |
||||
if(cursor==IDC_PAN_UP) cursor=IDC_PAN_UPRIGHT; |
||||
else if(cursor==IDC_PAN_DOWN) cursor=IDC_PAN_DOWNRIGHT; |
||||
else cursor=IDC_PAN_RIGHT; |
||||
} |
||||
|
||||
HCURSOR c=LoadCursor(theApp.m_hInstance,MAKEINTRESOURCE(cursor)); |
||||
SetCursor(c); |
||||
} |
||||
return; |
||||
} |
||||
|
||||
CWnd::OnTimer(nIDEvent); |
||||
} |
||||
|
||||
void CBrowserView::StartPanning(){ |
||||
m_panning = 1; |
||||
GetCursorPos(&m_panningPoint); |
||||
SetCapture(); |
||||
SetTimer(0x1,10,NULL); |
||||
|
||||
SetFocus(); |
||||
} |
||||
|
||||
void CBrowserView::StopPanning(){ |
||||
ReleaseCapture(); |
||||
KillTimer(0x1); |
||||
m_panning = 0; |
||||
} |
||||
|
||||
BOOL CBrowserView::PreTranslateMessage(MSG* pMsg) { |
||||
if(m_panning && (pMsg->message==WM_SETCURSOR || pMsg->message==WM_MOUSEMOVE)) |
||||
return TRUE; |
||||
|
||||
if(m_panning && (pMsg->message==WM_LBUTTONDOWN || pMsg->message==WM_RBUTTONDOWN)) |
||||
StopPanning(); |
||||
|
||||
return CWnd::PreTranslateMessage(pMsg); |
||||
} |
@ -0,0 +1,389 @@ |
||||
/*
|
||||
* Copyright (C) 2000 Christophe Thibault, Brian Harris, 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. |
||||
*/ |
||||
|
||||
/*
|
||||
These are little utils and stuff for the CBrowserView |
||||
it's mainly here to get it out of BrowserView.cpp which should |
||||
theoretically just contain overridden functions and message handlers |
||||
*/ |
||||
|
||||
#include "stdafx.h" |
||||
|
||||
#include "MfcEmbed.h" |
||||
extern CMfcEmbedApp theApp; |
||||
|
||||
#include "BrowserFrm.h" |
||||
#include "BrowserView.h" |
||||
|
||||
BOOL CBrowserView::IsViewSourceUrl(CString& strUrl) { |
||||
return (strUrl.Find("view-source:", 0) != -1) ? TRUE : FALSE; |
||||
} |
||||
|
||||
BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl) { |
||||
|
||||
// Use external viewer
|
||||
if (theApp.preferences.bSourceUseExternalCommand) { |
||||
if (theApp.preferences.sourceCommand) { |
||||
|
||||
char *tempfile = GetTempFile(); |
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(mWebBrowser)); |
||||
if(persist) { |
||||
persist->SaveDocument(nsnull, tempfile, 0); |
||||
|
||||
char *command = new char[theApp.preferences.sourceCommand.GetLength() + strlen(tempfile) +2]; |
||||
|
||||
strcpy(command, theApp.preferences.sourceCommand); |
||||
strcat(command, " "); //append " filename" to the viewer command
|
||||
strcat(command, tempfile); |
||||
|
||||
STARTUPINFO si = { 0 }; |
||||
PROCESS_INFORMATION pi; |
||||
si.cb = sizeof STARTUPINFO; |
||||
si.dwFlags = STARTF_USESHOWWINDOW; |
||||
si.wShowWindow = SW_SHOW; |
||||
|
||||
CreateProcess(0,command,0,0,0,0,0,0,&si,&pi); // launch external viewer
|
||||
} |
||||
return TRUE; |
||||
} |
||||
} |
||||
|
||||
// use the internal viewer
|
||||
|
||||
// Create a new browser frame in which we'll show the document source
|
||||
// Note that we're getting rid of the toolbars etc. by specifying
|
||||
// the appropriate chromeFlags
|
||||
PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS | |
||||