This appendix lists the sample code referred to in the preceeding chapters of this book. The subdirectories in \PENPOINT\SOK\SAMPLE contain the complete source files for these and other sample programs .
. The sample code for these applications is listed in this appendix:
Empty App The most simple application you can create.
Hello World (Toolkit) A simple Hello World application that uses the VI Toolkit.
Hello World (Custom Wmdow) A simple Hello World application that uses the Image Point graphics subsystem.
Counter Application A simple application that saves and restores its data.
Tic-Tac-Toe A fully featured PenPoint application.
Template Application A template for a fully-featured PenPoint application.
This appendix describes, but does not list, the sample code for:
Adder A simple pen-centric calculator, limited to addition and subtraction Calculator A floating, button~operated calculator.
Clock A digital alarm clock accessory.
Notepaper App A notetaking application that uses the NotePaper DLL.
Paint A simple raster painting program.
Toolkit Demo Shows how to use many of the classes in the VI toolkit.
Input Application Demonstrates pen-based input event handling.
Writer Application Demonstrates handwriting translation.
Basic Service Contains the absolute minimum code required for a service.
Test Service Provides a starter kit for most service writers.
MIL Service Provides a starter kit for device driver writers.
Hello World (f oolkit) 180 Hello World
(Custom Wmdow) 187 Counter Application 195 Tic-T ac-Toe 204
Template Application 251 Adder 260
Calculator 261
Notepaper App 265 Paint 266
Toolkit Demo 267 Inputapp 269 Writerap ·271 Basic Service 272 Test Service 272 MIL Service 273
Empty Application
Empty Application is the simplest sample application distributed with the PenPoint Software Developer's Kit. It does not have a view or any data. The only behavior it adds to the default PenPoint application is to print out a debugging message when the application is destroyed.
To provide this behavior, EmptyApp defines clsEmptyApp, which inherits from clsApp. In its handler for msgDestroy, clsEmptyApp prints out a simple debugging message.
clsEmptyApp inherits a rich set of default functionality from clsApp. When using EmptyApp, you can create, open, float, zoom, close, rename, embed, and destroy EmptyApp documents.
I
SAMPLE CODEObiectives
EmptyApp is used in the Application Writing Guide to show how to compile, install, and run applications.
This sample application also shows how to:
• Use Debugf and #ifdefDEBUG/#endif pairs
• Turn on message tracing for a class
• Let the PenPoint Application Framework provide default behavior.
Class Overview
Empty Application defines one class: clsEmptyApp. It makes use of the following classes:
clsApp clsAppMgr
Compiling
To compile EmptyApp, just cd \penpoint\sdk\sample\emptyapp wmake
I
This compiles the application and creates EMPTYAPP.EXE in - \PENPOINT\APP\EMPTYAPP.I
RunningI
After compiling EmptyApp, you can run it by
1 Adding \\boot\penpoint\app\Empty Application to
\PENPOINT\BOOT\APP .INI 2 Booting PenPoint
3 Creating a new Empty Application document, and turning to it.
Alternatively, you can boot PenPoint and then install Empty Application through the Connections Notebook.
files Used
The code for Empty Application is in \PENPOINT\SDK\SAMPLE\EMPTYAPP.
The files are:
EMPTY APPLICATION :::;
...
EMPlYAPP.C the application class's code and initialization.
METHODS.TBL the list of messages that the application class responds to, and the associated message handlers to call
METHODS. TIL
1****************************************************************************
File: methods.tbl
Copyright 1990-1992 GO Corporation. All Rights Reserved.
You may use this Sample Code any way you please provided you do not resell the code and that this notice (including the above copyright notice) is reproduced on all copies. THIS SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, AND GO CORPORATION EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING BUT NOT
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL GO CORPORATION BE LIABLE TO YOU FOR ANY CONSEQUENTIAL,INCIDENTAL,OR INDIRECT DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SAMPLE CODE.
$Revision: 1.0 $
$Date: 07 Jan 1992 16:37:36 $
classes.tbl contains the method table for clsEmptyApp.
****************************************************************************1
#ifndef CLSMGR_INCLUDED
#include <clsmgr.h>
#endif
MSG_INFO clsEmptyAppMethods []
#ifdef DEBUG
CLASS_INFO classlnfo[] =
"clsEmptyAppTable",
Copyright 1990-1992 GO Corporation. All Rights Reserved.
You may use this Sample Code any way you please provided you do not resell the code and that this notice (including the above copyright notice) is reproduced on all copies. THIS SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, AND GO CORPORATION EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING BUT NOT
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL GO CORPORATION BE LIABLE TO YOU
FOR ANY CONSEQUENTIAL, INCIDENTAL, OR INDIRECT DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SAMPLE CODE.
$Revision: 1.2 $
$Date: 07 Jan 1992 16:37:22 $
This file contains just about the simplest possible application.
It does not have a window.
in \penpoint\boot\environ.ini), then messages to clsEmptyApp will be traced.
***************************************************************************1 Hfndef APP .INCLUDED
#include <app.h>
#endif
#ifndef DEBUG INCLUDED
#include <debug.h>
#endif
#ifndef APPMGR INCLUDED
#include <appmgr.h>
#endif
#include <methods.h>
#include <string.h>
II for application messages (and clsmgr.h)
II for debugging statements.
II for AppMgr startup stuff STATUS EXPORTED EmptyAppInit (void);
*define clsEmptyApp wknGDTa
1* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Ufdef DEBUG
MsgHandlerParametersNoWarning; II suppress compiler warnings } 1* EmptyAppDestroy *1 new.appMgr.flags.accessory = true;
strcpy (new.appMgr. company, "GO Corporation");
strcpy(new.appMgr.defaultDocName, "Empty App Document");
ObjCaIIJmp(msgNew, clsAppMgr, &new, s, Error);
II
II Turn on message tracing if flag is set.
II
if (DbgFlagGet ('F', OxlL)) (
Debugf("Turning on message tracing for clsEmptyApp");
(void) ObjCallWarn (msgTrace, clsEmptyApp, (P_ARGS) true);
I
SAMPLE CODEDbg (Debugf ("main: starting emptyapp.exe [%d]", processCount);) if (processCount == 0) (
}
II Create application class.
ClsEmptyApplnit();
I I Invoke app monitor to install this application.
AppMonitorMain(clsEmptyApp, objNull);
else (
II Create an application instance and dispatch messages.
AppMain();
II Suppress compiler's "unused parameter" warnings Unused(argc); Unused(argv);
*
$Date: 07 Jan 1992 16:37:30 $* *****,*******************************,*********
*
Set PENPOINT_PATH to your environment variable, if it exists.*
Otherwise, set it to \penpoint!ifdef %PENPOINT PATH
PENPOINT_PATH = $(%PENPOINT_PATH)
!else
PENPOINT PATH = \penpoint
!endif
*
The DOS name of your project directory PROJ = emptyapp*
Standard defines for sample code!INCLUDE $ (PENPOINT_PATH)\sdk\sample\sdefines.mif
*
The PenPoint name of your application EXE_NAME = Empty Application*
The linker name for your executable: company-name-V<major> «minor»EXE_LNAME= GO-EMPTYAPP_EXE-Vl(O)
*
Object files needed to build your app EXE_OBJS = methods.obj emptyapp.obj*
Libs needed to build your app EXE_LIBS = penpoint app*
Targetsall: $(APP_DIR)\$(PROJ).exe . SYMBOLIC
*
The clean rule must be :: because it is also defined in srules clean :: .SYMBOLIC-del methods.h
*
Dependenciesemptyapp.obj: emptyapp.c methods.h
*
Standard rules for sample code!INCLUDE $(PENPOINT_PATH)\sdk\sample\srules.mif