Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merging fix for 1875c1f30f, a84b20edd |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: | 47959f6dc006bce278290e5e8187f192 |
User & Date: | kevin_walzer 2018-08-12 14:54:32 |
Original Comment: | Merging fix for 1875c1f30f, a84b20eddf, d83153578e |
Context
2018-08-12
| ||
17:13 | Eliminate all usage of CONST84, and fix a few MacOSX compiler warnings check-in: f72c3f43 user: jan.nijtmans tags: trunk | |
14:54 | Merging fix for 1875c1f30f, a84b20edd check-in: 47959f6d user: kevin_walzer tags: trunk | |
2018-08-11
| ||
21:33 | More preparation for TIP #494 compatibitly. Add 2 utility functions, which can retreive big strings and ByteArrays without length overflow. check-in: e8961ae6 user: jan.nijtmans tags: trunk | |
17:48 | Remove warning on unused variable Closed-Leaf check-in: c53b4a0f user: kevin_walzer tags: mac-scrollbar-fix | |
Changes
Changes to macosx/tkMacOSXScrlbr.c.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ... 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 ... 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 ... 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 ... 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 ... 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 ... 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
/*Information on scrollbar layout, metrics, and draw info.*/ typedef struct ScrollbarMetrics { SInt32 width, minThumbHeight; int minHeight, topArrowHeight, bottomArrowHeight; NSControlSize controlSize; } ScrollbarMetrics; static ScrollbarMetrics metrics[2] = { {15, 54, 26, 14, 14, kControlSizeNormal}, /* kThemeScrollBarMedium */ {11, 40, 20, 10, 10, kControlSizeSmall}, /* kThemeScrollBarSmall */ }; HIThemeTrackDrawInfo info = { .version = 0, .min = 0.0, .max = 100.0, .attributes = kThemeTrackShowThumb, }; ................................................................................ extern void TkpComputeScrollbarGeometry( register TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { int variant, fieldLength; if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; variant = ((scrollPtr->vertical ? Tk_Width(scrollPtr->tkwin) : Tk_Height(scrollPtr->tkwin)) - 2 * scrollPtr->inset < metrics[0].width) ? 1 : 0; scrollPtr->arrowLength = (metrics[variant].topArrowHeight + metrics[variant].bottomArrowHeight) / 2; fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) - 2 * (scrollPtr->arrowLength + scrollPtr->inset); if (fieldLength < 0) { fieldLength = 0; } scrollPtr->sliderFirst = fieldLength * scrollPtr->firstFraction; ................................................................................ if (scrollPtr->sliderFirst > (fieldLength - 2*scrollPtr->borderWidth)) { scrollPtr->sliderFirst = fieldLength - 2*scrollPtr->borderWidth; } if (scrollPtr->sliderFirst < 0) { scrollPtr->sliderFirst = 0; } if (scrollPtr->sliderLast < (scrollPtr->sliderFirst + metrics[variant].minThumbHeight)) { scrollPtr->sliderLast = scrollPtr->sliderFirst + metrics[variant].minThumbHeight; } if (scrollPtr->sliderLast > fieldLength) { scrollPtr->sliderLast = fieldLength; } scrollPtr->sliderFirst += scrollPtr->arrowLength + scrollPtr->inset; scrollPtr->sliderLast += scrollPtr->arrowLength + scrollPtr->inset; ................................................................................ /* Register the desired geometry for the window (leave enough space * for the two arrows plus a minimum-size slider, plus border around * the whole window, if any). Then arrange for the window to be * redisplayed. */ if (scrollPtr->vertical) { Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2 * scrollPtr->inset, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics[variant].minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics[variant].minThumbHeight, scrollPtr->width + 2 * scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } ................................................................................ UpdateControlValues( TkScrollbar *scrollPtr) /* Scrollbar data struct. */ { Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); double dViewSize; HIRect contrlRect; int variant; short width, height; NSView *view = TkMacOSXDrawableView(macWin); CGFloat viewHeight = [view bounds].size.height; NSRect frame; frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); ................................................................................ contrlRect = NSRectToCGRect(frame); info.bounds = contrlRect; width = contrlRect.size.width; height = contrlRect.size.height; variant = contrlRect.size.width < metrics[0].width ? 1 : 0; /* * Ensure we set scrollbar control bounds only once all size adjustments * have been computed. */ info.bounds = contrlRect; if (scrollPtr->vertical) { ................................................................................ info.value = info.max - factor * scrollPtr->firstFraction; } } else { info.value = MIN_SCROLLBAR_VALUE + factor * scrollPtr->firstFraction; } if((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0) || height <= metrics[variant].minHeight) { info.enableState = kThemeTrackHideTrack; } else { info.enableState = kThemeTrackActive; info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } |
> | | < > | < < < | | | | | | < < < | |
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 ... 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 ... 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 ... 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 ... 444 445 446 447 448 449 450 451 452 453 454 455 456 457 ... 460 461 462 463 464 465 466 467 468 469 470 471 472 473 ... 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
/*Information on scrollbar layout, metrics, and draw info.*/ typedef struct ScrollbarMetrics { SInt32 width, minThumbHeight; int minHeight, topArrowHeight, bottomArrowHeight; NSControlSize controlSize; } ScrollbarMetrics; static ScrollbarMetrics metrics = { {15, 54, 26, 14, 14, kControlSizeNormal}, /* kThemeScrollBarMedium */ }; HIThemeTrackDrawInfo info = { .version = 0, .min = 0.0, .max = 100.0, .attributes = kThemeTrackShowThumb, }; ................................................................................ extern void TkpComputeScrollbarGeometry( register TkScrollbar *scrollPtr) /* Scrollbar whose geometry may have * changed. */ { int fieldLength; if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; scrollPtr->arrowLength = (metrics.topArrowHeight + metrics.bottomArrowHeight) / 2; fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) - 2 * (scrollPtr->arrowLength + scrollPtr->inset); if (fieldLength < 0) { fieldLength = 0; } scrollPtr->sliderFirst = fieldLength * scrollPtr->firstFraction; ................................................................................ if (scrollPtr->sliderFirst > (fieldLength - 2*scrollPtr->borderWidth)) { scrollPtr->sliderFirst = fieldLength - 2*scrollPtr->borderWidth; } if (scrollPtr->sliderFirst < 0) { scrollPtr->sliderFirst = 0; } if (scrollPtr->sliderLast < (scrollPtr->sliderFirst + metrics.minThumbHeight)) { scrollPtr->sliderLast = scrollPtr->sliderFirst + metrics.minThumbHeight; } if (scrollPtr->sliderLast > fieldLength) { scrollPtr->sliderLast = fieldLength; } scrollPtr->sliderFirst += scrollPtr->arrowLength + scrollPtr->inset; scrollPtr->sliderLast += scrollPtr->arrowLength + scrollPtr->inset; ................................................................................ /* Register the desired geometry for the window (leave enough space * for the two arrows plus a minimum-size slider, plus border around * the whole window, if any). Then arrange for the window to be * redisplayed. */ if (scrollPtr->vertical) { Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2 * scrollPtr->inset, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics.minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2 * (scrollPtr->arrowLength + scrollPtr->borderWidth + scrollPtr->inset) + metrics.minThumbHeight, scrollPtr->width + 2 * scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } ................................................................................ UpdateControlValues( TkScrollbar *scrollPtr) /* Scrollbar data struct. */ { Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); double dViewSize; HIRect contrlRect; short width, height; NSView *view = TkMacOSXDrawableView(macWin); CGFloat viewHeight = [view bounds].size.height; NSRect frame; frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin), Tk_Height(tkwin)); ................................................................................ contrlRect = NSRectToCGRect(frame); info.bounds = contrlRect; width = contrlRect.size.width; height = contrlRect.size.height; /* * Ensure we set scrollbar control bounds only once all size adjustments * have been computed. */ info.bounds = contrlRect; if (scrollPtr->vertical) { ................................................................................ info.value = info.max - factor * scrollPtr->firstFraction; } } else { info.value = MIN_SCROLLBAR_VALUE + factor * scrollPtr->firstFraction; } if((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0) || height <= metrics.minHeight) { info.enableState = kThemeTrackHideTrack; } else { info.enableState = kThemeTrackActive; info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } |