TweetFollow Us on Twitter

Building PICT 2
Volume Number:10
Issue Number:3
Column Tag:Getting Started

Related Info: List Manager Resource Manager

Using The List Manager

Building and using a list of PICT resources

By Dave Mark, MacTech Magazine Regular Contributing Author

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

Last month’s column presented PictLister, a program designed to showcase the Mac Toolbox’s List Manager. The vast majority of Macintosh applications make use of the List Manager, albeit indirectly. Figure 1 shows a call to StandardGetFile(), the Mac Toolbox’s standard mechanism for selecting a file to open. The scrolling list in Figure 1 was implemented by the List Manager.

Figure 1. The List Manager, as used by StandardGetFile().

Just as a reminder, we’ll put PictLister through its paces before we walk through the source code. Startup THINK C by double-clicking on the file PictLister.Π. When the project opens, select Run from the Project menu.

PictLister features three menus: Apple, File, and Edit. Figure 2 shows the File menu.

Figure 2. PictLister’s File menu.

Close closes the frontmost window and Quit quits PictLister. New List builds a list out of all available PICT resources, then creates a window to display the list. It’s important to note that the Resource Manager searches all open resource files in its quest for a particular resource type. At the very least, this search includes the application’s resource fork as well as the System file in the currently blessed System Folder (a.k.a., the System on the startup disk).

Figure 3 shows a sample PictLister window.

Figure 3. A PictLister window.

The entire content region of the window (including both scroll bars, but not the window’s title bar) is dedicated to the window’s list. With very little effort on our part (just a call here or there) the List Manager will handle the scroll bars, clicks in the list, auto-scrolling (click in the bottom of the list and drag down), update events, etc. As you’ll see, the List Manager gives you a lot of functionality with very little work on your part.

Once the PictLister window appears, you can do all the normal window-type things. You can drag the window, resize it, and close it by clicking in the close box.

If you click on a name in the list, the List Manager will highlight the name. Click on another name, the first name will be unhighlighted, then that name will be highlighted. If you double-click on a name, a new window will appear showing the specified PICT.

By the way, the names in the list are drawn directly from the names of the associated PICT resource. If the resource isn’t named, we use the string “Unnamed” to name the string.

Walking Through the Source Code

PictLister starts off with a bunch of #defines, some familiar, some not. As usual, you’ll see what they do in context.


/* 1 */
#define kMBARResID 128
#define kSleep   60L
#define kMoveToFront (WindowPtr)-1L
#define kNilFilterProc    (ProcPtr)0L
#define kEmptyString "\p"
#define kHasGoAway true
#define kInvisible false

#define kListDefProc 0
#define kDontDrawYet false
#define kHasGrow true
#define kHasHScrolltrue
#define kHasVScrolltrue
#define kFindNexttrue

#define kListWindow0
#define kDAWindow1
#define kUnknownWindow    2
#define kPictWindow3
#define kNilWindow 4

#define kMinWindowWidth   210
#define kMinWindowHeight  63
#define kWindowHeight255
#define kMinPictWinHeight 50
#define kMinPictWinWidth  150

#define mApple   128
#define iAbout   1

#define mFile    129
#define iNewList 1
#define iClose   2
#define iQuit    4

#define kErrorAlertID128

Frequently, you’ll want to attach additional information to a window. Suppose you wrote a program that implemented a personal phone book. Suppose your program creates an individual window for each person in the phone book. Each window would have the same fields but would contain different data to place in the fields when the window was updated.

One way to write this program is to create a struct containing the data for each window, allocate memory for the struct when you create the window, then tie it to the window. When it comes time to update the window, retrieve the struct tied to that window and use the data in the struct to fill in the window’s fields. This technique is known as window piggybacking. You’ll see how this works as we walk through the code.!cuses the piggybacking technique to tie the list to the list window and to tie the PICT to the PICT window. This is done by embedding a WindowRecord in each of the following typedefs.


/* 2 */
/************************/
/*      Typedefs        */
/************************/

typedef struct
{
 WindowRecord  w;
 short  wType;
 ListHandle list;
} ListRecord, *ListPeek;

typedef struct
{
 WindowRecord  w;
 short  wType;
 short  PictResID;
} PictRecord, *PictPeek;

