-- GENERATED by C->Haskell Compiler, version 0.28.6 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}
{-# LANGUAGE CPP, ExistentialQuantification, TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.UI.FLTK.LowLevel.Base.MenuButton
    (
     -- * Constructor
     menuButtonNew,
     MenuButtonType(..),
     menuButtonCustom
   , drawMenuButtonBase
   , handleMenuButtonBase
   , resizeMenuButtonBase
   , hideMenuButtonBase
   , showWidgetMenuButtonBase
     -- * 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.Base.Widget

data MenuButtonType = NormalMenuButton
                    | Popup1MenuButton
                    | Popup2MenuButton
                    | Popup12MenuButton
                    | Popup3MenuButton
                    | Popup13MenuButton
                    | Popup123MenuButton
  deriving (Int -> MenuButtonType -> ShowS
[MenuButtonType] -> ShowS
MenuButtonType -> String
(Int -> MenuButtonType -> ShowS)
-> (MenuButtonType -> String)
-> ([MenuButtonType] -> ShowS)
-> Show MenuButtonType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MenuButtonType] -> ShowS
$cshowList :: [MenuButtonType] -> ShowS
show :: MenuButtonType -> String
$cshow :: MenuButtonType -> String
showsPrec :: Int -> MenuButtonType -> ShowS
$cshowsPrec :: Int -> MenuButtonType -> ShowS
Show,MenuButtonType -> MenuButtonType -> Bool
(MenuButtonType -> MenuButtonType -> Bool)
-> (MenuButtonType -> MenuButtonType -> Bool) -> Eq MenuButtonType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MenuButtonType -> MenuButtonType -> Bool
$c/= :: MenuButtonType -> MenuButtonType -> Bool
== :: MenuButtonType -> MenuButtonType -> Bool
$c== :: MenuButtonType -> MenuButtonType -> Bool
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 46 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}

overriddenWidgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (CString) -> (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 
  (flip ($)) a5 $ \a5' -> 
  let {a6' = id a6} in 
  overriddenWidgetNewWithLabel''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 47 "src/Graphics/UI/FLTK/LowLevel/Base/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 48 "src/Graphics/UI/FLTK/LowLevel/Base/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 65 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}

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

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

menuButtonNew :: Rectangle -> Maybe T.Text -> IO (Ref MenuButton)
menuButtonNew rectangle l'=
  widgetMaker
    rectangle
    l'
    Nothing
    Nothing
    overriddenWidgetNew'
    overriddenWidgetNewWithLabel'

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

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

instance (impl ~ ( IO ())) => Op (Destroy ()) MenuButtonBase 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 82 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}

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

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

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

drawMenuButtonBase ::  Ref MenuButtonBase -> IO ()
drawMenuButtonBase menuButton = withRef menuButton $ \menuButtonPtr -> drawSuper' menuButtonPtr
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/Base/MenuButton.chs" #-}

handleMenuButtonBase :: Ref MenuButtonBase -> Event ->  IO (Either UnknownEvent ())
handleMenuButtonBase menuButton event = withRef menuButton $ \menuButtonPtr -> handleSuper' menuButtonPtr (fromIntegral (fromEnum event)) >>= return . successOrUnknownEvent
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 92 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}

resizeMenuButtonBase :: Ref MenuButtonBase -> Rectangle -> IO ()
resizeMenuButtonBase menuButton rectangle =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in withRef menuButton $ \menuButtonPtr -> resizeSuper' menuButtonPtr x_pos y_pos width height
hideSuper' :: (Ptr ()) -> IO ((()))
hideSuper' a1 =
  let {a1' = id a1} in 
  hideSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

hideMenuButtonBase ::  Ref MenuButtonBase -> IO ()
hideMenuButtonBase menuButton = withRef menuButton $ \menuButtonPtr -> hideSuper' menuButtonPtr
showSuper' :: (Ptr ()) -> IO ((()))
showSuper' a1 =
  let {a1' = id a1} in 
  showSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')

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

showWidgetMenuButtonBase ::  Ref MenuButtonBase -> IO ()
showWidgetMenuButtonBase menuButton = withRef menuButton $ \menuButtonPtr -> showSuper' menuButtonPtr

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

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

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

instance (impl ~ (Event -> IO (Either UnknownEvent ()))) => Op (Handle ()) MenuButtonBase orig impl where
  runOp _ _ menuButton event = withRef menuButton (\p -> menuButtonHandle' p (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 110 "src/Graphics/UI/FLTK/LowLevel/Base/MenuButton.chs" #-}

instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) MenuButtonBase 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
hide' :: (Ptr ()) -> IO ()
hide' a1 =
  let {a1' = id a1} in 
  hide''_ a1' >>
  return ()

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

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

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

instance (impl ~ (  IO ())) => Op (ShowWidget ()) MenuButtonBase orig impl where
  runOp _ _ menuButton = withRef menuButton $ \menuButtonPtr -> show' menuButtonPtr


-- $hierarchy
-- @
-- "Graphics.UI.FLTK.LowLevel.Base.Widget"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Base.MenuPrim"
--  |
--  v
-- "Graphics.UI.FLTK.LowLevel.Base.MenuButton"
-- @

-- $functions
-- @
-- destroy :: 'Ref' 'MenuButtonBase' -> 'IO' ()
--
-- draw :: 'Ref' 'MenuButtonBase' -> 'IO' ()
--
-- handle :: 'Ref' 'MenuButtonBase' -> 'Event' -> 'IO' ('Either' 'UnknownEvent' ())
--
-- hide :: 'Ref' 'MenuButtonBase' -> 'IO' ()
--
-- popup :: 'Ref' 'MenuButtonBase' -> 'IO' ('Maybe' ('Ref' 'MenuItemBase'))
--
-- resize :: 'Ref' 'MenuButtonBase' -> 'Rectangle' -> 'IO' ()
--
-- showWidget :: 'Ref' 'MenuButtonBase' -> 'IO' ()
-- @

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/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/Base/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/Base/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/Base/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/Base/MenuButton.chs.h Fl_Menu_Button_Destroy"
  menuButtonDestroy''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

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

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

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/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/Base/MenuButton.chs.h Fl_Menu_Button_hide_super"
  hideSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

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

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

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

foreign import ccall safe "Graphics/UI/FLTK/LowLevel/Base/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/Base/MenuButton.chs.h Fl_Menu_Button_hide"
  hide''_ :: ((C2HSImp.Ptr ()) -> (IO ()))

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