Re: Proposed: new support for vertical anchor value of 'baseline in addition to n,s,c





Aric Bills wrote:
It's not a dumb idea, it just needs a TIP and some accompanying source
code.

OK. I am a total tcl/tk noob so not sure how all that works. Can i submit yours? :) Thanks for that, btw.

I am getting ready to do the same transfromation on the Lisp side, where I happen to have a rule-based geometry manager I have been using for years. Pack and grid are great, but I kinda do the same with my system so I am leaning towards place-ing almost everything.

But I will look at doing the TIP anyway, and another to get for font info: maxWidth and leading, internal and external.

thx again, kt



In the meantime, you can accomplish your objective in one of two ways,
exemplified by procs alignAnchorN (for text items anchored n) and
alignAnchorS (for text items anchored s):

proc alignAnchorN {font baselineY} {
return [expr {$baselineY - [font metrics $font -ascent]}]
}

proc alignAnchorS {font baselineY} {
return [expr {$baselineY + [font metrics $font -descent]}]
}


# test code

font create font1 -family {Times New Roman} -size 24
font create font2 -family {Times New Roman} -size 18

set text1 "Text 1"
set text2 "Text 2"

toplevel .test
set c [canvas .test.c]
grid $c -sticky nsew

set baseline 100
$c create line 0 $baseline [winfo reqwidth $c] $baseline
$c create text 0 [alignAnchorN font1 $baseline] \
-anchor nw -font font1 -text $text1
$c create text [font measure font1 $text1] [alignAnchorS font2
$baseline] \
-anchor sw -font font2 -text $text2


--
Cells: http://common-lisp.net/project/cells/

"Have you ever been in a relationship?"
Attorney for Mary Winkler, confessed killer of her
minister husband, when asked if the couple had
marital problems.
.