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

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.