• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
problem with slider backround
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with slider backround


  • Subject: problem with slider backround
  • From: "Christoph Teschner" <email@hidden>
  • Date: Thu, 08 Jun 2006 17:19:34 +0200

Hi,

I am subclassing NSSlider and NSSliderCell. Everything works fine except the backround. I have overwritten drawBarInside method in NSSliderCell. the new bar appears as expected, but the slider knob does not reach the edges of the bar. Does anybody see what I am doing wrong?

- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped{

	NSImage* progressLeftImage = [[NSImage imageNamed:@"a.tiff" ]retain];
	NSImage* progressRightImage = [[NSImage imageNamed:@"b.tiff" ]retain];
	NSImage* progressCenterImage = [[NSImage imageNamed:@"slider.png" ]retain];

// Create a Canvas
NSImage *canvas = [[[NSImage alloc] initWithSize:aRect.size] autorelease];
NSRect canvasRect = NSMakeRect(0, 0, [canvas size].width, [canvas size].height);


// Draw fill onto Canvas
[canvas lockFocus];
[progressLeftImage compositeToPoint:NSMakePoint(0, 2) operation:NSCompositeSourceOver];


[progressRightImage compositeToPoint:NSMakePoint([canvas size].width - [progressRightImage size].width, 2) operation:NSCompositeSourceOver];

NSSize middleSize = NSMakeSize([canvas size].width - [progressLeftImage size].width - [progressRightImage size].width, [progressCenterImage size].height);
[progressCenterImage setScalesWhenResized:YES];
[progressCenterImage setSize:middleSize];
[progressCenterImage compositeToPoint:NSMakePoint([progressLeftImage size].width, 2) operation:NSCompositeSourceOver];
[canvas unlockFocus];


// Draw canvas
[[self controlView] lockFocus];
[canvas drawInRect:aRect fromRect:canvasRect operation:NSCompositeSourceOver fraction:1.0];
[[self controlView] unlockFocus];


}

Thanks
Christoph


_______________________________________________ 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
  • Prev by Date: Changing NSStepper
  • Next by Date: How to make a blue (active) progressbar within a hotloop?
  • Previous by thread: Changing NSStepper
  • Next by thread: How to make a blue (active) progressbar within a hotloop?
  • Index(es):
    • Date
    • Thread