-- GENERATED by C->Haskell Compiler, version 0.18.2 The shapeless maps, 31 Oct 2014 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}
{-# LANGUAGE CPP, ExistentialQuantification, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.MenuButton
    (
     -- * Constructor
     menuButtonNew
     -- * Hierarchy
     --
     -- $hierarchy

     -- * Functions
     --
     -- $functions
    )
where




import C2HS hiding (cFromEnum, cFromBool, cToBool,cToEnum)
import Foreign.C.Types
import Graphics.UI.FLTK.LowLevel.Fl_Enumerations
import Graphics.UI.FLTK.LowLevel.Fl_Types
import Graphics.UI.FLTK.LowLevel.Utils
import Graphics.UI.FLTK.LowLevel.Dispatch
import Graphics.UI.FLTK.LowLevel.Hierarchy

menuButtonNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
menuButtonNew' a1 a2 a3 a4 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  menuButtonNew''_ a1' a2' a3' a4' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 28 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

menuButtonNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
menuButtonNewWithLabel' a1 a2 a3 a4 a5 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  withCString a5 $ \a5' -> 
  menuButtonNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 29 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

menuButtonNew :: Rectangle -> Maybe String -> IO (Ref MenuButton)
menuButtonNew rectangle l'=
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in case l' of
        Nothing -> menuButtonNew' x_pos y_pos width height >>=
                             toRef
        Just l -> menuButtonNewWithLabel' x_pos y_pos width height l >>=
                               toRef

menuButtonDestroy' :: (Ptr ()) -> IO ((()))
menuButtonDestroy' a1 =
  let {a1' = id a1} in 
  menuButtonDestroy''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

{-# LINE 39 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

instance (impl ~ ( IO ())) => Op (Destroy ()) MenuButton orig impl where
  runOp _ _ win = swapRef win $ \winPtr -> do
    menuButtonDestroy' winPtr
    return nullPtr
menuButtonHandle' :: (Ptr ()) -> (CInt) -> IO ((Int))
menuButtonHandle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  menuButtonHandle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 44 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

instance (impl ~ (Event -> IO Int)) => Op (Handle ()) MenuButton orig impl where
  runOp _ _ menu_bar event = withRef menu_bar (\p -> menuButtonHandle' p (fromIntegral . fromEnum $ event))
menuButtonPopup' :: (Ptr ()) -> IO ((Ptr ()))
menuButtonPopup' a1 =
  let {a1' = id a1} in 
  menuButtonPopup''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 47 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

instance (impl ~ ( IO (Ref MenuItem))) => Op (Popup ()) MenuButton orig impl where
  runOp _ _ menu_bar = withRef menu_bar (\p -> menuButtonPopup' p >>= toRef)

-- $functions
-- @
--
-- destroy :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- handle :: 'Ref' 'MenuButton' -> 'Event' -> 'IO' 'Int'
--
-- popup :: 'Ref' 'MenuButton' -> 'IO' ('Ref' 'MenuItem')
-- @

-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.MenuPrim"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.MenuButton"
-- @
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuButton.chs.h Fl_Menu_Button_New"
  menuButtonNew''_ :: (CInt -> (CInt -> (CInt -> (CInt -> (IO (Ptr ()))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuButton.chs.h Fl_Menu_Button_New_WithLabel"
  menuButtonNewWithLabel''_ :: (CInt -> (CInt -> (CInt -> (CInt -> ((Ptr CChar) -> (IO (Ptr ())))))))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuButton.chs.h Fl_Menu_Button_Destroy"
  menuButtonDestroy''_ :: ((Ptr ()) -> (IO ()))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuButton.chs.h Fl_Menu_Button_handle"
  menuButtonHandle''_ :: ((Ptr ()) -> (CInt -> (IO CInt)))

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuButton.chs.h Fl_Menu_Button_popup"
  menuButtonPopup''_ :: ((Ptr ()) -> (IO (Ptr ())))