Re: [racket-users] Want to change Racket GUI application title (on the taskbar)

2020-11-23 Thread KOKOU AFIDEGNON
can you check on* frame%* *label* ?

On Mon, Nov 23, 2020 at 6:25 AM JavaCommons  wrote:

> When I build Racket (scheme) GUI application like this:
>
> raco exe --gui gui-01.rkt
>
> Windows taksbar displays the name of the application as "Racket GUI
> application". I want to change this name to something like "My GUI
> Program". Is this possible?
>
> [image: 無題.png]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/8a775b49-8bb3-4ffb-95b4-09d43ffcc637n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGcmBVUDZhQS3yMozXG_30qs1tyeT90gcxkRfCfMHjCpEb2irw%40mail.gmail.com.


[racket-users] building a GUI rectangle builder: I have a little bug.

2020-11-23 Thread KOKOU AFIDEGNON
I can click to drag in order to draw a rectangle, but when i drag the
created rectangle (for position adjustment), a new rectangle is created
from the said position. How do i constrain/fix the issue? i have been
trying to use key-combination to draw a new rectangle on demand. can you
please give a hint?
```
#lang racket
(require racket/gui racket/draw pict)




(define my-pasteboard (class* pasteboard% ()
(init)
(super-new)
(define/override (on-default-event evt)
 (new-rect evt



(define board (new pasteboard%))
(define toplevel (new frame%
  [label "My board"]
  [width 500]
  [height 500]))

(define canvas (new editor-canvas%
[parent toplevel]
[editor board]))
(send toplevel show #t)

(define my-snip-class
  (new (class snip-class%
 (super-new)
 (send this set-classname "my-snip"

(send (get-the-snip-class-list) add my-snip-class)

(define rectangle-snip%
  (class snip%
(init-field w h)
(super-new)
(send this set-snipclass my-snip-class)
(define/override (get-extent dc x y width height . other)
  (when width (set-box! width w))
  (when height (set-box! height h)))
(define/override (draw dc x y . other)
  (draw-pict (rectangle w h) dc x y


(define (new-rect) (send my-pasteboard insert (new rectangle-snip% [w 30]
[h 80]) 100 300))
```

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGcmBVWOkibP%2BFnmrY9X-FDTmjfxMZQFXwHTzCqzguhb8RZwOw%40mail.gmail.com.


Re: [racket-users] Want to change Racket GUI application title (on the taskbar)

2020-11-23 Thread JavaCommons
The big problem is when you distribute several racket gui applications as 
executables, the user cannnot distinguish applications (he does not know 
which application (icon) to click on the taskbar).

2020年11月23日月曜日 18:30:20 UTC+9 kokou.a...@gmail.com:

> can you check on* frame%* *label* ?
>
> On Mon, Nov 23, 2020 at 6:25 AM JavaCommons  wrote:
>
>> When I build Racket (scheme) GUI application like this:
>>
>> raco exe --gui gui-01.rkt
>>
>> Windows taksbar displays the name of the application as "Racket GUI 
>> application". I want to change this name to something like "My GUI 
>> Program". Is this possible?
>>
>> [image: 無題.png]
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/8a775b49-8bb3-4ffb-95b4-09d43ffcc637n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/57bbc1f6-d1c7-40cf-b47e-dafc8a6440e2n%40googlegroups.com.


[racket-users] Re: building a GUI rectangle builder: I have a little bug.

2020-11-23 Thread KOKOU AFIDEGNON
please disregard the previous code. this si the correct code

