Browse Source

Allow to replace the url bar context menu with a menu called "URLBar"

master
Dorian 7 years ago
parent
commit
0141232e7b
  1. 57
      k-meleon/BrowserView.cpp
  2. 20
      k-meleon/urlbar.cpp
  3. 2
      k-meleon/urlbar.h

57
k-meleon/BrowserView.cpp

@ -463,24 +463,50 @@ void CBrowserView::OnUpdateFileSave(CCmdUI* pCmdUI)
void CBrowserView::OnCut()
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
((CEdit*)focus)->Cut();
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
m_pWindow->Cut();
}
void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI)
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
DWORD sel = ((CEdit*)focus)->GetSel();
pCmdUI->Enable(HIWORD(sel)!=LOWORD(sel));
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
pCmdUI->Enable(m_pWindow->CanCut());
}
void CBrowserView::OnCopy()
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
((CEdit*)focus)->Copy();
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
m_pWindow->Copy();
}
void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI)
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
DWORD sel = ((CEdit*)focus)->GetSel();
pCmdUI->Enable(HIWORD(sel)!=LOWORD(sel));
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
pCmdUI->Enable(m_pWindow->CanCopy());
}
@ -499,29 +525,60 @@ void CBrowserView::OnPaste()
void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI)
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
pCmdUI->Enable(!(((CEdit*)focus)->GetStyle() & ES_READONLY));
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
pCmdUI->Enable(m_pWindow->CanPaste());
}
void CBrowserView::OnUndo()
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
((CEdit*)focus)->Undo();
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
m_pWindow->Undo();
}
void CBrowserView::OnUpdateUndo(CCmdUI* pCmdUI)
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
pCmdUI->Enable(((CEdit*)focus)->CanUndo());
return;
}
pCmdUI->Enable(m_pWindow->CanUndo());
}
void CBrowserView::OnDelete()
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
((CEdit*)focus)->ReplaceSel(_T(""), TRUE);
return;
}
if (::IsChild(m_hWnd, ::GetFocus()))
m_pWindow->Delete();
}
void CBrowserView::OnUpdateDelete(CCmdUI* pCmdUI)
{
CWnd* focus = GetFocus();
if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit))) {
DWORD sel = ((CEdit*)focus)->GetSel();
pCmdUI->Enable(HIWORD(sel)!=LOWORD(sel) && !(((CEdit*)focus)->GetStyle() & ES_READONLY));
return;
}
pCmdUI->Enable(m_pWindow->CanDelete());
}

20
k-meleon/urlbar.cpp

@ -38,6 +38,7 @@ BEGIN_MESSAGE_MAP(CUrlBarEdit, CEdit)
ON_WM_SETFOCUS()
ON_MESSAGE(WM_SETTEXT, OnSetText)
//ON_MESSAGE(WM_GETTEXT, OnGetText)
ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CACListBox, CListBox)
@ -883,3 +884,22 @@ void CUrlBar::OnCbnSelchange()
TRACE0("EditChanged TRUE in OnCbnSelchange\n");
EditChanged(FALSE);
}
void CUrlBarEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu* m = theApp.menus.GetMenu(L"URLBar");
if (!m) return CEdit::OnContextMenu(pWnd, point);
if (point.x == -1 || point.y == -1)
{
CRect rc;
GetClientRect(&rc);
point = rc.CenterPoint();
ClientToScreen(&point);
}
theApp.menus.Activate(m);
m->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON |
TPM_RIGHTBUTTON, point.x, point.y, this->GetParentFrame());
}

2
k-meleon/urlbar.h

@ -95,7 +95,7 @@ public:
#ifndef URLBAR_USE_SETWORDBREAKPROC
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
#endif
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
protected:
virtual void PreSubclassWindow();

Loading…
Cancel
Save