From: <kr_...@us...> - 2004-05-15 06:47:58
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9734/src/Graphics/UI/GIO Modified Files: Controls.hs Layout.hs Log Message: Initial support for Splitter Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Controls.hs 25 Nov 2003 15:57:48 -0000 1.43 --- Controls.hs 15 May 2004 06:47:45 -0000 1.44 *************** *** 121,124 **** --- 121,127 ---- , Notebook, notebook, labelsPosition, selectedPage , NotebookPage, notebookPageAt, notebookPage + + -- * Splitter + , Splitter, hSplitter, vSplitter ) where *************** *** 1060,1061 **** --- 1063,1109 ---- instance HasIcon NotebookPage where icon = newStdAttr pghandle Port.getNotebookPageBitmap Port.setNotebookPageBitmap + + -------------------------------------------------------------------- + -- Splitter + -------------------------------------------------------------------- + -- | A Splitter control. + data Splitter = Splitter + { splhandle :: !WindowHandle + , splparent :: !WindowHandle + , spllayout :: !(Var Layout) + } + + -- | Create a horizontal splitter control. + hSplitter :: Container w => [Prop Splitter] -> w -> IO Splitter + hSplitter props w + = do spl <- do hsplitter <- Port.createHorzSplitter (hwindow w) + layoutRef <- newVar empty + return (Splitter hsplitter (hwindow w) layoutRef) + set spl props + return spl + + -- | Create a horizontal splitter control. + vSplitter :: Container w => [Prop Splitter] -> w -> IO Splitter + vSplitter props w + = do spl <- do hsplitter <- Port.createVertSplitter (hwindow w) + layoutRef <- newVar empty + return (Splitter hsplitter (hwindow w) layoutRef) + set spl props + return spl + + instance Control Splitter where + pack = stdPack splparent splhandle Port.getSplitterRequestSize + + instance Container Splitter where + layout = writeAttr "layout" (\w c -> do + let new_lay = pack c + old_lay <- getVar (spllayout w) + updateControlsVisibility old_lay new_lay + case extractControls new_lay of + [(_,hc1),(_,hc2)] -> Port.setSplitterChildren (splhandle w) hc1 hc2 + _ -> ioError (userError "The layout of the splitter can include only two controls") + setVar (spllayout w) new_lay) + autosize = readAttr "autosize" (\w -> return True) + layoutSize = readAttr "layoutSize" (\w -> getVar (spllayout w) >>= getLayoutSize) + relayout = newStdEvent splhandle Port.getContainerReLayoutHandler Port.setContainerReLayoutHandler Port.setContainerReLayoutDefHandler + hwindow = splhandle Index: Layout.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Layout.hs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Layout.hs 19 Oct 2003 10:06:31 -0000 1.10 --- Layout.hs 15 May 2004 06:47:45 -0000 1.11 *************** *** 123,126 **** --- 123,127 ---- , layoutInRect , updateControlsVisibility + , extractControls ) where *************** *** 433,437 **** (Size w h) = rectSize r ! parents = [hwnd | (Control hwnd _ _) <- extractControls layout] parent = head parents --- 434,438 ---- (Size w h) = rectSize r ! parents = map fst (extractControls layout) parent = head parents *************** *** 447,461 **** mapM_ (\c -> Port.setControlVisible c True ) (new_controls \\ old_controls) where ! old_controls = [hwnd | (Control _ hwnd _) <- extractControls old_lay] ! new_controls = [hwnd | (Control _ hwnd _) <- extractControls new_lay] ! ! extractControls :: Layout -> [Layout] extractControls lay = case lay of ! Grid lss -> concat (map (concat . map extractControls) lss) ! Changer f l -> extractControls l ! Empty -> [] ! Control _ h _ -> [lay] --- 448,465 ---- mapM_ (\c -> Port.setControlVisible c True ) (new_controls \\ old_controls) where ! old_controls = map snd (extractControls old_lay) ! new_controls = map snd (extractControls new_lay) ! -- | The 'extractControls' function extracts the list of all controls ! -- which are included in the given 'Layout'. Each control is reperesented ! -- with a tuple of two handles. The first handle is the handle of its parent ! -- and the second is the handle of the control itself. ! extractControls :: Layout -> [(WindowHandle,WindowHandle)] extractControls lay = case lay of ! Grid lss -> concat (map (concat . map extractControls) lss) ! Changer f l -> extractControls l ! Empty -> [] ! Control hp hc _ -> [(hp,hc)] |