From: <kr_...@us...> - 2003-05-02 06:35:34
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv9023/port/src/Port Modified Files: CommonDialogs.hs Types.hs Log Message: added AboutDialog (still only Linux) Index: CommonDialogs.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/CommonDialogs.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CommonDialogs.hs 26 Apr 2003 21:02:13 -0000 1.3 --- CommonDialogs.hs 2 May 2003 06:35:30 -0000 1.4 *************** *** 19,22 **** --- 19,23 ---- , runColorDialog , runFontDialog + , runAboutDialog ) where *************** *** 126,132 **** alloca $ \fstrikeoutref -> do res <- osRunFontDialog fnameref fsizeref fweightref fstyleref funderlineref fstrikeoutref owner ! if res then do ! cname <- peek fnameref csize <- peek fsizeref cweight <- peek fweightref --- 127,133 ---- alloca $ \fstrikeoutref -> do res <- osRunFontDialog fnameref fsizeref fweightref fstyleref funderlineref fstrikeoutref owner ! if res then do ! cname <- peek fnameref csize <- peek fsizeref cweight <- peek fweightref *************** *** 140,141 **** --- 141,167 ---- foreign import ccall osRunFontDialog :: Ptr CString -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CBool -> Ptr CBool -> WindowHandle -> IO Bool + ----------------------------------------------------------------------------------------- + -- About dialog + ----------------------------------------------------------------------------------------- + + runAboutDialog :: String -- ^ application name + -> String -- ^ application version + -> String -- ^ copyright + -> String -- ^ comments + -> [String] -- ^ authors + -> [String] -- ^ documenters + -> String -- ^ translator credits + -> Bitmap -- ^ logo + -> WindowHandle + -> IO () + runAboutDialog appName appVersion copyright comments authors documenters tcredits logo owner = + withCString appName $ \cAppName -> + withCString appVersion $ \cAppVersion -> + withCString copyright $ \cCopyright -> + withCString comments $ \cComments -> + withCStrings authors $ \cAuthors -> + withCStrings documenters $ \cDocumenters -> + (if null tcredits then ($ nullPtr) else withCString tcredits) $ \cTCredits -> + withCBitmap logo $ \cBmp -> + osRunAboutDialog cAppName cAppVersion cCopyright cComments cAuthors cDocumenters cTCredits cBmp owner + foreign import ccall osRunAboutDialog :: CString -> CString -> CString -> CString -> Ptr CChar -> Ptr CChar -> CString -> BitmapHandle -> WindowHandle -> IO () Index: Types.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Types.hs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Types.hs 31 Mar 2003 00:12:06 -0000 1.17 --- Types.hs 2 May 2003 06:35:30 -0000 1.18 *************** *** 110,114 **** , CBool, fromCBool, toCBool , fromCChar, toCChar ! , peekCStrings, resultCString, resultCStrings ) where --- 110,114 ---- , CBool, fromCBool, toCBool , fromCChar, toCChar ! , withCStrings, peekCStrings, resultCString, resultCStrings ) where *************** *** 1053,1060 **** = toEnum (fromIntegral cc) ! peekCStrings :: CString -> IO [String] peekCStrings cstrs | cstrs == nullPtr = return [] ! | otherwise = do str <- peekCString cstrs if (null str) --- 1053,1073 ---- = toEnum (fromIntegral cc) ! withCStrings :: [String] -> (Ptr CChar -> IO a) -> IO a ! withCStrings [] io = io nullPtr ! withCStrings strings io = allocaArray (memSize strings) $ \cbuffer -> do ! pokeStrings strings cbuffer ! io cbuffer ! where ! memSize = foldr (\x xs -> xs + length x + 1) 1 ! ! pokeStrings [] cbuffer = poke cbuffer (castCharToCChar '\0') ! pokeStrings (s:ss) cbuffer = do ! pokeArray0 (castCharToCChar '\0') cbuffer (map castCharToCChar s) ! pokeStrings ss (cbuffer `plusPtr` (length s+1)) ! ! peekCStrings :: Ptr CChar -> IO [String] peekCStrings cstrs | cstrs == nullPtr = return [] ! | otherwise = do str <- peekCString cstrs if (null str) *************** *** 1072,1076 **** -- | Convert and free a c-string of c-strings. ! resultCStrings :: IO CString -> IO [String] resultCStrings io ! = bracket io free peekCStrings \ No newline at end of file --- 1085,1089 ---- -- | Convert and free a c-string of c-strings. ! resultCStrings :: IO (Ptr CChar) -> IO [String] resultCStrings io ! = bracket io free peekCStrings |