Since NewWindow() allows you to allocate your own memory for your windows, you can allocate one of the above structs instead, passing a pointer to the struct to NewWindow(). To refer to the WindowRecord, just cast the struct pointer to a WindowPtr. This works because the WindowRecord is the first element in the struct. To refer to the entire struct, cast the struct pointer to a ListPeek or PictPeek, depending on which struct you are referring to.

Given a WindowPtr, how do you know which struct type is piggybacked on top of the window? That’s what the wType field is for. When the struct is allocated, the wType field is set to either kListWindow or kPictWindow. You’ll see how all this works as we go along.

The global variable gDone serves its usual role, indicating when it’s time to drop out of the main event loop. gNewWindowX and gNewWindowY specify the upper left corner of the next window to be created.


/* 3 */
/*************/
/*  Globals  */
/*************/

Boolean gDone;
short   gNewWindowX = 20, gNewWindowY = 50;

As usual, we provide a function prototype for each function in the source file.


/* 4 */
/***************/
/*  Functions  */
/***************/

void    ToolboxInit( void );
void    MenuBarInit( void );
void    CreateListWindow( void );
void    DestroyWindow( WindowPtr w );
void    EventLoop( void );
void    DoEvent( EventRecord *eventPtr );
void    DoUpdate( EventRecord *eventPtr );
void    DoActivate( EventRecord *eventPtr );
void    HandleMouseDown( EventRecord *eventPtr );
void    DoContentClick( EventRecord *eventPtr, WindowPtr w );
void    CreatePictWindow( ListHandle list );
void    BumpGlobalXandY( void );
void    DoGrow( EventRecord *eventPtr, WindowPtr w );
void    HandleMenuChoice( long menuChoice );
void    HandleAppleChoice( short item );
void    HandleFileChoice( short item );
void    CenterWindow( WindowPtr w );
void    CenterPict( PicHandle picture, Rect *destRectPtr );
short WindowType( WindowPtr window );
void    DoError( Str255 errorString );

main() initializes the Toolbox, sets up the menu bar, then enters the main event loop.


/* 5 */
/********************* main *********************/

void    main( void )
{
 ToolboxInit();
 MenuBarInit();
 
 EventLoop();
}

ToolboxInit() does its usual thing.


/* 6 */
/********************* ToolboxInit *********************/

void    ToolboxInit( void )
{
 InitGraf( &thePort );
 InitFonts();
 InitWindows();
 InitMenus();
 TEInit();
 InitDialogs( nil );
 InitCursor();
}

MenuBarInit() loads the MBAR, adds the normal resources to the Apple menu, and draws the menu bar.


/* 7 */
/********************* MenuBarInit *********************/

void    MenuBarInit( void )
{
 Handle menuBar;
 MenuHandle menu;
 
 menuBar = GetNewMBar( kMBARResID );
 SetMenuBar( menuBar );

 menu = GetMHandle( mApple );
 AddResMenu( menu, 'DRVR' );
 
 DrawMenuBar();
}

CreateListWindow() gets called when New List... is selected from the File menu. It starts by creating a Rect that specifies the size and position of the new window.


/* 8 */
/********************* CreateListWindow *********************/

