SDC C-Project CF Review 프로그램
LAPTOP-N7PT1MHU\dit-709
2021-05-10 a94966aed7229fbacf418acf73dfb0885050f47d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#pragma once
 
#include "PropertyGridCombo.h"
#include "PropertyGridInPlaceEdit.h"
 
#include <map>
#include <vector>
// CPropertyGrid
 
#define WM_PG_ITEMCHANGED WM_USER+486
 
typedef UINT HSECTION;
typedef UINT HITEM;
 
class ICustomItem;
 
class AFX_EXT_CLASS CPropertyGrid : public CWnd
{
    DECLARE_DYNAMIC(CPropertyGrid)
 
public:
    // display mode
    enum EDisplayMode
    {
        DM_CATEGORIZED = 0,
        DM_ALPHABETICAL,
        DM_NOSORT
    };
 
    // editing
    enum EEditMode
    {
        EM_CUSTOM = 0,
        EM_INPLACE,
        EM_DROPDOWN,
        EM_MODAL
    };
 
    enum EItemType
    {
        IT_CUSTOM = 0,
        IT_STRING,
        IT_TEXT,
        IT_INTEGER,
        IT_DOUBLE,
        IT_COMBO,
        IT_BOOLEAN,
        IT_DATE,
        IT_DATETIME,
        IT_FILE,
        IT_PATH,
        IT_FOLDER,
        IT_COLOR,
        IT_FONT
    };
 
public:
    CPropertyGrid();
    virtual ~CPropertyGrid();
 
    // customization
    bool GetShadeTitles();
    void SetShadeTitles(bool shade_titles);
    bool GetDrawLines();
    void SetDrawLines(bool draw_lines);
    bool GetDrawGutter();
    void SetDrawGutter(bool draw_gutter);
    bool GetFocusDisabled();
    void SetFocusDisabled(bool focus_disabled);
    bool GetBoldModified();
    void SetBoldModified(bool bold_modified);
    bool GetBoldEditables();
    void SetBoldEditables(bool bold_editables);
 
    // gutter width
    int GetGutterWidth();
    void SetGutterWidth(int gutter_width);
 
    // custom colors
    void SetTextColor(COLORREF clrText);
    void SetTitleColor(COLORREF clrText);
    void SetBackColor(COLORREF clrBack);
    void SetShadeColor(COLORREF clrShade);
    void SetFocusColor(COLORREF clrFocus);
    void SetHiliteColor(COLORREF clrHilite);
    void SetEditableColor(COLORREF clrEditable);
    void SetDisabledColor(COLORREF clrDisabled);
 
    // localization
    void SetTrueFalseStrings(CString strTrue, CString strFalse);
    void SetOkCancelStrings(CString strOk, CString strCancel);
    void SetDateTimeStrings(CString strDate, CString strTime);
    void SetUndefinedString(CString strUndefined);
    void SetEmptyString(CString strEmpty);
 
    // add a section
    HSECTION AddSection(CString title, bool collapsed = false, HSECTION after = -1);
 
