home *** CD-ROM | disk | FTP | other *** search
- /*
- File: WinUtils.cpp
-
- Contains: Implementation of window utilities
-
- Owned by: Richard Rodseth
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
-
- */
-
- #ifndef _ALTPOINT_
- #include "AltPoint.h"
- #endif
-
- #ifndef _WINUTILS_
- #include "WinUtils.h"
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include "Draft.xh"
- #endif
-
- #ifndef _ODUTILS_
- #include "ODUtils.h"
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include "Frame.xh"
- #endif
-
- #ifndef _PASCLSTR_
- #include "PasclStr.h"
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODDEBUG_
- #include "ODDebug.h"
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef _STDTYPIO_
- #include "StdTypIO.h"
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
-
- ODBoolean BeginGetWindowProperties(Environment* ev, ODFrame* frame, WindowProperties* properties)
- {
- ASSERT(frame != kODNULL, kODErrInvalidFrame);
-
- ODBoolean propsExist = kODFalse;
-
- ODStorageUnit* frameSU = frame->GetStorageUnit(ev);
- ODStorageUnit* windowPropsSU = kODNULL;
-
- ODID id = ODGetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef);
-
- if (id != 0)
- {
- TRY
- TempODStorageUnit windowPropsSU = frameSU->GetDraft(ev)->AcquireStorageUnit(ev,id);
- if (windowPropsSU)
- {
- propsExist = kODTrue;
-
- ODRect odRect;
- ODGetRectProp(ev, windowPropsSU, kODPropWindowRect, kODRect, &odRect);
- odRect.AsQDRect(properties->boundsRect);
-
- properties->title[0] = 0;
- ODIText* iText = ODGetITextProp(ev, windowPropsSU, kODPropWindowTitle, kODMacIText, kODNULL);
- if (iText)
- IntlToPStr(iText, &(properties->title[0]));
- // No error checking is done for
- // strings longer than 255 chars.
- DisposeIText(iText);
-
- properties->procID = ODGetSShortProp(ev,
- windowPropsSU, kODPropWindowProcID, kODSShort);
-
- properties->wasVisible = ODGetBooleanProp(ev,
- windowPropsSU, kODPropWindowIsVisible, kODBoolean);
- properties->hasCloseBox = ODGetBooleanProp(ev,
- windowPropsSU, kODPropWindowHasCloseBox, kODBoolean);
- properties->shouldShowLinks = ODGetBooleanProp(ev,
- windowPropsSU, kODPropShouldShowLinks, kODBoolean);
-
- properties->refCon = ODGetSLongProp(ev,
- windowPropsSU, kODPropWindowRefCon, kODSLong);
- properties->isResizable = ODGetBooleanProp(ev,
- windowPropsSU, kODPropWindowIsResizable, kODBoolean);
- properties->isFloating = ODGetBooleanProp(ev,
- windowPropsSU, kODPropWindowIsFloating, kODBoolean);
- properties->isRootWindow = ODGetBooleanProp(ev,
- windowPropsSU, kODPropWindowIsRootWindow, kODBoolean);
-
- properties->sourceFrame = kODNULL;
- ODID id = ODGetStrongSURefProp(ev,
- windowPropsSU, kODPropSourceFrame, kODStrongStorageUnitRef);
- if (id != 0)
- {
- properties->sourceFrame = windowPropsSU->GetDraft(ev)->AcquireFrame(ev,id);
- }
- }
- CATCH_ALL
- WARN("Frame has kODPropWindowProperties, but unable to retrieve ID for strong suref in it.");
- ENDTRY
- }
- return propsExist;
- }
-
- void EndGetWindowProperties(Environment* ev, WindowProperties* properties)
- {
- if (properties)
- ODReleaseObject(ev, properties->sourceFrame);
- }
-
-