OSDN Git Service

Git Rebase Dialog Resize and modify split position okay
authorFrank Li <lznuaa@gmail.com>
Fri, 13 Feb 2009 08:38:06 +0000 (16:38 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 13 Feb 2009 08:44:59 +0000 (16:44 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/RebaseDlg.cpp
src/TortoiseProc/RebaseDlg.h
src/TortoiseProc/resource.h

index 4adba90..9286524 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index f0b736d..e3a658d 100644 (file)
@@ -31,6 +31,8 @@ void CRebaseDlg::DoDataExchange(CDataExchange* pDX)
     DDX_Check(pDX, IDC_PICK_ALL, m_bPickAll);\r
     DDX_Check(pDX, IDC_SQUASH_ALL, m_bSquashAll);\r
     DDX_Check(pDX, IDC_EDIT_ALL, m_bEditAll);\r
+       DDX_Control(pDX, IDC_REBASE_SPLIT, m_wndSplitter);\r
+       DDX_Control(pDX,IDC_COMMIT_LIST,m_CommitList);\r
 }\r
 \r
 \r
@@ -39,8 +41,24 @@ BEGIN_MESSAGE_MAP(CRebaseDlg, CResizableStandAloneDialog)
     ON_BN_CLICKED(IDC_SQUASH_ALL, &CRebaseDlg::OnBnClickedSquashAll)\r
     ON_BN_CLICKED(IDC_EDIT_ALL, &CRebaseDlg::OnBnClickedEditAll)\r
     ON_BN_CLICKED(IDC_REBASE_SPLIT, &CRebaseDlg::OnBnClickedRebaseSplit)\r
+       ON_WM_SIZE()\r
 END_MESSAGE_MAP()\r
 \r
+void CRebaseDlg::AddRebaseAnchor()\r
+{\r
+       AddAnchor(IDC_REBASE_TAB,TOP_LEFT,BOTTOM_RIGHT);\r
+       AddAnchor(IDC_COMMIT_LIST,TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_REBASE_SPLIT,TOP_LEFT, TOP_RIGHT);\r
+       AddAnchor(IDC_STATUS_STATIC, BOTTOM_LEFT,BOTTOM_RIGHT);\r
+       AddAnchor(IDC_REBASE_CONTINUE,BOTTOM_RIGHT);\r
+       AddAnchor(IDC_REBASE_ABORT, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_REBASE_PROGRESS,BOTTOM_LEFT, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_PICK_ALL,TOP_LEFT);\r
+       AddAnchor(IDC_SQUASH_ALL,TOP_LEFT);\r
+       AddAnchor(IDC_EDIT_ALL,TOP_LEFT);\r
+       \r
+}\r
+\r
 BOOL CRebaseDlg::OnInitDialog()\r
 {\r
        CResizableStandAloneDialog::OnInitDialog();\r
@@ -48,10 +66,19 @@ BOOL CRebaseDlg::OnInitDialog()
        CRect rectDummy;\r
        //IDC_REBASE_DUMY_TAB\r
        \r
+       GetClientRect(m_DlgOrigRect);\r
+       m_CommitList.GetClientRect(m_CommitListOrigRect);\r
+\r
        CWnd *pwnd=this->GetDlgItem(IDC_REBASE_DUMY_TAB);\r
        pwnd->GetWindowRect(&rectDummy);\r
+\r
+       rectDummy.top-=20;\r
+       rectDummy.bottom-=20;\r
+\r
+       rectDummy.left-=5;\r
+       rectDummy.right-=5;\r
        \r
-       if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 0))\r
+       if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_REBASE_TAB))\r
        {\r
                TRACE0("Failed to create output tab window\n");\r
                return FALSE;      // fail to create\r
@@ -73,8 +100,35 @@ BOOL CRebaseDlg::OnInitDialog()
                return FALSE;\r
        }\r
 \r
+       m_FileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS , _T("RebaseDlg"));\r
+\r
        m_ctrlTabCtrl.AddTab(&m_FileListCtrl,_T("Modified File"));\r
        m_ctrlTabCtrl.AddTab(&m_LogMessageCtrl,_T("Log Message"),1);\r
+       AddRebaseAnchor();\r
+\r
+\r
+       EnableSaveRestore(_T("RebaseDlg"));\r
+\r
+       DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));\r
+       RECT rcDlg, rcLogMsg, rcFileList;\r
+       GetClientRect(&rcDlg);\r
+       m_CommitList.GetWindowRect(&rcLogMsg);\r
+       ScreenToClient(&rcLogMsg);\r
+       this->m_ctrlTabCtrl.GetWindowRect(&rcFileList);\r
+       ScreenToClient(&rcFileList);\r
+       if (yPos)\r
+       {\r
+               RECT rectSplitter;\r
+               m_wndSplitter.GetWindowRect(&rectSplitter);\r
+               ScreenToClient(&rectSplitter);\r
+               int delta = yPos - rectSplitter.top;\r
+               if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30))\r
+               {\r
+                       m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE);\r
+                       DoSize(delta);\r
+               }\r
+       }\r
+\r
 \r
        return TRUE;\r
 }\r
@@ -99,3 +153,86 @@ void CRebaseDlg::OnBnClickedRebaseSplit()
 {\r
     // TODO: Add your control notification handler code here\r
 }\r