    // add items
    HITEM AddCustomItem(HSECTION, CString name, ICustomItem* pItem, bool editable = true, HITEM after = -1);
    HITEM AddStringItem(HSECTION section, CString name, CString value, bool editable = true, HITEM after = -1);
    HITEM AddTextItem(HSECTION section, CString name, CString value, bool editable = true, HITEM after = -1);
    HITEM AddIntegerItem(HSECTION section, CString name, int value, CString format = _T(""), bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddDoubleItem(HSECTION section, CString name, double value, CString format = _T(""), bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddComboItem(HSECTION section, CString name, const std::vector<CString>& values, int cur, bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddBoolItem(HSECTION section, CString name, bool value, bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddDateItem(HSECTION section, CString name, COleDateTime value, CString format = _T(""), bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddDateTimeItem(HSECTION section, CString name, COleDateTime value, CString format = _T(""), bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddFileItem(HSECTION section, CString name, CString value, CString filter = _T(""), bool editable = true, HITEM after = -1);
    HITEM AddPathItem(HSECTION section, CString name, CString value, CString filter = _T(""), bool editable = true, HITEM after = -1);
    HITEM AddFolderItem(HSECTION section, CString name, CString value, CString title = _T(""), bool editable = true, HITEM after = -1);
    HITEM AddColorItem(HSECTION section, CString name, COLORREF value, bool editable = true, bool undefined = false, HITEM after = -1);
    HITEM AddFontItem(HSECTION section, CString name, LOGFONT value, bool editable = true, bool undefined = false, HITEM after = -1);
 
    // contents
    void ResetContents();
    bool RemoveSection(HSECTION hs);
    bool RemoveItem(HITEM item);
    void ValidateChanges();
 
    // status
    int GetNumSections();
    int GetSectionSize(HSECTION hs);
 
    // get item value
    bool GetItemValue(HITEM item, CString& strValue) const;
    bool GetItemValue(HITEM item, int& nValue) const;
    bool GetItemValue(HITEM item, double& dValue) const;
    bool GetItemValue(HITEM item, bool& bValue) const;
    bool GetItemValue(HITEM item, COleDateTime& dtValue) const;
    bool GetItemValue(HITEM item, COLORREF& clrValue) const;
    bool GetItemValue(HITEM item, LOGFONT& lfValue) const;
 
    // set item value
    bool SetItemValue(HITEM item, const CString strValue);
    bool SetItemValue(HITEM item, const int nValue);
    bool SetItemValue(HITEM item, const double nValue);
    bool SetItemValue(HITEM item, const bool bValue);
    bool SetItemValue(HITEM item, const COleDateTime dtValue);
    bool SetItemValue(HITEM item, const COLORREF clrValue);
    bool SetItemValue(HITEM item, const LOGFONT lfValue);
 
    // for custom items
    int GetTextMargin();
    CFont* GetFontNormal();
    CFont* GetFontBold();
 
    // appearance stuff
    void SetDisplayMode(EDisplayMode display_mode);
    void ExpandAll(bool expand);
    void ExpandSection(HSECTION hs, bool expand);
    bool IsSectionCollapsed(HSECTION hs);
 
protected:
    class CItem
    {
    public:
        HITEM m_id;
        bool m_editable;
        bool m_undefined;
        EItemType m_type;
        CString m_name;
 
        std::vector<CString> m_options;
 
        int m_nValue;
        double m_dValue;
        CString m_strValue;
        bool m_bValue;
        COleDateTime m_dtValue;
        COLORREF m_clrValue;
        LOGFONT m_lfValue;
        ICustomItem* m_pCustom;
 
        bool m_undefined_old;
        int m_nValue_old;
        double m_dValue_old;
        CString m_strValue_old;
        bool m_bValue_old;
        COleDateTime m_dtValue_old;
        COLORREF m_clrValue_old;
        LOGFONT m_lfValue_old;
 
        CRect m_rcName;
        CRect m_rcValue;
 
        bool operator==(const HITEM& item) const;
        bool operator==(const CString& name) const;
 
        void ValidateChanges();
    };
 
    friend bool item_alpha_sort(std::vector<CPropertyGrid::CItem>::iterator it1, std::vector<CPropertyGrid::CItem>::iterator it2);
 
    class CSection
    {
    public:
        HSECTION m_id;
        CString m_title;
        bool m_collapsed;
        std::vector<CItem> m_items;
 
        CRect m_rcSign;
        CRect m_rcTitle;
 
        bool operator==(const HSECTION& section) const;
    };
 
    std::vector<CSection> m_sections;
 
    HSECTION m_focused_section;
    HITEM m_focused_item;
 
    EDisplayMode m_display_mode;
 
    bool m_shade_titles;
    bool m_draw_lines;
    bool m_draw_gutter;
    bool m_focus_disabled;
    bool m_bold_modified;
    bool m_bold_editables;
 
    int m_gutter_width;
    bool m_resizing_gutter;
    CPoint m_ptLast;
 
    CFont m_fntNormal;
    CFont m_fntBold;
 
    int m_line_height;
 
    CRect m_rect_button;
    CWnd* m_control;
    bool m_button_pushed;
    bool m_button_depressed;
    bool m_value_clicked;
    bool m_custom_tracking;
 
    HSECTION m_section_id;
    HITEM m_item_id;
 
    CString m_strTrue;
    CString m_strFalse;
    CString m_strOk;
    CString m_strCancel;
    CString m_strDate;
    CString m_strTime;
    CString m_strUndefined;
    CString m_strEmpty;
 
    COLORREF m_clrText;
    COLORREF m_clrTitle;
    COLORREF m_clrBack;
    COLORREF m_clrShade;
    COLORREF m_clrFocus;
    COLORREF m_clrHilite;
    COLORREF m_clrEditable;
    COLORREF m_clrDisabled;
    COLORREF m_clrItemLine;
 
protected:
    DECLARE_MESSAGE_MAP()
 
    // init control
    void InitControl();
 
    // drawing
    void DrawItem(CDC& dc, int w, int x, int y, std::vector<CItem>::iterator& it);
 
    // item management
    CSection* FindSection(HSECTION hs) const;
    CItem* FindItem(HITEM hi) const;
    HITEM AddItem(HSECTION hs, EItemType type, CString name, void* pValue, bool editable, bool undefined, HITEM after);
 
    // scrolling stuff
    CScrollBar m_scrollbar;
    bool m_scroll_enabled;
    int GetScrollOffset();
    void RecalcLayout();
 
    // editing
    EEditMode GetEditMode(CItem& item);
    void DeleteEditControl();
    void EditFocusedItem();
 
    // movement in list
    void MoveForward(HSECTION& focused_section, HITEM& focused_item);
 
    // keyboard
    void FocusNextItem();
    void FocusPrevItem();
 
protected:
    virtual void PreSubclassWindow();
 
public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnDestroy();
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg void OnPaint();
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nHitTest, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
    afx_msg LRESULT OnComboSelChanged(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnEditChanged(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnDateChanged(WPARAM wParam, LPARAM lParam);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg UINT OnGetDlgCode();
    afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
};