OSDN Git Service

Fix the issue where the Apache Tika plugin becomes enabled again when reopening the...
[winmerge-jp/winmerge-jp.git] / Src / PropProject.cpp
1 /** 
2  * @file  PropProject.cpp
3  *
4  * @brief Implementation of PropProject propertysheet
5  */
6
7 #include "stdafx.h"
8 #include "PropProject.h"
9 #include "OptionsMgr.h"
10 #include "OptionsPanel.h"
11 #include "OptionsProject.h"
12
13 #ifdef _DEBUG
14 #define new DEBUG_NEW
15 #endif
16
17 /** 
18  * @brief Constructor.
19  * @param [in] optionsMgr Pointer to options manager for handling options.
20  */
21 PropProject::PropProject(COptionsMgr *optionsMgr)
22 : OptionsPanel(optionsMgr, PropProject::IDD)
23 {
24         for (int i = 0; i < Options::Project::OperationCount; i++)
25                 for (int j = 0; j < Options::Project::ItemCount; j++)
26                         m_settings[i][j] = false;
27 }
28
29 /** 
30  * @brief Function handling dialog data exchange between GUI and variables.
31  */
32 void PropProject::DoDataExchange(CDataExchange* pDX)
33 {
34         CDialog::DoDataExchange(pDX);
35
36         //{{AFX_DATA_MAP(PropEditor)
37         DDX_Control(pDX, IDC_PROJECT_LIST, m_list);
38         //}}AFX_DATA_MAP
39
40         if (!pDX->m_bSaveAndValidate)
41         {
42                 for (int i = 0; i < Options::Project::OperationCount; i++)
43                         for (int j = 0; j < Options::Project::ItemCount; j++)
44                                 m_list.SetItemBooleanValue(j, i + 1, m_settings[i][j]);
45
46         }
47         else
48         {
49                 for (int i = 0; i < Options::Project::OperationCount; i++)
50                         for (int j = 0; j < Options::Project::ItemCount; j++)
51                                 m_settings[i][j] = m_list.GetItemBooleanValue(j, i + 1);
52         }
53
54 }
55
56
57 BEGIN_MESSAGE_MAP(PropProject, OptionsPanel)
58         //{{AFX_MSG_MAP(PropEditor)
59 //      ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
60         //}}AFX_MSG_MAP
61 END_MESSAGE_MAP()
62
63 /** 
64  * @brief Reads options values from storage to UI.
65  */
66 void PropProject::ReadOptions()
67 {
68         Options::Project::Load(GetOptionsMgr(), m_settings);
69 }
70
71 /** 
72  * @brief Writes options values from UI to storage.
73  */
74 void PropProject::WriteOptions()
75 {
76         Options::Project::Save(GetOptionsMgr(), m_settings);
77 }
78
79 /** 
80  * @brief Called before propertysheet is drawn.
81  */
82 BOOL PropProject::OnInitDialog()
83 {
84         OptionsPanel::OnInitDialog();
85
86         InitList();
87
88         UpdateData(false);
89
90         return TRUE;  // return TRUE unless you set the focus to a control
91                                   // EXCEPTION: OCX Property Pages should return FALSE
92 }
93
94 /**
95  * @brief Initialize listcontrol containing project settings.
96  */
97 void PropProject::InitList()
98 {
99         // Show selection across entire row.
100         // Also enable infotips.
101         m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
102
103         const int lpx = CClientDC(this).GetDeviceCaps(LOGPIXELSX);
104         auto pointToPixel = [lpx](int point) { return MulDiv(point, lpx, 72); };
105
106         String title = _("Item");
107         m_list.InsertColumn(0, title.c_str(), LVCFMT_LEFT, pointToPixel(150));
108         title = _("Open");
109         m_list.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(50));
110         title = _("Load");
111         m_list.InsertColumn(2, title.c_str(), LVCFMT_LEFT, pointToPixel(50));
112         title = _("Save");
113         m_list.InsertColumn(3, title.c_str(), LVCFMT_LEFT, pointToPixel(50));
114
115         m_list.SetReadOnlyColumn(0);
116         for (int i = 0; i < Options::Project::OperationCount; ++i)
117         {
118                 m_list.SetEditStyle(i+1, CSubeditList::EditStyle::EDIT_BOX);
119                 m_list.SetBooleanValueColumn(i+1);
120         }
121
122         int nID[Options::Project::ItemCount] = {
123                 IDS_PROJECT_ITEM_FILE_FILTER,
124                 IDS_PROJECT_ITEM_INCLUDE_SUBFOLDERS,
125                 IDS_PROJECT_ITEM_PLUGIN,
126                 IDS_PROJECT_ITEM_COMPARE_OPTIONS,
127                 IDS_PROJECT_ITEM_HIDDEN_ITEMS
128         };
129
130         for (int i = 0; i < Options::Project::ItemCount; i++)
131         {
132                 String str = LoadResString(nID[i]);
133                 m_list.InsertItem(i, str.c_str());
134         }
135 }