TweetFollow Us on Twitter

Screen I/O
Volume Number:9
Issue Number:2
Column Tag:C Workshop

Related Info: TextEdit Color QuickDraw

Three Subclasses for Screen Input/Output

Using existing TCL classes to solve the input/output problem

By Gerry H. Kenner, Magna, Utah

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

About the author

Gerry Kenner is a professional electrical and computer engineering consultant, university researcher and sometimes writer who specializes in image analysis systems for investigative scientists.

INTRODUCTION

While writing and debugging major commercial applications with THINK C 5.0, I have often needed to input test variables into the program or to do data printouts or bitmap dumps. In the DOS world the first two can be done fairly easily using printf and scanf library functions. Likewise, the cin and cout instructions used in C++ provide that language with considerable operational ease.

The third operation is more difficult to perform because it involves dumping the contents of bitmaps which have been drawn offscreen as well as others in which the bitmap has been modified with a CopyBits function call without being drawn anywhere.

My approach to creating these utilities was to make maximum use of existing TCL classes with the result that I was able to create the three classes presented in this article in less than two days. I had to write surprisingly little new code.

Nomenclature

A note about naming of classes. The prefix “C” is reserved for THINK Class Library (TCL) classes, i.e. CApplication, CObject, etc. The prefix “B” is used for user defined library classes. These are non-TCL classes which are used by more than one application. The following user library classes will be developed in this paper, BEditDoc, BEditPane, BBitMapDoc, BBitMapPane, BDisplayOutput, BGetTCLInfo and BUtilities.

Project specific classes are prefixed with two letters. My convention is to use upper case letters for major projects, while lower case and mixed letters are used for the smaller projects. As an example, the project name for this article was Dumps. Because of its limited scope, the project only needed one project specific class which was name duApp.

GENERAL

I decided that the classes would be easier to access if I called them indirectly using regular C function calls rather than directly with method calls from within objects. For this reason I created files named BUtilities.h and BUtilities.c containing the definitions and code for three functions named GetInfo, DumpData and OutputBitMap. These functions set up the objects for requesting input, dumping data and dumping bitmaps respectively.

Each function consisted of code for defining the object, initializing and then running it and then disposing of it when finished. For example, this is the code for GetInfo.

 theGetInfo = new BGetTCLInfo;
 theGetInfo->IBGetTCLInfo(DLOGinfo, gApplication);
 theGetInfo->GetInfo(promptPtr, returnPtr);
 theGetInfo->Dispose();

DLOGinfo was a constant with a value of 601 for identifying the DLOG resource used. Similar code was used for DumpData and OutputBitMap where the classes used were named BDisplayOutput and BBitMapDoc respectively. The exact calls can be determined from the method definitions given later in the paper. Note that required variable declarations and error checking code were omitted for brevity.

The functions are used by including the BUtilities.h file and then calling them wherever desired.

As an example of how to use the utility functions, take a copy of the THINK C Starter project and rename it Dumps. Make the appropriate changes in the file names and text, including changing the names of Starter and CStarterApp to Dumps and duApp respectively. Do whatever you like with CStarterDoc and CStarterPane as they will not be used. Remove all the code from the CreateDocument method. This will prevent unwanted windows from being opened. Increase the project memory allotment from 200 to 512k.

The utilities are accessed by overridding the CApplication Run method. The new Run method calls the three utility functions before calling the inherited Run method. A simplified version of the code is:

 GetInfo((char*)”A prompt string”, returnPtr);
 PtoCstr(returnPtr);
 textHdl = &returnPtr;
 DumpData(textHdl);
 OutputBitMap(&thePort->portBits);
 inherited::Run();

Don’t forget to allocate memory to textHdl and returnPtr. The bitmap for the screen is stored in thePort->portBits. I used it in this example because it is easy to access.

DATA INPUT CLASS

Description

This class is built using the TCL dialog classes to build and manage a diaog box with an OK button, a prompt string and an edit box for taking input.

The class is accessed by passing two parameters to the utility function call GetInfo. These parameters are a prompt string which identifies the information being requested and a char* to a buffer which is to receive the returned information.

