TweetFollow Us on Twitter

MicroApp 2
Volume Number:6
Issue Number:1
Column Tag:Jörg's Folder

C++ Micro-application

By Jörg Langowski, MacTutor Editorial Board

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

“C++ micro-application, part 2”

We’ll expand the micro-application that I presented last month by adding more functionality to the windows this time. But first, let me review some discussions that started on our Calvacom bulletin board after my first introduction to C++. The way I defined my matrix operations, it seems, wasn’t totally in the C++ spirit; there was a reason for this, which I forgot to explain.

The problem is that our matrix operators must return a result somehow. If you define the operator the intuitive way:

// 1

matrix  matrix::operator* (matrix& a)
{
 if (cols != a.rows)
 error(“class matrix: size mismatch in *”);
 matrix c(rows,a.cols);
 for (register int i=0 ; i<rows; i++)
 for (register int j=0 ; j<a.cols; j++)
 {
 register float sum = 0;
 for (register int k=0 ; k<cols; k++)
 sum = sum + elem(i,k)*a.elem(k,j);
 c(i,j) = sum;
 }
 return c;
}

the result matrix is allocated locally first, the product computed and stored into the local object, and the whole matrix is copied as soon as it is assigned to another variable of type matrix- like in matrix x = a*b, where x is newly created in the assignment, or in x = a*b, where x has been defined previously. That the local object is destroyed as soon as one leaves the operator’s scope and a copy be made for use in the scope that called the operator is required by C++. But the copy operation may take a long time with big arrays, and in most cases it won’t be necessary because the result has already been computed and the memory allocated.

One solution - which I chose - was not to return an object as a result, but a reference to it:

//2

matrix& matrix::operator* (matrix& a)
{
 if (cols != a.rows)
 error(“class matrix: size mismatch in *”);
 matrix& c = *new matrix(rows,a.cols);
 for (register int i=0 ; i<rows; i++)
 for (register int j=0 ; j<a.cols; j++)
 {
 register float sum = 0;
 for (register int k=0 ; k<cols; k++)
 sum = sum + elem(i,k)*a.elem(k,j);
 c(i,j) = sum;
 }
 return c;
}

Here, the space for the result is allocated through the new() operation, which creates memory space that is not automatically destroyed as one leaves the operator’s context. Now, however, the system will never know when to free the space associated with the matrix, unless you tell it to do so by calling delete(). This precludes usage of those operators in any complex formulas, because intermediate results will be stored in matrix-type objects that are never accessible and can therefore never be deleted.

Alain Richard (on Calvacom) has raised these points, and others:

“ Constructors/destructors allow the use of data structures without having to care about initialization/ termination code. For instance, a first version of a class X might not need such code while the second version might need it; a program using class X can be recompiled without modification in both cases.

When a result of type matrix is produced, a 500*500 matrix is not passed back through the stack; only the data structure which defines it and contains a pointer to the data. The only problem is that the constructor will often copy the data unnecessarily; but the current definition of C++ doesn’t allow a better solution.”

Alain proposes to use procedures instead of operators for functions in which the programmer has to clean up intermediate results explicitly. One possibility, but this gives up the last advantage of operators, shortness of notation.

He has some more comments on bugs and deficiencies:

“ In C++, the only way to pass a result is through the return statement, even though the result is a function parameter. However, since one doesn’t know its name, one has to go through an intermediate variable R and then copy R into the actual result.

One should also note that the code that CFront generates isn’t very well optimized (a euphemism), or that the preprocessor relies too much on the efficiency of the C compiler, in our case MPW C 3.1b1. Some observations I made in the code generated by CFront:

CFront doesn’t optimize the use of intermediate variables and creates them for each new expression. Then, these variables are freed only at the end of the block containing the expression, which is stupid because it blocks memory.

A lot of dead code is generated by CFront. Usually, such code should be removed by the C compiler, but that is unfortunately not the case. For instance:

//3

struct A { A() {} };

struct B:A { B() {} };

main()
{
 B b;
}

The declaration of b causes 30 lines of assembler code to be generated which don’t do anything [in fact, when I checked it there seemed to be even more dead code - JL].

For the maintenance of virtual methods of a class A, CFront creates a method dispatch table. The table, named __A_vtbl, is stored together with the application code. In addition, CFront creates a global variable __A_ptbl, a pointer to __A_vtbl. This global is later used to initialize a hidden instance of each variable of type A. __A_vtbl and __A_ptbl are stored as globals, which prohibits the use of classes for DAs, CDEFs, LDEFs, etc.