void    CreateListWindow( void )
{
 Rect   r, dataBounds;
 WindowPtrw;
 Point  cSize, cIndex;
 ListHandle list;
 short  i, dummy, numPicts;
 Handle rHandle;
 short  resID;
 ResTypetheResType;
 Str255 rName;
 Ptr    wStorage;
 ListPeek l;
 
 SetRect( &r, gNewWindowX, gNewWindowY, gNewWindowX + 
 kMinWindowWidth, gNewWindowY + kWindowHeight);

The routine BumpGlobalXandY() increment gNewWindowX and gNewWindowY to the preferred position for the next window.


/* 9 */
 BumpGlobalXandY();

Since we’re creating a list window, we’ll allocate a ListRecord and pass a pointer to it to NewWindow().


/* 10 */
 wStorage = NewPtr( sizeof( ListRecord ) );
 
 w = NewWindow( wStorage, &r, "\pPicture List", kInvisible,
 documentProc, kMoveToFront, kHasGoAway, 0L );

 SetPort( w );

The call to TextFont() ensures that the list is drawn using the system font (Chicago).


/* 11 */
 TextFont( systemFont );

Next, we’ll prepare to create our list. dataBounds specifies the initial size of the list. In this case, we’re specifying a list 1 column wide and 0 rows deep. We’ll add rows to the list a little later.


/* 12 */
 SetRect( &dataBounds, 0, 0, 1, 0 );

cSize specifies the size, in pixels, of each cell in the list. By passing (0,0) as the cell size, we ask the List Manager to calcualte the size for us.


/* 13 */
 SetPt( &cSize, 0, 0 );

Finally, r is a Rect that specifies the bounds of the list. Note that the scroll bars are drawn outside this area.


/* 14 */
 SetRect (&r, 0, 0, kMinWindowWidth -15, kWindowHeight -15);

The list is created via a call to LNew(). kDontDrawYet tells the List Manager not to draw the list yet. We’ll draw the list later, once we add all the rows to it. kHasGrow, kHasHScroll, and kHasHScroll tell the List Manager to add two scroll bars and a grow box to the list.


/* 15 */
 list = LNew( &r, &dataBounds, cSize, kListDefProc,
 w, kDontDrawYet, kHasGrow, kHasHScroll, kHasVScroll );

LNew() returns a handle to a ListRec, the data structure representing the list. The selFlags field lets you specify how the list reacts to clicks in the list. We’ll use the flag lOnlyOne to tell the List Manager that only one item at a time can be highlighted in this list.


/* 16 */
 (**list).selFlags = lOnlyOne;

Our next step is to set the fields in our piggybacking list struct. We’ll set wType to kListWindow and save the handle to the ListRec for later recall.


/* 17 */
 l = (ListPeek)w;
 
 l->wType = kListWindow;
 l->list = list;

This next chunk of code adds the rows to the list. We’ll add one row to the list for every available PICT resource.


/* 18 */
 numPicts = CountResources( 'PICT' );
 
 for ( i = 0; i<numPicts; i++ )
 {

For each resource, retrieve the resource handle using GetIndResource(), then call GetResInfo() to retrieve the resource name, if it exists.


/* 19 */
 rHandle = GetIndResource( 'PICT', i + 1 );
 GetResInfo( rHandle, &resID, &theResType, rName );

LAddRow() adds 1 row the list specified by list. cIndex is set to the cell in the first (and only) column and in the i-th row.


/* 20 */
 dummy = LAddRow( 1, i, list );
 SetPt( &cIndex, 0, i );

Next, the data is added to the cell specified by cIndex. If the resource is not named, the string “<Unnamed>” is used instead.


/* 21 */
 if ( rName[ 0 ] > 0 )
 LAddToCell( &(rName[1]), rName[0], cIndex, list );
 else
 LAddToCell( "<Unnamed>", 10, cIndex, list );
 }

Next, the window is made visible, and LDoDraw() is called to enable drawing in the list. This doesn’t mean that the list will be drawn at this point. Instead, the next time the List Manager is asked to draw the list (perhaps via a call to LUpdate(), it will be able to.


/* 22 */
 ShowWindow( w );
 LDoDraw( true, list );
}

DestroyWindow() is called to close and deallocate the specified window.


/* 23 */
/********************* DestroyWindow *********************/

void    DestroyWindow( WindowPtr w )
{
 ListPeek l;

If the window is a list window, we need to deallocate the memory allocated for the list by calling LDispose() and then the memory allocated for the window itself by calling DisposePtr().


/* 24 */
 if ( WindowType( w ) == kListWindow )
 {
 HideWindow( w );
 l = (ListPeek)w;
 
 LDispose( l->list );
 
 CloseWindow( w );
 
 DisposePtr( (Ptr)w );
 }

If the window was a PICT window, all we need to deallocate is the memory allocated for the window.


/* 25 */
 else if ( WindowType( w ) == kPictWindow )
 {
 CloseWindow( w );
 DisposePtr( (Ptr)w );
 }
}

EventLoop() does what it always did.


/* 26 */
/********************* EventLoop *********************/

void    EventLoop( void )
{
 EventRecordevent;
 
 gDone = false;
 while ( gDone == false )
 {
 if ( WaitNextEvent( everyEvent, &event, kSleep, NULL ) )
 DoEvent( &event );
 }
}

DoEvent() dispatches the specified event.


/* 27 */
/********************* DoEvent *********************/

void    DoEvent( EventRecord *eventPtr )
{
 char   theChar;
 
 switch ( eventPtr->what )
 {
 case mouseDown: 
 HandleMouseDown( eventPtr );
 break;
 case keyDown:
 case autoKey:
 theChar = eventPtr->message & charCodeMask;
 if ( (eventPtr->modifiers & cmdKey) != 0 ) 
 HandleMenuChoice( MenuKey( theChar ) );
 break;
 case updateEvt:
 DoUpdate( eventPtr );
 break;
 case activateEvt:
 DoActivate( eventPtr );
 break;
 }
}

DoUpdate() handles update events.


/* 28 */
/********************* DoUpdate *********************/

void    DoUpdate( EventRecord *eventPtr )
{
 WindowPtrw;
 short  numPicts, i;
 ListPeek l;
 ListHandle list;
 GrafPtroldPort;
 Rect   r;
 Point  cellIndex;
 PicHandlepic;
 PictPeek p;

We’ll retrieve the WindowPtr from the EventRecord. As always, we’ll sandwich our update processing code between calls to BeginUpdate() and EndUpdate().


/* 29 */
 w = (WindowPtr)(eventPtr->message);
 BeginUpdate( w );

If the window is a list window (See explanation of WindowType() later in the column), we’ll retrieve the list handle from the piggybacking list struct, redraw the grow box, then call LUpdate() to update the list as needed. Simple, eh?


/* 30 */
 if ( WindowType( w ) == kListWindow )
 {
 GetPort( &oldPort );
 SetPort( w );
 
 l = (ListPeek)w;
 list = l->list;
 
 DrawGrowIcon( w );
 
 LUpdate( (**list).port->visRgn, list );
 
 SetPort( oldPort );
 }

If the window is a pict window, we’ll retrieve the PICT resource id from the piggybacked pict struct, retrieve the PICT resource by calling GetPicture(), then center and draw the picture.


/* 31 */
 else if ( WindowType( w ) == kPictWindow )
 {
 GetPort( &oldPort );
 SetPort( w );
 
 r = w->portRect;
 
 p = (PictPeek)w;
 
 pic = GetPicture( p->PictResID );
 
 CenterPict( pic, &r );
 DrawPicture( pic, &r );
 
 SetPort( oldPort );
 }
 EndUpdate( w );
}

DoActivate() handles activate events. Since the Pict window doesn’t need any special activate event processing, all we have to do is handle list window activates.


/* 32 */
/********************* DoActivate *********************/

void    DoActivate( EventRecord *eventPtr )
{
 WindowPtrw;
 ListPeek l;
 ListHandle list;
 
 w = (WindowPtr)(eventPtr->message);

If the window receiving the activate event is a list window, we’ll check to see whether the activate event is an activate or deactivate event, then make the appropriate call to LActivate(), then redraw the grow box.


/* 33 */
 if ( WindowType( w ) == kListWindow )
 {
 l = (ListPeek)w;
 list = l->list;
 
 if ( eventPtr->modifiers & activeFlag )
 LActivate( true, list );
 else
 LActivate( false, list );
 
 DrawGrowIcon( w );
 }
}

Most of HandleMouseDown() should look familiar to you.


/* 34 */
/********************* HandleMouseDown *********************/

void    HandleMouseDown( EventRecord *eventPtr )
{
 WindowPtrwindow;
 short  thePart;
 long   menuChoice;
 GrafPtroldPort;
 long   windSize;
 Rect   growRect;
 
 thePart = FindWindow( eventPtr->where, &window );
 
 switch ( thePart )
 {
 case inMenuBar:
 menuChoice = MenuSelect( eventPtr->where );
 HandleMenuChoice( menuChoice );
 break;
 case inSysWindow : 
 SystemClick( eventPtr, window );
 break;
 case inContent:
 DoContentClick( eventPtr, window );
 break;
 case inGrow:
 DoGrow( eventPtr, window );
 break;
 case inDrag : 
 DragWindow( window, eventPtr->where, 
 &screenBits.bounds );
 break;

The one exception is the call to DestroyWindow() when the mouse is clicked in the go away box.


/* 35 */
 case inGoAway:
 if ( TrackGoAway( window, eventPtr->where ) )
 DestroyWindow( window );
 break;
 }
}

DoContentClick() is called when the mouse is clicked in the specified window’s content region.


/* 36 */
/********************* DoContentClick *********************/

void    DoContentClick( EventRecord *eventPtr, WindowPtr w )
{
 GrafPtroldPort;
 ListHandle list;
 ListPeek l;

If the window is not currently in front, SelectWindow() is called to bring the window to the front.


/* 37 */
 if ( w != FrontWindow() )
 {
 SelectWindow( w );
 }

If the click was in the frontmost window and the window is a list window, we’ll convert the current mouse coordinates (which are in global coordinates) to the window’s local coordinate system.


/* 38 */
 else if ( WindowType( w ) == kListWindow )
 {
 GetPort( &oldPort );
 SetPort( w );
 
 GlobalToLocal( &(eventPtr->where) );

Next, we’ll retrieve the list handle and pass it to LClick(). LClick() handles all types of clicks, from clicks in the scroll bars to clicks in the list cells. LClick() returns true if a double-click occurs. In that case, we’ll create a new pict window from the currently selected list item.


/* 39 */
 l = (ListPeek)w;
 list = l->list;
 
 if (LClick( eventPtr->where, eventPtr->modifiers, list ))
 CreatePictWindow( list );
 SetPort( oldPort );
 }
}

CreatePictWindow() first must figure out which of the list’s cells is selected, then create a pict window based on the resource associated with that cell.


/* 40 */
/********************* CreatePictWindow *********************/

void    CreatePictWindow( ListHandle list )
{
 Cell   cell;
 PicHandlepic;
 Handle rHandle;
 Rect   r;
 short  resID;
 ResTypetheResType;
 Str255 rName;
 PictPeek p;
 Ptr    wStorage;
 WindowPtrw;

We’ll start by setting cell to identify the first cell in the list.


/* 41 */
 SetPt( &cell, 0, 0 );

LGetSelect() starts at cell, then moves through the list until it finds a cell that is highlighted. If LGetSelect() finds a highlighted cell, it puts the cell’s coordinates in cell and returns true.

 
/* 42 */
 if ( LGetSelect( kFindNext, &cell, list ) )
 {

If a highlighted cell was found, we’ll use cell.v to retrieve the appropriate PICT resource. Notice that cell is zero-based, while GetIndResource() is one-based.


/* 43 */
 rHandle = GetIndResource( 'PICT', cell.v + 1 );
 pic = (PicHandle)rHandle;
 
 r = (**pic).picFrame;

Once the PICT is loaded, we’ll make sure the new window is at least as wide as kMinPictWinWidth and at least as tall as kMinPictWinHeight.


/* 44 */
 if ( r.right - r.left < kMinPictWinWidth )
 r.right = r.left + kMinPictWinWidth;
 
 if ( r.bottom - r.top < kMinPictWinHeight )
 r.bottom = r.top + kMinPictWinHeight;

Next, we’ll offset the window’s Rect to correspond to the appropriate upper-left corner and the upper-left globals are bumped again.


/* 45 */
 OffsetRect( &r, gNewWindowX - r.left, 
 gNewWindowY - r.top );
 
 BumpGlobalXandY();

Next, a PictRecord is allocated and the new storage is used to create the new window.


/* 46 */
 wStorage = NewPtr( sizeof( PictRecord ) );
 
 GetResInfo( rHandle, &resID, &theResType, rName );
 
 if ( rName[ 0 ] > 0 )
 {
 w = NewWindow( wStorage, &r, rName, kInvisible,
 noGrowDocProc, kMoveToFront, kHasGoAway, 0L );
 }
 else
 {
 w = NewWindow( wStorage, &r, "\p<Unnamed>", kInvisible,
 noGrowDocProc, kMoveToFront, kHasGoAway, 0L );
 }
 
 ShowWindow( w );
 SetPort( w );

Finally, the PictRecord’s wType field is set to kPictWindow and the PICT’s resource id is stored in the PictResID field for use by DoUpdate().


/* 47 */
 p = (PictPeek)w;
 p->wType = kPictWindow;
 p->PictResID = resID;
 }
}

BumpGlobalXandY() bumps the global X and Y coordinates of the next window’s upper left corner by 20 pixels.


/* 48 */
/********************* BumpGlobalXandY *********************/

void    BumpGlobalXandY( void )
{
 gNewWindowX += 20;
 gNewWindowY += 20;

If the window is threatening to move off the bottom or right hand side of the screen, the gNewWindowX and gNewWindowY are reset.


/* 49 */
 if ( (gNewWindowX > screenBits.bounds.right - 100) ||
 (gNewWindowY > screenBits.bounds.bottom - 100) )
 {
 gNewWindowX = 20;
 gNewWindowY = 50;
 }
}

DoGrow() is called when the mouse is clicked in a window’s grow box.


/* 50 */
/********************* DoGrow  *********************/

void    DoGrow( EventRecord *eventPtr, WindowPtr w )
{
 Rect   r;
 GrafPtroldPort;
 Cell   cSize;
 long   windSize;
 ListHandle list;

If the window is a list window, we’ll first establish the minimum and maximum size 
of the window.

/* 51 */
 if ( WindowType( w ) == kListWindow )
 {
 r.top = kMinWindowHeight;
 r.bottom = 32767;
 r.left = kMinWindowWidth;
 r.right = 32767;

Next, we’ll call GrowWindow(). If the window was resized, we’ll call SizeWindow() to resize the window, then LSize() to let the List Manager know that the list has been resized.


/* 52 */
 windSize = GrowWindow( w, eventPtr->where, &r );
 if ( windSize )
 {
 GetPort( &oldPort );
 SetPort( w );
 EraseRect( &w->portRect );

 SizeWindow( w, LoWord (windSize),
 HiWord(windSize), true );

Notice that the scroll bars are not included in the list’s height and width.


/* 53*/
 list = ((ListPeek)w)->list;
 LSize( LoWord(windSize)-15,
 HiWord(windSize)-15, list );

Next, cSize is set to the current cell size in pixels (including both height and width).


/* 54 */
 cSize = (*list)->cellSize;

Though the height of a cell hasn’t changed, we’re going to make our cell as wide as the window. Note that this won’t always be the case (resize an Excel spreadsheet and the cells don’t change size). We’ll call LCellSize() to resize all the cells and InvalRect() to force an update.

If you have any doubts about any of these calls, try commenting them out and see what happens.


/* 55 */
 cSize.h = LoWord( windSize ) - 15;
 LCellSize( cSize, list );
 InvalRect( &w->portRect );
 SetPort( oldPort );
 }
 }
}

HandleMenuChoice() dispatches a menu selection.


/* 56 */
/********************* HandleMenuChoice *********************/

void    HandleMenuChoice( long menuChoice )
{
 short  menu;
 short  item;
 
 if ( menuChoice != 0 )
 {
 menu = HiWord( menuChoice );
 item = LoWord( menuChoice );
 
 switch ( menu )
 {
 case mApple:
 HandleAppleChoice( item );
 break;
 case mFile:
 HandleFileChoice( item );
 break;
 }
 HiliteMenu( 0 );
 }
}

HandleAppleChoice() does what it always does.


/* 57 */
/********************* HandleAppleChoice ********************/

void    HandleAppleChoice( short item )
{
 MenuHandle appleMenu;
 Str255 accName;
 short  accNumber;
 
 switch ( item )
 {
 case iAbout:
 SysBeep( 20 );
 break;
 default:
 appleMenu = GetMHandle( mApple );
 GetItem( appleMenu, item, accName );
 accNumber = OpenDeskAcc( accName );
 break;
 }
}

HandleFileChoice() dispatches selections from the File menu.


/* 58 */
/********************* HandleFileChoice *********************/

void    HandleFileChoice( short item )
{
 switch ( item )
 {
 case iNewList:
 CreateListWindow();
 break;
 case iClose:
 DestroyWindow( FrontWindow() );
 break;
 case iQuit:
 gDone = true;
 break;
 }
}

CenterPict() centers the specified picture in the specified Rect, setting the Rect to the newly centered Pict’s Rect.


/* 59 */
/********************* CenterPict *********************/

void    CenterPict( PicHandle picture, Rect *destRectPtr )
{
 Rect   windRect, pictRect;
 
 windRect = *destRectPtr;
 pictRect = (**( picture )).picFrame;
 OffsetRect( &pictRect, windRect.left - pictRect.left,
 windRect.top   - pictRect.top);
 OffsetRect( &pictRect, (windRect.right - pictRect.right)/2,
 (windRect.bottom - pictRect.bottom)/2);
 *destRectPtr = pictRect;
}

WindowType() returns the type of the specified window. If the window has a negative windowKind field, it’s a Desk Accessory. If the window’s wType field is kListWindow or kPictWindow, one of those is returned, otherwise kUnknownWindow is returned.


/* 60 */
/********************* WindowType *********************/

short WindowType( WindowPtr window )
{
 if ( window == nil )
 return( kNilWindow );
 if ( ((WindowPeek)window)->windowKind < 0 )
 return( kDAWindow );
 
 if ( ((ListPeek)window)->wType == kListWindow )
 return( kListWindow );
 
 if ( ((ListPeek)window)->wType == kPictWindow )
 return( kPictWindow );
 
 return( kUnknownWindow );
}

DoError() puts up a StopAlert(), then exits.


/* 61 */
/********************* DoError *********************/

void    DoError( Str255 errorString )
{
 ParamText( errorString, kEmptyString, 
 kEmptyString, kEmptyString );
 
 StopAlert( kErrorAlertID, kNilFilterProc );
 
 ExitToShell();
}

Till Next Month

If you want to know more about the List Manager, check out the appropriate chapters in Inside Macintosh or read about it online in THINK Reference. For some real thrills, try writing your own LDEF that displays small icons as well as text in your list. If you want to exceed 32K worth of list data, you’ll have to write your own LDEF.

Next month, I’m going to try my hardest to get to that PixMap program I keep promising to do. We’ll see. In the meantime, Deneen and I are going to Santa Fe to take Daniel skiing for the first time. Can you believe how quickly time flies?

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Ableton Live 11.3.11 - Record music usin...
Ableton Live lets you create and record music on your Mac. Use digital instruments, pre-recorded sounds, and sampled loops to arrange, produce, and perform your music like never before. Ableton Live... Read more
Affinity Photo 2.2.0 - Digital editing f...
Affinity Photo - redefines the boundaries for professional photo editing software for the Mac. With a meticulous focus on workflow it offers sophisticated tools for enhancing, editing and retouching... Read more
SpamSieve 3.0 - Robust spam filter for m...
SpamSieve is a robust spam filter for major email clients that uses powerful Bayesian spam filtering. SpamSieve understands what your spam looks like in order to block it all, but also learns what... Read more
WhatsApp 2.2338.12 - Desktop client for...
WhatsApp is the desktop client for WhatsApp Messenger, a cross-platform mobile messaging app which allows you to exchange messages without having to pay for SMS. WhatsApp Messenger is available for... Read more
Fantastical 3.8.2 - Create calendar even...
Fantastical is the Mac calendar you'll actually enjoy using. Creating an event with Fantastical is quick, easy, and fun: Open Fantastical with a single click or keystroke Type in your event details... Read more
iShowU Instant 1.4.14 - Full-featured sc...
iShowU Instant gives you real-time screen recording like you've never seen before! It is the fastest, most feature-filled real-time screen capture tool from shinywhitebox yet. All of the features you... Read more
Geekbench 6.2.0 - Measure processor and...
Geekbench provides a comprehensive set of benchmarks engineered to quickly and accurately measure processor and memory performance. Designed to make benchmarks easy to run and easy to understand,... Read more
Quicken 7.2.3 - Complete personal financ...
Quicken makes managing your money easier than ever. Whether paying bills, upgrading from Windows, enjoying more reliable downloads, or getting expert product help, Quicken's new and improved features... Read more
EtreCheckPro 6.8.2 - For troubleshooting...
EtreCheck is an app that displays the important details of your system configuration and allow you to copy that information to the Clipboard. It is meant to be used with Apple Support Communities to... Read more
iMazing 2.17.7 - Complete iOS device man...
iMazing is the world’s favourite iOS device manager for Mac and PC. Millions of users every year leverage its powerful capabilities to make the most of their personal or business iPhone and iPad.... Read more

Latest Forum Discussions

See All

Motorsport legends NASCAR announce an up...
NASCAR often gets a bad reputation outside of America, but there is a certain charm to it with its close side-by-side action and its focus on pure speed, but it never managed to really massively break out internationally. Now, there's a chance... | Read more »
Skullgirls Mobile Version 6.0 Update Rel...
I’ve been covering Marie’s upcoming release from Hidden Variable in Skullgirls Mobile (Free) for a while now across the announcement, gameplay | Read more »
Amanita Design Is Hosting a 20th Anniver...
Amanita Design is celebrating its 20th anniversary (wow I’m old!) with a massive discount across its catalogue on iOS, Android, and Steam for two weeks. The announcement mentions up to 85% off on the games, and it looks like the mobile games that... | Read more »
SwitchArcade Round-Up: ‘Operation Wolf R...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 21st, 2023. I got back from the Tokyo Game Show at 8 PM, got to the office here at 9:30 PM, and it is presently 11:30 PM. I’ve done what I can today, and I hope you enjoy... | Read more »
Massive “Dark Rebirth” Update Launches f...
It’s been a couple of months since we last checked in on Diablo Immortal and in that time the game has been doing what it’s been doing since its release in June of last year: Bringing out new seasons with new content and features. | Read more »
‘Samba De Amigo Party-To-Go’ Apple Arcad...
SEGA recently released Samba de Amigo: Party-To-Go () on Apple Arcade and Samba de Amigo: Party Central on Nintendo Switch worldwide as the first new entries in the series in ages. | Read more »
The “Clan of the Eagle” DLC Now Availabl...
Following the last paid DLC and free updates for the game, Playdigious just released a new DLC pack for Northgard ($5.99) on mobile. Today’s new DLC is the “Clan of the Eagle" pack that is available on both iOS and Android for $2.99. | Read more »
Let fly the birds of war as a new Clan d...
Name the most Norse bird you can think of, then give it a twist because Playdigious is introducing not the Raven clan, mostly because they already exist, but the Clan of the Eagle in Northgard’s latest DLC. If you find gathering resources a... | Read more »
Out Now: ‘Ghost Detective’, ‘Thunder Ray...
Each and every day new mobile games are hitting the App Store, and so each week we put together a big old list of all the best new releases of the past seven days. Back in the day the App Store would showcase the same games for a week, and then... | Read more »
Urban Open-World RPG ‘Project Mugen’ Fro...
Last month, NetEase Games revealed a new free to play open world RPG tentatively titled Project Mugen for mobile, PC, and consoles. I’ve liked the setting and aesthetic since its first trailer, and today’s new video has the Game Designer and... | Read more »

Price Scanner via MacPrices.net

Apple AirPods 2 with USB-C now in stock and o...
Amazon has Apple’s 2023 AirPods Pro with USB-C now in stock and on sale for $199.99 including free shipping. Their price is $50 off MSRP, and it’s currently the lowest price available for new AirPods... Read more
New low prices: Apple’s 15″ M2 MacBook Airs w...
Amazon has 15″ MacBook Airs with M2 CPUs and 512GB of storage in stock and on sale for $1249 shipped. That’s $250 off Apple’s MSRP, and it’s the lowest price available for these M2-powered MacBook... Read more
New low price: Clearance 16″ Apple MacBook Pr...
B&H Photo has clearance 16″ M1 Max MacBook Pros, 10-core CPU/32-core GPU/1TB SSD/Space Gray or Silver, in stock today for $2399 including free 1-2 day delivery to most US addresses. Their price... Read more
Switch to Red Pocket Mobile and get a new iPh...
Red Pocket Mobile has new Apple iPhone 15 and 15 Pro models on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide service using all the major... Read more
Apple continues to offer a $350 discount on 2...
Apple has Studio Display models available in their Certified Refurbished store for up to $350 off MSRP. Each display comes with Apple’s one-year warranty, with new glass and a case, and ships free.... Read more
Apple’s 16-inch MacBook Pros with M2 Pro CPUs...
Amazon is offering a $250 discount on new Apple 16-inch M2 Pro MacBook Pros for a limited time. Their prices are currently the lowest available for these models from any Apple retailer: – 16″ MacBook... Read more
Closeout Sale: Apple Watch Ultra with Green A...
Adorama haș the Apple Watch Ultra with a Green Alpine Loop on clearance sale for $699 including free shipping. Their price is $100 off original MSRP, and it’s the lowest price we’ve seen for an Apple... Read more
Use this promo code at Verizon to take $150 o...
Verizon is offering a $150 discount on cellular-capable Apple Watch Series 9 and Ultra 2 models for a limited time. Use code WATCH150 at checkout to take advantage of this offer. The fine print: “Up... Read more
New low price: Apple’s 10th generation iPads...
B&H Photo has the 10th generation 64GB WiFi iPad (Blue and Silver colors) in stock and on sale for $379 for a limited time. B&H’s price is $70 off Apple’s MSRP, and it’s the lowest price... Read more
14″ M1 Pro MacBook Pros still available at Ap...
Apple continues to stock Certified Refurbished standard-configuration 14″ MacBook Pros with M1 Pro CPUs for as much as $570 off original MSRP, with models available starting at $1539. Each model... Read more

Jobs Board

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
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Retail Key Holder- *Apple* Blossom Mall - Ba...
Retail Key Holder- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 03YM1 Job Area: Store: Sales and Support 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.