GetInfo sets up and accesses an object of class BGetTCLInfo. This class was created as a subclass of CDLOGDirector which in turn is a subclass of CDialogDirector. The CDLOGDirector class provides the code for setting up a dialog box using DLOG/DITL resources created by a resource editor. This is done by creating an object of type CDLOGDialog in the initialization method. CDLOGDialog and its parent class CDialog have code which takes the description of a dialog box and its contained elements given in the DLOG/DITL resources and builds objects based thereon. The result is a regular window containing controls and text items which behaves like a modal dialog box but does not use the Dialog Manager functions of the Toolbox.

Objects of the CDialogDirector class have the code to manage dialog windows. In addition to functionality inherited from its ancester classes (CObject, CCollaborator, CBureaucrat, CDirectorOwner and CDirector), CDialogDirector has the following variable and methods for managing dialog windows.

Variable

long dismissCmd command that dismisses the dialog.

Methods

IDialogDirector Initialization method.

DoCommand Handles menu and control commands.

DoModalDialog Emulates ModalDialog toolbox function.

Validate Verifies window can be closed.

BeginDialog Sets up dialog box.

Close Closes dialog window.

EndDialog Disposes of dialog box.

DisableTheMenus Disables the menu bar.

EnableTheMenus Reenables the menu bar.

The first step for creating BGetTCLInfo was to use ResEdit to create a DLOG resource with its associated DITL resource both of which were designated as #601. The DITL resource consisted of a “OK#100” button (item #1) centered at the bottom, one line of static text at the top (item #3) with a large edit text box in between (item #2). The exact size and layout of the resource were determined by programmer tastes and requirements. The #100 associated with the word OK enables the CDlogDirector object to recognize when the button has been clicked on so that the dialog box can be closed.

The BGetTCLInfo class has one instance variable and three methods.

Instance Variable

Str255 fReturnStr Store input information.

Methods

IBGetTCLInfo Initialization method.

GetInfo Entry method.

DoCommand Response to button click.

The methods are defined as follows:

 void IBGetTCLInfo(short DLOGid, CDirectorOwner
 *aSupervisor);
 virtual void  GetInfo(char *promptPtr, char *returnPtr);
 virtual void  DoCommand(long theCommand);

fReturnStr is used to store the information input by the user. All the initialization method does is call the initialization method of the CDialogDirector class. For this it needs the number of the DLOG resource being used and the name of the objects Director Owner. The GetInfo method contains the code to manipulate the DITL items. The nucleus of this code is as follows.

 strcpy((char*)tempStr, promptPtr);
 CtoPstr((char*)tempStr);
 staticItem = (CDialogText*)itsWindow->FindViewByID(kPrompt);
 staticItem->SetTextString(tempStr);
 BeginDialog();
 theCommand = DoModalDialog(cmdOK);
 strcpy(returnPtr, &fReturnStr);

Character pointers to the prompt string and the return buffer are passed into GetInfo. The prompt string must be converted to a pascal string before it can be used. kPrompt is a constant whose value 3, cmdOK is defined as 100. returnPtr is used to return a copy of the data input to the calling function. The CWindow method FindViewByID locates the static text object which was created from DITL item #3 and assigns it to an instance pointer of type CAbstractText. Once the instance pointer has been identified it is a simple matter to send a SetTextString message to the program to insert the desired prompt string in the dialog box. The message BeginDialog of the CDialogDirector class then sets up the dialog box after which it is activated by calling DoModalDialog. cmdOK tells the program what value to use for breaking out of the DoModalDialog loop. Finally, the requested data is copied into the return buffer from fReturnStr.

The DoCommand method is where the program responds to the user interaction with the dialog box. Its essentials are as follows.

case cmdOK:
 theText = (CDialogText*)itsWindow->FindViewByID(kReturnStr);
 theText->GetTextString(fReturnStr);
 EndDialog(cmdOK, TRUE);
 break;

Once again the CWindow method FindViewByID is used to locate the dialog object created from the DLOG/DITL resources and assigns it to an instance pointer of type CDialogText. A call to the GetTextString method of the CDialogText class returns the input which the user entered via the keyboard. The EndDialog method of the CDialogDirector class is then called to dismiss the window and to clean up.

DATA OUTPUT CLASS

Description

A window is built which displays the contents of a handle pointing to text. Optimally, all editing operations including saving, printing, copying, pasting, etc. could be performed if the necessary menus were provided.

A handle pointing to the text which is to be displayed is passed to the object via the utility function called DumpData. DumpData creates, initializes and calls the operating code of an object of class BDisplayOutput. This handle is made the text handle of the text edit record. After this, almost everything is taken care of by the superclasses and the TextEdit Manager of the Macintosh Toolbox.

The class BDisplayOutput is based on the CEditDoc and CEditPane classes of THINK’s TinyEdit demo program. These two classes contain all the functionality necessary for creating simple edit programs. They have the code for creating or opening text files, saving, printing and performing the standard editing chores of copy, paste, etc. In addition, they can change fonts, sizes, styles alert the user to changes made in the text and permit the use of multiple windows.

Since I insist on reserving the C- prefix for the TCL classes, I took the liberty of changing the names of these classes to BEditDoc and BEditPane. I also changed the value of aLineWidth from 432 in the BEditPane initialization method to 600 to permit text across the full width of the screen. While doing so, I added the line “modified by Gerry Kenner” after the THINK copyright notices on the four files involved. All other changes had to do with changing the prefix CEdit- to BEdit- in the four files.

At this point, nearly all the work required to write a data dump method was complete. BDisplayOutput has the following instance variables and methods.

Instance variable

Boolean fQuitStatus Event management boolean.

Methods

IBDisplayOutput Initialization method.

BuildWindow Builds floating window.

EventManagement Event management loop.

DisplayRun Prepare data for output.

CloseWind Response to click in goaway box.

SetQuitStatus Access fQuitStatus.

GetQuitStatus Access fQuitStatus.

The definitions for these methods are the following.

 void IBDisplayOutput(CApplication *anApplication,
 Boolean printable); 
 virtual void  BuildWindow (Handle theData);
 virtual void  EventManagement(void);
 virtual void  DisplayRun(Handle theText);
 virtual void  CloseWind(CWindow *theWindow);
 virtual void  SetQuitStatus(Boolean status);
 virtual Boolean GetQuitStatus(void);

Once again, all the initialization method does is call the initialization method of its superclass. The BuildWindow method was changed to make the window float. The only change made in the BuildWindow method of the BEditDoc class was in the following line where the boolean aFloating, the second parameter, was set to TRUE to designate the window as floating.

 itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);

This change necessitated that the programs desktop class be of the CFWDesktop type. This was done by overriding the CApplication class method MakeDesktop and changing it to:

 gDesktop = new(CFWDesktop);
 ((CFWDesktop*)gDesktop)->IFWDesktop(this);

The window was made floating to prevent it being completely covered by another window which might be made the active window by an accidental click.

SetQuitStatus and GetQuitStatus were used to manipulate the boolean fQuitStatus. They were used in the EventManagement and DoCommand methods.

The code for the EventManagement method was:

 SetQuitStatus(FALSE);
 do
 {
 gApplication->itsSwitchboard->ProcessEvent();
 } while (GetQuitStatus() == FALSE);

This is a continuous loop as long as the boolean fQuitStatus is set to FALSE.

The CloseWind method contained the code for exiting the EventManagement method. It does this by calling the method SetQuitStatus with the boolean set to TRUE. It does not call the inherited CloseWind method because this disposed of the BEditDisplay object and window before the EventManagement method had been exited resulting in immediate program failure.

The final method was DisplayRun. Here is a simplified version of its code.

BuildWindow(0L);
itsWindow->Select();
tempLong = strlen(*theText);
SetHandleSize(theText, tempLong);
((BEditPane*)itsMainPane)->SetTextHandle(theText);
EventManagement();

These commands build and display the output window, determine the length of the text passed into DisplayRun as a parameter and then made this handle the text handle of the text edit record. Finally, the event manager is called.

BITMAP DUMP CLASS

Description

A window is created into which a bitmap can be drawn and displayed. The document controlling the window contains a pane which is a subclass of CBitMapPane. A pointer to a bitmap is passed to the BBitMapPane object as a parameter of utility function OutputBitMap.

BBitMapDoc is a subclass of BDisplayDoc which was created above for dumping data. While at first glance this appears to be a very ineffective way of doing things since all that will be used are the EventManagement, SetQuitStatus and GetQuitStatus methods, it is actually very efficient. This is because the only memory requirements for objects are the space requirements of the instance variables plus a little bit of overhead. On the other hand, the code files are read in once and then reused whenever required. In this case, using BDisplayDoc as a superclass only requires two bytes (the boolean fQuitStatus) more than using CDocument as a superclass would with no loss for redundant method code.

