зеркало из https://github.com/mozilla/pjs.git
Родитель
b02a88f918
Коммит
5d10d519e3
|
@ -65,6 +65,40 @@ public:
|
|||
AddURLToList(urlStr, false);
|
||||
}
|
||||
}
|
||||
inline BOOL EditCtrlHasFocus() {
|
||||
return (GetEditCtrl()->m_hWnd == CWnd::GetFocus()->m_hWnd);
|
||||
}
|
||||
inline BOOL EditCtrlHasSelection() {
|
||||
int nStartChar = 0, nEndChar = 0;
|
||||
if(EditCtrlHasFocus())
|
||||
GetEditCtrl()->GetSel(nStartChar, nEndChar);
|
||||
return (nEndChar > nStartChar) ? TRUE : FALSE;
|
||||
}
|
||||
inline BOOL CanCutToClipboard() {
|
||||
return EditCtrlHasSelection();
|
||||
}
|
||||
inline void CutToClipboard() {
|
||||
GetEditCtrl()->Cut();
|
||||
}
|
||||
inline BOOL CanCopyToClipboard() {
|
||||
return EditCtrlHasSelection();
|
||||
}
|
||||
inline void CopyToClipboard() {
|
||||
GetEditCtrl()->Copy();
|
||||
}
|
||||
inline BOOL CanPasteFromClipboard() {
|
||||
return EditCtrlHasFocus();
|
||||
}
|
||||
inline void PasteFromClipboard() {
|
||||
GetEditCtrl()->Paste();
|
||||
}
|
||||
inline BOOL CanUndoEditOp() {
|
||||
return EditCtrlHasFocus() ? GetEditCtrl()->CanUndo() : FALSE;
|
||||
}
|
||||
inline void UndoEditOp() {
|
||||
if(EditCtrlHasFocus())
|
||||
GetEditCtrl()->Undo();
|
||||
}
|
||||
|
||||
protected:
|
||||
CMostRecentUrls m_MRUList;
|
||||
|
@ -90,6 +124,16 @@ public:
|
|||
// be displayed in
|
||||
CBrowserView m_wndBrowserView;
|
||||
|
||||
// Wrapper functions for UrlBar clipboard operations
|
||||
inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); }
|
||||
inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); }
|
||||
inline BOOL CanCopyUrlBarSelection() { return m_wndUrlBar.CanCopyToClipboard(); }
|
||||
inline void CopyUrlBarSelToClipboard() { m_wndUrlBar.CopyToClipboard(); }
|
||||
inline BOOL CanPasteToUrlBar() { return m_wndUrlBar.CanPasteFromClipboard(); }
|
||||
inline void PasteFromClipboardToUrlBar() { m_wndUrlBar.PasteFromClipboard(); }
|
||||
inline BOOL CanUndoUrlBarEditOp() { return m_wndUrlBar.CanUndoEditOp(); }
|
||||
inline void UndoUrlBarEditOp() { m_wndUrlBar.UndoEditOp(); }
|
||||
|
||||
// This specifies what UI elements this frame will sport
|
||||
// w.r.t. toolbar, statusbar, urlbar etc.
|
||||
PRUint32 m_chromeMask;
|
||||
|
|
|
@ -87,6 +87,7 @@ BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
|
|||
ON_COMMAND(ID_EDIT_CUT, OnCut)
|
||||
ON_COMMAND(ID_EDIT_COPY, OnCopy)
|
||||
ON_COMMAND(ID_EDIT_PASTE, OnPaste)
|
||||
ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp)
|
||||
ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
|
||||
ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone)
|
||||
ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow)
|
||||
|
@ -121,6 +122,8 @@ CBrowserView::CBrowserView()
|
|||
mbDocumentLoading = PR_FALSE;
|
||||
|
||||
m_pFindDlg = NULL;
|
||||
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
}
|
||||
|
||||
CBrowserView::~CBrowserView()
|
||||
|
@ -430,10 +433,19 @@ void CBrowserView::OnUpdateNavStop(CCmdUI* pCmdUI)
|
|||
|
||||
void CBrowserView::OnCut()
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
if(m_bUrlBarClipOp)
|
||||
{
|
||||
// We need to operate on the URLBar selection
|
||||
mpBrowserFrame->CutUrlBarSelToClipboard();
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
|
||||
if(clipCmds)
|
||||
clipCmds->CutSelection();
|
||||
if(clipCmds)
|
||||
clipCmds->CutSelection();
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI)
|
||||
|
@ -444,15 +456,36 @@ void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI)
|
|||
if (clipCmds)
|
||||
clipCmds->CanCutSelection(&canCutSelection);
|
||||
|
||||
if(!canCutSelection)
|
||||
{
|
||||
// Check to see if the Cut cmd is to cut the URL
|
||||
// selection in the UrlBar
|
||||
if(mpBrowserFrame->CanCutUrlBarSelection())
|
||||
{
|
||||
canCutSelection = TRUE;
|
||||
m_bUrlBarClipOp = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
pCmdUI->Enable(canCutSelection);
|
||||
}
|
||||
|
||||
void CBrowserView::OnCopy()
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
if(m_bUrlBarClipOp)
|
||||
{
|
||||
// We need to operate on the URLBar selection
|
||||
mpBrowserFrame->CopyUrlBarSelToClipboard();
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to operate on the web page content
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
|
||||
if(clipCmds)
|
||||
clipCmds->CopySelection();
|
||||
if(clipCmds)
|
||||
clipCmds->CopySelection();
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI)
|
||||
|
@ -463,15 +496,40 @@ void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI)
|
|||
if (clipCmds)
|
||||
clipCmds->CanCopySelection(&canCopySelection);
|
||||
|
||||
if(!canCopySelection)
|
||||
{
|
||||
// Check to see if the Copy cmd is to copy the URL
|
||||
// selection in the UrlBar
|
||||
if(mpBrowserFrame->CanCopyUrlBarSelection())
|
||||
{
|
||||
canCopySelection = TRUE;
|
||||
m_bUrlBarClipOp = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
pCmdUI->Enable(canCopySelection);
|
||||
}
|
||||
|
||||
void CBrowserView::OnPaste()
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
if(m_bUrlBarClipOp)
|
||||
{
|
||||
mpBrowserFrame->PasteFromClipboardToUrlBar();
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmds = do_GetInterface(mWebBrowser);
|
||||
|
||||
if(clipCmds)
|
||||
clipCmds->Paste();
|
||||
if(clipCmds)
|
||||
clipCmds->Paste();
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserView::OnUndoUrlBarEditOp()
|
||||
{
|
||||
if(mpBrowserFrame->CanUndoUrlBarEditOp())
|
||||
mpBrowserFrame->UndoUrlBarEditOp();
|
||||
}
|
||||
|
||||
void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI)
|
||||
|
@ -482,6 +540,15 @@ void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI)
|
|||
if (clipCmds)
|
||||
clipCmds->CanPaste(&canPaste);
|
||||
|
||||
if(!canPaste)
|
||||
{
|
||||
if(mpBrowserFrame->CanPasteToUrlBar())
|
||||
{
|
||||
canPaste = TRUE;
|
||||
m_bUrlBarClipOp = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
pCmdUI->Enable(canPaste);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,13 @@ public:
|
|||
inline void ClearFindDialog() { m_pFindDlg = NULL; }
|
||||
CFindDialog* m_pFindDlg;
|
||||
|
||||
// When set to TRUE...
|
||||
// indicates that the clipboard operation needs to be
|
||||
// performed on the UrlBar rather than on
|
||||
// the web page content
|
||||
//
|
||||
BOOL m_bUrlBarClipOp;
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CBrowserView)
|
||||
|
@ -128,6 +135,7 @@ protected:
|
|||
afx_msg void OnCut();
|
||||
afx_msg void OnCopy();
|
||||
afx_msg void OnPaste();
|
||||
afx_msg void OnUndoUrlBarEditOp();
|
||||
afx_msg void OnSelectAll();
|
||||
afx_msg void OnSelectNone();
|
||||
afx_msg void OnCopyLinkLocation();
|
||||
|
|
|
@ -232,6 +232,7 @@ BEGIN
|
|||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_ESCAPE, ID_NAV_STOP, VIRTKEY
|
||||
END
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче