OSDN Git Service

[ 777871 ] New headerbar for the file paths
authorLaurent Ganier <laoran@users.sourceforge.net>
Wed, 30 Jul 2003 09:20:56 +0000 (09:20 +0000)
committerLaurent Ganier <laoran@users.sourceforge.net>
Wed, 30 Jul 2003 09:20:56 +0000 (09:20 +0000)
12 files changed:
Src/ChildFrm.cpp
Src/ChildFrm.h
Src/EditorFilepathBar.cpp [new file with mode: 0644]
Src/EditorFilepathBar.h [new file with mode: 0644]
Src/FilepathEdit.cpp [new file with mode: 0644]
Src/FilepathEdit.h [new file with mode: 0644]
Src/Merge.dsp
Src/Merge.rc
Src/dllver.cpp
Src/dllver.h
Src/readme.txt
Src/resource.h

index 4c0a252..536c0ed 100644 (file)
@@ -48,12 +48,6 @@ BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
-static UINT indicatorsHdr[] =
-{
-       ID_SEPARATOR,
-       ID_SEPARATOR
-};
-
 static UINT indicatorsBottom[] =
 {
        ID_SEPARATOR,
@@ -163,20 +157,14 @@ int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        ModifyStyle(WS_THICKFRAME,0); // this is necessary to prevent the sizing tab on right
 
        // Merge frame has a status bar at top
-       if (!m_wndHdrStatusBar.Create(this) ||
-               !m_wndHdrStatusBar.SetIndicators(indicatorsHdr,
-                 sizeof(indicatorsHdr)/sizeof(UINT)))
+       if (!m_wndFilePathBar.Create(this))
        {
-               TRACE0("Failed to create status bar\n");
+               TRACE0("Failed to create dialog bar\n");
                return -1;      // fail to create
        }       
 
        ModifyStyle(0,WS_THICKFRAME);
 
-       m_wndHdrStatusBar.SetBarStyle(CBRS_ALIGN_TOP);
-       m_wndHdrStatusBar.SetPaneStyle(0, SBPS_NORMAL);
-       m_wndHdrStatusBar.SetPaneStyle(1, SBPS_NORMAL);
-
        // Merge frame also has a status bar at bottom
        if (!m_wndStatusBar.Create(this) ||
                !m_wndStatusBar.SetIndicators(indicatorsBottom,
@@ -210,8 +198,8 @@ void CChildFrame::ActivateFrame(int nCmdShow)
                m_wndSplitter.SetColumnInfo(0, rc.Width()/2, 10);
                m_wndSplitter.RecalcLayout();
     }
-       CMDIChildWnd::ActivateFrame(nCmdShow);
        UpdateHeaderSizes();
+       CMDIChildWnd::ActivateFrame(nCmdShow);
 }
 
 BOOL CChildFrame::DestroyWindow() 
@@ -262,11 +250,21 @@ void CChildFrame::UpdateHeaderSizes()
        {
                int w,wmin;
                m_wndSplitter.GetColumnInfo(0, w, wmin);
+               int w1;
+               m_wndSplitter.GetColumnInfo(1, w1, wmin);
                if (w<1) w=1; // Perry 2003-01-22 (I don't know why this happens)
-               m_wndHdrStatusBar.SetPaneInfo(0, ID_SEPARATOR, SBPS_NORMAL, w-1);
-               m_wndHdrStatusBar.SetPaneInfo(1, ID_SEPARATOR, SBPS_STRETCH, 0);
+               if (w1<1) w1=1; // Perry 2003-01-22 (I don't know why this happens)
+
+               // for bottom status bar
                m_wndStatusBar.SetPaneInfo(0, ID_SEPARATOR, SBPS_NORMAL, w-1);
                m_wndStatusBar.SetPaneInfo(1, ID_SEPARATOR, SBPS_STRETCH, 0);
+
+               // prepare file path bar to look as a status bar
+               if (m_wndFilePathBar.LookLikeThisWnd(&m_wndStatusBar) == TRUE)
+                       RecalcLayout();
+
+               // resize controls in header dialog bar
+               m_wndFilePathBar.Resize(w, w1);
        }
 
 }
@@ -295,7 +293,7 @@ void CChildFrame::OnTimer(UINT nIDEvent)
 
 void CChildFrame::SetHeaderText(int nPane, const CString &text)
 {
-       m_wndHdrStatusBar.SetPaneText(nPane, text);
+       m_wndFilePathBar.SetFilePath(nPane, text);
 }
 
 // document commanding us to close
index 5c36488..98af11a 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "SplitterWndEx.h"
 #include "MergeEditStatus.h"
+#include "EditorFilepathBar.h"
 
 class CChildFrame : public CMDIChildWnd
 {
@@ -40,7 +41,7 @@ public:
 // Attributes
 protected:
        CSplitterWndEx m_wndSplitter;
-       CStatusBar m_wndHdrStatusBar;
+       CEditorFilePathBar m_wndFilePathBar;
        CStatusBar m_wndStatusBar;
        // Object that displays status line info for one side of a merge view
        class MergeStatus : public IMergeEditStatus
diff --git a/Src/EditorFilepathBar.cpp b/Src/EditorFilepathBar.cpp
new file mode 100644 (file)
index 0000000..a8036e5
--- /dev/null
@@ -0,0 +1,158 @@
+/////////////////////////////////////////////////////////////////////////////
+//    WinMerge:  an interactive diff/merge utility
+//    Copyright (C) 1997-2000  Thingamahoochie Software
+//    Author: Dean Grimm
+//
+//    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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+/////////////////////////////////////////////////////////////////////////////
+// EditorFilepathBar.cpp : implementation of the CEditorFilepathBar class
+//
+
+#include "stdafx.h"
+#include "Merge.h"
+#include "EditorFilepathBar.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditorFilePathBar construction destruction
+
+BOOL CEditorFilePathBar::Create(CWnd* pParentWnd)
+{
+       if (! CDialogBar::Create(pParentWnd, CEditorFilePathBar::IDD, 
+                                                                                                        CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, 
+                                                                                                        CEditorFilePathBar::IDD))
+               return FALSE;
+
+       // subclass the two custom edit boxes
+       m_EditLeft.SubClassEdit(IDC_STATIC_TITLE_LEFT, this);
+       m_EditRight.SubClassEdit(IDC_STATIC_TITLE_RIGHT, this);
+
+       return TRUE;
+};
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+// return TRUE if parent must recompute layout
+BOOL CEditorFilePathBar::LookLikeThisWnd(CWnd * pWnd)
+{
+       // same font
+       CFont * pFont = pWnd->GetFont();
+       m_EditLeft.SetFont(pFont);
+       m_EditRight.SetFont(pFont);
+       // and same dimensions
+       CRect rectNew;
+       pWnd->GetWindowRect(rectNew);
+       CRect rectCurrent;
+       GetWindowRect(rectCurrent);
+       if (rectNew != rectCurrent)
+       {
+               SetWindowPos(NULL,0,0,rectNew.Width(), rectNew.Height(),
+                       SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE);     
+               return TRUE;
+       }
+       return FALSE;
+}
+
+void CEditorFilePathBar::Resize(int leftWidth, int rightWidth)
+{
+       WINDOWPLACEMENT info1;
+
+       // resize left filename
+       m_EditLeft.GetWindowPlacement(&info1);
+       info1.rcNormalPosition.right = info1.rcNormalPosition.left + leftWidth + 4;
+       m_EditLeft.SetWindowPlacement(&info1);
+       m_EditLeft.RefreshDisplayText();
+
+       // resize right filename
+       info1.rcNormalPosition.left = info1.rcNormalPosition.right + 3;
+       info1.rcNormalPosition.right = info1.rcNormalPosition.left + rightWidth + 4;
+       m_EditRight.SetWindowPlacement(&info1);
+       m_EditRight.RefreshDisplayText();
+}
+
+void CEditorFilePathBar::SetFilePath(int pane, const CString &text)
+{
+       ASSERT(pane == 0 || pane == 1);
+       if (pane == 0)
+               m_EditLeft.SetWholeText(text);
+       else
+               m_EditRight.SetWholeText(text);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditorFilePathBar message handlers
+
+BEGIN_MESSAGE_MAP(CEditorFilePathBar, CDialogBar)
+       ON_NOTIFY_EX (TTN_NEEDTEXT, 0, OnToolTipNotify)
+END_MESSAGE_MAP()
+
+
+BOOL CEditorFilePathBar::OnToolTipNotify(UINT id, NMHDR * pTTTStruct, LRESULT * pResult)
+{
+       TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pTTTStruct;
+       UINT nID =pTTTStruct->idFrom;
+       if (pTTT->uFlags & TTF_IDISHWND)
+       {
+               // idFrom is actually the HWND of the CEdit 
+               nID = ::GetDlgCtrlID((HWND)nID);
+               if(nID == IDC_STATIC_TITLE_LEFT || nID == IDC_STATIC_TITLE_RIGHT)
+               {
+                       // compute max width : 97% of application width or 80% or full screen width
+                       CRect rect;
+                       GetWindowRect(rect);
+                       int maxWidth = rect.Width() * .97;
+                       CRect rectScreen; 
+                       SystemParametersInfo(SPI_GETWORKAREA, 0, rectScreen, 0);
+                       if (rectScreen.Width() * .8 > maxWidth)
+                               maxWidth = rectScreen.Width() * .8;
+
+                       // use the tooltip font
+                       HANDLE hFont = (HANDLE) ::SendMessage(pTTTStruct->hwndFrom, WM_GETFONT, 0, 0);
+                       CClientDC tempDC(this);
+                       HANDLE hOldFont = ::SelectObject(tempDC.GetSafeHdc(),hFont);
+
+                       // fill in the returned structure
+                       CFilepathEdit * pItem = (CFilepathEdit*) GetDlgItem(nID);
+                       pTTT->lpszText = (char*) pItem->GetUpdatedTipText(&tempDC, maxWidth);
+
+                       // set old font back
+                       if (hOldFont)
+                               ::SelectObject(tempDC.GetSafeHdc(),hOldFont);
+
+                       // we must set TTM_SETMAXTIPWIDTH to use \n in tooltips
+                       // just to do the first time, but how to access the tooltip during init ?
+                       ::SendMessage(pTTTStruct->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000);
+
+                       return(TRUE);
+               }
+       }
+
+       return(FALSE);
+
+}
+
+
+
diff --git a/Src/EditorFilepathBar.h b/Src/EditorFilepathBar.h
new file mode 100644 (file)
index 0000000..3ef1d06
--- /dev/null
@@ -0,0 +1,59 @@
+/////////////////////////////////////////////////////////////////////////////
+//    WinMerge:  an interactive diff/merge utility
+//    Copyright (C) 1997  Dean P. Grimm
+//
+//    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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+/////////////////////////////////////////////////////////////////////////////
+// EditorFilePathBar.h : interface of the CEditorFilePathBar class
+
+// a dialog bar for the both files path in the editor
+//   looks like a statusBar (font, height)
+//   use CFilepathEdit instead of CEdit
+//   display a tip for each path (as a tooltip)
+
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __EDITORFILEPATHBAR_H__
+#define __EDITORFILEPATHBAR_H__
+
+#include "FilepathEdit.h"
+
+
+
+class CEditorFilePathBar : public CDialogBar
+{
+public : 
+       BOOL Create( CWnd* pParentWnd);
+
+// Dialog Data
+       enum { IDD = IDD_EDITOR_HEADERBAR };
+
+       BOOL LookLikeThisWnd(CWnd * pWnd);
+       void Resize(int leftWidth, int rightWidth);
+
+       void SetFilePath(int pane, const CString &text);
+
+protected:
+       BOOL OnToolTipNotify( UINT id, NMHDR * pTTTStruct, LRESULT * pResult );
+       DECLARE_MESSAGE_MAP();
+
+private:
+       // this dialog uses custom edit boxes
+       CFilepathEdit m_EditLeft, m_EditRight;
+};
+
+
+#endif //__EDITORFILEPATHBAR_H__
\ No newline at end of file
diff --git a/Src/FilepathEdit.cpp b/Src/FilepathEdit.cpp
new file mode 100644 (file)
index 0000000..12f7405
--- /dev/null
@@ -0,0 +1,315 @@
+/////////////////////////////////////////////////////////////////////////////
+//    WinMerge:  an interactive diff/merge utility
+//    Copyright (C) 1997-2000  Thingamahoochie Software
+//    Author: Dean Grimm
+//
+//    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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+/////////////////////////////////////////////////////////////////////////////
+// FilepathEdit.cpp : implementation of the CFilepathEdit class
+//
+
+#include "stdafx.h"
+#include "Merge.h"
+
+#include "FilepathEdit.h"
+
+// for PathCompactPath
+//#include "Shlwapi.h"         // dynamically linked
+#include "dllVer.h"            
+
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+
+// safe PathCompactPath call
+// as it is not supported for shlwapi.dll before 4.71
+
+typedef BOOL (STDAPICALLTYPE *PathCompactPathFnc)(
+       HDC hDC,
+       LPTSTR lpszPath,
+       UINT dx);
+
+#ifdef UNICODE
+// Windows doesn't seem to have Unicode version of GetProcAddress, so both strings here are 8-bit :(
+#define PathCompactPathName "PathCompactPathW"
+#else
+#define PathCompactPathName "PathCompactPathA"
+#endif
+
+static BOOL PathCompactPathDynamic(HDC hdc, LPTSTR lpszPath, UINT dx)
+{
+       if (GetDllVersion(_T("shlwapi.dll")) < PACKVERSION(4,71))
+       {
+               // not supported before 4.71
+               return FALSE;
+       }
+
+       Library lib;
+       if (!lib.Load(_T("shlwapi.dll")))
+       {
+               // Shouldn't happen; GetDllVersion loaded this successfully, oh well
+               return FALSE;
+       }
+       FARPROC proc = GetProcAddress(lib.Inst(), PathCompactPathName);
+       if (!proc)
+       {
+               // Shouldn't happen, 4.71 should have this, oh well
+               return FALSE;
+       }
+       PathCompactPathFnc pathproc = (PathCompactPathFnc)proc;
+       return (*pathproc)(hdc, lpszPath, dx);
+}
+
+
+
+
+
+// format a path in a pDC box of width maxWidth
+// try to cut lines only at slash characters
+int FormatFilePathForDisplayWidth(CDC * pDC, int maxWidth, CString & sFilepath)
+{
+       int iBegin = 0;
+       int nLines = 1;
+       
+       while (1)
+       {
+               CString line;
+
+               // find the next truncation point
+               int iEndMin = 0;
+               int iEndMax = sFilepath.GetLength()-iBegin + 1;
+               while(1)
+               {
+                       int iEnd = (iEndMin + iEndMax) / 2;
+                       if (iEnd == iEndMin)
+                               break;
+                       line = sFilepath.Mid(iBegin, iEnd);
+                       int width = (pDC->GetTextExtent(line)).cx;
+                       if (width > maxWidth)
+                               iEndMax = iEnd;
+                       else
+                               iEndMin = iEnd;
+               };
+               ASSERT(iEndMax == iEndMin+1);
+
+               // here iEndMin is the last character displayed in maxWidth
+
+               // exit the loop if we can display the remaining characters with no truncation
+               if (iBegin+iEndMin == sFilepath.GetLength())
+                       break;
+
+               // truncate the text to the previous "\" if possible
+               line = sFilepath.Mid(iBegin, iEndMin);
+               int lastSlash = line.ReverseFind('\\');
+               if (lastSlash >= 0)
+                       iEndMin = lastSlash+1;
+
+               sFilepath.Insert(iBegin+iEndMin, "\n");
+               iBegin += iEndMin+2;
+               nLines ++;
+       }
+
+       return nLines;
+}
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CFilepathEdit construction/destruction
+
+BOOL CFilepathEdit::SubClassEdit(UINT nID, CWnd* pParent)
+{
+       return SubclassDlgItem(nID, pParent);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// CFilepathEdit
+
+void CFilepathEdit::GetWholeText(CString& rString) const
+{              
+       rString = wholeText;
+}
+
+// set whole text
+// and set the display text (truncate it if necessary)
+void CFilepathEdit::SetWholeText(LPCTSTR lpszString)
+{
+       if (lpszString != 0)
+               wholeText = lpszString;
+
+       RefreshDisplayText();
+}
+
+// the display test is the window text for CWnd
+void CFilepathEdit::RefreshDisplayText()
+{
+       CString line = wholeText;
+
+       // we want to keep the first and the last path component, and in between,
+       // as much characters as possible from the right
+       // PathCompactPath keeps, in between, as much characters as possible from the left
+       // so we reverse everything between the first and the last component before calling PathCompactPath
+       int iBeginLast, iEndIntro;
+       iBeginLast = line.ReverseFind('\\');
+       iEndIntro = line.Find('\\');
+       if (iBeginLast >= 0 && iEndIntro != iBeginLast)
+       {
+               CString textToReverse = line.Mid(iEndIntro+1, iBeginLast-(iEndIntro+1));
+               textToReverse.MakeReverse();
+               line = line.Left(iEndIntro+1) + textToReverse + line.Mid(iBeginLast);
+       }
+
+       // get a device context object
+       CClientDC lDC(this);
+       // and use the correct font
+       CFont * pFontOld = lDC.SelectObject(GetFont()); 
+
+       // compact the path
+       CRect rect;
+       GetRect(rect);
+       // take GetBuffer (lenght +3) to count for ellipsis
+       PathCompactPathDynamic(lDC.GetSafeHdc(), line.GetBuffer(line.GetLength()+3), rect.Width());
+       line.ReleaseBuffer();
+       
+       // set old font back
+       lDC.SelectObject(pFontOld);
+
+       // we reverse back everything between the first and the last component
+       // it works OK as "..." reversed = "..." again
+       iBeginLast = line.ReverseFind('\\');
+       iEndIntro = line.Find('\\');
+       if (iBeginLast >= 0 && iEndIntro != iBeginLast)
+       {
+               CString textToReverse = line.Mid(iEndIntro+1, iBeginLast-(iEndIntro+1));
+               textToReverse.MakeReverse();
+               line = line.Left(iEndIntro+1) + textToReverse + line.Mid(iBeginLast);
+       }
+
+       SetWindowText(line);
+}
+
+
+
+
+// updates and returns the tooltip for this edit box
+LPCTSTR CFilepathEdit::GetUpdatedTipText(CDC * pDC, int maxWidth)
+{
+       GetWholeText(toolTipString);
+
+       if (GetDllVersion(_T("shlwapi.dll")) < PACKVERSION(4,70))
+               // \n in tooltip text not supported before 4.70
+               ;
+       else
+               FormatFilePathForDisplayWidth(pDC, maxWidth, toolTipString);
+               
+       // add the help text
+// toolTipString += "\n\nRight click on the path to copy";
+
+       return (LPCTSTR) toolTipString;
+}
+
+// use this when we want to copy from the wholeText
+// the standard Copy function works with the windowText 
+void CFilepathEdit::CustomCopy(int iBegin, int iEnd /*=-1*/)
+{
+       if (iEnd == -1)
+               iEnd = wholeText.GetLength();
+
+       // get the clipboard
+       if (! OpenClipboard())
+               return;
+       if (! EmptyClipboard())
+               return;         
+               
+       // insert text into clipboard
+       HGLOBAL hData = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, iEnd-iBegin + 1);
+       if (hData == NULL)
+               return;
+       LPTSTR pszData = (LPTSTR)::GlobalLock (hData);
+       _tcscpy (pszData, (LPTSTR) wholeText.Mid(iBegin, iEnd-iBegin).GetBuffer(0));
+       GlobalUnlock (hData);
+       SetClipboardData (CF_TEXT, hData);
+
+       // release the clipboard
+       CloseClipboard ();
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CFilepathEdit message handlers
+BEGIN_MESSAGE_MAP(CFilepathEdit, CEdit)
+  ON_WM_CONTEXTMENU()
+END_MESSAGE_MAP()
+
+
+void CFilepathEdit::OnContextMenu(CWnd*, CPoint point)
+{
+       {
+               if (point.x == -1 && point.y == -1){
+                       //keystroke invocation
+                       CRect rect;
+                       GetClientRect(rect);
+                       ClientToScreen(rect);
+
+                       point = rect.TopLeft();
+                       point.Offset(5, 5);
+               }
+
+               CMenu menu;
+               VERIFY(menu.LoadMenu(IDR_POPUP_EDITOR_HEADERBAR));
+
+               CMenu* pPopup = menu.GetSubMenu(0);
+               ASSERT(pPopup != NULL);
+
+               // invoke context menu
+               // we don't want to use the main application handlers, so we use flags TPM_NONOTIFY | TPM_RETURNCMD
+               // we have to disable unwanted menu entries (everything is enabled so nothing to do)
+               // and handle the command after TrackPopupMenu
+               int command = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY  | TPM_RETURNCMD, point.x, point.y, this);
+               if (command != ID_EDITOR_COPY_FILENAME && command != ID_EDITOR_COPY_PATH)
+                       return;
+
+               // compute the beginning of the text to copy (in wholeText)
+               int iBegin;
+               switch (command)
+               {
+               case ID_EDITOR_COPY_FILENAME:
+                       {
+                       int lastSlash = wholeText.ReverseFind('\\');
+                       if (lastSlash != -1)
+                               iBegin = lastSlash+1;
+                       else
+                               iBegin = 0;
+                       }
+                       break;
+               case ID_EDITOR_COPY_PATH:
+                       iBegin = 0;
+                       break;
+               }
+               
+               CustomCopy(iBegin);
+       }
+}
+
+
+
+
diff --git a/Src/FilepathEdit.h b/Src/FilepathEdit.h
new file mode 100644 (file)
index 0000000..aae7755
--- /dev/null
@@ -0,0 +1,68 @@
+/////////////////////////////////////////////////////////////////////////////
+//    WinMerge:  an interactive diff/merge utility
+//    Copyright (C) 1997  Dean P. Grimm
+//
+//    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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+/////////////////////////////////////////////////////////////////////////////
+// FilepathEdit.h : interface of the CFilepathEdit class
+
+// an edit class for file paths : 
+//   display the path with ellipsis to fill into the CEdit 
+//   prepare a tip with the whole path and a help 
+//   has a right-click context menu with 2 functions (copy whole path, copy filename)
+
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __FILEPATHEDIT_H__
+#define __FILEPATHEDIT_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+// format a path in a pDC box of width maxWidth
+// try to cut lines only at slash characters
+int FormatFilePathForDisplayWidth(CDC * pDC, int maxWidth, CString & sFilepath);
+
+
+class CFilepathEdit : public CEdit
+{
+public : 
+       BOOL SubClassEdit(UINT nID, CWnd* pParent);
+
+       void GetWholeText( CString& rString ) const;
+       void SetWholeText(LPCTSTR lpszString );
+       void RefreshDisplayText();
+       LPCTSTR GetUpdatedTipText(CDC * pDC, int maxWidth);
+
+protected:
+       afx_msg void OnContextMenu(CWnd*, CPoint point);
+       DECLARE_MESSAGE_MAP();
+
+private:
+       void CustomCopy(int iBegin, int iEnd =-1);
+
+       CString toolTipString;
+       CString wholeText;
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+#endif //__FILEPATHEDIT_H__
index 8784e22..2f18f88 100644 (file)
@@ -279,10 +279,18 @@ SOURCE=.\ED.C
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditorFilepathBar.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\FileFilterMgr.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\FilepathEdit.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\files.cpp
 # End Source File
 # Begin Source File
@@ -688,10 +696,18 @@ SOURCE=.\EditFile.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditorFilepathBar.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\FileFilterMgr.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\FilepathEdit.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\files.h
 # End Source File
 # Begin Source File
index 0a49362..c2e994b 100644 (file)
@@ -186,6 +186,15 @@ BEGIN
     END
 END
 
+IDR_POPUP_EDITOR_HEADERBAR MENU DISCARDABLE 
+BEGIN
+    POPUP "_POPUP_"
+    BEGIN
+        MENUITEM "Copy full Path",              ID_EDITOR_COPY_PATH
+        MENUITEM "Copy Filename",               ID_EDITOR_COPY_FILENAME
+    END
+END
+
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -501,6 +510,18 @@ BEGIN
     PUSHBUTTON      "Save path",IDC_WINMERGE_PATH_SAVE,8,51,50,14
 END
 
+IDD_EDITOR_HEADERBAR DIALOGEX 0, 0, 373, 12
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+    EDITTEXT        IDC_STATIC_TITLE_LEFT,0,2,160,12,ES_AUTOHSCROLL | 
+                    ES_OEMCONVERT | ES_READONLY | NOT WS_BORDER | NOT 
+                    WS_TABSTOP,WS_EX_STATICEDGE
+    EDITTEXT        IDC_STATIC_TITLE_RIGHT,163,2,160,12,ES_AUTOHSCROLL | 
+                    ES_OEMCONVERT | ES_READONLY | NOT WS_BORDER | NOT 
+                    WS_TABSTOP,WS_EX_STATICEDGE
+END
+
 
 #ifndef _MAC
 /////////////////////////////////////////////////////////////////////////////
@@ -633,6 +654,14 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 149
     END
+
+    IDD_EDITOR_HEADERBAR, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 366
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 4
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
@@ -1142,6 +1171,8 @@ BEGIN
     ID_VIEW_WHITESPACE      "Shows whitespace characters"
     ID_REFRESH              "Refresh display\nRefresh (F5)"
     ID_SHOWLINEDIFF         "Highlight difference in current line"
+    ID_EDITOR_COPY_PATH     "Copy full Path"
+    ID_EDITOR_COPY_FILENAME "Copy Filename"
 END
 
 STRINGTABLE DISCARDABLE 
@@ -1165,6 +1196,12 @@ BEGIN
     IDS_EMPTY_LINE_STATUS_INFO "Line: %s"
 END
 
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDC_STATIC_TITLE_LEFT   "Right click on the path to copy"
+    IDC_STATIC_TITLE_RIGHT  "Right click on the path to copy"
+END
+
 #endif    // English (U.S.) resources
 /////////////////////////////////////////////////////////////////////////////
 
index 9babb5e..d420167 100644 (file)
@@ -19,29 +19,6 @@ static char THIS_FILE[] = __FILE__;
 
 static CMap<CString, LPCTSTR, long, long> f_cache;
 
-// resource pattern for APIs LoadLibrary, FreeLibrary
-struct Library
-{
-       Library() : m_hinst(0) { }
-       ~Library() { Unload(); }
-       bool Load(LPCTSTR sz)
-       {
-               Unload();
-               m_hinst = LoadLibrary(sz);
-               return m_hinst != NULL;
-       }
-       void Unload()
-       {
-               if (m_hinst)
-               {
-                       FreeLibrary(m_hinst);
-                       m_hinst = NULL;
-               }
-       }
-       HINSTANCE Inst() const { return m_hinst; }
-protected:
-       HINSTANCE m_hinst;
-};
 
 // Return major/minor version number from version resource (0 if not found)
 DWORD getFixedModuleVersion(HMODULE hmod)
index 60932f9..9b99194 100644 (file)
@@ -5,6 +5,31 @@
 #define PACKVERSION(major,minor) MAKELONG(minor,major)
 #endif
 
+// resource pattern for APIs LoadLibrary, FreeLibrary
+struct Library
+{
+       Library() : m_hinst(0) { }
+       ~Library() { Unload(); }
+       bool Load(LPCTSTR sz)
+       {
+               Unload();
+               m_hinst = LoadLibrary(sz);
+               return m_hinst != NULL;
+       }
+       void Unload()
+       {
+               if (m_hinst)
+               {
+                       FreeLibrary(m_hinst);
+                       m_hinst = NULL;
+               }
+       }
+       HINSTANCE Inst() const { return m_hinst; }
+protected:
+       HINSTANCE m_hinst;
+};
+
+
 DWORD getFixedModuleVersion(HMODULE hmod);
 DWORD GetDllVersion_Raw(LPCTSTR lpszDllName); // checks very time
 DWORD GetDllVersion(LPCTSTR lpszDllName); // checks once & caches
index 64ab3d4..78c4af6 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-30 Laoran
+ PATCH: [ 777871 ] New headerbar for the file paths 
+  WinMerge: ChildFrm.cpp ChildFrm.h dllver.cpp dllver.h Merge.dsp Merge.rc resource.h
+  WinMerge new files : EditorFilepathBar.cpp EditorFilepathBar.h FilepathEdit.cpp FilepathEdit.h
+
 2003-07-30 Perry
  PATCH: [ 778379 ] Drag&drop reordering columns
   WinMerge: DirDoc.cpp DirView.cpp DirView.h Merge.dsp dllver.cpp dllver.h
index be30800..ecc6a18 100644 (file)
@@ -22,6 +22,8 @@
 #define IDD_PROPPAGE_FILTER             111
 #define IDD_OUTPUT                      112
 #define IDD_PROPPAGE_REGISTRY           113
+#define IDD_EDITOR_HEADERBAR            114
+#define IDR_POPUP_EDITOR_HEADERBAR      115
 #define IDS_VERSION_FMT                 130
 #define IDS_ALLFILES                    131
 #define IDS_CONFIRM_ALL_LEFT            132
 #define IDC_WINMERGE_PATH_BROWSE        1045
 #define IDC_WINMERGE_PATH               1046
 #define IDC_WINMERGE_PATH_SAVE          1047
+#define IDC_STATIC_TITLE_LEFT           1048
+#define IDC_STATIC_TITLE_RIGHT          1049
 #define IDS_NUM_REPLACED                8501
 #define IDS_EDIT_TEXT_NOT_FOUND         8502
 #define IDS_LINE_STATUS_INFO            8503
 #define ID_REFRESH                      32819
 #define ID_EDIT_FIND_PREVIOUS           32820
 #define ID_SHOWLINEDIFF                 32821
+#define ID_EDITOR_COPY_PATH             32822
+#define ID_EDITOR_COPY_FILENAME         32823
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        114
+#define _APS_NEXT_RESOURCE_VALUE        116
 #define _APS_NEXT_COMMAND_VALUE         32822
-#define _APS_NEXT_CONTROL_VALUE         1048
+#define _APS_NEXT_CONTROL_VALUE         1050
 #define _APS_NEXT_SYMED_VALUE           108
 #endif
 #endif