[WASTE-list] Re: Zoom factor
Marco Piovanelli
marco.piovanelli at pobox.com
Mon Oct 30 09:33:56 EST 2006
On Fri, 20 Oct 2006 16:51:29 -0500,
Dan Korn (dkorn at printable.com) wrote:
>Does anyone have any ideas on how to implement a zoom factor in
>WASTE, like the EM_SETZOOM message for a Rich Edit control?
>
>I found this old thread:
> http://www.merzwaren.com/waste/listarchive2000/58869.html
>
>But I didn't find it very helpful.
>
>I don't see anything built into WASTE to support a zoom factor. I'm
>using a customized version of the WText/CWasteEdit PowerPlant
>wrappers. So I'm thinking about two possibilities:
>
>1. Include the zoom factor in my calculations that convert points to
>Fixed points for point size, leading, etc., when I call
>WESetAttributes. This will certainly work, but when the user changes
>the zoom factor, I'll have to get all the text, apply the new sizes
>to it, and then set it again, which will certainly be slow.
>
>2. Get the GrafPort into which WASTE is drawing and apply a
>transformation and clipping to it. This should be fast, but I'm not
>sure if it will mess up WASTE's internals. And it's more work.
>
>Any other ideas?
While so far WASTE 3.0 doesn't have built-in support for a zoom
factor, either, I think it would make both of the approaches you
suggest above easier to implement. Let me try and explain why.
Option #1.
First of all, WASTE 3.0 uses a floating-point geometry internally,
and stores font sizes, vertical shifts, embedded object rectangles,
etc., in floating-point format, so scaling can be performed with
minimal rounding errors. Secondly, WASTE 3.0 has a concept of
"display" styles as distinct from "stored" styles.
"Stored styles" represent collections of attributes associated
with certain text ranges. The text model maintains a single,
shared copy of each unique collection in its style table.
"Display styles" are ATSUStyle objects generated dynamically,
on-demand, when a range of text needs to be laid out or rendered
into a Core Graphics context. There's a well-defined bottleneck
that creates a display style from a stored style. If you customize
this bottleneck (by overring a virtual function), you can easily
scale the font size on a per-layout basis, without affecting the
underlying model at all.
Option #2.
WASTE 3.0 draws everything using Core Graphics, and Core Graphics
makes it easy to apply arbitrary affine transforms to a drawing
context, something that would be hard or impossible to do in a
Quickdraw world.
Granted, both approaches would require the source code (at least
until built-in zooming is implemented), but likely less work than
grafting zooming support onto WASTE 2.1.
-- marco
--
It's not the data universe only, it's human conversation.
They want to turn it into a one-way flow that they have entirely
monetized. I look at the collective human mind as a kind of
ecosystem. They want to clear cut it. They want to go into the
rainforest of human thought and mow the thing down.
More information about the WASTE-list
mailing list