OSDN Git Service

Fix the issue where the Apache Tika plugin becomes enabled again when reopening the...
[winmerge-jp/winmerge-jp.git] / Src / PropCompareImage.cpp
1 /** 
2  * @file  PropCompareImage.cpp
3  *
4  * @brief Implementation of PropCompareImage propertysheet
5  */
6
7 #include "stdafx.h"
8 #include "PropCompareImage.h"
9 #include "WildcardDropList.h"
10 #include "OptionsDef.h"
11 #include "OptionsMgr.h"
12 #include "OptionsPanel.h"
13
14 #ifdef _DEBUG
15 #define new DEBUG_NEW
16 #endif
17
18 /** 
19  * @brief Constructor.
20  * @param [in] optionsMgr Pointer to COptionsMgr.
21  */
22 PropCompareImage::PropCompareImage(COptionsMgr *optionsMgr) 
23  : OptionsPanel(optionsMgr, PropCompareImage::IDD)
24  , m_bEnableImageCompare(false)
25  , m_nOcrResultType(0)
26 {
27 }
28
29 void PropCompareImage::DoDataExchange(CDataExchange* pDX)
30 {
31         CPropertyPage::DoDataExchange(pDX);
32         //{{AFX_DATA_MAP(PropCompareImage)
33         DDX_Control(pDX, IDC_COMPAREIMAGE_PATTERNS, m_comboPatterns);
34         DDX_Text(pDX, IDC_COMPAREIMAGE_PATTERNS, m_sFilePatterns);
35         DDX_Check(pDX, IDC_ENABLE_IMGCMP_IN_DIRCMP, m_bEnableImageCompare);
36         DDX_CBIndex(pDX, IDC_COMPAREIMAGE_OCR_RESULT_TYPE, m_nOcrResultType);
37         //}}AFX_DATA_MAP
38 }
39
40
41 BEGIN_MESSAGE_MAP(PropCompareImage, OptionsPanel)
42         //{{AFX_MSG_MAP(PropCompareImage)
43         ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
44         ON_CBN_DROPDOWN(IDC_COMPAREIMAGE_PATTERNS, OnDropDownPatterns)
45         ON_CBN_CLOSEUP(IDC_COMPAREIMAGE_PATTERNS, OnCloseUpPatterns)
46         //}}AFX_MSG_MAP
47 END_MESSAGE_MAP()
48
49 /** 
50  * @brief Reads options values from storage to UI.
51  * Property sheet calls this before displaying GUI to load values
52  * into members.
53  */
54 void PropCompareImage::ReadOptions()
55 {
56         m_sFilePatterns = GetOptionsMgr()->GetString(OPT_CMP_IMG_FILEPATTERNS);
57         m_bEnableImageCompare = GetOptionsMgr()->GetBool(OPT_CMP_ENABLE_IMGCMP_IN_DIRCMP);
58         m_nOcrResultType = GetOptionsMgr()->GetInt(OPT_CMP_IMG_OCR_RESULT_TYPE);
59 }
60
61 /** 
62  * @brief Writes options values from UI to storage.
63  * Property sheet calls this after dialog is closed with OK button to
64  * store values in member variables.
65  */
66 void PropCompareImage::WriteOptions()
67 {
68         WildcardRemoveDuplicatePatterns(m_sFilePatterns);
69         GetOptionsMgr()->SaveOption(OPT_CMP_IMG_FILEPATTERNS, m_sFilePatterns);
70         GetOptionsMgr()->SaveOption(OPT_CMP_ENABLE_IMGCMP_IN_DIRCMP, m_bEnableImageCompare);
71         GetOptionsMgr()->SaveOption(OPT_CMP_IMG_OCR_RESULT_TYPE, m_nOcrResultType);
72 }
73
74 /** 
75  * @brief Called before propertysheet is drawn.
76  */
77 BOOL PropCompareImage::OnInitDialog()
78 {
79         SetDlgItemComboBoxList(IDC_COMPAREIMAGE_OCR_RESULT_TYPE,
80                 { _("Text only"), _("Line-by-line position and text"), _("Word-by-word position and text") });
81
82         OptionsPanel::OnInitDialog();
83         return TRUE;  // return TRUE unless you set the focus to a control
84 }
85
86 /** 
87  * @brief Sets options to defaults
88  */
89 void PropCompareImage::OnDefaults()
90 {
91         m_sFilePatterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_IMG_FILEPATTERNS);
92         UpdateData(FALSE);
93 }
94
95 /**
96  * @brief Prepares multi-selection drop list 
97  */
98 void PropCompareImage::OnDropDownPatterns()
99 {
100         String patterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_IMG_FILEPATTERNS)
101 #ifdef _WIN64
102                 + _T(";*.pdf;*.svg;*.wmf;*.emf");
103 #else
104                 + _T(";*.wmf;*.emf");
105 #endif
106         WildcardDropList::OnDropDown(m_comboPatterns, 6, patterns.c_str());
107 }
108
109 /**
110  * @brief Finishes drop list multi-selection
111  */
112 void PropCompareImage::OnCloseUpPatterns()
113 {
114         WildcardDropList::OnCloseUp(m_comboPatterns);
115 }