(* OCaml-Win32
 * win32_trackbar.ml
 * Copyright (c) 2002-2004 by Harry Chomsky
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *)

open Win32_core

(********************************************************************)
(* User Interface: Windows User Experience: Windows Shell: SDK: Windows Controls: Individual Control Information: Trackbar Controls *)

let trackbar_class = "msctls_trackbar32"

(* Styles *)

type trackbar_style_option =
    TBS_AUTOTICKS
  | TBS_BOTH
  | TBS_BOTTOM
  | TBS_ENABLESELRANGE
  | TBS_FIXEDLENGTH
  | TBS_HORZ
  | TBS_LEFT
  | TBS_NOTHUMB
  | TBS_NOTICKS
  | TBS_RIGHT
  | TBS_TOOLTIPS
  | TBS_TOP
  | TBS_VERT

external trackbar_style_of_option : trackbar_style_option -> style = "trackbar_style_of_option"

let trackbar_style_of_options = special_style_of_options ~special_func:trackbar_style_of_option

(* Messages *)

let tbm_clearsel = wm_user + 19
external pack_tbm_clearsel : redraw:bool -> message_contents = "pack_tbm_clearsel"
let unpack_tbm_clearsel = ignore
let issue_tbm_clearsel ~sender ~redraw = unpack_tbm_clearsel (sender ~msg:(pack_tbm_clearsel ~redraw))

let tbm_cleartics = wm_user + 9
external pack_tbm_cleartics : redraw:bool -> message_contents = "pack_tbm_cleartics"
let unpack_tbm_cleartics = ignore
let issue_tbm_cleartics ~sender ~redraw = unpack_tbm_cleartics (sender ~msg:(pack_tbm_cleartics ~redraw))

let tbm_getbuddy = wm_user + 33
external pack_tbm_getbuddy : location:bool -> message_contents = "pack_tbm_getbuddy"
external unpack_tbm_getbuddy : message_result -> hwnd = "unpack_tbm_getbuddy"
let issue_tbm_getbuddy ~sender ~location = unpack_tbm_getbuddy (sender ~msg:(pack_tbm_getbuddy ~location))

let tbm_getchannelrect = wm_user + 26
external issue_tbm_getchannelrect : sender:message_sender -> rect = "issue_tbm_getchannelrect"

let tbm_getlinesize = wm_user + 24
let pack_tbm_getlinesize = pack_simple_message ~id:tbm_getlinesize
external unpack_tbm_getlinesize : message_result -> int = "unpack_tbm_getlinesize"
let issue_tbm_getlinesize ~sender = unpack_tbm_getlinesize (sender ~msg:pack_tbm_getlinesize)

let tbm_getnumtics = wm_user + 16
let pack_tbm_getnumtics = pack_simple_message ~id:tbm_getnumtics
external unpack_tbm_getnumtics : message_result -> int = "unpack_tbm_getnumtics"
let issue_tbm_getnumtics ~sender = unpack_tbm_getnumtics (sender ~msg:pack_tbm_getnumtics)

let tbm_getpagesize = wm_user + 22
let pack_tbm_getpagesize = pack_simple_message ~id:tbm_getpagesize
external unpack_tbm_getpagesize : message_result -> int = "unpack_tbm_getpagesize"
let issue_tbm_getpagesize ~sender = unpack_tbm_getpagesize (sender ~msg:pack_tbm_getpagesize)

let tbm_getpos = wm_user + 0
let pack_tbm_getpos = pack_simple_message ~id:tbm_getpos
external unpack_tbm_getpos : message_result -> int = "unpack_tbm_getpos"
let issue_tbm_getpos ~sender = unpack_tbm_getpos (sender ~msg:pack_tbm_getpos)

let tbm_getptics = wm_user + 14
external issue_tbm_getptics : sender:message_sender -> tics:int array -> unit = "issue_tbm_getptics"

let tbm_getrangemax = wm_user + 2
let pack_tbm_getrangemax = pack_simple_message ~id:tbm_getrangemax
external unpack_tbm_getrangemax : message_result -> int = "unpack_tbm_getrangemax"
let issue_tbm_getrangemax ~sender = unpack_tbm_getrangemax (sender ~msg:pack_tbm_getrangemax)

