From: <kr_...@us...> - 2003-08-17 16:45:10
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv25012/port/src/Port Modified Files: Menu.hs Log Message: Implementation for popup menus Index: Menu.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/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 *************** *** 9,13 **** Portability : portable ! Menus -} ----------------------------------------------------------------------------------------- --- 9,17 ---- Portability : portable ! The module contains all functions for creation and management of menus. ! A menu is a list of items that specify options or groups of options (a submenu). ! Clicking a menu item opens a submenu or causes the application to carry out a command. ! A menu is arranged in a hierarchy. At the top level of the hierarchy is the menu bar; ! which contains a list of menus, which in turn can contain submenus. -} ----------------------------------------------------------------------------------------- *************** *** 19,22 **** --- 23,29 ---- , insertMenu , getMenuItemCount + -- * Popup menus + , createPopupMenu + , trackPopupMenu -- * Menu items , insertMenuItem *************** *** 48,52 **** ----------------------------------------------------------------------------------------- ! -- | The handle of the main application menu mainMenu :: MenuHandle mainMenu = nullHandle --- 55,59 ---- ----------------------------------------------------------------------------------------- ! -- | The main application menu (the menu bar) mainMenu :: MenuHandle mainMenu = nullHandle *************** *** 56,66 **** ----------------------------------------------------------------------------------------- ! -- | Add a sub menu. ! insertMenu :: MenuHandle -> Maybe Int -> IO MenuHandle insertMenu handle pos = osInsertMenu handle (fromMaybe (-1) pos) foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The getMenuItemsCount function determines the number of items in the specified menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int ----------------------------------------------------------------------------------------- --- 63,101 ---- ----------------------------------------------------------------------------------------- ! -- | The 'insertMenu' function creates and inserts an item with submenu in the parent menu. ! -- The created submenu is initially empty. You can insert or append menu items by using the ! -- 'insertMenuItem', 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' ! -- functions. Using the 'insertMenu' you can create nested submenus. ! insertMenu :: MenuHandle -- ^ The handle of the parent menu. ! -- Use the 'mainMenu' handle if you want to ! -- place the menu in the application menu bar. ! -> Maybe Int -- ^ The position where to place the submenu. ! -- or Nothing if you want to append it. ! -> IO MenuHandle -- ^ The handle of the created submenu. insertMenu handle pos = osInsertMenu handle (fromMaybe (-1) pos) foreign import ccall osInsertMenu :: MenuHandle -> Int -> IO MenuHandle ! -- | The 'getMenuItemCount' function determines the number of items in the ! -- specified popup or sub menu. foreign import ccall "osGetMenuItemCount" getMenuItemCount :: MenuHandle -> IO Int + + ----------------------------------------------------------------------------------------- + -- Popup menus + ----------------------------------------------------------------------------------------- + + -- | The 'createPopupMenu' function creates a drop-down menu. The menu is initially empty. + -- You can insert or append menu items by using the 'insertMenuItem', + -- 'insertMenuCheckItem', 'insertMenuRadioItem' or 'insertMenuSeparatorItem' functions. + -- Using the 'insertMenu' you can create nested submenus. + foreign import ccall "osCreatePopupMenu" createPopupMenu :: IO MenuHandle -- ^ The handle of the created popup menu. + + -- | The 'trackPopupMenu' function displays a shortcut menu at the specified location in the + -- window and tracks the selection of items on the menu. + trackPopupMenu :: MenuHandle -- ^ The handle of the popup menu + -> WindowHandle -- ^ The handle of the window in which to popup the menu + -> Point -- ^ The location inside the window at which to display the menu + -> IO () + trackPopupMenu handle hwnd pos = withCPoint pos (osTrackPopupMenu handle hwnd) + foreign import ccall osTrackPopupMenu :: MenuHandle -> WindowHandle -> CInt -> CInt -> IO () ----------------------------------------------------------------------------------------- |