```
#lang racket/gui

(define (maybe-set-box! b v)
  (when b
(set-box! b v)))



(define rect-snip-class%
  (class snip-class%
(inherit set-classname)
(super-new)

(set-classname "rect-snip-class%")
))


(define rect-snip-class (new rect-snip-class%))

(define rect-snip%
  (class snip%
(inherit set-snipclass
 set-flags get-flags
 get-admin)
(init w h)
(super-new)
(set-snipclass rect-snip-class)
(define height h)
(define width w)

(define/override (get-extent dc x y [w #f] [h #f] . _)
  (maybe-set-box! w width)
  (maybe-set-box! h height))

(define/override (draw dc x y left top right bottom . _)
  (send dc draw-rectangle x y width height))
))



(define pb
  (new
   (class pasteboard%
 (super-new)
 (inherit insert)

 (define start-pos #f)

 (define/override (on-default-event event)
   (super on-default-event event)
   (define x (send event get-x))
   (define y (send event get-y))
   (cond
 [(and (equal? (send event get-event-type) 'left-down)
   (send event button-down? 'left)
   (not (send event dragging?)))
  (set! start-pos (cons x y))]
 [(and (equal? (send event get-event-type) 'left-up)
   start-pos)
  (let ([dx (- (car start-pos) x)]
[dy (- (cdr start-pos) y)])
(define-values (nx nw)
  (if (> dx 0)
  (values x dx)
  (values (+ x dx) (abs dx
(define-values (ny nh)
  (if (> dy 0)
  (values y dy)
  (values (+ y dy) (abs dy
(define sn (new rect-snip%
[w nw]
[h nh]))
(insert sn nx ny)
(set! start-pos #f))]))


 )))

(define f-main (new frame% [label "wireframe"]))
(define cnv-main (new editor-canvas%
  [editor pb]
  [parent f-main]))


(send f-main show #t)
```

On Mon, Nov 23, 2020 at 9:43 AM KOKOU AFIDEGNON 
wrote:

> I can click to drag in order to draw a rectangle, but when i drag the
> created rectangle (for position adjustment), a new rectangle is created
> from the said position. How do i constrain/fix the issue? i have been
> trying to use key-combination to draw a new rectangle on demand. can you
> please give a hint?
> ```
> #lang racket
> (require racket/gui racket/draw pict)
>
>
>
>
> (define my-pasteboard (class* pasteboard% ()
> (init)
> (super-new)
> (define/override (on-default-event evt)
>  (new-rect evt
>
>
>
> (define board (new pasteboard%))
> (define toplevel (new frame%
>   [label "My board"]
>   [width 500]
>   [height 500]))
>
> (define canvas (new editor-canvas%
> [parent toplevel]
> [editor board]))
> (send toplevel show #t)
>
> (define my-snip-class
>   (new (class snip-class%
>  (super-new)
>  (send this set-classname "my-snip"
>
> (send (get-the-snip-class-list) add my-snip-class)
>
> (define rectangle-snip%
>   (class snip%
> (init-field w h)
> (super-new)
> (send this set-snipclass my-snip-class)
> (define/override (get-extent dc x y width height . other)
>   (when width (set-box! width w))
>   (when height (set-box! height h)))
> (define/override (draw dc x y . other)
>   (draw-pict (rectangle w h) dc x y
>
>
> (define (new-rect) (send my-pasteboard insert (new rectangle-snip% [w 30]
> [h 80]) 100 300))
> ```
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGcmBVWuESZp_C800ANz17biq1mnsWjJobHM15AHtCkjrc59Ag%40mail.gmail.com.


[racket-users] EDIT: Building a rectangle builder: trailing rectangle bug.

2020-11-23 Thread KOKOU AFIDEGNON
*please, disregard the previous email, there was a little bug. this is the
correct code. the issue still exists. *

I can click to drag in order to draw a rectangle, but when i drag the
created rectangle (for position adjustment), a new rectangle is created
from the said position. How do i constrain/fix the issue? i have been
trying to use key-combination to draw a new rectangle on demand. How do i
fix it ?

