Custom drawing in IKImageBrowserView fails
Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom drawing in IKImageBrowserView fails
Hi Florian, You can't do custom drawing this way (because the IKImageBrowserView renders into an openGL surface, so AppKit or CoreGraphics calls won't do anything). So to do what you want you can either: - make the view layer backed and add a sub-layer - add an overlay transparent window on top of the image browser view - add an overlay layer with setForegroundLayer: (that's the easiest solution but it is SnowLeopard only). -- Thomas On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote: Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%40mac.com This email sent to tgooss...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom drawing in IKImageBrowserView fails
Also, you could try swapping out the image browser (or making it hidden) when it is empty, and display an alternative placeholder view in its place. Also, file a bug report requesting the ability to do this built-in. On 25 Nov 2009, at 13:44, Thomas Goossens wrote: Hi Florian, You can't do custom drawing this way (because the IKImageBrowserView renders into an openGL surface, so AppKit or CoreGraphics calls won't do anything). So to do what you want you can either: - make the view layer backed and add a sub-layer - add an overlay transparent window on top of the image browser view - add an overlay layer with setForegroundLayer: (that's the easiest solution but it is SnowLeopard only). -- Thomas On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote: Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%40mac.com This email sent to tgooss...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom drawing in IKImageBrowserView fails
Hi Thomas, thanks for the reply, i did try the first method you suggest with adding a layer but it didn't work either. I also tought of the second method but how would i make sure that my IKImageBrowserView still receives drop event? I ned to be compatible with 10.5 so method 3 is out of the question. Thanks anyway! Florian. On 25 Nov 2009, at 14:44, Thomas Goossens wrote: Hi Florian, You can't do custom drawing this way (because the IKImageBrowserView renders into an openGL surface, so AppKit or CoreGraphics calls won't do anything). So to do what you want you can either: - make the view layer backed and add a sub-layer - add an overlay transparent window on top of the image browser view - add an overlay layer with setForegroundLayer: (that's the easiest solution but it is SnowLeopard only). -- Thomas On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote: Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%40mac.com This email sent to tgooss...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be This email sent to florian.soen...@nss.be Looking for Web-to-Print Solutions? Visit our website : http://www.vit2print.com This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful. If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof. We may monitor e-mail to and from our network. NSS nv Tieltstraat 167 8740 Pittem Belgium ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom drawing in IKImageBrowserView fails
On 25 Nov 2009, at 14:06, Florian Soenens wrote: Hi Thomas, thanks for the reply, i did try the first method you suggest with adding a layer but it didn't work either. I also tought of the second method but how would i make sure that my IKImageBrowserView still receives drop event? You should be able to set the overlay to be invisible to mouse events etc. quite easily. I ned to be compatible with 10.5 so method 3 is out of the question. Thanks anyway! Florian. On 25 Nov 2009, at 14:44, Thomas Goossens wrote: Hi Florian, You can't do custom drawing this way (because the IKImageBrowserView renders into an openGL surface, so AppKit or CoreGraphics calls won't do anything). So to do what you want you can either: - make the view layer backed and add a sub-layer - add an overlay transparent window on top of the image browser view - add an overlay layer with setForegroundLayer: (that's the easiest solution but it is SnowLeopard only). -- Thomas On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote: Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%40mac.com This email sent to tgooss...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be This email sent to florian.soen...@nss.be Looking for Web-to-Print Solutions? Visit our website : http://www.vit2print.com This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful. If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof. We may monitor e-mail to and from our network. NSS nv Tieltstraat 167 8740 Pittem Belgium___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom drawing in IKImageBrowserView fails
Thanks to all for the help. i went with Mike's solution of swapping view. I wrapped the IKImageBrowserView into a Tabless NSTabview with in the second tab my dropview. I will also file the bug report as Mike suggested. Thanks! On Wednesday, November 25, 2009, at 03:34PM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 25 Nov 2009, at 14:06, Florian Soenens wrote: Hi Thomas, thanks for the reply, i did try the first method you suggest with adding a layer but it didn't work either. I also tought of the second method but how would i make sure that my IKImageBrowserView still receives drop event? You should be able to set the overlay to be invisible to mouse events etc. quite easily. I ned to be compatible with 10.5 so method 3 is out of the question. Thanks anyway! Florian. On 25 Nov 2009, at 14:44, Thomas Goossens wrote: Hi Florian, You can't do custom drawing this way (because the IKImageBrowserView renders into an openGL surface, so AppKit or CoreGraphics calls won't do anything). So to do what you want you can either: - make the view layer backed and add a sub-layer - add an overlay transparent window on top of the image browser view - add an overlay layer with setForegroundLayer: (that's the easiest solution but it is SnowLeopard only). -- Thomas On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote: Hi list, i'm trying to override an IKImageBrowserView to do some custom drawing but i'm stuck. What i try to accomplish is that when the view contains zero items, some custom drawing happens like drawing an NSAttributedString that says Drop items here... Problem is that my drawing code gets never called. Here's the drawRect method of my IKImageBrowserView: - (void)drawRect:(NSRect)rect { [super drawRect:rect]; NSUInteger numItems = [[self dataSource] numberOfItemsInImageBrowser:self]; if(numItems = 0) { NSLog(@No items in me); // This gets called, so i'm sure the above code works NSRect bounds = [self bounds]; bounds.size.width = 200; bounds.size.height = 200; bounds.origin.x += 200; bounds.origin.y += 200; //[NSGraphicsContext saveGraphicsState]; [[NSColor yellowColor] set]; // Just for testing purposes NSRectFill(bounds); //[NSGraphicsContext restoreGraphicsState]; } } Uncommenting the NSGrahicsContext doesn't help either. Anyone has any ideas or workarounds for this? Thanks in advance, Florian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%40mac.com This email sent to tgooss...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be This email sent to florian.soen...@nss.be Looking for Web-to-Print Solutions? Visit our website : http://www.vit2print.com This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful. If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof. We may monitor e-mail to and from our network. NSS nv Tieltstraat 167 8740 Pittem Belgium___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: