module Graphics.UI.FLTK.LowLevel.MenuPrim
    (
     menu_New,
     menu_Custom
     
     
     
     
     
     
    )
where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import C2HS hiding (cFromEnum, cFromBool, cToBool,cToEnum)
import Foreign.C.Types
import Graphics.UI.FLTK.LowLevel.Widget
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
import Graphics.UI.FLTK.LowLevel.MenuItem
import qualified Data.ByteString.Char8 as C
widgetNew' :: (Int) -> (Int) -> (Int) -> (Int) -> IO ((Ptr ()))
widgetNew' a1 a2 a3 a4 =
  let {a1' = fromIntegral a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  widgetNew''_ a1' a2' a3' a4' >>= \res ->
  let {res' = id res} in
  return (res')
widgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> IO ((Ptr ()))
widgetNewWithLabel' 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 
  widgetNewWithLabel''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = id res} in
  return (res')
overriddenWidgetNewWithLabel' :: (Int) -> (Int) -> (Int) -> (Int) -> (String) -> (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')
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')
menu_Custom :: Rectangle -> Maybe String -> Maybe (CustomWidgetFuncs MenuPrim) -> IO (Ref MenuPrim)
menu_Custom rectangle l' funcs' =
  widgetMaker
    rectangle
    l'
    Nothing
    funcs'
    widgetNew'
    widgetNewWithLabel'
    overriddenWidgetNew'
    overriddenWidgetNewWithLabel'
menu_New :: Rectangle -> Maybe String -> IO (Ref MenuPrim)
menu_New rectangle l' =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in case l' of
        Nothing -> widgetNew' x_pos y_pos width height >>=
                             toRef
        Just l -> widgetNewWithLabel' x_pos y_pos width height l >>=
                             toRef
widgetDestroy' :: (Ptr ()) -> IO ((()))
widgetDestroy' a1 =
  let {a1' = id a1} in 
  widgetDestroy''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')
instance (impl ~ (IO ())) => Op (Destroy ()) MenuPrim orig impl where
  runOp _ _ menu_ = swapRef menu_ $
                          \menu_Ptr ->
                             widgetDestroy' menu_Ptr >>
                             return nullPtr
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')
instance (impl ~ (Int ->  IO (Int))) => Op (HandleSuper ()) MenuPrim orig impl where
  runOp _ _ menu_ event = withRef menu_ $ \menu_Ptr -> handleSuper' menu_Ptr event
menu_Handle' :: (Ptr ()) -> (CInt) -> IO ((Int))
menu_Handle' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  menu_Handle''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ (Event -> IO Int)) => Op (Handle ()) MenuPrim orig impl where
  runOp _ _ menu_ event = withRef menu_ (\p -> menu_Handle' p (fromIntegral . fromEnum $ event))
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')
instance (impl ~ (Rectangle -> IO ())) => Op (ResizeSuper ()) MenuPrim orig impl where
  runOp _ _ menu_ rectangle =
    let (x_pos, y_pos, width, height) = fromRectangle rectangle
    in withRef menu_ $ \menu_Ptr -> resizeSuper' menu_Ptr x_pos y_pos width height
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')
instance (impl ~ (Rectangle -> IO ())) => Op (Resize ()) MenuPrim orig impl where
  runOp _ _ menu_ rectangle = withRef menu_ $ \menu_Ptr -> do
                                 let (x_pos,y_pos,w_pos,h_pos) = fromRectangle rectangle
                                 resize' menu_Ptr x_pos y_pos w_pos h_pos
hideSuper' :: (Ptr ()) -> IO ((()))
hideSuper' a1 =
  let {a1' = id a1} in 
  hideSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')
instance (impl ~ ( IO ())) => Op (HideSuper ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> hideSuper' menu_Ptr
hide' :: (Ptr ()) -> IO ((()))
hide' a1 =
  let {a1' = id a1} in 
  hide''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')
instance (impl ~ ( IO ())) => Op (Hide ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> hide' menu_Ptr
showSuper' :: (Ptr ()) -> IO ((()))
showSuper' a1 =
  let {a1' = id a1} in 
  showSuper''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')
instance (impl ~ ( IO ())) => Op (ShowWidgetSuper ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> showSuper' menu_Ptr
menu_Show' :: (Ptr ()) -> IO ((()))
menu_Show' a1 =
  let {a1' = id a1} in 
  menu_Show''_ a1' >>= \res ->
  let {res' = supressWarningAboutRes res} in
  return (res')
instance (impl ~ (IO ())) => Op (ShowWidget ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ (\p -> menu_Show' p)
itemPathnameWithFinditem' :: (Ptr ()) -> (Ptr CChar) -> (Int) -> (Ptr ()) -> IO ((Int))
itemPathnameWithFinditem' a1 a2 a3 a4 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = id a4} in 
  itemPathnameWithFinditem''_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
itemPathname' :: (Ptr ()) -> (Ptr CChar) -> (Int) -> IO ((Int))
itemPathname' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  let {a3' = fromIntegral a3} in 
  itemPathname''_ a1' a2' a3' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (Parent a MenuItem, impl ~ (Ref a -> IO (Maybe String))) => Op (ItemPathname ()) MenuPrim orig impl where
  runOp _ _ menu_ menu_item' =
    withRef menu_ $
    \ menu_Ref ->
     allocaBytes oneKb $ \ptr -> do
       retVal' <- withRef menu_item' $ \ menu_item'Ref -> itemPathnameWithFinditem' menu_Ref (castPtr ptr) oneKb menu_item'Ref
       if (retVal' == 1)
         then return Nothing
         else do
           b' <- C.packCString (castPtr ptr)
           return $ Just (C.unpack b')
instance (impl ~ (IO (Maybe String))) => Op (ItemPathnameRecent ()) MenuPrim orig impl where
  runOp _ _ menu_ =
    withRef menu_ $ \menu_Ptr ->
    allocaBytes oneKb $ \pathPtr -> do
      retVal' <- itemPathname' menu_Ptr (castPtr pathPtr) oneKb
      if (retVal' == 1)
        then return Nothing
        else do
          b' <- C.packCString (castPtr pathPtr)
          return $ Just (C.unpack b')
picked' :: (Ptr ()) -> (Ptr ()) -> IO ((Ptr ()))
picked' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  picked''_ a1' a2' >>= \res ->
  let {res' = id res} in
  return (res')
instance (Parent a MenuItem, Parent b MenuItem, impl ~ (Ref a -> IO (Maybe (Ref b)))) => Op (Picked ()) MenuPrim orig impl where
  runOp _ _ menu_ item = withRef menu_ $ \menu_Ptr -> withRef item $ \itemPtr -> picked' menu_Ptr itemPtr >>= toMaybeRef
findIndexWithName' :: (Ptr ()) -> (String) -> IO ((Int))
findIndexWithName' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = unsafeToCString a2} in 
  findIndexWithName''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
findIndexWithItem' :: (Ptr ()) -> (Ptr ()) -> IO ((Int))
findIndexWithItem' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  findIndexWithItem''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ (MenuItemLocator -> IO (Maybe Int))) => Op (FindIndex ()) MenuPrim orig impl where
  runOp _ _ menu_ menu_item_referene =
    withRef menu_ $ \menu_Ptr ->
        case menu_item_referene of
          MenuItemNameLocator (MenuItemName name) -> findIndexWithName' menu_Ptr name >>= \r -> if (r == 1) then (return Nothing) else (return $ Just r)
          MenuItemPointerLocator (MenuItemPointer menu_item) ->
              withRef menu_item $ \menu_itemPtr -> findIndexWithItem' menu_Ptr menu_itemPtr >>= \r -> if (r == 1) then (return Nothing) else (return $ Just r)
testShortcut' :: (Ptr ()) -> IO ((Ptr ()))
testShortcut' a1 =
  let {a1' = id a1} in 
  testShortcut''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')
instance (Parent a MenuItem, impl ~ ( IO (Maybe (Ref a)))) => Op (TestShortcut ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> testShortcut' menu_Ptr >>= toMaybeRef
global' :: (Ptr ()) -> IO ()
global' a1 =
  let {a1' = id a1} in 
  global''_ a1' >>
  return ()
instance (impl ~ ( IO ())) => Op (Global ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> global' menu_Ptr
getMenuItemByIndex' :: (Ptr ()) -> (CInt) -> IO ((Ptr ()))
getMenuItemByIndex' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  getMenuItemByIndex''_ a1' a2' >>= \res ->
  let {res' = id res} in
  return (res')
instance (impl ~ ( IO [(Maybe (Ref MenuItem))])) => Op (GetMenu ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> do
    n <- getSize menu_
    if (n == 0)
     then return []
     else go menu_Ptr 0 (n1) []
      where
        go _ _ 0 accum = return accum
        go ptr offset left accum = do
          ref <- getMenuItemByIndex' ptr offset >>= toMaybeRef
          go ptr
             (offset + 1)
             (left  1)
             (accum ++ [ref])
menuWithM' :: (Ptr ()) -> (Ptr (Ptr ())) -> (Int) -> IO ()
menuWithM' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  let {a3' = fromIntegral a3} in 
  menuWithM''_ a1' a2' a3' >>
  return ()
instance (Parent a MenuItem, impl ~ ([Ref a] -> IO ())) => Op (SetMenu ()) MenuPrim orig impl where
  runOp _ _ menu_ items =
    withRef menu_ $ \menu_Ptr ->
        withRefs items $ \menu_itemsPtr ->
            menuWithM' menu_Ptr menu_itemsPtr (length items)
copy' :: (Ptr ()) -> (Ptr ()) -> IO ()
copy' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  copy''_ a1' a2' >>
  return ()
instance (Parent a MenuItem, impl ~ (Ref a->  IO ())) => Op (Copy ()) MenuPrim orig impl where
  runOp _ _ menu_ m = withRef menu_ $ \menu_Ptr -> withRef m $ \mPtr -> copy' menu_Ptr mPtr
insertWithFlags' :: (Ptr ()) -> (Int) -> (String) -> (CInt) -> (FunPtr CallbackWithUserDataPrim) -> (Int) -> IO ((Int))
insertWithFlags' a1 a2 a3 a4 a5 a6 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = unsafeToCString a3} in 
  let {a4' = id a4} in 
  let {a5' = id a5} in 
  let {a6' = fromIntegral a6} in 
  insertWithFlags''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
insertWithShortcutnameFlags' :: (Ptr ()) -> (Int) -> (String) -> (String) -> (FunPtr CallbackWithUserDataPrim) -> (Int) -> IO ((Int))
insertWithShortcutnameFlags' a1 a2 a3 a4 a5 a6 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = unsafeToCString a3} in 
  let {a4' = unsafeToCString a4} in 
  let {a5' = id a5} in 
  let {a6' = fromIntegral a6} in 
  insertWithShortcutnameFlags''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (Parent a MenuPrim, impl ~ ( Int -> String -> Maybe Shortcut -> (Ref a -> IO ()) -> MenuItemFlags -> IO (MenuItemIndex))) => Op (Insert ()) MenuPrim orig impl where
  runOp _ _ menu_ index' name shortcut cb flags =
    withRef menu_ $ \menu_Ptr -> do
      let combinedFlags = menuItemFlagsToInt flags
      ptr <- toCallbackPrim cb
      idx' <- case shortcut of
               Just s' -> case s' of
                 KeySequence (ShortcutKeySequence modifiers char) ->
                   insertWithFlags'
                    menu_Ptr
                    index'
                    name
                    (keySequenceToCInt modifiers char)
                    (castFunPtr ptr)
                    combinedFlags
                 KeyFormat format' ->
                   if (not $ null format') then
                     insertWithShortcutnameFlags'
                       menu_Ptr
                       index'
                       name
                       format'
                       (castFunPtr ptr)
                       combinedFlags
                   else error "Fl_Menu_.menu_insert: shortcut format string cannot be empty"
               Nothing ->
                 insertWithFlags'
                   menu_Ptr
                   index'
                   name
                   0
                   (castFunPtr ptr)
                   combinedFlags
      return (MenuItemIndex idx')
add' :: (Ptr ()) -> (String) -> IO ()
add' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = unsafeToCString a2} in 
  add''_ a1' a2' >>
  return ()
instance (impl ~ (String -> IO ())) => Op (AddName ()) MenuPrim orig impl where
  runOp _ _ menu_ name' = withRef menu_ $ \menu_Ptr -> add' menu_Ptr name'
addWithFlags' :: (Ptr ()) -> (String) -> (CInt) -> (FunPtr CallbackWithUserDataPrim) -> (Int) -> IO ((Int))
addWithFlags' a1 a2 a3 a4 a5 =
  let {a1' = id a1} in 
  let {a2' = unsafeToCString a2} in 
  let {a3' = id a3} in 
  let {a4' = id a4} in 
  let {a5' = fromIntegral a5} in 
  addWithFlags''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
addWithShortcutnameFlags' :: (Ptr ()) -> (String) -> (String) -> (FunPtr CallbackWithUserDataPrim) -> (Int) -> IO ((Int))
addWithShortcutnameFlags' a1 a2 a3 a4 a5 =
  let {a1' = id a1} in 
  let {a2' = unsafeToCString a2} in 
  let {a3' = unsafeToCString a3} in 
  let {a4' = id a4} in 
  let {a5' = fromIntegral a5} in 
  addWithShortcutnameFlags''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (Parent a MenuItem, impl ~ ( String -> Maybe Shortcut -> Maybe (Ref a-> IO ()) -> MenuItemFlags -> IO (MenuItemIndex))) => Op (Add ()) MenuPrim orig (impl) where
  runOp _ _ menu_ name shortcut cb flags =
    withRef menu_ $ \menu_Ptr -> do
      let combinedFlags = menuItemFlagsToInt flags
      ptr <- maybe (return (castPtrToFunPtr nullPtr)) toCallbackPrim cb
      idx' <- case shortcut of
               Just s' -> case s' of
                 KeySequence (ShortcutKeySequence modifiers char) ->
                   addWithFlags'
                    menu_Ptr
                    name
                    (keySequenceToCInt modifiers char)
                    (castFunPtr ptr)
                    combinedFlags
                 KeyFormat format' ->
                   if (not $ null format') then
                     addWithShortcutnameFlags'
                     menu_Ptr
                     name
                     format'
                     (castFunPtr ptr)
                     combinedFlags
                   else error "Fl_Menu_.menu_add: Shortcut format string cannot be empty"
               Nothing ->
                   addWithFlags'
                    menu_Ptr
                    name
                    0
                    (castFunPtr ptr)
                    combinedFlags
      return (MenuItemIndex idx')
size' :: (Ptr ()) -> IO ((Int))
size' a1 =
  let {a1' = id a1} in 
  size''_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ ( IO (Int))) => Op (GetSize ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> size' menu_Ptr
setSize' :: (Ptr ()) -> (Int) -> (Int) -> IO ()
setSize' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  setSize''_ a1' a2' a3' >>
  return ()
instance (impl ~ (Int -> Int ->  IO ())) => Op (SetSize ()) MenuPrim orig impl where
  runOp _ _ menu_ w h = withRef menu_ $ \menu_Ptr -> setSize' menu_Ptr w h
clear' :: (Ptr ()) -> IO ()
clear' a1 =
  let {a1' = id a1} in 
  clear''_ a1' >>
  return ()
instance (impl ~ ( IO ())) => Op (Clear ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> clear' menu_Ptr
clearSubmenu' :: (Ptr ()) -> (Int) -> IO ((Int))
clearSubmenu' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  clearSubmenu''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ (Int ->  IO (Either OutOfRange ()))) => Op (ClearSubmenu ()) MenuPrim orig impl where
  runOp _ _ menu_ index' = withRef menu_ $ \menu_Ptr -> clearSubmenu' menu_Ptr index' >>= \ret' -> if ret' == 1 then return (Left OutOfRange) else return (Right ())
replace' :: (Ptr ()) -> (Int) -> (String) -> IO ()
replace' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = unsafeToCString a3} in 
  replace''_ a1' a2' a3' >>
  return ()
instance (impl ~ (Int -> String ->  IO ())) => Op (Replace ()) MenuPrim orig impl where
  runOp _ _ menu_ index' name = withRef menu_ $ \menu_Ptr -> replace' menu_Ptr index' name
remove' :: (Ptr ()) -> (Int) -> IO ()
remove' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  remove''_ a1' a2' >>
  return ()
instance (impl ~ (Int  ->  IO ())) => Op (Remove ()) MenuPrim orig impl where
  runOp _ _ menu_ index' = withRef menu_ $ \menu_Ptr -> remove' menu_Ptr index'
shortcut' :: (Ptr ()) -> (Int) -> (CInt) -> IO ()
shortcut' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = id a3} in 
  shortcut''_ a1' a2' a3' >>
  return ()
instance (impl ~ (Int -> ShortcutKeySequence ->  IO ())) => Op (SetShortcut ()) MenuPrim orig impl where
  runOp _ _ menu_ index' (ShortcutKeySequence modifiers char) =
    withRef menu_ $ \menu_Ptr ->
        shortcut' menu_Ptr index' (keySequenceToCInt modifiers char)
setMode' :: (Ptr ()) -> (Int) -> (Int) -> IO ()
setMode' a1 a2 a3 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  setMode''_ a1' a2' a3' >>
  return ()
instance (impl ~ (Int -> MenuItemFlags ->  IO ())) => Op (SetMode ()) MenuPrim orig impl where
  runOp _ _ menu_ i fl = withRef menu_ $ \menu_Ptr -> setMode' menu_Ptr i (menuItemFlagsToInt fl)
mode' :: (Ptr ()) -> (Int) -> IO ((Int))
mode' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  mode''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ (Int ->  IO (Int))) => Op (GetMode ()) MenuPrim orig impl where
  runOp _ _ menu_ i = withRef menu_ $ \menu_Ptr -> mode' menu_Ptr i
mvalue' :: (Ptr ()) -> IO ((Ptr ()))
mvalue' a1 =
  let {a1' = id a1} in 
  mvalue''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')
instance (impl ~ (IO (Maybe (Ref MenuItem)))) => Op (Mvalue ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> mvalue' menu_Ptr >>= toMaybeRef
value' :: (Ptr ()) -> IO ((Int))
value' a1 =
  let {a1' = id a1} in 
  value''_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ ( IO (MenuItemIndex))) => Op (GetValue ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> value' menu_Ptr >>= return . MenuItemIndex
valueWithItem' :: (Ptr ()) -> (Ptr ()) -> IO ((Int))
valueWithItem' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  valueWithItem''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
valueWithIndex' :: (Ptr ()) -> (Int) -> IO ((Int))
valueWithIndex' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  valueWithIndex''_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')
instance (impl ~ (MenuItemReference -> IO (Int))) => Op (SetValue ()) MenuPrim orig impl where
  runOp _ _ menu_ menu_item_reference =
    withRef menu_ $ \menu_Ptr ->
        case menu_item_reference of
          (MenuItemByIndex (MenuItemIndex index')) -> valueWithIndex' menu_Ptr index'
          (MenuItemByPointer (MenuItemPointer menu_item)) ->
              withRef menu_item $ \menu_itemPtr ->
                  valueWithItem' menu_Ptr menu_itemPtr
text' :: (Ptr ()) -> IO ((String))
text' a1 =
  let {a1' = id a1} in 
  text''_ a1' >>= \res ->
  let {res' = unsafeFromCString res} in
  return (res')
instance (impl ~ ( IO (String))) => Op (GetText ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> text' menu_Ptr
textWithIndex' :: (Ptr ()) -> (Int) -> IO ((String))
textWithIndex' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  textWithIndex''_ a1' a2' >>= \res ->
  let {res' = unsafeFromCString res} in
  return (res')
instance (impl ~ (Int ->  IO (String))) => Op (GetTextWithIndex ()) MenuPrim orig impl where
  runOp _ _ menu_ i = withRef menu_ $ \menu_Ptr -> textWithIndex' menu_Ptr i
textfont' :: (Ptr ()) -> IO ((Font))
textfont' a1 =
  let {a1' = id a1} in 
  textfont''_ a1' >>= \res ->
  let {res' = cToFont res} in
  return (res')
instance (impl ~ ( IO (Font))) => Op (GetTextfont ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> textfont' menu_Ptr
setTextfont' :: (Ptr ()) -> (Font) -> IO ()
setTextfont' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromFont a2} in 
  setTextfont''_ a1' a2' >>
  return ()
instance (impl ~ (Font ->  IO ())) => Op (SetTextfont ()) MenuPrim orig impl where
  runOp _ _ menu_ c = withRef menu_ $ \menu_Ptr -> setTextfont' menu_Ptr c
textsize' :: (Ptr ()) -> IO ((CInt))
textsize' a1 =
  let {a1' = id a1} in 
  textsize''_ a1' >>= \res ->
  let {res' = id res} in
  return (res')
instance (impl ~ ( IO (FontSize))) => Op (GetTextsize ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> textsize' menu_Ptr >>= return . FontSize
setTextsize' :: (Ptr ()) -> (CInt) -> IO ()
setTextsize' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = id a2} in 
  setTextsize''_ a1' a2' >>
  return ()
instance (impl ~ (FontSize ->  IO ())) => Op (SetTextsize ()) MenuPrim orig impl where
  runOp _ _ menu_ (FontSize c) = withRef menu_ $ \menu_Ptr -> setTextsize' menu_Ptr c
textcolor' :: (Ptr ()) -> IO ((Color))
textcolor' a1 =
  let {a1' = id a1} in 
  textcolor''_ a1' >>= \res ->
  let {res' = cToColor res} in
  return (res')
instance (impl ~ ( IO (Color))) => Op (GetTextcolor ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> textcolor' menu_Ptr
setTextcolor' :: (Ptr ()) -> (Color) -> IO ()
setTextcolor' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromColor a2} in 
  setTextcolor''_ a1' a2' >>
  return ()
instance (impl ~ (Color ->  IO ())) => Op (SetTextcolor ()) MenuPrim orig impl where
  runOp _ _ menu_ c = withRef menu_ $ \menu_Ptr -> setTextcolor' menu_Ptr c
downBox' :: (Ptr ()) -> IO ((Boxtype))
downBox' a1 =
  let {a1' = id a1} in 
  downBox''_ a1' >>= \res ->
  let {res' = cToEnum res} in
  return (res')
instance (impl ~ ( IO (Boxtype))) => Op (GetDownBox ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> downBox' menu_Ptr
setDownBox' :: (Ptr ()) -> (Boxtype) -> IO ()
setDownBox' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cFromEnum a2} in 
  setDownBox''_ a1' a2' >>
  return ()
instance (impl ~ (Boxtype ->  IO ())) => Op (SetDownBox ()) MenuPrim orig impl where
  runOp _ _ menu_ b = withRef menu_ $ \menu_Ptr -> setDownBox' menu_Ptr b
downColor' :: (Ptr ()) -> IO ((Color))
downColor' a1 =
  let {a1' = id a1} in 
  downColor''_ a1' >>= \res ->
  let {res' = cToColor res} in
  return (res')
instance (impl ~ ( IO (Color))) => Op (GetDownColor ()) MenuPrim orig impl where
  runOp _ _ menu_ = withRef menu_ $ \menu_Ptr -> downColor' menu_Ptr
setDownColor' :: (Ptr ()) -> (Int) -> IO ()
setDownColor' a1 a2 =
  let {a1' = id a1} in 
  let {a2' = fromIntegral a2} in 
  setDownColor''_ a1' a2' >>
  return ()
instance (impl ~ (Int ->  IO ())) => Op (SetDownColor ()) MenuPrim orig impl where
  runOp _ _ menu_ c = withRef menu_ $ \menu_Ptr -> setDownColor' menu_Ptr c
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__New"
  widgetNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__New_WithLabel"
  widgetNewWithLabel''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO (C2HSImp.Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_OverriddenMenu__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/MenuPrim.chs.h Fl_OverriddenMenu__New"
  overriddenWidgetNew''_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__Destroy"
  widgetDestroy''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__handle_super"
  handleSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__handle"
  menu_Handle''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__resize_super"
  resizeSuper''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__resize"
  resize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__hide_super"
  hideSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__hide"
  hide''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__show_super"
  showSuper''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__show"
  menu_Show''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__item_pathname_with_finditem"
  itemPathnameWithFinditem''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__item_pathname"
  itemPathname''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__picked"
  picked''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__find_index_with_name"
  findIndexWithName''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__find_index_with_item"
  findIndexWithItem''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__test_shortcut"
  testShortcut''_ :: ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__global"
  global''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__get_menu_item_by_index"
  getMenuItemByIndex''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__menu_with_m"
  menuWithM''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (C2HSImp.CInt -> (IO ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__copy"
  copy''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__insert_with_flags"
  insertWithFlags''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.FunPtr ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ())))) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__insert_with_shortcutname_flags"
  insertWithShortcutnameFlags''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.FunPtr ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ())))) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__add_with_name"
  add''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__add_with_flags"
  addWithFlags''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.FunPtr ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ())))) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__add_with_shortcutname_flags"
  addWithShortcutnameFlags''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.FunPtr ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO ())))) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__size"
  size''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_size"
  setSize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__clear"
  clear''_ :: ((C2HSImp.Ptr ()) -> (IO ()))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__clear_submenu"
  clearSubmenu''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__replace"
  replace''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__remove"
  remove''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__shortcut"
  shortcut''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_mode"
  setMode''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__mode"
  mode''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__mvalue"
  mvalue''_ :: ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__value"
  value''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__value_with_item"
  valueWithItem''_ :: ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__value_with_index"
  valueWithIndex''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__text"
  text''_ :: ((C2HSImp.Ptr ()) -> (IO (C2HSImp.Ptr C2HSImp.CChar)))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__text_with_index"
  textWithIndex''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr C2HSImp.CChar))))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__textfont"
  textfont''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_textfont"
  setTextfont''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__textsize"
  textsize''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_textsize"
  setTextsize''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__textcolor"
  textcolor''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_textcolor"
  setTextcolor''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__down_box"
  downBox''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_down_box"
  setDownBox''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CInt -> (IO ())))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__down_color"
  downColor''_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CUInt))
foreign import ccall safe "Graphics/UI/FLTK/LowLevel/MenuPrim.chs.h Fl_Menu__set_down_color"
  setDownColor''_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (IO ())))