• Keine Ergebnisse gefunden

Files Use"

Im Dokument PenPomt GO (Seite 197-200)

The code for Hello World (custom window) is in

\PENPOINT\SDK\SAMPLE\HELLO. The files are:

DLL.LBC list of exported functions for the Watcom linker DLLINIT.C the routine to initialize the dll

HELLO.C the source code for the application

HELLO.DLC indicates the dependency of the application upon the window dll

HELLOWIN.C the source code for the Window class HELLOWIN.H the header file for the window class HELTBL.TBL the method table for the application class HELWfBL.TBI the method table for the window class.

HELTBL.TBL

'***************************************************************************~

File: helthl.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.2 $

$Date: 13 Nov -1991 18:04:54 $

heltbl.tbl contains the method table for clsHelloWorld.

*****************************************************************************'

MSG INFO clsHelloWorldMethods []

} ;

Copyright 1990~1992 GO Corpo~ation. 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 CORPORATIQN BE LIABLE TO YOU FORANY_CONSEQUENTIAL,_INCIDENTAL,OR INDIRECT DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SAMPLE CODE.

MSG INFO clsHel1oWinMethods [1 msglnit,

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.

in \penpoint\boot\environ.ini), then messages to clsHelloWorld will be traced.

***************************************************************************1 'ifndef DEBUG INCLUDED

'include <debug.h>

'ifndef FRAME INCLUDED 'include <fraie.h>

II for debugging statements.

II for application messages.

II for AppMgr startup stuff

II for frame metrics.

II for strcpy().

II method definitions

II clsHelloWin's UID and msgNew args.

Respond to msgAppOpen by creating a clsHelloWin instance and inserting it as the frame's client window.

ObjCallRet(msgAppGetMetrics, self, &am, s);

II Create the Hello window.

I

SAMPLE CODE

ObjCallWarn(msgNewDefaults, 'clsHelloWin, &hwn);

ObjCallRet(msgNew, clsHelloWin, &hwn, s);

II Insert the Hello win in the frame.

ObjCallJmp(msgFrameSetClientWin, am.mainWin, (P_ARGS)hwn.object.uid, s, exit);

II Ancestor will put it all on the screen.

return stsOK;

MsgHandlerParametersNoWarning; II suppress compiler warnings about unused parameters

exit:

ObjCallWarn(msgDestroy, hwn.object.uid, pNull);

return s;

ObjCallRet(msgAppGetMetrics, self, &am, s);

ObjCaIIRet(msgFrameGetClientWin, am.mainWin, &clientWin, s);

II Destroy it.

ObjCaIIRet(msgDestroy, clientWin, objWKNKey, s);

Dbg (Debugf ("Hello: back from freeing HelloWin");)

II Update the frame since the client window is gone.

ObjCallRet(msgFrameSetClientWin, am.mainWin, (P_ARGS)objNull, s);

return stsOK;

MsgHandlerParametersNoWarning; 1/ suppress compiler warnings about unused parameters

} /* HelloClose */

1****************************************************************************

ClsHellolnit

Install the Hello application.

****************************************************************************/

STATUS ClsHellolnit (void) {

ObjCalIWarn(msgNewDefaults, clsAppMgr, 'new);

new. object; uid clsHelloWorld;

new.object.key (OBJ_KEY)clsHelloWorldTable;

new. cIs. newArgsSize SizeOf (APP NEW);

new.appMgr.flags.stationery = true; - . new.appMgr.flags.accessory = true;

strcpy (new.appMgr. company, "GO Corporation");

ObjCallRet(msgNew, clsAppMgr, 'new, s);

if (DbgFlagGet('F', OxlOL» (

Debugf(nTurning on message tracing for clsHelloWorld");

(void) ObjCallWarn (msgTrace, clsHelloWorld, (P_ARGS) true);

return stsOK;

} 1* ClsHelloInit *1

1****************************************************************************

main

Main application entry point.

****************************************************************************1

Dbg(Debugf("main: starting Hello.exe[%d]", processCount);) if (processCount == 0) (

II II Initialize self.

I! II Note that the loader calls DLLMain in the Hello World DLL,

II which creates clsHelloWin.

II

II Suppress compiler warnings

1****************************************************************************

File: hellowin.h

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.3 $

$Date: 13 Nov 1991 18:04:58 $

This file contains the API definition for clsHelloWin.

clsHelloWin inherits from clsWin.

It has no messages or msgNew arguments.

'define clsHelloWin MakeWKN(2165,I,wknGlobal)

1****************************************************************************

msgNew takes P_HELLO_WIN_NEW, returns STATUS category: class message

Creates a new Hello Window.

} HELLO_WIN_NEW, *P_HELLO_WIN_NEW;

1****************************************************************************

msgNewDefaults takes P_HELLO_WIN_NEW, returns STATUS category: class message

Initializes HELLO WIN NEW structure to default values.

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

..

10

o

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.

Since clsHelloWorld frees the hello window upon receiving msgAppClose, the DC doesn't take up space when the application is "closed down."

The. repainting routine jumps through some geometry/drawing context hoops to ensure that the drawing fits in the window yet remains proportionately sized.

I f you turn on the "F40" debugging flag (e.g. by putting DEBUGSET=/DF0040

in \penpoint\boot\environ.ini), then drawing takes places with thick lines so that drawing operations are more visible.

typedef struct INSTANCE_DATA

SYSDC dc;

II for memset().

II for scale calc. in fixed point.

II method definitions

II clsHelloWin's UID and msgNew args.

memset(&data, 0, sizeof(INSTANCE_DATA»;

II Create a dc.

ObjCaIIWarn(msgNewDefaults, clsSysDrwCtx, &dn);

ObjCallRet (msgNew, clsSysDrwCtx, ·&dn, s);

data. dc = dn. ob'ject. uid;

II Rounded lines, thickness of zero.

ObjectCall(msgDcSetLineThickness, data.dc, (P_ARGS)O);

i f (DbgFlagGet (' F', Ox40L» (

Debugf("Use a non-zero line thickness.");

ObjectCall(msgDcSetLineThickness, data. dc, (P_ARGS)2);

}

ObjCaIIJmp(msgDcOpenFont, data,dc, &fs, s, Error);

II II Scale the font. The entire DC will be scaled in the repaint

II to pleasingly fill the window.

fontScale.x = fontScale.y = FxMakeFixed(initFontScale,O);

ObjectCall(msgDcScaleFont, data.dc, &fontScale);

II Bind the window to the dc.

ObjectCall(msgDcSetWindow, data.dc, (P_ARGS)self);

II Update the instance data.

ObjectWrite(self, ctx, &data);

return stsOK;

MsgHandlerParametersNoWarning; II suppress compiler warnings about unused parameters

Error:

ObjCaIIWarn(msgDestroy, data.dc, Nil(OBJ_KEY»;

return s;

1* HelloWinInit *1

HELLO WORLD (CUSTOM WINDOW)

.. ..

-0

Im Dokument PenPomt GO (Seite 197-200)