home *** CD-ROM | disk | FTP | other *** search
- /*
- File: WinUtilM.cpp
-
- Contains: Utilities to manipulate Mac windows
-
- Owned by: Richard Rodseth
-
- Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <8> 9/8/95 TÇ 1281096 FB2:Many constants in ODTypesB
- without kOD prefix!
- <7> 6/28/95 RR 1242642 BB Mostly ref counting. Add
- WindowLink::ShouldRemove
- <6> 6/22/95 RR #1245283 Undoable frame deletion
- #1209427 Changed private api between
- iterator and iteratee. Allow deletion while
- iterating. Added fRemove flag to WindowLink
- <5> 5/26/95 RR #1251403: Multithreading naming support
- <4> 5/25/95 jpa Removed GetNextWindow, which is now in
- Toolbox <Windows.h> [1241078, 1253324]
- <3> 4/14/95 TÇ With RR & CG: #1194507 DR/BB:title bar of a
- draft window doesn't reveal it is a draft
- or which draft it is. Add
- AcquireDraftNumFromDraft
- <2> 9/29/94 RA 1189812: Mods for 68K build.
- <1> 6/16/94 RR first checked in
-
- To Do:
- In Progress:
-
- */
-
- #ifndef _WINUTILM_
- #include "WinUtilM.h"
- #endif
-
- #ifndef __LOWMEM__
- #include <LowMem.h> // For WindowList global
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
-
- // New Window API uses a new "WindowRef" type as an opaque window type. So that we can compile
- // with or without the new Windows.h, define WindowRef if it's not already defined: --jpa
- #ifndef STRICT_WINDOWS
- #define WindowRef WindowPeek
- #endif
-
-
- WindowPtr GetWindowList()
- {
- return (WindowPtr)LMGetWindowList();
- }
-
- void SetWindowList(WindowPtr theWindow)
- {
- LMSetWindowList((WindowRef)theWindow); /* Adkins -- changed from WindowPeek to WindowRef */
- }
-
- void SetNextWindow(WindowPtr theWindow, WindowPtr nextWindow)
- {
- ((WindowRecord*) theWindow)->nextWindow = (WindowPeek) nextWindow;
- }
-
- ODBoolean GetWindowVisible(WindowPtr theWindow)
- {
- return (((WindowRecord*) theWindow)->visible ? kODTrue : kODFalse);
- }
-
- ODBoolean GetWindowHilite(WindowPtr theWindow)
- {
- return (((WindowRecord*) theWindow)->hilited ? kODTrue : kODFalse);
- }
-
- void SetWindowHilite(WindowPtr theWindow, ODBoolean windowHilite)
- {
- ((WindowRecord*) theWindow)->hilited = windowHilite;
- }
-
- RgnHandle GetStructureRegion(WindowPtr theWindow)
- {
- return ((WindowRecord*) theWindow)->strucRgn;
- }
-
- RgnHandle GetContentRegion(WindowPtr theWindow)
- {
- return ((WindowRecord*) theWindow)->contRgn;
- }
-
- ODULong GetDraftNumFromDraft(Environment* ev, ODDraft* draft)
- {
- ODULong draftNumber = 0;
- ODDocument* document = draft->GetDocument(ev);
-
- if (document->Exists(ev, 0, draft, kODPosFirstAbove))
- {
- ODDraft* aDraft = document->AcquireBaseDraft(ev, kODDPReadOnly);
- draftNumber = 1;
- while (!ODObjectsAreEqual(ev, aDraft, draft))
- {
- ++draftNumber;
- aDraft = document->AcquireDraft(ev, kODDPReadOnly, 0, aDraft,
- kODPosFirstAbove, kODTrue);
- }
- ODReleaseObject(ev, aDraft);
- }
- return draftNumber;
- }
-
- //=====================================================================================
- // WindowLink
- //=====================================================================================
-
- //-------------------------------------------------------------------------------------
- // WindowLink::WindowLink
- //
- // Description
- //-------------------------------------------------------------------------------------
-
- WindowLink::WindowLink(ODID windowID, ODWindow* window)
- {
- fID = windowID;
- fWindow = window;
- fRemove = kODFalse;
- }
-
- ODBoolean WindowLink::ShouldRemove()
- {
- if (fRemove)
- return kODTrue; // Separate line for debugging purposes
- else
- return kODFalse;
- }
-
- //=====================================================================================
- // WindowListIterator - iterates over the Window Manager window list. Iterating from
- // back to front using Last/Previous obviously results in several scans of the list,
- // as it's a singly-linked list
- //=====================================================================================
-
-
-
- WindowListIterator::WindowListIterator()
- {
- fCurrentWindow = kODNULL;
- }
-
- WindowListIterator::~WindowListIterator()
- {
- }
-
- WindowPtr WindowListIterator::First()
- {
- fCurrentWindow = FrontWindow();
- return fCurrentWindow;
- }
-
- WindowPtr WindowListIterator::Next()
- {
- if (fCurrentWindow)
- fCurrentWindow = (WindowPtr)(((WindowPeek)fCurrentWindow)->nextWindow);
- return fCurrentWindow;
- }
-
- WindowPtr WindowListIterator::Last()
- {
- fCurrentWindow = FrontWindow();
- if (fCurrentWindow)
- {
- WindowPtr nextWindow = (WindowPtr)(((WindowPeek)fCurrentWindow)->nextWindow);
- while (nextWindow)
- {
- fCurrentWindow = nextWindow;
- nextWindow = (WindowPtr)(((WindowPeek)fCurrentWindow)->nextWindow);
- }
- }
- return fCurrentWindow;
- }
-
- WindowPtr WindowListIterator::Previous()
- {
- WindowPtr savedCurrent = fCurrentWindow;
-
- fCurrentWindow = FrontWindow();
-
- while (fCurrentWindow && ( (WindowPtr) (((WindowPeek)fCurrentWindow)->nextWindow) != savedCurrent))
- {
- fCurrentWindow = (WindowPtr) (((WindowPeek) fCurrentWindow)->nextWindow);
- }
- return fCurrentWindow;
- }
-
- ODBoolean WindowListIterator::IsNotComplete()
- {
- return (fCurrentWindow != kODNULL);
- }
-
-
-
-