TweetFollow Us on Twitter

Slider FKEY
Volume Number:6
Issue Number:1
Column Tag:Pascal Procedures

Related Info: Quickdraw Window Manager

Slider FKEY

By Bill Johnson, Ron Duritsch, Cincinnati, OH

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

[Bill Johnson is an Architect who gave up the good life to become a Macintosh developer. He has written several architectural utilities for the Macintosh, and recently finished Retriever™, a database desk accessory for managing lists of information. Ron Duritsch is an Economist who can’t afford to give up the good life. Except evenings and weekends.]

Sliding Around The Guidelines

Direct interaction by users with the Macintosh screen, in the form of choosing or selecting objects they are interested in, is an important feature of the Mac’s graphical user interface. This general form of user action is described in Apple’s Human Interface Guidelines as noun-then-verb.

User selection of “objects”, or the nouns, includes many items such as icons, text, graphics, and others. One important function of the Macintosh Finder is managing icons in windows and on the desktop. Users can select an icon, or group of icons, and move them about to better manage applications and documents in a window or on the desktop.

One at a Time, Please

With the advent of larger and multiple screen use on the Mac has come a realization that objects the user can select in multiples do not include windows. Only one window can be selected or moved at any given time. We feel a simple extension of the definition of objects to include windows should be considered. Just as groups of icons can be moved for better placement on the desktop, moving groups of windows on a large screen can be just as useful. Slider is an FKEY that implements one method of doing just that.

Let It Slide

When Slider is invoked the cursor is changed to give the user feedback. The cursor takes the form of a hand (the familiar MacPaint “grabber”) over the outline of a window. At this point multiple windows can be grabbed by shift-clicking on any part of any individual window. The term “grabbed” is used here to avoid confusion with normal window “selection”, using the SelectWindow toolbox call. As each window is grabbed, it’s outline is displayed in the same manner as when clicking in it’s drag region. When the user clicks in a window using Slider, the outline of all windows currently chosen is drawn, and a sound that is correctly named and placed in the System folder is played. This group of windows can then be dragged to any position on the screen. The movement does not effect the ordering of windows from front to back.

Slider can be used effectively in any application under MultiFinder or UniFinder. Under MultiFinder, only windows in the current layer can be grabbed and moved. This is analogous to the current interface guidelines of only allowing users to select and move icons or objects in one window at any time. Slider defaults to moving all windows in the current if any one window is clicked in and immediately dragged. This provides for a very fast method of moving all windows in the current layer out of the way to expose a clearer view of windows in other layers under MultiFinder, or simply a bare desktop under UniFinder. Holding the shift key down while clicking in successive windows grabs them and adds them to a group that can be dragged. After any window or group of windows is moved beyond its initial location, Slider drops out, the pointer cursor reappears, and control is passed back to the current application.

A few other features were included to provide additional functionality. Holding the option key down while clicking in a single window grabs that window and any windows behind it in the current layer. This is useful in allowing the user to grab and drag a particular subset of windows out of view while leaving the screen position and ordering of the windows above it undisturbed.

Slider can be useful with both single and multiple screens. In default mode, dragging windows to the extreme left, right or bottom will result in at least 20 pixels of each window’s drag bar remaining on the main screen. This is to ensure that windows are not completely lost from view on a single screen. In this case, some windows that are moved must lose their positions relative to one another. Holding the command key down prevents the loss of relative window positions. In multiple screen use, holding the command key down will allow windows to be dragged to an alternate display (although we haven’t been able to test that feature). With a single screen, some windows may be lost completely from view if the command key is held down. In this case, windows out of view can be retrieved by grabbing all windows in the current layer. In all cases, dragging windows to the extreme top will leave windows positioned just below the menu bar.

Uses Of Slider

So who would need or want Slider’s features? We are guessing that more than just of few of us are annoyed at the clutter of windows that can accumulate on the desktop, especially when using several applications under MultiFinder. Moving windows one at a time is slow. Repositioning singularly moved windows to conform to their previous relative positions takes even more time. Slider provides for a very quick and efficient way to get windows out of the way all while keeping their relative positions.

The advantages of moving entire groups of windows are readily noticeable in a multiple display environment. An entire layer of windows can be quickly moved to an alternate display screen while holding on to relative window positions. Even with a minimal configuration, such as in UniFinder with a nine inch screen, the added functionality afforded by Slider’s features is useful.

Abuses Of Slider

In its current configuration Slider will move literally any window. This includes modal dialogs and windows that were meant to always be stationary. The movement of modal dialogs is not apparent to us as being useful. Usually, when a modal dialog is moved, the screen area behind it is not refreshed until the dialog is dismissed. We left this feature in for two reasons. First off, it doesn’t hurt the performance of any application that we know of. Secondly, you may find it useful where we haven’t. We invite you to recode the FKEY to bypass modal dialogs if you wish. This could be accomplished by checking the WindowKind field of the window record for inappropriate window types, although some applications use dBoxProc windows for things other than modal dialogs.

Moving an application or document window that was programmed never to be moved is a much more serious issue. In fact, it’s quite rude! You’ll find that most applications won’t care because they draw to the window’s port and only in response to update events. If the programmer of the application has followed these two rules, which are recommended by Inside Macintosh, there should be no problems. But let’s face it. Most of us break the rules from time to time. Some drawing applications use a global coordinate system, since the drawing surface (they thought) would remain stationary. Some applications will react very strangely to the movement of otherwise stationary windows. And that’s exactly why we left this feature in!

That’s Not A Virus, That’s A Feature

We found some applications to respond in fascinating ways. The command line of an excellent Mac spreadsheet application is actually made up of three windows. The part of the command line that the user types into is actually a ghost window and is not found in the window list. Surprisingly, these windows still operate correctly when moved to other screen locations.

In others, we discovered hidden windows left in for debugging purposes and who-knows-what. An easy three-dimensional drawing program that was written in an implementation of Forth has a drawing surface that appears not to be a window at all. After moving this surface with Slider, a drag region appears from under the menu bar to show that, indeed, the drawing surface is a window with a title bar. Right off the top left of this window a small white rectangle appears with a slight hint of a grow box. Expanding the grow box reveals a window with an “ok ?” prompt. Apparently this window was left in for debugging purposes and responds to different user actions.

The palettes and pattern areas of a super painting application reveal themselves to be a single inverted L-shaped window. After moving this window, however, the palette is unusable since it uses fixed global coordinates to detect mouse hits. We like to think of these not as Slider bugs, but features! You too can surprise and amuse your friends as you tear apart the windows of some of the most beloved Mac applications.

If It Ain’t Broke, Fix It

Moving otherwise stationary windows is rude if their locations are hard-coded, but occasionally it can be useful from the standpoint of adding functionality to a user interface, as in the case of unmovable tool palettes. However if you do move these, you do so at your own risk, since at times moving stationary windows will bomb an application. Any version of MacPaint, for instance, will allow you only a little fun before breaking. We found this to be rare but this is the price you are sure to pay, especially with applications that bypass normal toolbox calls or IM recommendations. At present we know of no clean way of leaving stationary windows alone, aside from simply not attempting to move them. We invite you to try and write the code that says “if the window is meant to be stationary, then don’t move it”. As a favorite professor used to say when caught in a similar dilemma, “this is left as an exercise for the reader”.

Variables and Data Structures

Before we get into the code, we need to look at the data structure that is used to store the pointers to the windows that are individually chosen with a shift-click. The variable ‘WPtrArray’ is an array of 32 window pointers, and the integer variable ‘NumWSel’ is the number of windows currently selected. Simple enough. Every time a window is clicked in, if its pointer isn’t already in the array the pointer is added to the array and ‘NumWSel’ is incremented by one. However, when we drag shift-clicked windows around the screen, we want to avoid drawing over windows that are in front of the windows being dragged. In order to do that we need to know which window is the frontmost out of our collection of shift-clicked windows. We can then call ‘ClipAbove’ using the pointer to that window to achieve this effect.

We could use a separate variable to store the pointer to the frontmost chosen window. Instead we structure the information we have by adding one more characteristic to our array of pointers; of all the pointers in the array, the one nearest the front should always be stored in the first position in the array (WPtrArray[1]). All that is required to maintain this property when inserting pointers into the pointer array is to walk down the window list starting with the pointer you want to insert. If you encounter the window pointed to by ‘WPtrArray[1]’, then the new window is above the current ‘highest’ window and belongs in ‘WPtrArray[1]’. All of these gory details are handled in the function ‘InsertWPtr’ (see below).

One last note. The toolbox call ‘ClipAbove’ is only called when ‘WPtrArray[1]’ is not equal to ‘TopWindPtr’, since there is no need to clip if the front window is being dragged. So we can kill two birds with one stone by initializing ‘WPtrArray[1]’ to ‘TopWindPtr’. If the user clicks in the menubar or desktop before any windows have been selected ‘ClipAbove’ will not be called.

The Code

Slider consists of a main procedure with no parameters (as every FKEY must) and seven procedures & functions that get called to do the dirty work. These routines are declared FORWARD so that the entrypoint of the FKEY (the main procedure ‘DragIt’) is at the beginning of the code.

PROCEDURE DragIt;

The layout of the main procedure is similar to that of a small application, with 16 lines of initialization, a mini-event loop and a few lines of dispose code.

Initialization

The first line of code gets a pointer to the front window for use in miscellaneous places. Since Slider does not change the ordering of the windows, this will not change during execution of the FKEY. The next four lines save the current port, create two regions that we need, and save the current clip region. Then call ‘GetScreenSize’ to set the dragging rectangle, and two lines later set the port to the entire window manager port. That brings us down to ‘Get3Cursors’ (see below) which sets up the cursors we will use. In the last four lines before the main loop, ‘LoadSound’ sets up a sound buffer and fills it with the contents of a sound file (if a sound file is in the System Folder), and the vars ‘DropOut’, ‘NumWSel’ and ‘WPtrArray[1]’ are initialized.

Main Loop

