Configure Window
Volume Number: 7
Issue Number: 1
Column Tag: Pascal Procedures
Related Info: Window Manager
Project X: Configurable Window
By Rod Magnuson, Lincoln, NE
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
[Rod Magnuson: Has been programming the Macintosh for 2 1/2 years. Founded
MindVision software with Steve Kiene in early 1988. Co-author of Elaborate!, a
HyperCard XCMD that adds extensive reporting abilities to HyperCard. Worked on the
development team of Chroma-32, a scanning application that allows color scans to be
scanned on a grey-scale scanner. Currently working with Steve Kiene on Power Pack
Vol. #1, a forth coming INIT package.]
WHAT IS IT?
Project X is a small, quick and dirty application that illustrates an idea for
Macintosh windows. The window in the application is user configurable; that is: the
user can move the go-away box, title bar, zoom box, content area, scrollbars, and grow
box by holding down the command key and dragging it where the user wants. The
window part will then move when the window is dragged in the same corresponding
position to the rest of the window parts. The idea belongs to Scott Boyd; I am not sure
that he imagined what I have come up with, but he did originally think of a customizable
window definition. Sorry Scott, it is not a WDEF, but it does illustrate the idea.
The code is not important and most-likely has bugs, it was written as quickly as
my mind could think and my fingers could type; it was one of those applications that you
really could not justify spending large amounts of time on because you couldn’t get
anything out of it, and, therefore, you wrote it as quickly as possible. What is
important about this application is the idea!
Original window
Customized window
UTOPIA?
I will not say that this idea is perfect. It is not. It needs to be worked on and
possibly trashed altogether. It is, however, a new idea that could make the Macintosh
user interface more customizable.
MindVision Software
1721 Benton Street.
Lincoln, NE 68512
(402)477-3269
{--------------------------------------------------------------}
Program ProjectX;
USES
Types, { Nothing }
Errors, { Nothing }
Memory, { Types }
OSUtils, { Types }
QuickDraw, { Types }
Resources, { Types }
SegLoad, { Types }
Controls, { QuickDraw }
Events, { QuickDraw }
Fonts, { QuickDraw }
Menus, { QuickDraw }
TextEdit, { QuickDraw }
ToolUtils, { QuickDraw }
OSEvents, { Types, Events, OSUtils }
Desk, { Types, QuickDraw, Events }
Windows, { Events, Controls }
Dialogs, { Windows, TextEdit }
Devices, { OSUtils, Files, QuickDraw }
Lists, { Controls }
Packages, { Dialogs, Files }
Script; { Packages }
(*
The following lines will rez, compile, link, and execute ProjectX
Rez Types.r SysTypes.r Pict.r ProjectX.rsrc -rd -a -o ProjectX
Pascal ProjectX.p
Link ProjectX.p.o {PLibraries}PasLib.o {Libraries}Interface.o
{Libraries}Runtime.o -o ProjectX
ProjectX
*)
CONST
TitleBarHeight = 19;
ScrollBarWidth = 16;
Lastmenu = 4;
appleMenu = 1;
AboutItem = 1;
fileMenu = 2;
QuitItem = 1;
editMenu = 3;
windowMenu = 4;
ReAdjustItem = 1;
projX windowKind = 2000;
MainWindowType = 10;
TitleWindowType = 11;
GoAwayWindowType = 12;
ZoomBoxWindowType = 13;
GrowBoxWindowType = 14;
VScrollWindowType = 15;
HScrollWindowType = 16;
VAR
theEvent : EventRecord;
theChar : Char;
tempWindow : WindowPtr;
Doneflag : Boolean;
theScreen : Rect;
theItem : Integer;
theMenu : Integer;
ItemHit : Integer;
myMenus : Array[1..Lastmenu] of MenuHandle;
itype : Integer;
item : Handle;
box : Rect;
GrowReturn : Longint;
WNEExists : Boolean;
{ * Window vars * }
theMainWindow : WindowPtr;
theTitleWindow : WindowPtr;
theGoAwayWindow : WindowPtr;
theZoomWindow : WindowPtr;
theGrowWindow : WindowPtr;
theVScrollWindow : WindowPtr;
theHScrollWindow : WindowPtr;
MainWindowRect : Rect;
GoAwayBoxWidth : Integer;
ZoomBoxWidth : Integer;
function MyGetNextEvent(evtMask:Integer):Boolean; forward;
{--------------------------------------------------------------}
Function Str(i:longInt):str255;
var
myStr : Str255;
begin
NumToString(i,myStr);
Str:=myStr;
end;
{--------------------------------------------------------------}
Function Val(s:str255):Longint;
var
myVal : Longint;
begin
StringToNum(s,myVal);
Val:=myVal;
end;
{--------------------------------------------------------------}
function GetScreenBits:Rect;
IntPtr = ^Integer;
var
WMGRPort : GrafPtr;
begin
If IntPtr($28E)^=$3FFF then
GetScreenBits:=GetGDevice^^.gdRect
else
begin
GetWMGRPort(WMGRPort);
GetScreenBits:=WMGRPort^.portRect;
end;
end;
{--------------------------------------------------------------}
Procedure SetUpMenus;
var
i : Integer;
begin
InitMenus;
{ * Get and insert menus * }
for i:=1 to Lastmenu do
begin
MyMenus[i]:=GetMenu(i);
InsertMenu(myMenus[i],0);
end;
AddResMenu(MyMenus[ appleMenu],'DRVR');
DrawMenuBar;
end;
{--------------------------------------------------------------}
Procedure DoMyUpdate;
var
TitleOffSet : Integer;
savePort : GrafPtr;
thePICT : PicHandle;
eRect : Rect;
begin
tempWindow:=WindowPtr(theEvent.message);
GetPort(savePort);
SetPort(tempWindow);
BeginUpdate(tempWindow);
with windowPeek(tempWindow)^ do
If windowKind=projX windowKind then
begin
EraseRect(port.portRect);
If dataHandle= handle(TitleWindowType) then
begin
with port.portRect do
begin
MoveTo(left,top+3);
LineTo(right,top+3);
MoveTo(left,top+5);
LineTo(right,top+5);
MoveTo(left,top+7);
LineTo(right,top+7);
MoveTo(left,top+9);
LineTo(right,top+9);
MoveTo(left,top+11);
LineTo(right,top+11);
MoveTo(left,top+13);
LineTo(right,top+13);
TitleOffSet:=Right Div 2-TitleWidth Div 2;
S
SetRect(eRect,left+TitleOffSet-3,top,left+TitleOffSet+titleWidth+3,
bottom);
EraseRect(eRect);
MoveTo(left+TitleOffSet,13);