-- GENERATED by C->Haskell Compiler, version 0.28.1 Switcheroo, 1 April 2016 (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,
     MenuButtonType(..),
     menuButtonCustom
     -- * Hierarchy
     --
     -- $hierarchy

     -- * Functions
     --
     -- $functions
    )
where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp






import C2HS hiding (cFromEnum, cFromBool, cToBool,cToEnum)
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 qualified Data.Text as T
import Graphics.UI.FLTK.LowLevel.Hierarchy
import Graphics.UI.FLTK.LowLevel.Widget

data MenuButtonType = NormalMenuButton
                    | Popup1MenuButton
                    | Popup2MenuButton
                    | Popup12MenuButton
                    | Popup3MenuButton
                    | Popup13MenuButton
                    | Popup123MenuButton
  deriving (Show,Eq)
instance Enum MenuButtonType where
  succ NormalMenuButton = Popup1MenuButton
  succ Popup1MenuButton = Popup2MenuButton
  succ Popup2MenuButton = Popup12MenuButton
  succ Popup12MenuButton = Popup3MenuButton
  succ Popup3MenuButton = Popup13MenuButton
  succ Popup13MenuButton = Popup123MenuButton
  succ Popup123MenuButton = error "MenuButtonType.succ: Popup123MenuButton has no successor"

  pred Popup1MenuButton = NormalMenuButton
  pred Popup2MenuButton = Popup1MenuButton
  pred Popup12MenuButton = Popup2MenuButton
  pred Popup3MenuButton = Popup12MenuButton
  pred Popup13MenuButton = Popup3MenuButton
  pred Popup123MenuButton = Popup13MenuButton
  pred NormalMenuButton = error "MenuButtonType.pred: NormalMenuButton has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from Popup123MenuButton

  fromEnum NormalMenuButton = 0
  fromEnum Popup1MenuButton = 1
  fromEnum Popup2MenuButton = 2
  fromEnum Popup12MenuButton = 3
  fromEnum Popup3MenuButton = 4
  fromEnum Popup13MenuButton = 5
  fromEnum Popup123MenuButton = 7

  toEnum 0 = NormalMenuButton
  toEnum 1 = Popup1MenuButton
  toEnum 2 = Popup2MenuButton
  toEnum 3 = Popup12MenuButton
  toEnum 4 = Popup3MenuButton
  toEnum 5 = Popup13MenuButton
  toEnum 7 = Popup123MenuButton
  toEnum unmatched = error ("MenuButtonType.toEnum: Cannot match " ++ show unmatched)

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

overriddenWidgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> (Ptr ()) -> IO ((Ptr ()))
overriddenWidgetNewWithLabel' a1 a2 a3 a4 a5 a6 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = unsafeToCString a5} in 
  let {a6' = id a6} in 
  overriddenWidgetNewWithLabel''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = id res} in
  return (res')

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

overriddenWidgetNew' :: (Int) -> (Int) -> (Int) -> (Int) -> (Ptr ()) -> IO ((Ptr ()))
overriddenWidgetNew' 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 
  let {a5' = id a5} in 
  overriddenWidgetNew''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

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

menuButtonCustom ::
       Rectangle                         -- ^ The bounds of this MenuButton
    -> Maybe T.Text                      -- ^ The MenuButton label
    -> Maybe (Ref MenuButton -> IO ())           -- ^ Optional custom drawing function
    -> Maybe (CustomWidgetFuncs MenuButton)      -- ^ Optional custom widget functions
    -> IO (Ref MenuButton)
menuButtonCustom rectangle l' draw' funcs' =
  widgetMaker
    rectangle
    l'
    draw'
    funcs'
    overriddenWidgetNew'
    overriddenWidgetNewWithLabel'


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 60 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

menuButtonNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (T.Text) -> 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 
  let {a5' = unsafeToCString a5} in 
  menuButtonNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')

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

menuButtonNew :: Rectangle -> Maybe T.Text -> 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 71 "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
menuButtonPopup' :: (Ptr ()) -> IO ((Ptr ()))
menuButtonPopup' a1 =
  let {a1' = id a1} in 
  menuButtonPopup''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')

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

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

draw'' :: (Ptr ()) -> IO ()
draw'' a1 =
  let {a1' = id a1} in 
  draw'''_ a1' >>
  return ()

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

instance (impl ~ (  IO ())) => Op (Draw ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> draw'' menuButtonPtr
drawSuper' :: (Ptr ()) -> IO ((()))
drawSuper' a1 =
  let {a1' = id a1} in 
  drawSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

instance (impl ~ ( IO ())) => Op (DrawSuper ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> drawSuper' menuButtonPtr
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 86 "src/Graphics/UI/FLTK/LowLevel/MenuButton.chs" #-}

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

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

instance (impl ~ (Event ->  IO (Either UnknownEvent ()))) => Op (HandleSuper ()) MenuButton orig impl where
  runOp _ _ menuButton event = withRef menuButton $ \menuButtonPtr -> handleSuper' menuButtonPtr (fromIntegral (fromEnum event)) >>= return . successOrUnknownEvent
resize' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((()))
resize' a1 a2 a3 a4 a5 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = fromIntegral a5} in 
  resize''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) MenuButton orig impl where
  runOp _ _ menuButton rectangle = withRef menuButton $ \menuButtonPtr -> do
                                 let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
                                 resize' menuButtonPtr x_pos y_pos w_pos h_pos
resizeSuper' :: (Ptr ()) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((()))
resizeSuper' a1 a2 a3 a4 a5 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  let {a5' = fromIntegral a5} in 
  resizeSuper''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

instance (impl ~ (Rectangle -> IO ())) => Op (ResizeSuper ()) MenuButton orig impl where
  runOp _ _ menuButton rectangle =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in withRef menuButton $ \menuButtonPtr -> resizeSuper' menuButtonPtr x_pos y_pos width height
hide' :: (Ptr ()) -> IO ()
hide' a1 =
  let {a1' = id a1} in 
  hide''_ a1' >>
  return ()

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

instance (impl ~ (  IO ())) => Op (Hide ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> hide' menuButtonPtr
hideSuper' :: (Ptr ()) -> IO ((()))
hideSuper' a1 =
  let {a1' = id a1} in 
  hideSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

instance (impl ~ ( IO ())) => Op (HideSuper ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> hideSuper' menuButtonPtr
show' :: (Ptr ()) -> IO ()
show' a1 =
  let {a1' = id a1} in 
  show''_ a1' >>
  return ()

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

instance (impl ~ (  IO ())) => Op (ShowWidget ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> show' menuButtonPtr
showSuper' :: (Ptr ()) -> IO ((()))
showSuper' a1 =
  let {a1' = id a1} in 
  showSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

instance (impl ~ ( IO ())) => Op (ShowWidgetSuper ()) MenuButton orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> showSuper' menuButtonPtr

-- $functions
-- @
-- destroy :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- draw :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- drawSuper :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- handle :: 'Ref' 'MenuButton' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
--
-- handleSuper :: 'Ref' 'MenuButton' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
--
-- hide :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- hideSuper :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- popup :: 'Ref' 'MenuButton' -> 'IO' ('Maybe' ('Ref' 'MenuItem'))
--
-- resize :: 'Ref' 'MenuButton' -> 'Rectangle' -> 'IO' ()
--
-- resizeSuper :: 'Ref' 'MenuButton' -> 'Rectangle' -> 'IO' ()
--
-- showWidget :: 'Ref' 'MenuButton' -> 'IO' ()
--
-- showWidgetSuper :: 'Ref' 'MenuButton' -> 'IO' ()
-- @

-- $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_OverriddenMenu_Button_New_WithLabel"
  overriddenWidgetNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ()))))))))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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