I am a bit clue less
I have reduced to the bare minimum

gr <- graphicsRendererCreateContextFromNativeWindow f
graphicsContextDelete gr

it compiles and segfault…

any ideas ?

mbp2-de-luc:wxcanvastest luc$ ghc --make Paint.hs [1 of 1] Compiling Main ( Paint.hs, Paint.o )
Linking Paint ...
mbp2-de-luc:wxcanvastest luc$ ./Paint Segmentation fault: 11 mbp2-de-luc:wxcanvastest luc$
--------

module Main where

import Graphics.UI.WXCore
import Graphics.UI.WX

main :: IO ()
main
 = start gui

gui :: IO ()
gui
 = do f  <- frame [text := "Paint demo", fullRepaintOnResize := False]
     -- sw <- scrolledWindow f [ on paint := onpaint
-- , virtualSize := sz 500 500, scrollRate := sz 10 10
     --                        , fullRepaintOnResize := False]
      -- dcc <- paintDCCreate sw
      gr <- graphicsRendererCreateContextFromNativeWindow f
-- pa <-graphicsPathCreate -- graphicsPathAddCircle pa (pt 30 30) 20
      -- graphicsPathCloseSubpath pa
      graphicsContextDelete gr
      set f [clientSize := sz 150 150]
--, layout := fill $ widget sw]
      return ()





On 2013-03-25 22:03:55 +0000, Luc TAESCH said:

I tried this so far
which is copied from the basic Paint.hs from the sample.

- it compiles , run and break at run time if I omit Line [1]
gr <- graphicsContextCreate dc -- 1. this break for now

and it does not compile when I leave it on.

My sources are  [1] and [2]

[1]: http://docs.wxwidgets.org/trunk/classwx_graphics_context.html
[2]: http://chandlerproject.org/Projects/WxPythonGraphicsContext  

Ill keep you posted
----------

module Main where

import Graphics.UI.WXCore
import Graphics.UI.WX

main :: IO ()
main
  = start gui

gui :: IO ()
gui
  = do f  <- frame [text := "Paint demo", fullRepaintOnResize := False]
       sw <- scrolledWindow f [ on paint := onpaint
                              , virtualSize := sz 500 500, scrollRate := sz 10 10
                              , fullRepaintOnResize := False]
       
       set f [clientSize := sz 150 150, layout := fill $ widget sw]
       return ()
  where
    onpaint dc viewArea
      = do 
          gr <- graphicsContextCreate dc -- 1. this break for now
                 
                
          pa <-graphicsPathCreate 
          graphicsPathAddCircle pa (pt 30 30) 20
          graphicsPathCloseSubpath pa
          --circle dc (pt 30 30) 20 [penKind := PenSolid]


Paint.hs:13:45:
    Couldn't match expected type `()' with actual type `CWindowDC a0'
    Expected type: DC () -> Rect -> IO ()
      Actual type: WindowDC a0 -> t0 -> IO ()
    In the second argument of `(:=)', namely `onpaint'
    In the expression: on paint := on paint


void MyCanvas::OnPaint(wxPaintEvent &event)
{
    // Create paint DC
    wxPaintDC dc(this);

    // Create graphics context from it
    wxGraphicsContext *gc = wxGraphicsContext::Create( dc );

    if (gc)
    {
        // make a path that contains a circle and some lines
        gc->SetPen( *wxRED_PEN );
        wxGraphicsPath path = gc->CreatePath();
        path.AddCircle( 50.0, 50.0, 50.0 );
        path.MoveToPoint(0.0, 50.0);
        path.AddLineToPoint(100.0, 50.0);
        path.MoveToPoint(50.0, 0.0);
        path.AddLineToPoint(50.0, 100.0 );
        path.CloseSubpath();
        path.AddRectangle(25.0, 25.0, 50.0, 50.0);

        gc->StrokePath(path);

        delete gc;
    }
}

--------------
Luc
be.linkedin.com/in/luctaesch/
Envoyé avec Sparrow

Le lundi 25 mars 2013 à 22:52, Henk-Jan van Tuyl a écrit :
On Mon, 25 Mar 2013 19:00:58 +0100, Luc TAESCH <luc.tae...@gmail.com>
wrote:

ah many thanks ! I understand better now ( change quite a bit since
2003 :-)
I indeed can see the classes .

are these new renderers already mapped into wx, or should we use them as
such , directly ?
any sample / test available , out of chance ?

Many thanks for your patience, anyway :-)

Luc

I can't find any renderer functions in wx, or any samples/tests; I suppose
the best thing to do is to try to translate C++ sample programs to Haskell.

Regards,
Henk-Jan van Tuyl


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--

------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
wxhaskell-devel mailing list
wxhaskell-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-devel

Reply via email to