Skip to content
Browse files

Working for wxWidgets 2.8.12 on Windows 7.

Ignore-this: 1ec0b058132651f3a7f9d4321ef38e59

darcs-hash:20120101234845-75908-3ad6e2c8d1bde4da79d9abb2c913684e0adb7fe3.gz
  • Loading branch information...
1 parent 0c86da7 commit ef9abd787c4d9c1b3657413c45012998e9c1a19c @jodonoghue committed
View
3 etc/darcs-boring
@@ -58,3 +58,6 @@
(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/)
(^|/)\.lock-wscript$
^\.darcs-temp-mail$
+(^|/)dist$
+(^|/)cabal-dev$
+(^|/)patches$
View
17 samples/wx/ListCtrl.hs
@@ -45,9 +45,11 @@ gui
,("Size", AlignRight, -1)
,("Date", AlignRight, -1)]
,items := [[name,size,date] | (name,size,date) <- entries]
- ,on listEvent := onListEvent
]
+
+ set l [on listEvent := onListEvent l]
+
-- specify layout
set f [layout := container p $ margin 10 $
column 5 [ fill $ widget l
@@ -56,9 +58,10 @@ gui
,clientSize := sz 400 300
]
return ()
- where
- onListEvent eventList
- = case eventList of
- ListItemSelected idx -> logMessage ("item selected: " ++ show idx)
- ListItemDeselected idx -> logMessage ("item de-selected: " ++ show idx)
- other -> logMessage ("list control event.")
+
+onListEvent list eventList
+ = case eventList of
+ ListItemSelected idx -> listCtrlGetItemText list idx >>= logMessage . (++) "item selected: "
+ ListItemDeselected idx -> logMessage ("item de-selected: " ++ show idx)
+ other -> logMessage ("list control event.")
+
View
26 samples/wx/ListView.hs
@@ -0,0 +1,26 @@
+{--------------------------------------------------------------------------------
+ List view demo.
+--------------------------------------------------------------------------------}
+module Main where
+
+import Graphics.UI.WX
+import Graphics.UI.WXCore
+
+entries :: [Int]
+entries = [-1,1,-123,123]
+
+main :: IO ()
+main = start gui
+
+gui :: IO ()
+gui = do
+ f <- frame [text := "List view Sample"]
+ p <- panel f []
+
+ l <- listView p ["n", "n >= 0"] (\n-> [show n, show (n >= 0)])
+ listViewSetItems l entries
+
+ -- specify layout
+ set f [layout := container p . fill . widget . listViewCtrl $ l, clientSize := sz 230 400]
+ return ()
+
View
5 samples/wxcore/HelloWorld.hs
@@ -22,7 +22,7 @@ helloWorld
-- create top frame
f <- frameCreate objectNull idAny "Hello world" rectZero frameDefaultStyle
windowSetBackgroundColour f white
- windowSetClientSize f (sz 300 250)
+ windowSetClientSize f (sz 600 250)
-- set status bar with 1 field
frameCreateStatusBar f 1 0
@@ -39,7 +39,8 @@ helloWorld
return ()
where
onAbout f
- = do messageDialog f "About 'Hello World'" "This is a wxHaskell sample" (wxOK + wxICON_INFORMATION)
+ = do version <- versionNumber
+ messageDialog f "About 'Hello World'" ("This is a wxHaskell " ++ show version ++ " sample") (wxOK + wxICON_INFORMATION)
return ()
onQuit f
View
62 wx/src/Graphics/UI/WX/Controls.hs
@@ -1,3 +1,4 @@
+
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, DeriveDataTypeable #-}
--------------------------------------------------------------------------------
{-| Module : Controls
@@ -48,7 +49,8 @@ module Graphics.UI.WX.Controls
-- ** Tree control
, TreeCtrl, treeCtrl, treeCtrlEx, treeEvent, treeCtrlRes
-- ** List control
- , ListCtrl, listCtrl, listCtrlEx, listCtrlRes, listEvent, columns
+ , ListCtrl, listCtrl, listCtrlEx, listCtrlRes, listCtrlSetColumnWidths, listEvent, columns
+ , ListView(..), listViewLayout, listViewSetHandler, listViewSelectHandle, listViewSetItems, listViewGetItems, listViewAddItem, listView
-- ** Static text
, StaticText, staticText, staticTextRes
-- ** SplitterWindow
@@ -69,8 +71,10 @@ import Graphics.UI.WX.Classes
import Graphics.UI.WX.Events
import Graphics.UI.WX.Layout
import Graphics.UI.WX.Media (Media(..))
+import Graphics.UI.WX.Variable (variable)
import Graphics.UI.WX.Window
+import Control.Monad (forM_)
import Data.Dynamic -- for "alignment"
@@ -1101,6 +1105,60 @@ listCtrlRes parent name props =
set l props
return l
+-- TODO: figure out how to set a resize handler in addition to the
+-- default one. this will allow us to expand as needed upon resize
+-- events.
+listCtrlSetColumnWidths :: ListCtrl () -> Int -> IO ()
+listCtrlSetColumnWidths ctrl w = do
+-- size <- (realToFrac.sizeW) `fmap` get ctrl clientSize
+ cols <- listCtrlGetColumnCount ctrl
+-- let w = 65 --ceiling $ size / realToFrac cols
+ forM_ [0 .. cols - 1] $ \i -> listCtrlSetColumnWidth ctrl i w
+
+-- | A small wrapper over WX's ListCtrl, allowing us to keep the data
+-- we're representing as well as its string form (shown to the user as
+-- rows).
+data ListView a = ListView {
+ listViewCtrl :: ListCtrl (),
+ listViewItems :: Var [a],
+ listViewToRow :: a -> [String]
+}
+
+listViewLayout :: ListView a -> Layout
+listViewLayout = fill . widget . listViewCtrl
+
+listViewSetHandler :: ListView a -> (EventList -> IO ()) -> IO ()
+listViewSetHandler list handler =
+ set (listViewCtrl list) [on listEvent := handler]
+
+listViewSelectHandle :: ListView a -> (Maybe a -> IO ()) -> EventList -> IO ()
+listViewSelectHandle _ _ (ListItemActivated (-1)) = propagateEvent
+listViewSelectHandle list end (ListItemActivated n ) = end . Just =<< (!! n) `fmap` listViewGetItems list
+listViewSelectHandle _ _ _ = propagateEvent
+
+listViewSetItems :: ListView a -> [a] -> IO ()
+listViewSetItems list its = do
+ set (listViewItems list) [value := its]
+ set (listViewCtrl list) [items := map (listViewToRow list) its]
+
+listViewGetItems :: ListView a -> IO [a]
+listViewGetItems list = get (listViewItems list) value
+
+listViewAddItem :: ListView a -> a -> IO ()
+listViewAddItem list it = do
+ its <- (it:) `fmap` get (listViewItems list) value
+ listViewSetItems list its
+
+listViewSetColumnWidths :: ListView a -> Int -> IO ()
+listViewSetColumnWidths list w = do
+ listCtrlSetColumnWidths (listViewCtrl list) w
+
+listView :: Window b -> [String] -> (a -> [String]) -> IO (ListView a)
+listView parent cols toRow = do
+ ctrl <- listCtrl parent [columns := map (\n -> (n, AlignLeft, -1)) cols]
+ var <- variable [value := []]
+ return $ ListView ctrl var toRow
+
{--------------------------------------------------------------------------------
SplitterWindow
--------------------------------------------------------------------------------}
@@ -1225,4 +1283,4 @@ styledTextCtrlEx parent style props
initialContainer $ \id rect -> \props flags ->
do s <- styledTextCtrlCreate parent id "" rect style
set s props
- return s
+ return s
View
2 wx/wx.cabal
@@ -1,5 +1,5 @@
Name: wx
-Version: 0.13.1
+Version: 0.13.2
License: OtherLicense
License-file: license.txt
Homepage: http://haskell.org/haskellwiki/WxHaskell
View
14 wxcore/Setup.hs
@@ -7,6 +7,7 @@ import Distribution.Simple.Setup (ConfigFlags)
import System.Cmd (system)
import System.FilePath.Posix ((</>), (<.>))
import System.Directory (createDirectoryIfMissing)
+import System.Info (os)
import System.Process (readProcess)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -48,13 +49,14 @@ myConfHook (pkg0, pbi) flags = do
system $ "wxdirect -d --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ intercalate " " eiffelFiles
ver <- fmap (head . drop 1 . splitBy (== '.')) (readProcess "wx-config" ["--version"] "")
- let extra_wx_libs = if ver == "9"
- then [ "-lwxmsw29ud_xrc", "-lwxmsw29ud_stc", "-lwxmsw29ud_aui", "-lwxmsw29ud_media"
- , "-lwxmsw29ud_ribbon", "-lwxmsw29ud_propgrid", "-lwxmsw29ud_richtext"
- , "-lwxmsw29ud_gl" , "-lstdc++"]
- else [ "-lwxmsw28ud_media", "-lwxmsw28ud_richtext", "-lwxmsw28ud_aui"
+ let extra_wx_libs = if os == "mingw32"
+ then [ "-lwxmsw28ud_media", "-lwxmsw28ud_richtext", "-lwxmsw28ud_aui"
, "-lwxmsw28ud_xrc", "-lstdc++" ]
- wx <- fmap parseWxConfig (readProcess "wx-config" ["--libs", "--cppflags"] "")
+ else [ "-lstdc++" ]
+ wx_cfg_parms = if os == "mingw32"
+ then [ "--libs", "gl,stc", "--cppflags" ]
+ else [ "--libs", "all", "--cppflags" ]
+ wx <- fmap parseWxConfig (readProcess "wx-config" wx_cfg_parms "")
lbi <- confHook simpleUserHooks (pkg0, pbi) flags
let lpd = localPkgDescr lbi
View
6 wxcore/src/cpp/dragimage.cpp
@@ -8,17 +8,17 @@ extern "C" {
-----------------------------------------------------------------------------*/
EWXWEXPORT(wxDragImage*,wxDragImage_Create)(wxBitmap* image,int x,int y)
{
- return new wxDragImage(*image, wxNullCursor, wxPoint(x, y));
+ return new wxDragImage(*image, wxNullCursor);
}
EWXWEXPORT(wxDragImage*,wxDragIcon)(wxIcon* icon,int x,int y)
{
- return new wxDragImage(*icon, wxNullCursor, wxPoint(x, y));
+ return new wxDragImage(*icon, wxNullCursor);
}
EWXWEXPORT(wxDragImage*,wxDragString)(wxString* text,int x,int y)
{
- return new wxDragImage(*text, wxNullCursor, wxPoint(x, y));
+ return new wxDragImage(*text, wxNullCursor);
}
EWXWEXPORT(wxDragImage*,wxDragTreeItem)(wxTreeCtrl* treeCtrl,wxTreeItemId* id)
View
2 wxcore/src/cpp/eljevent.cpp
@@ -1530,10 +1530,12 @@ MAKE_EVENT_WRAPPER(EVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
#endif
// from power.h
+#ifdef wxHAS_POWER_EVENTS
MAKE_EVENT_WRAPPER(EVT_POWER_SUSPENDING)
MAKE_EVENT_WRAPPER(EVT_POWER_SUSPENDED)
MAKE_EVENT_WRAPPER(EVT_POWER_SUSPEND_CANCEL)
MAKE_EVENT_WRAPPER(EVT_POWER_RESUME)
+#endif
// from process.h
MAKE_EVENT_WRAPPER(EVT_END_PROCESS)
View
4 wxcore/src/cpp/eljpen.cpp
@@ -15,7 +15,11 @@ EWXWEXPORT(void*,wxPen_CreateFromColour)(wxColour* col,int width,int style)
EWXWEXPORT(void*,wxPen_CreateFromBitmap)(wxBitmap* stipple,int width)
{
+#ifdef __WXGTK__
+ return 0;
+#else
return new wxPen(*stipple, width);
+#endif
}
EWXWEXPORT(void*,wxPen_CreateFromStock)(int id)
View
2 wxcore/src/cpp/eljprinting.cpp
@@ -828,7 +828,7 @@ EWXWEXPORT(void,wxPostScriptDC_Delete)(wxPostScriptDC* self)
EWXWEXPORT(void,wxPostScriptDC_SetResolution)(wxPostScriptDC* self,int ppi)
{
-#ifdef wxUSE_POSTSCRIPT
+#if (defined(wxUSE_POSTSCRIPT)) && (wxVERSION_NUMBER < 2900)
self->SetResolution(ppi);
#endif
}
View
2 wxcore/src/cpp/extra.cpp
@@ -1210,7 +1210,7 @@ EWXWEXPORT(void,wxString_Delete)(wxString* s)
EWXWEXPORT(int,wxString_GetString)(wxString* s,wxChar* buffer)
{
- if (buffer) memcpy (buffer, s->c_str(), s->Length() * sizeof(wxChar));
+ if (buffer) memcpy (buffer, s->wc_str(), s->Length() * sizeof(wxChar));
return s->Length();
}
View
32 wxcore/src/cpp/graphicscontext.cpp
@@ -223,7 +223,13 @@ EWXWEXPORT(void,wxGraphicsContext_DrawLines)( wxGraphicsContext* self, size_t n,
for (size_t i = 0; i < n; i++)
points[i] = wxPoint2DDouble(x[i], y[i]);
- self->DrawLines(n, points, fillStyle);
+ #if (wxVERSION_NUMBER >= 2900)
+ wxPolygonFillMode pfm_fillStyle = (wxPolygonFillMode) fillStyle;
+ #else
+ int pfm_fillStyle = fillStyle;
+ #endif
+
+ self->DrawLines(n, points, pfm_fillStyle);
free (points);
#endif
@@ -233,7 +239,13 @@ EWXWEXPORT(void,wxGraphicsContext_DrawPath)( wxGraphicsContext* self,
const wxGraphicsPath* path, int fillStyle )
{
#ifdef wxUSE_GRAPHICS_CONTEXT
- self->DrawPath(*path, fillStyle);
+ #if (wxVERSION_NUMBER >= 2900)
+ wxPolygonFillMode pfm_fillStyle = (wxPolygonFillMode) fillStyle;
+ #else
+ int pfm_fillStyle = fillStyle;
+ #endif
+
+ self->DrawPath(*path, pfm_fillStyle);
#endif
}
@@ -274,7 +286,13 @@ EWXWEXPORT(void,wxGraphicsContext_FillPath)( wxGraphicsContext* self,
const wxGraphicsPath* path, int fillStyle )
{
#ifdef wxUSE_GRAPHICS_CONTEXT
- self->FillPath(*path, fillStyle);
+ #if (wxVERSION_NUMBER >= 2900)
+ wxPolygonFillMode pfm_fillStyle = (wxPolygonFillMode) fillStyle;
+ #else
+ int pfm_fillStyle = fillStyle;
+ #endif
+
+ self->FillPath(*path, pfm_fillStyle);
#endif
}
@@ -722,7 +740,13 @@ EWXWEXPORT(void,wxGraphicsPath_CloseSubpath)( wxGraphicsPath* self )
EWXWEXPORT(void,wxGraphicsPath_Contains)( wxGraphicsPath* self, wxDouble x, wxDouble y, int fillStyle )
{
#ifdef wxUSE_GRAPHICS_CONTEXT
- self->Contains(x, y, fillStyle);
+ #if (wxVERSION_NUMBER >= 2900)
+ wxPolygonFillMode pfm_fillStyle = (wxPolygonFillMode) fillStyle;
+ #else
+ int pfm_fillStyle = fillStyle;
+ #endif
+
+ self->Contains(x, y, pfm_fillStyle);
#endif
}
View
2 wxcore/src/cpp/mediactrl.cpp
@@ -41,6 +41,7 @@ extern "C" {
// Event Handlers
////////////////////////////////////////////////////////////////////////////////
+#ifdef wxUSE_MEDIACTRL
#pragma message "wxWidgets mediacontrol event wrappers generated"
MAKE_EVENT_WRAPPER(EVT_MEDIA_FINISHED)
MAKE_EVENT_WRAPPER(EVT_MEDIA_STOP)
@@ -48,6 +49,7 @@ MAKE_EVENT_WRAPPER(EVT_MEDIA_LOADED)
MAKE_EVENT_WRAPPER(EVT_MEDIA_STATECHANGED)
MAKE_EVENT_WRAPPER(EVT_MEDIA_PLAY)
MAKE_EVENT_WRAPPER(EVT_MEDIA_PAUSE)
+#endif
////////////////////////////////////////////////////////////////////////////////
// Wrappers
View
4 wxcore/src/haskell/Graphics/UI/WXCore/Events.hs
@@ -190,6 +190,7 @@ module Graphics.UI.WXCore.Events
-- * TaskBar icon events
, EventTaskBarIcon(..)
+
-- * Current event
, propagateEvent
, skipCurrentEvent
@@ -241,7 +242,7 @@ import Foreign.Marshal.Array
import Foreign.Marshal.Utils
import Data.Char ( chr ) -- used in stc
-import Data.Maybe ( fromMaybe )
+import Data.Maybe ( fromMaybe, fromJust )
import Control.Concurrent.MVar
import System.IO.Unsafe( unsafePerformIO )
@@ -2371,7 +2372,6 @@ evtHandlerGetOnTaskBarIconEvent window id evt
skipCurrentEvent
-
------------------------------------------------------------------------------------------
-- TimerEx is handled specially.
------------------------------------------------------------------------------------------
View
1 wxcore/src/haskell/Graphics/UI/WXCore/Layout.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE FlexibleInstances #-}
-----------------------------------------------------------------------------------------
{-| Module : Layout
Copyright : (c) Daan Leijen & Wijnand van Suijlen 2003
View
6 wxcore/src/include/mediactrl.h
@@ -25,9 +25,3 @@ TInt64 wxMediaCtrl_Tell(TSelf(wxMediaCtrl) self);
TClassDefExtend(wxMediaEvent,wxNotifyEvent);
/* The wxMediaEvent's events */
-int expEVT_MEDIA_LOADED();
-int expEVT_MEDIA_STOP();
-int expEVT_MEDIA_FINISHED();
-int expEVT_MEDIA_STATECHANGED();
-int expEVT_MEDIA_PLAY();
-int expEVT_MEDIA_PAUSE();
View
3 wxcore/src/include/wxc_glue.h
@@ -15,8 +15,6 @@ TClass(wxPalette) Null_Palette( );
TClass(wxPen) Null_Pen( );
/* Events */
-int expEVT_NULL();
-int expEVT_FIRST();
int expEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN();
int expEVT_COMMAND_AUITOOLBAR_OVERFLOW_CLICK();
int expEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK();
@@ -5134,6 +5132,5 @@ TClassDefExtend(wxZlibInputStream,wxFilterInputStream)
TClassDefExtend(wxZlibInputStream,wxFilterInputStream)
/* wxZlibOutputStream */
-TClassDefExtend(wxZlibOutputStream,wxFilterOutputStream)
TClassDefExtend(wxZlibOutputStream,wxFilterOutputStream)
View
2 wxcore/wxcore.cabal
@@ -1,5 +1,5 @@
name: wxcore
-version: 0.13.1
+version: 0.13.2
license: OtherLicense
license-file: LICENSE
author: Daan Leijen
View
4 wxdirect/src/Classes.hs
@@ -23,10 +23,12 @@ module Classes( isClassName, isBuiltin, haskellClassDefs
) where
import System.Environment ( getEnv )
+import Control.Exception ( catch, SomeException(..) )
import Data.Char( isUpper )
import Data.List( sort, sortBy )
import qualified Data.Set as Set
import qualified Data.Map as Map
+import Prelude hiding ( catch )
import HaskellNames( haskellTypeName, isBuiltin )
import Types
@@ -300,7 +302,7 @@ parseClassHierarchy fname
Left err -> do putStrLn ("parse error in class hierarchy: " ++ show err)
return []
Right cs -> return cs
- `catch` \err ->
+ `catch` \(SomeException err) ->
do putStrLn ("exception while parsing: " ++ fname)
print err
return []
View
6 wxdirect/src/CompileClassInfo.hs
@@ -18,6 +18,7 @@ import Data.List( sortBy, sort )
import Types
import HaskellNames
import Classes
+import IOExtra
{-----------------------------------------------------------------------------------------
@@ -102,11 +103,10 @@ compileClassInfo verbose moduleRoot moduleClassesName moduleClassTypesName modul
, ""
]
]
- prologue <- getPrologue moduleName "class info"
- (show defCount ++ " class info definitions.") []
+ prologue <- getPrologue moduleName "class info" (show defCount ++ " class info definitions.") []
putStrLn ("generating: " ++ outputFile)
- writeFile outputFile (unlines (prologue ++ export ++ classDefs ++ downcDefs))
+ writeFileLazy outputFile (unlines (prologue ++ export ++ classDefs ++ downcDefs))
putStrLn ("generated " ++ show defCount ++ " class info definitions")
putStrLn "ok."
View
3 wxdirect/src/CompileClassTypes.hs
@@ -19,6 +19,7 @@ import Types
import HaskellNames
import Classes( isClassName, haskellClassDefs )
import DeriveTypes( ClassName )
+import IOExtra
{-----------------------------------------------------------------------------------------
Compile
@@ -51,7 +52,7 @@ compileClassTypes showIgnore moduleRoot moduleName outputFile inputFiles
let output = unlines (prologue ++ export ++ classDecls)
putStrLn ("generating: " ++ outputFile)
- writeFile outputFile output
+ writeFileLazy outputFile output
putStrLn ("generated " ++ show classCount ++ " class definitions.")
putStrLn ("ok.")
View
27 wxdirect/src/CompileClasses.hs
@@ -19,13 +19,14 @@ import qualified MultiSet
import Data.Time( getCurrentTime)
import Data.Char( toUpper, isUpper, toLower ) --toLower, toUpper, isSpace, isLower, isUpper )
-import Data.List( isPrefixOf, sort, sortBy, intersperse, zipWith4 )
+import Data.List( isPrefixOf, sort, sortBy, intersperse, zipWith4, elemIndex )
import Types
import HaskellNames
import Classes( isClassName, haskellClassDefs, objectClassNames, ClassInfo(..), classInfo, classIsManaged )
import ParseC( parseC )
import DeriveTypes( deriveTypes, classifyName, Name(..), Method(..), ClassName, MethodName, PropertyName )
+import IOExtra
{-----------------------------------------------------------------------------------------
Compile
@@ -45,10 +46,8 @@ compileClasses showIgnore moduleRoot moduleClassTypesName moduleName outputFile
module2 = moduleRoot ++ moduleName ++ postfix2
export = concat [ ["module " ++ moduleRoot ++ moduleName
- , " ( -- * Version"
- , " version" ++ moduleName
- , " -- * Re-export"
- , " , module " ++ module1
+ , " ( -- * Re-export"
+ , " module " ++ module1
, " , module " ++ module2
, " , module " ++ moduleRoot ++ moduleClassTypesName
, " ) where"
@@ -57,9 +56,6 @@ compileClasses showIgnore moduleRoot moduleClassTypesName moduleName outputFile
, "import " ++ module2
, "import " ++ moduleRoot ++ moduleClassTypesName
, ""
- , "version" ++ moduleName ++ " :: String"
- , "version" ++ moduleName ++ " = \"" ++ show time ++ "\""
- , ""
]
]
@@ -76,7 +72,7 @@ compileClasses showIgnore moduleRoot moduleClassTypesName moduleName outputFile
let output = unlines (prologue ++ export)
putStrLn ("generating: " ++ outputFile ++ ".hs")
- writeFile (outputFile ++ ".hs") output
+ writeFileLazy (outputFile ++ ".hs") output
putStrLn ("generated " ++ show methodCount ++ " total methods for " ++ show classCount ++ " total classes.")
putStrLn ("ok.")
@@ -96,10 +92,8 @@ compileClassesFile showIgnore moduleRoot moduleClassTypesName moduleName outputF
ghcoptions = [ "{-# LANGUAGE ForeignFunctionInterface #-}"]
export = concat [ ["module " ++ moduleRoot ++ moduleName
- , " ( -- * Version"
- , " version" ++ moduleName
- , " -- * Global" ]
- , exportsStatic
+ , " ( -- * Global" ]
+ , (let es1 : es2 : estail = exportsStatic in es1 : dropFirstComma es2 : estail)
, [ " -- * Classes" ]
, exportsClassClasses
, [ " ) where"
@@ -110,9 +104,6 @@ compileClassesFile showIgnore moduleRoot moduleClassTypesName moduleName outputF
, "import " ++ moduleRoot ++ "WxcTypes"
, "import " ++ moduleRoot ++ moduleClassTypesName
, ""
- , "version" ++ moduleName ++ " :: String"
- , "version" ++ moduleName ++ " = \"" ++ show time ++ "\""
- , ""
]
]
@@ -122,7 +113,7 @@ compileClassesFile showIgnore moduleRoot moduleClassTypesName moduleName outputF
let output = unlines (ghcoptions ++ prologue ++ export ++ marshalDecls)
putStrLn ("generating: " ++ outputFile ++ ".hs")
- writeFile (outputFile ++ ".hs") output
+ writeFileLazy (outputFile ++ ".hs") output
putStrLn ("generated " ++ show methodCount ++ " methods for " ++ show classCount ++ " classes.")
return (methodCount,classCount)
@@ -135,6 +126,8 @@ cmpDecl decl1 decl2
exportComma = exportSpaces ++ ","
exportSpaces = " "
+dropFirstComma str = maybe str replaceNthWithSpace (elemIndex ',' str)
+ where replaceNthWithSpace n = let (front,back) = splitAt n str in front ++ " " ++ tail back
{-----------------------------------------------------------------------------------------
Create export definitions
View
26 wxdirect/src/IOExtra.hs
@@ -0,0 +1,26 @@
+-----------------------------------------------------------------------------------------
+{-| Module : IOExtra
+ Copyright : (c) Dave Tapley 2011
+ License : BSD-style
+
+ Maintainer : wxhaskell-devel@lists.sourceforge.net
+
+ Defines most of the classes in wxWindows.
+-}
+-----------------------------------------------------------------------------------------
+module IOExtra( writeFileLazy ) where
+
+import Control.Exception
+import Control.Monad
+import System.Directory
+import System.Environment
+import System.IO.Error
+import qualified System.IO.Strict as Strictly
+
+{-----------------------------------------------------------------------------------------
+Only write to the file if its contents have changed,
+e.g. don't change the file's modifed time unless you change the contents.
+-----------------------------------------------------------------------------------------}
+writeFileLazy :: FilePath -> String -> IO ()
+writeFileLazy f str = fileChanged >>= flip when (writeFile f str)
+ where fileChanged = return . either (const True) (/= str) =<< tryJust (guard . isDoesNotExistError) (Strictly.readFile f)
View
2 wxdirect/src/ParseC.hs
@@ -75,7 +75,7 @@ pairComments lines
parseDecl :: FilePath -> (String,String) -> IO [Decl]
parseDecl fname (comment,line)
= case parse pdecl fname line of
- Left err -> do putStrLn ("ignore: parse error : " ++ line)
+ Left err -> do putStrLn ("ignore: parse error : " ++ show err ++ ", on : " ++ line)
return []
Right mbd -> case mbd of
Just d -> return [d{ declComment = comment }]
View
4 wxdirect/wxdirect.cabal
@@ -60,7 +60,9 @@ executable wxdirect
build-depends:
parsec >= 2.1.0 && < 4,
- time >= 1.0 && < 1.3
+ time >= 1.0 && < 1.3,
+ strict >= 0.3 && < 1.0,
+ directory >= 1.0 && < 2.0
if flag(splitBase)
build-depends:

0 comments on commit ef9abd7

Please sign in to comment.
Something went wrong with that request. Please try again.