1(*
2    Copyright (c) 2001, 2015
3        David C.J. Matthews
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License version 2.1 as published by the Free Software Foundation.
8    
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13    
14    You should have received a copy of the GNU Lesser General Public
15    License along with this library; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17*)
18
19structure MenuBase =
20struct
21    local
22        open Foreign Base
23    in
24        (* TODO: This duplicates some of the other datatypes. *)
25        datatype MenuFlag =
26            (*MF_INSERT | MF_CHANGE | MF_APPEND | MF_DELETE | MF_REMOVE | *)
27            MF_BYCOMMAND | MF_BYPOSITION | MF_SEPARATOR | MF_ENABLED | MF_GRAYED |
28            MF_DISABLED | MF_UNCHECKED | MF_CHECKED | MF_USECHECKBITMAPS | MF_STRING |
29            MF_BITMAP | MF_OWNERDRAW | MF_POPUP | MF_MENUBARBREAK | MF_MENUBREAK |
30            MF_UNHILITE | MF_HILITE | MF_DEFAULT | MF_SYSMENU | MF_HELP |
31            MF_RIGHTJUSTIFY | MF_MOUSESELECT
32
33        local
34            val tab = [
35                (*(MF_INSERT,   0wx00000000),
36                (MF_CHANGE,     0wx00000080),
37                (MF_APPEND,     0wx00000100),
38                (MF_DELETE,     0wx00000200),
39                (MF_REMOVE,     0wx00001000),*)
40                (MF_BYCOMMAND,  0wx00000000),
41                (MF_BYPOSITION, 0wx00000400),
42                (MF_SEPARATOR,  0wx00000800),
43                (MF_ENABLED,    0wx00000000),
44                (MF_GRAYED,     0wx00000001),
45                (MF_DISABLED,   0wx00000002),
46                (MF_UNCHECKED,  0wx00000000),
47                (MF_CHECKED,    0wx00000008),
48                (MF_USECHECKBITMAPS, 0wx00000200),
49                (MF_STRING,     0wx00000000),
50                (MF_BITMAP,     0wx00000004),
51                (MF_OWNERDRAW,  0wx00000100),
52                (MF_POPUP,      0wx00000010),
53                (MF_MENUBARBREAK, 0wx00000020),
54                (MF_MENUBREAK,  0wx00000040),
55                (MF_UNHILITE,   0wx00000000),
56                (MF_HILITE,     0wx00000080),
57                (MF_DEFAULT,    0wx00001000),
58                (MF_SYSMENU,    0wx00002000),
59                (MF_HELP,       0wx00004000),
60                (MF_RIGHTJUSTIFY, 0wx00004000),
61                (MF_MOUSESELECT, 0wx00008000)
62             ]
63        in
64            val (fromMenuFlagSet, toMenuFlagSet) = tableSetLookup(tab, NONE)
65            val cMENUFLAGSET = absConversion {abs=toMenuFlagSet, rep=fromMenuFlagSet} cUintw
66            (* Sometimes we just want a single flag - either MF_BYCOMMAND or MF_BYPOSITION
67               or, for WM_MENUCHAR, MF_POPUP or MF_SYSMENU. *)
68            val (fromMenuFlag, toMenuFlag) = tableLookup(tab, NONE)
69            val cMENUFLAG = tableConversion(tab, NONE) cUintw
70        end
71
72    end
73end;
74