|
From: <kr_...@us...> - 2003-08-17 16:45:11
|
Update of /cvsroot/htoolkit/gio/src/Graphics/UI/GIO
In directory sc8-pr-cvs1:/tmp/cvs-serv25012/gio/src/Graphics/UI/GIO
Modified Files:
Menu.hs
Log Message:
Implementation for popup menus
Index: Menu.hs
===================================================================
RCS file: /cvsroot/htoolkit/gio/src/Graphics/UI/GIO/Menu.hs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Menu.hs 15 Aug 2003 21:24:54 -0000 1.10
--- Menu.hs 17 Aug 2003 16:45:07 -0000 1.11
***************
*** 13,27 ****
module Graphics.UI.GIO.Menu
( -- * Menus
! Menu, mainMenu, menu, menuAt, itemCount
-- * Menu items
! -- ** Menu item
! , MenuItem, menuitem, menuitemAt
! -- ** Checked menu items
! , MenuCheck, menucheck, menucheckAt
-- ** Radio items
, MenuRadioItem, menuRadioItemAt, menuRadioItem
, setMenuRadioGroup
-- ** Menu separator
! , MenuLine, menuline, menulineAt
) where
--- 13,28 ----
module Graphics.UI.GIO.Menu
( -- * Menus
! Menu, mainMenu, menuAt, menu, itemCount
! , popupMenu, trackPopupMenu
-- * Menu items
! -- ** Command items
! , MenuItem, menuitemAt, menuitem
! -- ** Checked items
! , MenuCheck, menucheckAt, menucheck
-- ** Radio items
, MenuRadioItem, menuRadioItemAt, menuRadioItem
, setMenuRadioGroup
-- ** Menu separator
! , MenuLine, menulineAt, menuline
) where
***************
*** 42,51 ****
hmenu (Menu h) = h
! -- | The main application menu
mainMenu :: Menu
mainMenu = Menu Lib.mainMenu
! -- | Insert a menu at specified position.
! menuAt :: Maybe Int -> [Prop Menu] -> Menu -> IO Menu
menuAt pos props parent
= do m <- do hmenu <- Lib.insertMenu (hmenu parent) pos
--- 43,59 ----
hmenu (Menu h) = h
! -- | The main application menu (the menu bar)
mainMenu :: Menu
mainMenu = Menu Lib.mainMenu
! -- | The 'menuAt' function creates and inserts an item with submenu in the parent menu.
! -- The created submenu is initially empty. You can populate it with items by using the
! -- 'menuitemAt', 'menucheckAt', 'menuRadioItemAt' or 'menulineAt' functions.
! -- Using the 'menuAt' you can create nested submenus.
! menuAt :: Maybe Int -- ^ The position where to place the submenu
! -- or Nothing if you want to append the item.
! -> [Prop Menu] -- ^ The setup of the menu attributes
! -> Menu -- ^ The parent menu
! -> IO Menu -- ^ The created sub menu
menuAt pos props parent
= do m <- do hmenu <- Lib.insertMenu (hmenu parent) pos
***************
*** 54,61 ****
return m
! -- | Append a menu
menu :: [Prop Menu] -> Menu -> IO Menu
menu = menuAt Nothing
instance Able Menu where
enabled = newAttr (Lib.getMenuItemEnabled . hmenu) (Lib.setMenuItemEnabled . hmenu)
--- 62,88 ----
return m
! -- | The function is the same as the 'menuAt' function but always appends the item. The 'menu' function
! -- is semantically equal to @menuAt Nothing@
menu :: [Prop Menu] -> Menu -> IO Menu
menu = menuAt Nothing
+ -- | The 'popupMenu' function creates a popup menu. The menu is initially empty.
+ -- You can populate it with items by using the 'menuitemAt', 'menucheckAt',
+ -- 'menuRadioItemAt' or 'menulineAt' functions. Using the 'menuAt' you can create nested submenus.
+ popupMenu :: [Prop Menu] -> IO Menu
+ popupMenu props
+ = do m <- do hmenu <- Lib.createPopupMenu
+ return (Menu hmenu)
+ set m props
+ return m
+
+ -- | The 'trackPopupMenu' function displays a popup menu at the specified location in the
+ -- window and tracks the selection of items on the menu.
+ trackPopupMenu :: Menu -- ^ The popup menu
+ -> Window -- ^ The window in which to popup the menu
+ -> Point -- ^ The location inside the window at which to display the menu
+ -> IO ()
+ trackPopupMenu menu window pos = Lib.trackPopupMenu (hmenu menu) (hwindow window) pos
+
instance Able Menu where
enabled = newAttr (Lib.getMenuItemEnabled . hmenu) (Lib.setMenuItemEnabled . hmenu)
***************
*** 63,67 ****
instance Titled Menu where
title = newAttr (Lib.getMenuLabel . hmenu) (Lib.setMenuLabel . hmenu)
!
itemCount :: Attr Menu Int
itemCount = readAttr "itemsCount" (Lib.getMenuItemCount . hmenu)
--- 90,96 ----
instance Titled Menu where
title = newAttr (Lib.getMenuLabel . hmenu) (Lib.setMenuLabel . hmenu)
!
! -- | 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)
***************
*** 122,131 ****
--------------------------------------------------------------------
! -- | Radio menu items are labeled entries in a menu.
newtype MenuRadioItem = MenuRadioItem MenuHandle
hradioitem (MenuRadioItem h) = h
! -- | Create a menu item and insert it at specified position.
! menuRadioItemAt :: Maybe Int -> [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem
menuRadioItemAt pos props menu
= do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hmenu menu) pos
--- 151,167 ----
--------------------------------------------------------------------
! -- | Radio menu items are labeled entries in a menu with bookmark.
! -- Sometimes, a group of menu items corresponds to a set of mutually exclusive options.
! -- In this case, you can indicate the selected option by using a selected radio menu item.
! -- To check a menu item use the 'checked' attribute.
newtype MenuRadioItem = MenuRadioItem MenuHandle
hradioitem (MenuRadioItem h) = h
! -- | Create a radio menu item and insert it at specified position.
! menuRadioItemAt :: Maybe Int -- ^ The position where to place the item
! -- or Nothing if you want to append it.
! -> [Prop MenuRadioItem] -- ^ The setup of the radio item attributes
! -> Menu -- ^ The parent menu
! -> IO MenuRadioItem -- ^ The created radio item
menuRadioItemAt pos props menu
= do mradioitem <- do hradioitem <- Lib.insertMenuRadioItem (hmenu menu) pos
***************
*** 134,138 ****
return mradioitem
! -- | Create a menu item and appends it to parent menu.
menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem
menuRadioItem = menuRadioItemAt Nothing
--- 170,175 ----
return mradioitem
! -- | The function is the same as the 'menuRadioItemAt' function but always appends the item. The 'menuRadioItem'
! -- function is semantically equal to @menuRadioItemAt Nothing@
menuRadioItem :: [Prop MenuRadioItem] -> Menu -> IO MenuRadioItem
menuRadioItem = menuRadioItemAt Nothing
***************
*** 162,166 ****
instance Accelerated MenuRadioItem where
accel = newAttr (Lib.getMenuItemAccel . hradioitem) (Lib.setMenuItemAccel . hradioitem)
!
setMenuRadioGroup :: [MenuRadioItem] -> IO ()
setMenuRadioGroup items = Lib.setMenuRadioGroup (map hradioitem items)
--- 199,204 ----
instance Accelerated MenuRadioItem where
accel = newAttr (Lib.getMenuItemAccel . hradioitem) (Lib.setMenuItemAccel . hradioitem)
!
! -- | The 'setMenuRadioGroup' function specifies a set of mutually exclusive options.
setMenuRadioGroup :: [MenuRadioItem] -> IO ()
setMenuRadioGroup items = Lib.setMenuRadioGroup (map hradioitem items)
***************
*** 169,178 ****
-- Checked menu items
--------------------------------------------------------------------
! -- | Menu items are labeled entries in a menu.
newtype MenuCheck = MenuCheck MenuHandle
hcheck (MenuCheck h) = h
! -- | Create a menu item and insert it at specified position.
! menucheckAt :: Maybe Int -> [Prop MenuCheck] -> Menu -> IO MenuCheck
menucheckAt pos props menu
= do mcheck <- do mcheck <- Lib.insertMenuCheckItem (hmenu menu) pos
--- 207,222 ----
-- Checked menu items
--------------------------------------------------------------------
! -- | Checked menu items are labeled entries in a menu with check mark.
! -- Applications typically check or clear a menu item to indicate whether
! -- an option is in effect.
newtype MenuCheck = MenuCheck MenuHandle
hcheck (MenuCheck h) = h
! -- | Create a check menu item and insert it at specified position.
! menucheckAt :: Maybe Int -- ^ The position where to place the item
! -- or Nothing if you want to append it.
! -> [Prop MenuCheck] -- ^ The setup of the item attributes
! -> Menu -- ^ The parent menu
! -> IO MenuCheck -- ^ The created checked item
menucheckAt pos props menu
= do mcheck <- do mcheck <- Lib.insertMenuCheckItem (hmenu menu) pos
***************
*** 181,185 ****
return mcheck
! -- | Create a checked menu item and appends it to parent menu.
menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck
menucheck = menucheckAt Nothing
--- 225,230 ----
return mcheck
! -- | The function is the same as the 'menucheckAt' function but always appends the item. The 'menucheck'
! -- function is semantically equal to @menucheckAt Nothing@
menucheck :: [Prop MenuCheck] -> Menu -> IO MenuCheck
menucheck = menucheckAt Nothing
|