```
#lang racket/gui

(define (maybe-set-box! b v)
  (when b
(set-box! b v)))



(define rect-snip-class%
  (class snip-class%
(inherit set-classname)
(super-new)

(set-classname "rect-snip-class%")
))


(define rect-snip-class (new rect-snip-class%))

(define rect-snip%
  (class snip%
(inherit set-snipclass
 set-flags get-flags
 get-admin)
(init w h)
(super-new)
(set-snipclass rect-snip-class)
(define height h)
(define width w)

(define/override (get-extent dc x y [w #f] [h #f] . _)
  (maybe-set-box! w width)
  (maybe-set-box! h height))

(define/override (draw dc x y left top right bottom . _)
  (send dc draw-rectangle x y width height))
))



(define pb
  (new
   (class pasteboard%
 (super-new)
 (inherit insert)

 (define start-pos #f)

 (define/override (on-default-event event)
   (super on-default-event event)
   (define x (send event get-x))
   (define y (send event get-y))
   (cond
 [(and (equal? (send event get-event-type) 'left-down)
   (send event button-down? 'left)
   (not (send event dragging?)))
  (set! start-pos (cons x y))]
 [(and (equal? (send event get-event-type) 'left-up)
   start-pos)
  (let ([dx (- (car start-pos) x)]
[dy (- (cdr start-pos) y)])
(define-values (nx nw)
  (if (> dx 0)
  (values x dx)
  (values (+ x dx) (abs dx
(define-values (ny nh)
  (if (> dy 0)
  (values y dy)
  (values (+ y dy) (abs dy
(define sn (new rect-snip%
[w nw]
[h nh]))
(insert sn nx ny)
(set! start-pos #f))]))


 )))

(define f-main (new frame% [label "wireframe"]))
(define cnv-main (new editor-canvas%
  [editor pb]
  [parent f-main]))


(send f-main show #t)
```

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGcmBVVWXxnAYqYt49O-JmW-AZYP-vMYyHeXrRPRa7%3DWRDY46w%40mail.gmail.com.


Re: [racket-users] Questions

2020-11-23 Thread Matthew Flatt
At Mon, 23 Nov 2020 00:14:56 -0600, Nate Griswold wrote:
> Hello. I have a few questions:
> 
> 1) Why do the docs say that racket_eval and racket_apply eval and apply in
> the “initial” or “original” racket thread? I have verified that the thread
> id returned from pthread_self when using racket_apply in c code called from
> a racket place is different from the thread id of the thread i called
> racket_boot on.

The `racket_apply` function was intended for use only in the OS thread
where Racket is booted, and only "outside" to get Racket started. It's
not intended for use in callbacks from Racket.

That's generally true for functions listed in sections 4-6 of "Inside",
and I see that the intent is not remotely clear there. I'll improve the
documentation.

To call back to Racket from C code, you should use the Racket FFI,
where a Racket function that's passed to C gets converted to a function
pointer for the C side. When you call that callback (as a regular C
function call), various bits of Scheme and Racket state get
configured/restored in a consistent way before jumping to the wrapped
Racket code as a callback.

For simple things, it turns out that `Scall0`, etc. would work to
invoke a callback within the Racket context that had called into C, but
there are many pitfalls, so you shouldn't do that.

You definitely should not use `racket_apply` or `racket_eval` from C
that was called from Racket. It will... well, do something. Take the
uncertainly of using `Scall0` and multiply by 100, since functions like
`racket_apply` specifically attempt to interact with the thread
scheduler.

> 2) I noticed that if i racket_eval in c code called by a racket place, i
> can’t evaluate things that would otherwise (in racket code) be available in
> the place’s namespace. What is the correct way to get at things in the
> place’s racket namespace from c code? Is my problem unique to using a
> place, or would i have this problem in a non-place scenario as well?

I think it's probably not just about places, but let me answer the
"correct way" question with the next bullet.

> 3) (related to 2) I want to be able to put and get from a place channel
> from a long-running c function. If i just pass a place channel to the
> function, that is wrong because if i am correct in my thinking (and in what
> i have witnessed) there is a chance that when i go to use that channel in
> the future, it will have been moved by the garbage collector. Is there any
> way to prevent a specific value from being garbage collected, at least for
> the lifetime of my place? This is related to (2) because i actually don’t
> need this functionality if i can just racket_eval to get at the place
> channel from the namespace of the place’s module in the middle of a
> Sactivate_thread / Sdeactivate_thread session.