+\r
+LRESULT CRebaseDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r
+{\r
+       switch (message) {\r
+       case WM_NOTIFY:\r
+               if (wParam == IDC_REBASE_SPLIT)\r
+               { \r
+                       SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
+                       DoSize(pHdr->delta);\r
+               }\r
+               break;\r
+       }\r
+\r
+       return __super::DefWindowProc(message, wParam, lParam);\r
+}\r
+\r
+void CRebaseDlg::DoSize(int delta)\r
+{\r
+       \r
+       this->RemoveAllAnchors();\r
+\r
+       CSplitterControl::ChangeHeight(GetDlgItem(IDC_COMMIT_LIST), delta, CW_TOPALIGN);\r
+       //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);\r
+       CSplitterControl::ChangeHeight(GetDlgItem(IDC_REBASE_TAB), -delta, CW_BOTTOMALIGN);\r
+       //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);\r
+       CSplitterControl::ChangePos(GetDlgItem(IDC_SQUASH_ALL),0,delta);\r
+       CSplitterControl::ChangePos(GetDlgItem(IDC_PICK_ALL),0,delta);\r
+       CSplitterControl::ChangePos(GetDlgItem(IDC_EDIT_ALL),0,delta);\r
+       \r
+       this->AddRebaseAnchor();\r
+       // adjust the minimum size of the dialog to prevent the resizing from\r
+       // moving the list control too far down.\r
+       CRect rcLogMsg;\r
+       m_CommitList.GetClientRect(rcLogMsg);\r
+       SetMinTrackSize(CSize(m_DlgOrigRect.Width(), m_DlgOrigRect.Height()-m_CommitListOrigRect.Height()+rcLogMsg.Height()));\r
+\r
+       SetSplitterRange();\r
+//     m_CommitList.Invalidate();\r
+\r
+//     GetDlgItem(IDC_LOGMESSAGE)->Invalidate();\r
+\r
+       this->m_ctrlTabCtrl.Invalidate();\r
+       this->m_CommitList.Invalidate();\r
+       this->m_FileListCtrl.Invalidate();\r
+       this->m_LogMessageCtrl.Invalidate();\r
+\r
+}\r
+\r
+void CRebaseDlg::SetSplitterRange()\r
+{\r
+       if ((m_CommitList)&&(m_ctrlTabCtrl))\r
+       {\r
+               CRect rcTop;\r
+               m_CommitList.GetWindowRect(rcTop);\r
+               ScreenToClient(rcTop);\r
+               CRect rcMiddle;\r
+               m_ctrlTabCtrl.GetWindowRect(rcMiddle);\r
+               ScreenToClient(rcMiddle);\r
+               if (rcMiddle.Height() && rcMiddle.Width())\r
+                       m_wndSplitter.SetRange(rcTop.top+60, rcMiddle.bottom-80);\r
+       }\r
+}\r
+\r
+void CRebaseDlg::OnSize(UINT nType,int cx, int cy)\r
+{\r
+        // first, let the resizing take place\r
+    __super::OnSize(nType, cx, cy);\r
+\r
+    //set range\r
+    SetSplitterRange();\r
+}\r
+\r
+void CRebaseDlg::SaveSplitterPos()\r
+{\r
+       if (!IsIconic())\r
+       {\r
+               CRegDWORD regPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));\r
+               RECT rectSplitter;\r
+               m_wndSplitter.GetWindowRect(&rectSplitter);\r
+               ScreenToClient(&rectSplitter);\r
+               regPos = rectSplitter.top;\r
+       }\r
+}
\ No newline at end of file
index b53b07e..e3a7d60 100644 (file)
@@ -4,7 +4,9 @@
 #include "StandAloneDlg.h"\r
 #include "GitStatusListCtrl.h"\r
 #include "SciEdit.h"\r
+#include "SplitterControl.h"\r
 // CRebaseDlg dialog\r
+#define IDC_REBASE_TAB 0x1000000\r
 \r
 class CRebaseDlg : public CResizableStandAloneDialog\r
 {\r
@@ -21,19 +23,34 @@ protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        virtual BOOL OnInitDialog();\r
        DECLARE_MESSAGE_MAP()\r
+       virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r
+       void DoSize(int delta);\r
+       void AddRebaseAnchor();\r
+       void RemoveAnchor();\r
+\r
+       void SetSplitterRange();\r
+       void SaveSplitterPos();\r
+       \r
+       CRect                           m_DlgOrigRect;\r
+       CRect                           m_CommitListOrigRect;\r
+\r
 public:\r
    \r
     afx_msg void OnBnClickedPickAll();\r
     afx_msg void OnBnClickedSquashAll();\r
     afx_msg void OnBnClickedEditAll();\r
     afx_msg void OnBnClickedRebaseSplit();\r
+       afx_msg void OnSize(UINT nType, int cx, int cy);\r
+\r
     CProgressCtrl m_ProgressBar;\r
     CStatic m_CtrlStatusText;\r
     BOOL m_bPickAll;\r
     BOOL m_bSquashAll;\r
     BOOL m_bEditAll;\r
 \r
+       CSplitterControl        m_wndSplitter;\r
        CMFCTabCtrl m_ctrlTabCtrl;\r
        CGitStatusListCtrl m_FileListCtrl;\r
        CSciEdit                   m_LogMessageCtrl;\r
+       CListCtrl                  m_CommitList;\r
 };\r
index 2d9cc51..36fdeab 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