kjk / moriarty-sm

This URL has Read+Write access

moriarty-sm / ModuleDialog.h
100644 124 lines (82 sloc) 3.309 kb
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
#ifndef INFOMAN_MODULE_DIALOG_H__
#define INFOMAN_MODULE_DIALOG_H__
 
#include <WindowsCE/Dialog.hpp>
#include <WindowsCE/CommandBar.hpp>
#include <ExtendedEvent.hpp>
 
struct LookupFinishedEventData;
 
class MenuDialog: public Dialog {
    DWORD menuBarFlags_;
    UINT menuBarId_;
#ifdef SHELL_MENUBAR
    CommandBar menuBar_;
#endif
 
    virtual bool handleBackKey(UINT msg, WPARAM wParam, LPARAM lParam);
    
protected:
 
#ifdef SHELL_MENUBAR
    CommandBar& menuBar() {return menuBar_;}
    const CommandBar& menuBar() const {return menuBar_;}
#endif
 
    void setMenuBarId(UINT menuBarId) {menuBarId_ = menuBarId;}
    void setMenuBarFlags(DWORD flags) {menuBarFlags_ = flags;}
    void overrideBackKey();
 
    bool handleInitDialog(HWND focus_widget_handle, long init_param);
   
    LRESULT callback(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
    bool createSipPrefControl();
    
    virtual bool drawListViewItem(NMLVCUSTOMDRAW& data);
   
    virtual bool handleMeasureItem(UINT controlId, MEASUREITEMSTRUCT& data);
 
    long handleNotify(int controlId, const NMHDR& header);
   
    virtual long handleListItemActivate(int controlId, const NMLISTVIEW& header);
   
public:
 
    
    enum {menuBarNone = UINT(-1)};
    enum AdvancedOption {advanced};
 
    explicit MenuDialog(AdvancedOption, bool inputDialog = false, DWORD initDialogFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN);
 
    explicit MenuDialog(UINT menuBarId = menuBarNone, bool inputDialog = false);
 
    ~MenuDialog();
 
 
};
 
class ModuleDialog: public MenuDialog {
    ExtEventHelper extEventHelper_;
 
protected:
    
    LRESULT callback(UINT msg, WPARAM wParam, LPARAM lParam);
 
    virtual bool handleLookupFinished(Event& event, const LookupFinishedEventData* data);
 
    bool handleInitDialog(HWND focus_widget_handle, long init_param);
   
    long handleCommand(ushort nc, ushort id, HWND sender);
   
public:
    
    explicit ModuleDialog(AdvancedOption, bool inputDialog = false, DWORD initDialogFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLGFULLSCREEN);
 
    explicit ModuleDialog(UINT menuBarId = menuBarNone, bool inputDialog = false);
 
    ~ModuleDialog();
 
    bool create(UINT resourceId);
   
    long showModal(UINT resourceId);
   
    void endModal(int code);
 
};
 
void ModuleDialogSetCurrent(ModuleDialog* dialog);
void ModuleDialogDestroyCurrent();
ModuleDialog* ModuleDialogGetCurrent();
 
#define MODULE_DIALOG_CREATE_DECLARE(Class) static Class* create()
 
#define MODULE_DIALOG_CREATE_IMPLEMENT(Class, resourceId) \
Class* Class::create() \
{ \
Class* dlg = new_nt Class(); \
if (NULL == dlg) \
return NULL; \
if (!dlg->ModuleDialog::create(resourceId)) \
{ \
delete dlg; \
return NULL; \
} \
return dlg; \
}
 
#define MODULE_DIALOG_SHOW_MODAL_DECLARE(Class) static long showModal()
 
#define MODULE_DIALOG_SHOW_MODAL_IMPLEMENT(Class, resourceId) \
long Class::showModal() \
{ \
Class* dlg = new_nt Class(); \
if (NULL == dlg) \
{ \
Alert(IDS_ALERT_NOT_ENOUGH_MEMORY); \
return 0; \
} \
long res = dlg->ModuleDialog::showModal(resourceId); \
delete dlg; \
return res; \
}
 
#endif