From: <kr_...@us...> - 2004-05-06 10:27:55
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23600/port/src/Port Modified Files: Types.hs Window.hs Log Message: Support for the Center/CenterOnParent/Mouse positioning Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Types.hs 22 Feb 2004 10:29:56 -0000 1.35 --- Types.hs 6 May 2004 10:27:46 -0000 1.36 *************** *** 71,78 **** -- * Document interface , DocumentInterface(..) ! -- * PositionType , PositionType(..) -- * Primitive Handles , WindowHandle --- 71,81 ---- -- * Document interface , DocumentInterface(..) ! -- * PositionType , PositionType(..) + -- * Window position + , WindowPosition(..) + -- * Primitive Handles , WindowHandle *************** *** 100,113 **** , withCSize, withCSizeResult, fromCSize , withCRect, withCRectResult, fromCRect ! , fromCModifiers, toCModifiers , fromCKey, toCKey , fromCMouseEvent , fromCKeyboardEvent ! , toCDocumentInterface ! , toCPositionType, fromCPositionType , fromCInt, toCInt , CWord, fromCWord, toCWord --- 103,118 ---- , withCSize, withCSizeResult, fromCSize , withCRect, withCRectResult, fromCRect ! , fromCModifiers, toCModifiers , fromCKey, toCKey , fromCMouseEvent , fromCKeyboardEvent ! , toCDocumentInterface ! , toCPositionType, fromCPositionType + , withCWindowPosition + , fromCInt, toCInt , CWord, fromCWord, toCWord *************** *** 720,724 **** ----------------------------------------------------------------------------------------- ! data PositionType = PosLeft | PosTop | PosRight --- 725,729 ---- ----------------------------------------------------------------------------------------- ! data PositionType = PosLeft | PosTop | PosRight *************** *** 738,741 **** --- 743,765 ---- fromCPositionType 3 = PosBottom + ----------------------------------------------------------------------------------------- + -- WindowPosition + ----------------------------------------------------------------------------------------- + + data WindowPosition + = WinPosExact Rect + | WinPosCenter Size + | WinPosMouse Size + | WinPosCenterAlways Size + | WinPosCenterOnParent Size + deriving (Eq,Show) + + withCWindowPosition :: WindowPosition -> (CInt -> CInt -> CInt -> CInt -> CInt -> IO a) -> IO a + withCWindowPosition (WinPosExact rect) f = withCRect rect (f 0) + withCWindowPosition (WinPosCenter size) f = withCSize size (f 1 0 0) + withCWindowPosition (WinPosMouse size) f = withCSize size (f 2 0 0) + withCWindowPosition (WinPosCenterAlways size) f = withCSize size (f 3 0 0) + withCWindowPosition (WinPosCenterOnParent size) f = withCSize size (f 4 0 0) + {----------------------------------------------------------------------------------------- Buffermode & Pattern Index: Window.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Window.hs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Window.hs 12 Oct 2003 23:14:56 -0000 1.17 --- Window.hs 6 May 2004 10:27:46 -0000 1.18 *************** *** 25,29 **** -- * Properties , setWindowVisible, getWindowVisible ! , setWindowFrame, getWindowFrame , setWindowResizeable , setWindowColor --- 25,29 ---- -- * Properties , setWindowVisible, getWindowVisible ! , setWindowPosition, getWindowRect , setWindowResizeable , setWindowColor *************** *** 57,72 **** foreign import ccall "osInvalidateWindow" invalidateWindow :: WindowHandle -> IO () ! -- | Move and resize the outer frame of a window. ! setWindowFrame :: WindowHandle -> Rect -> IO () ! setWindowFrame hwnd rect ! = withCRect rect $ \x0 y0 x1 y1 -> ! osSetWindowRect hwnd x0 y0 x1 y1 ! foreign import ccall osSetWindowRect :: WindowHandle -> CInt -> CInt -> CInt -> CInt -> IO () ! -- | Get the outer frame of a window. ! getWindowFrame :: WindowHandle -> IO Rect ! getWindowFrame hwnd ! = withCRectResult $ \crect -> ! osGetWindowRect hwnd crect foreign import ccall osGetWindowRect :: WindowHandle -> Ptr CInt -> IO () --- 57,70 ---- foreign import ccall "osInvalidateWindow" invalidateWindow :: WindowHandle -> IO () ! -- | Sets the position of the window. The position can be specified using the exact bounding rectangle ! -- or in a way relative to the parent window or to the screen. ! setWindowPosition :: WindowHandle -> WindowPosition -> IO () ! setWindowPosition hwnd pos = withCWindowPosition pos (osSetWindowPosition hwnd) ! foreign import ccall osSetWindowPosition :: WindowHandle -> CInt -> CInt -> CInt -> CInt -> CInt -> IO () ! -- | Gets the smallest rectangle which bounds the outer frame of the window. Use the 'setWindowPosition' function ! -- to move\/resize the window ! getWindowRect :: WindowHandle -> IO Rect ! getWindowRect hwnd = withCRectResult (osGetWindowRect hwnd) foreign import ccall osGetWindowRect :: WindowHandle -> Ptr CInt -> IO () |