OSDN Git Service

resource.h: Add IDS_PLUGIN_DESCRIPTION*
[winmerge-jp/winmerge-jp.git] / Src / PropCompareBinary.cpp
1 /** 
2  * @file  PropCompareBinary.cpp
3  *
4  * @brief Implementation of PropCompareBinary propertysheet
5  */
6
7 #include "stdafx.h"
8 #include "PropCompareBinary.h"
9 #include "WildcardDropList.h"
10 #include "OptionsDef.h"
11 #include "OptionsMgr.h"
12 #include "OptionsPanel.h"
13 #include "heksedit.h"
14
15 #ifdef _DEBUG
16 #define new DEBUG_NEW
17 #endif
18
19 class Heksedit
20 {
21 public:
22         explicit Heksedit(CWnd *pwndParent)
23         {
24                 HMODULE pv = GetModuleHandle(_T("hekseditU.dll"));
25                 if (pv == nullptr)
26                         pv = LoadLibrary(_T("Frhed\\hekseditU.dll"));
27                 if (pv == nullptr)
28                 {
29                         LangMessageBox(IDS_FRHED_NOTINSTALLED, MB_OK);
30                         return;
31                 }
32                 wnd.Create(_T("heksedit"), nullptr, 0, CRect(), pwndParent, 1);
33                 get_interface()->read_ini_data();
34                 get_interface()->get_settings()->bSaveIni = true;
35         }
36
37         ~Heksedit()
38         {
39                 wnd.DestroyWindow();
40         }
41
42         Heksedit(const Heksedit&) = delete;
43
44         IHexEditorWindow *get_interface()
45         {
46                 return reinterpret_cast<IHexEditorWindow *>(::GetWindowLongPtr(wnd.m_hWnd, GWLP_USERDATA));
47         }
48
49 private:
50         CWnd wnd;
51 };
52
53 /** 
54  * @brief Constructor.
55  * @param [in] optionsMgr Pointer to COptionsMgr.
56  */
57 PropCompareBinary::PropCompareBinary(COptionsMgr *optionsMgr) 
58  : OptionsPanel(optionsMgr, PropCompareBinary::IDD)
59 {
60 }
61
62 void PropCompareBinary::DoDataExchange(CDataExchange* pDX)
63 {
64         CPropertyPage::DoDataExchange(pDX);
65         //{{AFX_DATA_MAP(PropCompareBinary)
66         DDX_Control(pDX, IDC_COMPAREBINARY_PATTERNS, m_comboPatterns);
67         DDX_Text(pDX, IDC_COMPAREBINARY_PATTERNS, m_sFilePatterns);
68         //}}AFX_DATA_MAP
69 }
70
71
72 BEGIN_MESSAGE_MAP(PropCompareBinary, OptionsPanel)
73         //{{AFX_MSG_MAP(PropCompareBinary)
74         ON_BN_CLICKED(IDC_COMPAREBINARY_VIEWSETTINGS, OnViewSettings)
75         ON_BN_CLICKED(IDC_COMPAREBINARY_BINARYMODE, OnBinaryMode)
76         ON_BN_CLICKED(IDC_COMPAREBINARY_CHARACTERSET, OnCharacterSet)
77         ON_BN_CLICKED(IDC_COMPARE_DEFAULTS, OnDefaults)
78         ON_CBN_DROPDOWN(IDC_COMPAREBINARY_PATTERNS, OnDropDownPatterns)
79         ON_CBN_CLOSEUP(IDC_COMPAREBINARY_PATTERNS, OnCloseUpPatterns)
80         //}}AFX_MSG_MAP
81 END_MESSAGE_MAP()
82
83 /** 
84  * @brief Reads options values from storage to UI.
85  * Property sheet calls this before displaying GUI to load values
86  * into members.
87  */
88 void PropCompareBinary::ReadOptions()
89 {
90         m_sFilePatterns = GetOptionsMgr()->GetString(OPT_CMP_BIN_FILEPATTERNS);
91 }
92
93 /** 
94  * @brief Writes options values from UI to storage.
95  * Property sheet calls this after dialog is closed with OK button to
96  * store values in member variables.
97  */
98 void PropCompareBinary::WriteOptions()
99 {
100         WildcardRemoveDuplicatePatterns(m_sFilePatterns);
101         GetOptionsMgr()->SaveOption(OPT_CMP_BIN_FILEPATTERNS, m_sFilePatterns);
102 }
103
104 /** 
105  * @brief Show Frhed view settings dialog
106  */
107 void PropCompareBinary::OnViewSettings()
108 {
109         Heksedit heksedit(this);
110         if (heksedit.get_interface())
111                 heksedit.get_interface()->CMD_view_settings();
112 }
113
114 /** 
115  * @brief Show Frhed binary mode dialog
116  */
117 void PropCompareBinary::OnBinaryMode()
118 {
119         Heksedit heksedit(this);
120         if (heksedit.get_interface())
121                 heksedit.get_interface()->CMD_binarymode();
122 }
123
124 /** 
125  * @brief Show Frhed characterset dialog
126  */
127 void PropCompareBinary::OnCharacterSet()
128 {
129         Heksedit heksedit(this);
130         if (heksedit.get_interface())
131                 heksedit.get_interface()->CMD_character_set();
132 }
133
134 /** 
135  * @brief Sets options to defaults
136  */
137 void PropCompareBinary::OnDefaults()
138 {
139         m_sFilePatterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_BIN_FILEPATTERNS);
140         UpdateData(FALSE);
141 }
142
143 /**
144  * @brief Prepares multi-selection drop list 
145  */
146 void PropCompareBinary::OnDropDownPatterns()
147 {
148         String patterns = GetOptionsMgr()->GetDefault<String>(OPT_CMP_BIN_FILEPATTERNS);
149         WildcardDropList::OnDropDown(m_comboPatterns, 6, patterns.c_str());
150 }
151
152 /**
153  * @brief Finishes drop list multi-selection
154  */
155 void PropCompareBinary::OnCloseUpPatterns()
156 {
157         WildcardDropList::OnCloseUp(m_comboPatterns);
158 }