From: <kr_...@us...> - 2003-10-10 14:21:56
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO In directory sc8-pr-cvs1:/tmp/cvs-serv31021/src/Graphics/UI/GIO Modified Files: Controls.hs Layout.hs Window.hs Log Message: support for dynamic layout Index: Controls.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Controls.hs 7 Oct 2003 20:22:18 -0000 1.33 --- Controls.hs 10 Oct 2003 14:21:52 -0000 1.34 *************** *** 161,166 **** instance Control Label where ! pack w ! = stdPack (lparent w) (Port.getLabelRequestSize (lhandle w)) (Port.moveResizeControl (lhandle w)) -------------------------------------------------------------------- --- 161,165 ---- instance Control Label where ! pack = stdPack lparent lhandle Port.getLabelRequestSize -------------------------------------------------------------------- *************** *** 198,203 **** instance Control Button where ! pack b ! = stdPack (bparent b) (Port.getButtonRequestSize (bhandle b)) (Port.moveResizeControl (bhandle b)) instance Commanding Button where --- 197,201 ---- instance Control Button where ! pack = stdPack bparent bhandle Port.getButtonRequestSize instance Commanding Button where *************** *** 238,243 **** instance Control Entry where ! pack w ! = stdPack (eparent w) (Port.getEditRequestSize (ehandle w)) (Port.moveResizeControl (ehandle w)) -- | Determines if the user can edit the text in the editable widget or not. --- 236,240 ---- instance Control Entry where ! pack = stdPack eparent ehandle Port.getEditRequestSize -- | Determines if the user can edit the text in the editable widget or not. *************** *** 321,325 **** instance Control Popup where ! pack p = stdPack (pparent p) (Port.getPopUpRequestSize (phandle p)) (Port.moveResizeControl (phandle p)) instance Commanding Popup where --- 318,322 ---- instance Control Popup where ! pack = stdPack pparent phandle Port.getPopUpRequestSize instance Commanding Popup where *************** *** 410,414 **** instance Control ListBox where ! pack lb = stdPack (lbparent lb) (Port.getListBoxRequestSize (lbhandle lb)) (Port.moveResizeControl (lbhandle lb)) instance Commanding ListBox where --- 407,411 ---- instance Control ListBox where ! pack = stdPack lbparent lbhandle Port.getListBoxRequestSize instance Commanding ListBox where *************** *** 451,455 **** instance Control CheckBox where ! pack w = stdPack (cparent w) (Port.getCheckBoxRequestSize (chandle w)) (Port.moveResizeControl (chandle w)) -------------------------------------------------------------------- --- 448,452 ---- instance Control CheckBox where ! pack = stdPack cparent chandle Port.getCheckBoxRequestSize -------------------------------------------------------------------- *************** *** 486,490 **** instance Control RadioBox where ! pack w = stdPack (rparent w) (Port.getRadioBoxRequestSize (rhandle w)) (Port.moveResizeControl (rhandle w)) --- 483,487 ---- instance Control RadioBox where ! pack = stdPack rparent rhandle Port.getRadioBoxRequestSize *************** *** 529,533 **** instance Control Slider where ! pack w = stdPack (sparent w) (Port.getSliderRequestSize (shandle w)) (Port.moveResizeControl (shandle w)) --- 526,530 ---- instance Control Slider where ! pack = stdPack sparent shandle Port.getSliderRequestSize *************** *** 581,585 **** instance Control ProgressBar where ! pack w = stdPack (pbparent w) (Port.getProgressBarRequestSize (pbhandle w)) (Port.moveResizeControl (pbhandle w)) --- 578,582 ---- instance Control ProgressBar where ! pack = stdPack pbparent pbhandle Port.getProgressBarRequestSize *************** *** 680,691 **** layout = writeAttr "layout" (\w c -> do ! let lay = pack c domain <- get w domain ! needed <- getLayoutSize lay let d = maxSize domain needed Port.setWindowDomainSize (cchandle w) d frame <- Port.getControlFrame (cchandle w) ! layoutInRect (rectOfSize (maxSize d (rectSize frame))) lay ! setVar (vlayout w) lay) autosize = readAttr "autosize" (\c -> return False) layoutSize = readAttr "layoutSize" (\c -> getVar (vlayout c) >>= getLayoutSize) --- 677,690 ---- layout = writeAttr "layout" (\w c -> do ! let new_lay = pack c ! old_lay <- getVar (vlayout w) domain <- get w domain ! needed <- getLayoutSize new_lay let d = maxSize domain needed Port.setWindowDomainSize (cchandle w) d frame <- Port.getControlFrame (cchandle w) ! updateControlsVisibility old_lay new_lay ! layoutInRect (rectOfSize (maxSize d (rectSize frame))) new_lay ! setVar (vlayout w) new_lay) autosize = readAttr "autosize" (\c -> return False) layoutSize = readAttr "layoutSize" (\c -> getVar (vlayout c) >>= getLayoutSize) *************** *** 694,698 **** instance Control CompoundControl where ! pack w = stdPack (ccparent w) (Port.getCompoundControlRequestSize (cchandle w)) (Port.moveResizeControl (cchandle w)) --- 693,697 ---- instance Control CompoundControl where ! pack = stdPack ccparent cchandle Port.getCompoundControlRequestSize *************** *** 726,730 **** instance Container GroupBox where ! layout = writeAttr "layout" (\w c -> setVar (gblayout w) (pack c)) autosize = readAttr "autosize" (\c -> return True) layoutSize = readAttr "layoutSize" (\c -> getVar (gblayout c) >>= getLayoutSize) --- 725,733 ---- instance Container GroupBox where ! layout = writeAttr "layout" (\w c -> do ! let new_lay = pack c ! old_lay <- getVar (gblayout w) ! updateControlsVisibility old_lay new_lay ! setVar (gblayout w) new_lay) autosize = readAttr "autosize" (\c -> return True) layoutSize = readAttr "layoutSize" (\c -> getVar (gblayout c) >>= getLayoutSize) *************** *** 736,743 **** instance Control GroupBox where ! pack c = stdPack (gbparent c) getGroupBoxRequestSize (Port.moveResizeControl (gbhandle c)) where ! getGroupBoxRequestSize = do ! (l,t,r,b) <- Port.getGroupBoxBordersSize (gbhandle c) Size w h <- getVar (gblayout c) >>= getLayoutSize return (Size (l+w+r) (t+h+b)) --- 739,746 ---- instance Control GroupBox where ! pack c = stdPack gbparent gbhandle getGroupBoxRequestSize c where ! getGroupBoxRequestSize hwnd = do ! (l,t,r,b) <- Port.getGroupBoxBordersSize hwnd Size w h <- getVar (gblayout c) >>= getLayoutSize return (Size (l+w+r) (t+h+b)) *************** *** 765,772 **** instance Control Notebook where ! pack w = stdPack (nbparent w) getNotebookRequestSize (Port.moveResizeControl (nbhandle w)) where ! getNotebookRequestSize = do ! outSize <- Port.getNotebookRequestSize (nbhandle w) pages <- getVar (nbpages w) pageSizes <- mapM (\page -> get page layoutSize) pages --- 768,775 ---- instance Control Notebook where ! pack w = stdPack nbparent nbhandle getNotebookRequestSize w where ! getNotebookRequestSize hwnd = do ! outSize <- Port.getNotebookRequestSize hwnd pages <- getVar (nbpages w) pageSizes <- mapM (\page -> get page layoutSize) pages *************** *** 826,830 **** instance Container NotebookPage where ! layout = writeAttr "layout" (\w c -> setVar (pglayout w) (pack c)) autosize = readAttr "autosize" (\c -> return True) layoutSize = readAttr "layoutSize" (\c -> getVar (pglayout c) >>= getLayoutSize) --- 829,837 ---- instance Container NotebookPage where ! layout = writeAttr "layout" (\w c -> do ! let new_lay = pack c ! old_lay <- getVar (pglayout w) ! updateControlsVisibility old_lay new_lay ! setVar (pglayout w) new_lay) autosize = readAttr "autosize" (\c -> return True) layoutSize = readAttr "layoutSize" (\c -> getVar (pglayout c) >>= getLayoutSize) Index: Layout.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Layout.hs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Layout.hs 20 Aug 2003 21:37:26 -0000 1.7 --- Layout.hs 10 Oct 2003 14:21:52 -0000 1.8 *************** *** 119,128 **** -- ** Functions , stdPack - , stdPackChangingLayout , getLayoutSize , layoutInRect ) where ! import Data.List( transpose, intersperse ) import qualified Graphics.UI.Port as Port import Graphics.UI.GIO.Types --- 119,128 ---- -- ** Functions , stdPack , getLayoutSize , layoutInRect + , updateControlsVisibility ) where ! import Data.List( transpose, intersperse, (\\) ) import qualified Graphics.UI.Port as Port import Graphics.UI.GIO.Types *************** *** 208,224 **** -- | Internal: creates a standard 'pack' function from a parent handle, ! -- a function that returns the preferred size and a function that repositions the control. ! stdPack :: WindowHandle -> IO Size -> (Rect -> IO ()) -> Layout ! stdPack parent getPrefferedSize moveResize ! = Control parent getPrefferedSize moveResize ! ! -- | Internal: creates a standard 'pack' function from a parent handle, ! -- and a changing layout. This function is only used when the layout can ! -- change, like a radio group that is layout horizontally or vertically. ! stdPackChangingLayout :: WindowHandle -> IO Layout -> Layout ! stdPackChangingLayout parent io ! = Control parent (do layout <- io; getLayoutSize layout) ! (\r -> do layout <- io; layoutInRect r layout; return ()) ! {-------------------------------------------------------------------- --- 208,215 ---- -- | Internal: creates a standard 'pack' function from a parent handle, ! -- control handle and a function that returns the preferred size. ! stdPack :: (w -> WindowHandle) -> (w -> WindowHandle) -> (WindowHandle -> IO Size) -> w -> Layout ! stdPack getParent getControl getPrefferedSize w ! = Control (getParent w) (getControl w) getPrefferedSize {-------------------------------------------------------------------- *************** *** 229,233 **** data Layout = Grid [[Layout]] | Changer (Pack -> Pack) Layout ! | Control WindowHandle (IO Size) (Rect -> IO ()) -- parent, get request size, set new position/size {-------------------------------------------------------------------- --- 220,224 ---- data Layout = Grid [[Layout]] | Changer (Pack -> Pack) Layout ! | Control WindowHandle WindowHandle (WindowHandle -> IO Size) -- parent handle, control handle, get request size {-------------------------------------------------------------------- *************** *** 238,242 **** -- need to mimic a control instead of "Grid [[]]" or otherwise the calculation of -- the initial dialog size fails to take outer padding into account. ! empty = Control nullHandle (return (Size 0 0)) (\r -> return ()) -- Grid [[]] -- | Primitive: Create a grid of controls, gives precise control over alignment. (See also 'tabular'). --- 229,233 ---- -- need to mimic a control instead of "Grid [[]]" or otherwise the calculation of -- the initial dialog size fails to take outer padding into account. ! empty = Control nullHandle nullHandle (\h -> return (Size 0 0)) -- Grid [[]] -- | Primitive: Create a grid of controls, gives precise control over alignment. (See also 'tabular'). *************** *** 420,425 **** parent = head parents ! moveResize rect (Control hwnd get setRect) ! = setRect rect --- 411,427 ---- parent = head parents ! moveResize rect (Control hparent hcontrol get) ! = if hcontrol /= nullHandle then Port.moveResizeControl hcontrol rect else return () ! ! ! updateControlsVisibility :: Layout -> Layout -> IO () ! updateControlsVisibility old_lay new_lay = do ! mapM_ (\c -> Port.setControlVisible c False) (old_controls \\ new_controls) ! mapM_ (\c -> Port.setControlVisible c True ) (new_controls \\ old_controls) ! where ! old_controls = foldr collectHandles [] (extractControls old_lay) ! new_controls = foldr collectHandles [] (extractControls new_lay) ! ! collectHandles (Control _ h _) hs = if h /= nullHandle then h:hs else hs *************** *** 429,434 **** Grid lss -> concat (map (concat . map extractControls) lss) Changer f l -> extractControls l ! Control _ _ _ -> [lay] ! --- 431,435 ---- Grid lss -> concat (map (concat . map extractControls) lss) Changer f l -> extractControls l ! Control _ h _ -> [lay] *************** *** 457,462 **** Grid lss -> do lss' <- mapM (mapM layoutToPack) lss return (table lss') ! Control parent getPrefSize moveResize ! -> do (Size w h) <- getPrefSize return (Item False False w h (\pos sz -> pos)) Changer f lay -> do p <- layoutToPack lay --- 458,463 ---- Grid lss -> do lss' <- mapM (mapM layoutToPack) lss return (table lss') ! Control hparent hcontrol getPrefSize ! -> do (Size w h) <- getPrefSize hcontrol return (Item False False w h (\pos sz -> pos)) Changer f lay -> do p <- layoutToPack lay Index: Window.hs =================================================================== RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Window.hs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Window.hs 7 Oct 2003 21:39:31 -0000 1.28 --- Window.hs 10 Oct 2003 14:21:52 -0000 1.29 *************** *** 185,198 **** layout = writeAttr "layout" (\w c -> do ! let lay = pack c autosize <- get w autosize domain <- get w domain ! needed <- getLayoutSize lay let d = maxSize domain needed Lib.setWindowDomainSize (hwindow w) d when autosize (set w [view =: d]) view <- get w view ! layoutInRect (rectOfSize (maxSize d view)) lay ! setVar (vlayout w) lay) autosize = varAttr vautosize layoutSize = readAttr "layoutSize" (\w -> getVar (vlayout w) >>= getLayoutSize) --- 185,200 ---- layout = writeAttr "layout" (\w c -> do ! let new_lay = pack c ! old_lay <- getVar (vlayout w) autosize <- get w autosize domain <- get w domain ! needed <- getLayoutSize new_lay let d = maxSize domain needed Lib.setWindowDomainSize (hwindow w) d when autosize (set w [view =: d]) view <- get w view ! updateControlsVisibility old_lay new_lay ! layoutInRect (rectOfSize (maxSize d view)) new_lay ! setVar (vlayout w) new_lay) autosize = varAttr vautosize layoutSize = readAttr "layoutSize" (\w -> getVar (vlayout w) >>= getLayoutSize) |