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 ScrollBase =
20struct
21    local
22        open Foreign Base
23    in
24        type enableArrows = { enableLeftUp: bool, enableRightDown: bool }
25        val ESB_ENABLE_BOTH = { enableLeftUp = true, enableRightDown = true }
26        val ESB_DISABLE_BOTH = { enableLeftUp = false, enableRightDown = false }
27        val ESB_DISABLE_LEFT = { enableLeftUp = false, enableRightDown = true }
28        val ESB_DISABLE_RIGHT = { enableLeftUp = true, enableRightDown = false }
29        val ESB_DISABLE_UP = ESB_DISABLE_LEFT
30        val ESB_DISABLE_DOWN = ESB_DISABLE_RIGHT
31
32        local
33            (* The arrows are disabled if the bit is set. *)
34            fun toInt({enableLeftUp: bool, enableRightDown}: enableArrows) =
35                IntInf.orb(if enableLeftUp then 0 else 1,
36                           if enableRightDown then 0 else 2)
37            and fromInt i : enableArrows =
38                {enableLeftUp = IntInf.andb(i, 1) = 0,
39                 enableRightDown = IntInf.andb(i, 2) = 0} 
40        in
41            (* It's easier to use the functions directly for messages *)
42            val ENABLESCROLLBARFLAG = (toInt, fromInt)
43            val cENABLESCROLLBARFLAG = absConversion{rep = toInt, abs = fromInt} cUint
44        end
45
46        type SCROLLINFO =
47            { minPos: int, maxPos: int, pageSize: int, pos: int, trackPos: int }
48
49        datatype ScrollInfoOption =
50            SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL | SIF_TRACKPOS
51
52        val SIF_ALL = [SIF_RANGE, SIF_PAGE, SIF_POS, SIF_TRACKPOS]
53
54        local
55            val tab = [
56                (SIF_RANGE,           0wx0001),
57                (SIF_PAGE,            0wx0002),
58                (SIF_POS,             0wx0004),
59                (SIF_DISABLENOSCROLL, 0wx0008),
60                (SIF_TRACKPOS,        0wx0010)]
61        in
62            (*val (fromSIF, toSIF) = tableSetLookup(tab, NONE)*)
63            val cSCROLLINFOOPTION = tableSetConversion(tab, NONE)
64        end
65
66        (* Needed in Scrollbar and also Messages *)
67        val cSCROLLINFOSTRUCT =
68            cStruct7(cUint, cSCROLLINFOOPTION, cInt, cInt, cUint, cInt, cInt)
69    end
70end;
71