|
From: <kr_...@us...> - 2003-09-01 20:27:55
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO
In directory sc8-pr-cvs1:/tmp/cvs-serv26139/gio/src/Graphics/UI/GIO
Modified Files:
Controls.hs
Log Message:
Added GroupBox control. /* Still only for Windows */
Index: Controls.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** Controls.hs 31 Aug 2003 13:22:32 -0000 1.31
--- Controls.hs 1 Sep 2003 20:27:50 -0000 1.32
***************
*** 83,86 ****
--- 83,93 ----
, RadioBox, radioBox, setRadioBoxGroup
+ -- ** GroupBox
+ -- | A group box is a rectangle that surrounds a set of controls, such as
+ -- check boxes or radio buttons, with application-defined label in its upper
+ -- left corner. The sole purpose of a group box is to organize controls related
+ -- by a common purpose (usually indicated by the label).
+ , GroupBox, groupBox
+
-- ** CompoundControl
, CompoundControl, compoundControl
***************
*** 592,596 ****
}
! -- | Create a window
compoundControl :: Container w => [Prop CompoundControl] -> w -> IO CompoundControl
compoundControl props w
--- 599,603 ----
}
! -- | Create a compound control
compoundControl :: Container w => [Prop CompoundControl] -> w -> IO CompoundControl
compoundControl props w
***************
*** 688,691 ****
--- 695,746 ----
instance Control CompoundControl where
pack w = stdPack (ccparent w) (Port.getCompoundControlRequestSize (cchandle w)) (Port.moveResizeControl (cchandle w))
+
+
+ --------------------------------------------------------------------
+ -- GroupBox
+ --------------------------------------------------------------------
+ -- | A group box.
+ data GroupBox = GroupBox
+ { gbhandle :: !WindowHandle
+ , gbparent :: !WindowHandle
+ , gblayout :: Var Layout
+ }
+
+ -- | Create a group box
+ groupBox :: Container w => [Prop GroupBox] -> w -> IO GroupBox
+ groupBox props w
+ = do c <- do gbhandle <- Port.createGroupBox (hwindow w)
+ gblayout <- newVar empty
+ return (GroupBox gbhandle (hwindow w) gblayout)
+ set c [on relayout =:: relayoutGroupBox]
+ set c props
+ return c
+
+ relayoutGroupBox :: GroupBox -> IO ()
+ relayoutGroupBox c
+ = do (Rect fl ft fr fb) <- Port.getControlFrame (gbhandle c)
+ lay <- getVar (gblayout c)
+ (l,t,r,b) <- Port.getGroupBoxBordersSize (gbhandle c)
+ layoutInRect (Rect l t (fr-r) (fb-b)) lay
+ return ()
+
+ 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)
+ relayout = newStdEvent gbhandle Port.getContainerReLayoutHandler Port.setContainerReLayoutHandler Port.setContainerReLayoutDefHandler
+ hwindow c = gbhandle c
+
+ instance Titled GroupBox where
+ title = newStdAttr gbhandle Port.getGroupBoxText Port.setGroupBoxText
+
+ 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))
+
|