The best approach here is to hand the C code a callback, which it will
see as plain old C functions. Maybe there's one callback to get from
the channel and another to put to the channel --- where the channel is
in the closure of the function, although the C side has no idea about
closures. If you go that route, then as long as you retain a reference
to the callback closure on the Racket side, the callback function
itself won't move.

Overall, reasoning about the interaction between Racket/Scheme and C
interaction from the C side is very difficult. The more you can arrange
for the C code to oblivious to Racket, the easier things get, because
the Racket-side tools for interacting with C are much better.

> 3) Is there any way to pass a c callback function into racket so that
> racket can call that function? I defined a ctype for the function, but i
> couldn’t think of a way to cast a pointer value passed into racket from c
> to an instance of my ctype (the `cast` function takes existing ctypes and
> not numeric values). Is there any way to manually make a value for my
> function ctype using an existing pointer value?

You can cast from a numeric value by casting from `_intptr` to a
pointer type. For example, this expression creates a function that
tries to jump to address 16 (and crashes, but in gdb you'd see it
crashing with the instruction pointer at address 16):

   (cast 16 _intptr (_fun -> _void))


Matthew

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20201123060111.3b5%40sirmail.smtps.cs.utah.edu.


Re: [racket-users] Re: Copy keybinding in DrRacket not working

2020-11-23 Thread Laurent
On Sun, Nov 22, 2020 at 7:45 PM Dimaugh Silvestris <
dimaughsilvest...@gmail.com> wrote:

> So I tried adding a custom keybinding using c:c, and now when I open
> DrRacket, I get the error:
> < /home/dimaugh/prog/rkt/keybindings.rkt:
> map-function in keymap%: "c:c" is already mapped as a non-prefix key>>
>

This seems like there was another keybinding with the *prefix* c:c (say
c:c;c:x for example).

In the search bar of Edit->Keybindings->Show Active Keybindings, type
"c:c", maybe you'll see several entries matching this prefix.

If not, I don't know :)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABNTSaEgFQrs9mfjN%2B_4TDgkLErKoPgEQ34wDx%2B%3Dy6qebHb9HQ%40mail.gmail.com.


Re: [racket-users] Re: Copy keybinding in DrRacket not working

2020-11-23 Thread Dimaugh Silvestris
No, as I said in the first mail, I hadn't added any custom keybindings 
before and so I only had the DrRacket default keybindings, and c:c only 
showed the keybinding for Copy, though it didn't work.
Really odd.

On Monday, 23 November 2020 at 14:53:03 UTC+1 laurent...@gmail.com wrote:

> On Sun, Nov 22, 2020 at 7:45 PM Dimaugh Silvestris  
> wrote:
>
>> So I tried adding a custom keybinding using c:c, and now when I open 
>> DrRacket, I get the error:
>> <> /home/dimaugh/prog/rkt/keybindings.rkt:
>> map-function in keymap%: "c:c" is already mapped as a non-prefix key>>
>>
>
> This seems like there was another keybinding with the *prefix* c:c (say 
> c:c;c:x for example).
>
> In the search bar of Edit->Keybindings->Show Active Keybindings, type 
> "c:c", maybe you'll see several entries matching this prefix.
>
> If not, I don't know :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/16e98f60-46b3-449c-967f-fb74aa394467n%40googlegroups.com.


[racket-users] Re: Want to change Racket GUI application title (on the taskbar)

2020-11-23 Thread JavaCommons


electron/rcedit solved the problem. With this solution, taskmanager's 
display also became "My GUI Program".

https://github.com/electron/rcedit/releases/tag/v1.1.1

[for 32bit racket] rcedit-x86.exe gui-01.exe --set-version-string 
FileDescription "My GUI Program"

[for 64bit racket] rcedit-x64.exe gui-01.exe --set-version-string 
FileDescription "My GUI Program"

