diff --git a/dana-2.0/ReadMe.txt b/dana-2.0/ReadMe.txt new file mode 100644 index 0000000..cef68c4 --- /dev/null +++ b/dana-2.0/ReadMe.txt @@ -0,0 +1,5 @@ +Dana SDK + +For those developers that are only interested in adding the wide/tall screen capabilities to their application, please read the Dana Companion Guide, Chapter 3. + + diff --git a/dana-2.0/docs/Bachmann Software PrintBoy Technical Note.pdf b/dana-2.0/docs/Bachmann Software PrintBoy Technical Note.pdf new file mode 100644 index 0000000..a1243f9 Binary files /dev/null and b/dana-2.0/docs/Bachmann Software PrintBoy Technical Note.pdf differ diff --git a/dana-2.0/docs/Dana API Reference.pdf b/dana-2.0/docs/Dana API Reference.pdf new file mode 100644 index 0000000..67b0109 Binary files /dev/null and b/dana-2.0/docs/Dana API Reference.pdf differ diff --git a/dana-2.0/docs/Dana Companion Guide.pdf b/dana-2.0/docs/Dana Companion Guide.pdf new file mode 100644 index 0000000..4a58b9a Binary files /dev/null and b/dana-2.0/docs/Dana Companion Guide.pdf differ diff --git a/dana-2.0/docs/FontBucket Developers.pdf b/dana-2.0/docs/FontBucket Developers.pdf new file mode 100644 index 0000000..8f91564 Binary files /dev/null and b/dana-2.0/docs/FontBucket Developers.pdf differ diff --git a/dana-2.0/docs/FontBucket License.pdf b/dana-2.0/docs/FontBucket License.pdf new file mode 100644 index 0000000..78cba6d Binary files /dev/null and b/dana-2.0/docs/FontBucket License.pdf differ diff --git a/dana-2.0/docs/FontBucket Users.pdf b/dana-2.0/docs/FontBucket Users.pdf new file mode 100644 index 0000000..7adafbf Binary files /dev/null and b/dana-2.0/docs/FontBucket Users.pdf differ diff --git a/dana-2.0/examples/Example A - Screen/ExampleA.mcp b/dana-2.0/examples/Example A - Screen/ExampleA.mcp new file mode 100644 index 0000000..c9c5ec6 Binary files /dev/null and b/dana-2.0/examples/Example A - Screen/ExampleA.mcp differ diff --git a/dana-2.0/examples/Example A - Screen/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example A - Screen/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..990c3f5 Binary files /dev/null and b/dana-2.0/examples/Example A - Screen/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example A - Screen/Rsc/Starter.rsrc b/dana-2.0/examples/Example A - Screen/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example A - Screen/Rsc/StarterRsc.h b/dana-2.0/examples/Example A - Screen/Rsc/StarterRsc.h new file mode 100644 index 0000000..dd98a89 --- /dev/null +++ b/dana-2.0/examples/Example A - Screen/Rsc/StarterRsc.h @@ -0,0 +1,46 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 2:34:14 PM on Tuesday, March 19, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example A\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainOKButton 1003 //(Left Origin = 11, Top Origin = 140, Width = 36, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define MainSimpleCheckbox 1002 //(Left Origin = 97, Top Origin = 139, Width = 62, Height = 13, Usable = 1, Selected = 1, Group ID = 0, Font = Standard) +#define MainGlobeBitMap 1000 //(Left Origin = 68, Top Origin = 97, Bitmap Resource ID = 1000, Usable = 1) +#define MainTextInputField 1001 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 70, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1000 +#define BigIconBitmap 1000 + diff --git a/dana-2.0/examples/Example A - Screen/Src/Starter.c b/dana-2.0/examples/Example A - Screen/Src/Starter.c new file mode 100644 index 0000000..582c8d2 --- /dev/null +++ b/dana-2.0/examples/Example A - Screen/Src/Starter.c @@ -0,0 +1,489 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct + { + UInt8 replaceme; + } StarterPreferenceType; + +typedef struct + { + UInt8 replaceme; + } StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +//static Boolean HideSecretRecords; + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + + // See if we're on in minimum required version of the ROM or later. + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + + // Palm OS 1.0 will continuously relaunch this app unless we switch to + // another safe one. + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr frmP) +{ + RectangleType winRect; + RectangleType objectRect; + RectangleType originalFormRect; + RectangleType resizedFormRect; + Coord gapOnTextBottom; + Coord gapOnButtonBottom; + Coord gapOnCheckboxBottom; + Coord gapOnCheckboxRight; + Coord gapOnBitmapBottom; + + FrmGetFormBounds(frmP, &originalFormRect); + + + // INCREASE THE SIZE OF THE FORM TO MATCH SCREEN SIZE + winRect.topLeft.x = 0; + winRect.topLeft.y = 0; + // get the current screen size + WinGetDisplayExtent(&winRect.extent.x, &winRect.extent.y); + + // change the size of the form to match the screen size + WinSetWindowBounds(FrmGetWindowHandle(frmP), &winRect); + + FrmGetFormBounds(frmP, &resizedFormRect); + + // REPOSITION CONTROLS + // text input field (grow both x and y direction) + FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainTextInputField), &objectRect); + gapOnTextBottom = originalFormRect.extent.y - + (objectRect.topLeft.y + objectRect.extent.y); + objectRect.extent.x = resizedFormRect.extent.x; + objectRect.extent.y = resizedFormRect.extent.y - gapOnTextBottom - objectRect.topLeft.y; + FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainTextInputField), &objectRect); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, MainTextInputField)); + + // checkbox (right side of the screen) + FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainSimpleCheckbox), &objectRect); + gapOnCheckboxBottom = originalFormRect.extent.y - objectRect.topLeft.y; + gapOnCheckboxRight = originalFormRect.extent.x - objectRect.topLeft.x; + objectRect.topLeft.x = resizedFormRect.extent.x - gapOnCheckboxRight; + objectRect.topLeft.y = resizedFormRect.extent.y - gapOnCheckboxBottom; + FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainSimpleCheckbox), &objectRect); + + // bitmap (center in x direction) + FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainGlobeBitMap), &objectRect); + gapOnBitmapBottom = originalFormRect.extent.y - objectRect.topLeft.y; + objectRect.topLeft.x = (resizedFormRect.extent.x / 2) - (objectRect.extent.x / 2); + objectRect.topLeft.y = resizedFormRect.extent.y - gapOnBitmapBottom; + FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainGlobeBitMap), &objectRect); + + // button (left side of screen) + FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainOKButton), &objectRect); + gapOnButtonBottom = originalFormRect.extent.y - objectRect.topLeft.y; + objectRect.topLeft.y = resizedFormRect.extent.y - gapOnButtonBottom; + FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainOKButton), &objectRect); + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case MainOptionsAboutStarterApp: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + default: + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { + // Load the form resource. + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + + default: +// ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return true; + } + + return false; +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + + // Read the saved preferences / saved-state information. + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + + // Write the saved preferences / saved-state information. This data + // will be backed up during a HotSync. + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + + // Close all the open forms. + FrmCloseAllForms (); +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + + error = RomVersionCompatible (ourMinVersion, launchFlags); + if (error) return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example B - Screen/ExampleB.mcp b/dana-2.0/examples/Example B - Screen/ExampleB.mcp new file mode 100644 index 0000000..99b410c Binary files /dev/null and b/dana-2.0/examples/Example B - Screen/ExampleB.mcp differ diff --git a/dana-2.0/examples/Example B - Screen/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example B - Screen/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..470043f Binary files /dev/null and b/dana-2.0/examples/Example B - Screen/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example B - Screen/Rsc/Starter.r b/dana-2.0/examples/Example B - Screen/Rsc/Starter.r new file mode 100644 index 0000000..c68b635 --- /dev/null +++ b/dana-2.0/examples/Example B - Screen/Rsc/Starter.r @@ -0,0 +1 @@ +/*------- WIDE FORM -----------------*/ resource 'tFRM' (1200, "Main - Wide") { 0, 0, 560, 160, usable, notModal, noSaveBehind, 1200, 0, 1000, 0, { /* array ObjectArray: 5 elements */ /* [1] */ 1200, "tTTL", /* [2] */ 1201, "tFLD", /* [3] */ 1202, "tCBX", /* [4] */ 1203, "tBTN", /* [5] */ 1204, "tFBM" } }; data 'tTTL' (1200) { $"5374 6172 7465 7241 7070 00" /* StarterApp. */ }; resource 'tFLD' (1201, "TextInput") { 1201, 0, 23, 559, 70, usable, editable, underlined, notSingleLine, notDynamicSize, leftJustified, 3000, stdFont, notAutoShift, notHasScrollbar, notNumeric }; resource 'tCBX' (1202, "Simple") { 1202, 560 - 63, 139, 62, 13, usable, selected, 0, stdFont, "Stay Right" }; resource 'tBTN' (1203, "OK") { 1203, 11, 140, 36, 12, usable, leftAnchor, frame, nonBoldFrame, stdFont, "OK" }; resource 'tFBM' (1204, "Globe") { (560 / 2) - 11, 97, 1000, usable }; /*------- TALL FORM -----------------*/ resource 'tFRM' (1300, "Main - Tall") { 0, 0, 160, 499, usable, notModal, noSaveBehind, 1300, 0, 1000, 0, { /* array ObjectArray: 5 elements */ /* [1] */ 1300, "tTTL", /* [2] */ 1301, "tFLD", /* [3] */ 1302, "tCBX", /* [4] */ 1303, "tBTN", /* [5] */ 1304, "tFBM" } }; data 'tTTL' (1300) { $"5374 6172 7465 7241 7070 00" /* StarterApp. */ }; resource 'tFLD' (1301, "TextInput") { 1201, 0, 23, 160, 399, usable, editable, underlined, notSingleLine, notDynamicSize, leftJustified, 3000, stdFont, notAutoShift, notHasScrollbar, notNumeric }; resource 'tCBX' (1302, "Simple") { 1202, 97, 478, 62, 13, usable, selected, 0, stdFont, "Stay Right" }; resource 'tBTN' (1303, "OK") { 1203, 11, 478, 36, 12, usable, leftAnchor, frame, nonBoldFrame, stdFont, "OK" }; resource 'tFBM' (1304, "Globe") { 68, 430, 1000, usable }; \ No newline at end of file diff --git a/dana-2.0/examples/Example B - Screen/Rsc/Starter.rsrc b/dana-2.0/examples/Example B - Screen/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example B - Screen/Rsc/StarterRsc.h b/dana-2.0/examples/Example B - Screen/Rsc/StarterRsc.h new file mode 100644 index 0000000..498093d --- /dev/null +++ b/dana-2.0/examples/Example B - Screen/Rsc/StarterRsc.h @@ -0,0 +1,46 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 11:18:47 AM on Tuesday, March 19, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example B\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainOKButton 1003 //(Left Origin = 11, Top Origin = 140, Width = 36, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define MainSimpleCheckbox 1002 //(Left Origin = 97, Top Origin = 139, Width = 62, Height = 13, Usable = 1, Selected = 1, Group ID = 0, Font = Standard) +#define MainGlobeBitMap 1000 //(Left Origin = 68, Top Origin = 97, Bitmap Resource ID = 1000, Usable = 1) +#define MainTextInputField 1001 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 70, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1000 +#define BigIconBitmap 1000 + diff --git a/dana-2.0/examples/Example B - Screen/Src/Starter.c b/dana-2.0/examples/Example B - Screen/Src/Starter.c new file mode 100644 index 0000000..1e68868 --- /dev/null +++ b/dana-2.0/examples/Example B - Screen/Src/Starter.c @@ -0,0 +1,461 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + +#include "Screen.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct + { + UInt8 replaceme; + } StarterPreferenceType; + +typedef struct + { + UInt8 replaceme; + } StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +//static Boolean HideSecretRecords; + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + +#define wideMainForm 1200 +#define tallMainForm 1300 + + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + + // See if we're on in minimum required version of the ROM or later. + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + + // Palm OS 1.0 will continuously relaunch this app unless we switch to + // another safe one. + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr frmP) +{ + + + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case MainOptionsAboutStarterApp: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + default: + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { + // Load the form resource. + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) + { + case tallMainForm: + case wideMainForm: + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + + default: +// ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return true; + } + + return false; +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + + // Read the saved preferences / saved-state information. + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + + // Write the saved preferences / saved-state information. This data + // will be backed up during a HotSync. + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + + // Close all the open forms. + FrmCloseAllForms (); +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + UInt32 version; + ScrnRotateModeType rotation; + + error = RomVersionCompatible (ourMinVersion, launchFlags); + if (error) return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + if ( _ScreenFeaturePresent(&version) == true) + { + ScrnGetRotateMode(&rotation); + if (rotation == rotateScrnMode0) + { + FrmGotoForm(wideMainForm); + } + else // either 90 or 270 degree rotation + { + FrmGotoForm(tallMainForm); + } + } + else // non AlphaSmart device + { // just use the 160 x 160 form + FrmGotoForm(MainForm); + } + + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example C - Keyboard/ExampleC.mcp b/dana-2.0/examples/Example C - Keyboard/ExampleC.mcp new file mode 100644 index 0000000..a3f1256 Binary files /dev/null and b/dana-2.0/examples/Example C - Keyboard/ExampleC.mcp differ diff --git a/dana-2.0/examples/Example C - Keyboard/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example C - Keyboard/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..682778d Binary files /dev/null and b/dana-2.0/examples/Example C - Keyboard/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example C - Keyboard/Rsc/Starter.rsrc b/dana-2.0/examples/Example C - Keyboard/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example C - Keyboard/Rsc/StarterRsc.h b/dana-2.0/examples/Example C - Keyboard/Rsc/StarterRsc.h new file mode 100644 index 0000000..293eb52 --- /dev/null +++ b/dana-2.0/examples/Example C - Keyboard/Rsc/StarterRsc.h @@ -0,0 +1,49 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 9:27:22 AM on Wednesday, March 20, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example C - F1 and Escape key\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainTextInputField 1001 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 70, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) +#define MainUnnamed1005Label 1005 //(Left Origin = 22, Top Origin = 108, Usable = 1, Font = Standard) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + +// Resource: tFRM 1200 +#define CoolForm 1200 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define CoolTextInputField 1201 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 70, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) +#define CoolUnnamed1205Label 1205 //(Left Origin = 34, Top Origin = 114, Usable = 1, Font = Standard) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1000 +#define BigIconBitmap 1000 + diff --git a/dana-2.0/examples/Example C - Keyboard/Src/Starter.c b/dana-2.0/examples/Example C - Keyboard/Src/Starter.c new file mode 100644 index 0000000..e5340ad --- /dev/null +++ b/dana-2.0/examples/Example C - Keyboard/Src/Starter.c @@ -0,0 +1,513 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + +#include "WideTallAppChars.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct + { + UInt8 replaceme; + } StarterPreferenceType; + +typedef struct + { + UInt8 replaceme; + } StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +//static Boolean HideSecretRecords; + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + + // See if we're on in minimum required version of the ROM or later. + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + + // Palm OS 1.0 will continuously relaunch this app unless we switch to + // another safe one. + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr frmP) +{ + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case MainOptionsAboutStarterApp: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + case keyDownEvent: + if (eventP->data.keyDown.chr == AS_VIRTUAL_KEY) + { + if (eventP->data.keyDown.keyCode == ICODE_F1_KEY) + { + // put the code to handle the F1 key + FrmGotoForm(CoolForm); + handled = true; + } + } + else // not an AlphaSmart virtual key + { // get the Escape key being pressed + if (eventP->data.keyDown.chr == chrEscape) + { + EvtEnqueueKey(vchrLaunch, 0, commandKeyMask); + handled = true; + } + } + break; + + default: + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: CoolFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "CoolForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean CoolFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + case keyDownEvent: + if (eventP->data.keyDown.chr == AS_VIRTUAL_KEY) + { + if (eventP->data.keyDown.keyCode == ICODE_F1_KEY) + { + // put the code to handle the F1 key + FrmGotoForm(MainForm); + handled = true; + } + } + break; + + default: + break; + + } + + return handled; +} + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { + // Load the form resource. + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + + case CoolForm: + FrmSetEventHandler(frmP, CoolFormHandleEvent); + break; + + default: +// ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return true; + } + + return false; +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + + // Read the saved preferences / saved-state information. + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + + // Write the saved preferences / saved-state information. This data + // will be backed up during a HotSync. + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + + // Close all the open forms. + FrmCloseAllForms (); +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + + error = RomVersionCompatible (ourMinVersion, launchFlags); + if (error) return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example D - Keyboard/ExampleD.mcp b/dana-2.0/examples/Example D - Keyboard/ExampleD.mcp new file mode 100644 index 0000000..0aeceb3 Binary files /dev/null and b/dana-2.0/examples/Example D - Keyboard/ExampleD.mcp differ diff --git a/dana-2.0/examples/Example D - Keyboard/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example D - Keyboard/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..cf0bdd0 Binary files /dev/null and b/dana-2.0/examples/Example D - Keyboard/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example D - Keyboard/Rsc/Starter.rsrc b/dana-2.0/examples/Example D - Keyboard/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example D - Keyboard/Rsc/StarterRsc.h b/dana-2.0/examples/Example D - Keyboard/Rsc/StarterRsc.h new file mode 100644 index 0000000..de97139 --- /dev/null +++ b/dana-2.0/examples/Example D - Keyboard/Rsc/StarterRsc.h @@ -0,0 +1,51 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 9:28:02 AM on Wednesday, March 20, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example D - Key Modifiers\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainTextInputField 1001 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 49, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) +#define MainUnnamed1009GraffitiShift 1009 //(Left Origin = 137, Top Origin = 76) +#define MainUnnamed1002Label 1002 //(Left Origin = 20, Top Origin = 81, Usable = 1, Font = Bold) +#define MainCapsLockLabel 1003 //(Left Origin = 33, Top Origin = 111, Usable = 0, Font = Standard) +#define MainLeftShiftLabel 1004 //(Left Origin = 33, Top Origin = 124, Usable = 1, Font = Standard) +#define MainRightShiftLabel 1005 //(Left Origin = 33, Top Origin = 137, Usable = 1, Font = Standard) +#define MainControlLabel 1006 //(Left Origin = 99, Top Origin = 111, Usable = 1, Font = Standard) +#define MainFunctionLabel 1007 //(Left Origin = 99, Top Origin = 124, Usable = 1, Font = Standard) +#define MainCmdLabel 1008 //(Left Origin = 99, Top Origin = 137, Usable = 1, Font = Standard) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1000 +#define BigIconBitmap 1000 + diff --git a/dana-2.0/examples/Example D - Keyboard/Src/Starter.c b/dana-2.0/examples/Example D - Keyboard/Src/Starter.c new file mode 100644 index 0000000..a72cb2c --- /dev/null +++ b/dana-2.0/examples/Example D - Keyboard/Src/Starter.c @@ -0,0 +1,524 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + +#include "WideTallAppChars.h" +#include "KeyboardAccess.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct + { + UInt8 replaceme; + } StarterPreferenceType; + +typedef struct + { + UInt8 replaceme; + } StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +//static Boolean HideSecretRecords; + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ +void UpdateModifierIndicators(void); + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + + // See if we're on in minimum required version of the ROM or later. + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + + // Palm OS 1.0 will continuously relaunch this app unless we switch to + // another safe one. + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr frmP) +{ + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, MainTextInputField)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case MainOptionsAboutStarterApp: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + } + + return handled; +} + +/*********************************************************************** + * + * FUNCTION: UpdateModifierIndicators + * + * DESCRIPTION: This routine updates the form objects. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void UpdateModifierIndicators(void) +{ + KeyboardEvent keyboardModifiers; + FormPtr frmP; + + keyboardModifiers = KybdGetModifiers(); + + frmP = FrmGetActiveForm(); + + if (keyboardModifiers & KEYBOARD_MODIFIER_CAPS_LOCK) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainCapsLockLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainCapsLockLabel)); + } + + if (keyboardModifiers & KEYBOARD_MODIFIER_LEFT_SHIFT) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainLeftShiftLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainLeftShiftLabel)); + } + + if (keyboardModifiers & KEYBOARD_MODIFIER_RIGHT_SHIFT) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainRightShiftLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainRightShiftLabel)); + } + + if (keyboardModifiers & KEYBOARD_MODIFIER_CONTROL) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainControlLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainControlLabel)); + } + + if (keyboardModifiers & KEYBOARD_MODIFIER_FUNCTION) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainFunctionLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainFunctionLabel)); + } + + if (keyboardModifiers & KEYBOARD_MODIFIER_COMMAND) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainCmdLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainCmdLabel)); + } + + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + UpdateModifierIndicators(); + FrmDrawForm ( frmP); + handled = true; + break; + + case keyDownEvent: + case MODIFIER_KEY_EVENT: + UpdateModifierIndicators(); + break; + + default: + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { + // Load the form resource. + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + + default: +// ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return true; + } + + return false; +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + + // Read the saved preferences / saved-state information. + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + + // Write the saved preferences / saved-state information. This data + // will be backed up during a HotSync. + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + + // Close all the open forms. + FrmCloseAllForms (); +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + + error = RomVersionCompatible (ourMinVersion, launchFlags); + if (error) return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example E - WritePad/ExampleE.mcp b/dana-2.0/examples/Example E - WritePad/ExampleE.mcp new file mode 100644 index 0000000..185d7c9 Binary files /dev/null and b/dana-2.0/examples/Example E - WritePad/ExampleE.mcp differ diff --git a/dana-2.0/examples/Example E - WritePad/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example E - WritePad/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..9504198 Binary files /dev/null and b/dana-2.0/examples/Example E - WritePad/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example E - WritePad/Rsc/Starter.rsrc b/dana-2.0/examples/Example E - WritePad/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example E - WritePad/Rsc/StarterRsc.h b/dana-2.0/examples/Example E - WritePad/Rsc/StarterRsc.h new file mode 100644 index 0000000..8ccfc4b --- /dev/null +++ b/dana-2.0/examples/Example E - WritePad/Rsc/StarterRsc.h @@ -0,0 +1,69 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 2:06:57 PM on Tuesday, April 02, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example E - WritePad - Graphic\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainUnnamed1001Label 1001 //(Left Origin = 23, Top Origin = 34, Usable = 1, Font = Bold) +#define MainUnnamed1002Label 1002 //(Left Origin = 48, Top Origin = 58, Usable = 1, Font = Standard) +#define MainUnnamed1003Label 1003 //(Left Origin = 48, Top Origin = 106, Usable = 1, Font = Standard) +#define MainMinLabel 1004 //(Left Origin = 61, Top Origin = 118, Usable = 0, Font = Standard) +#define MainMaxLabel 1005 //(Left Origin = 61, Top Origin = 131, Usable = 0, Font = Standard) +#define MainLeftLabel 1006 //(Left Origin = 61, Top Origin = 84, Usable = 0, Font = Standard) +#define MainRightLabel 1007 //(Left Origin = 61, Top Origin = 70, Usable = 0, Font = Standard) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + +// Resource: Talt 1000 +#define WritePadExtNotFoundAlert 1000 +#define WritePadExtNotFoundOK 0 + +// Resource: Talt 1100 +#define WritePadDrawErrorAlert 1100 +#define WritePadDrawErrorOK 0 + + +// Resource: MBAR 1000 +#define AboutFormMenuBar 1000 + + +// Resource: MENU 1100 +#define MainOptionsMenu 1100 +#define MainOptionsAboutStarter 1100 + + +// Resource: PICT 1204 +#define Graphic4Bitmap 1204 + +// Resource: PICT 1203 +#define Graphic3Bitmap 1203 + +// Resource: PICT 1000 +#define BigIconBitmap 1000 + +// Resource: PICT 1201 +#define Graphic1Bitmap 1201 + +// Resource: PICT 1202 +#define Graphic2Bitmap 1202 + diff --git a/dana-2.0/examples/Example E - WritePad/Src/starter.c b/dana-2.0/examples/Example E - WritePad/Src/starter.c new file mode 100644 index 0000000..f15aa68 --- /dev/null +++ b/dana-2.0/examples/Example E - WritePad/Src/starter.c @@ -0,0 +1,673 @@ +/****************************************************************************** + * + * File: Starter.c + * + * Project : ExampleF + * + *****************************************************************************/ + +#include +#include +#include "StarterRsc.h" + +#include "WritePad.h" +#include "Screen.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct +{ + UInt8 replaceme; +} StarterPreferenceType; + +typedef struct +{ + UInt8 replaceme; +} StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + +Boolean writePadExtensionPresent; + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +static Boolean notifyRegistered = false; +static DmResID currentGraphicID = Graphic1Bitmap; + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ +static void UpdateWritePadInfo(writePadEventType *writePadEventP); +static void BuildWritePadEvent(void); + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + +/*------------------------------------------------------------------------ + * See if we're on in minimum required version of the ROM or later. + *----------------------------------------------------------------------*/ + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + +/*------------------------------------------------------------------------ + * Palm OS 1.0 will continuously relaunch this app unless we switch to + * another safe one. + *----------------------------------------------------------------------*/ + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID))); +} + +/*********************************************************************** + * + * FUNCTION: DrawGraphic + * + * DESCRIPTION: This routine puts a graphic on the WritePad alpha area. + * + * PARAMETERS: none + * + * RETURNED: err + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err DrawGraphic(void) +{ + WinHandle writePadWindow, savedWindow; + MemHandle resH; + BitmapPtr resP; + Coord x, y, winWidth, winHeight; + Coord resWidth, resHeight; + UInt16 rowBytes; + Boolean screenActive; + +/*------------------------------------------------------------------------ + * Get the WinHandle to the WritePad window + *----------------------------------------------------------------------*/ + if ((writePadWindow = WrtpGetWindow()) == NULL) + { + return(-1); + } + + + // only draw the graphic when the writepad is visible + if (WrtpWindowMaximized()) + { + savedWindow = WinSetDrawWindow(writePadWindow); + + // must disable screen extension so that we can draw to the + // WritePad + screenActive = ScrnIsEnabled(); + if (screenActive) + { + ScrnDisable(); + } + + // check for rollover + if (currentGraphicID > Graphic4Bitmap) + { + currentGraphicID = Graphic1Bitmap; + } + + resH = DmGetResource(bitmapRsc, currentGraphicID); + ErrFatalDisplayIf(!resH, "Missing bitmap"); + resP = MemHandleLock(resH); + + ++currentGraphicID; +/*------------------------------------------------------------------------ + * Determine the size of the WritePad area so we can center the graphic. + *----------------------------------------------------------------------*/ + WinGetWindowExtent(&winWidth, &winHeight); + +/*------------------------------------------------------------------------ + * Draw the graphic + *----------------------------------------------------------------------*/ + BmpGlueGetDimensions(resP, &resWidth, &resHeight, &rowBytes); + x = (winWidth/2) - (resWidth/2); + x -= 20; //OK, fudge a little so we don't erase the down arrow. + y = (winHeight/2) - (resHeight/2); + WinPaintBitmap(resP, x, y); + + MemPtrUnlock(resP); + DmReleaseResource(resH); + + // turn the screen extension back on if necessary + if (screenActive) + { + ScrnEnable(); + } + + WinSetDrawWindow(savedWindow); + } + else + { + } + + + + return(errNone); +} + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr /*frmP*/) +{ + BuildWritePadEvent(); + +} + +/*********************************************************************** + * + * FUNCTION: BuildWritePadEvent + * + * DESCRIPTION: This routine builds a writepad event structure so + * that the information can be updated + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void BuildWritePadEvent(void) +{ + writePadEventType writePadEvent; + + writePadEvent.writePad_minimized = !WrtpWindowMaximized(); + + writePadEvent.writePad_onTheRight = WrtpWindowRight(); + + UpdateWritePadInfo(&writePadEvent); + +} + +/*********************************************************************** + * + * FUNCTION: UpdateWritePadInfo + * + * DESCRIPTION: This routine updates the writepad information on the + * Main form. + * + * PARAMETERS: writePadEventP - pointer to writepad info + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void UpdateWritePadInfo(writePadEventType *writePadEventP) +{ + + FormPtr frmP; + UInt16 formID; + + formID = FrmGetActiveFormID(); + if (formID != MainForm) + { + return; + } + + frmP = FrmGetActiveForm(); + + + if (writePadEventP->writePad_minimized) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainMinLabel)); + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainMaxLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainMinLabel)); + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainMaxLabel)); + } + + if (writePadEventP->writePad_onTheRight) + { + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainRightLabel)); + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainLeftLabel)); + } + else + { + FrmHideObject(frmP, FrmGetObjectIndex(frmP, MainRightLabel)); + FrmShowObject(frmP, FrmGetObjectIndex(frmP, MainLeftLabel)); + } + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case AboutForm: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + BuildWritePadEvent(); + break; + + } + return(handled); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case ctlSelectEvent : + switch(eventP->data.ctlSelect.controlID) + { + + + } + break; + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + default: + break; + } + return(handled); +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { +/*------------------------------------------------------------------------ + * Load the form resource. + *----------------------------------------------------------------------*/ + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); +/*------------------------------------------------------------------------ + * Set the event handler for the form. The handler of the currently + * active form is called by FrmHandleEvent each time is receives an event. + *----------------------------------------------------------------------*/ + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + default: + ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return(true); + } + + return(false); +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do + { + EvtGetEvent(&event, 15); + + DrawGraphic(); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + UInt32 version; + Err error; + UInt16 cardNo; + LocalID dbID; + +/*------------------------------------------------------------------------ + * Read the saved preferences / saved-state information. + *----------------------------------------------------------------------*/ + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + if (_WritePadFeaturePresent(&version)) + writePadExtensionPresent = true; + else + writePadExtensionPresent = false; + + if (notifyRegistered == false) + { + error = SysCurAppDatabase(&cardNo, &dbID); + error = SysNotifyRegister(cardNo, dbID, notifyWritePadEvent, + NULL, sysNotifyNormalPriority , NULL); + + notifyRegistered = true; + } + + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + Err error; + UInt16 cardNo; + LocalID dbID; + StarterPreferenceType prefs; + +/*------------------------------------------------------------------------ + * Write the saved preferences / saved-state information. This data + * will be backed up during a HotSync. + *----------------------------------------------------------------------*/ + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + +/*------------------------------------------------------------------------ + * Close all the open forms. + *----------------------------------------------------------------------*/ + FrmCloseAllForms (); + + if (notifyRegistered == true) + { + error = SysCurAppDatabase(&cardNo, &dbID); + error = SysNotifyUnregister(cardNo, dbID, notifyWritePadEvent, + sysNotifyNormalPriority); + } + +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + Err error; + writePadEventType *writePadEventP; + + if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0) + return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + + case sysAppLaunchCmdNotify: + if (((SysNotifyParamType *)cmdPBP)->notifyType == notifyWritePadEvent) + { + writePadEventP = ((SysNotifyParamType *)cmdPBP)->notifyDetailsP; + UpdateWritePadInfo(writePadEventP); + + } + break; + + + default: + break; + + } + return(errNone); +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example F - WritePad/ExampleF.mcp b/dana-2.0/examples/Example F - WritePad/ExampleF.mcp new file mode 100644 index 0000000..faf67ce Binary files /dev/null and b/dana-2.0/examples/Example F - WritePad/ExampleF.mcp differ diff --git a/dana-2.0/examples/Example F - WritePad/Rsc/Resource.frk/Starter.rsrc b/dana-2.0/examples/Example F - WritePad/Rsc/Resource.frk/Starter.rsrc new file mode 100644 index 0000000..ba4da3a Binary files /dev/null and b/dana-2.0/examples/Example F - WritePad/Rsc/Resource.frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example F - WritePad/Rsc/Starter.rsrc b/dana-2.0/examples/Example F - WritePad/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example F - WritePad/Rsc/StarterRsc.h b/dana-2.0/examples/Example F - WritePad/Rsc/StarterRsc.h new file mode 100644 index 0000000..8f1a559 --- /dev/null +++ b/dana-2.0/examples/Example F - WritePad/Rsc/StarterRsc.h @@ -0,0 +1,64 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 2:26:27 PM on Friday, March 28, 2003 +// +// Generated for file: C:\AS\Software\HEMING~1\Sources\SDK\examples\EX3500~1\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainSetTemplateButton 1001 //(Left Origin = 50, Top Origin = 75, Width = 60, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define MainResetTemplateButton 1002 //(Left Origin = 40, Top Origin = 110, Width = 80, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + +// Resource: Talt 1000 +#define WritePadExtNotFoundAlert 1000 +#define WritePadExtNotFoundOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1600 +#define NormalWritePad1bitBitmap 1600 + +// Resource: PICT 1700 +#define NormalWritePad2bitBitmap 1700 + +// Resource: PICT 1800 +#define InvertedWritePad1bitBitmap 1800 + +// Resource: PICT 1900 +#define InvertedWritePad2bitBitmap 1900 + + +// Resource: tbmf 3000 +#define InvertedWritePadBitmapFamily 3000 + +// Resource: tbmf 3100 +#define NormalWritePadBitmapFamily 3100 + diff --git a/dana-2.0/examples/Example F - WritePad/Src/starter.c b/dana-2.0/examples/Example F - WritePad/Src/starter.c new file mode 100644 index 0000000..992fde8 --- /dev/null +++ b/dana-2.0/examples/Example F - WritePad/Src/starter.c @@ -0,0 +1,763 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + +#include "WritePad.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct +{ + UInt8 replaceme; +} StarterPreferenceType; + +typedef struct +{ + UInt8 replaceme; +} StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + +Boolean writePadPresent; + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +#define NUM_NEW_BUTTONS 11 + +#define KEYPAD_TOPX 98 +#define KEYPAD_TOPY 11 +#define BUTTON_WIDTH 9 +#define BUTTON_HEIGHT 9 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + +/*------------------------------------------------------------------------ + * See if we're on in minimum required version of the ROM or later. + *----------------------------------------------------------------------*/ + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + +/*------------------------------------------------------------------------ + * Palm OS 1.0 will continuously relaunch this app unless we switch to + * another safe one. + *----------------------------------------------------------------------*/ + if (romVersion < ourMinVersion) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID))); +} + +/*********************************************************************** + * + * FUNCTION: SetNewButtons + * + * DESCRIPTION: Sets up the numeric keypad structure. + * + * PARAMETERS: + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void SetNewButtons(PenBtnListType *buttonList) +{ + UInt16 index, i; + + index = buttonList->numButtons; + +/*------------------------------------------------------------------------ + * Look for the numeric keyboard button. Simply set the width to 0 for this + * example. A complete app would competely remove it. + *----------------------------------------------------------------------*/ + for (i = 0;i < index; i++) + { + if (buttonList->buttons[i].asciiCode == vchrKeyboardNumeric) + { + buttonList->buttons[i].boundsR.extent.x = 1; + buttonList->buttons[i].boundsR.extent.y = 1; + } + } + +/*------------------------------------------------------------------------ + * '1' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+0].boundsR.topLeft.x = KEYPAD_TOPX ; + buttonList->buttons[index+0].boundsR.topLeft.y = KEYPAD_TOPY; + buttonList->buttons[index+0].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+0].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+0].asciiCode = '1'; + buttonList->buttons[index+0].keyCode = 0; + buttonList->buttons[index+0].modifiers = 0; + +/*------------------------------------------------------------------------ + * '2' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+1].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH; + buttonList->buttons[index+1].boundsR.topLeft.y = KEYPAD_TOPY; + buttonList->buttons[index+1].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+1].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+1].asciiCode = '2'; + buttonList->buttons[index+1].keyCode = 0; + buttonList->buttons[index+1].modifiers = 0; + +/*------------------------------------------------------------------------ + * '3' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+2].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2); + buttonList->buttons[index+2].boundsR.topLeft.y = KEYPAD_TOPY; + buttonList->buttons[index+2].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+2].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+2].asciiCode = '3'; + buttonList->buttons[index+2].keyCode = 0; + buttonList->buttons[index+2].modifiers = 0; + +/*------------------------------------------------------------------------ + * '4' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+3].boundsR.topLeft.x = KEYPAD_TOPX; + buttonList->buttons[index+3].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT; + buttonList->buttons[index+3].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+3].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+3].asciiCode = '4'; + buttonList->buttons[index+3].keyCode = 0; + buttonList->buttons[index+3].modifiers = 0; + +/*------------------------------------------------------------------------ + * '5' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+4].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH; + buttonList->buttons[index+4].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT; + buttonList->buttons[index+4].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+4].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+4].asciiCode = '5'; + buttonList->buttons[index+4].keyCode = 0; + buttonList->buttons[index+4].modifiers = 0; + +/*------------------------------------------------------------------------ + * '6' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+5].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2); + buttonList->buttons[index+5].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT; + buttonList->buttons[index+5].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+5].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+5].asciiCode = '6'; + buttonList->buttons[index+5].keyCode = 0; + buttonList->buttons[index+5].modifiers = 0; + +/*------------------------------------------------------------------------ + * '7' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+6].boundsR.topLeft.x = KEYPAD_TOPX; + buttonList->buttons[index+6].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2); + buttonList->buttons[index+6].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+6].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+6].asciiCode = '7'; + buttonList->buttons[index+6].keyCode = 0; + buttonList->buttons[index+6].modifiers = 0; + +/*------------------------------------------------------------------------ + * '8' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+7].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH; + buttonList->buttons[index+7].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2); + buttonList->buttons[index+7].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+7].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+7].asciiCode = '8'; + buttonList->buttons[index+7].keyCode = 0; + buttonList->buttons[index+7].modifiers = 0; + +/*------------------------------------------------------------------------ + * '9' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+8].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2); + buttonList->buttons[index+8].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2); + buttonList->buttons[index+8].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+8].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+8].asciiCode = '9'; + buttonList->buttons[index+8].keyCode = 0; + buttonList->buttons[index+8].modifiers = 0; + +/*------------------------------------------------------------------------ + * '0' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+9].boundsR.topLeft.x = KEYPAD_TOPX; + buttonList->buttons[index+9].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*3); + buttonList->buttons[index+9].boundsR.extent.x = (BUTTON_WIDTH * 2) - 1; + buttonList->buttons[index+9].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+9].asciiCode = '0'; + buttonList->buttons[index+9].keyCode = 0; + buttonList->buttons[index+9].modifiers = 0; + +/*------------------------------------------------------------------------ + * '.' + *----------------------------------------------------------------------*/ + buttonList->buttons[index+10].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2); + buttonList->buttons[index+10].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*3); + buttonList->buttons[index+10].boundsR.extent.x = BUTTON_WIDTH - 1; + buttonList->buttons[index+10].boundsR.extent.y = BUTTON_HEIGHT - 1; + buttonList->buttons[index+10].asciiCode = '.'; + buttonList->buttons[index+10].keyCode = 0; + buttonList->buttons[index+10].modifiers = 0; + + buttonList->numButtons += NUM_NEW_BUTTONS; + +} + +/*********************************************************************** + * + * FUNCTION: SetTemplate + * + * DESCRIPTION: This routine changes the template to our template + * + * PARAMETERS: + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void SetTemplate(void) +{ + MemHandle normalH, invertedH; + BitmapPtr normal, inverted, originalNormal, originalInverted; + RectangleType alpha, numeric; + UInt16 numNewButtons; + PenBtnListType *currentPtr, *newPtr; + UInt16 currentSize, newSize; + WinHandle winH, oldWinH; + Err err; + +/*------------------------------------------------------------------------ + * First draw the new writepad template + *----------------------------------------------------------------------*/ + // get the normal keypad + normalH = DmGetResource(bitmapRsc, NormalWritePadBitmapFamily); + ErrFatalDisplayIf(!normalH, "Missing normal bitmap"); + normal = MemHandleLock(normalH); + + // draw the normal keypad on the normal writepad bitmap + WrtpGetTemplateBitmaps(&originalNormal, &originalInverted, NULL, NULL); + winH = WinCreateBitmapWindow(originalNormal, &err); + oldWinH = WinSetDrawWindow(winH); + WinDrawBitmap(normal, KEYPAD_TOPX - 1, KEYPAD_TOPY - 1); + WinSetDrawWindow(oldWinH); + WinDeleteWindow(winH, false); + + // get the inverted keypad + invertedH = DmGetResource(bitmapRsc, InvertedWritePadBitmapFamily); + ErrFatalDisplayIf(!invertedH, "Missing inverted bitmap"); + inverted = MemHandleLock(invertedH); + + // draw the invertedkeypad on the inverted writepad bitmap + winH = WinCreateBitmapWindow(originalInverted, &err); + oldWinH = WinSetDrawWindow(winH); + WinDrawBitmap(inverted, KEYPAD_TOPX - 1, KEYPAD_TOPY - 1); + WinSetDrawWindow(oldWinH); + WinDeleteWindow(winH, false); + + WrtpSetTemplateBitmaps(originalNormal, originalInverted, NULL, NULL); + WrtpMaximizeWindow(); // force of redraw of the writepad + + MemPtrUnlock(normal); + DmReleaseResource(normalH); + MemPtrUnlock(inverted); + DmReleaseResource(invertedH); + +/*------------------------------------------------------------------------ + * The numeric graffiti area can not be removed, so make its width 1, which + * will effectively remove it. + *----------------------------------------------------------------------*/ + WrtpGetAreas(&alpha, &numeric); + numeric.extent.x = 1; + WrtpSetAreas(&alpha, &numeric); + +/*------------------------------------------------------------------------ + * First get the number of writepad buttons so we know how much to allocate, + * with our additional buttons. + *----------------------------------------------------------------------*/ + currentSize = WrtpGetButtonListSize(true); + + if ((currentPtr = MemPtrNew(currentSize)) == NULL) + { + ErrFatalDisplay("Allcoate Errror"); + return; + } + + WrtpGetButtonList(currentPtr, true); + +/*------------------------------------------------------------------------ + * Allocate space for new button list. + *----------------------------------------------------------------------*/ + numNewButtons = currentPtr->numButtons + NUM_NEW_BUTTONS; + newSize = sizeof(PenBtnListType) + (sizeof(PenBtnInfoType) * (numNewButtons - 1)); + + if ((newPtr = MemPtrNew(newSize)) == NULL) + { + MemPtrFree(currentPtr); + ErrFatalDisplay("Allcoate Errror"); + return; + } + + MemMove(newPtr, currentPtr, currentSize); + + SetNewButtons(newPtr); + WrtpSetButtonList(newPtr, true); + +/*------------------------------------------------------------------------ + * Since the button list is copied by the system, we can free our copy. + *----------------------------------------------------------------------*/ + MemPtrFree(currentPtr); + MemPtrFree(newPtr); + +} + + + +/*********************************************************************** + * + * FUNCTION: ResetTemplate + * + * DESCRIPTION: This routine restores the defaul template, areas and + * writepad buttons. + * + * PARAMETERS: + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void ResetTemplate(void) +{ + WrtpRestoreDefaultTemplates(); + WrtpMaximizeWindow(); +} + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr /*frmP*/) +{ +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + + switch (command) + { + case MainOptionsAboutStarterApp : + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + } + return(handled); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case ctlSelectEvent : + switch(eventP->data.ctlSelect.controlID) + { + case MainSetTemplateButton : + if (!writePadPresent) + FrmAlert(WritePadExtNotFoundAlert); + else + SetTemplate(); + break; + + case MainResetTemplateButton : + if (!writePadPresent) + FrmAlert(WritePadExtNotFoundAlert); + else + ResetTemplate(); + break; + } + break; + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit( frmP); + FrmDrawForm ( frmP); + handled = true; + break; + + default: + break; + } + return(handled); +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { +/*------------------------------------------------------------------------ + * Load the form resource. + *----------------------------------------------------------------------*/ + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); +/*------------------------------------------------------------------------ + * Set the event handler for the form. The handler of the currently + * active form is called by FrmHandleEvent each time is receives an event. + *----------------------------------------------------------------------*/ + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + default: + ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return(true); + } + + return(false); +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do + { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + UInt32 version; + +/*------------------------------------------------------------------------ + * Read the saved preferences / saved-state information. + *----------------------------------------------------------------------*/ + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != + noPreferenceFound) + { + } + + if (_WritePadFeaturePresent(&version)) + writePadPresent = true; + else + writePadPresent = false; + + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + +/*------------------------------------------------------------------------ + * Write the saved preferences / saved-state information. This data + * will be backed up during a HotSync. + *----------------------------------------------------------------------*/ + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + +/*------------------------------------------------------------------------ + * Close all the open forms. + *----------------------------------------------------------------------*/ + FrmCloseAllForms (); +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + + if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0) + return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + return(errNone); +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} + diff --git a/dana-2.0/examples/Example G - FontBucket/ExampleG.mcp b/dana-2.0/examples/Example G - FontBucket/ExampleG.mcp new file mode 100644 index 0000000..b7dc075 Binary files /dev/null and b/dana-2.0/examples/Example G - FontBucket/ExampleG.mcp differ diff --git a/dana-2.0/examples/Example G - FontBucket/Rsc/Resource.Frk/Starter.rsrc b/dana-2.0/examples/Example G - FontBucket/Rsc/Resource.Frk/Starter.rsrc new file mode 100644 index 0000000..9389df0 Binary files /dev/null and b/dana-2.0/examples/Example G - FontBucket/Rsc/Resource.Frk/Starter.rsrc differ diff --git a/dana-2.0/examples/Example G - FontBucket/Rsc/Starter.rsrc b/dana-2.0/examples/Example G - FontBucket/Rsc/Starter.rsrc new file mode 100644 index 0000000..e69de29 diff --git a/dana-2.0/examples/Example G - FontBucket/Rsc/StarterRsc.h b/dana-2.0/examples/Example G - FontBucket/Rsc/StarterRsc.h new file mode 100644 index 0000000..5638dee --- /dev/null +++ b/dana-2.0/examples/Example G - FontBucket/Rsc/StarterRsc.h @@ -0,0 +1,40 @@ +// Header generated by Constructor for Palm OS (R) 1.6.2 +// +// Generated at 4:59:50 PM on Wednesday, April 10, 2002 +// +// Generated for file: C:\AS\Software\Hemingway\Sources\SDK\examples\Example G - FontBucket\Rsc\Starter.rsrc +// +// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE +// DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST +// +// Palm App Name: "" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) +#define MainInputField 1001 //(Left Origin = 0, Top Origin = 23, Width = 159, Height = 100, Usable = 1, Editable = 1, Underline = 1, Single Line = 0, Dynamic Size = 0, Left Justified = 1, Max Characters = 3000, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0) + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsFont 1000 // Command Key: F +#define MainOptionsAboutStarterApp 1001 + diff --git a/dana-2.0/examples/Example G - FontBucket/Src/Starter.c b/dana-2.0/examples/Example G - FontBucket/Src/Starter.c new file mode 100644 index 0000000..559f518 --- /dev/null +++ b/dana-2.0/examples/Example G - FontBucket/Src/Starter.c @@ -0,0 +1,526 @@ +/****************************************************************************** + * + * + * File: Starter.c + * + *****************************************************************************/ + +#include +#include "StarterRsc.h" + +#include "FontBucket.h" + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Structures + * + ***********************************************************************/ +typedef struct +{ + FmFontID fmListFontID; +} StarterPreferenceType; + +typedef struct +{ + UInt8 replaceme; +} StarterAppInfoType; + +typedef StarterAppInfoType* StarterAppInfoPtr; + + +/*********************************************************************** + * + * Global variables + * + ***********************************************************************/ +//static Boolean HideSecretRecords; + +static FmType FontBucketParams; +static FontID ListFont; + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'STRT' // register your own at http://www.palmos.com/dev/creatorid/ +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 + +// Define the minimum OS version we support (2.0 for now). +#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0) +#define kPalmOS10Version sysMakeROMVersion(1,0,0,sysROMStageRelease,0) + + +/*********************************************************************** + * + * Internal Functions + * + ***********************************************************************/ + + +/*********************************************************************** + * + * FUNCTION: RomVersionCompatible + * + * DESCRIPTION: This routine checks that a ROM version is meet your + * minimum requirement. + * + * PARAMETERS: requiredVersion - minimum rom version required + * (see sysFtrNumROMVersion in SystemMgr.h + * for format) + * launchFlags - flags that indicate if the application + * UI is initialized. + * + * RETURNED: error code or zero if rom is compatible + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags) +{ + UInt32 romVersion; + + // See if we're on in minimum required version of the ROM or later. + FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); + if (romVersion < requiredVersion) + { + if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) == + (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) + { + FrmAlert (RomIncompatibleAlert); + + // Palm OS 1.0 will continuously relaunch this app unless we switch to + // another safe one. + if (romVersion <= kPalmOS10Version) + { + AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); + } + } + + return sysErrRomIncompatible; + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void * GetObjectPtr(UInt16 objectID) +{ + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit(FormPtr frmP) +{ + RectangleType winRect; + Coord gapOnTextBottom; + RectangleType objectRect; + RectangleType originalFormRect; + RectangleType resizedFormRect; + FieldPtr textFieldPtr; + + FrmGetFormBounds(frmP, &originalFormRect); + + // INCREASE THE SIZE OF THE FORM TO MATCH SCREEN SIZE + winRect.topLeft.x = 0; + winRect.topLeft.y = 0; + // get the current screen size + WinGetDisplayExtent(&winRect.extent.x, &winRect.extent.y); + + // change the size of the form to match the screen size + WinSetWindowBounds(FrmGetWindowHandle(frmP), &winRect); + + FrmGetFormBounds(frmP, &resizedFormRect); + + // REPOSITION CONTROLS + // text input field (grow both x and y direction) + FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainInputField), &objectRect); + gapOnTextBottom = originalFormRect.extent.y - + (objectRect.topLeft.y + objectRect.extent.y); + objectRect.extent.x = resizedFormRect.extent.x; + objectRect.extent.y = resizedFormRect.extent.y - gapOnTextBottom - objectRect.topLeft.y; + FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainInputField), &objectRect); + + textFieldPtr = (FieldPtr) FrmGetObjectPtr(frmP, + FrmGetObjectIndex(frmP, MainInputField)); + FldSetFont (textFieldPtr, ListFont); + //FldDrawField (textFieldPtr); + + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, MainInputField)); + +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormPtr frmP; + FontID previousFontID; + FmFontID fmFontID; + Boolean fontChanged; + FieldPtr textFieldPtr; + + + switch (command) + { + case MainOptionsAboutStarterApp: + MenuEraseStatus(0); // Clear the menu status from the display. + frmP = FrmInitForm (AboutForm); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); + handled = true; + break; + + case MainOptionsFont: + { + frmP = FrmGetActiveForm(); + + FmGetFMFontID(&FontBucketParams, ListFont, &fmFontID); + fontChanged = FmSelectFont(&FontBucketParams, &fmFontID); + + if (fontChanged) + { + previousFontID = ListFont; + FmUseFont(&FontBucketParams, fmFontID, &ListFont); + + textFieldPtr = (FieldPtr) FrmGetObjectPtr(frmP, + FrmGetObjectIndex(frmP, MainInputField)); + FldSetFont (textFieldPtr, ListFont); + FldDrawField (textFieldPtr); + + FmFreeFont(&FontBucketParams, previousFontID); + + } + handled = true; + } + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + + switch (eventP->eType) + { + case keyDownEvent: + break; + + case menuEvent: + return MainFormDoCommand(eventP->data.menu.itemID); + + case frmOpenEvent: + frmP = FrmGetActiveForm(); + MainFormInit(frmP); + + FrmDrawForm ( frmP); + handled = true; + break; + + default: + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventPtr eventP) +{ + UInt16 formId; + FormPtr frmP; + + if (eventP->eType == frmLoadEvent) + { + // Load the form resource. + formId = eventP->data.frmLoad.formID; + frmP = FrmInitForm(formId); + FrmSetActiveForm(frmP); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) + { + case MainForm: + FrmSetEventHandler(frmP, MainFormHandleEvent); + break; + + default: +// ErrFatalDisplay("Invalid Form Load Event"); + break; + + } + return true; + } + + return false; +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + UInt16 error; + EventType event; + + do + { + EvtGetEvent(&event, evtWaitForever); + + if (! SysHandleEvent(&event)) + if (! MenuHandleEvent(0, &event, &error)) + if (! AppHandleEvent(&event)) + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value 0 if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + StarterPreferenceType prefs; + UInt16 prefsSize; + FmFontID fmFontID; + + FmInit(&FontBucketParams, kNoFontRangeSpecified, kNoFontRangeSpecified, false); + + + // Read the saved preferences / saved-state information. + prefsSize = sizeof(StarterPreferenceType); + if (PrefGetAppPreferences(appFileCreator, + appPrefID, &prefs, &prefsSize, true) == + noPreferenceFound) + { + FmGetFMFontID(&FontBucketParams, stdFont, &fmFontID); + FmUseFont(&FontBucketParams, fmFontID, &ListFont); + } + else + { + FmUseFont(&FontBucketParams, prefs.fmListFontID, &ListFont); + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppStop(void) +{ + StarterPreferenceType prefs; + FmFontID fmFontID; + + FmGetFMFontID(&FontBucketParams, ListFont, &fmFontID); + prefs.fmListFontID = fmFontID; + + // Write the saved preferences / saved-state information. This data + // will saved during a HotSync backup. + PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, + &prefs, sizeof (prefs), true); + + // Close all the open forms. + FrmCloseAllForms (); + + FmFreeFont (&FontBucketParams, ListFont); + FmClose(&FontBucketParams); + +} + + +/*********************************************************************** + * + * FUNCTION: StarterPalmMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags) +{ + Err error; + + error = RomVersionCompatible (ourMinVersion, launchFlags); + if (error) return (error); + + switch (cmd) + { + case sysAppLaunchCmdNormalLaunch: + error = AppStart(); + if (error) + return error; + + FrmGotoForm(MainForm); + AppEventLoop(); + AppStop(); + break; + + default: + break; + + } + + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + return StarterPalmMain(cmd, cmdPBP, launchFlags); +} diff --git a/dana-2.0/examples/ReadMe.txt b/dana-2.0/examples/ReadMe.txt new file mode 100644 index 0000000..cce9c18 --- /dev/null +++ b/dana-2.0/examples/ReadMe.txt @@ -0,0 +1 @@ +The following example projects were created with CodeWarrior 7 on the PC. They have been tested with CodeWarrior 8.3 on the PC, also. \ No newline at end of file diff --git a/dana-2.0/include/ASSubLaunch.h b/dana-2.0/include/ASSubLaunch.h new file mode 100644 index 0000000..383d928 --- /dev/null +++ b/dana-2.0/include/ASSubLaunch.h @@ -0,0 +1,85 @@ +/************************************************************************* + * + * Copyright (c) 2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: ASSubLaunch.h + * + * DESCRIPTION: AlphaSmart sub-launch parameter structure definitions. + * + ****************************************************************************/ + +#ifndef AS_SUB_LAUNCH_H +#define AS_SUB_LAUNCH_H + +//------------------------------------------------------------------------ +// AlphaSmart sub-launch parameter structure used to pass parameters to +// sub-launched AlphaSmart IrDA and USB text transfer utilities. +//------------------------------------------------------------------------ + +typedef struct +{ + // pointer to the first byte of the text to transfer to the host + UInt8 * pubText; + + // pointer to a null-terminated ASCII string of that is to be displayed + // as the name of the data being transferred to the host + // NOTE: if this string is too long, it will be truncated to fit. In + // the standard system font (FONT 0), approximately 30 characters will + // fit horizontally on the screen. + UInt8 * pubDisplayName; + + // flags that control the behavior of the sub-launched application + // for valid flag values, please see the "asSubLaunch..." + // #defines below + UInt32 ulFlags; + + // length, in bytes, of the text pointed to by "pubText." + UInt16 uwTextLength; + +} asSubLaunchTextTransferParms; + +typedef asSubLaunchTextTransferParms * asSubLaunchTextTransferParmsP; + +//---------------------------------------------------------------------- +// bitwise flag value constants for use in the "ulFlags" field of the +// asSubLanuchTextTransferParms structure +//---------------------------------------------------------------------- + +// This flag value indicates that no flags are set. The sub-launched +// application executes its default behavior. +// +#define asSubLaunchNoFlags (0x00000000) + +// This flag instructs sub-launched applications that normally wait for +// some user input before performing their function to perform that +// function without waiting. +// +// An example of this behavior is the USBEmu USB emulator and text +// transfer application. It normally waits in emulation mode for the +// user to press the "Send" key before transferring text to the host. +// If this flag is set, USBEmu transfers any text it was given when +// sub-launched without waiting for the user to press "Send." +// +#define asSubLaunchNoWaitToStart (0x00000001) + +// This flag instructs sub-launched applications that normally wait for +// some user input before exiting to exit as soon as their function is +// performed. +// +// An example of this behavior is the USBEmu USB emulator and text +// transfer application. Once it finishes sending any text it was +// sub-launched with to the host, it resumes emulation mode and does +// not return to its caller until the user presses a "Done" button. +// If this flag is set, USBEmu returns to its caller as soon as it +// has finished sending the text it was given. +// +#define asSubLaunchNoWaitToExit (0x00000002) + +// This value contains all of the as yet unused flag bits. This is used +// to validate the ulFlags field, i.e., none of the bits in this value +// may be set in a valid ulFlags field. +// +#define asSubLaunchUnusedFlags ( ~ ( asSubLaunchNoWaitToStart | \ + asSubLaunchNoWaitToExit ) ) +#endif diff --git a/dana-2.0/include/ASUSBPrint.h b/dana-2.0/include/ASUSBPrint.h new file mode 100644 index 0000000..386292a --- /dev/null +++ b/dana-2.0/include/ASUSBPrint.h @@ -0,0 +1,158 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: ASUSBPrint.h + * + * DESCRIPTION: AlphaSmart USB Printer Virtual Serial Driver header file. + * + ****************************************************************************/ + +#ifndef AS_USB_PRINT_H +#define AS_USB_PRINT_H + + +#include +#include + +// the port ID associated with the AlphaSmart printer virtual serial driver, +// i.e., the creator type for AlphaSmart printer interface. +#define sysPortUSBPrint 'ASpr' + +// error codes from the serial manager and their meaning with usb printing... +// from SrmOpen() +// serErrTimeOut - could not find any usb device. +// serErrNoDevicesAvail - could not find usb printer device. +// serErrNoMem - not enough memory. +// serErrAlreadyOpen - already opened. +// serErrBadPort - usb hardware not found or functioning. +// from SrmClose() +// serErrStillOpen - opened multiple times, and still open +// from SrmSend() +// serErrBadParam - serial manager is confused. +// serErrLineErr - printer disappeared from usb bus. +// from SrmControl +// serErrBadParam - pLen not passed in. +// serErrLineErr - usb error, could not complete request. + +/*** SrmControl "*valueLenP" Parameter Definitions **************************/ +// ------------------------------------------------------------------------------ +// Control codes when using SerialMgr to access USB specific stuff +// ------------------------------------------------------------------------------ +#define usbOpCodeGetManufacturerString srmCtlCustom+0 +#define usbOpCodeGetProductString srmCtlCustom+1 +#define usbOpCodeGetSerialNumString srmCtlCustom+2 +// for usbOpCodeGetManufacturerString, usbOpCodeGetProductString, usbOpCodeGetSerialNumString +// control call defines... +// Input: +// valueP = MemPtr to buffer for UNICODE string +// valueLenP = MemPtr to buffer length in bytes +// +// Output: +// valueP = MemPtr to filled in with UNICODE string +// valueLenP = MemPtr to number of bytes copied (will always be even) + +#define usbOpCodePrintGetDeviceID srmCtlCustom+3 +// Input: +// valueP = MemPtr to buffer for data +// valueLenP = MemPtr to buffer length in bytes - set to at least 512 bytes +// +// Output: +// valueP = MemPtr to filled in with data +// valueLenP = MemPtr to number of bytes read in. +// note that the data is proceeded with the length of the data in big endian format. + +#define usbOpCodePrintGetPortStatus srmCtlCustom+4 +// Input: +// valueP = MemPtr to byte to hold status bitfield... +// valueLenP = should be sizeof(UInt8) +// +// Output: +// valueP = MemPtr to byte, which now contains status - see following defines +// valueLenP = sizeof(UInt8) + #define usbOpCodePrintGetPortStatusBitEmptyPaper 0x20 // set if paper tray is empty + #define usbOpCodePrintGetPortStatusBitSelect 0x10 // set if printer is selected + #define usbOpCodePrintGetPortStatusBitNotError 0x08 // set if printer is NOT in error state + +#define usbOpCodePrintDoSoftReset srmCtlCustom+5 +// Input: pass NULLs +// Output: none. + +#define usbOpCodePrintGetInterfaceProtocol srmCtlCustom+6 +// Input: +// valueP = MemPtr to byte to hold interface protocol type +// valueLenP = should be sizeof(UInt8) +// +// Output: +// valueP = MemPtr to byte, which now contains interface protocol type - see following defines +// valueLenP = sizeof(UInt8) + #define usbOpCodePrintGetInterfaceProtocolUnidir 0x01 // set if paper tray is empty + #define usbOpCodePrintGetInterfaceProtocolBidir 0x02 // set if printer is selected + #define usbOpCodePrintGetInterfaceProtocolBidir1284 0x03 // set if printer is NOT in error state + + +// some sample code...with error handling omitted. +#if 0 +#include +#include "ASUSBPrint.h" + +static const UInt8 PrinterMessage[] = "Some text to send the printer.\r\n\f"; + +void OutputToPrinter(void) +{ + UInt16 vuwPortId = 0; + UInt16 vuwUniStringSize; + UInt16 vuwUniString[64]; + UInt8 vubInterfaceProtocol; + UInt8 vubPortStatus; + UInt8 bigBuffer[512]; + // Open the virtual port to the printer. + // At this time the printer is enumerated + // and an error is returned if a printer is + // not found. + err = SrmOpen(sysPortUSBPrint, 57600, &vuwPortId); + // Get the printer manufacturer length only - useful if + // you will allocate memory to save it. + vuwUniStringSize=0; + err = SrmControl(vuwPortId, usbOpCodeGetManufacturerString, NULL, &vuwUniStringSize); + + // Actually get the usb manufacturer id string. + err = SrmControl(vuwPortId, usbOpCodeGetManufacturerString, &vuwUniString, &vuwUniStringSize); + + // Get the product id string, assuming it will fit in 64 words. + vuwUniStringSize=64; + err = SrmControl(vuwPortId, usbOpCodeGetProductString, &vuwUniString, &vuwUniStringSize); + // Get the Serial number string... + vuwUniStringSize=64; + err = SrmControl(vuwPortId, usbOpCodeGetSerialNumString, &vuwUniString, &vuwUniStringSize); + + // Get the device id string. This string can be parsed for + // details about the printer + vuwUniStringSize=sizeof(bigBuffer); + err = SrmControl(vuwPortId, usbOpCodePrintGetDeviceID, bigBuffer, &vuwUniStringSize); + + // Get the port status.... + vuwUniStringSize=sizeof(UInt8); + err = SrmControl(vuwPortId, usbOpCodePrintGetPortStatus, &vubPortStatus, &vuwUniStringSize); + + // Reset the printer.. not needed here. + err = SrmControl(vuwPortId, usbOpCodePrintDoSoftReset, NULL, NULL); + + // Get the interface protocol type. + vuwUniStringSize=sizeof(UInt8); + err = SrmControl(vuwPortId, usbOpCodePrintGetInterfaceProtocol, &vubInterfaceProtocol, &vuwUniStringSize); + + // Send the print page here. + SrmSend(vuwPortId, + PrinterMessage, + sizeof( PrinterMessage )-1, + &err); + + SrmClose(vuwPortId); // close the port. + // this is important, as the power consumption drops, when the + // port is closed. +} +#endif + +#endif \ No newline at end of file diff --git a/dana-2.0/include/FontBucket.c b/dana-2.0/include/FontBucket.c new file mode 100644 index 0000000..1f9d3b7 --- /dev/null +++ b/dana-2.0/include/FontBucket.c @@ -0,0 +1 @@ +/*********************************************************************** FontBucket.c Purpose: FontBucket support file. Include this file in your project to support FontBucket. Copyright © 2000 Hands High Software All Rights Reserved The code in this file may be freely copied, distributed and used without compensation to Hands High Software, Inc. or its permission. API Version: 1.2 File Version: 1.21 History: 1.11 Modified _WhichFont per Joel Shafer to prevent returning a font of a different style. Added device check and type to FMType 1.20 Added Sony support items FB_SONY_SUPPORT. Changed HANDERA_SUPPORT to FB_HANDERA_SUPPORT Fix FmInit so that it looks for latest version of FB in case one is in ROM ************************************************************************/ #include "PalmOS.h" #include "FontBucket.h" #include "FntGlue.h" #ifdef FB_SONY_SUPPORT #include "SonyCLIE.h" #endif #ifdef FB_HANDERA_SUPPORT #include "VGA.h" #endif #define kLaunchFlags 0 #ifdef FB_HANDERA_SUPPORT #define kSysFontCount 8 #else #define kSysFontCount 4 #endif // private structures typedef struct { UInt16 version; UInt16 numberOfFonts; UInt16 fontIndex; UInt8 fontSize; UInt8 fromSublaunch; Err err; FmFontID fmFontId; FontID fontId; FontID first; FontID last; Char name[kMaxFontNameSize]; Char style[kMaxFontStyleSize]; MemHandle h; } FmParamType, *FmParamPtr; typedef struct { UInt32 first; UInt32 last; } FmInitParamType, *FmInitParamPtr; typedef struct { FontID font; char style[2]; // whatever the maximum size is for a system style string in all translations. Should be one character. See FontBucket.r } FontItemType, *FontItemPtr; // private statics #define systemFontMask 0xff000000L #define systemFontHiBit 0x80000000L // private functions static void _FmGetSystemFontInfo(FmPtr fmPtr, FontID fontId, char *name, char *style, UInt8 *fontSize, FmFontID *fmFontID); static Err _FmCallFontBucket(FmPtr fmPtr, FmLaunchCodes code, FmParamType *params); static FontID _WhichFont(FontItemPtr fntArray, UInt16 count, UInt16 size, const char *style, Boolean *exact); static FontID _FmToSystemFont(FmPtr fmPtr, FmFontID fmID); static FmFontID _FmToFmFont(FontID font); /*********************************************************************** FmInit Purpose: Initializes the FontManager. Call this once before using any fonts, probably in your startup code. This fuction initializes a table in the storage heap that stores mappings between FontIDs and fonts in the database. The maximum size that this table will require is 768 bytes of storage memory. Preconditions: Input: firstFont - the first font to use in the range of fonts defined. Many applications aleady use 128. 129 is used by FontHack, so if you use it and someone has FontHack installed, it may act strange. kDefaultFontStart is the lowest number you should use. Specify kDefaultFontStart to get the default minimum. Specify kNoFontRangeSpecified the default as well. lastFont - the last font to use in the range of fonts. the maximum is 255. Specify kDefaultFontMax to get the default max. Specify kNoFontRangeSpecified for no absolute range. Note that you MUST allocate a range of at least 3 fonts, and you are encouraged to allocate a range of more. Also, there is a bug in Palm OS's less than 3.5 that does not count custom fonts correctly. Our work-around requires that we never return the "lastFont" value that you specify, so take that into account too. Also note that Handera mapped its VGA system fonts to 0xE0 and above, so if you use font IDs in that range, you might write over the VGA fonts. fromSubLaunch - True if this is getting initialized from a sub-launched application. If you are initializing normally, set this to false. For the rare case when a sub-launched application makes use of FontBucket, the sub-launched app should set this to true. Output: fmPtr - pointer to the FmType struct. This struct is used for all subsequent calls. Treat it as a private token that you must pass to each FontBucket routine. Returns: errFontInvalidRange if firstFont and lastFont are not within the range of kDefaultFontStart to kDefaultFontMax or kNoFontRangeSpecified. ************************************************************************/ Err FmInit(FmPtr fmPtr, FontID firstFont, FontID lastFont, Boolean fromSubLaunch) { UInt32 value; FmParamType params; DmSearchStateType state; Err err = 0; err = FtrGet(sysFtrCreator, sysFtrNumEncoding, &value); if (value == charEncodingCP932){ // Japenese , double byte chars fmPtr->localID = 0; } else { params.first = firstFont; params.last = lastFont; params.fromSublaunch = fromSubLaunch; params.err = 0; params.version = kFontBucketVersion; // needs to be card independent, in case they put it on a Handspring card err = DmGetNextDatabaseByTypeCreator(true, &state, sysFileTApplication, 'FMGR', true, &fmPtr->card, &fmPtr->localID); fmPtr->device = fmStd; #ifdef FB_HANDERA_SUPPORT { UInt32 version; if (_TRGVGAFeaturePresent (&version)) { fmPtr->device = fmHandera; } } #endif #ifdef FB_SONY_SUPPORT { SonySysFtrSysInfoType *sonyInfo; if (FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonyInfo) == 0 && sonyInfo && (sonyInfo->libr & sonySysFtrSysInfoLibrHR) && (SysLibFind (sonySysLibNameHR, &fmPtr->sonyHiResLib) == 0)) { fmPtr->device = fmSony; } else { fmPtr->sonyHiResLib = 0; } } #endif if (!err) { err = _FmCallFontBucket (fmPtr, FmInitFontLaunchCode, ¶ms); } if (err != 0) { fmPtr->localID = 0; } } return err; } /* FmInit */ /*********************************************************************** FmSelectFont Purpose: Puts up the FontManager font dialog or the standard font dialog if the localID is 0. Preconditions: Input: fmPtr - FontBucket token (See FmInit) fmFontID - The previously selected Id, or kNoFmFontID (Initial value). This will be highlighted in the font selector dialog. Output: fmFontID - The newly selected font. Return: True - If the selectedID was changed False - If the selectedID stayed the same ************************************************************************/ Boolean FmSelectFont (FmPtr fmPtr, FmFontID* fmFontId) { UInt32 originalFontID; Boolean changed = false; FmParamType params; Err err; Boolean isInSonyHiRes = false; #ifdef FB_SONY_SUPPORT if (fmPtr->sonyHiResLib) { UInt32 width, height, depth; Boolean color; HRWinScreenMode (fmPtr->sonyHiResLib, winScreenModeGet, &width, &height, &depth, &color); if (width == 320) { isInSonyHiRes = true; } } #endif originalFontID = *fmFontId; if (fmPtr->localID #ifdef FB_SONY_SUPPORT && !(isInSonyHiRes && fmPtr->preventSonyHiRes) // FB will work in hi res mode if the app is ready for it #endif ) { params.fmFontId = *fmFontId; params.version = kFontBucketVersion; params.err = 0; err = _FmCallFontBucket (fmPtr, FmSelectFontLaunchCode, ¶ms); if (!err) { *fmFontId = params.fmFontId; if (originalFontID != *fmFontId) { changed = true; } } } else { FontID sysFontId; #ifdef FB_SONY_SUPPORT if (isInSonyHiRes && fmPtr->preventSonyHiRes) { isInSonyHiRes = false; } if (isInSonyHiRes) { sysFontId = (FontID) HRFontSelect (fmPtr->sonyHiResLib, (hrFontID)_FmToSystemFont (fmPtr, *fmFontId)); } #endif if (!isInSonyHiRes) { sysFontId = FontSelect(_FmToSystemFont (fmPtr, *fmFontId)); } *fmFontId = _FmToFmFont(sysFontId); if (originalFontID != *fmFontId) { changed = true; } } return changed; } /* FmSelectFont */ /*********************************************************************** FmUseFont Purpose: Returns a unique FontID that is mapped to the FmFontId passed in. It also allocates locks the font down in memory. Preconditions: Input: fmPtr - FontBucket token. (See FmInit) fmFontId - obtained from the FmSelectFont call or some other call. This id will be mapped to the returned FontID in the table that was created by the FmInit call. Output: fontID ( call FntSetFont with this fontID ) Returns: Error if the function failed. Might return errFontTableOutOfSlots if you have used more fonts than our available without calling FmFreeFont on them. You can use a maximum of 126 fonts at any one time. Also dmErrUniqueIdNotFound resulting if the FmFontId could not be found. ************************************************************************/ Err FmUseFont(FmPtr fmPtr, FmFontID fmFontId, FontID *fontID) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.fmFontId = fmFontId; params.fontId = FntGlueGetDefaultFontID(defaultSmallFont); params.err = 0; params.version = kFontBucketVersion; *fontID = FntGlueGetDefaultFontID(defaultSmallFont); err = _FmCallFontBucket (fmPtr, FmUseFontLaunchCode, ¶ms); if (!err) { *fontID = params.fontId; } } else { *fontID = _FmToSystemFont (fmPtr, fmFontId); } return err; } /* FmUseFont */ /*********************************************************************** FmFreeFont Purpose: Free's a font from the FmUseFont's internal table of active fonts. You must call this on every font you use before exiting the application. Don't free a font that is in use. In particular, if a field is using the font, don't free it, even if you never draw the field again, because when the field gets deallocated, the system tries to validate it, and the font change could cause the validation code to crash. The right thing to do is to set the field's font to some other font before freeing the font. Preconditions: Input: fmPtr - FontBucket token. (See FmInit) fontId - the FontID you wish to free ( obtained using FmUseFont ) Output: none Returns: Error. dmErrUniqueIdNotFound resulting if the FmFontId could not be found. ************************************************************************/ Err FmFreeFont(FmPtr fmPtr, FontID fontId) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.err = 0; params.fontId = fontId; params.version = kFontBucketVersion; err = _FmCallFontBucket (fmPtr, FmFreeFontLaunchCode, ¶ms); } return err; } /* FmFreeFont */ /*********************************************************************** FmClose Purpose: Frees memory allocated for the font table during FmInit. If you do not call FmFreeFont on each font, it will return an error, but will still free the memory. Call this function when your application quits. Preconditions: Input: fmRetPtr - Holds any error generated by this call. (See FmInit) Possible Error : errFontNotFree resulting if the fonts use count and free count do not match. Output: none Returns: none ************************************************************************/ Err FmClose (FmPtr fmPtr) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.err = 0; params.version = kFontBucketVersion; err = _FmCallFontBucket (fmPtr, FmCloseLaunchCode, ¶ms); } return err; } /* FmClose */ /*********************************************************************** FmValidFont Purpose: Determines if the given id is still vaild ( does it still exist on the device ). You can call this during your startup code, to verify that the font you saved from the previous user session is still a valid font. Note that if for some reason FontBucket gets removed by the user, this will always return valid, because any saved FmFontIDs will be converted to stdFont in this case. Preconditions: none Input: fmPtr - Input token. (See FmInit) fmFontId - the FontID to be validated Output: none Returns: Error. Possible Error: dmErrUniqueIdNotFound resulting if the FmFontId could not be found. ************************************************************************/ Err FmValidFont(FmPtr fmPtr, FmFontID fmFontId) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.err = 0; params.fmFontId = fmFontId; params.version = kFontBucketVersion; err = _FmCallFontBucket (fmPtr, FmValidateFontLaunchCode, ¶ms); } return 0; } /* FmValidFont */ /*********************************************************************** FmFontName Purpose: A convience method to retrieve the name of the font for a specific id. Preconditions: Input: fmPtr - FontBucket token. (See FmInit) id - the selectedId obtained from ( FmSelectFont ) name - a pointer to the buffer to hold the name of the font. Allocate at least kMaxFontName bytes. Output: none Returns: Error if an error occurred. ************************************************************************/ Err FmFontName (FmPtr fmPtr, FmFontID fmFontId, Char *name) { FmParamType params; Err err = 0; FontID fontId; *name = 0; if (fmPtr->localID) { params.err = 0; params.fmFontId = fmFontId; params.version = kFontBucketVersion; err = _FmCallFontBucket (fmPtr, FmNameLaunchCode, ¶ms); if (!err) { StrCopy(name, params.name); } } else { fontId = _FmToSystemFont (fmPtr, fmFontId); _FmGetSystemFontInfo (fmPtr, fontId, name, NULL, NULL, NULL); } return err; } /* FmFontName */ /*********************************************************************** FmGetFMFontIdFromName Purpose: A convience method to retrieve the selectedID of the font for a specific name. If the font is not found, the closest possible font will by found using the following algorithm and errFontNotFound will be returned: 1) If fonts matching the name (not case sensitive) exist, it will choose one of those fonts. Otherwise it will select a system font. 2) If it can then find fonts with matching sizes, it will choose one of those fonts. Otherwise, it will attempt to find a font that is larger. If no larger font exists, it will find one smaller. 3) It will then try to find a font with a matching style. If none exists, it will match the first one it comes to, which would be the plain version of the font if one exists. Preconditions: none Input: fmPtr - FontBucket token. (See FmInit) name - a pointer to the NULL terminated string style - a style, set to NULL to ignore size - the pixel size, if you need to match by pixel size too. Set to zero to ignore. Note, to search by style, you must also specify a size. If you specify a size of 0, the style will be ignored and only the name will be matched with the first occurrence of that name. Output: fmFontID - the corresponding fmFontID, or zero if none matces. Returns: errFontNotFound if not found. A different error if some other problem happens. ************************************************************************/ Err FmGetFMFontIdFromName (FmPtr fmPtr, const Char *name, FmFontID* fmFontId, const Char* style /* = NULL */, UInt16 size /* = 0 */) { FmParamType params; Err err = 0; Char fontString[kMaxFontNameSize]; if (fmPtr->localID) { params.err = 0; StrCopy (params.name, name); *fmFontId = 0; params.version = kFontBucketVersion; params.fontSize = size; params.err = 0; if (style) { StrCopy (params.style, style); } else { params.style[0] = 0; } err = _FmCallFontBucket (fmPtr, FmIdLaunchCode, ¶ms); *fmFontId = params.fmFontId; // even if there is an error, it will return something close return err; } else { FontID font; Boolean matched, exact; FontItemType fnt[kSysFontCount]; // match a system font SysCopyStringResource (fontString, PalmFontNameString); matched = (StrCaselessCompare (name, fontString) == 0); if (size == 0) { // don't check the size, just return first font font = stdFont; *fmFontId = _FmToFmFont(font); if (matched) { return 0; } else { return errFontNotFound; } } else { fnt[0].font = stdFont; fnt[0].style[0] = 0; fnt[1].font = boldFont; SysCopyStringResource (fnt[1].style, BoldStyleString); fnt[2].font = largeFont; fnt[2].style[0] = 0; fnt[3].font = largeBoldFont; SysCopyStringResource (fnt[3].style, BoldStyleString); #ifdef FB_HANDERA_SUPPORT // Handera fonts are just system fonts, so we use the same font name fnt[4].font = VgaBaseToVgaFont(stdFont); fnt[4].style[0] = 0; fnt[5].font = VgaBaseToVgaFont(boldFont); SysCopyStringResource (fnt[5].style, BoldStyleString); fnt[6].font = VgaBaseToVgaFont(largeFont); fnt[6].style[0] = 0; fnt[7].font = VgaBaseToVgaFont(largeBoldFont); SysCopyStringResource (fnt[7].style, BoldStyleString); #endif font = _WhichFont (fnt, kSysFontCount, size, style, &exact); *fmFontId = _FmToFmFont(font); if (matched && exact) { return 0; } else { return errFontNotFound; } } // else } // else } /* FmGetFMFontIdFromName */ /*********************************************************************** _WhichFont Purpose: Chooses between the fonts in array, trying to match the given parameters. Returns the closest font matched. Also returns true in exact if an exact match was found. Preconditions: The font array is ordered smallest to largest. Also, you must have at least one item in the array. Input: fnt Array of font descriptions count Number of items in the array size Size to match style Style to match...uses the first character to do the match Output: exact Whether the chosen font was an exact match Returns: font The fontID chosen from the font array ************************************************************************/ static FontID _WhichFont(FontItemPtr fnt, UInt16 count, UInt16 size, const char *style, Boolean *exact) { //Tries to match the requested font //returns the font with the nearest size that has the matching style UInt16 firstOfSize = 0, foundSize = 0, i; FontID oldFont; UInt16 compareSize; Boolean matchedSize = false, matchedStyle = false; for (i = 0; i < count; i++) { if (fnt[i].font == largeFont) { compareSize = 12; // hardcode this value, because largeBoldFont is a 12 point, and we want them to match } else { oldFont = FntSetFont (fnt[i].font); compareSize = FntBaseLine(); FntSetFont (oldFont); } if (compareSize > size) { break; } else if(style[0] == fnt[i].style[0]) { // assume we only need to match first char //Style *MUST* match foundSize=compareSize; firstOfSize = i; } } *exact=(foundSize==size); return fnt[firstOfSize].font; } /* _WhichFont */ /*********************************************************************** FmGetFMFontID Purpose: A convience method to retrieve the selectedId. ( see FmUseFont ) Preconditions: Input: fmPtr - (See FmInit) fontID - a valid fontID . Output: fmFontID The corresponding FmFontID Returns: Error ************************************************************************/ Err FmGetFMFontID(FmPtr fmPtr, FontID fontID, FmFontID* fmFontId) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.fontId = fontID; params.err = 0; params.version = kFontBucketVersion; err = _FmCallFontBucket (fmPtr, FmFontIdLaunchCode, ¶ms); if (!err) { *fmFontId = params.fmFontId; } } else { *fmFontId = _FmToFmFont(fontID); } return err; } /* FmGetFMFontID */ /*********************************************************************** FmGetFontCount Purpose: A convenience method for retreiving the number of valid fonts availiable. Preconditions: Input: fmPtr - (See FmInit) Output: none Returns: none ************************************************************************/ UInt16 FmGetFontCount(FmPtr fmPtr) { FmParamType params; Err err; if (fmPtr->localID) { params.err = 0; params.numberOfFonts = 0; err = _FmCallFontBucket (fmPtr, FmNumberOfFontsLaunchCode, ¶ms); if (err != 0) { params.numberOfFonts = 0; } } else { params.numberOfFonts = 4; #ifdef FB_HANDERA_SUPPORT if (fmPtr->device == fmHandera) { params.numberOfFonts = 8; } #endif } return params.numberOfFonts; } /* FmGetFontCount */ /*********************************************************************** FmGetIndexedFontInfo Purpose: A convience method for obtaining info on a particular font. Use in conjunction with FmGetFontCount to iterate through all valid fonts. Preconditions: Input: fmPtr - (See FmInit) index - the index of the font fontName - the name of the font. Pass NULL if you do not want to retreive this value. fontSize - the pt. size of the font. Pass NULL if you do not want to retreive this value. fmFontID - the fmFontID for this font. Pass NULL if you do not want to retreive this value. Output: none Returns: Error ************************************************************************/ Err FmGetIndexedFontInfo(FmPtr fmPtr, UInt16 index, Char* fontName, Char* fontStyle, UInt8 *fontSize, FmFontID *fmFontID) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.err = 0; params.fontIndex = index; err = _FmCallFontBucket (fmPtr, FmInfoLaunchCode, ¶ms); if (!err) { if (fontSize) { *fontSize = params.fontSize; } if (fmFontID) { *fmFontID = params.fmFontId; } if (fontName) { StrCopy (fontName, params.name); } if (fontStyle) { StrCopy (fontStyle, params.style); } } } else { switch (index){ case 0: _FmGetSystemFontInfo (fmPtr, stdFont, fontName, fontStyle, fontSize, fmFontID); break; case 1: _FmGetSystemFontInfo (fmPtr, boldFont, fontName, fontStyle, fontSize, fmFontID); break; case 2: _FmGetSystemFontInfo (fmPtr, largeFont, fontName, fontStyle, fontSize, fmFontID); break; case 3: _FmGetSystemFontInfo (fmPtr, largeBoldFont, fontName, fontStyle, fontSize, fmFontID); break; default: #ifdef FB_HANDERA_SUPPORT if (fmPtr->device == fmHandera) { switch (index) { case 4: _FmGetSystemFontInfo (fmPtr, VgaBaseToVgaFont(stdFont), fontName, fontStyle, fontSize, fmFontID); break; case 5: _FmGetSystemFontInfo (fmPtr, VgaBaseToVgaFont(boldFont), fontName, fontStyle, fontSize, fmFontID); break; case 6: _FmGetSystemFontInfo (fmPtr, VgaBaseToVgaFont(largeFont), fontName, fontStyle, fontSize, fmFontID); break; case 7: _FmGetSystemFontInfo (fmPtr, VgaBaseToVgaFont(largeBoldFont), fontName, fontStyle, fontSize, fmFontID); break; } } #endif break; } } return err; } /* FmGetIndexedFontInfo */ /*********************************************************************** FmGetFontInfo Purpose: Return information about the given font Preconditions: Input: fmPtr Font info block fmFontID The font to find the info on Output: fontName The name of the font, NULL to ignore fontStyle The style of the font, NULL to ignore fontSize The size of the font, NULL to ignore Returns: none ************************************************************************/ Err FmGetFontInfo(FmPtr fmPtr, FmFontID fmFontID, Char* fontName, Char *fontStyle, UInt8 *fontSize) { FmParamType params; Err err = 0; if (fmPtr->localID) { params.err = 0; params.fmFontId = fmFontID; StrCopy (params.name, fontName); err = _FmCallFontBucket (fmPtr, FmInfoByIDLaunchCode, ¶ms); if (!err) { if (fontSize) { *fontSize = params.fontSize; } if (fontName) { StrCopy (fontName, params.name); } if (fontStyle) { StrCopy (fontStyle, params.style); } } } else { FontID font = _FmToSystemFont (fmPtr, fmFontID); _FmGetSystemFontInfo (fmPtr, font, fontName, fontStyle, fontSize, NULL); } return err; } /* FmGetFontInfo */ /*********************************************************************** FmGetFamilyNames Purpose: Return a handle that contains a packed string of all the font family names in alphabetic order. Preconditions: Input: fmPtr FontManager structure Output: none Returns: Newly created handle that contains the strings. This handle may be in storage memory and it is up to you to free it. NULL if there was an error such that the handle could not even be created. An incomplete list may be returned if memory runs out half way. ************************************************************************/ MemHandle FmGetFamilyNames(FmPtr fmPtr) { MemHandle hRet = NULL; FmParamType params; Err err; if (fmPtr->localID) { params.err = 0; err = _FmCallFontBucket (fmPtr, FMFaceListLaunchCode, ¶ms); if (!err) { hRet = params.h; } } else { char buf[10]; char *p; SysCopyStringResource (buf, PalmFontNameString); // no FontBucket installed. hRet = MemHandleNew (StrLen (buf) + 1); if (hRet) { p = (char*)MemHandleLock (hRet); StrCopy (p, buf); MemHandleUnlock (hRet); } } return hRet; } /* FmGetFamilyNames */ /*********************************************************************** _FmGetSystemFontInfo Purpose: Retrieves info for a system font. Does it without calling into FontBucket. Preconditions: Input: fmPtr FontManager structure fontID font to find the info for Output: name Name of font style Style of font fontSize Size of font fmFontID fmFontID Returns: none ************************************************************************/ static void _FmGetSystemFontInfo(FmPtr fmPtr, FontID fontId, char *name, char *style, UInt8 *fontSize, FmFontID *fmFontID) { FontID oldFont; if (fontSize) { oldFont = FntSetFont (fontId); *fontSize = FntBaseLine(); FntSetFont (oldFont); } if (fmFontID) { *fmFontID = _FmToFmFont(fontId); } if (style) { style[0] = 0; // start with empty string } if (name) { switch (fontId){ case boldFont: case largeBoldFont: if (style) { SysCopyStringResource (style, BoldStyleString); } //break; drop through to next case case stdFont: case largeFont: SysCopyStringResource (name, PalmFontNameString); break; default: #ifdef FB_HANDERA_SUPPORT if (fmPtr->device == fmHandera) { SysCopyStringResource (name, VGAFontNameString); if (fontId == VgaBaseToVgaFont (boldFont) || fontId == VgaBaseToVgaFont (largeBoldFont)) { SysCopyStringResource (style, BoldStyleString); } } #endif break; } } } /* _FmGetSystemFontInfo */ /*********************************************************************** _FmCallFontBucket Purpose: Calls into FontBucket. Putting this code here reduces redundancy and makes the footprint smaller. Preconditions: Input: none Output: none Returns: none ************************************************************************/ static Err _FmCallFontBucket(FmPtr fmPtr, FmLaunchCodes code, FmParamType *params) { Err err; UInt32 result; err = SysAppLaunch(fmPtr->card, fmPtr->localID, kLaunchFlags, code, params, &result); if (err != 0) { return err; } else if (result != 0) { return result; } else if (params->err != 0) { return params->err; } return 0; } /* _FmCallFontBucket */ /*********************************************************************** _FmToSystemFont Purpose: Convert an FmFontID to FontID. Deals with Handera's system fonts, which maps VGA fonts to 0xE0 and above (OOOPS!). Our solution is to invert the high bit. This will prevent the system from being able to issue a font ID of 0x80 (which it better NOT do, since that at a minimum is reserved for applications.) Preconditions: Input: fmFontID The fmFontID Output: none Returns: FontID equivalent. ************************************************************************/ static FontID _FmToSystemFont(FmPtr fmPtr, FmFontID fmFontID) { FontID font; if (fmFontID & systemFontMask) { font = (FontID)(((fmFontID ^ systemFontHiBit) & systemFontMask) >> 24); } else { // this is a font bucket font, so just return the standard system font font = FntGlueGetDefaultFontID(defaultSmallFont); #ifdef FB_HANDERA_SUPPORT if (fmPtr->device == fmHandera) { font = VgaBaseToVgaFont (font); } #endif } return font; } /* _FmToSystemFont */ /*********************************************************************** _FmToFmFont Purpose: Convert a system font to an FmFontID. Preconditions: Input: FontID Output: none Returns: FmFontID ************************************************************************/ static FmFontID _FmToFmFont(FontID font) { return (((UInt32)font) << 24) ^ systemFontHiBit; } /* _FmToFmFont */ \ No newline at end of file diff --git a/dana-2.0/include/FontBucket.h b/dana-2.0/include/FontBucket.h new file mode 100644 index 0000000..4f22e67 --- /dev/null +++ b/dana-2.0/include/FontBucket.h @@ -0,0 +1,242 @@ +/*********************************************************************** + +FontBucket.h + +Purpose: Include this header file in any source files that work + with FontBucket. FontBucket enables you to easily include + custom fonts in your application, and allow users to + pick their own fonts from popular font collections. + +Copyright © 2000 Hands High Software +All Rights Reserved + +The code in this file may be freely copied, distributed and used without +compensation to Hands High Software, Inc. or its permission. + + +API Version: 1.2 + +File Version: 1.11 + +See FontBucket.c for history + +************************************************************************/ + + +#ifndef _FONTBUCKET_H_ +#define _FONTBUCKET_H_ + +#include "ErrorBase.h" + +// The following version number gets incremented whenever an API change happens that +// requires the user to install a new version of FontBucket. If an older version is +// detected, FmInit will return errFontObsoleteFBVersion and FontBucket will act as +// if it was not installed. + +#define kFontBucketVersion 2 + + +#define PalmFontNameString 9500 +#define VGAFontNameString 9504 +#define BoldStyleString 9550 + +#define kMaxFontNameSize 64 // 63 + null +#define kMaxFontStyleSize 32 // 31 + null +#define kFontBucketNotInstalled 0 + +#define kDefaultFontStart ((FontID)fntAppFontCustomBase + ((FontID) 2)) +#define kDefaultFontMax ((FontID)255) +#define kNoFontRangeSpecified ((FontID)0) + +#define kNoFmFontID ((FmFontID)0) + +#define errFontTableOutOfSlots ((Err)(appErrorClass | 0x01)) +#define errFontNotFree ((Err)(appErrorClass | 0x02)) +#define errFontNotFound ((Err)(appErrorClass | 0x03)) +#define errFontInvalidRange ((Err)(appErrorClass | 0x04)) +#define errFontBucketNotInitialized ((Err)(appErrorClass | 0x05)) +#define errFontIndexInvalid ((Err)(appErrorClass | 0x06)) +#define errFontInvalidFmFontID ((Err)(appErrorClass | 0x07)) +#define errFontObsoleteFBVersion ((Err)(appErrorClass | 0x08)) +#define errFontBadFontData ((Err)(appErrorClass | 0x09)) + +typedef UInt32 FmFontID; + +typedef enum { + FmInitFontLaunchCode = sysAppLaunchCmdCustomBase, + FmSelectFontLaunchCode, + FmUseFontLaunchCode, + FmValidateFontLaunchCode, + FmFreeFontLaunchCode, + FmCloseLaunchCode, + FmNameLaunchCode, + FmIdLaunchCode, + FmFontIdLaunchCode, + FmNumberOfFontsLaunchCode, + FmInfoLaunchCode, + FmInfoByIDLaunchCode, + FMFaceListLaunchCode, + FMDrawModeLaunchCode +} FmLaunchCodes; + +typedef enum { + fmStd, + fmHandera, + fmSony +} FMDeviceType; + +typedef struct { + UInt16 card; + LocalID localID; + FMDeviceType device; +#ifdef FB_SONY_SUPPORT + UInt16 sonyHiResLib; // sony hi res lib, if present + Boolean preventSonyHiRes; // uses the standard OS selector when on a Sony AND the screen is in hi-res mode +#endif +} FmType, *FmPtr; + +#if __cplusplus +extern "C" { +#endif + +Err FmInit(FmPtr fmPtr, FontID firstFont, FontID lastFont, Boolean fromSubLaunch); +Boolean FmSelectFont (FmPtr fmPtr, FmFontID* fmFontId); +Err FmUseFont(FmPtr fmPtr, FmFontID fmFontId, FontID *fontID); +Err FmFreeFont(FmPtr fmPtr, FontID fontID); +Err FmClose (FmPtr fmPtr); +Err FmValidFont(FmPtr fmPtr, FmFontID fmFontId); +Err FmFontName (FmPtr fmPtr, FmFontID fmFontId, Char *name); +Err FmGetFMFontIdFromName (FmPtr fmPtr, const Char *name, FmFontID* fmFontId, const Char* style, UInt16 size); +Err FmGetFMFontID(FmPtr fmPtr, FontID fontID, FmFontID* fmFontId); +UInt16 FmGetFontCount(FmPtr fmPtr); +Err FmGetIndexedFontInfo(FmPtr fmPtr, UInt16 index, Char* fontName, Char *fontStyle, + UInt8 *fontSize, FmFontID *fmFontID); +Err FmGetFontInfo (FmPtr fmPtr, FmFontID fmFontID, Char* fontName, Char *fontStyle, UInt8 *fontSize); +MemHandle FmGetFamilyNames (FmPtr fmPtr); + +// Return true if FontBucket is installed +// Normally, you shouldn't need to call this, since the API works whether or not +// FontBucket is installed. However, if you need to know for some reason, call this after +// calling FmInit. +__inline Boolean FmIsInstalled (FmPtr fmPtr) { + return fmPtr->localID != 0; +} + +#ifdef FB_SONY_SUPPORT + +// Prevent FontBucket from working when in sony hi-res mode. +// This is useful if the user forces hi-res assist mode and your app doesn't handle that, +// or you only want to use standard fonts in hi-res mode, since Sony can't handle custom fonts +// in fields or form objects when in hi-res mode. +// default is off. + +__inline void FmPreventSonyHiRes (FmPtr fmPtr, Boolean prevent) { + fmPtr->preventSonyHiRes = prevent; +} + +__inline Boolean FmIsSonyHiResPrevented (FmPtr fmPtr) { + return fmPtr->preventSonyHiRes; +} + +#endif + +#if __cplusplus +} +#endif + + +#ifdef __cplusplus +// c++ implementation of the fontbucket interface + +class FontBucket { +protected: + FmType m_params; + +public: + FontBucket () { + m_params.card = 0; + m_params.localID = 0; + } + ~FontBucket () { } // need to explicitly close + + Err init (FontID first = kNoFontRangeSpecified, + FontID last = kNoFontRangeSpecified, + Boolean fromSubLaunch = false) { + return FmInit (&m_params, first, last, fromSubLaunch); + } + + Err close (void) { + return FmClose (&m_params); + } + + Boolean isInstalled (void) { + return FmIsInstalled (&m_params); + } + + Boolean select (FmFontID *fmFontId) { + return FmSelectFont (&m_params, fmFontId); + } + + Err use (FmFontID fmFontId, FontID *fontID) { + return FmUseFont(&m_params, fmFontId, fontID); + } + + Err free (FontID fontID) { + return FmFreeFont(&m_params, fontID); + } + + Err valid (FmFontID fmFontId) { + return FmValidFont(&m_params, fmFontId); + } + + Err name (FmFontID fmFontId, Char *name) { + return FmFontName (&m_params, fmFontId, name); + } + + Err id (const Char *name, FmFontID* fmFontId, const Char* style = NULL, UInt16 size = 0) { + return FmGetFMFontIdFromName (&m_params, name, fmFontId, style, size); + } + + Err id (FontID fontID, FmFontID* fmFontId) { + return FmGetFMFontID (&m_params, fontID, fmFontId); + } + + UInt16 getFontCount(void) { + return FmGetFontCount(&m_params); + } + + Err getIndexedFontInfo(UInt16 index, + Char * fontName, + Char* fontStyle, + UInt8 *fontSize, + FmFontID *fmFontID) { + return FmGetIndexedFontInfo(&m_params, index, fontName, fontStyle, fontSize, fmFontID); + } + + Err info (FmFontID fmFontId, Char * fontName, + Char* fontStyle, + UInt8 *fontSize) { + return FmGetFontInfo(&m_params, fmFontId, fontName, fontStyle, fontSize); + } + + MemHandle familyNames (void) { + return FmGetFamilyNames (&m_params); + } + +#ifdef FB_SONY_SUPPORT + void preventSonyHiRes (Boolean prevent) { + FmPreventSonyHiRes (&m_params, prevent); + } + + Boolean isSonyHiResPrevented (void) { + return FmIsSonyHiResPrevented(&m_params); + } +#endif + + + +}; + +#endif // _cplusplus + +#endif // _FONTBUCKET_H_ \ No newline at end of file diff --git a/dana-2.0/include/FontBucket.r b/dana-2.0/include/FontBucket.r new file mode 100644 index 0000000..8c6318d --- /dev/null +++ b/dana-2.0/include/FontBucket.r @@ -0,0 +1 @@ +#ifndef alertType #include "UIResDefs.r" #endif resource 'tSTR' (9500, "System") { "Palm OS" /* Palm name */ }; resource 'tSTR' (9550, "Bold") { "B" /* String to represent the BOLD setting */ }; resource 'tSTR' (9504, "VGA Font Name") { "Palm OS" /* To the user, this is a built-in font, so map to the same name */ }; \ No newline at end of file diff --git a/dana-2.0/include/KeyboardAccess.h b/dana-2.0/include/KeyboardAccess.h new file mode 100644 index 0000000..e101b25 --- /dev/null +++ b/dana-2.0/include/KeyboardAccess.h @@ -0,0 +1,112 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: KeyboardAccess.h + * + * DESCRIPTION: This file contains the API to the keyboard related functions. + * + ****************************************************************************/ +#ifndef KEYBOARDACCESS_H +#define KEYBOARDACCESS_H + +#include "WideTallApp.h" +#include "WideTallAppChars.h" + +#define WTAPKeyboardAccessFtrNum 10 + +/*--------------------------------------------------------------------------- + * Check whether US or ISO keyboard is on the Dana + *--------------------------------------------------------------------------*/ +typedef enum +{ + kybdTypeUS = 1, + kybdTypeISO +} KeyboardKeyType; + +#define KeyboardTypeFtrNum 14 + +#define _KybdType(keyboardType) \ + (Boolean)(FtrGet(AlphaSmartSysFtrID, KeyboardTypeFtrNum, keyboardType) == 0) + + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ +typedef enum +{ + kybdLayoutQwerty = 0, + kybdLayoutDvorak, + kybdLayoutLeft, + kybdLayoutRight +} KeyboardLayoutType; + +/*--------------------------------------------------------------------------- + * Extension Installed + *--------------------------------------------------------------------------*/ +#define _KybdFeaturePresent(version) \ + (Boolean)(FtrGet(AlphaSmartSysFtrID, WTAPKeyboardAccessFtrNum, version) == 0) + +/*--------------------------------------------------------------------------- + * KeyboardAccess API result codes + *--------------------------------------------------------------------------*/ +#define kybdErrorClass (oemErrorClass | 0x800) +#define kybdErrBadParam (kybdErrorClass | 0) // invalid parameter + + +#ifdef __cplusplus +extern "C" { +#endif + +#define kybdMinFunction 0x0800 + +#define kybdGetLayout (kybdMinFunction + 0) +#define kybdGetModifiers (kybdMinFunction + 1) +#define kybdGetKeyboardEmulation (kybdMinFunction + 2) +#define kybdSetKeyboardEmulation (kybdMinFunction + 3) + +#define kybdLastFunction (kybdSetKeyboardEmulation) + +/******************************************************************** + * Keyboard Access API Prototypes + ********************************************************************/ + +/*--------------------------------------------------------------------------- + * Get the current layout of the keyboard. + * Note: All non US versions will return kybdLayoutQwerty. + *--------------------------------------------------------------------------*/ +extern KeyboardLayoutType KybdGetLayout(void) + EXTERNAL_TRAP(kybdGetLayout); + +/*--------------------------------------------------------------------------- + * Get the current state of the keyboard modifiers. + * Caps lock, Right shift, Left shift, Right shift, Option/Alt/Function, Cmd + * Upper 8 bits of the event represent the modifiers. + * Look for the bit definitions in WideTallAppChars.h such as: + * KEYBOARD_MODIFIER_COMMAND + *--------------------------------------------------------------------------*/ +extern KeyboardEvent KybdGetModifiers(void) + EXTERNAL_TRAP(kybdGetModifiers); + +/*--------------------------------------------------------------------------- + * Get the current state of keyboard enable. + * For system use only. + *--------------------------------------------------------------------------*/ +extern Boolean KybdGetKeyboardEmulation(void) + EXTERNAL_TRAP(kybdGetKeyboardEmulation); + +/*--------------------------------------------------------------------------- + * Set the keyboard enable value. + * For system use only. + *--------------------------------------------------------------------------*/ +extern void KybdSetKeyboardEmulation(Boolean value) + EXTERNAL_TRAP(kybdSetKeyboardEmulation); + + +#ifdef __cplusplus +} +#endif + + +#endif // KEYBOARDACCESS_H diff --git a/dana-2.0/include/Screen.h b/dana-2.0/include/Screen.h new file mode 100644 index 0000000..c0a937d --- /dev/null +++ b/dana-2.0/include/Screen.h @@ -0,0 +1,140 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: Screen.h + * + * DESCRIPTION: This file contains the API to the screen. + * + ****************************************************************************/ + +#ifndef __SCREEN_H__ +#define __SCREEN_H__ + +#include "WideTallApp.h" + +#define ScrnFtrNum 2 + +/*-------------------------------------------------------------------------- + * Screen result codes + * (oemErrorClass is reserved for Palm licensees). + *-------------------------------------------------------------------------*/ +#define scrnErrorClass (oemErrorClass | 0x200) + +#define scrnErrUnimplemented (scrnErrorClass | 0) // function not implemented (on this hardware) +#define scrnErrBadParam (scrnErrorClass | 1) // invalid parameter +#define scrnErrModeUnsupported (scrnErrorClass | 2) // does not support screen mode +#define scrnErrScreenLocked (scrnErrorClass | 3) // could not lock the screen + +/*--------------------------------------------------------------------------- + * Extension Installed + *--------------------------------------------------------------------------*/ +#define _ScreenFeaturePresent(versionPtr) \ + (Boolean)(FtrGet(AlphaSmartSysFtrID, ScrnFtrNum, versionPtr) == 0) + +/*--------------------------------------------------------------------------- + * Rotation modes + *--------------------------------------------------------------------------*/ +typedef enum +{ + rotateScrnMode0 = 0, + rotateScrnMode90, + rotateScrnMode270 +} ScrnRotateModeType; + + +/*--------------------------------------------------------------------------- + * Screen modes + *--------------------------------------------------------------------------*/ +typedef enum +{ + screenModeWideTall = 0, + screenModeCentered +} ScrnScreenModeType; + +/*--------------------------------------------------------------------------- + * Screen System State + *--------------------------------------------------------------------------*/ +typedef struct ScrnSystemStateType +{ + ScrnScreenModeType screenMode; // current state of screen ext. + ScrnScreenModeType curAppScreenMode; // current state of app + Int16 offset_X; + Int16 offset_Y; + UInt8 draw_override; // > 0, no offsetting + + UInt8 reserved[8]; // not used +} ScrnSystemStateType; + + + +#ifdef __cplusplus +extern "C" { +#endif + +#define scrnMinFunction 0x0200 +#define scrnGetRotateMode (scrnMinFunction + 0) +#define scrnSetRotateMode (scrnMinFunction + 1) + +#define scrnEnable (scrnMinFunction + 2) +#define scrnDisable (scrnMinFunction + 3) +#define scrnIsEnabled (scrnMinFunction + 4) + +#define scrnTableSetFontID (scrnMinFunction + 5) +#define scrnGetSystemState (scrnMinFunction + 6) + +/******************************************************************** + * SCREEN API Prototypes + ********************************************************************/ + +/*--------------------------------------------------------------------------- + * ScrnGetRotateMode - Returns the current rotation settings + *--------------------------------------------------------------------------*/ +extern void ScrnGetRotateMode(ScrnRotateModeType *rotation) + EXTERNAL_TRAP(scrnGetRotateMode); + +/*--------------------------------------------------------------------------- + * ScrnSetRotateMode - Set current screen mode. + *--------------------------------------------------------------------------*/ +extern Err ScrnSetRotateMode(ScrnRotateModeType rotation) + EXTERNAL_TRAP(scrnSetRotateMode); + +/*--------------------------------------------------------------------------- + * ScrnTableSetFontID - Use small Palm font when drawing tableItemStyles + * excluding customTableItem which determines its. + *--------------------------------------------------------------------------*/ +extern void ScrnTableSetFontID(TablePtr table, FontID fontID) + EXTERNAL_TRAP(scrnTableSetFontID); + +/*--------------------------------------------------------------------------- + * ScrnEnable + *--------------------------------------------------------------------------*/ +extern void ScrnEnable(void) + EXTERNAL_TRAP(scrnEnable); + +/*--------------------------------------------------------------------------- + * ScrnDisable + *--------------------------------------------------------------------------*/ +extern void ScrnDisable(void) + EXTERNAL_TRAP(scrnDisable); + +/*--------------------------------------------------------------------------- + * ScrnIsEnabled + *--------------------------------------------------------------------------*/ +extern Boolean ScrnIsEnabled(void) + EXTERNAL_TRAP(scrnIsEnabled); + +/*--------------------------------------------------------------------------- + * ScrnGetSystemState + *--------------------------------------------------------------------------*/ +extern void ScrnGetSystemState(ScrnSystemStateType *pState) + EXTERNAL_TRAP(scrnGetSystemState); + + +#ifdef __cplusplus +} +#endif + + +#endif // __SCREEN_H__ diff --git a/dana-2.0/include/USBEmu.h b/dana-2.0/include/USBEmu.h new file mode 100644 index 0000000..24c7ac0 --- /dev/null +++ b/dana-2.0/include/USBEmu.h @@ -0,0 +1,42 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: USBEmu.h + * + * DESCRIPTION: USB Keyboard Emulator and Text Transfer program public + * header file. + * + ****************************************************************************/ + +#ifndef USB_EMU_H +#define USB_EMU_H + + +// application database, preference, ..., creator ID +#define usbEmuCreatorId 'ASem' + +// The feature number of the feature under usbEmuCreatorId in which the UInt16 +// port ID of the USB HID connection port is stored (this value is returned by +// SrmOpen). If this feature exists, it contains the port ID and the HID +// connection to the host is considered open/valid. If this feature does NOT +// exist, their is currently not a HID connection to the host. +#define usbEmuAsUSBPortIdFtr (1) + +// The feature number of the feature under the usbEmuCreatorId whoes existance +// indicates that a USB cable is plugged into the Dana. If this feature does +// NOT exist, there is not a cable plugged into the Dana. The feature currently +// does not contain any meaningful value. +#define usbEmuAsUSBCableConnectedFtr (2) + +// sub-launch command codes (sysAppLaunchCmdCustomBase = 0x8000 in SystemMgr.h) +#define appSubLaunchCmdTextTransfer (sysAppLaunchCmdCustomBase + 0) +#define appSubLaunchCmdEmulator (sysAppLaunchCmdCustomBase + 1) +#define appSubLaunchCmdFirstUnused (sysAppLaunchCmdCustomBase + 2) + +// EventType.eType field value for events generated by USBEmu +#define asUSBHidConnectedEvent (AlphaSmartfirstOEMEvent + 1) +#define asUSBHidDisconnectedEvent (AlphaSmartfirstOEMEvent + 2) + +#endif diff --git a/dana-2.0/include/WideTallApp.h b/dana-2.0/include/WideTallApp.h new file mode 100644 index 0000000..ba9f0c7 --- /dev/null +++ b/dana-2.0/include/WideTallApp.h @@ -0,0 +1,55 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: WideTallApp.h + * + * DESCRIPTION: This file contains the trap interface for Wide Tall Applications. + * + ****************************************************************************/ +#ifndef _OEMTYPES_H_ +#define _OEMTYPES_H_ + +#include +#include + +#define ON 1 +#define OFF 0 + +#define AlphaSmartSysFtrID 'WTAP' + +#ifdef __GNUC__ + +#define _AS_CALL_WITH_16BIT_SELECTOR(table, vector, selector)\ + __attribute__ ((__callseq__ (\ + "move.w #" _Str(selector) ",%%d2; "\ + "trap #" _Str(table) "; dc.w " _Str(vector) ))) + +#elif defined (__MWERKS__) /* The equivalent in CodeWarrior syntax */ + +#define _AS_CALL_WITH_16BIT_SELECTOR(table, vector, selector) \ + = { 0x343C, selector, 0x4E40 + table, vector } + +#endif + +#define AS_TRAP(sel) \ + _AS_CALL_WITH_16BIT_SELECTOR(_SYSTEM_TABLE, sysTrapOEMDispatch, sel) + +#ifdef BUILDING_EXTENSION + #define EXTERNAL_TRAP(x) +#else + #define EXTERNAL_TRAP(x) AS_TRAP(x) +#endif + + +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef __cplusplus + } +#endif + + +#endif diff --git a/dana-2.0/include/WideTallApp.r b/dana-2.0/include/WideTallApp.r new file mode 100644 index 0000000..c4cf84c --- /dev/null +++ b/dana-2.0/include/WideTallApp.r @@ -0,0 +1,24 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: WideTallApp.r + * + * DESCRIPTION: This file contains resources for WideTall applications. + * + ****************************************************************************/ + + +type 'wTap' { + //Currently no data is stored in resource, need dummy otherwise + //resource is not linked in + unsigned longint; +}; + + +resource 'wTap' (1000, "WideTall Aware") +{ + 0x00000001; //Set bit 0 for wide tall aware. + +}; diff --git a/dana-2.0/include/WideTallApp.rcp b/dana-2.0/include/WideTallApp.rcp new file mode 100644 index 0000000..a2a9835 --- /dev/null +++ b/dana-2.0/include/WideTallApp.rcp @@ -0,0 +1,14 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: WideTallApp.rcp + * + * DESCRIPTION: This file contains resources for WideTall applications. + * + ****************************************************************************/ + +/* Set bit 0 for wide tall aware. */ +HEX 'wTap' ID 1000 + 0x00 0x00 0x00 0x01 diff --git a/dana-2.0/include/WideTallAppChars.h b/dana-2.0/include/WideTallAppChars.h new file mode 100644 index 0000000..640894e --- /dev/null +++ b/dana-2.0/include/WideTallAppChars.h @@ -0,0 +1,212 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: WideTallAppChars.h + * + * DESCRIPTION: This file contains the definitions and constants + * for the keyboard characters. + * + ****************************************************************************/ +#ifndef WIDETALLAPPCHARS_H +#define WIDETALLAPPCHARS_H + +//------------------------------------------------------------------------------ +// All alphasmart key events are a virtual key +//------------------------------------------------------------------------------ +#define AS_VIRTUAL_KEY 0x2000 + +//------------------------------------------------------------------------------ +// New event type for detecting modifiers keys up and down +// Palm has allocated AlphaSmart 0x4000 - 0x4007 event type numbers +// for use on their device +//------------------------------------------------------------------------------ +#define AlphaSmartfirstOEMEvent (0x4000) // (firstOEMEvent + 0) +#define MODIFIER_KEY_EVENT (AlphaSmartfirstOEMEvent + 0) +// the following two events are defined in USBEmu.h -- DON'T USE THESE EVENT VALUES! +//#define asUSBHidConnectedEvent (AlphaSmartfirstOEMEvent + 1) +//#define asUSBHidDisconnectedEvent (AlphaSmartfirstOEMEvent + 2) + + +//------------------------------------------------------------------------------ +// ICode values +//------------------------------------------------------------------------------ +#define ICODE_INVALID 0xFF +#define ICODE_LAST 0x50 + +#define ICODE_DOWN_ARROW 0x0D +#define ICODE_UP_ARROW 0x4B +#define ICODE_RIGHT_ARROW 0x4A +#define ICODE_LEFT_ARROW 0x49 +#define ICODE_BACKSPACE 0x03 +#define ICODE_LEFT_SHIFT 0x08 +#define ICODE_RIGHT_SHIFT 0x45 +#define ICODE_LEFT_OPTION 0x26 +#define ICODE_PC_DELETE 0x3C +#define ICODE_COMMAND 0x0C +#define ICODE_CONTROL 0x4D +#define ICODE_CAPS_LOCK 0x05 +#define ICODE_RETURN 0x40 +#define ICODE_TAB 0x06 +#define ICODE_ESC 0x48 +#define ICODE_SPACEBAR 0x4C + + +#define ICODE_POWER_KEY 0x50 +#define ICODE_F1_KEY 0x2D +#define ICODE_F2_KEY 0x2C +#define ICODE_F3_KEY 0x04 +#define ICODE_F4_KEY 0x0F +#define ICODE_F5_KEY 0x0E +#define ICODE_F6_KEY 0x0A +#define ICODE_F7_KEY 0x01 +#define ICODE_F8_KEY 0x27 +#define ICODE_F9_KEY 0x2B +#define ICODE_F10_KEY 0x35 +#define ICODE_F11_KEY 0x3F +#define ICODE_F12_KEY 0x34 +#define ICODE_F13_KEY 0x1F +#define ICODE_F14_KEY 0x3E +#define ICODE_F15_KEY 0x29 +#define ICODE_F16_KEY 0x2A + + +#define ICODE_APP_1 ICODE_F9_KEY +#define ICODE_APP_2 ICODE_F10_KEY +#define ICODE_APP_3 ICODE_F11_KEY +#define ICODE_APP_4 ICODE_F12_KEY +#define ICODE_FIND ICODE_F13_KEY +#define ICODE_MENU ICODE_F14_KEY +#define ICODE_APPS ICODE_F15_KEY +#define ICODE_SEND ICODE_F16_KEY + +#define ICODE_FN_NEW_BUTTON ICODE_F9_KEY +#define ICODE_FN_CANCEL_BUTTON ICODE_F10_KEY +#define ICODE_FN_DONE_BUTTON ICODE_F11_KEY +#define ICODE_FN_CONTRAST ICODE_F13_KEY +#define ICODE_FN_NOTE_BUTTON ICODE_F12_KEY +#define ICODE_FN_CALC ICODE_F14_KEY +#define ICODE_FN_SHORTCUT ICODE_F15_KEY +#define ICODE_FN_HOT_SYNC ICODE_F16_KEY +#define ICODE_FN_OK_BUTTON ICODE_RETURN +#define ICODE_FN_DELETE_BUTTON ICODE_PC_DELETE +#define ICODE_FN_SHOW_BUTTON ICODE_LEFT_ARROW +#define ICODE_FN_DETAILS_BUTTON ICODE_RIGHT_ARROW + + +#define ICODE_FN_PAGE_UP ICODE_UP_ARROW +#define ICODE_FN_PAGE_DOWN ICODE_DOWN_ARROW + +#define ICODE_TICK_TILDE 0x2E // ` and ~ key +#define ICODE_QUOTE 0x0B // ' and " key +#define ICODE_SEMICOLON 0x14 // ; and : key + +#define ICODE_1 0x38 +#define ICODE_2 0x37 +#define ICODE_3 0x36 +#define ICODE_4 0x39 +#define ICODE_5 0x2F +#define ICODE_6_HAT 0x30 // 6 and ^ key +#define ICODE_7 0x3A +#define ICODE_8 0x31 +#define ICODE_9 0x32 // 9 key +#define ICODE_ZERO 0x33 + +#define ICODE_A 0x18 +#define ICODE_B 0x4E +#define ICODE_C 0x41 +#define ICODE_D 0x16 +#define ICODE_E 0x20 +#define ICODE_F 0x19 +#define ICODE_G 0x10 +#define ICODE_H 0x11 +#define ICODE_I 0x1C +#define ICODE_J 0x1B +#define ICODE_K 0x12 +#define ICODE_L 0x13 +#define ICODE_M 0x46 +#define ICODE_N 0x4F +#define ICODE_O 0x1D +#define ICODE_P 0x1E +#define ICODE_Q 0x22 +#define ICODE_R 0x23 +#define ICODE_S 0x17 +#define ICODE_T 0x07 +#define ICODE_U 0x24 +#define ICODE_V 0x44 +#define ICODE_W 0x21 +#define ICODE_X 0x42 +#define ICODE_Y 0x09 +#define ICODE_Z 0x43 + +#define ICODE_PLUS_EQUAL 0x25 +#define ICODE_COMMA 0x3B +#define ICODE_MINUS 0x28 +#define ICODE_PERIOD 0x3D +#define ICODE_QUESTION_MARK 0x47 +#define ICODE_LEFT_BRACKET 0x02 +#define ICODE_RIGHT_BRACKET 0x00 +#define ICODE_VERTICAL_BAR 0x15 +#define ICODE_EXTRA_ISO 0x1A + + +//------------------------------------------------------------------------------ +// New Types +// For a palm keydown event, if the chr field is AS_VIRTUAL_KEY then: +// keyCode = an alphasmart keyboard event +// modifiers = commandMask +// +// The alphasmart keyboard event has the icode in the lower 8 bits and the +// modifers in the upper 8 bits. +//------------------------------------------------------------------------------ + // upper 8 bits of modifier info + // lower 8 bits are is the icode +typedef UInt16 KeyboardEvent; +typedef KeyboardEvent *KeyboardEvent_p; + +//------------------------------------------------------------------------------ +// Modifier bits in the upper 8 bits of the alphsmart event. +// If the bit is set then the key on the keyboard is down. +//------------------------------------------------------------------------------ + +#define KEYBOARD_PATCH_IGNORE_EVENT 0x8000 +#define KEYBOARD_MODIFIER_COMMAND 0x4000 +#define KEYBOARD_MODIFIER_FUNCTION 0x2000 +#define KEYBOARD_MODIFIER_RIGHT_SHIFT 0x1000 +#define KEYBOARD_MODIFIER_LEFT_SHIFT 0x0800 +#define KEYBOARD_MODIFIER_CAPS_LOCK 0x0400 +#define KEYBOARD_MODIFIER_CONTROL 0x0200 + +//------------------------------------------------------------------------------ +// Useful macros for manipulating the keyboard event +//------------------------------------------------------------------------------ + +#define KEYBOARD_MODIFIER_SHIFT_MASK (KEYBOARD_MODIFIER_LEFT_SHIFT | \ + KEYBOARD_MODIFIER_RIGHT_SHIFT) + // if this bit is set then the key went up not down +#define KEYBOARD_MODIFIER_KEY_UP 0x0080 + +#define KEYBOARD_ICODE_MASK 0x00FF +#define KEYBOARD_MODIFIER_MASK 0x7e00 + +#define KEYBOARD_CMD_CONTROL_MASK (KEYBOARD_MODIFIER_CONTROL | \ + KEYBOARD_MODIFIER_COMMAND) + +#define KEYBOARD_ACTION_CODES_MASK (KEYBOARD_MODIFIER_CONTROL | \ + KEYBOARD_MODIFIER_COMMAND | \ + KEYBOARD_MODIFIER_FUNCTION) + +#define KEYBOARD_STICKY_CODES_MASK (KEYBOARD_MODIFIER_CONTROL | \ + KEYBOARD_MODIFIER_COMMAND | \ + KEYBOARD_MODIFIER_FUNCTION | \ + KEYBOARD_MODIFIER_SHIFT_MASK) + + // pass an alphasmart keyboard event (16 bit), not a palm event +#define KEYBOARD_GET_ICODE(keyboardEvent) ((UInt8 )((keyboardEvent) & \ + KEYBOARD_ICODE_MASK)) + +#define KEYBOARD_MAKE_EVENT(icode) (((KeyboardEvent)(icode)) & 0x00FF) + + +#endif diff --git a/dana-2.0/include/WritePad.h b/dana-2.0/include/WritePad.h new file mode 100644 index 0000000..2a24715 --- /dev/null +++ b/dana-2.0/include/WritePad.h @@ -0,0 +1,194 @@ +/************************************************************************* + * + * Copyright (c) 2001-2002 by AlphaSmart, Inc. + * All rights reserved. + * + * FILE: WritePad.h + * + * DESCRIPTION: This file contains the API to the WritePad. + * + ****************************************************************************/ +#ifndef __WRITEPAD_H__ +#define __WRITEPAD_H__ + +#include "WideTallApp.h" + + +#define WritePadFtrNum 7 + +/*--------------------------------------------------------------------------- + * Billboard feature number + *--------------------------------------------------------------------------*/ +#define BillboardFtrNum 3 + +/*--------------------------------------------------------------------------- + * NotifyMgr: Notification of WritePad minimize/maximize events + *--------------------------------------------------------------------------*/ +#define notifyWritePadEvent 'wrtp' +#define notifyBillboardDrawEvent 'bill' +typedef struct +{ + Boolean writePad_minimized; + Boolean writePad_onTheRight; +} writePadEventType; + + +/*--------------------------------------------------------------------------- + * Extension Installed + *--------------------------------------------------------------------------*/ +#define _WritePadFeaturePresent(version) \ + (Boolean)(FtrGet(AlphaSmartSysFtrID, WritePadFtrNum, version) == 0) + +/*--------------------------------------------------------------------------- + * WritePad API result codes + * (oemErrorClass is reserved for Palm licensees). + *--------------------------------------------------------------------------*/ +#define wrtpErrorClass (oemErrorClass | 0x700) +#define wrtpErrBadParam (wrtpErrorClass | 0) // invalid parameter + + +#ifdef __cplusplus +extern "C" { +#endif + +#define wrtMinFunction 0x0700 + +#define wrtGetWritePadWindow (wrtMinFunction + 0) +#define wrtGetWritePadTemplate (wrtMinFunction + 1) +#define wrtWritePadRestoreDefaultTemplate (wrtMinFunction + 2) +#define wrtDrawWritePadWindow (wrtMinFunction + 3) +#define wrtEraseWritePadWindow (wrtMinFunction + 4) +#define wrtGetAreas (wrtMinFunction + 5) +#define wrtSetAreas (wrtMinFunction + 6) +#define wrtGetButtons (wrtMinFunction + 7) +#define wrtSetButtons (wrtMinFunction + 8) +#define wrtGetGraffitiPersistence (wrtMinFunction + 9) +#define wrtSetGraffitiPersistence (wrtMinFunction + 10) +#define wrtSetWritePadTemplate (wrtMinFunction + 11) +#define wrtGetButtonListSize (wrtMinFunction + 12) +#define wrtWritePadWindowShown (wrtMinFunction + 13) +#define wrtSetPenEnabled (wrtMinFunction + 14) +#define wrtGetPenEnabled (wrtMinFunction + 15) +#define wrtWindowRight (wrtMinFunction + 16) +#define wrtGetBillboardWin (wrtMinFunction + 17) + +#define wrtMaxFunction (wrtMinFunction + 17) + +/******************************************************************** + * WritePad API Prototypes + ********************************************************************/ + +/*--------------------------------------------------------------------------- + * Show the WritePad window. + *--------------------------------------------------------------------------*/ +extern void WrtpMaximizeWindow(void) + EXTERNAL_TRAP(wrtDrawWritePadWindow); + +/*--------------------------------------------------------------------------- + * Hide the WritePad window. + *--------------------------------------------------------------------------*/ +extern void WrtpMinimizeWindow(void) + EXTERNAL_TRAP(wrtEraseWritePadWindow); + +/*--------------------------------------------------------------------------- + * Is the WritePad window maximized or minimized?. + *--------------------------------------------------------------------------*/ +extern Boolean WrtpWindowMaximized(void) + EXTERNAL_TRAP(wrtWritePadWindowShown); + +/*--------------------------------------------------------------------------- + * Return a WinHandle to the WritePad Template to allow drawing directly to the + * onscreen window + *--------------------------------------------------------------------------*/ +extern WinHandle WrtpGetWindow(void) + EXTERNAL_TRAP(wrtGetWritePadWindow); + +/*--------------------------------------------------------------------------- + * Returns pointers to the template bitmaps + *--------------------------------------------------------------------------*/ +extern void WrtpGetTemplateBitmaps(BitmapPtr *maxWritePadTemplate, BitmapPtr *selectedMaxWritePadTemplate, + BitmapPtr *minWritePadTemplate, BitmapPtr *selectedMinWritePadTemplate) + EXTERNAL_TRAP(wrtGetWritePadTemplate); + +/*--------------------------------------------------------------------------- + * Provide bitmaps for the WritePad template. + *--------------------------------------------------------------------------*/ +extern Err WrtpSetTemplateBitmaps(BitmapPtr maxWritePadTemplate, BitmapPtr selectedMaxWritePadTemplate, + BitmapPtr minWritePadTemplate, BitmapPtr selectedMinWritePadTemplate) + EXTERNAL_TRAP(wrtSetWritePadTemplate); + +/*--------------------------------------------------------------------------- + * Restore the WritePad Template to default. + *--------------------------------------------------------------------------*/ +extern Err WrtpRestoreDefaultTemplates(void) + EXTERNAL_TRAP(wrtWritePadRestoreDefaultTemplate); + +/*--------------------------------------------------------------------------- + * Get the WritePad screen button list size. Caller should call this first, + * allocate a buffer of this size, then call WritePadGetButtons(). + *--------------------------------------------------------------------------*/ +extern UInt16 WrtpGetButtonListSize(Boolean maximized) + EXTERNAL_TRAP(wrtGetButtonListSize); + +/*--------------------------------------------------------------------------- + * Get the WritePad screen button list + *--------------------------------------------------------------------------*/ +extern Err WrtpGetButtonList(PenBtnListType *buttonList, Boolean maximized) + EXTERNAL_TRAP(wrtGetButtons); + +/*--------------------------------------------------------------------------- + * Set the WritePad screen button list + *--------------------------------------------------------------------------*/ +extern Err WrtpSetButtonList(PenBtnListType *buttonList, Boolean maximized) + EXTERNAL_TRAP(wrtSetButtons); + +/*--------------------------------------------------------------------------- + * Get the WritePad screen alpha and numeric areas + *--------------------------------------------------------------------------*/ +extern Err WrtpGetAreas(RectangleType *alphaEntry, RectangleType *numericEntry) + EXTERNAL_TRAP(wrtGetAreas); + +/*--------------------------------------------------------------------------- + * Set the WritePad alpha and numeric areas + *--------------------------------------------------------------------------*/ +extern Err WrtpSetAreas(RectangleType *alphaEntry, RectangleType *numericEntry) + EXTERNAL_TRAP(wrtSetAreas); + +/*--------------------------------------------------------------------------- + * Get number of timer ticks graffiti remains on the WritePad area + *--------------------------------------------------------------------------*/ +extern UInt32 WrtpGetGraffitiPersistence(void) + EXTERNAL_TRAP(wrtGetGraffitiPersistence); + +/*--------------------------------------------------------------------------- + * Set number of timer ticks graffiti remains on the WritePad area + *--------------------------------------------------------------------------*/ +extern void WrtpSetGraffitiPersistence(UInt32 ticks) + EXTERNAL_TRAP(wrtSetGraffitiPersistence); + +/*--------------------------------------------------------------------------- + * Get the window handle to the billboard window. + * Make sure to check if the handle is NULL! + *--------------------------------------------------------------------------*/ +extern WinHandle WrtpGetBillboardWin(void) + EXTERNAL_TRAP(wrtGetBillboardWin); + +/*--------------------------------------------------------------------------- + * System use only + *--------------------------------------------------------------------------*/ +extern void WrtpSetPenEnabled(Boolean enabled) + EXTERNAL_TRAP(wrtSetPenEnabled); + + +extern Boolean WrtpGetPenEnabled(void) + EXTERNAL_TRAP(wrtGetPenEnabled); + +extern Boolean WrtpWindowRight(void) + EXTERNAL_TRAP(wrtWindowRight); + +#ifdef __cplusplus +} +#endif + + +#endif // __WRITEPAD_H__ diff --git a/dana-2.0/poser/AlphaSmart/Dana.skin b/dana-2.0/poser/AlphaSmart/Dana.skin new file mode 100644 index 0000000..93969c7 --- /dev/null +++ b/dana-2.0/poser/AlphaSmart/Dana.skin @@ -0,0 +1,46 @@ +#// This is a skin file for the Palm OS Emulator. The coordinates +#// are for the Dana skin + +Name = Dana without SD cards +File1x = DanaSkin_1x.jpg +File2x = DanaSkin_2x.jpg +BackgroundColor = 0x98, 0xA8, 0x7A +HighlightColor = 0x64, 0xF0, 0xDC +Devices = DanaDevice + +#// x y w h +#// ---- ---- ---- ---- +Element1 = PowerButton, 48, 326, 37, 35 +Element2 = Touchscreen, 162, 77, 560, 160 +Element3 = LCD, 162, 77, 560, 160 + +Element4 = F1_KEY, 96, 326, 37, 35 +Element5 = F2_KEY, 142, 326, 37, 35 +Element6 = F3_KEY, 189, 326, 37, 35 +Element7 = F4_KEY, 235, 326, 37, 35 +Element8 = F5_KEY, 282, 326, 37, 35 +Element9 = F6_KEY, 329, 326, 37, 35 +Element10 = F7_KEY, 376, 326, 37, 35 +Element11 = F8_KEY, 423, 326, 37, 35 +Element12 = F9_KEY, 470, 326, 37, 35 +Element13 = F10_KEY, 517, 326, 37, 35 +Element14 = F11_KEY, 564, 326, 37, 35 +Element15 = F12_KEY, 612, 326, 37, 35 +Element16 = F13_KEY, 659, 326, 37, 35 +Element17 = F14_KEY, 707, 326, 37, 35 +Element18 = F15_KEY, 754, 326, 37, 35 +Element19 = F16_KEY, 801, 326, 37, 35 + +Element20 = CONTROL_KEY, 51, 589, 52, 42 +Element21 = ALT_LEFT_KEY, 118, 589, 52, 42 +Element22 = COMMAND_KEY, 185, 589, 52, 42 +Element23 = CLEAR_MODIFIERS_KEY, 124, 652, 71, 22 + +Element24 = PC_DELETE_KEY, 615, 591, 37, 35 +Element25 = SHIFT_RIGHT_KEY, 726, 537, 108, 40 +Element26 = SHIFT_LEFT_KEY, 51, 537, 108, 45 +Element27 = CAPS_LOCK_KEY, 54, 481, 82, 45 +Element28 = ESCAPE_KEY, 559, 591, 37, 35 + + + diff --git a/dana-2.0/poser/AlphaSmart/DanaSkin_1x.jpg b/dana-2.0/poser/AlphaSmart/DanaSkin_1x.jpg new file mode 100644 index 0000000..de29956 Binary files /dev/null and b/dana-2.0/poser/AlphaSmart/DanaSkin_1x.jpg differ diff --git a/dana-2.0/poser/AlphaSmart/DanaSkin_2x.jpg b/dana-2.0/poser/AlphaSmart/DanaSkin_2x.jpg new file mode 100644 index 0000000..22a6512 Binary files /dev/null and b/dana-2.0/poser/AlphaSmart/DanaSkin_2x.jpg differ diff --git a/dana-2.0/poser/Emulator.exe b/dana-2.0/poser/Emulator.exe new file mode 100644 index 0000000..dbbb345 Binary files /dev/null and b/dana-2.0/poser/Emulator.exe differ diff --git a/dana-2.0/poser/Mac Palm OS Emulator.sit b/dana-2.0/poser/Mac Palm OS Emulator.sit new file mode 100644 index 0000000..2856307 Binary files /dev/null and b/dana-2.0/poser/Mac Palm OS Emulator.sit differ diff --git a/dana-2.0/poser/ReadMe POSER.txt b/dana-2.0/poser/ReadMe POSER.txt new file mode 100644 index 0000000..efe98b0 --- /dev/null +++ b/dana-2.0/poser/ReadMe POSER.txt @@ -0,0 +1,39 @@ +Dana Poser ReadMe + +The latest version of the Dana poser should be used with Dana 1.2 Roms. + +Most developers use the Double Scale checkbox in the Skins dialog, but you must have a very large display to just get the screen to display on your computer. It is recommended that you run the Hemingway poser in standard mode and not the Double Scale mode. + +The following Skin buttons can be clicked on: + +Power key +F1 through F8 keys +date key +address key +todo key +memo key +find key +menu key +apps key +send key +del key +esc key + +The following Skin buttons are "sticky", in that when you click them they stay "pressed" until you click them again or you click on the "clear modifiers" button: + +ctrl key +function key +cmd key +right shift key +left shift key + +The caps lock key is a Skin button that is "sticky", but it is not affected by the "clear modifiers" button. + +The Shift keys on the PC keyboard can be used in poser, but the form Graffiti shift indicator does not respond immediately to that input, but the incoming keys do get shifted correctly. + +To get the secondary function (printed in blue) on some keys, can be activated by clicking on the function key button and then clicking on the appropriate key button. An example would be that you can invoke the contrast dialog by clicking on the function key button and then clicking on the contrast key button. Remember to click on the function key button to turn it off or else everything you type or click on will have the function modifier bit attached to it. + +The Slow Keys and Sticky Keys feature in the Keyboard application does not work on poser. The Auto Repeat functionality does not work on poser. The keys will repeat in poser, but the Auto Repeat is being generated by the PC or Mac and not poser. + +The Mac poser will freeze when keys are type very quickly. This is a known issue with the PalmSource poser, also. + diff --git a/dana-2.0/roms/Dana1.2.1.rom b/dana-2.0/roms/Dana1.2.1.rom new file mode 100644 index 0000000..9c519fb Binary files /dev/null and b/dana-2.0/roms/Dana1.2.1.rom differ