custom NSSliderCell

  • Hi,
    I have a custom NSSliderCell so the slider's bar is translucent. The
    issue is: The 'original' bar is still dran behind mine and shines
    through.

    In awakeFromNib I do:
    //cell is NSSliderCell from IB - it is the same with SGZoomSlider but
    there the SGImageView sets it
    - (void)awakeFromNib {
    PGZoomSliderCell *cell = [[PGZoomSliderCell alloc] init];

    [cell setControlSize: [[slider cell] controlSize]];
    [cell setBezeled:NO];
    [cell setBordered:NO];

    [cell setAction: [[slider cell] action]];
    [cell setTarget: [[slider cell] target]];

    [cell setMaxValue: [[slider cell] maxValue]];
    [cell setMinValue: [[slider cell] minValue]];

    [slider setCell:cell];
    [cell release];
    }

    and my cell is:
    - (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped {
    aRect.origin.x += 7.0f;
    aRect.origin.y += aRect.size.height / 2 - 4.0f;
    aRect.size.height = 9.0f;
    aRect.size.width -= 14.0f;

    //draw white bar
    NSBezierPath *path = [NSBezierPath bezierPathWithRect:aRect];
    [[NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0] set];
    [path stroke];
    }

    - (void)drawKnob:(NSRect)aRect {
    if(aRect.origin.y < 0) aRect.origin.y = 0; //bad slider calls us
    with negative values

    //bg disabled

    aRect.origin.x += aRect.size.height / 2 - 4.0f;
    aRect.origin.y += aRect.size.height / 2 - 4.0f;
    aRect.size.height = 7.0f;
    aRect.size.width = 8.0f;

    //draw white oval
    NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect:aRect];
    [[NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0] set];
    [path fill];
    }

    Thanks in advance,
    Regards, Dominik
previous month october 2006 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 31          
Go to today