forked from WinMerge/winmerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChildFrm.cpp
677 lines (592 loc) · 18.8 KB
/
ChildFrm.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
/////////////////////////////////////////////////////////////////////////////
// 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.
//
/////////////////////////////////////////////////////////////////////////////
/**
* @file ChildFrm.cpp
*
* @brief Implementation file for CChildFrame
*
*/
#include "stdafx.h"
#include "ChildFrm.h"
#include "Merge.h"
#include "MainFrm.h"
#include "MergeDoc.h"
#include "MergeEditView.h"
#include "LocationView.h"
#include "DiffViewBar.h"
#include "OptionsDef.h"
#include "OptionsMgr.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define SWAPPARAMS_IF(c, a, b) (c ? a : b), (c ? b : a)
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
ON_WM_MDIACTIVATE()
ON_WM_TIMER()
ON_WM_GETMINMAXINFO()
ON_UPDATE_COMMAND_UI(ID_VIEW_DETAIL_BAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_DETAIL_BAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_LOCATION_BAR, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_LOCATION_BAR, OnBarCheck)
ON_COMMAND(ID_VIEW_SPLITVERTICALLY, OnViewSplitVertically)
ON_UPDATE_COMMAND_UI(ID_VIEW_SPLITVERTICALLY, OnUpdateViewSplitVertically)
ON_MESSAGE(MSG_STORE_PANESIZES, OnStorePaneSizes)
ON_WM_SIZE()
ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#define IDT_SAVEPOSITION 2
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
/**
* @brief Constructor.
*/
CChildFrame::CChildFrame()
#pragma warning(disable:4355) // 'this' : used in base member initializer list
: m_hIdentical(NULL)
, m_hDifferent(NULL)
#pragma warning(default:4355)
{
m_bActivated = FALSE;
std::fill_n(m_nLastSplitPos, 2, 0);
m_pMergeDoc = 0;
}
/**
* Destructor.
*/
CChildFrame::~CChildFrame()
{
m_wndDetailBar.setSplitter(0);
}
BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
BOOL bSplitVert = !GetOptionsMgr()->GetBool(OPT_SPLIT_HORIZONTALLY);
CMergeDoc * pDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, SWAPPARAMS_IF(bSplitVert, 1, pDoc->m_nBuffers),
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL) )
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
int pane;
for (pane = 0; pane < pDoc->m_nBuffers; pane++)
{
if (!m_wndSplitter.CreateView(SWAPPARAMS_IF(bSplitVert, 0, pane),
RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
{
TRACE1("Failed to create pane%d\n", pane);
return FALSE;
}
}
m_wndSplitter.ResizablePanes(TRUE);
m_wndSplitter.AutoResizePanes(GetOptionsMgr()->GetBool(OPT_RESIZE_PANES));
// Merge frame has also a dockable bar at the very left
// This is not the client area, but we create it now because we want
// to use the CCreateContext
String sCaption = _("Location Pane");
if (!m_wndLocationBar.Create(this, sCaption.c_str(), WS_CHILD | WS_VISIBLE, ID_VIEW_LOCATION_BAR))
{
TRACE0("Failed to create LocationBar\n");
return FALSE;
}
CWnd* pWnd = new CLocationView;
DWORD dwStyle = AFX_WS_DEFAULT_VIEW & ~WS_BORDER;
pWnd->Create(NULL, NULL, dwStyle, CRect(0,0,40,100), &m_wndLocationBar, 152, pContext);
// Merge frame has also a dockable bar at the very bottom
// This is not the client area, but we create it now because we want
// to use the CCreateContext
sCaption = _("Diff Pane");
if (!m_wndDetailBar.Create(this, sCaption.c_str(), WS_CHILD | WS_VISIBLE, ID_VIEW_DETAIL_BAR))
{
TRACE0("Failed to create DiffViewBar\n");
return FALSE;
}
// create a splitter with 2 rows, 1 column
// this is not a vertical scrollable splitter (see MergeDiffDetailView.h)
if (!m_wndDetailSplitter.CreateStatic(&m_wndDetailBar, SWAPPARAMS_IF(bSplitVert, pDoc->m_nBuffers, 1),
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, AFX_IDW_PANE_FIRST+1) )
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
for (pane = 0; pane < pDoc->m_nBuffers; pane++)
{
// add splitter pane - the default view in column (pane)
if (!m_wndDetailSplitter.CreateView(SWAPPARAMS_IF(bSplitVert, pane, 0),
RUNTIME_CLASS(CMergeEditView), CSize(-1, 200), pContext))
{
TRACE1("Failed to create pane %d\n", pane);
return FALSE;
}
}
m_wndDetailSplitter.LockBar(TRUE);
m_wndDetailSplitter.ResizablePanes(TRUE);
m_wndDetailBar.setSplitter(&m_wndDetailSplitter);
// stash left & right pointers into the mergedoc
CMergeEditView * pView[3];
for (pane = 0; pane < pDoc->m_nBuffers; pane++)
{
pView[pane] = static_cast<CMergeEditView *>(m_wndSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, 0, pane)));
// connect merge views up to display of status info
pView[pane]->SetStatusInterface(m_wndStatusBar.GetIMergeEditStatus(pane));
pView[pane]->m_nThisPane = pane;
}
// tell merge doc about these views
m_pMergeDoc = dynamic_cast<CMergeDoc *>(pContext->m_pCurrentDoc);
m_pMergeDoc->SetMergeViews(pView);
// stash left & right detail pointers into the mergedoc
CMergeEditView * pDetail[3];
for (pane = 0; pane < pDoc->m_nBuffers; pane++)
{
pDetail[pane] = static_cast<CMergeEditView *>(m_wndDetailSplitter.GetPane(SWAPPARAMS_IF(bSplitVert, pane, 0)));
pDetail[pane]->m_nThisPane = pane;
}
// tell merge doc about these views
m_pMergeDoc->SetMergeDetailViews(pDetail);
m_wndFilePathBar.SetPaneCount(pDoc->m_nBuffers);
m_wndStatusBar.SetPaneCount(pDoc->m_nBuffers);
// Set frame window handles so we can post stage changes back
static_cast<CLocationView *>(pWnd)->SetFrameHwnd(GetSafeHwnd());
m_wndLocationBar.SetFrameHwnd(GetSafeHwnd());
m_wndDetailBar.SetFrameHwnd(GetSafeHwnd());
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
/**
* @brief Create the child frame, the splitter, the filename bar, the status bar,
* the diff dockable bar, and the four views
*
* @note the panels layout is
* <ul>
* <li> -----------
* <li> ! header !
* <li> !.........!
* <li> !. . .!
* <li> !. 1 . 2 .!
* <li> !. . .!
* <li> !.........!
* <li> !.........!
* <li> ! status !
* <li> -----------
* <li> !.........!
* <li> !. 3 .!
* <li> !.dockable!
* <li> ! splitbar!
* <li> !. 4 .!
* <li> !.........!
* <li> -----------
* </ul>
*/
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM|CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
// Merge frame has a header bar at top
if (!m_wndFilePathBar.Create(this))
{
TRACE0("Failed to create dialog bar\n");
return -1; // fail to create
}
// Set filename bars inactive so colors get initialized
m_wndFilePathBar.SetActive(0, false);
m_wndFilePathBar.SetActive(1, false);
m_wndFilePathBar.SetActive(2, false);
// Merge frame also has a dockable bar at the very left
// created in OnCreateClient
m_wndLocationBar.SetBarStyle(m_wndLocationBar.GetBarStyle() |
CBRS_SIZE_DYNAMIC | CBRS_ALIGN_LEFT);
m_wndLocationBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
DockControlBar(&m_wndLocationBar, AFX_IDW_DOCKBAR_LEFT);
// Merge frame also has a dockable bar at the very bottom
// created in OnCreateClient
m_wndDetailBar.SetBarStyle(m_wndDetailBar.GetBarStyle() |
CBRS_SIZE_DYNAMIC | CBRS_ALIGN_TOP);
m_wndDetailBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
DockControlBar(&m_wndDetailBar, AFX_IDW_DOCKBAR_BOTTOM);
// Merge frame also has a status bar at bottom,
// m_wndDetailBar is below, so we create this bar after m_wndDetailBar
if (!m_wndStatusBar.Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALTEXTFILE);
m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALTEXTFILE);
return 0;
}
/**
* @brief We must use this function before a call to SetDockState
*
* @note Without this, SetDockState will assert or crash if a bar from the
* CDockState is missing in the current CChildFrame.
* The bars are identified with their ID. This means the missing bar bug is triggered
* when we run WinMerge after changing the ID of a bar.
*/
BOOL CChildFrame::EnsureValidDockState(CDockState& state)
{
for (int i = (int) state.m_arrBarInfo.GetSize()-1 ; i >= 0; i--)
{
BOOL barIsCorrect = TRUE;
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
if (! pInfo)
barIsCorrect = FALSE;
else
{
if (! pInfo->m_bFloating)
{
pInfo->m_pBar = GetControlBar(pInfo->m_nBarID);
if (!pInfo->m_pBar)
barIsCorrect = FALSE; //toolbar id's probably changed
}
}
if (! barIsCorrect)
state.m_arrBarInfo.RemoveAt(i);
}
return TRUE;
}
static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_NCPAINT:
case WM_PAINT:
return 0;
case WM_NCACTIVATE:
return 1;
case WM_SIZE:
if (wParam != SIZE_RESTORED)
return 0;
}
WNDPROC pfnOldWndProc = (WNDPROC)GetProp(hwnd, _T("OldWndProc"));
return CallWindowProc(pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
if (lParam == FALSE)
{
if (IsWindowVisible(hwnd))
::SendMessage(hwnd, WM_SETREDRAW, (WPARAM)lParam, 0);
else
SetProp(hwnd, _T("Hidden"), (HANDLE)1);
}
else
{
BOOL bHidden = static_cast<BOOL>(reinterpret_cast<uintptr_t>(RemoveProp(hwnd, _T("Hidden"))));
if (!bHidden)
::SendMessage(hwnd, WM_SETREDRAW, (WPARAM)lParam, 0);
}
return TRUE;
}
/**
* @brief Alternative LockWindowUpdate(hWnd) API.
* See the comment near the code that calls this function.
*/
static BOOL MyLockWindowUpdate(HWND hwnd)
{
WNDPROC pfnOldWndProc;
EnumChildWindows(hwnd, EnumChildProc, FALSE);
pfnOldWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
SetProp(hwnd, _T("OldWndProc"), (HANDLE)pfnOldWndProc);
return TRUE;
}
/**
* @brief Alternative LockWindowUpdate(NULL) API.
* See the comment near the code that calls this function.
*/
static BOOL MyUnlockWindowUpdate(HWND hwnd)
{
WNDPROC pfnOldWndProc = (WNDPROC)RemoveProp(hwnd, _T("OldWndProc"));
if (pfnOldWndProc)
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnOldWndProc);
EnumChildWindows(hwnd, EnumChildProc, TRUE);
return TRUE;
}
void CChildFrame::ActivateFrame(int nCmdShow)
{
BOOL bMaximized = FALSE;
CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);
if (!m_bActivated)
{
m_bActivated = TRUE;
// get the active child frame, and a flag whether it is maximized
if (oldActiveFrame == NULL)
// for the first frame, get the restored/maximized state from the registry
bMaximized = theApp.GetProfileInt(_T("Settings"), _T("ActiveFrameMax"), TRUE);
if (bMaximized)
nCmdShow = SW_SHOWMAXIMIZED;
else
nCmdShow = SW_SHOWNORMAL;
}
// load docking positions and sizes
CDockState pDockState;
pDockState.LoadState(_T("Settings"));
if (EnsureValidDockState(pDockState)) // checks for valid so won't ASSERT
SetDockState(pDockState);
// for the dimensions of the diff and location pane, use the CSizingControlBar loader
m_wndLocationBar.LoadState(_T("Settings"));
m_wndDetailBar.LoadState(_T("Settings"));
if (bMaximized)
{
// If ActivateFrame() is called without tricks, Resizing panes in MergeView window could be visible.
// Here, two tricks are used.
// [First trick]
// To complete resizing panes before displaying MergeView window,
// it needs to send WM_SIZE message with SIZE_MAXIMIZED to MergeView window before calling ActivateFrame().
// [Second trick]
// But it causes side effect that DirView window becomes restored window from maximized window
// and the process could be visible.
// To avoid it, it needs to block the redrawing DirView window.
// I had tried to use LockWindowUpdate for this purpose. However, it had caused flickering desktop icons.
// So instead of using LockWindowUpdate(),
// I wrote My[Lock/Unlock]WindowUpdate() function that uses subclassing window.
//
if (oldActiveFrame)
MyLockWindowUpdate(oldActiveFrame->m_hWnd);
RECT rc;
GetClientRect(&rc);
SendMessage(WM_SIZE, SIZE_MAXIMIZED, MAKELPARAM(rc.right, rc.bottom));
CMDIChildWnd::ActivateFrame(nCmdShow);
if (oldActiveFrame)
MyUnlockWindowUpdate(oldActiveFrame->m_hWnd);
}
else
{
RecalcLayout();
CMDIChildWnd::ActivateFrame(nCmdShow);
}
}
BOOL CChildFrame::DestroyWindow()
{
SavePosition();
// If we are active, save the restored/maximized state
// If we are not, do nothing and let the active frame do the job.
if (this->GetParentFrame()->GetActiveFrame() == (CFrameWnd*)this)
{
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(&wp);
theApp.WriteProfileInt(_T("Settings"), _T("ActiveFrameMax"), (wp.showCmd == SW_MAXIMIZE));
}
return CMDIChildWnd::DestroyWindow();
}
/**
* @brief Save coordinates of the frame, splitters, and bars
*
* @note Do not save the maximized/restored state here. We are interested
* in the state of the active frame, and maybe this frame is not active
*/
void CChildFrame::SavePosition()
{
CRect rc;
CWnd* pLeft = m_wndSplitter.GetPane(0,0);
if (pLeft != NULL)
{
pLeft->GetWindowRect(&rc);
theApp.WriteProfileInt(_T("Settings"), _T("WLeft"), rc.Width());
}
// save the bars layout
// save docking positions and sizes
CDockState m_pDockState;
GetDockState(m_pDockState);
m_pDockState.SaveState(_T("Settings"));
// for the dimensions of the diff pane, use the CSizingControlBar save
m_wndLocationBar.SaveState(_T("Settings"));
m_wndDetailBar.SaveState(_T("Settings"));
int iCol;
m_wndSplitter.GetActivePane(NULL, &iCol);
theApp.WriteProfileInt(_T("Settings"), _T("ActivePane"), iCol);
}
void CChildFrame::OnClose()
{
// clean up pointers.
CMDIChildWnd::OnClose();
GetMainFrame()->ClearStatusbarItemCount();
}
/// update splitting position for panels 1/2 and headerbar and statusbar
void CChildFrame::UpdateHeaderSizes()
{
if(!::IsWindow(m_wndFilePathBar.m_hWnd) || !::IsWindow(m_wndSplitter.m_hWnd))
return;
if(IsWindowVisible())
{
int w[3];
int pane;
CMergeDoc * pDoc = GetMergeDoc();
if (m_wndSplitter.GetColumnCount() > 1)
{
for (pane = 0; pane < m_wndSplitter.GetColumnCount(); pane++)
{
int wmin;
m_wndSplitter.GetColumnInfo(pane, w[pane], wmin);
if (w[pane]<1) w[pane]=1; // Perry 2003-01-22 (I don't know why this happens)
}
}
else
{
CRect rect;
m_wndSplitter.GetWindowRect(&rect);
for (pane = 0; pane < pDoc->m_nBuffers; pane++)
{
w[pane] = rect.Width() / pDoc->m_nBuffers;
}
}
if (!std::equal(m_nLastSplitPos, m_nLastSplitPos + pDoc->m_nBuffers - 1, w))
{
std::copy_n(w, pDoc->m_nBuffers - 1, m_nLastSplitPos);
// resize controls in header dialog bar
m_wndFilePathBar.Resize(w);
m_wndStatusBar.Resize(w);
}
}
}
IHeaderBar * CChildFrame::GetHeaderInterface()
{
return &m_wndFilePathBar;
}
/**
* @brief Reflect comparison result in window's icon.
* @param nResult [in] Last comparison result which the application returns.
*/
void CChildFrame::SetLastCompareResult(int nResult)
{
HICON hCurrent = GetIcon(FALSE);
HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
if (hCurrent != hReplace)
{
SetIcon(hReplace, TRUE);
BOOL bMaximized;
GetMDIFrame()->MDIGetActive(&bMaximized);
// When MDI maximized the window icon is drawn on the menu bar, so we
// need to notify it that our icon has changed.
if (bMaximized)
{
GetMDIFrame()->DrawMenuBar();
}
GetMDIFrame()->OnUpdateFrameTitle(FALSE);
}
theApp.SetLastCompareResult(nResult);
}
void CChildFrame::UpdateAutoPaneResize()
{
m_wndSplitter.AutoResizePanes(GetOptionsMgr()->GetBool(OPT_RESIZE_PANES));
}
void CChildFrame::UpdateSplitter()
{
m_wndSplitter.RecalcLayout();
m_wndDetailBar.UpdateBarHeight(0);
}
/**
* @brief Synchronize control with splitter position,
*/
void CChildFrame::OnIdleUpdateCmdUI()
{
UpdateHeaderSizes();
CMDIChildWnd::OnIdleUpdateCmdUI();
}
void CChildFrame::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == IDT_SAVEPOSITION)
{
SavePosition();
KillTimer(IDT_SAVEPOSITION);
}
else
{
UpdateHeaderSizes();
}
CMDIChildWnd::OnTimer(nIDEvent);
}
void CChildFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
// [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
// https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
#if _MFC_VER >= 0x0800
lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
#endif
}
void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
CMergeDoc *pDoc = GetMergeDoc();
if (bActivate && pDoc)
this->GetParentFrame()->PostMessage(WM_USER+1);
return;
}
/**
* @brief Split panes vertically
*/
void CChildFrame::OnViewSplitVertically()
{
bool bSplitVertically = (m_wndSplitter.GetColumnCount() != 1);
bSplitVertically = !bSplitVertically; // toggle
GetOptionsMgr()->SaveOption(OPT_SPLIT_HORIZONTALLY, !bSplitVertically);
m_wndSplitter.FlipSplit();
m_wndDetailSplitter.FlipSplit();
}
/**
* @brief Update "Split Vertically" UI items
*/
void CChildFrame::OnUpdateViewSplitVertically(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
pCmdUI->SetCheck((m_wndSplitter.GetColumnCount() != 1));
}
/// Document commanding us to close
void CChildFrame::CloseNow()
{
SavePosition(); // Save settings before closing!
MDIActivate();
MDIDestroy();
}
/**
* @brief Update any resources necessary after a GUI language change
*/
void CChildFrame::UpdateResources()
{
m_wndStatusBar.UpdateResources();
m_wndLocationBar.UpdateResources();
m_wndDetailBar.UpdateResources();
}
/**
* @brief Save pane sizes and positions when one of panes requests it.
*/
LRESULT CChildFrame::OnStorePaneSizes(WPARAM wParam, LPARAM lParam)
{
KillTimer(IDT_SAVEPOSITION);
SetTimer(IDT_SAVEPOSITION, 300, NULL);
return 0;
}
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);
UpdateHeaderSizes();
}