The class BBitMapDoc has three methods and no instance variables. The methods are:

IBBitMapDoc Initialization method. 
BuildWindow Build window.
OutputMap Entry method.

Here are the definitions of the methods.

 void   IBBitMapDoc(CApplication *aSupervisor,
 Boolean printable);
 virtual void    OutputMap(BitMap *theBitMap);
 virtual void    BuildWindow (Handle theData);

IBBitMapDoc just calls the initialization method of its superclass BDisplayDoc. BuildWindow was overridden to change the type of pane used from a text pane to a bitmap pane. The pertinent changes were as follows.

 tRect = screenBits.bounds;
 SetRect(&bounds, 0, 0, tRect.right, tRect.bottom - 38);
 SetLongRect(&bitMapRect, 0, 0, BITMAPWIDTH, BITMAPHEIGHT);

 theMainPane = new(BBitMapPane);
 itsMainPane = theMainPane;
 itsGopher = theMainPane;

 theMainPane->IBBitMapPane(theScrollPane, this,
 bounds.right - SBARSIZE, bounds.bottom - SBARSIZE,
 0, 0, sizELASTIC, sizELASTIC, &bitMapRect, 0L, TRUE);

The first two instructions establish the size of the bitmap window as the full size of the screen less the width of the menu bar and the drag bar. The third instruction sets the dimensions of the bitmap as 640x480 pixels which is fairly standard for image capture systems.

BBitMapPane is a subclass of the TCL library class CBitMapPane. CBitMapPane provides the code for drawing a bitmap in a pane. It has an instance variable named itsBitMap which is a pointer to an object of the CBitMap class. CBitMap is a class for working with bitmaps. It has methods for copying to and from the current port, setting transfer modes, determining bitmap boundaries and making preparations for drawing and cleaning up afterwards.

The method OutputMap takes care of arranging the bitmap for display on the screen. Its code follows:

 BuildWindow(0L);
 itsWindow->Select();
 ((BBitMapPane*)itsMainPane)->InstallBitMap(theBitMap);
 EventManagement();

This is the same as the DisplayRun method of BDisplayDoc except it passes the address of the bit map to a method of BBitMapPane.

BBitMapPane could have been dispensed with by putting some convoluted code in the OutputMap method and then using CBitMapPane directly. I preferred to create a subclass of CBitMapPane instead.

BBitMapPane has the usual dummy initialization method and a method named InstallBitMap which takes care of assigning the bitmap to the CBitMapPane object pointer itsBitMap. This is done as follows:

 theLongRect.top = theBitMap->bounds.top;
 theLongRect.left = theBitMap->bounds.left;
 theLongRect.bottom = theBitMap->bounds.bottom;
 theLongRect.right = theBitMap->bounds.right;

 CopyBits(theBitMap, itsBitMap->macBitMap,
 &theBitMap->bounds, &theBitMap->bounds, srcCopy, 0L);
 Prepare();
 itsBitMap->CopyFrom(&theLongRect, &theLongRect, 0L);

The first four instructions set up the rectangles. The CopyBits call puts the desired bitmap into the BitMapPanes bitmap. The Prepare call makes certain the dump window is the active window and the CopyFrom call copies the bitmap into the dump window where it is displayed.

FINAL REMARKS

I have been using these classes for some time and find that they work quite well. On occasion, they do crash the program and then I have to resort to other less convenient methods of doing my work.

The functions generally work when embedded within object oriented code. I have not been able to use them from functions (non-object oriented code) where a previous window existed which had not been created with object oriented code.

OutputBitMap appears to work with MacPaint type files even though they are 576 bits deep rather than 480 bits.

The complete code for this article is included as part of the MacTutor disk which can be obtained from MacTutor Mail Order House.

I can be reached on internet at ghkenner@cc.utah.edu.

I wish to thank David Kenner for helping with the development of these classes.

Listing: BUtilities.h

/******************************************************
 * BUtilities.h
 *
 * General utilities for use with THINK C with objects.
 * © copyright 1991, KSS Scientific Consultants
 * © copyright 1989, Symantecs Corporation.  Some parts
 *   of the code used in this section were derived
 *   from their programs.
 *
 *******************************************************/

#define _H_BUtilities

 // Input/output utilities

