chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] iup cells draw callback


From: Martin DeMello
Subject: Re: [Chicken-users] iup cells draw callback
Date: Sun, 15 Nov 2015 01:49:57 -0800

Couple of weird problems with the code:

1. It works sometimes, and sometimes it just displays a grey grid, as though the draw callback didn't do anything (though it gets called, because the debug text does print out)

2. As per the debug printf, something odd happens to the xmin parameter, though passing it back to canvas-box! works fine.

(display (list i j xmin xmax ymin ymax canvas)) prints out

(8 1 75263102 50 17 67 #<tagged pointer cdCanvas 277bd80>

Code  below:

$ cat chess.scm 
(use iup)
(use canvas-draw)
(import canvas-draw-iup)

(define (nlines self) 8)
(define (ncols self) 8)
(define (height self line) 50)
(define (width self col) 50)

(define (draw self i j xmin xmax ymin ymax canvas)
  (when (and (= i 8) (= j 1))
    (display (list i j xmin xmax ymin ymax canvas)))
  (if (= (modulo (+ i j) 2) 0)
    (canvas-foreground-set! canvas #xFFFFFF)
    (canvas-foreground-set! canvas #x000000))
  (canvas-box! canvas xmin xmax ymin ymax))

(define dlg
  (dialog
    (vbox
      (cells name: "chessboard"
             height-cb: height
             width-cb: width
             nlines-cb: nlines
             draw-cb: (make-cells-draw-cb draw)
             ncols-cb: ncols)
      (button title: 'E&xit
              expand: 'Yes
              tip: "Close button"
              action: (lambda (self) 'close)))
    title: 'IUP))

(show dlg)
(main-loop)
(destroy! dlg)
(exit 0)


On Sat, Nov 7, 2015 at 2:58 PM, Martin DeMello <address@hidden> wrote:
Finally had time to finish this off. It needed one more change (pointer->canvas was not being reexported from canvas-draw).

Let me know when you've pushed the new egg, and I'll add the chessboard example to the tutorial in the wiki.

martin

On Wed, Oct 14, 2015 at 11:00 PM, Thomas Chust <address@hidden> wrote:
On 2015-10-15 04:04, Martin DeMello wrote:
> [...]
> it looks like the cb-draw callback has format "iiiiiiC", which doesn't
> match the sigil regex. I take it that means callbacks with a Canvas*
> argument are unsupported in chicken-iup?
> [...]

Hello Martin,

that is correct, however support is trivial to add: Add the #\C
character to the regular _expression_ for callback signatures, add a case
for #\C typed arguments in the dispatcher that treats them identically
to #\v typed arguments, use pointer->canvas from the canvas-draw egg in
your callback code to add the right type tags to the raw pointer.

I think that the #\C signature character has been introduced recently in
IUP. Anyway, I added the necessary marshalling code as outlined above to
the iup egg, it is available in the trunk version of the code.

Ciao,
Thomas


--
When C++ is your hammer, every problem looks like your thumb.

_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]