The main REPEAT - UNTIL statement encloses a call to GetNextEvent that is masked to only accept mouseDown events. When the mouse is clicked in a window execution passes to the inner part of the loop. In the three-statement setup, the sound is played and FindWindow is called to locate the window that the mouse was clicked in (if any). Four lines later, after being sure that the user clicked in a window, we fall into three tiers of IF statement setting up the drag region and changing the cursor. The IF statements determine which modifier keys (shift, option or none) were down when the mouse was clicked. For example, the current window region is added to ‘dragRegion’ when the shift key is down.

Now that we have set up ‘drag region’ (at least, it’s set up for now... if the shift key is down the user may continue to select windows and accumulate their StrucRgn into ‘DragRegion’ in successive passes through the loop) we set the current clipping with calls to ClipRect and ClipAbove. Remember that there is no need to call ClipAbove if the ‘highest’ window that we are to drag is equal to ‘TopWindPtr’. Then we set ‘limitRect’ and ‘slopRect’ depending on whether the command key is down. After these variables have been set up, DragGrayRgn is called to draw the gray outline of ‘DragRegion’ as it is dragged around the screen.

The remaining code inside the main loop again checks for modifier keys and moves the windows accordingly. If the shift key is down, the mouse has to have moved more than 5 pixels (hor + ver), otherwise we stay in the loop to select more windows.

Cleanup

Before returning control to the system, the the port and clipping need to be restored to their original state and regions and buffer we allocated need to be disposed of. Also, key events get flushed in case the user accidentally selects the FKEY while we were executing the code.

The first three routines after the main routine (Get3Cursors, GetScreenSize and LoadSound) are called at startup to do their work.

PROCEDURE Get3Cursors (VAR svCrs: Cursor; VAR hndCrs: Cursor; VAR scndCrs: Cursor);

Get3Cursors retrieves the current cursor from low memory, as well as stuffing hex values for the main and secondary FKEY cursors. The method was lifted from Greg Mariott’s Blast FKEY in the October ’87 MacTutor.

PROCEDURE GetScreenSize (topWind: windowPtr; VAR screenPerim: rect);

GetScreenSize uses a rather unique method to get the boundaries of the screen, since a DA or FKEY cannot use ‘Screenbits.bounds’. Instead of accessing low memory, it calls ‘NewWindow’ to create an invisible window and gets the ‘zoomed’ window size out of the ‘WStateHdl’. After this info is saved, the window is disposed of. The pointer to the front window is passed to ‘NewWindow’ in order to keep the temporary window from deactivating the front window. This ought to get points for Most Obscure Use of a Toolbox Call.

FUNCTION LoadSound (VAR SoundBuffer: Ptr; VAR sndSize: longint): boolean;

LoadSound trys to load a sound file. To allow some selection of playback rate, it will look for 2 different files. If it finds a file called ‘Sound22’, it will load it and set the sampling rate to 22 kHz. If it doesn’t find ‘Sound22’, it will look for ‘Sound11’ and if found it will load it and set the sampling rate to 11 kHz. The function will return FALSE if no sound file is found, or it TRUE if the file has been loaded. If ‘LoadSound’ returns TRUE, the pointer to the sound buffer will need to be disposed of when exiting the FKEY. Thanks to Dave Alverson for the original sound code, even if he doesn’t use Pascal.

These last four routines (InsertWPtr, SumWRgnsBelow, MoveWindBelow and MoveWindSel) are called inside the main loop.

FUNCTION InsertWPtr(HitWPtr: windowPtr; VAR PtrArray: WindArray; VAR NumWind: integer): boolean;

InsertWPtr attempts to put the pointer ‘HitWPtr’ into ‘WPtrArray’ and increment ‘NumWind’. It will return FALSE if the pointer is already in the array. It will also maintain the characteristic of the array that the first position in the array ‘WPtrArray[1]’ always contains the window pointer nearest the front.

PROCEDURE SumWRgnsBelow (StartWPtr: windowPtr; VAR DragRegion: RgnHandle);

SumWRgnsBelow returns in ‘DragRegion’ a handle to a region which is a union of the ‘strucRegion’ of all windows below ‘StartWPtr’. It is called when moving all windows (passing it the pointer to the top window) or when dragging windows with the option key down (passing it the pointer to the window clicked in).

PROCEDURE MoveWindBelow (StartWPtr: windowPtr; hor, ver: integer; dragArea: rect);

MoveWindBelow calls ‘MoveWindow’ for every window in the window list beginning with ‘StartWPtr’. The windows are moved by ‘hor’ & ‘ver’ but are not moved outside of ‘dragArea’. It is called when moving all windows (passing the pointer to the top window to ‘StartWPtr’) or when dragging windows with the option key down (passing the pointer to the window clicked in to ‘StartWPtr’).

PROCEDURE MoveWindSel (VAR PtrArray: WindArray; NumWind, hor, ver: integer; dragArea: rect);

MoveWindSel calls ‘MoveWindow’ to relocate all windows whose pointers are in ‘PtrArray’. The windows are moved by ‘hor’ & ‘ver’ but not outside of ‘dragArea’.