2020年11月23日月曜日 15:25:10 UTC+9 JavaCommons:

> When I build Racket (scheme) GUI application like this:
>
> raco exe --gui gui-01.rkt
>
> Windows taksbar displays the name of the application as "Racket GUI 
> application". I want to change this name to something like "My GUI 
> Program". Is this possible?
>
> [image: 無題.png]
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a1c215e5-6cbb-4b04-8d65-de6b54d0f0dan%40googlegroups.com.


Re: [racket-users] Re: Want to change Racket GUI application title (on the taskbar)

2020-11-23 Thread Stephen De Gabrielle
Hi

I think you can use 'gracket-launcher-names' to set a distinct name
https://docs.racket-lang.org/raco/setup-info.html?q=gracket-launcher-names#%28idx._%28gentag._18._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29

I think that is how it is done for the plt-games executable
https://github.com/racket/games/blob/master/info.rkt

It also set an icon

I think you can also use --ico ‹.ico-path› to set a distinct icon of you own

I'm not a windows user but I'm guessing;

raco exe --gui --ico ‹.ico-path› hello.rkt

https://docs.racket-lang.org/raco/exe.html

I'm sorry I don't have a windows machine so I can't test this.

Kind regards

Stephen




On Mon, Nov 23, 2020 at 4:05 PM JavaCommons  wrote:

> electron/rcedit solved the problem. With this solution, taskmanager's
> display also became "My GUI Program".
>
> https://github.com/electron/rcedit/releases/tag/v1.1.1
>
> [for 32bit racket] rcedit-x86.exe gui-01.exe --set-version-string
> FileDescription "My GUI Program"
>
> [for 64bit racket] rcedit-x64.exe gui-01.exe --set-version-string
> FileDescription "My GUI Program"
>
> 2020年11月23日月曜日 15:25:10 UTC+9 JavaCommons:
>
>> When I build Racket (scheme) GUI application like this:
>>
>> raco exe --gui gui-01.rkt
>>
>> Windows taksbar displays the name of the application as "Racket GUI
>> application". I want to change this name to something like "My GUI
>> Program". Is this possible?
>>
>> [image: 無題.png]
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/a1c215e5-6cbb-4b04-8d65-de6b54d0f0dan%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGHj7-J_iWJ%3D3U8P%2B4rw%3Dq_DPOzCS%2BKj9hnPiKO%2BieFWsdVkFA%40mail.gmail.com.


[racket-users] Re: EDIT: Building a rectangle builder: trailing rectangle bug.

2020-11-23 Thread Alex Harsanyi
The snip selection and resize is handled by the pasteboard 
on-default-event, and it looks like your code also handles events, 
resulting in duplicate handling.   There is no clear solution to this, as 
the system does not know if you want to select snips or draw rectangles.  
 However, you could use Ctrl + drag to draw the rectangles.  To do that, 
move your own code into a new method, say "my-on-default-event" and call 
that method for mouse events which have the control key set.

 (define/override (on-default-event event)
   (if (send event get-control-down)
   (on-default-event-1 event)
   (super on-default-event event)))

The disadvantage now, is that there is no visual feedback when you use Ctrl 
+ drag (previously, the selection rectangle was drawn).  To draw an 
intermediate selection rectangle, you can track mouse motion events in your 
"my-on-default-event" and keep the intermediate rectangle, same as you do 
for "start-pos", than override the "on-paint" method of the pasteboard to 
draw the intermediate rectangle.  Note that you cannot call on-paint 
directly from on-default-event, and the pasteboard does not know it needs 
to redraw itself unless you call "refresh".

Alex.

On Monday, November 23, 2020 at 7:49:00 PM UTC+8 kokou.a...@gmail.com wrote:

