{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Box.HBox
(
HBox
, mkHBox
) where
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Layout.LayoutWidget
type HBox = IPythonWidget 'HBoxType
mkHBox :: IO HBox
mkHBox :: IO HBox
mkHBox = do
UUID
wid <- IO UUID
U.random
IPythonWidget 'LayoutType
layout <- IO (IPythonWidget 'LayoutType)
mkLayout
let widgetState :: WidgetState 'HBoxType
widgetState = forall (w :: WidgetType).
Rec Attr (WidgetFields w) -> WidgetState w
WidgetState forall a b. (a -> b) -> a -> b
$ FieldType 'ViewName
-> FieldType 'ModelName
-> IPythonWidget 'LayoutType
-> Rec Attr BoxClass
defaultBoxWidget Text
"HBoxView" Text
"HBoxModel" IPythonWidget 'LayoutType
layout
IORef (WidgetState 'HBoxType)
stateIO <- forall a. a -> IO (IORef a)
newIORef WidgetState 'HBoxType
widgetState
let hBox :: HBox
hBox = forall (w :: WidgetType).
UUID -> IORef (WidgetState w) -> IPythonWidget w
IPythonWidget UUID
wid IORef (WidgetState 'HBoxType)
stateIO
forall a. IHaskellWidget a => a -> Value -> IO ()
widgetSendOpen HBox
hBox forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => a -> Value
toJSON WidgetState 'HBoxType
widgetState
forall (m :: * -> *) a. Monad m => a -> m a
return HBox
hBox
instance IHaskellWidget HBox where
getCommUUID :: HBox -> UUID
getCommUUID = forall (w :: WidgetType). IPythonWidget w -> UUID
uuid