]>
Commit | Line | Data |
---|---|---|
03e11df5 | 1 | #include "wx/defs.h" |
5fde6fcc | 2 | #include "wx/dc.h" |
03e11df5 GD |
3 | #include "wx/mac/uma.h" |
4 | #include "wx/mac/aga.h" | |
72e7876b | 5 | |
03e11df5 | 6 | #ifdef __UNIX__ |
5fde6fcc | 7 | #include <Carbon/Carbon.h> |
03e11df5 GD |
8 | #else |
9 | #include <Navigation.h> | |
10 | #endif | |
5b781a67 | 11 | |
72e7876b SC |
12 | // init |
13 | ||
e7b596fb SC |
14 | #if !TARGET_CARBON |
15 | #define GetControlOwner( control ) (**control).contrlOwner | |
16 | #endif | |
17 | ||
72e7876b SC |
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 ; } | |
5b781a67 SC |
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 | } | |
72e7876b SC |
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(); | |
72e7876b SC |
51 | ::InitMenus(); |
52 | ::TEInit(); | |
53 | ::InitDialogs(0L); | |
54 | ::FlushEvents(everyEvent, 0); | |
55 | ::InitCursor(); | |
56 | long total,contig; | |
57 | PurgeSpace(&total, &contig); | |
58 | #else | |
2f1ae414 | 59 | InitCursor(); |
72e7876b SC |
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 | |
5b781a67 | 86 | |
03e11df5 | 87 | #ifndef __UNIX__ |
8e8d3ba8 SC |
88 | #if TARGET_CARBON |
89 | // Call currently implicitely done : InitFloatingWindows() ; | |
90 | #else | |
5b781a67 SC |
91 | if ( sUMAHasWindowManager ) |
92 | InitFloatingWindows() ; | |
93 | else | |
94 | InitWindows(); | |
8e8d3ba8 | 95 | #endif |
03e11df5 | 96 | #endif |
5b781a67 SC |
97 | |
98 | if ( NavServicesAvailable() ) | |
99 | { | |
100 | NavLoad() ; | |
101 | } | |
72e7876b SC |
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 | ||
2f1ae414 | 129 | void UMASetMenuTitle( MenuRef menu , StringPtr title ) |
72e7876b SC |
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 | { | |
2f1ae414 | 159 | #if UMA_USE_APPEARANCE |
72e7876b SC |
160 | if ( UMAHasAppearance() ) |
161 | { | |
162 | return MenuEvent( inEvent ) ; | |
163 | } | |
164 | else | |
2f1ae414 | 165 | #endif |
72e7876b SC |
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 | { | |
2f1ae414 | 177 | #if UMA_USE_8_6 || TARGET_CARBON |
72e7876b SC |
178 | EnableMenuItem( inMenu , inItem ) ; |
179 | #else | |
180 | EnableItem( inMenu , inItem ) ; | |
181 | #endif | |
182 | } | |
183 | ||
184 | void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem ) | |
185 | { | |
2f1ae414 | 186 | #if UMA_USE_8_6 || TARGET_CARBON |
72e7876b SC |
187 | DisableMenuItem( inMenu , inItem ) ; |
188 | #else | |
189 | DisableItem( inMenu , inItem ) ; | |
190 | #endif | |
191 | } | |
2f1ae414 SC |
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 | ||
72e7876b SC |
288 | // quickdraw |
289 | ||
2f1ae414 SC |
290 | int gPrOpenCounter = 0 ; |
291 | ||
5b781a67 | 292 | OSStatus UMAPrOpen() |
2f1ae414 SC |
293 | { |
294 | #if !TARGET_CARBON | |
295 | OSErr err = noErr ; | |
296 | ++gPrOpenCounter ; | |
297 | if ( gPrOpenCounter == 1 ) | |
298 | { | |
299 | PrOpen() ; | |
300 | err = PrError() ; | |
301 | wxASSERT( err == noErr ) ; | |
302 | } | |
5b781a67 | 303 | return err ; |
2f1ae414 | 304 | #else |
5b781a67 SC |
305 | OSStatus err = noErr ; |
306 | ++gPrOpenCounter ; | |
307 | if ( gPrOpenCounter == 1 ) | |
308 | { | |
309 | err = PMBegin() ; | |
310 | wxASSERT( err == noErr ) ; | |
311 | } | |
312 | return err ; | |
2f1ae414 SC |
313 | #endif |
314 | } | |
315 | ||
5b781a67 | 316 | OSStatus UMAPrClose() |
2f1ae414 SC |
317 | { |
318 | #if !TARGET_CARBON | |
319 | OSErr err = noErr ; | |
320 | wxASSERT( gPrOpenCounter >= 1 ) ; | |
321 | if ( gPrOpenCounter == 1 ) | |
322 | { | |
323 | PrClose() ; | |
324 | err = PrError() ; | |
325 | wxASSERT( err == noErr ) ; | |
326 | } | |
327 | --gPrOpenCounter ; | |
5b781a67 | 328 | return err ; |
2f1ae414 | 329 | #else |
5b781a67 SC |
330 | OSStatus err = noErr ; |
331 | wxASSERT( gPrOpenCounter >= 1 ) ; | |
332 | if ( gPrOpenCounter == 1 ) | |
333 | { | |
334 | err = PMEnd() ; | |
335 | } | |
336 | --gPrOpenCounter ; | |
337 | return err ; | |
2f1ae414 SC |
338 | #endif |
339 | } | |
340 | ||
72e7876b SC |
341 | #if !TARGET_CARBON |
342 | ||
343 | pascal QDGlobalsPtr GetQDGlobalsPtr (void) | |
344 | { | |
345 | return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); | |
346 | } | |
347 | ||
348 | #endif | |
349 | ||
350 | void UMAShowWatchCursor() | |
351 | { | |
352 | OSErr err = noErr; | |
353 | ||
354 | CursHandle watchFob = GetCursor (watchCursor); | |
355 | ||
356 | if (!watchFob) | |
357 | err = nilHandleErr; | |
358 | else | |
359 | { | |
360 | #if TARGET_CARBON | |
361 | Cursor preservedArrow; | |
362 | GetQDGlobalsArrow (&preservedArrow); | |
363 | SetQDGlobalsArrow (*watchFob); | |
364 | InitCursor ( ); | |
365 | SetQDGlobalsArrow (&preservedArrow); | |
366 | #else | |
367 | SetCursor (*watchFob); | |
368 | #endif | |
369 | } | |
370 | } | |
371 | ||
372 | void UMAShowArrowCursor() | |
373 | { | |
374 | #if TARGET_CARBON | |
375 | Cursor arrow; | |
376 | SetCursor (GetQDGlobalsArrow (&arrow)); | |
377 | #else | |
378 | SetCursor (&(qd.arrow)); | |
379 | #endif | |
380 | } | |
381 | ||
382 | // window manager | |
383 | ||
384 | GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) | |
385 | { | |
386 | wxASSERT( inWindowRef != NULL ) ; | |
387 | #if TARGET_CARBON | |
388 | return GetWindowPort( inWindowRef ) ; | |
389 | #else | |
390 | return (GrafPtr) inWindowRef ; | |
391 | #endif | |
392 | } | |
393 | ||
394 | void UMADisposeWindow( WindowRef inWindowRef ) | |
395 | { | |
396 | wxASSERT( inWindowRef != NULL ) ; | |
397 | DisposeWindow( inWindowRef ) ; | |
398 | } | |
399 | ||
400 | void UMASetWTitleC( WindowRef inWindowRef , const char *title ) | |
401 | { | |
402 | Str255 ptitle ; | |
403 | strncpy( (char*)ptitle , title , 96 ) ; | |
404 | ptitle[96] = 0 ; | |
03e11df5 GD |
405 | #if TARGET_CARBON |
406 | c2pstrcpy( ptitle, (char *)ptitle ) ; | |
407 | #else | |
72e7876b | 408 | c2pstr( (char*)ptitle ) ; |
03e11df5 | 409 | #endif |
72e7876b SC |
410 | SetWTitle( inWindowRef , ptitle ) ; |
411 | } | |
03e11df5 | 412 | |
72e7876b SC |
413 | void UMAGetWTitleC( WindowRef inWindowRef , char *title ) |
414 | { | |
415 | GetWTitle( inWindowRef , (unsigned char*)title ) ; | |
03e11df5 GD |
416 | #if TARGET_CARBON |
417 | p2cstrcpy( title, (unsigned char *)title ) ; | |
418 | #else | |
72e7876b | 419 | p2cstr( (unsigned char*)title ) ; |
03e11df5 | 420 | #endif |
72e7876b SC |
421 | } |
422 | ||
423 | void UMAShowWindow( WindowRef inWindowRef ) | |
424 | { | |
425 | ShowWindow( inWindowRef ) ; | |
426 | } | |
427 | ||
428 | void UMAHideWindow( WindowRef inWindowRef ) | |
429 | { | |
430 | HideWindow( inWindowRef) ; | |
431 | } | |
432 | ||
433 | void UMASelectWindow( WindowRef inWindowRef ) | |
434 | { | |
435 | SelectWindow( inWindowRef ) ; | |
436 | } | |
437 | ||
438 | void UMABringToFront( WindowRef inWindowRef ) | |
439 | { | |
440 | BringToFront( inWindowRef ) ; | |
441 | } | |
442 | ||
443 | void UMASendBehind( WindowRef inWindowRef , WindowRef behindWindow ) | |
444 | { | |
445 | SendBehind( inWindowRef , behindWindow ) ; | |
446 | } | |
447 | ||
448 | void UMACloseWindow(WindowRef inWindowRef) | |
449 | { | |
450 | #if TARGET_CARBON | |
451 | #else | |
452 | CloseWindow( inWindowRef ) ; | |
453 | #endif | |
454 | } | |
455 | ||
456 | // appearance additions | |
457 | ||
458 | void UMAActivateControl( ControlHandle inControl ) | |
459 | { | |
e7b596fb SC |
460 | RgnHandle updateRgn = NewRgn() ; |
461 | GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; | |
2f1ae414 | 462 | #if UMA_USE_APPEARANCE |
72e7876b SC |
463 | if ( UMAHasAppearance() ) |
464 | { | |
465 | ::ActivateControl( inControl ) ; | |
466 | } | |
467 | else | |
2f1ae414 SC |
468 | #endif |
469 | #if !TARGET_CARBON | |
72e7876b SC |
470 | { |
471 | AGAActivateControl( inControl ) ; | |
472 | } | |
2f1ae414 SC |
473 | #else |
474 | { | |
475 | } | |
476 | #endif | |
e7b596fb | 477 | InvalRgn( updateRgn ) ; |
72e7876b SC |
478 | } |
479 | ||
480 | void UMADrawControl( ControlHandle inControl ) | |
481 | { | |
e7b596fb SC |
482 | RgnHandle updateRgn = NewRgn() ; |
483 | GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; | |
2f1ae414 | 484 | #if UMA_USE_APPEARANCE |
72e7876b SC |
485 | if ( UMAHasAppearance() ) |
486 | { | |
487 | ::DrawControlInCurrentPort( inControl ) ; | |
488 | } | |
489 | else | |
2f1ae414 SC |
490 | #endif |
491 | #if !TARGET_CARBON | |
72e7876b SC |
492 | { |
493 | AGADrawControl( inControl ) ; | |
494 | } | |
2f1ae414 SC |
495 | #else |
496 | { | |
497 | } | |
498 | #endif | |
e7b596fb | 499 | InvalRgn( updateRgn ) ; |
72e7876b SC |
500 | } |
501 | ||
502 | void UMAMoveControl( ControlHandle inControl , short x , short y ) | |
503 | { | |
e7b596fb SC |
504 | RgnHandle updateRgn = NewRgn() ; |
505 | GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; | |
2f1ae414 | 506 | #if UMA_USE_APPEARANCE |
72e7876b SC |
507 | if ( UMAHasAppearance() ) |
508 | { | |
509 | ::MoveControl( inControl , x , y ) ; | |
510 | } | |
511 | else | |
2f1ae414 SC |
512 | #endif |
513 | #if !TARGET_CARBON | |
72e7876b SC |
514 | { |
515 | AGAMoveControl( inControl , x ,y ) ; | |
516 | } | |
2f1ae414 SC |
517 | #else |
518 | { | |
519 | } | |
520 | #endif | |
e7b596fb | 521 | InvalRgn( updateRgn ) ; |
72e7876b SC |
522 | } |
523 | ||
524 | void UMASizeControl( ControlHandle inControl , short x , short y ) | |
525 | { | |
e7b596fb SC |
526 | RgnHandle updateRgn = NewRgn() ; |
527 | GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; | |
2f1ae414 | 528 | #if UMA_USE_APPEARANCE |
72e7876b SC |
529 | if ( UMAHasAppearance() ) |
530 | { | |
531 | ::SizeControl( inControl , x , y ) ; | |
532 | } | |
533 | else | |
2f1ae414 SC |
534 | #endif |
535 | #if !TARGET_CARBON | |
72e7876b SC |
536 | { |
537 | AGASizeControl( inControl , x ,y ) ; | |
538 | } | |
2f1ae414 SC |
539 | #else |
540 | { | |
541 | } | |
542 | #endif | |
e7b596fb | 543 | InvalRgn( updateRgn ) ; |
72e7876b SC |
544 | } |
545 | ||
546 | void UMADeactivateControl( ControlHandle inControl ) | |
547 | { | |
e7b596fb SC |
548 | RgnHandle updateRgn = NewRgn() ; |
549 | GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ; | |
2f1ae414 | 550 | #if UMA_USE_APPEARANCE |
72e7876b SC |
551 | if ( UMAHasAppearance() ) |
552 | { | |
553 | ::DeactivateControl( inControl ) ; | |
554 | } | |
555 | else | |
2f1ae414 SC |
556 | #endif |
557 | #if !TARGET_CARBON | |
72e7876b SC |
558 | { |
559 | AGADeactivateControl( inControl ) ; | |
560 | } | |
2f1ae414 SC |
561 | #else |
562 | { | |
563 | } | |
564 | #endif | |
e7b596fb | 565 | InvalRgn( updateRgn ) ; |
72e7876b SC |
566 | } |
567 | ||
568 | void UMASetThemeWindowBackground (WindowRef inWindow, | |
569 | ThemeBrush inBrush, | |
2f1ae414 SC |
570 | Boolean inUpdate) |
571 | { | |
572 | #if UMA_USE_APPEARANCE | |
72e7876b SC |
573 | if ( UMAHasAppearance() ) |
574 | { | |
575 | ::SetThemeWindowBackground( inWindow ,inBrush , inUpdate ) ; | |
576 | } | |
577 | else | |
2f1ae414 SC |
578 | #endif |
579 | #if !TARGET_CARBON | |
72e7876b SC |
580 | { |
581 | AGASetThemeWindowBackground( inWindow , inBrush , inUpdate ) ; | |
582 | } | |
2f1ae414 SC |
583 | #else |
584 | { | |
585 | } | |
586 | #endif | |
72e7876b SC |
587 | } |
588 | ||
2f1ae414 SC |
589 | void UMAApplyThemeBackground (ThemeBackgroundKind inKind, |
590 | const Rect * bounds, | |
591 | ThemeDrawState inState, | |
592 | SInt16 inDepth, | |
593 | Boolean inColorDev) | |
594 | { | |
595 | #if UMA_USE_APPEARANCE | |
596 | if ( UMAHasAppearance() ) | |
597 | { | |
598 | /* | |
599 | if ( sUMAAppearanceVersion >= 0x0110 ) | |
600 | ::ApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ; | |
601 | */ | |
602 | } | |
603 | else | |
604 | #endif | |
605 | #if !TARGET_CARBON | |
606 | { | |
607 | AGAApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ; | |
608 | } | |
609 | #else | |
610 | { | |
611 | } | |
612 | #endif | |
613 | } | |
72e7876b SC |
614 | |
615 | ControlHandle UMANewControl(WindowPtr owningWindow, | |
616 | const Rect * boundsRect, | |
617 | ConstStr255Param controlTitle, | |
618 | Boolean initiallyVisible, | |
619 | SInt16 initialValue, | |
620 | SInt16 minimumValue, | |
621 | SInt16 maximumValue, | |
622 | SInt16 procID, | |
623 | SInt32 controlReference) | |
624 | { | |
625 | ControlHandle theControl = NULL ; | |
2f1ae414 | 626 | #if UMA_USE_APPEARANCE |
72e7876b SC |
627 | if ( UMAHasAppearance() ) |
628 | { | |
629 | theControl = NewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , | |
630 | initialValue , minimumValue , maximumValue , procID , controlReference ) ; | |
631 | } | |
632 | else | |
2f1ae414 SC |
633 | #endif |
634 | #if !TARGET_CARBON | |
72e7876b SC |
635 | { |
636 | theControl = AGANewControl( owningWindow , boundsRect , controlTitle , initiallyVisible , | |
637 | initialValue , minimumValue , maximumValue , procID , controlReference ) ; | |
638 | } | |
2f1ae414 SC |
639 | #else |
640 | { | |
641 | } | |
642 | #endif | |
72e7876b SC |
643 | return theControl ; |
644 | } | |
645 | ||
646 | void UMADisposeControl (ControlHandle theControl) | |
647 | { | |
648 | if ( UMAHasAppearance() ) | |
649 | { | |
650 | ::DisposeControl( theControl ) ; | |
651 | } | |
652 | else | |
653 | { | |
654 | ::DisposeControl( theControl ) ; | |
655 | } | |
656 | } | |
657 | ||
658 | ||
659 | void UMAHiliteControl (ControlHandle theControl, | |
660 | ControlPartCode hiliteState) | |
661 | { | |
e7b596fb SC |
662 | RgnHandle updateRgn = NewRgn() ; |
663 | GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ; | |
72e7876b SC |
664 | if ( UMAHasAppearance() ) |
665 | { | |
666 | ::HiliteControl( theControl , hiliteState ) ; | |
667 | } | |
668 | else | |
669 | { | |
670 | ::HiliteControl( theControl , hiliteState ) ; | |
671 | } | |
e7b596fb | 672 | InvalRgn( updateRgn ) ; |
72e7876b SC |
673 | } |
674 | ||
675 | ||
676 | void UMAShowControl (ControlHandle theControl) | |
677 | { | |
e7b596fb SC |
678 | RgnHandle updateRgn = NewRgn() ; |
679 | GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ; | |
72e7876b SC |
680 | if ( UMAHasAppearance() ) |
681 | { | |
682 | ::ShowControl( theControl ) ; | |
683 | } | |
684 | else | |
685 | { | |
686 | ::ShowControl( theControl ) ; | |
687 | } | |
e7b596fb | 688 | InvalRgn( updateRgn ) ; |
72e7876b SC |
689 | } |
690 | ||
691 | ||
692 | void UMAHideControl (ControlHandle theControl) | |
693 | { | |
694 | if ( UMAHasAppearance() ) | |
695 | { | |
c809f3be | 696 | ::HideControl( theControl ) ; |
72e7876b SC |
697 | } |
698 | else | |
699 | { | |
c809f3be | 700 | ::HideControl( theControl ) ; |
72e7876b SC |
701 | } |
702 | } | |
703 | ||
704 | ||
705 | void UMASetControlVisibility (ControlHandle inControl, | |
706 | Boolean inIsVisible, | |
707 | Boolean inDoDraw) | |
708 | { | |
709 | if ( UMAHasAppearance() ) | |
710 | { | |
2f1ae414 | 711 | #if UMA_USE_APPEARANCE |
72e7876b | 712 | ::SetControlVisibility( inControl , inIsVisible, inDoDraw ) ; |
2f1ae414 | 713 | #endif |
72e7876b SC |
714 | } |
715 | } | |
716 | ||
717 | ||
718 | ||
719 | bool UMAIsControlActive (ControlHandle inControl) | |
720 | { | |
2f1ae414 SC |
721 | #if TARGET_CARBON |
722 | return IsControlActive( inControl ) ; | |
723 | #else | |
724 | #if UMA_USE_APPEARANCE | |
72e7876b SC |
725 | if ( UMAHasAppearance() ) |
726 | { | |
727 | return IsControlActive( inControl ) ; | |
728 | } | |
729 | else | |
2f1ae414 | 730 | #endif |
72e7876b | 731 | return (**inControl).contrlHilite == 0 ; |
2f1ae414 | 732 | #endif |
72e7876b SC |
733 | } |
734 | ||
735 | ||
736 | bool UMAIsControlVisible (ControlHandle inControl) | |
737 | { | |
2f1ae414 | 738 | #if UMA_USE_APPEARANCE |
72e7876b SC |
739 | if ( UMAHasAppearance() ) |
740 | { | |
741 | return IsControlVisible( inControl ) ; | |
742 | } | |
2f1ae414 | 743 | #endif |
72e7876b SC |
744 | return true ; |
745 | } | |
746 | ||
747 | OSErr UMAGetBestControlRect (ControlHandle inControl, | |
748 | Rect * outRect, | |
749 | SInt16 * outBaseLineOffset) | |
750 | { | |
2f1ae414 | 751 | #if UMA_USE_APPEARANCE |
72e7876b SC |
752 | if ( UMAHasAppearance() ) |
753 | { | |
754 | return GetBestControlRect( inControl , outRect , outBaseLineOffset ) ; | |
755 | } | |
756 | else | |
2f1ae414 SC |
757 | #endif |
758 | #if !TARGET_CARBON | |
72e7876b SC |
759 | { |
760 | return AGAGetBestControlRect( inControl , outRect , outBaseLineOffset ) ; | |
761 | } | |
2f1ae414 SC |
762 | #else |
763 | { | |
764 | return noErr ; | |
765 | } | |
766 | #endif | |
72e7876b SC |
767 | } |
768 | ||
769 | ||
770 | OSErr UMASetControlFontStyle (ControlHandle inControl, | |
771 | const ControlFontStyleRec * inStyle) | |
772 | { | |
2f1ae414 | 773 | #if UMA_USE_APPEARANCE |
72e7876b SC |
774 | if ( UMAHasAppearance() ) |
775 | { | |
776 | return ::SetControlFontStyle( inControl , inStyle ) ; | |
777 | } | |
778 | else | |
2f1ae414 SC |
779 | #endif |
780 | #if !TARGET_CARBON | |
72e7876b | 781 | return AGASetControlFontStyle( inControl , inStyle ) ; |
2f1ae414 SC |
782 | #else |
783 | { | |
784 | return noErr ; | |
785 | } | |
786 | #endif | |
72e7876b SC |
787 | } |
788 | ||
789 | ||
790 | ||
791 | // control hierarchy | |
792 | ||
793 | OSErr UMACreateRootControl (WindowPtr inWindow, | |
794 | ControlHandle * outControl) | |
795 | { | |
2f1ae414 | 796 | #if UMA_USE_APPEARANCE |
72e7876b SC |
797 | if ( UMAHasAppearance() ) |
798 | { | |
799 | return CreateRootControl( inWindow , outControl ) ; | |
800 | } | |
801 | else | |
2f1ae414 SC |
802 | #endif |
803 | #if !TARGET_CARBON | |
72e7876b | 804 | return AGACreateRootControl( inWindow , outControl ) ; |
2f1ae414 SC |
805 | #else |
806 | { | |
807 | return noErr ; | |
808 | } | |
809 | #endif | |
72e7876b SC |
810 | } |
811 | ||
812 | ||
813 | ||
814 | OSErr UMAEmbedControl (ControlHandle inControl, | |
815 | ControlHandle inContainer) | |
816 | { | |
2f1ae414 | 817 | #if UMA_USE_APPEARANCE |
72e7876b SC |
818 | if ( UMAHasAppearance() ) |
819 | { | |
820 | return EmbedControl( inControl , inContainer ) ; | |
821 | } | |
822 | else | |
2f1ae414 SC |
823 | #endif |
824 | #if !TARGET_CARBON | |
72e7876b | 825 | return AGAEmbedControl( inControl , inContainer ) ; ; |
2f1ae414 SC |
826 | #else |
827 | { | |
828 | return noErr ; | |
829 | } | |
830 | #endif | |
72e7876b SC |
831 | } |
832 | ||
833 | ||
834 | ||
835 | // keyboard focus | |
836 | OSErr UMASetKeyboardFocus (WindowPtr inWindow, | |
837 | ControlHandle inControl, | |
838 | ControlFocusPart inPart) | |
839 | { | |
2f1ae414 SC |
840 | OSErr err = noErr; |
841 | GrafPtr port ; | |
842 | GetPort( &port ) ; | |
843 | #if TARGET_CARBON | |
844 | SetPort( GetWindowPort( inWindow ) ) ; | |
845 | #else | |
846 | SetPort( inWindow ) ; | |
847 | #endif | |
848 | SetOrigin( 0 , 0 ) ; | |
849 | #if UMA_USE_APPEARANCE | |
72e7876b SC |
850 | if ( UMAHasAppearance() ) |
851 | { | |
2f1ae414 | 852 | err = SetKeyboardFocus( inWindow , inControl , inPart ) ; |
72e7876b SC |
853 | } |
854 | else | |
2f1ae414 SC |
855 | #endif |
856 | #if !TARGET_CARBON | |
857 | err = AGASetKeyboardFocus( inWindow , inControl , inPart ) ; | |
858 | #else | |
859 | { | |
860 | } | |
861 | #endif | |
862 | SetPort( port ) ; | |
863 | return err ; | |
72e7876b SC |
864 | } |
865 | ||
866 | ||
867 | ||
868 | ||
869 | // events | |
870 | ||
871 | ControlPartCode UMAHandleControlClick (ControlHandle inControl, | |
872 | Point inWhere, | |
873 | SInt16 inModifiers, | |
874 | ControlActionUPP inAction) | |
875 | { | |
2f1ae414 | 876 | #if UMA_USE_APPEARANCE |
72e7876b SC |
877 | if ( UMAHasAppearance() ) |
878 | { | |
879 | return HandleControlClick( inControl , inWhere , inModifiers , inAction ) ; | |
880 | } | |
881 | else | |
2f1ae414 SC |
882 | #endif |
883 | #if !TARGET_CARBON | |
72e7876b SC |
884 | { |
885 | return AGAHandleControlClick( inControl , inWhere , inModifiers , inAction ) ; | |
886 | } | |
2f1ae414 SC |
887 | #else |
888 | { | |
889 | return noErr ; | |
890 | } | |
891 | #endif | |
72e7876b SC |
892 | } |
893 | ||
894 | ||
895 | SInt16 UMAHandleControlKey (ControlHandle inControl, | |
896 | SInt16 inKeyCode, | |
897 | SInt16 inCharCode, | |
898 | SInt16 inModifiers) | |
899 | { | |
2f1ae414 | 900 | #if UMA_USE_APPEARANCE |
72e7876b SC |
901 | if ( UMAHasAppearance() ) |
902 | { | |
903 | return HandleControlKey( inControl , inKeyCode , inCharCode , inModifiers ) ; | |
904 | } | |
905 | else | |
2f1ae414 SC |
906 | #endif |
907 | #if !TARGET_CARBON | |
72e7876b SC |
908 | { |
909 | return AGAHandleControlKey(inControl , inKeyCode , inCharCode , inModifiers ) ; | |
910 | } | |
2f1ae414 SC |
911 | #else |
912 | { | |
913 | return noErr ; | |
914 | } | |
915 | #endif | |
72e7876b SC |
916 | } |
917 | ||
918 | ||
919 | ||
920 | void UMAIdleControls (WindowPtr inWindow) | |
921 | { | |
2f1ae414 | 922 | #if UMA_USE_APPEARANCE |
72e7876b SC |
923 | if ( UMAHasAppearance() ) |
924 | { | |
925 | IdleControls( inWindow ) ; | |
926 | } | |
927 | else | |
2f1ae414 SC |
928 | #endif |
929 | #if !TARGET_CARBON | |
72e7876b SC |
930 | { |
931 | AGAIdleControls( inWindow ) ; | |
932 | } | |
2f1ae414 SC |
933 | #else |
934 | { | |
935 | } | |
936 | #endif | |
72e7876b SC |
937 | } |
938 | ||
939 | void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) | |
940 | { | |
e7b596fb SC |
941 | RgnHandle updateRgn = NewRgn() ; |
942 | GetWindowUpdateRgn( inWindow , updateRgn ) ; | |
2f1ae414 | 943 | #if UMA_USE_APPEARANCE |
72e7876b SC |
944 | if ( UMAHasAppearance() ) |
945 | { | |
946 | UpdateControls( inWindow , inRgn ) ; | |
947 | } | |
948 | else | |
2f1ae414 SC |
949 | #endif |
950 | #if !TARGET_CARBON | |
72e7876b SC |
951 | { |
952 | AGAUpdateControls( inWindow , inRgn ) ; | |
953 | } | |
2f1ae414 SC |
954 | #else |
955 | { | |
956 | } | |
957 | #endif | |
e7b596fb | 958 | InvalRgn( updateRgn ) ; |
72e7876b SC |
959 | } |
960 | ||
961 | OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) | |
962 | { | |
2f1ae414 | 963 | #if UMA_USE_APPEARANCE |
72e7876b SC |
964 | if ( UMAHasAppearance() ) |
965 | { | |
966 | return GetRootControl( inWindow , outControl ) ; | |
967 | } | |
968 | else | |
2f1ae414 SC |
969 | #endif |
970 | #if !TARGET_CARBON | |
72e7876b SC |
971 | { |
972 | return AGAGetRootControl( inWindow , outControl ) ; | |
973 | } | |
2f1ae414 SC |
974 | #else |
975 | { | |
976 | return noErr ; | |
977 | } | |
978 | #endif | |
72e7876b SC |
979 | } |
980 | ||
981 | ||
982 | // handling control data | |
983 | ||
984 | OSErr UMASetControlData (ControlHandle inControl, | |
985 | ControlPartCode inPart, | |
986 | ResType inTagName, | |
987 | Size inSize, | |
988 | Ptr inData) | |
989 | { | |
2f1ae414 | 990 | #if UMA_USE_APPEARANCE |
72e7876b SC |
991 | if ( UMAHasAppearance() ) |
992 | { | |
993 | return SetControlData( inControl , inPart , inTagName , inSize , inData ) ; | |
994 | } | |
995 | else | |
2f1ae414 SC |
996 | #endif |
997 | #if !TARGET_CARBON | |
72e7876b | 998 | return AGASetControlData( inControl , inPart , inTagName , inSize , inData ) ; |
2f1ae414 SC |
999 | #else |
1000 | { | |
1001 | return noErr ; | |
1002 | } | |
1003 | #endif | |
72e7876b SC |
1004 | } |
1005 | ||
1006 | ||
1007 | ||
1008 | OSErr UMAGetControlData (ControlHandle inControl, | |
1009 | ControlPartCode inPart, | |
1010 | ResType inTagName, | |
1011 | Size inBufferSize, | |
1012 | Ptr outBuffer, | |
1013 | Size * outActualSize) | |
1014 | { | |
2f1ae414 | 1015 | #if UMA_USE_APPEARANCE |
72e7876b SC |
1016 | if ( UMAHasAppearance() ) |
1017 | { | |
1018 | return ::GetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; | |
1019 | } | |
1020 | else | |
2f1ae414 SC |
1021 | #endif |
1022 | #if !TARGET_CARBON | |
72e7876b SC |
1023 | { |
1024 | return AGAGetControlData( inControl , inPart , inTagName , inBufferSize , outBuffer , outActualSize ) ; | |
1025 | } | |
2f1ae414 SC |
1026 | #else |
1027 | { | |
1028 | return noErr ; | |
1029 | } | |
1030 | #endif | |
72e7876b SC |
1031 | } |
1032 | ||
1033 | ||
1034 | OSErr UMAGetControlDataSize (ControlHandle inControl, | |
1035 | ControlPartCode inPart, | |
1036 | ResType inTagName, | |
1037 | Size * outMaxSize) | |
1038 | { | |
2f1ae414 | 1039 | #if UMA_USE_APPEARANCE |
72e7876b SC |
1040 | if ( UMAHasAppearance() ) |
1041 | { | |
1042 | return GetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; | |
1043 | } | |
1044 | else | |
2f1ae414 SC |
1045 | #endif |
1046 | #if !TARGET_CARBON | |
72e7876b SC |
1047 | { |
1048 | return AGAGetControlDataSize( inControl , inPart , inTagName , outMaxSize ) ; | |
1049 | } | |
2f1ae414 SC |
1050 | #else |
1051 | { | |
1052 | return noErr ; | |
1053 | } | |
1054 | #endif | |
72e7876b SC |
1055 | } |
1056 | ||
1057 | ||
1058 | ||
1059 | ||
1060 | ||
1061 | // system 8.0 changes | |
1062 | ||
1063 | short UMAFindWindow( Point inPoint , WindowRef *outWindow ) | |
1064 | { | |
1065 | // todo add the additional area codes | |
1066 | return FindWindow( inPoint , outWindow ) ; | |
1067 | } | |
1068 | ||
1069 | OSStatus UMAGetWindowFeatures( WindowRef inWindowRef , UInt32 *outFeatures ) | |
1070 | { | |
1071 | #if UMA_USE_WINDOWMGR | |
1072 | return GetWindowFeatures( inWindowRef , outFeatures ) ; | |
1073 | #else | |
1074 | return 0 ; | |
1075 | #endif | |
1076 | } | |
1077 | ||
1078 | OSStatus UMAGetWindowRegion( WindowRef inWindowRef , WindowRegionCode inRegionCode , RgnHandle ioWinRgn ) | |
1079 | { | |
1080 | #if UMA_USE_WINDOWMGR | |
1081 | return GetWindowRegion( inWindowRef , inRegionCode , ioWinRgn ) ; | |
1082 | #else | |
1083 | return 0 ; | |
1084 | #endif | |
1085 | } | |
1086 | ||
1087 | void UMADrawGrowIcon( WindowRef inWindowRef ) | |
1088 | { | |
1089 | DrawGrowIcon( inWindowRef ) ; | |
1090 | } | |
1091 | ||
1092 | OSStatus UMACollapseWindow( WindowRef inWindowRef , Boolean inCollapseIt ) | |
1093 | { | |
1094 | return CollapseWindow( inWindowRef , inCollapseIt ) ; | |
1095 | } | |
1096 | ||
1097 | OSStatus UMACollapseAllWindows( Boolean inCollapseEm ) | |
1098 | { | |
1099 | return CollapseAllWindows( inCollapseEm ) ; | |
1100 | } | |
1101 | ||
1102 | Boolean UMAIsWindowCollapsed( WindowRef inWindowRef ) | |
1103 | { | |
1104 | return IsWindowCollapsed( inWindowRef ) ; | |
1105 | } | |
1106 | ||
1107 | Boolean UMAIsWindowCollapsable( WindowRef inWindowRef ) | |
1108 | { | |
1109 | return IsWindowCollapsable( inWindowRef ) ; | |
1110 | } | |
1111 | ||
1112 | // system 8.5 changes<MacWindows.h> | |
1113 | OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attributes , const Rect *bounds, WindowRef *outWindow ) | |
1114 | { | |
1115 | #if UMA_USE_WINDOWMGR | |
1116 | if ( UMAHasWindowManager() ) | |
1117 | { | |
1118 | return CreateNewWindow( windowClass , attributes, bounds, outWindow ) ; | |
1119 | } | |
1120 | else | |
1121 | #endif | |
1122 | { | |
1123 | short procID ; | |
1124 | if ( UMAHasAppearance() ) | |
1125 | { | |
1126 | switch( windowClass ) | |
1127 | { | |
1128 | case kMovableModalWindowClass : | |
1129 | procID = kWindowMovableModalDialogProc; | |
1130 | break ; | |
2f1ae414 SC |
1131 | case kModalWindowClass : |
1132 | procID = kWindowShadowDialogProc; | |
1133 | break ; | |
1134 | case kFloatingWindowClass : | |
1135 | if ( attributes & kWindowSideTitlebarAttribute ) | |
1136 | { | |
1137 | if( ( attributes & kWindowResizableAttribute ) && | |
1138 | ( attributes & kWindowFullZoomAttribute ) ) | |
1139 | { | |
1140 | procID = kWindowFloatSideFullZoomGrowProc ; | |
1141 | } | |
1142 | else if( attributes & kWindowFullZoomAttribute ) | |
1143 | { | |
1144 | procID = kWindowFloatSideFullZoomProc; | |
1145 | } | |
1146 | else if ( attributes & kWindowResizableAttribute ) | |
1147 | { | |
1148 | procID = kWindowFloatSideGrowProc; | |
1149 | } | |
1150 | else | |
1151 | { | |
1152 | procID = kWindowFloatSideProc; | |
1153 | } | |
1154 | } | |
1155 | else | |
1156 | { | |
1157 | if( ( attributes & kWindowResizableAttribute ) && | |
1158 | ( attributes & kWindowFullZoomAttribute ) ) | |
1159 | { | |
1160 | procID = kWindowFloatFullZoomGrowProc ; | |
1161 | } | |
1162 | else if( attributes & kWindowFullZoomAttribute ) | |
1163 | { | |
1164 | procID = kWindowFloatFullZoomProc; | |
1165 | } | |
1166 | else if ( attributes & kWindowResizableAttribute ) | |
1167 | { | |
1168 | procID = kWindowFloatGrowProc; | |
1169 | } | |
1170 | else | |
1171 | { | |
1172 | procID = kWindowFloatProc; | |
1173 | } | |
1174 | } | |
72e7876b | 1175 | break ; |
2f1ae414 | 1176 | case kDocumentWindowClass : |
72e7876b | 1177 | default : |
2f1ae414 SC |
1178 | if( ( attributes & kWindowResizableAttribute ) && |
1179 | ( attributes & kWindowFullZoomAttribute ) ) | |
1180 | { | |
1181 | procID = kWindowFullZoomGrowDocumentProc; | |
1182 | } | |
1183 | else if( attributes & kWindowFullZoomAttribute ) | |
1184 | { | |
1185 | procID = kWindowFullZoomDocumentProc; | |
1186 | } | |
1187 | else if ( attributes & kWindowResizableAttribute ) | |
1188 | { | |
1189 | procID = kWindowGrowDocumentProc; | |
1190 | } | |
1191 | else | |
1192 | { | |
1193 | procID = kWindowDocumentProc; | |
1194 | } | |
72e7876b SC |
1195 | break ; |
1196 | } | |
1197 | } | |
1198 | else | |
1199 | { | |
1200 | switch( windowClass ) | |
1201 | { | |
1202 | case kMovableModalWindowClass : | |
1203 | procID = movableDBoxProc; | |
72e7876b | 1204 | break ; |
2f1ae414 SC |
1205 | case kModalWindowClass : |
1206 | procID = altDBoxProc; | |
1207 | break ; | |
1208 | case kFloatingWindowClass : | |
1209 | if ( attributes & kWindowSideTitlebarAttribute ) | |
1210 | { | |
1211 | if( ( attributes & kWindowResizableAttribute ) && | |
1212 | ( attributes & kWindowFullZoomAttribute ) ) | |
1213 | { | |
1214 | procID = floatSideZoomGrowProc ; | |
1215 | } | |
1216 | else if( attributes & kWindowFullZoomAttribute ) | |
1217 | { | |
1218 | procID = floatSideZoomProc; | |
1219 | } | |
1220 | else if ( attributes & kWindowResizableAttribute ) | |
1221 | { | |
1222 | procID = floatSideGrowProc; | |
1223 | } | |
1224 | else | |
1225 | { | |
1226 | procID = floatSideProc; | |
1227 | } | |
1228 | } | |
1229 | else | |
1230 | { | |
1231 | if( ( attributes & kWindowResizableAttribute ) && | |
1232 | ( attributes & kWindowFullZoomAttribute ) ) | |
1233 | { | |
1234 | procID = floatZoomGrowProc ; | |
1235 | } | |
1236 | else if( attributes & kWindowFullZoomAttribute ) | |
1237 | { | |
1238 | procID = floatZoomProc; | |
1239 | } | |
1240 | else if ( attributes & kWindowResizableAttribute ) | |
1241 | { | |
1242 | procID = floatGrowProc; | |
1243 | } | |
1244 | else | |
1245 | { | |
1246 | procID = floatProc; | |
1247 | } | |
1248 | } | |
72e7876b | 1249 | break ; |
2f1ae414 | 1250 | case kDocumentWindowClass : |
72e7876b | 1251 | default : |
2f1ae414 SC |
1252 | if( ( attributes & kWindowResizableAttribute ) && |
1253 | ( attributes & kWindowFullZoomAttribute ) ) | |
1254 | { | |
1255 | procID = zoomDocProc; | |
1256 | } | |
1257 | else if( attributes & kWindowFullZoomAttribute ) | |
1258 | { | |
1259 | procID = zoomNoGrow; | |
1260 | } | |
1261 | else if ( attributes & kWindowResizableAttribute ) | |
1262 | { | |
1263 | procID = documentProc; | |
1264 | } | |
1265 | else | |
1266 | { | |
1267 | procID = noGrowDocProc; | |
1268 | } | |
1269 | break ; | |
72e7876b SC |
1270 | break ; |
1271 | } | |
1272 | } | |
1273 | *outWindow = NewCWindow(nil, bounds, "\p", false, procID, (WindowRef) -1 /*behind*/, | |
1274 | attributes & kWindowCloseBoxAttribute , (long)NULL); | |
1275 | return noErr ; | |
1276 | } | |
1277 | } | |
1278 | ||
1279 | OSStatus UMAGetWindowClass( WindowRef inWindowRef , WindowClass *outWindowClass ) | |
1280 | { | |
1281 | #if UMA_USE_WINDOWMGR | |
1282 | if ( UMAHasWindowManager() ) | |
1283 | { | |
1284 | return GetWindowClass( inWindowRef , outWindowClass ) ; | |
1285 | } | |
1286 | else | |
1287 | #endif | |
1288 | return kDocumentWindowClass ; | |
1289 | } | |
1290 | ||
1291 | OSStatus UMAGetWindowAttributes( WindowRef inWindowRef , WindowAttributes *outAttributes ) | |
1292 | { | |
1293 | #if UMA_USE_WINDOWMGR | |
1294 | if ( UMAHasWindowManager() ) | |
1295 | { | |
1296 | return GetWindowAttributes( inWindowRef , outAttributes ) ; | |
1297 | } | |
1298 | #endif | |
1299 | return kWindowNoAttributes ; | |
1300 | } | |
1301 | ||
1302 | void UMAShowFloatingWindows() | |
1303 | { | |
1304 | #if UMA_USE_WINDOWMGR | |
1305 | if ( UMAHasWindowManager() ) | |
1306 | { | |
1307 | ShowFloatingWindows() ; | |
1308 | } | |
1309 | #endif | |
1310 | } | |
1311 | ||
1312 | void UMAHideFloatingWindows() | |
1313 | { | |
1314 | #if UMA_USE_WINDOWMGR | |
1315 | if ( UMAHasWindowManager() ) | |
1316 | { | |
1317 | HideFloatingWindows() ; | |
1318 | } | |
1319 | #endif | |
1320 | } | |
1321 | ||
1322 | Boolean UMAAreFloatingWindowsVisible() | |
1323 | { | |
1324 | #if UMA_USE_WINDOWMGR | |
1325 | if ( UMAHasWindowManager() ) | |
1326 | { | |
1327 | return AreFloatingWindowsVisible() ; | |
1328 | } | |
1329 | #endif | |
1330 | return false ; | |
1331 | } | |
1332 | ||
1333 | WindowRef UMAFrontNonFloatingWindow() | |
1334 | { | |
1335 | #if UMA_USE_WINDOWMGR | |
1336 | if ( UMAHasWindowManager() ) | |
1337 | { | |
1338 | return FrontNonFloatingWindow() ; | |
1339 | } | |
1340 | else | |
1341 | #endif | |
1342 | { | |
1343 | return FrontWindow() ; | |
1344 | } | |
1345 | } | |
1346 | ||
1347 | WindowRef UMAFrontWindow() | |
1348 | { | |
1349 | #if UMA_USE_WINDOWMGR | |
1350 | if ( UMAHasWindowManager() ) | |
1351 | { | |
1352 | return FrontWindow() ; | |
1353 | } | |
1354 | else | |
1355 | #endif | |
1356 | { | |
1357 | return FrontWindow() ; | |
1358 | } | |
1359 | } | |
1360 | ||
1361 | WindowRef UMAGetActiveNonFloatingWindow() | |
1362 | { | |
1363 | return NULL ; | |
1364 | } | |
1365 | ||
1366 | bool UMAIsWindowFloating( WindowRef inWindow ) | |
1367 | { | |
1368 | WindowClass cl ; | |
1369 | ||
1370 | UMAGetWindowClass( inWindow , &cl ) ; | |
1371 | return cl == kFloatingWindowClass ; | |
1372 | } | |
1373 | ||
1374 | bool UMAIsWindowModal( WindowRef inWindow ) | |
1375 | { | |
1376 | WindowClass cl ; | |
1377 | ||
1378 | UMAGetWindowClass( inWindow , &cl ) ; | |
1379 | return cl < kFloatingWindowClass ; | |
1380 | } | |
1381 | ||
1382 | // others | |
1383 | ||
1384 | void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) | |
1385 | { | |
1386 | if ( inWindowRef ) | |
1387 | { | |
1388 | // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; | |
1389 | // if ( inActivate != isHightlited ) | |
c809f3be SC |
1390 | GrafPtr port ; |
1391 | GetPort( &port ) ; | |
1392 | #if TARGET_CARBON | |
1393 | SetPort( GetWindowPort( inWindowRef ) ) ; | |
1394 | #else | |
1395 | SetPort( inWindowRef ) ; | |
1396 | #endif | |
1397 | SetOrigin( 0 , 0 ) ; | |
1398 | HiliteWindow( inWindowRef , inActivate ) ; | |
1399 | ControlHandle control = NULL ; | |
1400 | UMAGetRootControl( inWindowRef , & control ) ; | |
1401 | if ( control ) | |
1402 | { | |
1403 | if ( inActivate ) | |
1404 | UMAActivateControl( control ) ; | |
1405 | else | |
1406 | UMADeactivateControl( control ) ; | |
1407 | } | |
1408 | SetPort( port ) ; | |
72e7876b SC |
1409 | } |
1410 | } | |
2f1ae414 SC |
1411 | OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) |
1412 | { | |
1413 | #if UMA_USE_APPEARANCE | |
03e11df5 GD |
1414 | if ( UMAHasAppearance() ) |
1415 | { | |
1416 | ::DrawThemePlacard( inRect , inState ) ; | |
1417 | } | |
1418 | else | |
2f1ae414 SC |
1419 | #endif |
1420 | #if !TARGET_CARBON | |
03e11df5 GD |
1421 | { |
1422 | } | |
2f1ae414 | 1423 | #else |
03e11df5 GD |
1424 | { |
1425 | } | |
2f1ae414 SC |
1426 | #endif |
1427 | } | |
72e7876b | 1428 |