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