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
use std::hash::Hash;
use std::any::{Any, TypeId};
use winapi::{UINT, LRESULT, DWORD, HBRUSH, ULONG_PTR, HMENU, BOOL, c_int, HBITMAP, LPWSTR};
use events::{Event, EventCallback};
use controls::ControlT;
pub const NWG_CUSTOM_MIN: UINT = 0x400;
pub const NWG_PACK_USER_VALUE: UINT = 0x400;
pub const NWG_PACK_CONTROL: UINT = 0x401;
pub const NWG_UNPACK: UINT = 0x402;
pub const NWG_BIND: UINT = 0x403;
pub const NWG_UNBIND: UINT = 0x404;
pub const NWG_CUSTOM_MAX: UINT = 0x405;
pub const COMMIT_SUCCESS: LRESULT = 0;
pub const COMMIT_FAILED: LRESULT = 5555;
pub const MIM_MENUDATA: DWORD = 0x00000008;
pub const MIM_STYLE: DWORD = 0x00000010;
pub const MIIM_DATA: DWORD = 0x00000020;
pub const MNS_NOTIFYBYPOS: DWORD = 0x08000000;
pub const MF_BYPOSITION: UINT = 0x00000400;
pub const ACTCTX_FLAG_RESOURCE_NAME_VALID: u32 = 0x008;
pub const ACTCTX_FLAG_SET_PROCESS_DEFAULT: u32 = 0x010;
pub const ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID: u32 = 0x004;
#[repr(C)]
#[allow(non_snake_case)]
pub struct MENUINFO {
pub cbSize: DWORD,
pub fMask: DWORD,
pub dwStyle: DWORD,
pub cyMax: UINT,
pub hbrBack: HBRUSH,
pub dwContextHelpID: DWORD,
pub dwMenuData: ULONG_PTR
}
#[repr(C)]
#[allow(non_snake_case)]
pub struct MENUITEMINFO {
pub cbSize: UINT,
pub fMask: UINT,
pub fType: UINT,
pub fState: UINT,
pub wID: UINT,
pub hSubMenu: HMENU,
pub hbmpChecked: HBITMAP,
pub hbmpUnchecked: HBITMAP,
pub dwItemData: ULONG_PTR,
pub dwTypeData: LPWSTR,
pub cch: UINT,
pub hbmpItem: HBITMAP
}
extern "system" {
pub fn GetMenuItemCount(menu: HMENU) -> c_int;
pub fn GetSubMenu(hMenu: HMENU, nPos: c_int) -> HMENU;
pub fn SetMenuInfo(menu: HMENU, info: &mut MENUINFO) -> BOOL;
pub fn GetMenuInfo(menu: HMENU, info: &mut MENUINFO) -> BOOL;
pub fn RemoveMenu(menu: HMENU, pos: UINT, flags: UINT) -> BOOL;
pub fn SetMenuItemInfoW(menu: HMENU, item: UINT, by_position: BOOL, lpmii: *mut MENUITEMINFO) -> BOOL;
pub fn GetMenuItemInfoW(menu: HMENU, item: UINT, by_position: BOOL, lpmii: *mut MENUITEMINFO) -> BOOL;
pub fn GetMenuItemID(menu: HMENU, index: c_int) -> UINT;
}
pub struct PackUserValueArgs<ID: Hash+Clone> {
pub id: ID,
pub tid: TypeId,
pub value: Box<Any>
}
pub struct UnpackArgs {
pub id: u64
}
pub struct PackControlArgs<ID: Hash+Clone> {
pub id: ID,
pub value: Box<ControlT<ID>>
}
pub struct BindArgs<ID: Hash+Clone+'static> {
pub id: u64,
pub cb_id: u64,
pub event: Event,
pub cb: Box<EventCallback<ID>>
}
pub struct UnbindArgs {
pub id: u64,
pub cb_id: u64,
pub event: Event
}