This Is A Hack!

We coded Slider to enter into the hack contest at MacHack ’88 conference in Ann Arbor, Michigan, where it took some measure of recognition. The idea came from members of the MACincinnati Hacker Group, an active user group and an indispensable hotbed of ideas. When confronted with the embarrassing possibility of traveling to Ann Arbor without a neat hack to evangelize, we turned to them for a solution, as well as some sound code. Thanks are in order to the group, especially Dave Alverson, Andrew Dignan and Dave Bosse, as well as to MacHack ’88 for the sponsorship of the hack contest.

Although Slider has its origins as an entrance in a hack contest, we truly had respectable intentions while writing the code. The purpose was to extend the Mac user interface by allowing windows to be grouped and moved, and it works as advertised. This is both it’s strength and weakness. What is probably needed is added functionality at the system level as opposed to the current implementation. Slider is intended to show what this type of added functionality can provide to the Mac user interface.

Source

UNIT Drag;
INTERFACE
USES
      MemTypes, QuickDraw, OSIntf, ToolIntf, SANE;
PROCEDURE DragIt;
IMPLEMENTATION
CONST
 nearInfinity  = 32000;
 SlopSize = 25;
 OutOfBounds= $8000;
 allKeyEvents  = keyDownMask + keyUpMask + autoKeyMask;
TYPE
 WindArray = ARRAY[1..32] OF WindowPtr;
{this data structure stores the window pointers that have been selected 
with the mouse. The first pointer in the array (WindArray[1]) must be 
the pointer to the selected window closest to the front window. }

PROCEDURE Get3Cursors (VAR svCrs: Cursor; VAR hndCrs: Cursor; VAR scndCrs: 
Cursor);FORWARD;
PROCEDURE GetScreenSize (topWind: windowPtr; VAR screenPerim: rect);
 FORWARD;
FUNCTION LoadSound (VAR SoundBuffer: Ptr; VAR sndSize: longint): boolean;
 FORWARD;
FUNCTION InsertWPtr(HitWPtr: windowPtr; VAR PtrArray: WindArray; VAR 
NumWind: integer): boolean; FORWARD;
PROCEDURE SumWRgnsBelow (StartWPtr: windowPtr; DragRegion: RgnHandle);
 FORWARD;
PROCEDURE MoveWindBelow (StartWPtr: windowPtr; hor, ver: integer; dragArea: 
rect);  FORWARD;
PROCEDURE MoveWindSel (VAR PtrArray: WindArray; NumWind, hor, ver: integer; 
dragArea: rect); FORWARD;

PROCEDURE DragIt;
VAR
 theEvent : EventRecord;
 WMgrPort, savePort: GrafPtr;
 HitWindPtr, topWindPtr : WindowPtr;
 currentWPeek    : windowPeek;
 WPtrArray: WindArray;
 DragRgn, ExistClipRgn    : RgnHandle;
 mousePos : Point;
 limitRect, slopRect : rect;
 screenBounds, dragLim    : rect;
 thePart, index  : integer;
 NumWSel, vMov, hMov : integer;
 mainCursor, saveCursr    : Cursor;
 secondCursor    : Cursor;
 DropOut, haveSound: boolean;
 SoundPointer    : Ptr;
 sndSize, longPos: longint;