let tbm_getrangemin = wm_user + 1
let pack_tbm_getrangemin = pack_simple_message ~id:tbm_getrangemin
external unpack_tbm_getrangemin : message_result -> int = "unpack_tbm_getrangemin"
let issue_tbm_getrangemin ~sender = unpack_tbm_getrangemin (sender ~msg:pack_tbm_getrangemin)

let tbm_getselend = wm_user + 18
let pack_tbm_getselend = pack_simple_message ~id:tbm_getselend
external unpack_tbm_getselend : message_result -> int = "unpack_tbm_getselend"
let issue_tbm_getselend ~sender = unpack_tbm_getselend (sender ~msg:pack_tbm_getselend)

let tbm_getselstart = wm_user + 17
let pack_tbm_getselstart = pack_simple_message ~id:tbm_getselstart
external unpack_tbm_getselstart : message_result -> int = "unpack_tbm_getselstart"
let issue_tbm_getselstart ~sender = unpack_tbm_getselstart (sender ~msg:pack_tbm_getselstart)

let tbm_getthumblength = wm_user + 28
let pack_tbm_getthumblength = pack_simple_message ~id:tbm_getthumblength
external unpack_tbm_getthumblength : message_result -> int = "unpack_tbm_getthumblength"
let issue_tbm_getthumblength ~sender = unpack_tbm_getthumblength (sender ~msg:pack_tbm_getthumblength)

let tbm_getthumbrect = wm_user + 25
external issue_tbm_getthumbrect : sender:message_sender -> rect = "issue_tbm_getthumbrect"

let tbm_gettic = wm_user + 3
external pack_tbm_gettic : tic:int -> message_contents = "pack_tbm_gettic"
external unpack_tbm_gettic : message_result -> int = "unpack_tbm_gettic"
let issue_tbm_gettic ~sender ~tic = unpack_tbm_gettic (sender ~msg:(pack_tbm_gettic ~tic))

let tbm_getticpos = wm_user + 15
external pack_tbm_getticpos : tic:int -> message_contents = "pack_tbm_getticpos"
external unpack_tbm_getticpos : message_result -> int = "unpack_tbm_getticpos"
let issue_tbm_getticpos ~sender ~tic = unpack_tbm_getticpos (sender ~msg:(pack_tbm_getticpos ~tic))

let tbm_gettooltips = wm_user + 30
let pack_tbm_gettooltips = pack_simple_message ~id:tbm_gettooltips
external unpack_tbm_gettooltips : message_result -> hwnd = "unpack_tbm_gettooltips"
let issue_tbm_gettooltips ~sender = unpack_tbm_gettooltips (sender ~msg:pack_tbm_gettooltips)

(* tbm_getunicodeformat: use ccm_getunicodeformat *)

let tbm_setbuddy = wm_user + 32
external pack_tbm_setbuddy : location:bool -> buddy:hwnd -> message_contents = "pack_tbm_setbuddy"
external unpack_tbm_setbuddy : message_result -> hwnd = "unpack_tbm_setbuddy"
let issue_tbm_setbuddy ~sender ~location ~buddy = unpack_tbm_setbuddy (sender ~msg:(pack_tbm_setbuddy ~location ~buddy))

let tbm_setlinesize = wm_user + 23
external pack_tbm_setlinesize : size:int -> message_contents = "pack_tbm_setlinesize"
external unpack_tbm_setlinesize : message_result -> int = "unpack_tbm_setlinesize"
let issue_tbm_setlinesize ~sender ~size = unpack_tbm_setlinesize (sender ~msg:(pack_tbm_setlinesize ~size))

let tbm_setpagesize = wm_user + 21
external pack_tbm_setpagesize : size:int -> message_contents = "pack_tbm_setpagesize"
external unpack_tbm_setpagesize : message_result -> int = "unpack_tbm_setpagesize"
let issue_tbm_setpagesize ~sender ~size = unpack_tbm_setpagesize (sender ~msg:(pack_tbm_setpagesize ~size))

let tbm_setpos = wm_user + 5
external pack_tbm_setpos : pos:int -> redraw:bool -> message_contents = "pack_tbm_setpos"
let unpack_tbm_setpos = ignore
let issue_tbm_setpos ~sender ~pos ~redraw = unpack_tbm_setpos (sender ~msg:(pack_tbm_setpos ~pos ~redraw))

let tbm_setrange = wm_user + 6
external pack_tbm_setrange : range:(int * int) -> redraw:bool -> message_contents = "pack_tbm_setrange"
let unpack_tbm_setrange = ignore
let issue_tbm_setrange ~sender ~range ~redraw = unpack_tbm_setrange (sender ~msg:(pack_tbm_setrange ~range ~redraw))