I have found one or two bugs: it is not always possible to declare a variable inside an expression (produces a syntax error). There is also a problem with pointers to base class member functions in the case of multiple inheritance. That error is easy to circumvent but causes a run time, not a compilation error.

This is not an exhaustive list, but unfortunately shows that the MPW compilers are not quite mature yet. But even with the bad code quality, CFront does at least exist. At any rate, C++ is going to be the most important development language for the next years.”

I almost agree with the last statement - however, I am also getting very curious about Eiffel, a new OOP-language which is rumored to be available for the Mac next year.

Zoom, grow and scroll for MacTutorApp

The skeleton application that I presented last month did not do much; the window could not be resized or zoomed, and there were no controls such as scroll bars present. This month we’ll expand the application by adding these functions. We’ll use the definitions that we made last time, and create a new subclass of MacTutorDocument, MacTutorGrow.

The interest of the object-oriented approach is, of course, that we can reuse most of the code that we have already defined in the previous example. Only those functions which are specific to our new document will have to be redefined.

Placeholders for these functions exist already in the TDocument class definition, which is part of the C++ examples that come with Apple’s C++ system. That definition is quite long, an we don’t need to reprint it here; all I show (listing 1) is the header file that constitutes the interface. You see that entries exist for methods such as DoContent, DoGrow and DoZoom. These methods will be called from the main event loop, so if you define your own document class with a non-empty DoContent method and a mouse click occurs inside the content region of the document window, that method will be called automatically.

Therefore, the changes we have to do to previous month’s example are quite simple: the main program will still be an object of type TMacTutorApp, but the document opened will be of a new class, which we call TMacTutorGrow. Then we only have to change a few lines in the main program definition of TMacTutorApp, as you see in listing 3. If someone had already defined a document class for us that handles scrolling and resizing, that is all we would have to do to make the application work with that new type of document window.

Unfortunately, we still have to do that work, and I won’t claim I did a perfect job of scrolling the display message around in the example window; window resizing and drawing of the controls works OK, but the scrolling still leaves something to be desired. Only when the window actually gets redrawn on an update event is the contents displayed correctly. You’re, of course, invited to improve on my example.

Listing 2 shows the definition of the TMacTutorGrow class - the header file - followed by the actual code. We derive TMacTutorGrow from TMacTutorDocument (see last column), adding some private variables and methods, and overriding some of the public methods in TDocument.

The first thing to note is that we define some functions that are not methods of any particular class for scroll bar handling (this is the approach Apple took for its TEDocument example). To indicate to the compiler that these functions are defined in C, their prototype definitions are enclosed in curly brackets and prefixed by extern “C”. This is a feature of the 2.0 implementation of C++ and not mentioned in Stroustrup’s book.

The class implementation follows, first we need to define the constructor and destructor. The constructor of a subclass is called after the constructor of its ancestor; therefore all that is left to do is to get the scroll bar resources, insert the controls into the window, and initialize their values. The display string (our document’s “contents”) is passed on to the ancestor’s constructor. The destructor will dispose the controls; disposing of the window is taken care of by the superclass.

For the DoUpdate method, we replicate the definition from the TMacTutorDocument class, because our DrawWindow method has changed. In this case, the display string and the controls are redrawn. I had to change the fDisplayString variable from the TMacTutorDocument class from private to protected, so that the derived class could access it. The other possibility would have been to go through the interface that I provided and use the method GetDisplayString.

The DoActivate method invalidates the control and grow rectangles when the window is activated, so that they get redrawn on the next update event. On deactivation, the controls are hidden.

Several methods are provided for redrawing the scroll bars in their correct position; they are needed by the DoGrow and DoZoom methods. The main work is done by the routine AdjustScrollSizes, which calculates the control positions from the port rectangle of the window and moves the controls into their places. AdjustScrollValues simply resets the controls to their initial values; in a real-world application, one would insert code here that calculates the correct maximum, minimum and control settings from the properties of the window’s contents (e.g. number of lines in a text, size of a picture).

DoZoom zooms the window, then repositions the scroll bars and invalidates all of the window’s contents except for the control rectangles. The update event will then take care of redrawing. DoGrow works in the same way, only the update region is calculated through an intersection of the old and the new window’s port rectangles, the standard method that’s already been described in IM Vol.I.