>
>
>
>
> *please, disregard the previous email, there was a little bug. this is the 
> correct code. the issue still exists. *
>
> I can click to drag in order to draw a rectangle, but when i drag the 
> created rectangle (for position adjustment), a new rectangle is created 
> from the said position. How do i constrain/fix the issue? i have been 
> trying to use key-combination to draw a new rectangle on demand. How do i 
> fix it ? 
>
> ```
> #lang racket/gui
>
> (define (maybe-set-box! b v)
>   (when b
> (set-box! b v)))
>
>
>
> (define rect-snip-class%
>   (class snip-class%
> (inherit set-classname)
> (super-new)
>
> (set-classname "rect-snip-class%")
> ))
>
>
> (define rect-snip-class (new rect-snip-class%))
>
> (define rect-snip%
>   (class snip%
> (inherit set-snipclass
>  set-flags get-flags
>  get-admin)
> (init w h)
> (super-new)
> (set-snipclass rect-snip-class)
> (define height h)
> (define width w)
>
> (define/override (get-extent dc x y [w #f] [h #f] . _)
>   (maybe-set-box! w width)
>   (maybe-set-box! h height))
>
> (define/override (draw dc x y left top right bottom . _)
>   (send dc draw-rectangle x y width height))
> ))
>
>
>
> (define pb
>   (new
>(class pasteboard%
>  (super-new)
>  (inherit insert)
>
>  (define start-pos #f)
>
>  (define/override (on-default-event event)
>(super on-default-event event)
>(define x (send event get-x))
>(define y (send event get-y))
>(cond
>  [(and (equal? (send event get-event-type) 'left-down)
>(send event button-down? 'left)
>(not (send event dragging?)))
>   (set! start-pos (cons x y))]
>  [(and (equal? (send event get-event-type) 'left-up)
>start-pos)
>   (let ([dx (- (car start-pos) x)]
> [dy (- (cdr start-pos) y)])
> (define-values (nx nw)
>   (if (> dx 0)
>   (values x dx)
>   (values (+ x dx) (abs dx
> (define-values (ny nh)
>   (if (> dy 0)
>   (values y dy)
>   (values (+ y dy) (abs dy
> (define sn (new rect-snip%
> [w nw]
> [h nh]))
> (insert sn nx ny)
> (set! start-pos #f))]))
>
>
>  )))
>
> (define f-main (new frame% [label "wireframe"]))
> (define cnv-main (new editor-canvas%
>   [editor pb]
>   [parent f-main]))
>
>
> (send f-main show #t)
> ```
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c1da5a4e-730f-43ec-8d53-c6e223225b0an%40googlegroups.com.


[racket-users] SRFI 201 and 202: a reference implelmentation and an invitation to discussion

2020-11-23 Thread godek....@gmail.com

Hi,
A while ago I proposed a few SRFIs, in particular
https://srfi.schemers.org/srfi-201, which provides extensions to core 
bindings (define, lambda, let, let*, or)
https://srfi.schemers.org/srfi-201, which extends SRFI 2 with the 
capability of pattern matching

Recently, with a second draft, I have added their implementations for 
Racket to SRFI repos:
https://github.com/scheme-requests-for-implementation/srfi-201/
https://github.com/scheme-requests-for-implementation/srfi-202/

I'd like to invite everyone to participate in the discussion, and if it 
concludes well, to include the implementation with the distribution


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b08ac87f-35ad-4f06-b36c-5da1f75a0ab1n%40googlegroups.com.


Re: [racket-users] Re: EDIT: Building a rectangle builder: trailing rectangle bug.

2020-11-23 Thread KOKOU AFIDEGNON
Hi Alex, thanks for your reply. Are you on Slack?

On Tue, Nov 24, 2020, 00:21 Alex Harsanyi  wrote:

> The snip selection and resize is handled by the pasteboard
> on-default-event, and it looks like your code also handles events,
> resulting in duplicate handling.   There is no clear solution to this, as
> the system does not know if you want to select snips or draw rectangles.
>  However, you could use Ctrl + drag to draw the rectangles.  To do that,
> move your own code into a new method, say "my-on-default-event" and call
> that method for mouse events which have the control key set.
>
>  (define/override (on-default-event event)
>(if (send event get-control-down)
>(on-default-event-1 event)
>(super on-default-event event)))
>
> The disadvantage now, is that there is no visual feedback when you use
> Ctrl + drag (previously, the selection rectangle was drawn).  To draw an
> intermediate selection rectangle, you can track mouse motion events in your
> "my-on-default-event" and keep the intermediate rectangle, same as you do
> for "start-pos", than override the "on-paint" method of the pasteboard to
> draw the intermediate rectangle.  Note that you cannot call on-paint
> directly from on-default-event, and the pasteboard does not know it needs
> to redraw itself unless you call "refresh".
>
> Alex.
>
> On Monday, November 23, 2020 at 7:49:00 PM UTC+8 kokou.a...@gmail.com
> wrote:
>
>>
>>
>>
>>
>> *please, disregard the previous email, there was a little bug. this is
>> the correct code. the issue still exists. *
>>
>> I can click to drag in order to draw a rectangle, but when i drag the
>> created rectangle (for position adjustment), a new rectangle is created
>> from the said position. How do i constrain/fix the issue? i have been
>> trying to use key-combination to draw a new rectangle on demand. How do i
>> fix it ?
>>
>> ```
>> #lang racket/gui
>>
>> (define (maybe-set-box! b v)
>>   (when b
>> (set-box! b v)))
>>
>>
>>
>> (define rect-snip-class%
>>   (class snip-class%
>> (inherit set-classname)
>> (super-new)
>>
>> (set-classname "rect-snip-class%")
>> ))
>>
>>
>> (define rect-snip-class (new rect-snip-class%))
>>
>> (define rect-snip%
>>   (class snip%
>> (inherit set-snipclass
>>  set-flags get-flags
>>  get-admin)
>> (init w h)
>> (super-new)
>> (set-snipclass rect-snip-class)
>> (define height h)
>> (define width w)
>>
>> (define/override (get-extent dc x y [w #f] [h #f] . _)
>>   (maybe-set-box! w width)
>>   (maybe-set-box! h height))
>>
>> (define/override (draw dc x y left top right bottom . _)
>>   (send dc draw-rectangle x y width height))
>> ))
>>
>>
>>
>> (define pb
>>   (new
>>(class pasteboard%
>>  (super-new)
>>  (inherit insert)
>>
>>  (define start-pos #f)
>>
>>  (define/override (on-default-event event)
>>(super on-default-event event)
>>(define x (send event get-x))
>>(define y (send event get-y))
>>(cond
>>  [(and (equal? (send event get-event-type) 'left-down)
>>(send event button-down? 'left)
>>(not (send event dragging?)))
>>   (set! start-pos (cons x y))]
>>  [(and (equal? (send event get-event-type) 'left-up)
>>start-pos)
>>   (let ([dx (- (car start-pos) x)]
>> [dy (- (cdr start-pos) y)])
>> (define-values (nx nw)
>>   (if (> dx 0)
>>   (values x dx)
>>   (values (+ x dx) (abs dx
>> (define-values (ny nh)
>>   (if (> dy 0)
>>   (values y dy)
>>   (values (+ y dy) (abs dy
>> (define sn (new rect-snip%
>> [w nw]
>> [h nh]))
>> (insert sn nx ny)
>> (set! start-pos #f))]))
>>
>>
>>  )))
>>
>> (define f-main (new frame% [label "wireframe"]))
>> (define cnv-main (new editor-canvas%
>>   [editor pb]
>>   [parent f-main]))
>>
>>
>> (send f-main show #t)
>> ```
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/c1da5a4e-730f-43ec-8d53-c6e223225b0an%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
http

[racket-users] Apple M1

2020-11-23 Thread Zachary Rippas
Does anyone know when/if a download version of racket will be released that 
supports Apple's new chip? I am using an M1 laptop and can't launch any 
intel version of racket; it says quit unexpectedly.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/619e8e24-a75c-4e9c-b172-d19a2892145cn%40googlegroups.com.