let tbm_setrangemax = wm_user + 8
external pack_tbm_setrangemax : max:int -> redraw:bool -> message_contents = "pack_tbm_setrangemax"
let unpack_tbm_setrangemax = ignore
let issue_tbm_setrangemax ~sender ~max ~redraw = unpack_tbm_setrangemax (sender ~msg:(pack_tbm_setrangemax ~max ~redraw))

let tbm_setrangemin = wm_user + 7
external pack_tbm_setrangemin : min:int -> redraw:bool -> message_contents = "pack_tbm_setrangemin"
let unpack_tbm_setrangemin = ignore
let issue_tbm_setrangemin ~sender ~min ~redraw = unpack_tbm_setrangemin (sender ~msg:(pack_tbm_setrangemin ~min ~redraw))

let tbm_setsel = wm_user + 10
external pack_tbm_setsel : sel:(int * int) -> redraw:bool -> message_contents = "pack_tbm_setsel"
let unpack_tbm_setsel = ignore
let issue_tbm_setsel ~sender ~sel ~redraw = unpack_tbm_setsel (sender ~msg:(pack_tbm_setsel ~sel ~redraw))

let tbm_setselend = wm_user + 12
external pack_tbm_setselend : pos:int -> redraw:bool -> message_contents = "pack_tbm_setselend"
let unpack_tbm_setselend = ignore
let issue_tbm_setselend ~sender ~pos ~redraw = unpack_tbm_setselend (sender ~msg:(pack_tbm_setselend ~pos ~redraw))

let tbm_setselstart = wm_user + 11
external pack_tbm_setselstart : pos:int -> redraw:bool -> message_contents = "pack_tbm_setselstart"
let unpack_tbm_setselstart = ignore
let issue_tbm_setselstart ~sender ~pos ~redraw = unpack_tbm_setselstart (sender ~msg:(pack_tbm_setselstart ~pos ~redraw))

let tbm_setthumblength = wm_user + 27
external pack_tbm_setthumblength : length:int -> message_contents = "pack_tbm_setthumblength"
let unpack_tbm_setthumblength = ignore
let issue_tbm_setthumblength ~sender ~length = unpack_tbm_setthumblength (sender ~msg:(pack_tbm_setthumblength ~length))

let tbm_settic = wm_user + 4
external pack_tbm_settic : pos:int -> message_contents = "pack_tbm_settic"
external unpack_tbm_settic : message_result -> bool = "unpack_tbm_settic"
let issue_tbm_settic ~sender ~pos = unpack_tbm_settic (sender ~msg:(pack_tbm_settic ~pos))

let tbm_setticfreq = wm_user + 20
external pack_tbm_setticfreq : freq:int -> message_contents = "pack_tbm_setticfreq"
let unpack_tbm_setticfreq = ignore
let issue_tbm_setticfreq ~sender ~freq = unpack_tbm_setticfreq (sender ~msg:(pack_tbm_setticfreq ~freq))

let tbm_settipside = wm_user + 31
type trackbar_tip_side =
    TBTS_TOP
  | TBTS_LEFT
  | TBTS_BOTTOM
  | TBTS_RIGHT
external pack_tbm_settipside : side:trackbar_tip_side -> message_contents = "pack_tbm_settipside"
external unpack_tbm_settipside : message_result -> trackbar_tip_side = "unpack_tbm_settipside"
let issue_tbm_settipside ~sender ~side = unpack_tbm_settipside (sender ~msg:(pack_tbm_settipside ~side))

let tbm_settooltips = wm_user + 29
external pack_tbm_settooltips : tooltips:hwnd -> message_contents = "pack_tbm_settooltips"
let unpack_tbm_settooltips = ignore
let issue_tbm_settooltips ~sender ~tooltips = unpack_tbm_settooltips (sender ~msg:(pack_tbm_settooltips ~tooltips))

(* tbm_setunicodeformat: use ccm_setunicodeformat *)

(* Notifications *)

type trackbar_customdraw_part =
    TBCD_CHANNEL
  | TBCD_THUMB
  | TBCD_TICS
external unpack_nmcustomdraw_trackbar_item_spec : msg:message_contents -> trackbar_customdraw_part = "unpack_nmcustomdraw_trackbar_item_spec"