void  GetInfo(char *promptPtr, char *returnPtr);
void  DumpData(Handle theData);
void  DumpBitMap(BitMap *theBitMap);
Listing: BUtilities.c

/******************************************************
 * BUtilities.c
 *
 * General utilities for use with THINK C with objects.
 * © copyright 1991, KSS Scientific Consultants
 * © copyright 1989, Symantecs Corporation.  Some parts
 *   of the code used in this section were derived
 *   from their programs.
 *
 *******************************************************/

#include <CApplication.h>
#include "BBitMapDoc.h"
#include "BDisplayOutput.h"
#include "BGetTCLInfo.h"
#include "BUtilities.h"
#include <stdio.h>
#include <string.h>

#define DLOGinfo 601 // Resource ID for DLOG template

extern CApplication*gApplication;

/********************************************************
 * GetInfo()
 *
 * Get data input from the user.
 *
 ********************************************************/

void  GetInfo(char *promptPtr, char *returnPtr)
{
 BGetTCLInfo*theGetInfo;
 
 TRY
 {
 theGetInfo = new BGetTCLInfo;
 theGetInfo->IBGetTCLInfo(DLOGinfo, gApplication);
 theGetInfo->GetInfo(promptPtr, returnPtr);
 }
 CATCH
 {
 theGetInfo->Dispose();
 }
 ENDTRY;
 theGetInfo->Dispose();
}
/****************************************************
 * DumpData()
 *
 * Dump the results to an output window.
 *
 ****************************************************/

void DumpData(Handle theData)
{
 BDisplayOutput  *theOutput;
 
 theOutput = new BDisplayOutput;
 theOutput->IBDisplayOutput(gApplication, TRUE);
 theOutput->DisplayRun(theData);
 theOutput->Dispose();
}

/*****************************************************
 * DumpBitMap()
 *
 * Dump a bitmap to an output window.
 *
 *****************************************************/

void DumpBitMap(BitMap *theBitMap)
{
 BBitMapDoc *theBitMapDoc;
 
 TRY
 {
 theBitMapDoc = new BBitMapDoc;
 theBitMapDoc->IBBitMapDoc(gApplication, TRUE);
 theBitMapDoc->OutputMap(theBitMap);
 }
 CATCH
 {
 theBitMapDoc->Dispose();
 }
 ENDTRY;
 theBitMapDoc->Dispose();
}
Listing: BGetTCLInfo.h

/*******************************************************
 * BGetTCLInfo.h
 *
 * Dialog class which prompts user for information and then
 * return his input.
 *  
 * © copyright 1992, KSS Scientific Consultants.
 *
 *******************************************************/

#pragma once

#include <CDLOGDirector.h>

class BGetTCLInfo : public CDLOGDirector
{
private:
 Str255 fReturnStr;

public: 
 void IBGetTCLInfo(short DLOGid, CDirectorOwner 
 *aSupervisor);

 virtual void  GetInfo(char *promptPtr, char *returnPtr);
 
protected:
 virtual void  DoCommand(long theCommand);
};
Listing: BGetTCLInfo.c

/*******************************************************
 * BGetTCLInfo.c
 *
 * SUPERCLASS = CDLOGDirector
 *
 * Dialog class which prompts user for information and then
 * return his input.
 *  
 * © copyright 1991, KSS Scientific Consultants.
 *
 *******************************************************/

#include <CDialogText.h>
#include <CWindow.h>
#include <Commands.h>
#include <string.h>
#include "BGetTCLInfo.h"

enum  // dialog item IDs
{
 kReturnStr = 2,
 kPrompt
};

/*******************************************************
 * IBGetTCLInfo()
 *
 * Initialization method.
 *
 *******************************************************/

void BGetTCLInfo::IBGetTCLInfo(short DLOGid, CDirectorOwner 
 *aSupervisor)
{
 CDLOGDirector::IDLOGDirector(DLOGid, aSupervisor);
}

/******************************************************
 * DoCommand()
 *
 ******************************************************/

void BGetTCLInfo::DoCommand(long theCommand)
{
 CDialogText*theText;
 
 switch (theCommand)
 {
 case cmdOK:
 theText = 
 (CDialogText*)itsWindow->FindViewByID(kReturnStr);
 theText->GetTextString(fReturnStr);
 EndDialog(cmdOK, TRUE);
 break;

 default:
 inherited::DoCommand(theCommand);
 break;
 }
}

