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

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »

Price Scanner via MacPrices.net

Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.