]>
Commit | Line | Data |
---|---|---|
1 | #include "wx/defs.h" | |
2 | #include "wx/dc.h" | |
3 | #include "wx/mac/uma.h" | |
4 | #include "wx/mac/aga.h" | |
5 | ||
6 | #ifndef __UNIX__ | |
7 | #include <Navigation.h> | |
8 | #endif | |
9 | ||
10 | // init | |
11 | ||
12 | #if !TARGET_CARBON | |
13 | #define GetControlOwner( control ) (**control).contrlOwner | |
14 | // since we always call this in the right context we don't have to set and reset the port | |
15 | #define InvalWindowRgn( window , rgn ) InvalRgn( rgn ) | |
16 | #endif | |
17 | ||
18 | static bool sUMAHasAppearance = false ; | |
19 | static long sUMAAppearanceVersion = 0 ; | |
20 | extern int gAGABackgroundColor ; | |
21 | bool UMAHasAppearance() { return sUMAHasAppearance ; } | |
22 | long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; } | |
23 | ||
24 | static bool sUMAHasWindowManager = false ; | |
25 | static long sUMAWindowManagerAttr = 0 ; | |
26 | ||
27 | bool UMAHasWindowManager() { return sUMAHasWindowManager ; } | |
28 | long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; } | |
29 | void UMACleanupToolbox() | |
30 | { | |
31 | #if UMA_USE_APPEARANCE | |
32 | if ( sUMAHasAppearance ) | |
33 | { | |
34 | UnregisterAppearanceClient() ; | |
35 | } | |
36 | #endif | |
37 | if ( NavServicesAvailable() ) | |
38 | { | |
39 | NavUnload() ; | |
40 | } | |
41 | } | |
42 | void UMAInitToolbox( UInt16 inMoreMastersCalls ) | |
43 | { | |
44 | #if !TARGET_CARBON | |
45 | ::MaxApplZone(); | |
46 | for (long i = 1; i <= inMoreMastersCalls; i++) | |
47 | ::MoreMasters(); | |
48 | ||
49 | ::InitGraf(&qd.thePort); | |
50 | ::InitFonts(); | |
51 | ::InitMenus(); | |
52 | ::TEInit(); | |
53 | ::InitDialogs(0L); | |
54 | ::FlushEvents(everyEvent, 0); | |
55 | ::InitCursor(); | |
56 | long total,contig; | |
57 | PurgeSpace(&total, &contig); | |
58 | #else | |
59 | InitCursor(); | |
60 | #endif | |
61 | ||
62 | #if UMA_USE_APPEARANCE | |
63 | long theAppearance ; | |
64 | if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) | |
65 | { | |
66 | sUMAHasAppearance = true ; | |
67 | RegisterAppearanceClient(); | |
68 | if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) | |
69 | { | |
70 | sUMAAppearanceVersion = theAppearance ; | |
71 | } | |
72 | else | |
73 | { | |
74 | sUMAAppearanceVersion = 0x0100 ; | |
75 | } | |
76 | } | |
77 | #endif // UMA_USE_APPEARANCE | |
78 | #if UMA_USE_8_6 | |
79 | #if UMA_USE_WINDOWMGR | |
80 | if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) | |
81 | { | |
82 | sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; | |
83 | } | |
84 | #endif // UMA_USE_WINDOWMGR | |
85 | #endif | |
86 | ||
87 | #ifndef __UNIX__ | |
88 | #if TARGET_CARBON | |
89 | // Call currently implicitely done : InitFloatingWindows() ; | |
90 | #else | |
91 | if ( sUMAHasWindowManager ) | |
92 | InitFloatingWindows() ; | |
93 | else | |
94 | InitWindows(); | |
95 | #endif | |
96 | #endif | |
97 | ||
98 | if ( NavServicesAvailable() ) | |
99 | { | |
100 | NavLoad() ; | |
101 | } | |
102 | } | |
103 | ||
104 | // process manager | |
105 | long UMAGetProcessMode() | |
106 | { | |
107 | OSErr err ; | |
108 | ProcessInfoRec processinfo; | |
109 | ProcessSerialNumber procno ; | |
110 | ||
111 | procno.highLongOfPSN = NULL ; | |
112 | procno.lowLongOfPSN = kCurrentProcess ; | |
113 | processinfo.processInfoLength = sizeof(ProcessInfoRec); | |
114 | processinfo.processName = NULL; | |
115 | processinfo.processAppSpec = NULL; | |
116 | ||
117 | err = ::GetProcessInformation( &procno , &processinfo ) ; | |
118 | wxASSERT( err == noErr ) ; | |
119 | return processinfo.processMode ; | |
120 | } | |
121 | ||
122 | bool UMAGetProcessModeDoesActivateOnFGSwitch() | |
123 | { | |
124 | return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; | |
125 | } | |
126 | ||
127 | // menu manager | |
128 | ||
129 | void UMASetMenuTitle( MenuRef menu , StringPtr title ) | |
130 | { | |
131 | #if !TARGET_CARBON | |
132 | long size = GetHandleSize( (Handle) menu ) ; | |
133 | const long headersize = 14 ; | |
134 | int oldlen = (**menu).menuData[0] + 1; | |
135 | int newlen = title[0] + 1 ; | |
136 | ||
137 | if ( oldlen < newlen ) | |
138 | { | |
139 | // enlarge before adjusting | |
140 | SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ); | |
141 | } | |
142 | ||
143 | if ( oldlen != newlen ) | |
144 | memmove( (char*) (**menu).menuData + newlen , (char*) (**menu).menuData + oldlen , size - headersize - oldlen ) ; | |
145 | ||
146 | memcpy( (char*) (**menu).menuData , title , newlen ) ; | |
147 | if ( oldlen > newlen ) | |
148 | { | |
149 | // shrink after | |
150 | SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ) ; | |
151 | } | |
152 | #else | |
153 | SetMenuTitle( menu , title ) ; | |
154 | #endif | |
155 | } | |
156 | ||
157 | UInt32 UMAMenuEvent( EventRecord *inEvent ) | |
158 | { | |
159 | #if UMA_USE_APPEARANCE | |
160 | if ( UMAHasAppearance() ) | |
161 | { | |
162 | return MenuEvent( inEvent ) ; | |
163 | } | |
164 | else | |
165 | #endif | |
166 | { | |
167 | if ( inEvent->what == keyDown && inEvent->modifiers & cmdKey) | |
168 | { | |
169 | return MenuKey( inEvent->message & charCodeMask ) ; | |
170 | } | |
171 | return NULL ; | |
172 | } | |
173 | } | |
174 | ||
175 | void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem ) | |
176 | { | |
177 | #if UMA_USE_8_6 || TARGET_CARBON | |
178 | EnableMenuItem( inMenu , inItem ) ; | |
179 | #else | |
180 | EnableItem( inMenu , inItem ) ; | |
181 | #endif | |
182 | } | |
183 | ||
184 | void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem ) | |
185 | { | |
186 | #if UMA_USE_8_6 || TARGET_CARBON | |
187 | DisableMenuItem( inMenu , inItem ) ; | |
188 | #else | |
189 | DisableItem( inMenu , inItem ) ; | |
190 | #endif | |
191 | } | |
192 | ||
193 | void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id ) | |
194 | { | |
195 | Str255 label ; | |
196 | memcpy( label , l , l[0]+1 ) ; | |
197 | // hardcoded adding of the submenu combination for mac | |
198 | ||
199 | int theEnd = label[0] + 1; | |
200 | if (theEnd > 251) | |
201 | theEnd = 251; // mac allows only 255 characters | |
202 | label[theEnd++] = '/'; | |
203 | label[theEnd++] = hMenuCmd; | |
204 | label[theEnd++] = '!'; | |
205 | label[theEnd++] = id ; | |
206 | label[theEnd] = 0x00; | |
207 | label[0] = theEnd; | |
208 | MacAppendMenu(menu, label); | |
209 | } | |
210 | ||
211 | void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id ) | |
212 | { | |
213 | Str255 label ; | |
214 | memcpy( label , l , l[0]+1 ) ; | |
215 | // hardcoded adding of the submenu combination for mac | |
216 | ||
217 | int theEnd = label[0] + 1; | |
218 | if (theEnd > 251) | |
219 | theEnd = 251; // mac allows only 255 characters | |
220 | label[theEnd++] = '/'; | |
221 | label[theEnd++] = hMenuCmd; | |
222 | label[theEnd++] = '!'; | |
223 | label[theEnd++] = id; | |
224 | label[theEnd] = 0x00; | |
225 | label[0] = theEnd; | |
226 | MacInsertMenuItem(menu, label , item); | |
227 | } | |
228 | ||
229 | void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers ) | |
230 | { | |
231 | Str255 label ; | |
232 | memcpy( label , l , l[0]+1 ) ; | |
233 | if ( key ) | |
234 | { | |
235 | int pos = label[0] ; | |
236 | label[++pos] = '/'; | |
237 | label[++pos] = toupper( key ); | |
238 | label[0] = pos ; | |
239 | } | |
240 | MacAppendMenu( menu , label ) ; | |
241 | } | |
242 | ||
243 | void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 key, UInt8 modifiers ) | |
244 | { | |
245 | Str255 label ; | |
246 | memcpy( label , l , l[0]+1 ) ; | |
247 | if ( key ) | |
248 | { | |
249 | int pos = label[0] ; | |
250 | label[++pos] = '/'; | |
251 | label[++pos] = toupper( key ); | |
252 | label[0] = pos ; | |
253 | } | |
254 | MacInsertMenuItem( menu , label , item) ; | |
255 | } | |
256 | ||
257 | void UMADrawMenuBar() | |
258 | { | |
259 | DrawMenuBar() ; | |
260 | } | |
261 | ||
262 | ||
263 | void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label ) | |
264 | { | |
265 | ::SetMenuItemText( menu , item , label ) ; | |
266 | } | |
267 | ||
268 | MenuRef UMANewMenu( SInt16 menuid , StringPtr label ) | |
269 | { | |
270 | return ::NewMenu(menuid, label); | |
271 | } | |
272 | ||
273 | void UMADisposeMenu( MenuRef menu ) | |
274 | { | |
275 | DisposeMenu( menu ) ; | |
276 | } | |
277 | void UMADeleteMenu( SInt16 menuId ) | |
278 | { | |
279 | ::DeleteMenu( menuId ) ; | |
280 | } | |
281 | ||
282 | void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId ) | |
283 | { | |
284 | ::InsertMenu( insertMenu , afterId ) ; | |
285 | } | |
286 | ||
287 | ||
288 | // quickdraw | |
289 | ||
290 | int gPrOpenCounter = 0 ; | |
291 | ||
292 | #if PM_USE_SESSION_APIS | |
293 | OSStatus UMAPrOpen(PMPrintSession *macPrintPort) | |
294 | #else | |
295 | OSStatus UMAPrOpen() | |
296 | #endif | |
297 | { | |
298 | #if !TARGET_CARBON | |
299 | OSErr err = noErr ; | |
300 | ++gPrOpenCounter ; | |
301 | if ( gPrOpenCounter == 1 ) | |
302 | { | |
303 | PrOpen() ; | |
304 | err = PrError() ; | |
305 | wxASSERT( err == noErr ) ; | |
306 | } | |
307 | return err ; | |
308 | #else | |
309 | OSStatus err = noErr ; | |
310 | ++gPrOpenCounter ; | |
311 | if ( gPrOpenCounter == 1 ) | |
312 | { | |
313 | #if PM_USE_SESSION_APIS | |
314 | err = PMCreateSession(macPrintPort) ; | |
315 | #else | |
316 | err = PMBegin() ; | |
317 | #endif | |
318 | wxASSERT( err == noErr ) ; | |
319 | } | |
320 | return err ; | |
321 | #endif | |
322 | } | |
323 | ||
324 | #if PM_USE_SESSION_APIS | |
325 | OSStatus UMAPrClose(PMPrintSession *macPrintPort) | |
326 | #else | |
327 | OSStatus UMAPrClose() | |
328 | #endif | |
329 | { | |
330 | #if !TARGET_CARBON | |
331 | OSErr err = noErr ; | |
332 | wxASSERT( gPrOpenCounter >= 1 ) ; | |
333 | if ( gPrOpenCounter == 1 ) | |
334 | { | |
335 | PrClose() ; | |
336 | err = PrError() ; | |
337 | wxASSERT( err == noErr ) ; | |
338 | } | |
339 | --gPrOpenCounter ; | |
340 | return err ; | |
341 | #else | |
342 | OSStatus err = noErr ; | |
343 | wxASSERT( gPrOpenCounter >= 1 ) ; | |
344 | if ( gPrOpenCounter == 1 ) | |
345 | { | |
346 | #if PM_USE_SESSION_APIS | |
347 | err = PMRelease(*macPrintPort) ; | |
348 | #else | |
349 | err = PMEnd() ; | |
350 | #endif | |
351 | } | |
352 | --gPrOpenCounter ; | |
353 | return err ; | |
354 | #endif | |
355 | } | |
356 | ||
357 | #if !TARGET_CARBON | |
358 | ||
359 | pascal QDGlobalsPtr GetQDGlobalsPtr (void) | |
360 | { | |
361 | return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); | |
362 | } | |
363 | ||
364 | #endif | |
365 | ||
366 | void UMAShowWatchCursor() | |
367 | { | |
368 | OSErr err = noErr; | |
369 | ||
370 | CursHandle watchFob = GetCursor (watchCursor); | |
371 | ||
372 | if (!watchFob) | |
373 | err = nilHandleErr; | |
374 | else | |
375 | { | |
376 | #if TARGET_CARBON | |
377 | Cursor preservedArrow; | |
378 | GetQDGlobalsArrow (&preservedArrow); | |
379 | SetQDGlobalsArrow (*watchFob); | |
380 | InitCursor ( ); | |
381 | SetQDGlobalsArrow (&preservedArrow); | |
382 | #else | |
383 | SetCursor (*watchFob); | |
384 | #endif | |
385 | } | |
386 | } | |
387 | ||
388 | void UMAShowArrowCursor() | |
389 | { | |
390 | #if TARGET_CARBON | |
391 | Cursor arrow; | |
392 | SetCursor (GetQDGlobalsArrow (&arrow)); | |
393 | #else | |
394 | SetCursor (&(qd.arrow)); | |
395 | #endif | |
396 | } | |
397 | ||
398 | // window manager | |
399 | ||
400 | GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) | |
401 | { | |
402 | wxASSERT( inWindowRef != NULL ) ; | |
403 | #if TARGET_CARBON | |
404 | return GetWindowPort( inWindowRef ) ; | |
405 | #else | |
406 | return (GrafPtr) inWindowRef ; | |
407 | #endif | |
408 | } | |
409 | ||
410 | void UMADisposeWindow( WindowRef inWindowRef ) | |
411 | { | |
412 | wxASSERT( inWindowRef != NULL ) ; | |
413 | DisposeWindow( inWindowRef ) ; | |
414 | } | |
415 | ||
416 | void UMASetWTitleC( WindowRef inWindowRef , const char *title ) | |
417 | { | |
418 | Str255 ptitle ; | |
419 | strncpy( (char*)ptitle , title , 96 ) ; | |
420 | ptitle[96] = 0 ; | |
421 | #if TARGET_CARBON | |
422 | c2pstrcpy( ptitle, (char *)ptitle ) ; | |
423 | #else | |
424 | c2pstr( (char*)ptitle ) ; | |
425 | #endif | |
426 | SetWTitle( inWindowRef , ptitle ) ; | |
427 | } | |
428 | ||
429 | void UMAGetWTitleC( WindowRef inWindowRef , char *title ) | |
430 | { | |
431 | GetWTitle( inWindowRef , (unsigned char*)title ) ; | |
432 | #if TARGET_CARBON | |
433 | p2cstrcpy( title, (unsigned char *)title ) ; | |
434 | #else | |
435 | p2cstr( (unsigned char*)title ) ; | |
436 | #endif | |
437 | } | |
438 | ||
439 | void UMAShowWindow( WindowRef inWindowRef ) | |
440 | { | |
441 | ShowWindow( inWindowRef ) ; | |
442 | ||
443 | } | |
444 | ||
445 | void UMAHideWindow( WindowRef inWindowRef ) | |
446 | { | |
447 | HideWindow( inWindowRef) ; | |
448 | } | |
449 | ||
450 | void UMASelectWindow( WindowRef inWindowRef ) | |
451 | { | |
452 | SelectWindow( inWindowRef ) ; | |
453 | } | |
454 | ||
455 | void UMABringToFront( WindowRef inWindowRef ) | |
456 | { | |
457 | BringToFront( inWindowRef ) ; | |
458 | } | |
459 | ||
460 | void UMASendBehind( WindowRef inWindowRef , WindowRef behindWindow ) | |
461 | { | |
462 | SendBehind( inWindowRef , behindWindow ) ; | |
463 | } | |
464 | ||
465 | void UMACloseWindow(WindowRef inWindowRef) | |
466 | { | |
467 | #if TARGET_CARBON | |
468 | #else | |
469 | CloseWindow( inWindowRef ) ; | |
470 | #endif | |
471 | } | |
472 | ||
473 | // appearance additions | |
474 | ||
475 | void UMAActivateControl( ControlHandle inControl ) | |
476 | { | |
477 | #if UMA_USE_APPEARANCE | |
478 | if ( UMAHasAppearance() ) | |
479 | { | |
480 | if ( !UMAIsControlActive( inControl ) ) | |
481 | { | |
482 | bool visible = IsControlVisible( inControl ) ; | |
483 | if ( visible ) | |
484 | SetControlVisibility( inControl , false , false ) ; | |
485 | ::ActivateControl( inControl ) ; | |
486 | if ( visible ) { | |
487 | SetControlVisibility( inControl , true , false ) ; | |
488 | Rect ctrlBounds ; | |
489 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
490 | } | |
491 | } | |
492 | } | |
493 | else | |
494 | #endif | |
495 | #if !TARGET_CARBON | |
496 | { | |
497 | AGAActivateControl( inControl ) ; | |
498 | } | |
499 | #else | |
500 | { | |
501 | } | |
502 | #endif | |
503 | } | |
504 | ||
505 | void UMADrawControl( ControlHandle inControl ) | |
506 | { | |
507 | WindowRef theWindow = GetControlOwner(inControl) ; | |
508 | RgnHandle updateRgn = NewRgn() ; | |
509 | #if TARGET_CARBON | |
510 | GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ; | |
511 | #else | |
512 | GetWindowUpdateRgn( theWindow , updateRgn ) ; | |
513 | #endif | |
514 | Point zero = { 0 , 0 } ; | |
515 | LocalToGlobal( &zero ) ; | |
516 | OffsetRgn( updateRgn , -zero.h , -zero.v ) ; | |
517 | #if UMA_USE_APPEARANCE | |
518 | if ( UMAHasAppearance() ) | |
519 | { | |
520 | ::DrawControlInCurrentPort( inControl ) ; | |
521 | } | |
522 | else | |
523 | #endif | |
524 | #if !TARGET_CARBON | |
525 | { | |
526 | AGADrawControl( inControl ) ; | |
527 | } | |
528 | #else | |
529 | { | |
530 | } | |
531 | #endif | |
532 | #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) | |
533 | InvalWindowRgn( theWindow, updateRgn) ; | |
534 | #else | |
535 | InvalRgn( updateRgn ) ; | |
536 | #endif | |
537 | DisposeRgn( updateRgn ) ; | |
538 | ||
539 | } | |
540 | ||
541 | void UMAMoveControl( ControlHandle inControl , short x , short y ) | |
542 | { | |
543 | if ( UMAHasAppearance() ) | |
544 | { | |
545 | bool visible = UMAIsControlVisible( inControl ) ; | |
546 | if ( visible ) { | |
547 | SetControlVisibility( inControl , false , false ) ; | |
548 | Rect ctrlBounds ; | |
549 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
550 | } | |
551 | ::MoveControl( inControl , x , y ) ; | |
552 | if ( visible ) { | |
553 | SetControlVisibility( inControl , true , false ) ; | |
554 | Rect ctrlBounds ; | |
555 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
556 | } | |
557 | } | |
558 | } | |
559 | ||
560 | void UMASizeControl( ControlHandle inControl , short x , short y ) | |
561 | { | |
562 | if ( UMAHasAppearance() ) | |
563 | { | |
564 | bool visible = UMAIsControlVisible( inControl ) ; | |
565 | if ( visible ) { | |
566 | SetControlVisibility( inControl , false , false ) ; | |
567 | Rect ctrlBounds ; | |
568 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
569 | } | |
570 | ::SizeControl( inControl , x , y ) ; | |
571 | if ( visible ) { | |
572 | SetControlVisibility( inControl , true , false ) ; | |
573 | Rect ctrlBounds ; | |
574 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
575 | } | |
576 | } | |
577 | } | |
578 | ||
579 | void UMADeactivateControl( ControlHandle inControl ) | |
580 | { | |
581 | if ( UMAHasAppearance() ) | |
582 | { | |
583 | if ( UMAIsControlActive( inControl ) ) | |
584 | { | |
585 | bool visible = IsControlVisible( inControl ) ; | |
586 | if ( visible ) | |
587 | SetControlVisibility( inControl , false , false ) ; | |
588 | ::DeactivateControl( inControl ) ; | |
589 | if ( visible ) { | |
590 | SetControlVisibility( inControl , true , false ) ; | |
591 | Rect ctrlBounds ; | |
592 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
593 | } | |
594 | } | |
595 | } | |
596 | } | |
597 | ||
598 | void UMASetThemeWindowBackground (WindowRef inWindow, | |
599 | ThemeBrush inBrush, | |
600 | Boolean inUpdate) | |
601 | { | |
602 | #if UMA_USE_APPEARANCE | |
603 | if ( UMAHasAppearance() ) | |
604 | { | |
605 | ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ; | |
606 | } | |
607 | else | |
608 | #endif | |
609 | #if !TARGET_CARBON | |
610 | { | |
611 | AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ; | |
612 | } | |
613 | #else | |
614 | { | |
615 | } | |
616 | #endif | |
617 | } | |
618 | ||
619 | void UMAApplyThemeBackground (ThemeBackgroundKind inKind, | |
620 | const Rect * bounds, | |
621 | ThemeDrawState inState, | |
622 | SInt16 inDepth, | |
623 | Boolean inColorDev) | |
624 | { | |
625 | #if UMA_USE_APPEARANCE | |
626 | if ( UMAHasAppearance() ) | |
627 | { | |
628 | /* | |
629 | if ( sUMAAppearanceVersion >= 0x0110 ) | |
630 | ::ApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ; | |
631 | */ | |
632 | } | |
633 | else | |
634 | #endif | |
635 | #if !TARGET_CARBON | |
636 | { | |
637 | AGAApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ; | |
638 | } | |
639 | #else | |
640 | { | |
641 | } | |
642 | #endif | |
643 | } | |
644 | ||
645 | ControlHandle UMANewControl(WindowPtr owningWindow, | |
646 | const Rect * boundsRect, | |
647 | ConstStr255Param controlTitle, | |
648 | Boolean initiallyVisible, | |
649 | SInt16 initialValue, | |
650 | SInt16 minimumValue, | |
651 | SInt16 maximumValue, | |
652 | SInt16 procID, | |
653 | SInt32 controlReference) | |
654 | { | |
655 | ControlHandle theControl = NULL ; | |
656 | #if UMA_USE_APPEARANCE | |
657 | if ( UMAHasAppearance() ) | |
658 | { | |
659 | theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , | |
660 | initialValue , minimumValue , maximumValue , procID , controlReference ) ; | |
661 | } | |
662 | else | |
663 | #endif | |
664 | #if !TARGET_CARBON | |
665 | { | |
666 | theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , | |
667 | initialValue , minimumValue , maximumValue , procID , controlReference ) ; | |
668 | } | |
669 | #else | |
670 | { | |
671 | } | |
672 | #endif | |
673 | return theControl ; | |
674 | } | |
675 | ||
676 | void UMADisposeControl (ControlHandle theControl) | |
677 | { | |
678 | if ( UMAHasAppearance() ) | |
679 | { | |
680 | ::DisposeControl( theControl ) ; | |
681 | } | |
682 | else | |
683 | { | |
684 | ::DisposeControl( theControl ) ; | |
685 | } | |
686 | } | |
687 | ||
688 | void UMAHiliteControl (ControlHandle inControl, | |
689 | ControlPartCode hiliteState) | |
690 | { | |
691 | if ( UMAHasAppearance() ) | |
692 | { | |
693 | ::HiliteControl( inControl , hiliteState ) ; | |
694 | } | |
695 | else | |
696 | { | |
697 | ::HiliteControl( inControl , hiliteState ) ; | |
698 | } | |
699 | } | |
700 | ||
701 | // shows the control and adds the region to the update region | |
702 | void UMAShowControl (ControlHandle inControl) | |
703 | { | |
704 | if ( UMAHasAppearance() ) | |
705 | { | |
706 | SetControlVisibility( inControl , true , false ) ; | |
707 | Rect ctrlBounds ; | |
708 | InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; | |
709 | } | |
710 | } | |
711 | ||
712 | // Hides the control and adds the region to the update region | |
713 | void UMAHideControl (ControlHandle inControl) | |
714 | { | |
715 | if ( UMAHasAppearance() ) | |
716 | { | |
717 | ::HideControl( inControl ) ; | |
718 | } | |
719 | else | |
720 | { | |
721 | ::HideControl( inControl ) ; | |
722 | } | |
723 | } | |
724 | ||
725 | ||
726 | void UMASetControlVisibility (ControlHandle inControl, | |
727 | Boolean inIsVisible, | |
728 | Boolean inDoDraw) | |
729 | { | |
730 | if ( UMAHasAppearance() ) | |
731 | { | |
732 | #if UMA_USE_APPEARANCE | |
733 | ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ; | |
734 | #endif | |
735 | } | |
736 | } | |
737 | ||
738 | ||
739 | ||
740 | bool UMAIsControlActive (ControlHandle inControl) | |
741 | { | |
742 | #if TARGET_CARBON | |
743 | return IsControlActive( inControl ) ; | |
744 | #else | |
745 | #if UMA_USE_APPEARANCE | |
746 | if ( UMAHasAppearance() ) | |
747 | { | |
748 | return IsControlActive( inControl ) ; | |
749 | } | |
750 | else | |
751 | #endif | |
752 | return (**inControl).contrlHilite == 0 ; | |
753 | #endif | |
754 | } | |
755 | ||
756 | ||
757 | bool UMAIsControlVisible (ControlHandle inControl) | |
758 | { | |
759 | #if UMA_USE_APPEARANCE | |
760 | if ( UMAHasAppearance() ) | |
761 | { | |
762 | return IsControlVisible( inControl ) ; | |
763 | } | |
764 | else | |
765 | #endif | |
766 | { | |
767 | #if !TARGET_CARBON | |
768 | return (**inControl).contrlVis == 255 ; | |
769 | #endif | |
770 | } | |
771 | return true ; | |
772 | } | |
773 | ||
774 | OSErr UMAGetBestControlRect (ControlHandle inControl, | |
775 | Rect * outRect, | |
776 | SInt16 * outBaseLineOffset) | |
777 | { | |
778 | #if UMA_USE_APPEARANCE | |
779 | if ( UMAHasAppearance() ) | |
780 | { | |
781 | return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ; | |
782 | } | |
783 | else | |
784 | #endif | |
785 | #if !TARGET_CARBON | |
786 | { | |
787 | return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ; | |
788 | } | |
789 | #else | |
790 | { | |
791 | return noErr ; | |
792 | } | |
793 | #endif | |
794 | } | |
795 | ||
796 | ||
797 | OSErr UMASetControlFontStyle (ControlHandle inControl, | |
798 | const ControlFontStyleRec * inStyle) | |
799 | { | |
800 | #if UMA_USE_APPEARANCE | |
801 | if ( UMAHasAppearance() ) | |
802 | { | |
803 | return ::SetControlFontStyle( inControl , inStyle ) ; | |
804 | } | |
805 | else | |
806 | #endif | |
807 | #if !TARGET_CARBON | |
808 | return AGASetControlFontStyle( inControl , inStyle ) ; | |
809 | #else | |
810 | { | |
811 | return noErr ; | |
812 | } | |
813 | #endif | |
814 | } | |
815 | ||
816 | ||
817 | ||
818 | // control hierarchy | |
819 | ||
820 | OSErr UMACreateRootControl (WindowPtr inWindow, | |
821 | ControlHandle * outControl) | |
822 | { | |
823 | #if UMA_USE_APPEARANCE | |
824 | if ( UMAHasAppearance() ) | |
825 | { | |
826 | return CreateRootControl( inWindow , outControl ) ; | |
827 | } | |
828 | else | |
829 | #endif | |
830 | #if !TARGET_CARBON | |
831 | return AGACreateRootControl( inWindow , outControl ) ; | |
832 | #else | |
833 | { | |
834 | return noErr ; | |
835 | } | |
836 | #endif | |
837 | } | |
838 | ||
839 | ||
840 | ||
841 | OSErr UMAEmbedControl (ControlHandle inControl, | |
842 | ControlHandle inContainer) | |
843 | { | |
844 | #if UMA_USE_APPEARANCE | |
845 | if ( UMAHasAppearance() ) | |
846 | { | |
847 | return EmbedControl( inControl , inContainer ) ; | |
848 | } | |
849 | else | |
850 | #endif | |
851 | #if !TARGET_CARBON | |
852 | return AGAEmbedControl( inControl , inContainer ) ; ; | |
853 | #else | |
854 | { | |
855 | return noErr ; | |
856 | } | |
857 | #endif | |
858 | } | |
859 | ||
860 | ||
861 | ||
862 | // keyboard focus | |
863 | OSErr UMASetKeyboardFocus (WindowPtr inWindow, | |
864 | ControlHandle inControl, | |
865 | ControlFocusPart inPart) | |
866 | { | |
867 | OSErr err = noErr; | |
868 | GrafPtr port ; | |
869 | GetPort( &port ) ; | |
870 | #if TARGET_CARBON | |
871 | SetPort( GetWindowPort( inWindow ) ) ; | |
872 | #else | |
873 | SetPort( inWindow ) ; | |
874 | #endif | |
875 | SetOrigin( 0 , 0 ) ; | |
876 | #if UMA_USE_APPEARANCE | |
877 | if ( UMAHasAppearance() ) | |
878 | { | |
879 | err = SetKeyboardFocus( inWindow , inControl , inPart ) ; | |
880 | } | |
881 | else | |
882 | #endif | |
883 | #if !TARGET_CARBON | |
884 | err = AGASetKeyboardFocus( inWindow , inControl , inPart ) ; | |
885 | #else | |
886 | { | |
887 | } | |
888 | #endif | |
889 | SetPort( port ) ; | |
890 | return err ; | |
891 | } | |
892 | ||
893 | ||
894 | ||
895 | ||
896 | // events | |
897 | ||
898 | ControlPartCode UMAHandleControlClick (ControlHandle inControl, | |
899 | Point inWhere, | |
900 | SInt16 inModifiers, | |
901 | ControlActionUPP inAction) | |
902 | { | |
903 | #if UMA_USE_APPEARANCE | |
904 | if ( UMAHasAppearance() ) | |
905 | { | |
906 | return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ; | |
907 | } | |
908 | else | |
909 | #endif | |
910 | #if !TARGET_CARBON | |
911 | { | |
912 | return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ; | |
913 | } | |
914 | #else | |
915 | { | |
916 | return noErr ; | |
917 | } | |
918 | #endif | |
919 | } | |
920 | ||
921 | ||
922 | SInt16 UMAHandleControlKey (ControlHandle inControl, | |
923 | SInt16 inKeyCode, | |
924 | SInt16 inCharCode, | |
925 | SInt16 inModifiers) | |
926 | { | |
927 | #if UMA_USE_APPEARANCE | |
928 | if ( UMAHasAppearance() ) | |
929 | { | |
930 | return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ; | |
931 | } | |
932 | else | |
933 | #endif | |
934 | #if !TARGET_CARBON | |
935 | { | |
936 | return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ; | |
937 | } | |
938 | #else | |
939 | { | |
940 | return noErr ; | |
941 | } | |
942 | #endif | |
943 | } | |
944 | ||
945 | ||
946 | ||
947 | void UMAIdleControls (WindowPtr inWindow) | |
948 | { | |
949 | #if UMA_USE_APPEARANCE | |
950 | if ( UMAHasAppearance() ) | |
951 | { | |
952 | IdleControls( inWindow ) ; | |
953 | } | |
954 | else | |
955 | #endif | |
956 | #if !TARGET_CARBON | |
957 | { | |
958 | AGAIdleControls( inWindow ) ; | |
959 | } | |
960 | #else | |
961 | { | |
962 | } | |
963 | #endif | |
964 | } | |
965 | ||
966 | void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) | |
967 | { | |
968 | RgnHandle updateRgn = NewRgn() ; | |
969 | #if TARGET_CARBON | |
970 | GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn ) ; | |
971 | #else | |
972 | GetWindowUpdateRgn( inWindow , updateRgn ) ; | |
973 | #endif | |
974 | Point zero = { 0 , 0 } ; | |
975 | LocalToGlobal( &zero ) ; | |
976 | OffsetRgn( updateRgn , -zero.h , -zero.v ) ; | |
977 | #if UMA_USE_APPEARANCE | |
978 | if ( UMAHasAppearance() ) | |
979 | { | |
980 | UpdateControls( inWindow , inRgn ) ; | |
981 | } | |
982 | else | |
983 | #endif | |
984 | #if !TARGET_CARBON | |
985 | { | |
986 | AGAUpdateControls( inWindow , inRgn ) ; | |
987 | } | |
988 | #else | |
989 | { | |
990 | } | |
991 | #endif | |
992 | #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332) | |
993 | InvalWindowRgn( inWindow, updateRgn) ; | |
994 | #else | |
995 | InvalRgn( updateRgn ) ; | |
996 | #endif | |
997 | DisposeRgn( updateRgn ) ; | |
998 | ||
999 | } | |
1000 | ||
1001 | OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) | |
1002 | { | |
1003 | #if UMA_USE_APPEARANCE | |
1004 | if ( UMAHasAppearance() ) | |
1005 | { | |
1006 | return GetRootControl( inWindow , outControl ) ; | |
1007 | } | |
1008 | else | |
1009 | #endif | |
1010 | #if !TARGET_CARBON | |
1011 | { | |
1012 | return AGAGetRootControl( inWindow , outControl ) ; | |
1013 | } | |
1014 | #else | |
1015 | { | |
1016 | return noErr ; | |
1017 | } | |
1018 | #endif | |
1019 | } | |
1020 | ||
1021 | ||
1022 | // handling control data | |
1023 | ||
1024 | OSErr UMASetControlData (ControlHandle inControl, | |
1025 | ControlPartCode inPart, | |
1026 | ResType inTagName, | |
1027 | Size inSize, | |
1028 | Ptr inData) | |
1029 | { | |
1030 | #if UMA_USE_APPEARANCE | |
1031 | if ( UMAHasAppearance() ) | |
1032 | { | |
1033 | return SetControlData( inControl , inPart , inTagName , inSize , inData ) ; | |
1034 | } | |
1035 | else | |
1036 | #endif | |
1037 | #if !TARGET_CARBON | |
1038 | return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ; | |
1039 | #else | |
1040 | { | |
1041 | return noErr ; | |
1042 | } | |
1043 | #endif | |
1044 | } | |
1045 | ||
1046 | ||
1047 | ||
1048 | OSErr UMAGetControlData (ControlHandle inControl, | |
1049 | ControlPartCode inPart, | |
1050 | ResType inTagName, | |
1051 | Size inBufferSize, | |
1052 | Ptr outBuffer, | |
1053 | Size * outActualSize) | |
1054 | { | |
1055 | #if UMA_USE_APPEARANCE | |
1056 | if ( UMAHasAppearance() ) | |
1057 | { | |
1058 | return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; | |
1059 | } | |
1060 | else | |
1061 | #endif | |
1062 | #if !TARGET_CARBON | |
1063 | { | |
1064 | return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; | |
1065 | } | |
1066 | #else | |
1067 | { | |
1068 | return noErr ; | |
1069 | } | |
1070 | #endif | |
1071 | } | |
1072 | ||
1073 | ||
1074 | OSErr UMAGetControlDataSize (ControlHandle inControl, | |
1075 | ControlPartCode inPart, | |
1076 | ResType inTagName, | |
1077 | Size * outMaxSize) | |
1078 | { | |
1079 | #if UMA_USE_APPEARANCE | |
1080 | if ( UMAHasAppearance() ) | |
1081 | { | |
1082 | return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; | |
1083 | } | |
1084 | else | |
1085 | #endif | |
1086 | #if !TARGET_CARBON | |
1087 | { | |
1088 | return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; | |
1089 | } | |
1090 | #else | |
1091 | { | |
1092 | return noErr ; | |
1093 | } | |
1094 | #endif | |
1095 | } | |
1096 | ||
1097 | ||
1098 | ||
1099 | ||
1100 | ||
1101 | // system 8.0 changes | |
1102 | ||
1103 | short UMAFindWindow( Point inPoint , WindowRef *outWindow ) | |
1104 | { | |
1105 | // todo add the additional area codes | |
1106 | return FindWindow( inPoint , outWindow ) ; | |
1107 | } | |
1108 | ||
1109 | OSStatus UMAGetWindowFeatures( WindowRef inWindowRef , UInt32 *outFeatures ) | |
1110 | { | |
1111 | #if UMA_USE_WINDOWMGR | |
1112 | return GetWindowFeatures( inWindowRef , outFeatures ) ; | |
1113 | #else | |
1114 | return 0 ; | |
1115 | #endif | |
1116 | } | |
1117 | ||
1118 | OSStatus UMAGetWindowRegion( WindowRef inWindowRef , WindowRegionCode inRegionCode , RgnHandle ioWinRgn ) | |
1119 | { | |
1120 | #if UMA_USE_WINDOWMGR | |
1121 | return GetWindowRegion( inWindowRef , inRegionCode , ioWinRgn ) ; | |
1122 | #else | |
1123 | return 0 ; | |
1124 | #endif | |
1125 | } | |
1126 | ||
1127 | void UMADrawGrowIcon( WindowRef inWindowRef ) | |
1128 | { | |
1129 | DrawGrowIcon( inWindowRef ) ; | |
1130 | } | |
1131 | ||
1132 | OSStatus UMACollapseWindow( WindowRef inWindowRef , Boolean inCollapseIt ) | |
1133 | { | |
1134 | return CollapseWindow( inWindowRef , inCollapseIt ) ; | |
1135 | } | |
1136 | ||
1137 | OSStatus UMACollapseAllWindows( Boolean inCollapseEm ) | |
1138 | { | |
1139 | return CollapseAllWindows( inCollapseEm ) ; | |
1140 | } | |
1141 | ||
1142 | Boolean UMAIsWindowCollapsed( WindowRef inWindowRef ) | |
1143 | { | |
1144 | return IsWindowCollapsed( inWindowRef ) ; | |
1145 | } | |
1146 | ||
1147 | Boolean UMAIsWindowCollapsable( WindowRef inWindowRef ) | |
1148 | { | |
1149 | return IsWindowCollapsable( inWindowRef ) ; | |
1150 | } | |
1151 | ||
1152 | // system 8.5 changes<MacWindows.h> | |
1153 | OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attributes , const Rect *bounds, WindowRef *outWindow ) | |
1154 | { | |
1155 | #if UMA_USE_WINDOWMGR | |
1156 | if ( UMAHasWindowManager() ) | |
1157 | { | |
1158 | return CreateNewWindow( windowClass , attributes, bounds, outWindow ) ; | |
1159 | } | |
1160 | else | |
1161 | #endif | |
1162 | { | |
1163 | short procID ; | |
1164 | if ( UMAHasAppearance() ) | |
1165 | { | |
1166 | switch( windowClass ) | |
1167 | { | |
1168 | case kMovableModalWindowClass : | |
1169 | procID = kWindowMovableModalDialogProc; | |
1170 | break ; | |
1171 | case kModalWindowClass : | |
1172 | procID = kWindowShadowDialogProc; | |
1173 | break ; | |
1174 | case kFloatingWindowClass : | |
1175 | if ( attributes & kWindowSideTitlebarAttribute ) | |
1176 | { | |
1177 | if( ( attributes & kWindowResizableAttribute ) && | |
1178 | ( attributes & kWindowFullZoomAttribute ) ) | |
1179 | { | |
1180 | procID = kWindowFloatSideFullZoomGrowProc ; | |
1181 | } | |
1182 | else if( attributes & kWindowFullZoomAttribute ) | |
1183 | { | |
1184 | procID = kWindowFloatSideFullZoomProc; | |
1185 | } | |
1186 | else if ( attributes & kWindowResizableAttribute ) | |
1187 | { | |
1188 | procID = kWindowFloatSideGrowProc; | |
1189 | } | |
1190 | else | |
1191 | { | |
1192 | procID = kWindowFloatSideProc; | |
1193 | } | |
1194 | } | |
1195 | else | |
1196 | { | |
1197 | if( ( attributes & kWindowResizableAttribute ) && | |
1198 | ( attributes & kWindowFullZoomAttribute ) ) | |
1199 | { | |
1200 | procID = kWindowFloatFullZoomGrowProc ; | |
1201 | } | |
1202 | else if( attributes & kWindowFullZoomAttribute ) | |
1203 | { | |
1204 | procID = kWindowFloatFullZoomProc; | |
1205 | } | |
1206 | else if ( attributes & kWindowResizableAttribute ) | |
1207 | { | |
1208 | procID = kWindowFloatGrowProc; | |
1209 | } | |
1210 | else | |
1211 | { | |
1212 | procID = kWindowFloatProc; | |
1213 | } | |
1214 | } | |
1215 | break ; | |
1216 | case kDocumentWindowClass : | |
1217 | default : | |
1218 | if( ( attributes & kWindowResizableAttribute ) && | |
1219 | ( attributes & kWindowFullZoomAttribute ) ) | |
1220 | { | |
1221 | procID = kWindowFullZoomGrowDocumentProc; | |
1222 | } | |
1223 | else if( attributes & kWindowFullZoomAttribute ) | |
1224 | { | |
1225 | procID = kWindowFullZoomDocumentProc; | |
1226 | } | |
1227 | else if ( attributes & kWindowResizableAttribute ) | |
1228 | { | |
1229 | procID = kWindowGrowDocumentProc; | |
1230 | } | |
1231 | else | |
1232 | { | |
1233 | procID = kWindowDocumentProc; | |
1234 | } | |
1235 | break ; | |
1236 | } | |
1237 | } | |
1238 | else | |
1239 | { | |
1240 | switch( windowClass ) | |
1241 | { | |
1242 | case kMovableModalWindowClass : | |
1243 | procID = movableDBoxProc; | |
1244 | break ; | |
1245 | case kModalWindowClass : | |
1246 | procID = altDBoxProc; | |
1247 | break ; | |
1248 | case kFloatingWindowClass : | |
1249 | if ( attributes & kWindowSideTitlebarAttribute ) | |
1250 | { | |
1251 | if( ( attributes & kWindowResizableAttribute ) && | |
1252 | ( attributes & kWindowFullZoomAttribute ) ) | |
1253 | { | |
1254 | procID = floatSideZoomGrowProc ; | |
1255 | } | |
1256 | else if( attributes & kWindowFullZoomAttribute ) | |
1257 | { | |
1258 | procID = floatSideZoomProc; | |
1259 | } | |
1260 | else if ( attributes & kWindowResizableAttribute ) | |
1261 | { | |
1262 | procID = floatSideGrowProc; | |
1263 | } | |
1264 | else | |
1265 | { | |
1266 | procID = floatSideProc; | |
1267 | } | |
1268 | } | |
1269 | else | |
1270 | { | |
1271 | if( ( attributes & kWindowResizableAttribute ) && | |
1272 | ( attributes & kWindowFullZoomAttribute ) ) | |
1273 | { | |
1274 | procID = floatZoomGrowProc ; | |
1275 | } | |
1276 | else if( attributes & kWindowFullZoomAttribute ) | |
1277 | { | |
1278 | procID = floatZoomProc; | |
1279 | } | |
1280 | else if ( attributes & kWindowResizableAttribute ) | |
1281 | { | |
1282 | procID = floatGrowProc; | |
1283 | } | |
1284 | else | |
1285 | { | |
1286 | procID = floatProc; | |
1287 | } | |
1288 | } | |
1289 | break ; | |
1290 | case kDocumentWindowClass : | |
1291 | default : | |
1292 | if( ( attributes & kWindowResizableAttribute ) && | |
1293 | ( attributes & kWindowFullZoomAttribute ) ) | |
1294 | { | |
1295 | procID = zoomDocProc; | |
1296 | } | |
1297 | else if( attributes & kWindowFullZoomAttribute ) | |
1298 | { | |
1299 | procID = zoomNoGrow; | |
1300 | } | |
1301 | else if ( attributes & kWindowResizableAttribute ) | |
1302 | { | |
1303 | procID = documentProc; | |
1304 | } | |
1305 | else | |
1306 | { | |
1307 | procID = noGrowDocProc; | |
1308 | } | |
1309 | break ; | |
1310 | break ; | |
1311 | } | |
1312 | } | |
1313 | *outWindow = NewCWindow(nil, bounds, "\p", false, procID, (WindowRef) -1 /*behind*/, | |
1314 | attributes & kWindowCloseBoxAttribute , (long)NULL); | |
1315 | return noErr ; | |
1316 | } | |
1317 | } | |
1318 | ||
1319 | OSStatus UMAGetWindowClass( WindowRef inWindowRef , WindowClass *outWindowClass ) | |
1320 | { | |
1321 | #if UMA_USE_WINDOWMGR | |
1322 | if ( UMAHasWindowManager() ) | |
1323 | { | |
1324 | return GetWindowClass( inWindowRef , outWindowClass ) ; | |
1325 | } | |
1326 | else | |
1327 | #endif | |
1328 | return kDocumentWindowClass ; | |
1329 | } | |
1330 | ||
1331 | OSStatus UMAGetWindowAttributes( WindowRef inWindowRef , WindowAttributes *outAttributes ) | |
1332 | { | |
1333 | #if UMA_USE_WINDOWMGR | |
1334 | if ( UMAHasWindowManager() ) | |
1335 | { | |
1336 | return GetWindowAttributes( inWindowRef , outAttributes ) ; | |
1337 | } | |
1338 | #endif | |
1339 | return kWindowNoAttributes ; | |
1340 | } | |
1341 | ||
1342 | void UMAShowFloatingWindows() | |
1343 | { | |
1344 | #if UMA_USE_WINDOWMGR | |
1345 | if ( UMAHasWindowManager() ) | |
1346 | { | |
1347 | ShowFloatingWindows() ; | |
1348 | } | |
1349 | #endif | |
1350 | } | |
1351 | ||
1352 | void UMAHideFloatingWindows() | |
1353 | { | |
1354 | #if UMA_USE_WINDOWMGR | |
1355 | if ( UMAHasWindowManager() ) | |
1356 | { | |
1357 | HideFloatingWindows() ; | |
1358 | } | |
1359 | #endif | |
1360 | } | |
1361 | ||
1362 | Boolean UMAAreFloatingWindowsVisible() | |
1363 | { | |
1364 | #if UMA_USE_WINDOWMGR | |
1365 | if ( UMAHasWindowManager() ) | |
1366 | { | |
1367 | return AreFloatingWindowsVisible() ; | |
1368 | } | |
1369 | #endif | |
1370 | return false ; | |
1371 | } | |
1372 | ||
1373 | WindowRef UMAFrontNonFloatingWindow() | |
1374 | { | |
1375 | #if UMA_USE_WINDOWMGR | |
1376 | if ( UMAHasWindowManager() ) | |
1377 | { | |
1378 | return FrontNonFloatingWindow() ; | |
1379 | } | |
1380 | else | |
1381 | #endif | |
1382 | { | |
1383 | return FrontWindow() ; | |
1384 | } | |
1385 | } | |
1386 | ||
1387 | WindowRef UMAFrontWindow() | |
1388 | { | |
1389 | #if UMA_USE_WINDOWMGR | |
1390 | if ( UMAHasWindowManager() ) | |
1391 | { | |
1392 | return FrontWindow() ; | |
1393 | } | |
1394 | else | |
1395 | #endif | |
1396 | { | |
1397 | return FrontWindow() ; | |
1398 | } | |
1399 | } | |
1400 | ||
1401 | WindowRef UMAGetActiveNonFloatingWindow() | |
1402 | { | |
1403 | return NULL ; | |
1404 | } | |
1405 | ||
1406 | bool UMAIsWindowFloating( WindowRef inWindow ) | |
1407 | { | |
1408 | WindowClass cl ; | |
1409 | ||
1410 | UMAGetWindowClass( inWindow , &cl ) ; | |
1411 | return cl == kFloatingWindowClass ; | |
1412 | } | |
1413 | ||
1414 | bool UMAIsWindowModal( WindowRef inWindow ) | |
1415 | { | |
1416 | WindowClass cl ; | |
1417 | ||
1418 | UMAGetWindowClass( inWindow , &cl ) ; | |
1419 | return cl < kFloatingWindowClass ; | |
1420 | } | |
1421 | ||
1422 | // others | |
1423 | ||
1424 | void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) | |
1425 | { | |
1426 | if ( inWindowRef ) | |
1427 | { | |
1428 | // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; | |
1429 | // if ( inActivate != isHightlited ) | |
1430 | GrafPtr port ; | |
1431 | GetPort( &port ) ; | |
1432 | #if TARGET_CARBON | |
1433 | SetPort( GetWindowPort( inWindowRef ) ) ; | |
1434 | #else | |
1435 | SetPort( inWindowRef ) ; | |
1436 | #endif | |
1437 | SetOrigin( 0 , 0 ) ; | |
1438 | HiliteWindow( inWindowRef , inActivate ) ; | |
1439 | ControlHandle control = NULL ; | |
1440 | UMAGetRootControl( inWindowRef , & control ) ; | |
1441 | if ( control ) | |
1442 | { | |
1443 | if ( inActivate ) | |
1444 | UMAActivateControl( control ) ; | |
1445 | else | |
1446 | UMADeactivateControl( control ) ; | |
1447 | } | |
1448 | SetPort( port ) ; | |
1449 | } | |
1450 | } | |
1451 | OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) | |
1452 | { | |
1453 | #if UMA_USE_APPEARANCE | |
1454 | if ( UMAHasAppearance() ) | |
1455 | { | |
1456 | ::DrawThemePlacard( inRect , inState ) ; | |
1457 | } | |
1458 | else | |
1459 | #endif | |
1460 | #if !TARGET_CARBON | |
1461 | { | |
1462 | } | |
1463 | #else | |
1464 | { | |
1465 | } | |
1466 | #endif | |
1467 | return noErr ; | |
1468 | } | |
1469 |