From: <kr_...@us...> - 2004-05-29 23:00:56
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26069/gio/src/Graphics/UI/GIO Modified Files: Controls.hs Log Message: Complete support for splitters under Linux. The windows versions still isn't ready Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** Controls.hs 15 May 2004 06:47:45 -0000 1.44 --- Controls.hs 29 May 2004 23:00:09 -0000 1.45 *************** *** 112,126 **** -- * CompoundControl , CompoundControl, compoundControl ! -- * Notebook -- | A notebook control is analogous to the dividers in a real notebook. ! -- By using a notebook control, an application can define multiple pages for ! -- the same area of a window or dialog box. Each page is represented from -- 'NotebookPage' type and is created from 'notebookPageAt' or 'notebookPage' -- function. , Notebook, notebook, labelsPosition, selectedPage , NotebookPage, notebookPageAt, notebookPage ! ! -- * Splitter , Splitter, hSplitter, vSplitter ) where --- 112,126 ---- -- * CompoundControl , CompoundControl, compoundControl ! -- * Notebook -- | A notebook control is analogous to the dividers in a real notebook. ! -- By using a notebook control, an application can define multiple pages for ! -- the same area of a window or dialog box. Each page is represented from -- 'NotebookPage' type and is created from 'notebookPageAt' or 'notebookPage' -- function. , Notebook, notebook, labelsPosition, selectedPage , NotebookPage, notebookPageAt, notebookPage ! ! -- * Splitter , Splitter, hSplitter, vSplitter ) where *************** *** 144,148 **** | pos == 0 = v : xs | otherwise = x : insertAt (pos-1) v xs ! removeAt :: Int -> [a] -> [a] removeAt pos [] = [] --- 144,148 ---- | pos == 0 = v : xs | otherwise = x : insertAt (pos-1) v xs ! removeAt :: Int -> [a] -> [a] removeAt pos [] = [] *************** *** 436,440 **** return lb ! -- | Create a selection checklist control. A "checklist control" -- displays a list of items where each item in the list has a -- check box next to it. The checklist control is a similar to the --- 436,440 ---- return lb ! -- | Create a selection checklist control. A "checklist control" -- displays a list of items where each item in the list has a -- check box next to it. The checklist control is a similar to the *************** *** 659,663 **** set r props return r ! -- | Create a vertical slider control. vslider :: Container w => [Prop Slider] -> w -> IO Slider --- 659,663 ---- set r props return r ! -- | Create a vertical slider control. vslider :: Container w => [Prop Slider] -> w -> IO Slider *************** *** 679,683 **** instance Control Slider where pack = stdPack sparent shandle Port.getSliderRequestSize ! instance Valued Slider Int where value = selectedPos --- 679,683 ---- instance Control Slider where pack = stdPack sparent shandle Port.getSliderRequestSize ! instance Valued Slider Int where value = selectedPos *************** *** 789,800 **** , vbufferMode :: Var BufferMode , vpaint :: Var PaintFunction ! , vlayout :: Var Layout } -- | Create a compound control compoundControl :: Container w => [Prop CompoundControl] -> w -> IO CompoundControl ! compoundControl props w ! = do c <- do cchandle <- Port.createCompoundControl (hwindow w) ! vpaint <- newVar (\_ _ _ -> return ()) vautosize <- newVar True vlayout <- newVar empty --- 789,805 ---- , vbufferMode :: Var BufferMode , vpaint :: Var PaintFunction ! , vlayout :: Var Layout } -- | Create a compound control compoundControl :: Container w => [Prop CompoundControl] -> w -> IO CompoundControl ! compoundControl props w = do ! c <- Port.createCompoundControl (hwindow w) >>= compoundControlFromHandle (hwindow w) ! set c props ! return c ! ! compoundControlFromHandle :: WindowHandle -> WindowHandle -> IO CompoundControl ! compoundControlFromHandle hwnd hctrl ! = do c <- do vpaint <- newVar (\_ _ _ -> return ()) vautosize <- newVar True vlayout <- newVar empty *************** *** 802,811 **** vpen <- newVar windowPen vbufferMode<- newVar UnBuffered ! return (CompoundControl cchandle (hwindow w) vdomain vautosize vpen vbufferMode vpaint vlayout) recolorCompound c set c [on relayout =:: relayoutCompound] -- just by setting a dummy paint function, we will at least intialize the canvas properly on a repaint set c [on paint =: (\_ _ _ -> return ())] - set c props return c --- 807,815 ---- vpen <- newVar windowPen vbufferMode<- newVar UnBuffered ! return (CompoundControl hctrl hwnd vdomain vautosize vpen vbufferMode vpaint vlayout) recolorCompound c set c [on relayout =:: relayoutCompound] -- just by setting a dummy paint function, we will at least intialize the canvas properly on a repaint set c [on paint =: (\_ _ _ -> return ())] return c *************** *** 1071,1109 **** { 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 --- 1075,1104 ---- { splhandle :: !WindowHandle , splparent :: !WindowHandle } -- | Create a horizontal splitter control. ! hSplitter :: Container w => [Prop Splitter] -> w -> IO (Splitter, CompoundControl, CompoundControl) ! hSplitter props w = do ! (hsplitter, hpane1, hpane2) <- Port.createHorzSplitter (hwindow w) ! let spl = Splitter hsplitter (hwindow w) ! pane1 <- compoundControlFromHandle hsplitter hpane1 ! pane2 <- compoundControlFromHandle hsplitter hpane2 ! set spl props ! return (spl,pane1,pane2) ! -- | Create a horizontal splitter control. ! vSplitter :: Container w => [Prop Splitter] -> w -> IO (Splitter, CompoundControl, CompoundControl) ! vSplitter props w = do ! (hsplitter, hpane1, hpane2) <- Port.createVertSplitter (hwindow w) ! let spl = Splitter hsplitter (hwindow w) ! pane1 <- compoundControlFromHandle hsplitter hpane1 ! pane2 <- compoundControlFromHandle hsplitter hpane2 ! set spl props ! return (spl,pane1,pane2) instance Control Splitter where pack = stdPack splparent splhandle Port.getSplitterRequestSize ! instance RangedSelect Splitter where ! range = readAttr "range" (Port.getSplitterRange . splhandle) ! selectedPos = newStdAttr splhandle Port.getSplitterPosition Port.setSplitterPosition |