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