BEGIN
 topWindPtr := FrontWindow; {does not change}
 GetPort(savePort);{save state of port/clip}
 DragRgn := NewRgn;
 ExistClipRgn := NewRgn;
 GetClip(ExistClipRgn);

 GetScreenSize (topWindPtr, screenBounds);   { get drag area size }
 dragLim := screenBounds;
 InsetRect (dragLim, 20, 0);

 GetWMgrPort(WMgrPort);
 SetPort(WMgrPort);
 
 Get3Cursors (saveCursr, mainCursor, secondCursor);
 SetCursor (mainCursor);
 haveSound := LoadSound (SoundPointer, sndSize);
 NumWSel := 0;
 DropOut := FALSE;
 WPtrArray[1] := topWindPtr;
{prevent ‘ClipAbove’ call when no windows sel}

 REPEAT
 IF GetNextEvent(mDownMask, theEvent) then
 begin
 IF (haveSound)
 then StartSound (SoundPointer, sndSize, NIL);
 mousePos := theEvent.where;
 thePart := FindWindow (theEvent.where, hitWindPtr);

 if (thePart < inSysWindow)
 then begin
 sysBeep (1);
 Dropout := TRUE;
 end
 else begin {setup of drag rgn}
 if (BitAnd(theEvent.modifiers, shiftKey) <> 0)
 then begin
 if (InsertWPtr(HitWindPtr, WPtrArray, NumWSel))
 then begin
 SetCursor (secondCursor);
 currentWPeek := WindowPeek (HitWindPtr);
 UnionRgn (currentWPeek^. StrucRgn, DragRgn, DragRgn);
 end;
 end
 else begin
 Dropout := TRUE;
 if (BitAnd(theEvent.modifiers,    optionKey) <> 0)
 then begin
 SetRectRgn (DragRgn,0,0,0,0);{ empty region of accumulated regions }
 SumWRgnsBelow (hitWindPtr, DragRgn);
 WPtrArray[1] := hitWindPtr;
 end
 else begin
 if (NumWSel = 0)
 then SumWRgnsBelow(topWindPtr, DragRgn)
 else begin
 if (InsertWPtr(HitWindPtr, WPtrArray, NumWSel))
 then begin
 SetCursor (secondCursor);
 currentWPeek := WindowPeek (HitWindPtr);
 UnionRgn (currentWPeek^.StrucRgn, DragRgn, DragRgn);
 end;
 end; { if (NumWSel > 0) }
 end;
 end;   {end setup of drag region}

 ClipRect(WMgrPort^.portRect);if (WPtrArray[1] <> topWindPtr)  
 then ClipAbove (WindowPeek (WPtrArray[1]));
 IF (BitAnd(theEvent.modifiers, cmdKey) <> 0)
 then SetRect(dragLim,-nearInfinity, -nearInfinity, nearInfinity, 
 nearInfinity);
 with dragLim do begin
 SetRect (limitRect, left, top, right, bottom);
 SetRect (slopRect, left - SlopSize, top - 45, right + SlopSize, 
 bottom + SlopSize);
 end;

 longPos := DragGrayRgn (DragRgn,
 mousePos,limitRect,slopRect,0,NIL);

 IF (longPos<>OutOfBounds) then begin
 hMov := LoWord (longPos);
 vMov := HiWord (longPos);
 IF (BitAnd(theEvent.modifiers,shiftKey)<>0)
 then begin
 IF (ABS(hMov) + ABS(vMov) > 5)    then begin
 Dropout := TRUE;
 MoveWindSel (WPtrArray,   NumWSel,hMov,vMov,dragLim);
 end;
 end
 else begin
 IF (BitAnd (theEvent.modifiers,   optionKey) <> 0)
 then MoveWindBelow (hitWindPtr, hMov, vMov, dragLim)
 else begin {default actions}
 if (NumWSel = 0)
 then MoveWindBelow  (topWindPtr, hMov,                        
 vMov, dragLim)
 else MoveWindSel  (WPtrArray, NumWSel,                        
 hMov, vMov, dragLim);
 end;
 end;
 end; {IF (longPos <> OutOfBounds)}
 end;   {if (thePart < inSysWindow)... }
 SetCursor (mainCursor);
 end;
 UNTIL Dropout;

 IF (haveSound)
 then DisposPtr (SoundPointer);
 SetPort (savePort); {restore port & clipping}
 SetClip (ExistClipRgn);
 DisposeRgn (ExistClipRgn);
 DisposeRgn (DragRgn);
 flushEvents (allKeyEvents, 0);  
 SetCursor (saveCursr); { restore cursor }
END;

PROCEDURE Get3Cursors (VAR svCrs: Cursor; VAR                  
 hndCrs: Cursor; VAR scndCrs: Cursor);
CONST
 LoMemCrsrLoc  = $844;
VAR
 CrsrPtr: ^Cursor;
