|
43 | 43 | (define NSDefaultControlTint 0) |
44 | 44 | (define NSClearControlTint 7) |
45 | 45 |
|
46 | | -(import-class NSView NSTabView NSTabViewItem) |
| 46 | +(import-class NSView NSTabView NSTabViewItem NSSegmentedControl) |
47 | 47 | (define TabBarControl |
48 | 48 | (cond |
49 | 49 | [(not tab-ok?) #f] |
|
126 | 126 | labels) |
127 | 127 | (inherit get-cocoa register-as-child |
128 | 128 | is-window-enabled? |
| 129 | + is-enabled-to-root? |
129 | 130 | block-mouse-events |
130 | 131 | refresh) |
131 | 132 |
|
|
168 | 169 | (tellv i setResizeTabsToFitTotalWidth: #:type _BOOL #t)) |
169 | 170 | i))) |
170 | 171 |
|
| 172 | + (define content-cocoa |
| 173 | + (as-objc-allocation |
| 174 | + (tell (tell NSView alloc) |
| 175 | + initWithFrame: #:type _NSRect (tell #:type _NSRect tabv-cocoa contentRect)))) |
| 176 | + |
171 | 177 | (define item-cocoas |
172 | 178 | (for/list ([lbl (in-list labels)]) |
173 | 179 | (let ([item (as-objc-allocation |
174 | 180 | (tell (tell NSTabViewItem alloc) initWithIdentifier: #f))]) |
175 | 181 | (tellv item setLabel: #:type _NSString (label->plain-label lbl)) |
| 182 | + (tellv item setView: content-cocoa) |
176 | 183 | (when (and has-close? |
177 | 184 | use-mm?) |
178 | 185 | (tellv item setHasCloseButton: #:type _BOOL #t)) |
|
185 | 192 | (tellv tabv-cocoa setFrame: #:type _NSRect (make-NSRect (make-init-point x y) sz)) |
186 | 193 | (tellv tabv-cocoa setDelegate: tabv-cocoa))) |
187 | 194 |
|
188 | | - (define content-cocoa |
189 | | - (as-objc-allocation |
190 | | - (tell (tell NSView alloc) |
191 | | - initWithFrame: #:type _NSRect (tell #:type _NSRect tabv-cocoa contentRect)))) |
192 | | - (tellv tabv-cocoa addSubview: content-cocoa) |
193 | | - |
194 | 195 | (define/override (get-cocoa-content) content-cocoa) |
195 | 196 | (define/override (get-cocoa-cursor-content) tabv-cocoa) |
196 | 197 | (define/override (set-size x y w h) |
|
241 | 242 | (let ([item (as-objc-allocation |
242 | 243 | (tell (tell NSTabViewItem alloc) initWithIdentifier: #f))]) |
243 | 244 | (tellv item setLabel: #:type _NSString (label->plain-label lbl)) |
| 245 | + (tellv item setView: content-cocoa) |
244 | 246 | (when (and has-close? |
245 | 247 | use-mm?) |
246 | 248 | (tellv item setHasCloseButton: #:type _BOOL #t)) |
|
279 | 281 | (super-new [parent parent] |
280 | 282 | [cocoa cocoa] |
281 | 283 | [no-show? (memq 'deleted style)]) |
282 | | - |
| 284 | + |
283 | 285 | (when control-cocoa |
284 | 286 | (set-ivar! control-cocoa wxb (->wxb this))) |
285 | 287 |
|
|
291 | 293 | (if on? NSDefaultControlTint NSClearControlTint)) |
292 | 294 | (when control-cocoa |
293 | 295 | (unless use-mm? |
294 | | - (tellv control-cocoa setEnabled: #:type _BOOL on?))))) |
| 296 | + (tellv control-cocoa seteEnabled: #:type _BOOL on?))) |
| 297 | + (when (version-26.0-or-later?) |
| 298 | + (when (eq? cocoa tabv-cocoa) |
| 299 | + (let ([subviews (tell cocoa subviews)]) |
| 300 | + (for ([i (in-range 0 (tell #:type _NSUInteger subviews count))]) |
| 301 | + (define c (tell subviews objectAtIndex: #:type _NSUInteger i)) |
| 302 | + (when (tell #:type _BOOL c isKindOfClass: (tell NSSegmentedControl class)) |
| 303 | + (tellv c setEnabled: #:type _BOOL on?)))))))) |
| 304 | + |
| 305 | + (unless (is-enabled-to-root?) |
| 306 | + (enable-window #f)) |
295 | 307 |
|
296 | 308 | (define/override (can-accept-focus?) |
297 | 309 | (and (not control-cocoa) |
|
0 commit comments