On 8/19/2020 1:37 PM, James Platt wrote:
> > On 8/18/2020 12:31 PM, James Platt wrote:
>> I'm looking at implementing a zoom contents (not zoom window) feature in a 
GUI with lots of elements and I'm wondering about the best way to do this.  Most, if 
not all, standard GUI widgets in Racket can be resized by changing the font size of 
their contents or label.   Then redraw the widget and you have the whole thing in a 
new size.  So zoom could be done by creating a function which handles each element 
individually but I would like a more general solution, if possible.  Most widgets use 
the value normal-control-font for their default but it doesn't look like this can be 
changed at present.  If there were a setter for normal-control-font, it looks like 
you could have a menu item change it, then recursively get the children of the frame 
it is attached to and redraw them.  Would this actually work? Is there a better way 
to do it?
> > If you can access (or render) the contents as a 'pict', then it be scaled somewhat arbitrarily (though a scaled version is not guaranteed to look good).
> https://docs.racket-lang.org/pict/Pict_Drawing_Adjusters.html
> > It is a form of BitBLT operation. I would search the docs for "blt" or "blit" in addition to "scale" and "size". Sorry I can't point you more directly to relevant functions: I've done a lot of GUI programming, but, unfortunately, I know it from C++ using device contexts directly, not from using Racket's graphics.

If I understand correctly, I would do that like in the Stackoverflow post 
below.   Note the need for using the bitmap% version of the button label.   The 
advantage of this approach is that you can change the label dynamically with a 
send.  The drawback is that I would have to create a modified version of every 
widget.  I was just hoping for a solution which would not require so much 
customization of a standard Racket package.

https://stackoverflow.com/questions/48414363/how-to-change-the-color-of-text-in-a-racket-gui-button/48468797#48468797

Sorry, it was not clear to me that you wanted to resize widgets (child windows).  Typically when one speaks about a window's "content" they are referring to text or imagery drawn onto the window's backing bitmap.

Basically, you need to push a resize message to every child.  I'm not sure the best way to do that, but my first thought would be something involving panels (or panes).  When a panel gets resized, all its children are resized as well.
https://docs.racket-lang.org/gui/windowing-overview.html#%28part._containeroverview%29
https://docs.racket-lang.org/gui/panel_.html
https://docs.racket-lang.org/gui/pane_.html

The trick is that normally a panel would be sized relative to its parent.  To effect a "zoom" you would have to override that behavior so at least the (Z-stack) bottom panel can be made larger than the application window's viewing area.

George

--
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/65bbe973-c309-1f92-620a-76d4708f32c7%40comcast.net.

Reply via email to