[comp.sys.mac.hypercard] "line height and auto wraparound"

detert@s.cs.uiuc.edu (06/13/89)

Is it possible for a script to determine whether a given string, containing no
carriage returns, can be placed in a particular field (window) and have each 
char. of the string be immediately visible?  

The problem is that i have fields that have a fixed width, but can vary in
height, and i don't want them to be any taller than necessary to reveal
the entire string that they hold.  So, i need a way to figure out how many
"lines" of the particular field are necessary to encompass the entire string.
NOTE:  by "line" i don't mean the HyperTalk conception of strings separated by
carriage returns, but instead a horizontal slice of the particular field 
having height equal to the height in pixels of the particular font/size comb-
ination of text.

I'm fairly sure that HyperTalk offers no solution or work-around.  I know
almost nothing about XCMDs and XFCNs.  
I would appreciate any advice on the problem.
Thank You,
Jon Detert.   detert@s.cs.uiuc.edu

Barry.Chern@f200.n226.z1.FIDONET.ORG (Barry Chern) (06/17/89)

I know that there is an XCMD I have seen recently that gives the length in 
pixels for any given string, but my collection is so unruly at the moment
that I can't identify it offhand. If I don't see any other replies to you
by the time I find it (if I do) I'll get back to you with more info.


--  
Barry Chern via cmhGate - Net 226 fido<=>uucp gateway Col, OH
UUCP: ...!osu-cis!n8emr!cmhgate!200!Barry.Chern
INET: Barry.Chern@f200.n226.z1.FIDONET.ORG

aisl@uhura.cc.rochester.edu (Lawrence Landry) (06/21/89)

In article <214100003@s.cs.uiuc.edu> detert@s.cs.uiuc.edu writes:
>
>
>Is it possible for a script to determine whether a given string, containing no
>carriage returns, can be placed in a particular field (window) and have each 
>char. of the string be immediately visible?  
>

I haven't actually tried this but something like the following may work with
a little bit of effort.

1) Shift-click at the end of the text to place the cursor either at the
   end of the text or to select all of the text from here to the end of the
   text.
2) Use one of the new functions of HC 1.2 that allow you to find what
   has been selected (ie. selectedChunk).  If you are at the end of the text
   (ie. it is all visible) the selection should be empty.  If not, it will
   be something like char 25 to 28 of bg fld "temp"

Hope it helps,
Larry Landry
University of Rochester
-- 
Larry Landry
University of Rochester

paul@torch.UUCP (Paul Andrews) (06/23/89)

detert@s.cs.uiuc.edu writes:



>Is it possible for a script to determine whether a given string, containing no
>carriage returns, can be placed in a particular field (window) and have each 
>char. of the string be immediately visible?  

Well, sort of. It is possible to determine whether the string fits AFTER you
have placed it in the field (you could then remove it of course). You do
something like the following:

1) put the text in the field.

2) Determine the height and textheight of the field

3) sit in a loop starting at the bottom of the field and working up to the
top in jumps of the textheight.

4) In the loop 'click at x,y' (y being the variable decremented by textheight)

5) 'get the selectedline'.

6) Until the selectedline changes, you are in the same 'Hypercard line' even
though you are in a different screen line.

This may not be a direct answer to your question, and it is certainly not
a complete algorithm but you should be able to use the same general method.

This is not a wonderfully clean way of doing what you want, but if its
absolutley essential, what choice do you have?

- Paul.