Calculating screen UI metrics in advance
Calculating screen UI metrics in advance
- Subject: Calculating screen UI metrics in advance
- From: Ken Tabb <email@hidden>
- Date: Fri, 17 Dec 2004 16:22:05 +0000
Hi folks,
is there any way to get screen metrics (eg. the height of an NSPanel's
titlebar (utility window mode, small titlebar)), ahead of actually
creating an instance of the NSPanel?
So for instance I have an NSPanel that I'd like to position initially 8
pixels below the bottom of the menu bar. I create it with
NSUtilityWindowMask, giving me a thin titlebar at the top. I need to
set it's contentRect as part of the init process, yet I need to know
how big it's titlebar is, to factor that into the contentRect's origin.
So what I'm currently doing is:
[1] figure out size of contentRect that I want inside the panel
[2] set the origin of that contentRect, factoring in [[NSScreen
mainScreen] visibleFrame] so that I don't end up behind the dock etc.,
but not factoring in the window's title bar (as I don't know this yet
until the window is init'ed)
[3] init the window with the contentRect from [2]
[4] adjust the window's contentRect's frame down a bit to now factor in
the window's titlebar (which I can determine now the window has been
initialised), so that there is an 8 pixel gap between the top of the
titlebar and the bottom of the menu bar..
I can't help but feel I'm missing something painfully obvious to most
of you, but I'm scratching my head like an idiot (cunning use of the
word "like"...)
With my custom matrix subclasses etc. I've opted to add class methods
such as:
+ (NSSize)cellSizeForControlSize:(NSControlSize)theControlSize;
... just so I can calculate the size of things prior to creation,
without needing to make them first and then adjust them. I wish I could
find NSWindow methods for doing similar ahead-of-creation stuff 8^(
Another great thing would be to be able to calculate the thickness of
the NSButtonCell bezel types (i.e. 1 pixel thick, 2 pixels thick etc.),
as different bezel types invade the frame by different amounts.
I can't believe I'm the first chap to have run into this though, so
guess I must be missing something.
Hope you can help,
Have a Merry Christmas (or equivalent religious festival, if this is
your time of year etc.) from the UK!
Ken
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Developer - Health & Human Sciences
Machine Vision & Neural Network researcher - School of Computer Science
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden