home *** CD-ROM | disk | FTP | other *** search
- unit WindowStuff;
- interface
- uses
- PrintTraps, Quickdraw, Picker, Toolutils, Palettes, DlogStuff, globs;
-
- procedure FakeGrowIcon (WPtr: WindowPtr);
- procedure PutUpWind (title: str255);
- procedure CloseUpWind;
- procedure DoDrag (theWindow: WindowPtr);
- procedure DoGrow (theWindow: WindowPtr);
-
- implementation
-
- {===========================================================================}
- procedure FakeGrowIcon; {(WPtr : WindowPtr)}
- var
- bot, rght: integer;
- R: rect;
- pState: PenState;
- begin
- bot := WPtr^.portRect.bottom;
- rght := WPtr^.PortRect.right;
- SetRect(gdh^^.GrowIconRect, rght - 15, bot - 15, rght + 1, bot + 1);
- if gdh^^.showGroBox then
- begin
- GetPenState(pState);
- EraseRect(gdh^^.GrowIconRect);
- FrameRect(gdh^^.GrowIconRect);
- SetRect(R, rght - 10, bot - 10, rght - 1, bot - 1);
- FrameRect(R);
- SetRect(R, rght - 12, bot - 12, rght - 5, bot - 5);
- EraseRect(R);
- FrameRect(R);
- SetPenState(pState);
- end;{if if ghd^^.showGroBox}
- end;{FakeGrowIcon}
-
- {===========================================================================}
- procedure PutUpWind;{title:str255}
- const
- xtra = 18; {for structure region of window}
- var
- offSet: point;
- begin
- {• if gdh^^.hasColorQD then•}
- {• begin•}
- {• MainWindPtr := GetNewCWindow(1000, @mainWindowStorage, pointer(-1));•}
- {• SetPalette(MainWindPtr, mainWindPalette, TRUE);•}
- {• ActivatePalette(MainWindPtr);•}
- {• end•}
- {• else•}
-
- MainWindPtr := GetNewWindow(1000, @mainWindowStorage, WindowPtr(-1));
-
-
- if MainWindPtr = nil then
- begin
- DoMessage('**WIND resource not found. Oops!', 'Can''t run. Gotta quit…', '', '');
- ExittoShell;
- end;
-
- SetPort(MainWindPtr);
-
- offSet.h := (ScreenBits.bounds.right - MainWindPtr^.portRect.right) div 2;
- offSet.v := gdh^^.MenuHeight + (ScreenBits.bounds.bottom - MainWindPtr^.portRect.bottom + xtra) div 3;
- MoveWindow(MainWindPtr, offSet.h, offSet.v, TRUE);
-
- SetWTitle(MainWindPtr, title);
- ShowWindow(MainWindPtr);
- FakeGrowIcon(MainWindPtr);
- end;{PutUpWind}
-
-
- {===========================================================================}
- procedure CloseUpWind;
- begin
- CloseWindow(MainWindPtr); {handle last-minute 'WannaSave' dlogs here…}
- end;
-
- {===========================================================================}
- procedure DoDrag;{(theWindow : WindowPtr);}
- var
- screen: rect;
- begin
- {this allows the user to drag a window around in the rectangle defined by}
- {our dragRect.}
- screen := gdh^^.dragRect;
- DragWindow(theWindow, MainEvent.where, screen);
- end;
-
- {===========================================================================}
- procedure DoGrow;{(theWindow : WindowPtr);}
- var
- Wptr: Windowptr;
- sizeRect: rect;
- newSize: longint;
- newWidth, newHeight: integer;
- r: rect;
- bot, rght: integer;
-
- begin
- if theWindow <> FrontWindow then
- SelectWindow(theWindow)
- else
- begin
- {the minimum size that this particular window can be resized is}
- {100 pixels wide, 100 pixels tall. The maximum size is}
- {screenBits.right,screenBits.bottom - 37 tall.}
- SetRect(sizeRect, 100, 100, screenBits.bounds.right, screenBits.bounds.bottom - 37);
- newSize := GrowWindow(theWindow, MainEvent.where, sizeRect);
- if newSize <> 0 then
- begin
- bot := WPtr^.portRect.bottom;
- rght := WPtr^.PortRect.right;
- EraseRect(theWindow^.portRect);
- newWidth := LoWord(newSize);
- newHeight := HiWord(newSize);
- SizeWindow(theWindow, newWidth, newHeight, TRUE);
- ClipRect(theWindow^.portRect);
- InvalRect(theWindow^.portRect);
- FakeGrowIcon(theWindow);
- end;
- end;
-
- end;{DoGrow}
-
- end. {WindowStuff Unit}