/*******************************************************
 * GetInfo()
 *
 * Entry method.
 *
 *******************************************************/

void BGetTCLInfo::GetInfo(char *promptPtr, char *returnPtr)
{
 long   theCommand;
 CDialogText*staticItem;
 Str255 tempStr;
 
 strcpy((char*)tempStr, promptPtr);
 CtoPstr((char*)tempStr);
 staticItem = (CDialogText*)itsWindow->FindViewByID(kPrompt);
 staticItem->SetTextString(tempStr);

 // show the dialog
 BeginDialog();
 
 theCommand = DoModalDialog(cmdOK);
 
 strcpy(returnPtr, (char*)fReturnStr);
}
Listing: BDisplayOutput.h

/*****************************************************
 * BDisplayOutput.h
 *
 * Display the contents of a Handle in a text screen.
 *
 * © copyright 1991, KSS Scientific Consultants.
 *
 ******************************************************/

#define _H_BDisplayOutput

#include "BEditDoc.h"

class BDisplayOutput : public BEditDoc
{
private:
 BooleanfQuitStatus;

public: 
 void IBDisplayOutput(CApplication *anApplication, 
 Boolean printable);
 
 virtual void  BuildWindow (Handle theData);
 virtual void  EventManagement(void);
 virtual void  DisplayRun(Handle theText);
 virtual void  CloseWind(CWindow *theWindow);

private:
 virtual void  SetQuitStatus(Boolean status);
 virtual Boolean GetQuitStatus(void);
};
Listing: BDisplayOutput.c

/******************************************************
 * BDisplayOutput.c
 *
 * SUPERCLASS = BEditDoc
 *
 * Display the contents of a Handle in a text screen.  It
 * requires a floating window desktop.
 * Window resource with id of 500 must be in resource file.
 *
 * © copyright 1991, KSS Scientific Consultants.
 *
 *****************************************************/

#include <CApplication.h>
#include <CBureaucrat.h>
#include <CScrollPane.h>
#include <CSwitchboard.h>
#include <CWindow.h>
#include <string.h>
#include "BDisplayOutput.h"
#include "BEditPane.h"

#define WINDculture500    // Res ID for WIND template

extern CApplication*gApplication;
extern CBureaucrat *gGopher;
extern CDesktop  *gDesktop; // The visible Desktop

/*******************************************************
 * IBDisplayOutput()
 *
 * Initialization method.
 *
 *******************************************************/
 
void BDisplayOutput::IBDisplayOutput(CApplication 
 *anApplication, Boolean printable)
{
 inherited::IEditDoc(anApplication, printable);
}

/********************************************************
 * BuildWindow
 *
 * Override BuildWindow so a floating window is created
 * and it is not positioned by the Decorator.
 *
 ********************************************************/

void BDisplayOutput::BuildWindow (Handle theData)

{
 CScrollPane*theScrollPane;
 BEditPane*theMainPane;
 Rect   margin;
 itsWindow = new(CWindow);
 itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);
 itsWindow->Move(40, 60);
 
 theScrollPane = new(CScrollPane);
 
 theScrollPane->IScrollPane(itsWindow, this, 10, 10, 0, 0,
 sizELASTIC, sizELASTIC, TRUE, TRUE, TRUE);

 theScrollPane->FitToEnclFrame(TRUE, TRUE);

 theMainPane = new(BEditPane);
 itsMainPane = theMainPane;
 itsGopher = theMainPane;

 theMainPane->IEditPane(theScrollPane, this);

 theScrollPane->InstallPanorama(theMainPane);

 if (theData)
 theMainPane->SetTextHandle(theData);
}

/**********************************************************
 * EventManagement()
 *
 * Event control loop
 *
 **********************************************************/

void BDisplayOutput::EventManagement(void)
{
 SetQuitStatus(FALSE);
 do
 {
 gApplication->itsSwitchboard->ProcessEvent();
 } while (GetQuitStatus() == FALSE);
}

/*******************************************************
 * DisplayRun()
 *
 * Entry method.
 *
 *******************************************************/
 
void BDisplayOutput::DisplayRun(Handle theText)
{
 long   tempLong;
 
 BuildWindow(0L);
 itsWindow->Select();

 tempLong = strlen(*theText);
 SetHandleSize(theText, tempLong);
 ((BEditPane*)itsMainPane)->SetTextHandle(theText);
 
 EventManagement();
}

/********************************************************
 * CloseWind()
 *
 * Add code to change QuitStatus to TRUE
 *
 ********************************************************/

void BDisplayOutput::CloseWind(CWindow *theWindow)
{
 SetQuitStatus(TRUE);
 
}

/*******************************************************
 * SetQuitStatus()
 *
 * Set or reset fQuitStatus.
 *
 *******************************************************/

void BDisplayOutput::SetQuitStatus(Boolean status)
{
 fQuitStatus = status;
}

/******************************************************
 * GetQuitStatus()
 *
 * Get the status fQuitStatus.
 *
 ******************************************************/

Boolean BDisplayOutput::GetQuitStatus(void)
{
 return (fQuitStatus);
}
Listing: BBitMapDoc.h

/********************************************************
 * BBitMapDoc.h
 *
 * Class for rapid dumping of a bitmap to a window.
 *
 * © copyright 1992, KSS Scientific Consultants
 *
 ********************************************************/

#pragma once

#include "BDisplayOutput.h"

class BBitMapDoc : public BDisplayOutput
{
public:
 void   IBBitMapDoc(CApplication *aSupervisor,
 Boolean printable);
 virtual void  OutputMap(BitMap *theBitMap);

protected:
 virtual void  BuildWindow (Handle theData);
};
Listing: BBitMapDoc.c

/********************************************************
 * BBitMapDoc.c
 *
 * SUPERCLASS = BDisplayOutput
 *
 * Class for rapid dumping of a bitmap to a window.
 *
 * © copyright 1992, KSS Scientific Consultants
 *
 ********************************************************/

#include <CDecorator.h>
#include <CDesktop.h>
#include <CScrollPane.h>
#include <CWindow.h>
#include <constants.h>
#include "BBitMapDoc.h"
#include "BBitMapPane.h"

#define WINDculture500    // Res ID for WIND template
#define BITMAPWIDTH640
#define BITMAPHEIGHT 480

extern CDecorator*gDecorator;
extern CDesktop  *gDesktop;

/*******************************************************
 * IBBitMapDoc()
 *
 * Initialization method
 *
 *******************************************************/

void BBitMapDoc::IBBitMapDoc(CApplication *aSupervisor, Boolean printable)
{
    inherited::IBDisplayOutput(aSupervisor, printable);
}

/********************************************************
 * BuildWindow
 *
 * Override BuildWindow so a floating window is created
 * and it is not positioned by the Decorator.
 *
 ********************************************************/

void BBitMapDoc::BuildWindow (Handle theData)

{
 CScrollPane*theScrollPane;
 BBitMapPane*theMainPane;
 Rect   bounds, tRect;
 LongRect bitMapRect;

 itsWindow = new(CWindow);
 itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);
 itsWindow->Move(40, 60);
 itsWindow->ChangeSize(screenBits.bounds.right,
 screenBits.bounds.bottom - 38);
 tRect = screenBits.bounds;
 SetRect(&bounds, 0, 0, tRect.right, tRect.bottom - 38);
 SetLongRect(&bitMapRect, 0, 0, BITMAPWIDTH, BITMAPHEIGHT);
 
 theScrollPane = new(CScrollPane);
 
 theScrollPane->IScrollPane(itsWindow, this, 10, 10, 0, 0,
 sizELASTIC, sizELASTIC, TRUE, TRUE, TRUE);
 theScrollPane->FitToEnclFrame(TRUE, TRUE);

 theMainPane = new(BBitMapPane);
 itsMainPane = theMainPane;
 itsGopher = theMainPane;

 theMainPane->IBBitMapPane(theScrollPane, this,
 bounds.right - SBARSIZE, bounds.bottom - SBARSIZE,
 0, 0, sizELASTIC, sizELASTIC, &bitMapRect, 0L, TRUE);

 theScrollPane->InstallPanorama(theMainPane);

 gDecorator->PlaceNewWindow(itsWindow);
}

/********************************************************
 * OutputMap()
 *
 * Initialize bitmap window and output bitmap.
 *
 *******************************************************/

