Window Properties
Window Properties
- Subject: Window Properties
- From: Richard 23 <email@hidden>
- Date: Fri, 10 Nov 2000 23:30:58 -0800
This seems like it should pretty straightfoward, and it probably is,
but for some reason it isn't working out that way:
The script works with Finder windows and batch process dropped folders
by means of the open handler.
Most of settings after processing are known ahead of time (constants)
while others will vary with each window.
So here's what a property in the script is looking like:
property OS9_Window:{
Title Bar: {width:-1, height: 21},
Window_Header: {width:0, height:-1},
Window_Header: {width:0, height:-1}}
Column_Title: {name: {width:190, height:-1}, ... },
Content_Region:{width:-1, height:-1}}
Scroll_Region: {width:15, height:15},
Window_Frame: {width:5, height:5}
}
The formatting is a little fanciful I know, but this stuff looks so
awful without styles that it hopefully makes it less of a headache
to read in email.
What this is is a list of measurements for your basic window in OS9.
A number of sizes are constants, eg, the window frame doesn't vary
with font size or window size, whereas the height of the window header
(item count, space remaining) varies with the font and size chosen in
the Appearance control panel.
Where the value is not known in advance or my script doesn't really
care what the value is, I used -1. So far so good.
I've already done the hard part: figuring out how to calculate the
variables so my script can set each window which is in list view
to show a user defined number of items.
This of course varies with the font.
But I thought it would be useful to plug a reference to the window
being processed into my OS9_Window property so I wouldn't have to
target the Finder directly. Instead I'd query the property for its
contents, which would in turn ask the Finder ... and so on.
With that in mind here's the next step, setting up the references:
property wRef: a reference to window 1 of application "Finder"
property wSize: a reference to wRef's size
An interesting thing happens when you set a property to a reference.
If you query the value of wSize for instance, you get the reference
form, and to get the current value, you use contents, right?
wSize
--> size of window 1 of application "Finder"
wSize's contents
--> {256, 139}
Great. Since the Finder is kind enough to do the math for me I
don't have to mess with bounds, but it doesn't further split it
into width and height, like I did in my script's OS9_Window
property (which is looking more and more like a pseudo object).
I thought it would be easy enough to stick in a couple of references
where I wanted to get the value for the current window and here's
where I got stuck.
Actually for a couple of reasons. The fact that the Finder's window
class doesn't even contain "size" kind of threw me. I'm so used to
using it in FaceSpan I start assuming all windows have that property.
But it worked, although I'm not able to trace back to to where it's
coming from. No matter. Moving on, I checked the class of wSize.
wSize's {class, contents}
--> {point, {256, 139}}
Ok. That's a QuickDraw point, I guess. Although I thought position
was a point, which is different than {height, width}. Another red
herring. When working with a normal list, it's pretty easy:
set theList to {1,2,3,4}
set theRef to a reference to theList's 3rd item
theRef
--> item 3 of {1, 2, 3, 4}
theRef's contents
--> 3
The problem is that a point looks like a list but isn't really a list
(a value whose class = list), so I can't reference items of it:
property wWidth: a reference to wSize's first item
wWidth's contents:
--> Finder got an error: Can't get item 1 of size of window 1.
and coercing it to a list then taking a reference is going down the
wrong path because then you're referencing the list and not window 1
anymore. So when another window becomes window 1, the property isn't
updated.
This isn't a script killer, I can continue without it. It's just that
this type of thing pops up now and again and I don't really recall
finding a satisfactory solution. Maybe there is none.
But someone knows...
Sorry for the length. I have a talent for going into painful detail
about even the smallest of things. The irony is the answer is probably
one or two words, like "no dice."
Speaking of painful detail you won't find much of that on my AppleScript
site but you will find a number of scripts some of which might have just
what you need to complete your day.
Visit me over at
http://homepage.mac.com/richard23/
The site gets lonely on weekends, but monday mornings kick!
R23