DoContent is where scrolling is handled. I implemented scrolling through a call to ScrollRect and a resetting of the origin of the GrafPort. This means that the controls have to be repositioned after the scrolling, otherwise they are redrawn outside the window (the SetOrigin made them scroll with the rest of the contents). Therefore, a call to AdjustScrollSizes() is made after the control value has changed and the window has been scrolled.

The thumb region and up/down arrows with page regions are handled separately; for the thumb region, the window adjustment can be made after the control has been released, while the arrows and page fields have to respond continuously while the mouse button is down. This is done through a control action procedure, which is defined as an external routine and not a class method. (This is the way Apple implemented it in their example; I don’t know whether a pointer to a class method can be passed as a filter procedure to a toolbox routine). The control action routines, whose prototypes had been defined at the start of the program, are implemented at the end of listing 2.

There are certainly a few bugs left in my example, and the scrolling leaves much to be desired but take this as a challenge for improving the example. We’ll expand this application with other features as we proceed in our tutorials. Until then.

Listing 1:  Apple’s TDocument class standard definitions

class TDocument : HandleObject {
protected:
 WindowPtr fDocWindow;

public:
 TDocument(short resID);  virtual ~TDocument();
 // you will need to override these in your subclasses,
 // since they are do-nothing routines by default...
 virtual void DoZoom(short partCode) {}
 virtual void DoGrow(EventRecord* theEvent) {}
 virtual void DoContent(EventRecord* theEvent) {}
 virtual void DoKeyDown(EventRecord* theEvent) {}
 virtual void DoActivate(Boolean becomingActive) {}
 virtual void DoUpdate(void) {}
 // file handling routines
 virtual void DoOpen(void) {};
 virtual void DoClose(void) { delete this; };
 // by default, we just delete ourself 
 // & let destructor do cleanup
 virtual void DoSave(void) {};
 virtual void DoSaveAs(void) {};
 virtual void DoRevert(void) {};
 virtual void DoPrint(void) {};
 // do standard edit menu actions
 virtual void DoUndo(void) {};
 virtual void DoCut(void) {};
 virtual void DoCopy(void) {};
 virtual void DoPaste(void) {};
 virtual void DoClear(void) {};
 virtual void DoSelectAll(void) {};

 // idle time routines: 
 // you can use these to do cursor handling,
 // TE caret blinking, marquee effects, etc...
 virtual void DoIdle(void) {};
 virtual unsigned long CalcIdle(void) 
 { return kMaxSleepTime; };
 // by default, we don’t need idle
 virtual void AdjustCursor(Point where) {};
 // where is in local coords

 // query state of document - 
 // useful for adjusting menu state
 virtual Boolean HaveUndo(void) { return false; };
 virtual Boolean HaveSelection(void) { return false; };
 virtual Boolean HavePaste(void) { return false; };
 virtual Boolean CanClose(void) { return true; };
 virtual Boolean CanSave(void) { return false; };
 virtual Boolean CanSaveAs(void) { return true; };
 virtual Boolean CanRevert(void) { return false; };
 virtual Boolean CanPrint(void) { return false; };

 // utility routine to get window pointer for document
 inline WindowPtr GetDocWindow(void) 
 { return fDocWindow; }
};
Listing 2: Our MacTutorGrow class, overriding some of TDocument’s methods

// MacTutorGrow definitions
// subclass of MacTutorDocument that adds 
// scroll, grow and zoom

#define rVScroll 128 /* vertical scrollbar control */
#define rHScroll 129 /* horizontal scrollbar control*/
class TMacTutorGrow : public TMacTutorDocument {
 
  private:
 ControlHandle fDocVScroll; // vertical scrollbar
 ControlHandle fDocHScroll; // horizontal scrollbar
 void AdjustViewRect(void);
 void ResizeWindow(void);
 void AdjustScrollSizes(void);
 void AdjustScrollbars(Boolean needsResize);
 void AdjustScrollValues(Boolean mustRedraw);
 void DrawWindow(void);
 
  public:
 TMacTutorGrow(short resID,StringPtr s);
 ~TMacTutorGrow(void);
 // new methods, override previous ones
 void DoZoom(short partCode);
 void DoGrow(EventRecord* theEvent);
 void DoContent(EventRecord* theEvent);
 void DoUpdate(void);
 void DoActivate(Boolean becomingActive);
};

