1 // PatchViewDlg.cpp : implementation file
5 #include "TortoiseProc.h"
6 #include "PatchViewDlg.h"
9 #include "UnicodeUtils.h"
10 // CPatchViewDlg dialog
12 IMPLEMENT_DYNAMIC(CPatchViewDlg
, CDialog
)
14 CPatchViewDlg::CPatchViewDlg(CWnd
* pParent
/*=NULL*/)
15 : CDialog(CPatchViewDlg::IDD
, pParent
)
20 CPatchViewDlg::~CPatchViewDlg()
24 void CPatchViewDlg::DoDataExchange(CDataExchange
* pDX
)
26 CDialog::DoDataExchange(pDX
);
27 DDX_Control(pDX
, IDC_PATCH
, m_ctrlPatchView
);
30 BEGIN_MESSAGE_MAP(CPatchViewDlg
, CDialog
)
37 void CPatchViewDlg::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, const char *face
)
39 m_ctrlPatchView
.Call(SCI_STYLESETFORE
, style
, fore
);
40 m_ctrlPatchView
.Call(SCI_STYLESETBACK
, style
, back
);
42 m_ctrlPatchView
.Call(SCI_STYLESETSIZE
, style
, size
);
44 m_ctrlPatchView
.Call(SCI_STYLESETFONT
, style
, reinterpret_cast<LPARAM
>(face
));
48 // CPatchViewDlg message handlers
50 BOOL
CPatchViewDlg::OnInitDialog()
52 CDialog::OnInitDialog();
54 // TODO: Add extra initialization here
55 m_ctrlPatchView
.Init(*m_pProjectProperties
);
56 m_ctrlPatchView
.SetFont((CString
)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
58 SetAStyle(STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
), ::GetSysColor(COLOR_WINDOW
),
59 // Reusing TortoiseBlame's setting which already have an user friendly
60 // pane in TortoiseSVN's Settings dialog, while there is no such
61 // pane for TortoiseUDiff.
62 CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
63 WideToMultibyte(CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str());
65 m_ctrlPatchView
.Call(SCI_SETTABWIDTH
, 4);
66 m_ctrlPatchView
.Call(SCI_SETREADONLY
, TRUE
);
67 //LRESULT pix = m_ctrlPatchView.Call(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"_99999");
68 //m_ctrlPatchView.Call(SCI_SETMARGINWIDTHN, 0, pix);
69 //m_ctrlPatchView.Call(SCI_SETMARGINWIDTHN, 1);
70 //m_ctrlPatchView.Call(SCI_SETMARGINWIDTHN, 2);
71 //Set the default windows colors for edit controls
72 m_ctrlPatchView
.Call(SCI_STYLESETFORE
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
));
73 m_ctrlPatchView
.Call(SCI_STYLESETBACK
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOW
));
74 m_ctrlPatchView
.Call(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
75 m_ctrlPatchView
.Call(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
76 m_ctrlPatchView
.Call(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
78 //SendEditor(SCI_SETREADONLY, FALSE);
79 m_ctrlPatchView
.Call(SCI_CLEARALL
);
80 m_ctrlPatchView
.Call(EM_EMPTYUNDOBUFFER
);
81 m_ctrlPatchView
.Call(SCI_SETSAVEPOINT
);
82 m_ctrlPatchView
.Call(SCI_CANCEL
);
83 m_ctrlPatchView
.Call(SCI_SETUNDOCOLLECTION
, 0);
85 m_ctrlPatchView
.Call(SCI_SETUNDOCOLLECTION
, 1);
86 m_ctrlPatchView
.Call(SCI_SETWRAPMODE
,SC_WRAP_NONE
);
88 //::SetFocus(m_hWndEdit);
89 m_ctrlPatchView
.Call(EM_EMPTYUNDOBUFFER
);
90 m_ctrlPatchView
.Call(SCI_SETSAVEPOINT
);
91 m_ctrlPatchView
.Call(SCI_GOTOPOS
, 0);
93 m_ctrlPatchView
.Call(SCI_CLEARDOCUMENTSTYLE
, 0, 0);
94 m_ctrlPatchView
.Call(SCI_SETSTYLEBITS
, 5, 0);
96 //SetAStyle(SCE_DIFF_DEFAULT, RGB(0, 0, 0));
97 SetAStyle(SCE_DIFF_COMMAND
, RGB(0x0A, 0x24, 0x36));
98 SetAStyle(SCE_DIFF_POSITION
, RGB(0xFF, 0, 0));
99 SetAStyle(SCE_DIFF_HEADER
, RGB(0x80, 0, 0), RGB(0xFF, 0xFF, 0x80));
100 SetAStyle(SCE_DIFF_COMMENT
, RGB(0, 0x80, 0));
101 m_ctrlPatchView
.Call(SCI_STYLESETBOLD
, SCE_DIFF_COMMENT
, TRUE
);
102 SetAStyle(SCE_DIFF_DELETED
, ::GetSysColor(COLOR_WINDOWTEXT
), RGB(0xFF, 0x80, 0x80));
103 SetAStyle(SCE_DIFF_ADDED
, ::GetSysColor(COLOR_WINDOWTEXT
), RGB(0x80, 0xFF, 0x80));
105 m_ctrlPatchView
.Call(SCI_SETLEXER
, SCLEX_DIFF
);
106 m_ctrlPatchView
.Call(SCI_SETKEYWORDS
, 0, (LPARAM
)"revision");
107 m_ctrlPatchView
.Call(SCI_COLOURISE
, 0, -1);
109 return TRUE
; // return TRUE unless you set the focus to a control
110 // EXCEPTION: OCX Property Pages should return FALSE
113 void CPatchViewDlg::OnSize(UINT nType
, int cx
, int cy
)
115 CDialog::OnSize(nType
, cx
, cy
);
117 // TODO: Add your message handler code here
118 if (this->IsWindowVisible())
122 GetDlgItem(IDC_PATCH
)->MoveWindow(rect
.left
, rect
.top
, cx
, cy
);
126 void CPatchViewDlg::OnMoving(UINT fwSide
, LPRECT pRect
)
128 // TODO: Add your message handler code here
131 this->m_ParentCommitDlg
->GetWindowRect(&parentRect
);
132 if (abs(parentRect
.right
- pRect
->left
) < STICKYSIZE
)
134 int width
= pRect
->right
- pRect
->left
;
135 pRect
->left
= parentRect
.right
;
136 pRect
->right
= pRect
->left
+ width
;
138 CDialog::OnMoving(fwSide
, pRect
);
141 void CPatchViewDlg::OnDestroy()
143 CDialog::OnDestroy();
145 this->m_ParentCommitDlg
->ShowViewPatchText(true);
146 // TODO: Add your message handler code here
149 void CPatchViewDlg::OnClose()
151 // TODO: Add your message handler code here and/or call default
153 this->DestroyWindow();