{-# LANGUAGE CPP, ForeignFunctionInterface #-}

module Graphics.UI.FLTK.MultiBrowser (MultiBrowser, newMultiBrowser,
                          deselect, select) where

import Graphics.UI.FLTK.Browser
import Graphics.UI.FLTK.Widget
import Foreign.Ptr

-- | The type for MultiBrowsers, which is a subtype of Browser.
newtype MultiBrowser = MultiBrowser (Ptr MultiBrowser)
instance Widget_C MultiBrowser where _widget (MultiBrowser p) = castPtr p
instance Browser_C MultiBrowser where _browser (MultiBrowser b) = castPtr b


foreign import ccall "fl_Multi_Browser_new" _newMultiBrowser ::  Int->Int->Int->Int->IO MultiBrowser
-- | Create a new browser.
newMultiBrowser :: Int->Int->Int->Int->[Prop MultiBrowser]->IO MultiBrowser
newMultiBrowser x y w h l = do { b <- _newMultiBrowser x y w h; set b l; return b }

foreign import ccall "fl_Multi_Browser_value_AS" fl_Multi_Browser_value_AS :: MultiBrowser->Int-> IO ()
foreign import ccall "fl_Multi_Browser_value_AG" fl_Multi_Browser_value_AG :: MultiBrowser->IO Int
instance Value_FC MultiBrowser Int where
    value = Attr fl_Multi_Browser_value_AG fl_Multi_Browser_value_AS

--  /*
-- | Deselect all entries
deselect :: MultiBrowser -> IO ()
--  */
foreign import ccall "fl_Multi_Browser_deselect" deselect :: MultiBrowser -> IO ()

foreign import ccall "fl_Multi_Browser_select_A2S" fl_Multi_Browser_select_A2S :: MultiBrowser->Int->Bool-> IO ()
foreign import ccall "fl_Multi_Browser_select_A2G" fl_Multi_Browser_select_A2G :: MultiBrowser->Int->IO Bool

-- | Toggle whether the specified row is selected or not.
select :: Int -> Attr MultiBrowser Bool
select iv = Attr (\mb -> fl_Multi_Browser_select_A2G mb iv)
                 (\mv v -> fl_Multi_Browser_select_A2S mv iv v)