module tut12_1 // ******************************************************************************** // Clean tutorial example program. // // This program creates a dialogue to display and change the current content // of the clipboard. // ******************************************************************************** import StdEnv, StdIO Start :: *World -> *World Start world # (showId, world) = openId world # (setId, world) = openId world = startProcesses (Process NDI Void (initialise showId setId) []) world initialise showId setId pst # (error, pst) = openDialog Void clipView pst | error <> NoError = closeProcess pst | otherwise = pst where clipView = Dialog "Clipboard Editor" (showClip :+: setClip :+: quit) [] showClip = EditControl "" width nrlines [ControlId showId, ControlPos (Left, zero), ControlSelectState Unable] :+: ButtonControl "Show" [ControlFunction (noLS show)] setClip = EditControl "" width nrlines [ControlId setId, ControlPos (Left, zero)] :+: ButtonControl "Set" [ControlFunction (noLS set)] quit = ButtonControl "Quit" [ControlFunction (noLS closeProcess), ControlPos (Center, zero)] width = PixelWidth (hmm 50.0) nrlines = 4 show pst # (cont, pst) = getClipboard pst # text = getString cont = appPIO (setControlText showId text) pst set pst # (wst, pst) = accPIO (getParentWindow showId) pst # text = fromJust (snd (getControlText setId (fromJust wst))) = setClipboard [toClipboard text] pst getString :: [ClipboardItem] -> String getString [] = "" getString [clip:clips] # item = fromClipboard clip | isNothing item = getString clips | otherwise = fromJust item