#include <Types.h>
#include <QuickDraw.h>
#include <Fonts.h>
#include <Events.h>
#include <OSEvents.h>
#include <Controls.h>
#include <Windows.h>
#include <Menus.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Desk.h>
#include <Scrap.h>
#include <ToolUtils.h>
#include <Memory.h>
#include <SegLoad.h>
#include <Files.h>
#include <OSUtils.h>
#include <Traps.h>
#include <StdLib.h>

#include “TDocument.h”
#include “TApplication.h”
#include “MacTutorApp.h”
#include “MacTutorDoc.h”
#include “MacTutorGrow.h”

// consts for scroll bar and grow box size adjustment
const short kScrollbarAdjust = 15;
const short kGrowboxAdjust = 15;
const short kScrollbarWidth = 16;
const short kScrollTweek = 2;
const short kControlVisible = 0xFF;

extern “C” { 
 // prototypes for functions outside of classes
 void CommonAction (ControlHandle control,
 short* amount);
 pascal void VActionProc(ControlHandle control,
 short part);
 pascal void HActionProc(ControlHandle control,
 short part);
};

// methods for the MacTutorGrow class

// create and delete document windows
// override methods from MacTutorDocument
// The base class creates the window and 
// sets the display string.
// We try to get the controls, and display an error if we can’t
//
TMacTutorGrow::TMacTutorGrow
 (short resID, StringPtr s) : (resID,s)
{
 Boolean good;
 fDocVScroll = GetNewControl(rVScroll, fDocWindow);
 good = (fDocVScroll != nil);
 if ( good)
   {
 fDocHScroll = GetNewControl (rHScroll, fDocWindow);
 good = (fDocHScroll != nil);
   }
 if ( good )// good? -- set & draw the controls
   {
 AdjustScrollValues(true);
   }
 else
   {
 // tell user we failed
 HideWindow(fDocWindow);
 AlertUser(kErrStrings,eNoWindow); 
   }
}

TMacTutorGrow::~TMacTutorGrow(void)
{
 HideWindow(fDocWindow);
 if ( fDocVScroll != nil )
   DisposeControl(fDocVScroll);
 if ( fDocHScroll != nil )
   DisposeControl(fDocHScroll);
}

void TMacTutorGrow::DoUpdate(void)
{

 BeginUpdate(fDocWindow);
 if ( ! EmptyRgn(fDocWindow->visRgn) ) 
   DrawWindow();
 EndUpdate(fDocWindow);
}

void TMacTutorGrow::DrawWindow(void)
{
 Rect tRect;
 SetPort(fDocWindow);
 tRect = fDocWindow->portRect;
 tRect.bottom = tRect.bottom - kScrollbarAdjust;
 tRect.right = tRect.right - kScrollbarAdjust;
 EraseRect(&tRect);
 
 MoveTo(100,100);
 TextSize(18); TextFont(monaco);
 DrawString(fDisplayString);
 DrawControls(fDocWindow);
 DrawGrowIcon(fDocWindow);

} // DrawWindow

void TMacTutorGrow::DoActivate
 (Boolean becomingActive)
{
 if ( becomingActive )
   {
 Rect growRect;
 Rect tRect;

 /* the controls must be redrawn on activation: */
 (*fDocVScroll)->contrlVis = kControlVisible;
 (*fDocHScroll)->contrlVis = kControlVisible;
 // copy rectangles to avoid 
 // unsafe object field references!
 tRect = (*fDocVScroll)->contrlRect; 
 InvalRect(&tRect);
 tRect = (*fDocHScroll)->contrlRect; 
 InvalRect(&tRect);
 // the growbox needs to be redrawn on activation:
 growRect = fDocWindow->portRect;
 // adjust for the scrollbars
 growRect.top = growRect.bottom - kScrollbarAdjust;
 growRect.left = growRect.right - kScrollbarAdjust;
 InvalRect(&growRect);
   }
 else
   {    
 /* the controls must be hidden on deactivation: */
 HideControl(fDocVScroll);
 HideControl(fDocHScroll);
 // we draw grow icon immediately, 
 // since we deactivate controls
 // immediately, and the update delay looks funny
 DrawGrowIcon(fDocWindow);
   }
}

void TMacTutorGrow::AdjustScrollSizes(void)
{
 MoveControl(fDocVScroll, 
 fDocWindow->portRect.right - kScrollbarAdjust, 
 fDocWindow->portRect.top);
 SizeControl(fDocVScroll, kScrollbarWidth,
 fDocWindow->portRect.bottom - 
 fDocWindow->portRect.top -
 kGrowboxAdjust + kScrollTweek);
 MoveControl(fDocHScroll, 
 fDocWindow->portRect.left, fDocWindow->portRect.bottom - kScrollbarAdjust);
 SizeControl(fDocHScroll,
 fDocWindow->portRect.right - 
 fDocWindow->portRect.left -
 kGrowboxAdjust + kScrollTweek,
 kScrollbarWidth);
} // AdjustScrollSizes

void TMacTutorGrow::AdjustScrollbars
 (Boolean needsResize)
{
 (*fDocVScroll)->contrlVis = 0;
 (*fDocHScroll)->contrlVis = 0;
 if ( needsResize )  AdjustScrollSizes();
 AdjustScrollValues(needsResize);
 (*fDocVScroll)->contrlVis = 0xff;
 (*fDocHScroll)->contrlVis = 0xff;
} // AdjustScrollbars 

void TMacTutorGrow::AdjustScrollValues
 (Boolean mustRedraw)
// always reset the controls to the same values. In reality,
// you would calculate reasonable control values here 
// from the contents of your document
{
 SetCtlMin(fDocVScroll,0);
 SetCtlMax(fDocVScroll,1000);
 SetCtlValue(fDocVScroll,500);
 SetCtlMin(fDocHScroll,0);
 SetCtlMax(fDocHScroll,1000);
 SetCtlValue(fDocHScroll,500);
 if ( mustRedraw )
 {
 ShowControl(fDocVScroll);
 ShowControl(fDocHScroll);
 }
} // AdjustScrollValues

void TMacTutorGrow::DoZoom(short partCode)
{
 Rect tRect;

 tRect = fDocWindow->portRect;
 EraseRect(&tRect);
 ZoomWindow(fDocWindow, partCode, 
 fDocWindow == FrontWindow());
 AdjustScrollbars(true);  // adjust, redraw anyway 
 InvalRect(&tRect);// invalidate the whole content 
 // revalidate scroll bars 
 tRect = (*fDocVScroll)->contrlRect;
 ValidRect(&tRect);
 tRect = (*fDocHScroll)->contrlRect;
 ValidRect(&tRect);
}

void TMacTutorGrow::DoGrow(EventRecord* theEvent)
{
 long growResult;
 Rect tRect, tRect2;
 
 tRect = qd.screenBits.bounds;
 tRect.left = kMinDocDim;
 tRect.top = kMinDocDim;
 tRect2 = fDocWindow->portRect;
 tRect2.bottom = tRect2.bottom - kScrollbarAdjust;
 tRect2.right = tRect2.right - kScrollbarAdjust;
 growResult = GrowWindow
 (fDocWindow, theEvent->where, &tRect);
 // see if it really changed size 
 if ( growResult != 0 )
   {
 SizeWindow (fDocWindow, 
 LoWrd(growResult), HiWrd(growResult), true);
 AdjustScrollbars(true);
 // calculate & validate the region 
 // that hasn’t changed so it won’t get redrawn
 // Note: we copy rectangles so that we don’t 
 // take address of object fields.
 tRect = fDocWindow->portRect; 
 (void) SectRect(&tRect, &tRect2, &tRect2);
 InvalRect(&tRect); ValidRect(&tRect2);
 tRect2 = (*fDocVScroll)->contrlRect;
 ValidRect(&tRect2);
 tRect2 = (*fDocHScroll)->contrlRect; 
 ValidRect(&tRect2);
 // redraw grow icon
 tRect.top = tRect.bottom - kScrollbarAdjust;
 tRect.left = tRect.right - kScrollbarAdjust;
 InvalRect(&tRect);
   }
}

