|
From: <kr_...@us...> - 2003-08-31 12:56:29
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO
In directory sc8-pr-cvs1:/tmp/cvs-serv3025/gio/src/Graphics/UI/GIO
Modified Files:
Attributes.hs Controls.hs Menu.hs ToolBar.hs
Log Message:
Implementation for Countable type class
Index: Attributes.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Attributes.hs,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Attributes.hs 23 Aug 2003 00:04:47 -0000 1.17
--- Attributes.hs 31 Aug 2003 12:56:25 -0000 1.18
***************
*** 83,86 ****
--- 83,87 ----
-- ** Selection
, Checked, checked
+ , Countable, count
, CommandItems, items, appendItem, insertItem, removeItem, removeAllItems
, SingleSelect, selected
***************
*** 304,309 ****
checked :: Attr w Bool
-- | Widgets that have selectable items, like popup controls.
! class CommandItems w where
items :: Attr w [(String,IO ())]
appendItem :: w -> (String,IO ()) -> IO ()
--- 305,316 ----
checked :: Attr w Bool
+ -- | Countable widgets are these which contains countable finite set
+ -- of child widgets or items.
+ class Countable w where
+ count :: Attr w Int -- ^ The attribute is read-only and returns the
+ -- count of items in the widget.
+
-- | Widgets that have selectable items, like popup controls.
! class Countable w => CommandItems w where
items :: Attr w [(String,IO ())]
appendItem :: w -> (String,IO ()) -> IO ()
***************
*** 311,321 ****
removeItem :: w -> Int -> IO ()
removeAllItems :: w -> IO ()
!
! -- | Widgets that have a single selection (like radio control groups).
! class SingleSelect w where
selected :: Attr w Int
! -- | Widgets with a multiple selection (like check box groups).
! class MultiSelect w where
selection :: Attr w [Int]
--- 318,328 ----
removeItem :: w -> Int -> IO ()
removeAllItems :: w -> IO ()
!
! -- | Widgets that have a single selection (like popup control).
! class Countable w => SingleSelect w where
selected :: Attr w Int
! -- | Widgets with a multiple selection (like multi selection list box).
! class Countable w => MultiSelect w where
selection :: Attr w [Int]
Index: Controls.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Controls.hs,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** Controls.hs 30 Aug 2003 22:57:46 -0000 1.29
--- Controls.hs 31 Aug 2003 12:56:25 -0000 1.30
***************
*** 270,273 ****
--- 270,275 ----
when (i>=0 && i < length xs) (snd (xs!!i)) -- invoke appropiate handler
+ instance Countable Popup where
+ count = readAttr "count" (fmap length . getVar . pitems)
instance CommandItems Popup where
***************
*** 346,349 ****
--- 348,354 ----
when (i>=0 && i < length xs) (snd (xs!!i)) -- invoke appropiate handler
+ instance Countable ListBox where
+ count = readAttr "count" (fmap length . getVar . lbitems)
+
instance CommandItems ListBox where
items
***************
*** 716,719 ****
--- 721,727 ----
labelsPosition :: Attr Notebook PositionType
labelsPosition = newStdAttr nbhandle Port.getNotebookLabelsPosition Port.setNotebookLabelsPosition
+
+ instance Countable Notebook where
+ count = readAttr "count" (Port.getNotebookPageCount . nbhandle)
instance SingleSelect Notebook where
Index: Menu.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Menu.hs 23 Aug 2003 00:04:47 -0000 1.14
--- Menu.hs 31 Aug 2003 12:56:25 -0000 1.15
***************
*** 17,21 ****
module Graphics.UI.GIO.Menu
( -- * Menus
! Menu, mainMenu, menuAt, menu, itemCount
, popupMenu, trackPopupMenu
-- * Menu items
--- 17,21 ----
module Graphics.UI.GIO.Menu
( -- * Menus
! Menu, mainMenu, menuAt, menu
, popupMenu, trackPopupMenu
-- * Menu items
***************
*** 98,105 ****
title = newStdAttr hmenu Lib.getMenuLabel Lib.setMenuLabel
! -- | The 'itemCount' attribute is readonly and returns the number of items in the
! -- popup or sub menu.
! itemCount :: Attr Menu Int
! itemCount = readAttr "itemsCount" (Lib.getMenuItemCount . hmenu)
instance Positioned Menu where
--- 98,103 ----
title = newStdAttr hmenu Lib.getMenuLabel Lib.setMenuLabel
! instance Countable Menu where
! count = readAttr "count" (Lib.getMenuItemCount . hmenu)
instance Positioned Menu where
Index: ToolBar.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/ToolBar.hs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ToolBar.hs 23 Aug 2003 11:43:02 -0000 1.6
--- ToolBar.hs 31 Aug 2003 12:56:25 -0000 1.7
***************
*** 45,48 ****
--- 45,50 ----
destroy = newStdEvent htoolbar Lib.getWindowDestroyHandler Lib.setWindowDestroyHandler Lib.setWindowDestroyDefHandler
+ instance Countable ToolBar where
+ count = readAttr "count" (Lib.getToolBarButtonCount . htoolbar)
--------------------------------------------------------------------
|