open import Data.Bool
module GUI.GUIExample where
open import StateSizedIO.GUI.BaseStateDependent
open import StateSizedIO.writingOOsUsingIOVers4ReaderMethods hiding (nˢ) renaming(execˢⁱ to execᵢ ; returnˢⁱ to returnᵢ)
open import GUI.GUIDefinitions
open import GUI.GUIDefinitionsBase
open import SizedIO.Base hiding (_>>_)
open import SizedIO.Console
open import Data.String
open import GUI.GUIExampleLib
open import Data.Fin
open import Size
open import Data.Unit
open import Data.Product
oneBtnFrame : Frame
oneBtnFrame = addButton "OK" emptyFrame
twoBtnFrame : Frame
twoBtnFrame = addButton "Cancel" oneBtnFrame
putStrLine' : {A : Set} → String → (f : IO consoleI ∞ A) →
IO consoleI ∞ A
putStrLine' s f = exec (putStrLn s) (λ _ → f)
syntax putStrLine' s f = putStrLine s >> f
mutual
obj2Btn : ∀ {i} → FrameObj {i} twoBtnFrame
obj2Btn .method (zero , _ ) = putStrLine "OK! Redefining GUI." >>
return (oneBtnFrame , obj1Btn)
obj2Btn .method (suc zero , _) = putStrLine "Cancel." >>
return (twoBtnFrame , obj2Btn)
obj2Btn .method (suc (suc ()) , _)
obj1Btn : ∀ {i} → FrameObj {i} oneBtnFrame
obj1Btn .method (zero , _ ) = putStrLine "OK! Redefining GUI." >>
return (twoBtnFrame , obj2Btn)
obj1Btn .method (suc () , _)
mutual
oneBtnGUI : ∀ {i} → GUI {i}
oneBtnGUI .gui = addButton "OK" emptyFrame
oneBtnGUI .obj .method (zero , _ ) = putStrLine "OK! Redefining GUI." >>
returnGUI twoBtnGUI
oneBtnGUI .obj .method (suc () , _ )
twoBtnGUI : ∀ {i} → GUI {i}
twoBtnGUI .gui = addButton "Cancel" (addButton "OK" emptyFrame)
twoBtnGUI .obj .method (zero , _ ) = putStrLine "OK! Redefining GUI." >>
returnGUI oneBtnGUI
twoBtnGUI .obj .method (suc zero , _) = putStrLine "Cancel." >>
returnGUI twoBtnGUI
twoBtnGUI .obj .method (suc (suc ()) , _)