BEGIN
    CrsrPtr := pointer (LoMemCrsrLoc);
    svCrs := CrsrPtr^;
    StuffHex (ptr (@hndCrs), ‘AAAA0000B030334E’ );
    StuffHex (ptr (longint (@hndCrs) + 8), ’84C954C982490249');
    StuffHex (ptr (longint (@hndCrs) + 16), ‘8D01130091000800’);
    StuffHex (ptr (longint (@hndCrs) + 24), ‘8400040082004100’);
    StuffHex (ptr (longint (@hndCrs) + 32), ‘AAAA0000B030337E’);
    StuffHex (ptr (longint (@hndCrs) + 40), ’87FF57FF83FF03FF’);
    StuffHex (ptr (longint (@hndCrs) + 48), ‘8FFF1FFF9FFF0FFF’);
    StuffHex (ptr (longint (@hndCrs) + 56), ’87FF07FF83FF41FF’);
    StuffHex (ptr (longint (@hndCrs) + 64), ‘00050007’);

    StuffHex (ptr (@scndCrs), ‘000000000030034E’ );
    StuffHex (ptr (longint (@scndCrs) + 8), ’04C904C902490249');
    StuffHex (ptr (longint (@scndCrs) + 16), ‘0D01130011000800’);
    StuffHex (ptr (longint (@scndCrs) + 24), ‘0400040002000100’);
    StuffHex (ptr (longint (@scndCrs) + 32), ‘000000000030037E’);
    StuffHex (ptr (longint (@scndCrs) + 40), ’07FF07FF03FF03FF’);
    StuffHex (ptr (longint (@scndCrs) + 48), ‘0FFF1FFF1FFF0FFF’);
    StuffHex (ptr (longint (@scndCrs) + 56), ’07FF07FF03FF01FF’);
    StuffHex (ptr (longint (@scndCrs) + 64), ‘00050007’);
END;

PROCEDURE GetScreenSize (topWind: windowPtr;                   
 VAR screenPerim: rect);
TYPE
 WStatePtr = ^WStateData;
 WStateHdl = ^WStatePtr;
VAR
 windRect : rect;
 ZoomDataHdl: WStateHdl;
 tempWindPtr: windowPtr;
BEGIN
 SetRect (windRect, 40, 0, 100, 100);
 tempWindPtr := NewWindow (nil, windRect, ‘x’,                 
 FALSE, 8, topWind, TRUE, 0);
 ZoomDataHdl := WStateHdl (WindowPeek  (tempWindPtr)^.dataHandle);
 screenPerim.left := ZoomDataHdl^^.stdState.left - 2;
 screenPerim.top := ZoomDataHdl^^.stdState.top;
 screenPerim.Right := ZoomDataHdl^^.stdState.right + 2;
 screenPerim.Bottom := ZoomDataHdl^^.stdState.bottom + 2;
 disposeWindow (tempWindPtr);
END;

FUNCTION LoadSound (VAR SoundBuffer: Ptr; VAR                  
 sndSize: longint): boolean;
 { This code trys to load a sound file. To allow some selection of playback 
rate, it will look for 2 different files.  If it finds a file called 
Sound22, it will load/play it at a sampling rate of 22 kHz. If thats 
not found, it will look for Sound11, and if found it will be played at 
11 kHz.}  
VAR
 FFSound: FFSynthPtr;
 soundRef : integer;
 rateDiv, rc: integer;
 Count, fSize  : longint;
BEGIN
 rateDiv := 1;   { assume 22 kHz sampling }
 LoadSound := FALSE;
 rc := FSOpen (‘Sound22’, 0, soundRef);
 IF (rc <> noErr)
 THEN BEGIN
 rateDiv := 2;   {set for 11 kHz playback}
 rc := FSOpen (‘Sound11’, 0, soundRef);
 END;
 IF (rc = noErr)
 THEN BEGIN
 LoadSound := TRUE;
 { get file size }
 rc := GetEOF( soundRef, fSize );
 { size of sound buffer }
 sndSize := fSize + 6;
 SoundBuffer := NewPtr (sndSize);
 FFSound := FFSynthPtr (SoundBuffer);
 FFSound^.mode := ffMode; { free form }
 { fill in the fixed binary playback rate }
 FFSound^.count := FixRatio (1, rateDiv);                      Count 
:= fSize;
 rc := FSRead (soundREf, Count, @FFSound^.waveBytes);
 rc := FSClose (soundRef);
 END;
END;

FUNCTION InsertWPtr(HitWPtr : windowPtr;
 VAR PtrArray  : WindArray;
 VAR NumWind: integer): boolean;
{IF ptr not in list, put window ptr ‘HitWPtr’ in list ‘PtrArray’ & add 
1 to ‘NumWind’ ALWAYS keep ptr to highest selected window in ‘PtrArray[1]’
 }
VAR
 ctr    : integer;
 match  : boolean;
 cWPeek : windowPeek;
 cWPtr  : WindowPtr;
 HiPtr  : WindowPtr;
BEGIN
 if (NumWind = 0)
 then begin
 NumWind := 1;
 PtrArray[1] := HitWPtr;
 InsertWPtr := TRUE;
 end
 else begin
 ctr := 0;
 REPEAT
 ctr := ctr + 1;
 match := (HitWPtr = PtrArray[ctr]);
 UNTIL (ctr = NumWind) or (match);

 if (match)
 then InsertWPtr := FALSE
 else begin
 NumWind := NumWind + 1;
 InsertWPtr := TRUE;

 HiPtr := PtrArray[1];
 cWPtr := HitWPtr;
 REPEAT
 cWPeek := WindowPeek (cWPtr);
 cWPtr := windowPtr(cWPeek^.nextWindow);
 UNTIL (cWPtr = HiPtr) or (cWPtr = NIL);
 if (cWPtr = HiPtr)
 then begin
 PtrArray[NumWind] := HiPtr;
 PtrArray[1] := HitWPtr;
 end
 else PtrArray[NumWind] := HitWPtr;
 end;
 end;
END;

PROCEDURE SumWRgnsBelow (StartWPtr: windowPtr;                 
 DragRegion: RgnHandle);
{ return in ‘DragRegion’ a region including all windows after & incl. 
window ‘StartWPtr’}
VAR
 currWPeek: windowPeek;
 PrevWPeek: windowPeek;
 currWindPtr: WindowPtr;
BEGIN
 currWindPtr := StartWPtr;
 REPEAT
 currWPeek := WindowPeek (currWindPtr);
 UnionRgn (currWPeek^.StrucRgn, DragRegion, DragRegion);
 PrevWPeek := currWPeek;
 currWindPtr := windowPtr(PrevWPeek^.nextWindow);
 UNTIL (currWindPtr = NIL);
END;

PROCEDURE MoveWindBelow (StartWPtr: windowPtr;                 
 hor, ver: integer; dragArea: rect);
{move windows -> ‘StartWPtr’ to last window in the window list by ‘hor’,’ver’
 }
VAR
 PrevWPeek: windowPeek;
 currWindPtr: WindowPtr;
 origLoc: point;
 leftBound: integer;
BEGIN
 currWindPtr := StartWPtr;
 
REPEAT
 SetPort (grafPtr(currWindPtr));
 origLoc := currWindPtr^.portrect.topleft;
 LocalToGlobal (origLoc);
 origLoc.h := origLoc.h + hor;
 origLoc.v := origLoc.v + ver;
 IF (origLoc.v < dragArea.top)
 then origLoc.v := dragArea.top;
 if (origLoc.v > dragArea.bottom)
 then origLoc.v := dragArea.bottom;
 leftBound := dragArea.left
 - GrafPtr(currWindPtr)^.portRect.right
 + GrafPtr(currWindPtr)^.portRect.left;
 if (origLoc.h < leftBound)
 then origLoc.h := leftBound;
 if (origLoc.h > dragArea.right)
 then origLoc.h := dragArea.right;
 MoveWindow(currWindPtr, origLoc.h, origLoc.v, FALSE);
 PrevWPeek := WindowPeek(currWindPtr);
 currWindPtr := windowPtr (PrevWPeek^.nextWindow);
 UNTIL (currWindPtr = NIL);
END;

PROCEDURE MoveWindSel (VAR PtrArray: 
 WindArray; NumWind: integer; hor, ver: 
 integer; dragArea : rect);
{move windows in ‘PtrArray’ by ‘hor’ & ‘ver’}

VAR
 origLoc: point;
 index  : integer;
 leftBound: integer;
BEGIN
 FOR index := 1 to NumWind DO begin
 SetPort (grafPtr(PtrArray[index]));
 origLoc := PtrArray[index]^.portrect.topleft;
 LocalToGlobal (origLoc);
 origLoc.h := origLoc.h + hor;
 origLoc.v := origLoc.v + ver;
 IF (origLoc.v < dragArea.top)
 then origLoc.v := dragArea.top;
 if (origLoc.v > dragArea.bottom)
 then origLoc.v := dragArea.bottom;
 leftBound := dragArea.left
  - GrafPtr(PtrArray[index])^.portRect.right
  + GrafPtr(PtrArray[index])^.portRect.left;
 if (origLoc.h < leftBound)
 then origLoc.h := leftBound;
 if (origLoc.h > dragArea.right)
 then origLoc.h := dragArea.right;
 MoveWindow (PtrArray[index], origLoc.h, origLoc.v, FALSE);
 end;
END;
END.    { of UNIT }
MPW MakeFile

DragIt  ƒ Drag.p.o
    Pascal Drag.p
    Link -rt FKEY=8 -m DRAGIT -t FKEY -c RSED 
      -sn “Main=Slider” 
      Drag.p.o 
 “{Libraries}”Interface.o 
      -o Slider.fkey

 
AAPL
$99.28
Apple Inc.
+1.61
MSFT
$43.87
Microsoft Corpora
+0.24
GOOG
$516.51
Google Inc.
+5.34

MacTech Search:
Community Search:

Software Updates via MacUpdate

TechTool Pro 7.0.5 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
Yasu 2.9.1 - System maintenance app; per...
Yasu was originally created with System Administrators who service large groups of workstations in mind, Yasu (Yet Another System Utility) was made to do a specific group of maintenance tasks... Read more
Hazel 3.3 - Create rules for organizing...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a... Read more
Autopano Giga 3.7 - Stitch multiple imag...
Autopano Giga allows you to stitch 2, 20, or 2,000 images. Version 3.0 integrates impressive new features that will definitely make you adopt Autopano Pro or Autopano Giga: Choose between 9... Read more
MenuMeters 1.8 - CPU, memory, disk, and...
MenuMeters is a set of CPU, memory, disk, and network monitoring tools for Mac OS X. Although there are numerous other programs which do the same thing, none had quite the feature set I was looking... Read more
Coda 2.5 - One-window Web development su...
Coda is a powerful Web editor that puts everything in one place. An editor. Terminal. CSS. Files. With Coda 2, we went beyond expectations. With loads of new, much-requested features, a few... Read more
Arq 4.6.1 - Online backup to Google Driv...
Arq is super-easy online backup for the Mac. Back up to your own Google Drive storage (15GB free storage), your own Amazon Glacier ($.01/GB per month storage) or S3, or any SFTP server. Arq backs up... Read more
Airfoil 4.8.10 - Send audio from any app...
Airfoil allows you to send any audio to AirPort Express units, Apple TVs, and even other Macs and PCs, all in sync! It's your audio - everywhere. With Airfoil you can take audio from any... Read more
Apple iMovie 10.0.6 - Edit personal vide...
With an all-new design, Apple iMovie lets you enjoy your videos like never before. Browse your clips more easily, instantly share your favorite moments, and create beautiful HD movies and Hollywood-... Read more
Tunnelblick 3.4.1 - GUI for OpenVPN. (Fr...
Tunnelblick is a free, open source graphic user interface for OpenVPN on OS X. It provides easy control of OpenVPN client and/or server connections. It comes as a ready-to-use application with all... Read more

Latest Forum Discussions

See All

GAMEVIL Announces the Upcoming Launch of...
GAMEVIL Announces the Upcoming Launch of Mark of the Dragon Posted by Jessica Fisher on October 20th, 2014 [ permalink ] Mark of the Dragon, by GAMEVIL, put | Read more »
Find Free Food on Campus with Ypay
Find Free Food on Campus with Ypay Posted by Jessica Fisher on October 20th, 2014 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
Strung Along Review
Strung Along Review By Jordan Minor on October 20th, 2014 Our Rating: :: GOT NO STRINGSUniversal App - Designed for iPhone and iPad A cool gimmick and a great art style keep Strung Along from completely falling apart.   | Read more »
P2P file transferring app Send Anywhere...
File sharing services like Dropbox have security issues. Email attachments can be problematic when it comes to sharing large files. USB dongles don’t fit into your phone. Send Anywhere, a peer-to-peer file transferring application, solves all of... | Read more »
Zero Age Review
Zero Age Review By Jordan Minor on October 20th, 2014 Our Rating: :: MORE THAN ZEROiPad Only App - Designed for the iPad With its mind-bending puzzles and spellbinding visuals, Zero Age has it all.   | Read more »
Hay Ewe Review
Hay Ewe Review By Campbell Bird on October 20th, 2014 Our Rating: :: SAVE YOUR SHEEPLEUniversal App - Designed for iPhone and iPad Pave the way for your flock in this line drawing puzzle game from the creators of Worms.   | Read more »
My Very Hungry Caterpillar (Education)
My Very Hungry Caterpillar 1.0.0 Device: iOS Universal Category: Education Price: $3.99, Version: 1.0.0 (iTunes) Description: Care for your very own Very Hungry Caterpillar! My Very Hungry Caterpillar will captivate you as he crawls... | Read more »
Dungeon Dick (Games)
Dungeon Dick 1.1 Device: iOS Universal Category: Games Price: $.99, Version: 1.1 (iTunes) Description: Dungeon Dick is a fantasy adventure where you must discover the wicked plot to destroy the lands . 'Fling' at your foes and land... | Read more »
Here’s How the Apple Watch Could Transfo...
With the Apple Watch’s generic release date of, “early 2015” hovering on the horizon, it’s only a matter of time before gamers begin to ask “What’s in it for us?” The obvious choice would be to place entire games directly on the face of the watch,... | Read more »
Republique Episode 3: Ones & Zeroes...
Republique Episode 3: Ones & Zeroes is Available Now Posted by Rob Rich on October 17th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »

Price Scanner via MacPrices.net

2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
Updated iPad Prices
We’ve updated our iPad Air Price Tracker and our iPad mini Price Tracker with the latest information on prices and availability from Apple and other resellers, including the new iPad Air 2 and the... Read more
Apple Pay Available to Millions of Visa Cardh...
Visa Inc. brings secure, convenient payments to iPad Air 2 and iPad mini 3as well as iPhone 6 and 6 Plus. Starting October 20th, eligible Visa cardholders in the U.S. will be able to use Apple Pay,... Read more
Textkraft Pocket – the missing TextEdit for i...
infovole GmbH has announced the release and immediate availability of Textkraft Pocket 1.0, a professional text editor and note taking app for Apple’s iPhone. In March 2014 rumors were all about... Read more
C Spire to offer iPad Air 2 and iPad mini 3,...
C Spire on Friday announced that it will offer iPad Air 2 and iPad mini 3, both with Wi-Fi + Cellular, on its 4G+ LTE network in the coming weeks. C Spire will offer the new iPads with a range of... Read more
Belkin Announces Full Line of Keyboards and C...
Belkin International has unveiled a new lineup of keyboard cases and accessories for Apple’s newest iPads, featuring three QODE keyboards and a collection of thin, lightweight folios for both the... Read more
Verizon offers new iPad Air 2 preorders for $...
Verizon Wireless is accepting preorders for the new iPad Air 2, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB iPad Air 2 WiFi... Read more
Price drops on refurbished Mac minis, now ava...
The Apple Store has dropped prices on Apple Certified Refurbished previous-generation Mac minis, with models now available starting at $419. Apple’s one-year warranty is included with each mini, and... Read more
Apple refurbished 2014 MacBook Airs available...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more
Refurbished 2013 MacBook Pros available for u...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available starting at $929. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros (4GB RAM/... Read more

Jobs Board

Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** At the Apple Store, you connect business professionals and entrepreneurs with the tools they need in order to put Apple solutions to work in their Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** The Apple Store is a retail environment like no other - uniquely focused on delivering amazing customer experiences. As an Expert, you introduce people Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** As businesses discover the power of Apple computers and mobile devices, it's your job - as a Solutions Engineer - to show them how to introduce these Read more
Position Opening at *Apple* - Apple (United...
…Summary** As a Specialist, you help create the energy and excitement around Apple products, providing the right solutions and getting products into customers' hands. You Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.