NSWindow - Sheets - background alpha value

  • How do I override the Leopard defaults to display sheets with an alpha
    of 1.0?

    My application uses a lot of NSWindow sheets - for a good reason.

    I do NOT want a semi-transparent background, nor do my users.

    Keith
  • You could probably wrap the whole sheet in a big primary NSBox and
    get a solid background that way.
    You could even push the edges of the NSBox off past the edges of the
    window so it's not visible.
    I haven't tested this theory but I think it would work.

    On Nov 24, 2007, at 5:14 PM, Keith Wilson wrote:

    > How do I override the Leopard defaults to display sheets with an
    > alpha of 1.0?
    >
    > My application uses a lot of NSWindow sheets - for a good reason.
    >
    > I do NOT want a semi-transparent background, nor do my users.
    >
    > Keith
  • >
    > How do I override the Leopard defaults to display sheets with an
    > alpha of 1.0?
    >
    > My application uses a lot of NSWindow sheets - for a good reason.
    >
    > I do NOT want a semi-transparent background, nor do my users.
    >

    Make the contentView of your window a custom view where you fill the
    rect with a solid colour. I actually used this to get rid of the
    pinstripes in Tiger, and it is not transparent in Leopard. I post the
    code down here, though that might be superfluous as it is really simple.

    Cheers, Patrick

    @interface PMPanelBackgroundView : NSView {

    }

    @end

    #import "PMPanelBackgroundView.h"

    @implementation PMPanelBackgroundView

    - (void)drawRect:(NSRect)rect
    {
    [[NSColor colorWithCalibratedWhite:0.9337 alpha:0.98] set];
    NSRectFill(rect);
    }

    @end
  • On Nov 25, 2007, at 3:22 PM, PGM wrote:

    >>
    >> How do I override the Leopard defaults to display sheets with an
    >> alpha of 1.0?
    >>
    >> My application uses a lot of NSWindow sheets - for a good reason.
    >>
    >> I do NOT want a semi-transparent background, nor do my users.
    >>
    >
    > Make the contentView of your window a custom view where you fill the
    > rect with a solid colour. I actually used this to get rid of the
    > pinstripes in Tiger, and it is not transparent in Leopard. I post
    > the code down here, though that might be superfluous as it is really
    > simple.
    >
    > Cheers, Patrick
    >
    > @interface PMPanelBackgroundView : NSView {
    >
    > }
    >
    > @end
    >
    >
    > #import "PMPanelBackgroundView.h"
    >
    >
    > @implementation PMPanelBackgroundView
    >
    > - (void)drawRect:(NSRect)rect
    > {
    > [[NSColor colorWithCalibratedWhite:0.9337 alpha:0.98] set];
    > NSRectFill(rect);
    > }
    >
    > @end

    If the goal here is to be 98% opqaue, you'll want to use
    NSRectFillUsingOperation instead.  Otherwise, to reinforce the fact
    that total opaqueness is desired, just set the alpha to 1.0.

    ___________________________________________________________
    Ricky A. Sharp        mailto:<rsharp...>
    Instant Interactive(tm)  http://www.instantinteractive.com
  • On 25-Nov-07, at 22:56 PM, Ricky Sharp wrote:

    >
    > On Nov 25, 2007, at 3:22 PM, PGM wrote:
    >
    >>>
    >>> How do I override the Leopard defaults to display sheets with an
    >>> alpha of 1.0?
    >>>
    >>> My application uses a lot of NSWindow sheets - for a good reason.
    >>>
    >>> I do NOT want a semi-transparent background, nor do my users.
    >>>
    >>
    >> Make the contentView of your window a custom view where you fill
    >> the rect with a solid colour. I actually used this to get rid of
    >> the pinstripes in Tiger, and it is not transparent in Leopard. I
    >> post the code down here, though that might be superfluous as it is
    >> really simple.
    >>
    >> Cheers, Patrick
    >>
    >> @interface PMPanelBackgroundView : NSView {
    >>
    >> }
    >>
    >> @end
    >>
    >>
    >> #import "PMPanelBackgroundView.h"
    >>
    >>
    >> @implementation PMPanelBackgroundView
    >>
    >> - (void)drawRect:(NSRect)rect
    >> {
    >> [[NSColor colorWithCalibratedWhite:0.9337 alpha:0.98] set];
    >> NSRectFill(rect);
    >> }
    >>
    >> @end
    >
    > If the goal here is to be 98% opqaue, you'll want to use
    > NSRectFillUsingOperation instead.  Otherwise, to reinforce the fact
    > that total opaqueness is desired, just set the alpha to 1.0.

    I just copied the code from my app and forgot to change the alpha to
    one to match Keith's question. I actually don't remember whether my
    goal was 98% opaque, it's a while since I wrote this.

    Patrick
  • Using a box did not work, already tried that one.

    Keith

    On 26/11/2007, at 3:13 AM, John Stiles wrote:

    > You could probably wrap the whole sheet in a big primary NSBox and
    > get a solid background that way.
    > You could even push the edges of the NSBox off past the edges of the
    > window so it's not visible.
    > I haven't tested this theory but I think it would work.
    >
    >
    > On Nov 24, 2007, at 5:14 PM, Keith Wilson wrote:
    >
    >> How do I override the Leopard defaults to display sheets with an
    >> alpha of 1.0?
    >>
    >> My application uses a lot of NSWindow sheets - for a good reason.
    >>
    >> I do NOT want a semi-transparent background, nor do my users.
    >>
    >> Keith
    >
  • Many thanks Patrick

    All my sheets are sub-classes of an NSPanel that I call FastPanel - it
    returns 0.0 for animationResizeTime. So it is simple (but laborious)
    to plough through all my nib files sub-classing each ContentView to my
    equivalent of your PMPanelBackgroundView. We should not have to build
    this get around so I have submitted an enhancement request to Apple so
    that setAlphaValue sticks.

    Keith

    On 26/11/2007, at 8:22 AM, PGM wrote:

    >>
    >> How do I override the Leopard defaults to display sheets with an
    >> alpha of 1.0?
    >>
    >> My application uses a lot of NSWindow sheets - for a good reason.
    >>
    >> I do NOT want a semi-transparent background, nor do my users.
    >>
    >
    > Make the contentView of your window a custom view where you fill the
    > rect with a solid colour. I actually used this to get rid of the
    > pinstripes in Tiger, and it is not transparent in Leopard. I post
    > the code down here, though that might be superfluous as it is really
    > simple.
    >
    > Cheers, Patrick
    > @interface PMPanelBackgroundView : NSView {
    > }
    > @end
    >
    > #import "PMPanelBackgroundView.h"
    > @implementation PMPanelBackgroundView
    > - (void)drawRect:(NSRect)rect
    > {
    > [[NSColor colorWithCalibratedWhite:0.9337 alpha:0.98] set];
    > NSRectFill(rect);
    > }
    > @end
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today