void BBitMapDoc::OutputMap(BitMap *theBitMap)
{
 BuildWindow(0L);
 itsWindow->Select();
 
 ((BBitMapPane*)itsMainPane)->InstallBitMap(theBitMap);

 EventManagement();
}

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

coconutBattery 3.9.14 - Displays info ab...
With coconutBattery you're always aware of your current battery health. It shows you live information about your battery such as how often it was charged and how is the current maximum capacity in... Read more
Keynote 13.2 - Apple's presentation...
Easily create gorgeous presentations with the all-new Keynote, featuring powerful yet easy-to-use tools and dazzling effects that will make you a very hard act to follow. The Theme Chooser lets you... Read more
Apple Pages 13.2 - Apple's word pro...
Apple Pages is a powerful word processor that gives you everything you need to create documents that look beautiful. And read beautifully. It lets you work seamlessly between Mac and iOS devices, and... Read more
Numbers 13.2 - Apple's spreadsheet...
With Apple Numbers, sophisticated spreadsheets are just the start. The whole sheet is your canvas. Just add dramatic interactive charts, tables, and images that paint a revealing picture of your data... Read more
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

Latest Forum Discussions

See All

The iPhone 15 Episode – The TouchArcade...
After a 3 week hiatus The TouchArcade Show returns with another action-packed episode! Well, maybe not so much “action-packed" as it is “packed with talk about the iPhone 15 Pro". Eli, being in a time zone 3 hours ahead of me, as well as being smart... | Read more »
TouchArcade Game of the Week: ‘DERE Veng...
Developer Appsir Games have been putting out genre-defying titles on mobile (and other platforms) for a number of years now, and this week marks the release of their magnum opus DERE Vengeance which has been many years in the making. In fact, if the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for September 22nd, 2023. I’ve had a good night’s sleep, and though my body aches down to the last bit of sinew and meat, I’m at least thinking straight again. We’ve got a lot to look at... | Read more »
TGS 2023: Level-5 Celebrates 25 Years Wi...
Back when I first started covering the Tokyo Game Show for TouchArcade, prolific RPG producer Level-5 could always be counted on for a fairly big booth with a blend of mobile and console games on offer. At recent shows, the company’s presence has... | Read more »
TGS 2023: ‘Final Fantasy’ & ‘Dragon...
Square Enix usually has one of the bigger, more attention-grabbing booths at the Tokyo Game Show, and this year was no different in that sense. The line-ups to play pretty much anything there were among the lengthiest of the show, and there were... | Read more »
Valve Says To Not Expect a Faster Steam...
With the big 20% off discount for the Steam Deck available to celebrate Steam’s 20th anniversary, Valve had a good presence at TGS 2023 with interviews and more. | Read more »
‘Honkai Impact 3rd Part 2’ Revealed at T...
At TGS 2023, HoYoverse had a big presence with new trailers for the usual suspects, but I didn’t expect a big announcement for Honkai Impact 3rd (Free). | Read more »
‘Junkworld’ Is Out Now As This Week’s Ne...
Epic post-apocalyptic tower-defense experience Junkworld () from Ironhide Games is out now on Apple Arcade worldwide. We’ve been covering it for a while now, and even through its soft launches before, but it has returned as an Apple Arcade... | Read more »
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 »

Price Scanner via MacPrices.net

New low price: 13″ M2 MacBook Pro for $1049,...
Amazon has the Space Gray 13″ MacBook Pro with an Apple M2 CPU and 256GB of storage in stock and on sale today for $250 off MSRP. Their price is the lowest we’ve seen for this configuration from any... Read more
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

Jobs Board

Optometrist- *Apple* Valley, CA- Target Opt...
Optometrist- Apple Valley, CA- Target Optical Date: Sep 23, 2023 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 796045 At Target Read more
Senior *Apple* iOS CNO Developer (Onsite) -...
…Offense and Defense Experts (CODEX) is in need of smart, motivated and self-driven Apple iOS CNO Developers to join our team to solve real-time cyber challenges. Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Child Care Teacher - Glenda Drive/ *Apple* V...
Child Care Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Share on Facebook Apply Read more
Machine Operator 4 - *Apple* 2nd Shift - Bon...
Machine Operator 4 - Apple 2nd ShiftApply now " Apply now + Start apply with LinkedIn + Apply Now Start + Please wait Date:Sep 22, 2023 Location: Swedesboro, NJ, US, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.