Tk Source Code

Check-in [534118d7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refinement of custom scrollbars on Tk-Cocoa; now more centered, virtually identical to scrollbars in Safari, etc.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 534118d77d63c7dcd96260380f22631fb55f2f70
User & Date: kevin_walzer 2014-12-24 07:13:08
Context
2014-12-24
09:17
merge-mark check-in: 66f4565d user: jan.nijtmans tags: trunk
07:13
Refinement of custom scrollbars on Tk-Cocoa; now more centered, virtually identical to scrollbars in Safari, etc. check-in: 534118d7 user: kevin_walzer tags: trunk
04:47
Revert change from ttk Mac theme check-in: b06f91b0 user: kevin_walzer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXScrlbr.c.

34
35
36
37
38
39
40

41
42
43
44
45
46
47
 * method so that it will not draw itself if the widget is completely outside
 * of its container.
 *
 * Custom drawing of the knob seems to work around the flickering visible after * private API's were removed. Based on technique outlined at 
 * http://stackoverflow.com/questions/1604682/nsscroller-
 * graphical-glitches-lag. Only supported on 10.7 and above.
 */


@interface TkNSScroller: NSScroller
-(void) drawRect:(NSRect)dirtyRect;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
-(BOOL) isHorizontal;
-(void) drawKnob;
- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag;







>







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 * method so that it will not draw itself if the widget is completely outside
 * of its container.
 *
 * Custom drawing of the knob seems to work around the flickering visible after * private API's were removed. Based on technique outlined at 
 * http://stackoverflow.com/questions/1604682/nsscroller-
 * graphical-glitches-lag. Only supported on 10.7 and above.
 */


@interface TkNSScroller: NSScroller
-(void) drawRect:(NSRect)dirtyRect;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
-(BOOL) isHorizontal;
-(void) drawKnob;
- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag;
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

129
130
131
132
133
134
135
	    }
	}
    }
    [super drawRect:dirtyRect];
}

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- (BOOL)isHorizontal {
    NSRect bounds = [self bounds];
    return NSWidth(bounds) < NSHeight (bounds);
}


- (void)drawKnob
{
    NSRect knobRect = [self rectForPart:NSScrollerKnob];
    
    if ([self isHorizontal]) {
	NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width - 5, knobRect.size.height);
	NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:7 yRadius:7];
 
        [[NSColor lightGrayColor] set];
	[path fill];
    } else {
	NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width, knobRect.size.height - 5);
	NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:7 yRadius:7];
 
        [[NSColor lightGrayColor] set];
	[path fill];
    }
       
}

- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag
{
    // We don't want arrows
}

- (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight
{

}

#endif

@end


/*
 * Declaration of Mac specific scrollbar structure.







|









|
|
|


|

|
|


|











|

>







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
	    }
	}
    }
    [super drawRect:dirtyRect];
}

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- (BOOL)isVertical {
    NSRect bounds = [self bounds];
    return NSWidth(bounds) < NSHeight (bounds);
}


- (void)drawKnob
{
    NSRect knobRect = [self rectForPart:NSScrollerKnob];
    
    if ([self isVertical]) {
	NSRect newRect = NSMakeRect(knobRect.origin.x + 3, knobRect.origin.y, knobRect.size.width - 6, knobRect.size.height);
       NSBezierPath  *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4];
 
        [[NSColor lightGrayColor] set];
	[scrollerPath fill];
    } else {
	NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y + 3, knobRect.size.width, knobRect.size.height - 6);
	NSBezierPath  *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4];
 
        [[NSColor lightGrayColor] set];
	[scrollerPath fill];
    }
       
}

- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag
{
    // We don't want arrows
}

- (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight
{
  
}

#endif

@end


/*
 * Declaration of Mac specific scrollbar structure.