Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
i read something quite vague about what's called and NSHUDWindowMask, and i'd really like to know if it's possible to mask the NSColorPanel? it's unfortunate that i can't include the built-in NSColorPanel to my NIB, where it would be a few clicks to convert the panel to a HUD, so it would have to be done manually... any thoughts?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Generally when you want to get custom window styles in Cocoa that aren't available via a checkbox in IB, you create an NSWindow subclass and override the initWithContentRect:styleMask:backing:defer:screen: method.

However, since NSColorPanel's window is not owned by you or created by you, it'd be tricky to override it. You could probably do it with some reverse engineering though.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
oh that's too bad... but at least now i know why i couldn't get styleMask working on the window... hopefully i can get it to work with the document you sent me... thanks.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I've not tried this an am pretty tired so may not be thinking straight, but could you not do something like this:

Code:
NSColorPanel *cp;
NSPanel *myPanel;

cp = [NSColorPanel sharedColorPanel];
myPanel = [[NSPanel alloc] – initWithContentRect:[cp contentRectForFrame:[cp frame]] styleMask:NSHUDWindowMask backing:NSBackingStoreRetained   defer:YES];  
[myPanel setContentView:[cp contentView]];

I think this should create a new panel the same size as the color panel with the correct style mask and then drop the content view from the real color panel into our new one. Of course this will probably look all wrong as the dropped in content view will not be HUD style, but it's a start.

I've not tried this mind...
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
robbieduncan, I tried playing around with your method, but it gets screwy if you don't use the NSColorPanel class.

Using poseAsClass: (marked as deprecated in Leopard), I got it to work:

Code:
@interface Blah : NSColorPanel {}
@end
@implementation Blah
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
	windowStyle |= 8223;
	return [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
}
@end


@implementation Controller

+ (void)initialize
{
	[[Blah class] poseAsClass:[NSColorPanel class]];
}

- (void)awakeFromNib
{
	[NSApp orderFrontColorPanel:nil];
}

@end

As you can see, the the controls don't fit the HUD style. I didn't find in the documentation a style mask for HUD windows. It must be private? But I setup a HUD window in IB and figured it out was 8223, so that works. I also did a screenshot using NSTexturedBackgroundWindowMask, which looks much better.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Wow, good work! As I said, I'd not actually tried the code, it just seemed to me like it should work. I suppose you need to pose as class to get the actions to link up correctly...
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
sweet! thanks a million everyone... and might i just say that the HUD NSColorPanel looks tasty... :D since i'm pretty new at all this still it's gonna take me a week to implement that into my code, but at least i now know it is possible... thanks again...
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
sweet! thanks a million everyone... and might i just say that the HUD NSColorPanel looks tasty... :D since i'm pretty new at all this still it's gonna take me a week to implement that into my code, but at least i now know it is possible... thanks again...

It'll take you a week to copy-paste some text?
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
It'll take you a week to copy-paste some text?

well, i though the process was more than simple cut/paste... and it wasn't entirely, i had to make it work with my own code, but yeah you're right, it actually took me about 2 minutes... :p

it's also very strange to see the color panel as a HUD window... such perversion! :p... if you resize the window to make it really large, and switch between the color modes, there are some geometric ghost shapes that are apparent... i suppose their placeholders?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.