OSDN Git Service

0f71a1378dc5946213cd9927da6b27d8ae8a6de5
[winmerge-jp/winmerge-jp.git] / Src / DirFrame.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 //    WinMerge:  an interactive diff/merge utility
3 //    Copyright (C) 1997-2000  Thingamahoochie Software
4 //    Author: Dean Grimm
5 //    SPDX-License-Identifier: GPL-2.0-or-later
6 /////////////////////////////////////////////////////////////////////////////
7 /** 
8  * @file  DirFrame.cpp
9  *
10  * @brief Implementation file for CDirFrame
11  *
12  */
13
14 #include "stdafx.h"
15 #include "DirFrame.h"
16 #include "Merge.h"
17 #include "OptionsDef.h"
18 #include "OptionsMgr.h"
19
20 #ifdef _DEBUG
21 #define new DEBUG_NEW
22 #endif
23
24 /**
25  * @brief Statusbar pane indexes
26  */
27 enum
28 {
29         PANE_COMPMETHOD = 1,
30         PANE_FILTER,
31         PANE_LEFT_RO,
32         PANE_MIDDLE_RO,
33         PANE_RIGHT_RO,
34 };
35
36 /**
37  * @brief Width of compare method name pane in statusbar
38  */
39 const int COMPMETHOD_PANEL_WIDTH = 100;
40 /**
41  * @brief Width of filter name pane in statusbar
42  */
43 const int FILTER_PANEL_WIDTH = 100;
44
45 /**
46  * @brief Bottom statusbar panels and indicators
47  */
48 static UINT indicators[] =
49 {
50         ID_SEPARATOR,           // status line indicator
51         ID_SEPARATOR,
52         ID_SEPARATOR,
53         ID_SEPARATOR,
54         ID_SEPARATOR,
55         ID_SEPARATOR,
56 };
57
58 /**
59  * @brief RO status panel width
60  */
61 static UINT RO_PANEL_WIDTH = 30;
62
63 /////////////////////////////////////////////////////////////////////////////
64 // CDirFrame
65
66 IMPLEMENT_DYNCREATE(CDirFrame, CMergeFrameCommon)
67
68 CDirFrame::CDirFrame()
69 : CMergeFrameCommon(IDI_EQUALFOLDER, IDI_NOTEQUALFOLDER)
70 {
71 }
72
73 CDirFrame::~CDirFrame()
74 {
75 }
76
77 BEGIN_MESSAGE_MAP(CDirFrame, CMergeFrameCommon)
78         //{{AFX_MSG_MAP(CDirFrame)
79         ON_WM_CREATE()
80         ON_WM_CLOSE()
81         ON_WM_SIZE()
82         //}}AFX_MSG_MAP
83 END_MESSAGE_MAP()
84
85 /////////////////////////////////////////////////////////////////////////////
86 // CDirFrame message handlers
87
88 /**
89  * @brief Create statusbar
90  */
91 int CDirFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
92 {
93         if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
94                 return -1;
95
96         EnableDocking(CBRS_ALIGN_TOP);
97
98         // Dir frame has a header bar at top
99         if (!m_wndFilePathBar.Create(this))
100         {
101                 TRACE0("Failed to create header bar\n");
102                 return -1;      // fail to create
103         }       
104
105         // Directory frame has a status bar
106         if (!m_wndStatusBar.Create(this) ||
107                 !m_wndStatusBar.SetIndicators(indicators,
108                   sizeof(indicators)/sizeof(UINT)))
109         {
110                 TRACE0("Failed to create status bar\n");
111                 return -1;      // fail to create
112         }       
113         
114         String sText = _("RO");
115         const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
116         auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
117         m_wndStatusBar.SetPaneInfo(0, 0, SBPS_STRETCH | SBPS_NOBORDERS, 0);
118         m_wndStatusBar.SetPaneInfo(PANE_COMPMETHOD, ID_STATUS_FILTER, 0, pointToPixel(COMPMETHOD_PANEL_WIDTH));
119         m_wndStatusBar.SetPaneInfo(PANE_FILTER, ID_STATUS_FILTER, 0, pointToPixel(FILTER_PANEL_WIDTH));
120         m_wndStatusBar.SetPaneInfo(PANE_LEFT_RO, ID_STATUS_LEFTDIR_RO, 0, pointToPixel(RO_PANEL_WIDTH));
121         m_wndStatusBar.SetPaneInfo(PANE_MIDDLE_RO, ID_STATUS_MIDDLEDIR_RO, 0, pointToPixel(RO_PANEL_WIDTH));
122         m_wndStatusBar.SetPaneInfo(PANE_RIGHT_RO, ID_STATUS_RIGHTDIR_RO, 0, pointToPixel(RO_PANEL_WIDTH));
123         m_wndStatusBar.SetPaneText(PANE_LEFT_RO, sText.c_str(), TRUE); 
124         m_wndStatusBar.SetPaneText(PANE_MIDDLE_RO, sText.c_str(), TRUE); 
125         m_wndStatusBar.SetPaneText(PANE_RIGHT_RO, sText.c_str(), TRUE);
126
127         // load docking positions and sizes
128         CDockState dockState;
129         dockState.LoadState(_T("Settings-DirFrame"));
130         SetDockState(dockState);
131
132         return 0;
133 }
134
135 /**
136  * @brief Set statusbar text
137  */
138 void CDirFrame::SetStatus(LPCTSTR szStatus)
139 {
140         m_wndStatusBar.SetPaneText(0, szStatus);
141 }
142
143 /**
144  * @brief Set current compare method name to statusbar
145  * @param [in] nCompMethod compare method to show
146  */
147 void CDirFrame::SetCompareMethodStatusDisplay(int nCompMethod)
148 {
149         m_wndStatusBar.SetPaneText(PANE_COMPMETHOD, LoadResString(IDS_COMPMETHOD_FULL_CONTENTS + nCompMethod).c_str());
150 }
151
152 /**
153  * @brief Set active filter name to statusbar
154  * @param [in] szFilter Filtername to show
155  */
156 void CDirFrame::SetFilterStatusDisplay(LPCTSTR szFilter)
157 {
158         m_wndStatusBar.SetPaneText(PANE_FILTER, szFilter);
159 }
160
161 /**
162  * @brief Restore maximized state of directory compare window
163  */
164 void CDirFrame::ActivateFrame(int nCmdShow) 
165 {
166         CMergeFrameCommon::ActivateFrame(nCmdShow);
167 }
168
169 /**
170  * @brief Update any resources necessary after a GUI language change
171  */
172 void CDirFrame::UpdateResources()
173 {
174 }
175
176 void CDirFrame::OnClose() 
177 {       
178         CMDIChildWnd::OnClose();
179 }
180
181 /**
182  * @brief Save maximized state before destroying window
183  */
184 BOOL CDirFrame::DestroyWindow() 
185 {
186         // save docking positions and sizes
187         CDockState dockState;
188         GetDockState(dockState);
189         dockState.SaveState(_T("Settings-DirFrame"));
190         SaveWindowState();
191         return CMDIChildWnd::DestroyWindow();
192 }
193
194 void CDirFrame::OnSize(UINT nType, int cx, int cy) 
195 {
196         CMDIChildWnd::OnSize(nType, cx, cy);
197         
198         m_wndFilePathBar.Resize();
199 }