frontierwindows.c

Go to the documentation of this file.
00001 
00002 /*  $Id: frontierwindows.c 1171 2006-03-29 02:00:53Z sethdill $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "quickdraw.h"
00032 #include "strings.h"
00033 #include "threads.h"
00034 #include "frontierwindows.h"
00035 #include "shell.h"
00036 
00037 
00038 
00039 #ifdef WIN95VERSION
00040 
00041 #define titlebarheight 20
00042 
00043 static boolean setwindowpos (HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags) {
00044     
00045     /*
00046     5.0.2b18 dmb: restore minimized windows before changing their position
00047     */
00048 
00049     POINT winpt;
00050     boolean fl;
00051     WINDOWPLACEMENT wp;
00052 
00053     /*
00054     if (cy)
00055         cy += titlebarheight;
00056         
00057     if (Y)
00058         Y -= titlebarheight;
00059     */
00060 
00061     winpt.x = X;
00062     winpt.y = Y;
00063     
00064 //  ScreenToClient (shellframewindow, &winpt);
00065     
00066     releasethreadglobals ();
00067     
00068     wp.length = sizeof(WINDOWPLACEMENT);
00069 
00070     if (GetWindowPlacement (hWnd, &wp) && (wp.showCmd == SW_SHOWMINIMIZED)) {
00071         
00072         wp.showCmd = SW_RESTORE;
00073         
00074         SetWindowPlacement (hWnd, &wp);
00075         }
00076     
00077     fl = SetWindowPos (hWnd, hWndInsertAfter, winpt.x, winpt.y, cx, cy, uFlags);
00078     
00079     grabthreadglobals ();
00080     
00081     return (fl);
00082     } /*setwindowpos*/
00083 
00084 #endif
00085 
00086 
00087 
00088 WindowPtr getnewwindow (short id, boolean fldialog, Rect *r) {
00089 
00090     WindowPtr w = nil;
00091     
00092 #ifdef MACVERSION
00093     //code change by Timothy Paustian 9/17/00 dialogPtrs and WindowPtrs
00094     //are not the save thing. Do a cast
00095     //This may cause trouble in other things that assume DialogPtrs
00096     //and WindowPtrs are the same, but I have to return a windowPtr
00097     //If needed this can be cast down to a DialogPtr
00098     if (fldialog)
00099     {
00100         DialogPtr   theDial = GetNewDialog (id, nil, (WindowRef) -1L);
00101         w = GetDialogWindow(theDial);
00102     }
00103     else {
00104         if (config.flcolorwindow && havecolorquickdraw ())
00105             w = GetNewCWindow (id, nil, (WindowPtr) -1L); 
00106         else
00107             w = GetNewWindow (id, nil, (WindowPtr) -1L); 
00108         }
00109 
00110     if (w != nil && r != nil) {
00111 
00112         constraintodesktop (w, r);
00113         
00114         /*make sure top-right corner (zoom box) is accessable*/ {
00115         
00116             Rect rmin;
00117             
00118             setrect (&rmin, (*r).top, (*r).right - 50, (*r).top + 5, (*r).right);
00119             
00120             if (constraintoscreenbounds (w, false, &rmin))
00121                 constraintoscreenbounds (w, false, r);
00122             }
00123         
00124         sizewindow (w,  (*r).right - (*r).left, (*r).bottom - (*r).top);
00125         
00126         movewindow (w, (*r).left, (*r).top);
00127         }
00128 
00129 #endif
00130 
00131 #ifdef WIN95VERSION
00132     HWND hwnd;
00133     CHAR            sz[160];
00134     MDICREATESTRUCT mcs;
00135     #ifdef USINGSTATUSBAR
00136         HWND hwndStatusBar;
00137     #endif
00138 
00139   //      LoadString (hInst, IDS_UNTITLED, sz, sizeof(sz));
00140     strcpy (sz, "Untitled");
00141     mcs.szTitle = (LPSTR)sz;
00142     mcs.szClass = szChild1;
00143 
00144     if (config.filetype == 'root')
00145         mcs.szClass = szChildRoot;
00146 
00147     else if (config.filetype == 'ftop')
00148         mcs.szClass = szChildFTop;
00149 
00150     else if (config.filetype == 'ftwp')
00151         mcs.szClass = szChildFTwp;
00152 
00153     else if (config.filetype == 'fttb')
00154         mcs.szClass = szChildFTtb;
00155 
00156     else if (config.filetype == 'ftmb')
00157         mcs.szClass = szChildFTmb;
00158 
00159     else if (config.filetype == 'ftsc')
00160         mcs.szClass = szChildFTsc;
00161 
00162 
00163     mcs.hOwner  = hInst;
00164 
00165     /* Use the default size for the window */
00166     if (r == NULL) {
00167 
00168         mcs.x = mcs.cx = CW_USEDEFAULT;
00169         mcs.y = mcs.cy = CW_USEDEFAULT;
00170         }
00171     else {
00172         mcs.x = (*r).left - 4;
00173         mcs.y = (*r).top - 23;
00174 
00175         mcs.cx = (*r).right - (*r).left + 5;
00176         mcs.cy = (*r).bottom - (*r).top + 24;
00177         }
00178 
00179     /* Set the style DWORD of the window to default */
00180     mcs.style = styleDefault;
00181 
00182     releasethreadglobals ();
00183 
00184     /* tell the MDI Client to create the child */
00185     hwnd = (HWND)SendMessage (hwndMDIClient,
00186                               WM_MDICREATE,
00187                               0,
00188                               (LONG)(LPMDICREATESTRUCT)&mcs);
00189     
00190     
00191     #ifdef USINGSTATUSBAR
00192         //RAB:  1/20/98 added call to create the status bar
00193         hwndStatusBar = CreateStatusWindow (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_BOTTOM | SBARS_SIZEGRIP, "Ready", hwnd, 2);
00194 
00195         SetWindowLong (hwnd, 8, (long) hwndStatusBar);
00196     #endif
00197 
00198     grabthreadglobals ();
00199 
00200     w = hwnd;
00201 
00202 #endif
00203     
00204     return (w);
00205     } /*getnewwindow*/
00206 
00207     
00208 void disposewindow (WindowPtr w) {
00209     
00210     #ifdef MACVERSION
00211         DisposeWindow (w);
00212     #endif
00213 
00214     #ifdef WIN95VERSION
00215         releasethreadglobals ();
00216 
00217         SendMessage (hwndMDIClient, WM_MDIDESTROY, (WPARAM) w, 0L);
00218 
00219         grabthreadglobals ();
00220     #endif
00221     } /*disposewindow*/
00222 
00223 
00224 void windowgettitle (WindowPtr w, bigstring bs) {
00225     
00226     #ifdef MACVERSION
00227         GetWTitle (w, bs);
00228     #endif
00229 
00230     #ifdef WIN95VERSION
00231         releasethreadglobals ();
00232         
00233         GetWindowText(w, bs, lenbigstring);
00234         
00235         grabthreadglobals ();
00236         
00237         convertcstring (bs);
00238     #endif
00239     } /*windowgettitle*/
00240     
00241 
00242 #if !flruntime
00243 
00244 void windowsettitle (WindowPtr w, bigstring bs) {
00245     
00246     #ifdef MACVERSION
00247         bigstring bsorig;
00248         
00249         GetWTitle (w, bsorig);
00250         
00251         if (!equalstrings (bs, bsorig)) /*save a little flickering*/
00252             SetWTitle (w, bs);
00253     #endif
00254 
00255     #ifdef WIN95VERSION
00256     #ifdef PASCALSTRINGVERSION
00257         bs[stringlength(bs)+1] = 0;
00258     #endif
00259         
00260         releasethreadglobals ();
00261 
00262         SetWindowText(w, stringbaseaddress(bs));
00263 
00264         grabthreadglobals ();
00265     #endif
00266     } /*windowsettitle*/
00267     
00268 
00269 void windowinval (WindowPtr w) {
00270     
00271     Rect r;
00272 
00273     getlocalwindowrect (w, &r);
00274 
00275     invalwindowrect (w, r);
00276 
00277     /*
00278     #ifdef MACVERSION
00279         invalwindowrect (w, (*w).portRect);
00280     #endif
00281     
00282     #ifdef WIN95VERSION
00283         releasethreadglobals ();
00284 
00285         ShowWindow (w, SW_SHOWNA);
00286 
00287         grabthreadglobals ();
00288 
00289     #endif
00290     */
00291     } /*windowinval*/
00292 
00293 
00294 boolean graywindow (WindowPtr w) {
00295     
00296     Rect r;
00297     //Code change by Timothy Paustian Monday, August 21, 2000 4:21:47 PM
00298     //Cannot do an implicit cast, pushport requires a CGrafPtr
00299     CGrafPtr    thePort;
00300     #if TARGET_API_MAC_CARBON == 1
00301     thePort = GetWindowPort(w);
00302     #else
00303     thePort = (CGrafPtr)w;
00304     #endif
00305         
00306     pushport (thePort);
00307     
00308     getlocalwindowrect (w, &r);
00309     
00310     grayrect (r);
00311     
00312     invalrect (r);
00313     
00314     popport ();
00315 
00316     return (true);
00317     } /*graywindow*/
00318     
00319 #endif
00320     
00321 void movewindow (WindowPtr w, short h, short v) {
00322 
00323     #ifdef MACVERSION
00324         MoveWindow (w, h, v, false); /*don't bring it to the front*/
00325     #endif
00326 
00327     #ifdef WIN95VERSION
00328         int windowFramingHeight = 23;  /* 2006-03-28 SMD - updated to use system-provided metrics instead of static values */
00329         int windowFramingWidth = 4;
00330         
00331         windowFramingHeight = GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYFRAME );
00332         windowFramingWidth  = GetSystemMetrics( SM_CXFRAME );
00333         setwindowpos (w, NULL, h - windowFramingWidth, v - windowFramingHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
00334     #endif
00335 
00336     } /*movewindow*/
00337 
00338 
00339 void movewindowhidden (WindowPtr w, short h, short v) {
00340 
00341     #ifdef MACVERSION
00342         MoveWindow (w, h, v, false); /*don't bring it to the front*/
00343     #endif
00344 
00345     #ifdef WIN95VERSION
00346         int windowFramingHeight = 23;  /* 2006-03-28 SMD - updated to use system-provided metrics instead of static values */
00347         int windowFramingWidth = 4;
00348         
00349         windowFramingHeight = GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYFRAME );
00350         windowFramingWidth  = GetSystemMetrics( SM_CXFRAME );
00351         setwindowpos (w, NULL, h - windowFramingWidth, v - windowFramingHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_HIDEWINDOW | SWP_NOACTIVATE);
00352     #endif
00353 
00354     } /*movewindowhidden*/
00355     
00356 
00357 void sizewindow (WindowPtr w, short h, short v) {
00358 
00359     #ifdef MACVERSION
00360         SizeWindow (w, h, v, true); /*add to the update region*/
00361     #endif
00362 
00363     #ifdef WIN95VERSION
00364         // dmb: must account for NC area
00365         /*long style = GetWindowLong (w, GWL_STYLE);
00366         
00367         if (style & WS_VSCROLL)
00368             h += 16;
00369         
00370         if (style & WS_HSCROLL)
00371             v += 16;
00372         */
00373 
00374         setwindowpos (w, NULL, 0, 0, h + 5, v + 24, SWP_NOMOVE | SWP_NOZORDER);
00375     #endif
00376 
00377     } /*sizewindow*/
00378 
00379     
00380 void sizewindowhidden (WindowPtr w, short h, short v) {
00381 
00382     #ifdef MACVERSION
00383         SizeWindow (w, h, v, true); /*add to the update region*/
00384     #endif
00385 
00386     #ifdef WIN95VERSION
00387         // dmb: must account for NC area
00388         /*long style = GetWindowLong (w, GWL_STYLE);
00389         
00390         if (style & WS_VSCROLL)
00391             h += 16;
00392         
00393         if (style & WS_HSCROLL)
00394             v += 16;
00395         */
00396 
00397         setwindowpos (w, NULL, 0, 0, h + 5, v + 24, SWP_NOMOVE | SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
00398     #endif
00399 
00400     } /*sizewindowhidden*/
00401 
00402 
00403 void moveandsizewindow (WindowPtr w, Rect r) {
00404     
00405     sizewindow (w, r.right - r.left, r.bottom - r.top);
00406     
00407     movewindow (w, r.left, r.top);
00408     } /*moveandsizewindow*/
00409 
00410 
00411 WindowPtr getfrontwindow (void) {
00412     
00413     /*
00414     5.1.5b15 dmb: return invisible window if in front, not NULL [Win]
00415     */
00416 
00417     #ifdef MACVERSION
00418         return (FrontWindow ());
00419     #endif
00420 
00421     #ifdef WIN95VERSION
00422         HWND w;
00423 
00424         w = GetTopWindow (hwndMDIClient);
00425         
00426         while (w && !IsWindowVisible (w))
00427             w = GetNextWindow (w, GW_HWNDNEXT);
00428         
00429         return (w);
00430     #endif
00431 
00432     } /*getfrontwindow*/
00433 
00434 
00435 WindowPtr getnextwindow (WindowPtr w) {
00436     
00437     #ifdef MACVERSION
00438         WindowPtr   nextWindow;
00439         //Code change by Timothy Paustian Monday, May 1, 2000 9:18:45 PM
00440         //Changed to Opaque call for Carbon
00441         #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00442         nextWindow = GetNextWindow(w);
00443         #else
00444         //old code
00445         nextWindow = ((WindowPtr) (*(WindowPeek) w).nextWindow);
00446         #endif
00447         return nextWindow;
00448     #endif
00449 
00450     #ifdef WIN95VERSION
00451         w = GetNextWindow (w, GW_HWNDNEXT);
00452         
00453         while (w && !IsWindowVisible (w))
00454             w = GetNextWindow (w, GW_HWNDNEXT);
00455         
00456         return (w);
00457     #endif
00458 
00459     } /*getfrontwindow*/
00460 
00461 
00462 boolean windowbringtofront (WindowPtr w) {
00463     
00464     if (w == nil)
00465         return (false);
00466     
00467     #ifdef MACVERSION
00468         SelectWindow (w);
00469     #endif
00470 
00471     #ifdef WIN95VERSION
00472         setwindowpos (w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
00473     #endif
00474 
00475     shellwindowmenudirty (); /*the checked item changes*/
00476     
00477     return (true);
00478     } /*windowbringtofront*/
00479 
00480 
00481 boolean windowsendtoback (WindowPtr w) {
00482 
00483     if (w == nil)
00484         return (false);
00485     
00486     #ifdef MACVERSION
00487         SendBehind (w, nil);
00488     #endif
00489 
00490     #ifdef WIN95VERSION
00491         {
00492         WindowPtr wnext = getnextwindow (w);
00493         
00494         setwindowpos (w, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
00495         
00496         if (wnext != nil)
00497             windowbringtofront (wnext);
00498         }
00499     #endif
00500     
00501     shellwindowmenudirty (); /*the checked item changes*/
00502         
00503     return (true);
00504     } /*windowsendtoback*/
00505 
00506 
00507 boolean getlocalwindowrect (WindowPtr w, Rect *r) {
00508     
00509     if (w == nil) { /*defensive driving*/
00510         
00511         zerorect (r);
00512         
00513         return (false);
00514         }
00515         
00516     #ifdef MACVERSION
00517         //Code change by Timothy Paustian Monday, May 1, 2000 9:19:35 PM
00518         //Changed to Opaque call for Carbon
00519         //we are assuming we want the entire window rectangle here, this may be wrong.
00520         //All defined in MacWindows.h
00521         //I had to do it this way to get the quick script window to work.
00522         //this may be moot because I am going to need to use a different WDEF
00523         //for the quick script window anyway.
00524         #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00525         {
00526         CGrafPtr    thePort;
00527         
00528         thePort = GetWindowPort(w);
00529         GetPortBounds(thePort, r);
00530         }
00531         #else
00532         //old code
00533         *r = (*w).portRect;
00534         #endif
00535     #endif
00536 
00537     #ifdef WIN95VERSION
00538         {
00539         RECT winrect;
00540 
00541         GetClientRect (w, &winrect);
00542         
00543         setrect (r, winrect.top, winrect.left, winrect.bottom, winrect.right);
00544         }
00545     #endif
00546     
00547     return (true);
00548     } /*getlocalwindowrect*/
00549     
00550 
00551 boolean getglobalwindowrect (WindowPtr w, Rect *r) {
00552     
00553     if (!getlocalwindowrect (w, r))
00554         return (false);
00555     
00556     localtoglobalrect (w, r);
00557     
00558     #ifdef WIN95VERSION
00559         {
00560         long style = GetWindowLong (w, GWL_STYLE);
00561 
00562         if (style & WS_VSCROLL)
00563             (*r).right += 16;
00564         else
00565             (*r).right += 3;
00566         
00567         if (style & WS_HSCROLL)
00568             (*r).bottom += 16;
00569         else
00570             (*r).bottom += 3;
00571         }
00572     #endif
00573     
00574     return (true);
00575     } /*getglobalwindowrect*/
00576 
00577 
00578 #if !flruntime
00579 
00580 boolean windowsendbehind (WindowPtr w, WindowPtr wbehind) {
00581     
00582     /*
00583     5.0a10 dmb: call dirty windowmenu for all platforms
00584     */
00585 
00586     #ifdef MACVERSION
00587         boolean flmovingup;
00588         
00589         if (w == nil)
00590             return (false);
00591         
00592         flmovingup = w != getfrontwindow (); /*maybe moving up*/
00593         
00594         SendBehind (w, wbehind);
00595         
00596         if (flmovingup) { /*IM I-286*/
00597             //Code change by Timothy Paustian Monday, May 1, 2000 9:28:35 PM
00598             //Changed to Opaque call for Carbon
00599             //note this routine is never called. The compiler strips it out.
00600             #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00601             #else
00602             //old code
00603             register WindowPeek wpeek = (WindowPeek) w;
00604             
00605             PaintOne ((WindowPtr) wpeek, (*wpeek).strucRgn);
00606             
00607             CalcVis ((WindowPtr) wpeek);
00608             #endif
00609             }
00610     #endif
00611 
00612     #ifdef WIN95VERSION
00613         setwindowpos (w, wbehind, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
00614     #endif
00615     
00616     shellwindowmenudirty (); /*the checked item changes*/
00617     
00618     return (true);
00619     } /*windowsendbehind*/
00620 
00621 
00622 boolean findmousewindow (Point globalpt, WindowPtr *w, short *part) {
00623     
00624     #ifdef MACVERSION
00625         *part = FindWindow (globalpt, w);
00626     #endif
00627 
00628     #ifdef WIN95VERSION
00629         POINT winPt;
00630         winPt.x = globalpt.h;
00631         winPt.y = globalpt.v;
00632         *w = ChildWindowFromPoint (hwndMDIClient, winPt);   // *** can't pass NULL?
00633     #endif
00634     
00635     return (*w != nil);
00636     } /*findmousewindow*/
00637 
00638 
00639 boolean windowsetcolor (WindowPtr w, long color, boolean flforeground) {
00640     
00641     if (w == nil)
00642         return (false);
00643         
00644     #ifdef MACVERSION
00645         //Code change by Timothy Paustian Monday, August 21, 2000 4:23:48 PM
00646         //pushport needs a CGrafPtr, passing windowPtr causes a crash on OS X
00647         {
00648         CGrafPtr    thePort;
00649         #if TARGET_API_MAC_CARBON == 1
00650         thePort = GetWindowPort(w);
00651         #else
00652         thePort = (CGrafPtr)w;
00653         #endif
00654         
00655         pushport (thePort);
00656         }
00657         if (flforeground)
00658             ForeColor (color);
00659         else
00660             BackColor (color);
00661         
00662         popport ();
00663     #endif
00664 
00665     #ifdef WIN95VERSION
00666     #endif
00667     
00668     return (true);
00669     } /*windowsetcolor**/
00670 
00671 
00672 boolean isdeskaccessorywindow (WindowPtr w) {
00673     
00674     #ifdef MACVERSION
00675         //Code change by Timothy Paustian Monday, May 1, 2000 9:31:55 PM
00676         //Changed to Opaque call for Carbon
00677         //I doubt we need this but what the hey.
00678         return (GetWindowKind(w) < 0);
00679         //old code
00680         //return ((*(WindowPeek) w).windowKind < 0);
00681     #endif
00682 
00683     #ifdef WIN95VERSION
00684         return (false);
00685     #endif
00686     } /*isdeskaccessorywindow*/
00687 
00688 #endif
00689 
00690 
00691 void showwindow (WindowPtr w) {
00692     
00693     #ifdef MACVERSION
00694         ShowWindow (w);
00695     #endif
00696 
00697     #ifdef WIN95VERSION
00698         releasethreadglobals ();
00699 
00700         ShowWindow (w, SW_SHOWNA);
00701 
00702         grabthreadglobals ();
00703     #endif
00704     } /*showwindow*/
00705 
00706 
00707 void hidewindow (WindowPtr w) {
00708     
00709     /*
00710     5.0a5 dmb: apparantly, we need to do more to fully activate the next
00711     window if w is in front now. Using SetWindowPos didn't work, so we 
00712     make two calls
00713 
00714     5.0a10 dmb: fixed above code. also, added SendBehind code for Mac here, 
00715     so it doesn't need to be done at the shell level
00716 
00717     5.1.5b15 dmb: still wasn't right. hiding the window leaves it in front.
00718     we need to activate the frontmost visible window.
00719     */
00720 
00721     #ifdef MACVERSION
00722         HideWindow (w);
00723         
00724         if (w == getfrontwindow ()) /*don't allow hidden window to remain active*/
00725             SendBehind (w, getfrontwindow ());
00726     #endif
00727 
00728     #ifdef WIN95VERSION
00729         WindowPtr wfront = getfrontwindow ();
00730         
00731         if (!IsWindowVisible (w))
00732             return;
00733 
00734         releasethreadglobals ();
00735         
00736         SetWindowPos (w, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
00737 
00738     //  ShowWindow (w, SW_HIDE);
00739         
00740         if (w == wfront) { // we were in front; activate first visible
00741             
00742             w = GetTopWindow (hwndMDIClient);
00743             
00744             while (w && !IsWindowVisible (w))
00745                 w = GetNextWindow (w, GW_HWNDNEXT);
00746 
00747             if (w)
00748                 SetWindowPos (w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
00749                 //SetActiveWindow (w);
00750             }
00751         
00752         grabthreadglobals ();
00753     #endif
00754     } /*hidewindow*/
00755 
00756 boolean windowvisible (WindowPtr w) {
00757     
00758     #ifdef MACVERSION
00759         //Code change by Timothy Paustian Monday, May 1, 2000 9:33:54 PM
00760         //Changed to Opaque call for Carbon
00761         return IsWindowVisible(w);
00762         //old code
00763         //return ((*(WindowPeek) w).visible);
00764     #endif
00765 
00766     #ifdef WIN95VERSION
00767         return (IsWindowVisible (w));
00768     #endif
00769     } /*windowvisible*/
00770 
00771 
00772 hdlregion getupdateregion (WindowPtr w) {
00773 #ifdef MACVERSION
00774     //Code change by Timothy Paustian Monday, May 1, 2000 9:35:02 PM
00775     //Changed to Opaque call for Carbon
00776     //watch out here. Make sure we are not making a memory leak.
00777     //I wonder if the windows version leaks memory or if all these calls
00778     //are mapped out and disposed of in the windows version.
00779     //ask Andre
00780     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00781     hdlregion   rgn;
00782     //I think I found a bug in carbon. Calling get window region looking for
00783     //the update region is always returning 0,0,0,0. For now use the 
00784     //content region. I will ask about this on the carbon mailing list.
00785     rgn = NewRgn();
00786     GetWindowRegion(w, kWindowContentRgn, rgn);
00787     return (rgn);
00788     #else
00789     //old code
00790     hdlregion retRegion = (*(WindowPeek) w).updateRgn;
00791     return (retRegion);
00792     #endif
00793 #endif
00794 
00795 #ifdef WIN95VERSION
00796     hdlregion rgn;
00797     rgn = (hdlregion) NewRgn();
00798     GetUpdateRgn (w, (HRGN) rgn, false);
00799     return (rgn);
00800 #endif
00801     } /*getupdateregion*/
00802 
00803 
00804 hdlregion getvisregion (WindowPtr w) {
00805 #ifdef MACVERSION
00806     //Code change by Timothy Paustian Monday, May 1, 2000 9:35:02 PM
00807     //Changed to Opaque call for Carbon
00808     //watch out here. Make sure we are not making a memory leak.
00809     //I wonder if the windows version leaks memory or if all these calls
00810     //are mapped out and disposed of in the windows version.
00811     //ask Andre
00812     //This is also not called in the PPC version, dead code.
00813     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00814     hdlregion   rgn;
00815     CGrafPtr    thePort;
00816     //we have to change to a port to get the visible region
00817     thePort = GetWindowPort(w);
00818     rgn = NewRgn();
00819     rgn = GetPortVisibleRegion(thePort, rgn);
00820     return (rgn);
00821     #else
00822     //old code
00823     return ((*w).visRgn);
00824     #endif
00825 #endif
00826 
00827 #ifdef WIN95VERSION
00828     hdlregion rgn;
00829     HDC hdc;
00830 
00831 //  hdc = GetDC (w);
00832     assert (w == getport ());
00833     hdc = getcurrentDC ();
00834 
00835     rgn = (hdlregion) NewRgn();
00836     GetClipRgn (hdc, (HRGN) rgn);
00837 //  ReleaseDC(w, hdc);
00838     return (rgn);
00839 #endif
00840     } /*getupdateregion*/
00841 
00842 
00843 void setwindowrefcon (WindowPtr w, long refcon) {
00844 
00845     #ifdef MACVERSION
00846         //Code change by Timothy Paustian Monday, May 1, 2000 9:42:05 PM
00847         //Changed to Opaque call for Carbon
00848         SetWRefCon(w, refcon);
00849         //old code
00850         //(*(WindowPeek) w).refCon = refcon;
00851     #endif
00852 
00853     #ifdef WIN95VERSION
00854         SetWindowLong (w, 0, (LONG) refcon);
00855     #endif
00856     } /*setwindowrefcon*/
00857 
00858 
00859 long getwindowrefcon (WindowPtr w) {
00860 
00861     #ifdef MACVERSION
00862         //Code change by Timothy Paustian Monday, May 1, 2000 9:42:44 PM
00863         //Changed to Opaque call for Carbon
00864         return GetWRefCon(w);
00865         /*old code
00866         return ((*(WindowPeek) w).refCon);*/
00867     #endif
00868 
00869     #ifdef WIN95VERSION
00870         return (GetWindowLong (w, 0));
00871     #endif
00872     } /*getwindowrefcon*/
00873 
00874 
00875 

Generated on Wed May 31 18:19:47 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6