home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 5.9 KB | 354 lines | [TEXT/MPS ] |
- /*
- File: ShellWindow.cp
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: xxx put dri here xxx
-
- Other Contact: xxx put other contact here xxx
-
- Technology: xxx put technology here xxx
-
- Writers:
-
- (BWS) Brent Schorsch
-
- Change History (most recent first):
-
- <SP1> 7/1/99 BWS first checked in
- */
-
- //• —————————————————————————————— Includes
-
- #include <Controls.h>
- #include <MacWindows.h>
- #include <ToolUtils.h>
-
- #include "ShellWindow.h"
- #include "ToolboxUtils.h"
-
- //• —————————————————————————————— Private Definitions
- //• —————————————————————————————— Private Types
- //• —————————————————————————————— Private Variables
- //• —————————————————————————————— Private Functions
- //• —————————————————————————————— Public Variables
-
- ShellWindow::ShellWindow()
- {
- }
-
- ShellWindow::~ShellWindow()
- {
- }
-
- //• ———————————————————— ShellWindow::Show
-
- void
- ShellWindow::Show(void)
- {
- ::ShowWindow(window);
- }
-
- //• ———————————————————— ShellWindow::Hide
-
- void
- ShellWindow::Hide(void)
- {
- ::HideWindow(window);
- }
-
- //• ———————————————————— ShellWindow::MakeCurrentPort
-
- void
- ShellWindow::MakeCurrentPort(void)
- {
- ::SetPort(window);
- }
-
- //• ———————————————————— ShellWindow::SetTitle
-
- void
- ShellWindow::SetTitle(const Str255 inTitle)
- {
- ::SetWTitle(window, inTitle);
- }
-
- //• ———————————————————— ShellWindow::SetWidth
-
- void
- ShellWindow::SetWidth(const UInt32 inWidth)
- {
- Rect r;
-
- r = window->portRect;
- r.right = r.left + inWidth;
-
- ::SizeWindow(window, r.right - r.left, r.bottom - r.top, true);
- }
-
- //• ———————————————————— ShellWindow::SetHeight
-
- void
- ShellWindow::SetHeight(const UInt32 inHeight)
- {
- Rect r;
-
- r = window->portRect;
- r.bottom = r.top + inHeight;
-
- ::SizeWindow(window, r.right - r.left, r.bottom - r.top, true);
- }
-
- //• ———————————————————— ShellWindow::Width
-
- short
- ShellWindow::Width(void)
- {
- return (window->portRect.right - window->portRect.left);
- }
-
- //• ———————————————————— ShellWindow::Height
-
- short
- ShellWindow::Height(void)
- {
- return (window->portRect.bottom - window->portRect.top);
- }
-
- //• ———————————————————— ShellWindow::MoveTo
-
- void
- ShellWindow::MoveTo(const SInt32 inH, const SInt32 inY)
- {
- Boolean isFrontWindow;
-
- if (window == ::FrontWindow())
- isFrontWindow = true;
- else
- isFrontWindow = false;
-
- ::MoveWindow(window, inH, inY, isFrontWindow);
- }
-
- //• ———————————————————— ShellWindow::MostOnWhichMonitor
-
- GDHandle
- ShellWindow::MostOnWhichMonitor(void)
- {
- GDHandle mostMonitor = nil;
- GDHandle monitor;
- UInt32 mostArea = 0U, area;
- Rect r, windowRect;
- GrafPtr oldPort;
- GDHandle mainMonitor;
-
-
- ::GetPort(&oldPort);
- MakeCurrentPort();
-
- windowRect = window->portRect;
- LocalToGlobalRect(&windowRect);
-
- mainMonitor = ::GetMainDevice();
- monitor = ::GetDeviceList();
-
- while (nil != monitor)
- {
- ::SectRect(&windowRect, & (**monitor).gdRect, &r);
- ::OffsetRect(&r, -r.left, -r.top);
- area = r.right * r.bottom;
-
- if (area > mostArea) //• Favor the device that has the most area
- {
- mostArea = area;
- mostMonitor = monitor;
- }
- else if (area == mostArea) //• But if it's equal to the main monitor, favor main
- {
- if ((monitor == mainMonitor) || (mostMonitor == mainMonitor))
- mostMonitor = mainMonitor;
- }
-
- monitor = ::GetNextDevice(monitor);
- }
-
- ::SetPort(oldPort);
-
- return (mostMonitor);
- }
-
- #pragma mark -
-
- //• ———————————————————— ShellWindow::Activate
-
- void
- ShellWindow::Activate(const Boolean inActivate)
- {
- ::HiliteWindow(window, inActivate);
- ::DrawGrowIcon(window);
- }
-
- //• ———————————————————— ShellWindow::Update
-
- void
- ShellWindow::Update(void)
- {
- GrafPtr oldPort;
- WindowPtr theWindow = window;
-
- ::GetPort(&oldPort);
- MakeCurrentPort();
-
- ::BeginUpdate(theWindow);
-
- ::ClipRect(&theWindow->portRect);
- ::EraseRect(&theWindow->portRect);
- ::DrawControls(theWindow);
- ::DrawGrowIcon(theWindow);
-
- ::EndUpdate(theWindow);
-
- ::SetPort(oldPort);
- }
-
- //• ———————————————————— ShellWindow::Select
-
- void
- ShellWindow::Select(void)
- {
- ::SelectWindow(window);
- MakeCurrentPort();
- }
-
- //• ———————————————————— ShellWindow::Click
-
- OSErr
- ShellWindow::Click(const Point inWhere, const short inModifiers)
- {
- #pragma unused (inWhere, inModifiers)
-
- if (FrontWindow() != window)
- ::SelectWindow(window);
-
- return (noErr);
- }
-
- //• ———————————————————— ShellWindow::Key
-
- OSErr
- ShellWindow::Key(const UInt8 inChar, const UInt8 inKey, const short inModifiers)
- {
- #pragma unused (inChar, inKey, inModifiers)
-
- return (noErr);
- }
-
- //• ———————————————————— ShellWindow::Grow
-
- OSErr
- ShellWindow::Grow(const Point inWhere)
- {
- Rect sizeRect;
- long result;
- WindowPtr theWindow = window;
-
- sizeRect.top = 80;
- sizeRect.left = 80;
- sizeRect.bottom = 440;
- sizeRect.right = 640;
-
- result = ::GrowWindow(theWindow, inWhere, &sizeRect);
-
- if (0 != result)
- {
- GrafPtr oldPort;
-
- ::SizeWindow(theWindow, LoWord(result), HiWord(result), false);
-
- ::GetPort(&oldPort);
- MakeCurrentPort();
-
- ::InvalRect(&theWindow->portRect);
-
- ::SetPort(oldPort);
- }
-
- return (noErr);
- }
-
- //• ———————————————————— ShellWindow::Zoom
-
- OSErr
- ShellWindow::Zoom(const short inZoomDir)
- {
- #pragma unused (inZoomDir)
-
- return (noErr);
- }
-
- //• ———————————————————— ShellWindow::Close
-
- OSErr
- ShellWindow::Close(void)
- {
- return (noErr);
- }
-
- //• ———————————————————— ShellWindow::Idle
-
- void
- ShellWindow::Idle(void)
- {
- ::IdleControls(window);
- }
-
- //• ———————————————————— ShellWindow::Menu
-
- Boolean
- ShellWindow::Menu(const UInt32 inMenuCommand, const short inModifiers)
- {
- #pragma unused (inMenuCommand, inModifiers)
-
- return (false);
- }
-
- //• ———————————————————— ShellWindow::Help
-
- void
- ShellWindow::Help(const Point inWhere)
- {
- #pragma unused (inWhere)
- }
-
- //• ———————————————————— ShellWindow::Drag
-
- Boolean
- ShellWindow::Drag(const Point inWhere, const short inModifiers)
- {
- #pragma unused (inModifiers)
-
- ::DragWindow(window, inWhere, &(**GetGrayRgn()).rgnBBox);
-
- return (false);
- }
-
- //• ———————————————————— ShellWindow::Suspend
-
- void
- ShellWindow::Suspend(void)
- {
- }
-
- //• ———————————————————— ShellWindow::Resume
-
- void
- ShellWindow::Resume(void)
- {
- }
-