Re: ScreenSaverView with multiple displays
Re: ScreenSaverView with multiple displays
- Subject: Re: ScreenSaverView with multiple displays
- From: Steve Christensen <email@hidden>
- Date: Wed, 29 Dec 2004 16:19:02 -0800
How about something like this?
1. Add a BOOL _isMenuBarDisplay to your screensaver view class.
2. Override -initWithFrame: and -initWithFrame:isPreview:.
In each, call the super's method, then
if -isPreview, set _isMenuBarDisplay to true, else check if
frameRect has
the same bounds as the main screen and set _isMenuBarDisplay
accordingly.
3. Override -animateOneFrame (and -drawRect: ?), check
_isMenuBarDisplay and
do the appropriate thing.
This assumes that the view bounds are in global coordinates and are
aligned with individual screens, but this is just a guess since I
haven't yet written a screensaver. :-) If it works, it should get you
away from messy issues like the order in which the views are
initialized.
As for counting the number of screens, how about:
unsigned int screenCount = [[NSScreen screens] count];
And finding the menu bar screen:
- (BOOL) isMenuBarScreen
{
NSArray* listOfScreens = [NSScreen screens];
if ((listOfScreens != nil) && ([listOfScreens count] > 0))
return NSEqualRects([self frame], [listOfScreens objectAtIndex:0]);
return false;
}
steve
On Dec 29, 2004, at 3:09 PM, patrick wrote:
I'm creating a screensaver, and I would like to be able to draw
something different on displays other than the primary. Through trial
and error, I've learned that initWithFrame() gets called for each
display, although it doesn't seem like any useful information is
passed into initWithFrame() or animateOneFrame() to help the developer
know which display is being used.
By using a counter in my ScreenSaverView and incrementing it each time
initWithFrame() is called (where isPreview is false) I am able to
count how many displays there are, and it seems like animateOneFrame()
is called in order of display: animateOneFrame() for display 1,
animateOneFrame() for display 2, and then back to 1 again, etc. So by
using another counter, I can [sort of] keep track of to which display
I'm drawing, though it doesn't seem like that great a way of doing
this, nor does it seem that foolproof.
Does anyone have any suggestions as to a better way of knowing a) how
many displays there are to begin with, and b) a good way in
animateOneFrame() to tell which display is being used?
Many thanks,
Patrick
_______________________________________________
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