OSDN Git Service

Update CWindowsManagerDialog - check some pointers for null and made … (#824) (2)
[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         CComboBox * combo = (CComboBox*) GetDlgItem(IDC_COMPAREIMAGE_OCR_RESULT_TYPE);
80
81         combo->AddString(_("Text only").c_str());
82         combo->AddString(_("Line-by-line position and text").c_str());
83         combo->AddString(_("Word-by-word position and text").c_str());
84         combo->SetCurSel(m_nOcrResultType);
85
86         OptionsPanel::OnInitDialog();
87         return TRUE;  // return TRUE unless you set the focus to a control
88 }
89
90 /** 
91  * @brief Sets options to defaults
92  */
93 void PropCompareImage::OnDefaults()
94 {
95         m_sFilePatterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_IMG_FILEPATTERNS);
96         UpdateData(FALSE);
97 }
98
99 /**
100  * @brief Prepares multi-selection drop list 
101  */
102 void PropCompareImage::OnDropDownPatterns()
103 {
104         String patterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_IMG_FILEPATTERNS)
105 #ifdef _WIN64
106                 + _T(";*.pdf;*.svg;*.wmf;*.emf");
107 #else
108                 + _T(";*.wmf;*.emf");
109 #endif
110         WildcardDropList::OnDropDown(m_comboPatterns, 6, patterns.c_str());
111 }
112
113 /**
114  * @brief Finishes drop list multi-selection
115  */
116 void PropCompareImage::OnCloseUpPatterns()
117 {
118         WildcardDropList::OnCloseUp(m_comboPatterns);
119 }