1(* 2 Copyright (c) 2001 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 as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18*) 19 20(* Comboboxes. *) 21structure Combobox: 22sig 23 structure Style: 24 sig 25 include BIT_FLAGS where type flags = Window.Style.flags 26 val WS_OVERLAPPED: flags and WS_POPUP: flags and WS_CHILD: flags and WS_MINIMIZE: flags 27 and WS_VISIBLE: flags and WS_DISABLED:flags and WS_CLIPSIBLINGS:flags 28 and WS_CLIPCHILDREN:flags and WS_MAXIMIZE:flags and WS_CAPTION:flags 29 and WS_BORDER:flags and WS_DLGFRAME:flags and WS_VSCROLL:flags and WS_HSCROLL:flags 30 and WS_SYSMENU:flags and WS_THICKFRAME:flags and WS_GROUP:flags and WS_TABSTOP:flags 31 and WS_MINIMIZEBOX:flags and WS_MAXIMIZEBOX:flags and WS_TILED:flags and WS_ICONIC:flags 32 and WS_SIZEBOX:flags and WS_OVERLAPPEDWINDOW:flags and WS_TILEDWINDOW:flags 33 and WS_POPUPWINDOW: flags and WS_CHILDWINDOW: flags 34 and CBS_SIMPLE: flags and CBS_DROPDOWN: flags and CBS_DROPDOWNLIST: flags 35 and CBS_OWNERDRAWFIXED: flags and CBS_OWNERDRAWVARIABLE: flags and CBS_AUTOHSCROLL: flags 36 and CBS_OEMCONVERT: flags and CBS_SORT: flags and CBS_HASSTRINGS: flags 37 and CBS_NOINTEGRALHEIGHT: flags and CBS_DISABLENOSCROLL: flags 38 and CBS_UPPERCASE: flags and CBS_LOWERCASE: flags 39 end 40 41 structure Notifications: 42 sig 43 val CBN_SELCHANGE: int 44 val CBN_DBLCLK: int 45 val CBN_SETFOCUS: int 46 val CBN_KILLFOCUS: int 47 val CBN_EDITCHANGE: int 48 val CBN_EDITUPDATE: int 49 val CBN_DROPDOWN: int 50 val CBN_CLOSEUP: int 51 val CBN_SELENDOK: int 52 val CBN_SELENDCANCEL: int 53 end 54 55 datatype CBDirAttr = 56 DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_SYSTEM | DDL_DIRECTORY | 57 DDL_ARCHIVE | DDL_POSTMSGS | DDL_DRIVES | DDL_EXCLUSIVE 58end 59= 60struct 61 open ComboBase 62 63 structure Style = 64 struct 65 open Window.Style (* Include all the windows styles. *) 66 67 val CBS_SIMPLE = fromWord 0wx0001 68 val CBS_DROPDOWN = fromWord 0wx0002 69 val CBS_DROPDOWNLIST = fromWord 0wx0003 70 val CBS_OWNERDRAWFIXED = fromWord 0wx0010 71 val CBS_OWNERDRAWVARIABLE = fromWord 0wx0020 72 val CBS_AUTOHSCROLL = fromWord 0wx0040 73 val CBS_OEMCONVERT = fromWord 0wx0080 74 val CBS_SORT = fromWord 0wx0100 75 val CBS_HASSTRINGS = fromWord 0wx0200 76 val CBS_NOINTEGRALHEIGHT = fromWord 0wx0400 77 val CBS_DISABLENOSCROLL = fromWord 0wx0800 78 val CBS_UPPERCASE = fromWord 0wx2000 79 val CBS_LOWERCASE = fromWord 0wx4000 80 81 val all = flags[Window.Style.all, CBS_SIMPLE, CBS_DROPDOWN, CBS_DROPDOWNLIST, 82 CBS_OWNERDRAWFIXED, CBS_OWNERDRAWVARIABLE, CBS_AUTOHSCROLL, 83 CBS_OEMCONVERT, CBS_SORT, CBS_HASSTRINGS, CBS_NOINTEGRALHEIGHT, 84 CBS_DISABLENOSCROLL, CBS_UPPERCASE, CBS_LOWERCASE] 85 86 val intersect = 87 List.foldl (fn (a, b) => fromWord(SysWord.andb(toWord a, toWord b))) all 88 end 89 90 structure Notifications = 91 struct 92 val CBN_SELCHANGE = 1 93 val CBN_DBLCLK = 2 94 val CBN_SETFOCUS = 3 95 val CBN_KILLFOCUS = 4 96 val CBN_EDITCHANGE = 5 97 val CBN_EDITUPDATE = 6 98 val CBN_DROPDOWN = 7 99 val CBN_CLOSEUP = 8 100 val CBN_SELENDOK = 9 101 val CBN_SELENDCANCEL = 10 102 end 103(* 104DlgDirListComboBox 105DlgDirSelectEx 106DlgDirSelectComboBoxEx 107*) 108end; 109 110(* 111let 112 open Combobox.Style 113 114 val flagTable = 115 [(CBS_DROPDOWNLIST, "CBS_DROPDOWNLIST"), (* Must come before the next two. *) 116 (CBS_SIMPLE, "CBS_SIMPLE"), 117 (CBS_DROPDOWN, "CBS_DROPDOWN"), 118 (CBS_OWNERDRAWFIXED, "CBS_OWNERDRAWFIXED"), 119 (CBS_OWNERDRAWVARIABLE, "CBS_OWNERDRAWVARIABLE"), 120 (CBS_AUTOHSCROLL, "CBS_AUTOHSCROLL"), 121 (CBS_OEMCONVERT, "CBS_OEMCONVERT"), 122 (CBS_SORT, "CBS_SORT"), 123 (CBS_HASSTRINGS, "CBS_HASSTRINGS"), 124 (CBS_NOINTEGRALHEIGHT, "CBS_NOINTEGRALHEIGHT"), 125 (CBS_DISABLENOSCROLL, "CBS_DISABLENOSCROLL"), 126 (CBS_UPPERCASE, "CBS_UPPERCASE"), 127 (CBS_LOWERCASE, "CBS_LOWERCASE"), 128 (WS_POPUP, "WS_POPUP"), 129 (WS_CHILD, "WS_CHILD"), 130 (WS_MINIMIZE, "WS_MINIMIZE"), 131 (WS_VISIBLE, "WS_VISIBLE"), 132 (WS_DISABLED, "WS_DISABLED"), 133 (WS_CLIPSIBLINGS, "WS_CLIPSIBLINGS"), 134 (WS_CLIPCHILDREN, "WS_CLIPCHILDREN"), 135 (WS_MAXIMIZE, "WS_MAXIMIZE"), 136 (WS_CAPTION, "WS_CAPTION"), 137 (WS_BORDER, "WS_BORDER"), 138 (WS_DLGFRAME, "WS_DLGFRAME"), 139 (WS_VSCROLL, "WS_VSCROLL"), 140 (WS_HSCROLL, "WS_HSCROLL"), 141 (WS_SYSMENU, "WS_SYSMENU"), 142 (WS_THICKFRAME, "WS_THICKFRAME"), 143 (WS_GROUP, "WS_GROUP"), 144 (WS_TABSTOP, "WS_TABSTOP"), 145 (WS_MINIMIZEBOX, "WS_MINIMIZEBOX"), 146 (WS_MAXIMIZEBOX, "WS_MAXIMIZEBOX")] 147 148 fun accumulateFlags f [] = [] 149 | accumulateFlags f ((w, s)::t) = 150 if allSet(w, f) then s :: accumulateFlags(clear(w, f)) t 151 else accumulateFlags f t 152 153 fun printFlags(put, beg, brk, nd) depth _ x = 154 (* This is just the code to print a list. *) 155 let 156 157 val stringFlags = accumulateFlags x flagTable 158 fun plist [] depth = () 159 | plist _ 0 = put "..." 160 | plist [h] depth = put h 161 | plist (h::t) depth = 162 ( put (h^","); 163 brk (1, 0); 164 plist t (depth - 1) 165 ) 166 in 167 beg (3, false); 168 put "["; 169 if depth <= 0 then put "..." else plist stringFlags depth; 170 put "]"; 171 nd () 172 end 173in 174 PolyML.install_pp printFlags 175end; 176*) 177