void TMacTutorGrow::DoContent(EventRecord* theEvent)
{
 Point mouse;
 ControlHandle control;
 short part, value;
 Rect tRect;
 
 SetPort(fDocWindow);
 mouse = theEvent->where;
 GlobalToLocal(&mouse);
 
 tRect = fDocWindow->portRect; 
 tRect.bottom = tRect.bottom - kScrollbarAdjust;
 tRect.right = tRect.right - kScrollbarAdjust;
 part = FindControl(mouse, fDocWindow, &control);
 switch ( part )
 {
 case 0: break;
 case inThumb:
 value = GetCtlValue(control);
 part = TrackControl(control, mouse, nil);
 if ( part != 0 )
 {
 value -= GetCtlValue(control);
 // value now has CHANGE in value; 
 // if value changed, scroll 
 if ( value != 0 )
 {
 if ( control == fDocVScroll )
 {
   ScrollRect (&tRect, 0, value, nil);
   SetOrigin (tRect.left,tRect.top-value);
 }
 else 
 {
   ScrollRect (&tRect, value, 0, nil);
   SetOrigin (tRect.left-value,tRect.top);
 }
 AdjustScrollSizes();
 }
 }
 break; 
 default: // clicked in an arrow, so track & scroll 
 if ( control == fDocVScroll )
 value = TrackControl
 (control, mouse, (ProcPtr) VActionProc);
 else value = TrackControl
 (control, mouse, (ProcPtr) HActionProc);
 AdjustScrollSizes();
 break;
 }
}

// routines that do not belong to any particular class. 

// Common algorithm for changing the value of a control. 
// It returns the value by which the control changed.

void CommonAction(ControlHandle control,short* amount)
{
 short value, max;
 
 value = GetCtlValue(control);
 max = GetCtlMax(control);
 *amount = value - *amount;
 if ( *amount <= 0 ) *amount = 0;
 else if ( *amount >= max ) *amount = max;
 SetCtlValue(control, *amount);
 *amount = value - *amount;
} // CommonAction 

pascal void VActionProc(ControlHandle control,short part)
{
 short  amount;
 WindowPtrwindow;
 Rect tRect;

 if ( part != 0 )
   {
 window = (*control)->contrlOwner;
 tRect = window->portRect; 
 tRect.bottom = tRect.bottom - kScrollbarAdjust;
 tRect.right = tRect.right - kScrollbarAdjust;
 switch ( part )
   {
 case inUpButton:
 case inDownButton:  // 5 pixels
 amount = 5;
 break;
 case inPageUp:  // 50 pixels
 case inPageDown:
 amount = 50;
 break;
   }
 if ((part == inDownButton) || (part == inPageDown))
 amount = -amount;  // reverse direction 
 CommonAction(control, &amount);
 if ( amount != 0 )
 {
 ScrollRect (&tRect, 0, amount, nil);
 SetOrigin(tRect.left,tRect.top-amount);
 }
   }
} // VActionProc 

pascal void HActionProc(ControlHandle control,short part)
{
 short  amount;
 WindowPtrwindow;
 Rect tRect;

 if ( part != 0 )
   {
 window = (*control)->contrlOwner;
 tRect = window->portRect; 
 tRect.bottom = tRect.bottom - kScrollbarAdjust;
 tRect.right = tRect.right - kScrollbarAdjust;
 switch ( part )
   {
 case inUpButton:
 case inDownButton:  // 5 pixels
 amount = 5;
 break;
 case inPageUp:  // 50 pixels
 case inPageDown:
 amount = 50;
 break;
   }
 if ((part == inDownButton) || (part == inPageDown))
 amount = -amount;  // reverse direction 
 CommonAction(control, &amount);
 if ( amount != 0 )
 {
 ScrollRect (&tRect, amount, 0, nil);
 SetOrigin(tRect.left-amount,tRect.top);
 }
   }
} // HActionProc 
Listing 3:  Adjustments to the MacTutorApp.cp and MacTutorApp.r files

Changes in MacTutorApp.cp:

#include “MacTutorGrow.h” 
 // insert behind the other #includes

// change the definition of the main() routine:
TMacTutorApp *gTheApplication;
int main(void)
{
 gTheApplication = new TMacTutorApp;
 if (gTheApplication == nil)return 0;
 gTheApplication->EventLoop();
 return 0;
}

// insert the following definitions to MacTutorApp.r:

#define kErrStrings 129
#define eNoMemory1
#define eNoWindow2

resource ‘CNTL’ (rVScroll, preload, purgeable) {
 {-1, 385, 236, 401},
 0, visible, 0, 0, scrollBarProc, 0, “” };

resource ‘CNTL’ (rHScroll, preload, purgeable) {
 {235, -1, 251, 386},
 0, visible, 0, 0, scrollBarProc, 0, “” };

// change the WIND definition:

resource ‘WIND’ (rDocWindow, preload, purgeable) {
 {64, 60, 314, 460},
 zoomDocProc, invisible, goAway, 0x0, 
 “MacTutor C++ demo” };

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance 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
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and 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
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
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.