GUI zoom and normal-control-font

51 views
Skip to first unread message

James Platt

unread,
Aug 18, 2020, 12:31:42 PM8/18/20
to Racket Users
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?

George Neuner

unread,
Aug 18, 2020, 1:16:59 PM8/18/20
to James Platt, racket users

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.

Hope this helps,
George

James Platt

unread,
Aug 19, 2020, 1:38:07 PM8/19/20
to Racket Users
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


George Neuner

unread,
Aug 19, 2020, 8:54:02 PM8/19/20
to James Platt, Racket Users
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

Alex Harsanyi

unread,
Aug 19, 2020, 10:09:08 PM8/19/20
to Racket Users
At least on Windows, users can select the text size in the Windows System Settings,and Racket GUI applications will use that setting.   So I can make the text of the GUI controls bigger or smaller by adjusting this setting.  The Racket GUI have to be restarted though for the settings to take effect -- they don't react dynamically to text size changes.

Of course this is a system level setting and all applications on the machine will use the chosen text size.

Alex.

James Platt

unread,
Aug 20, 2020, 12:18:11 PM8/20/20
to Racket Users

On Aug 19, 2020, at 8:53 PM, George Neuner wrote:

> 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.

I was going by Macintosh terminology where there are two different kinds of zoom. A window zoom is activated, currently, by double clicking on the top bar of a window. Previously, it was the green button on the window bar but that now activates full screen mode. It toggles between the last custom dragged size of the window and a size of its contents. Unfortunately, this has never worked as well in Mac OS X and macOS as well as it did in Classic Mac OS which might be part of the reason they switched the green button to full screen mode. The zoom I want is the one activated by the zoom menu item (or command - / command =). This resizes contents of the window, including text and imagery as well as widgets. I would really like to have the full functionality but, for now, just resizing widgets would be a major improvement.
Reply all
Reply to author
Forward
0 new messages