@ -11,4 +11,4 @@ Contributers
|
||||
- https://github.com/jichu4n[*@jichu4n*]: SDK 5.0r3
|
||||
- https://github.com/stevelittle[*@stevelittle*]: SDK 5.0r4
|
||||
- https://github.com/Tavisco[*@Tavisco*]: Handera SDK 1.05
|
||||
|
||||
- *Musashi:* Alphasmart Dana 2.0 SDK
|
||||
|
||||
5
dana-2.0/ReadMe.txt
Normal file
@ -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.
|
||||
|
||||
|
||||
BIN
dana-2.0/docs/Bachmann Software PrintBoy Technical Note.pdf
Normal file
BIN
dana-2.0/docs/Dana API Reference.pdf
Normal file
BIN
dana-2.0/docs/Dana Companion Guide.pdf
Normal file
BIN
dana-2.0/docs/FontBucket Developers.pdf
Normal file
BIN
dana-2.0/docs/FontBucket License.pdf
Normal file
BIN
dana-2.0/docs/FontBucket Users.pdf
Normal file
BIN
dana-2.0/examples/Example A - Screen/ExampleA.mcp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
46
dana-2.0/examples/Example A - Screen/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
489
dana-2.0/examples/Example A - Screen/Src/Starter.c
Normal file
@ -0,0 +1,489 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example B - Screen/ExampleB.mcp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
1
dana-2.0/examples/Example B - Screen/Rsc/Starter.r
Normal file
@ -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
};
|
||||
46
dana-2.0/examples/Example B - Screen/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
461
dana-2.0/examples/Example B - Screen/Src/Starter.c
Normal file
@ -0,0 +1,461 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example C - Keyboard/ExampleC.mcp
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
49
dana-2.0/examples/Example C - Keyboard/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
513
dana-2.0/examples/Example C - Keyboard/Src/Starter.c
Normal file
@ -0,0 +1,513 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example D - Keyboard/ExampleD.mcp
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
51
dana-2.0/examples/Example D - Keyboard/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
524
dana-2.0/examples/Example D - Keyboard/Src/Starter.c
Normal file
@ -0,0 +1,524 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example E - WritePad/ExampleE.mcp
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
69
dana-2.0/examples/Example E - WritePad/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
673
dana-2.0/examples/Example E - WritePad/Src/starter.c
Normal file
@ -0,0 +1,673 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
* Project : ExampleF
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#include <PalmOSGlue.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example F - WritePad/ExampleF.mcp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
64
dana-2.0/examples/Example F - WritePad/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
763
dana-2.0/examples/Example F - WritePad/Src/starter.c
Normal file
@ -0,0 +1,763 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
BIN
dana-2.0/examples/Example G - FontBucket/ExampleG.mcp
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
40
dana-2.0/examples/Example G - FontBucket/Rsc/StarterRsc.h
Normal file
@ -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
|
||||
|
||||
526
dana-2.0/examples/Example G - FontBucket/Src/Starter.c
Normal file
@ -0,0 +1,526 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
*
|
||||
* File: Starter.c
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <PalmOS.h>
|
||||
#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);
|
||||
}
|
||||
1
dana-2.0/examples/ReadMe.txt
Normal file
@ -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.
|
||||
85
dana-2.0/include/ASSubLaunch.h
Normal file
@ -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
|
||||
158
dana-2.0/include/ASUSBPrint.h
Normal file
@ -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 <PalmOS.h>
|
||||
#include <SerialVdrv.h>
|
||||
|
||||
// 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 <PalmOS.h>
|
||||
#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
|
||||
1
dana-2.0/include/FontBucket.c
Normal file
242
dana-2.0/include/FontBucket.h
Normal file
@ -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_
|
||||
1
dana-2.0/include/FontBucket.r
Normal file
@ -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 */
};
|
||||
112
dana-2.0/include/KeyboardAccess.h
Normal file
@ -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
|
||||
140
dana-2.0/include/Screen.h
Normal file
@ -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__
|
||||
42
dana-2.0/include/USBEmu.h
Normal file
@ -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
|
||||
55
dana-2.0/include/WideTallApp.h
Normal file
@ -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 <PalmTypes.h>
|
||||
#include <CoreTraps.h>
|
||||
|
||||
#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
|
||||
24
dana-2.0/include/WideTallApp.r
Normal file
@ -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.
|
||||
|
||||
};
|
||||
14
dana-2.0/include/WideTallApp.rcp
Normal file
@ -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
|
||||
212
dana-2.0/include/WideTallAppChars.h
Normal file
@ -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
|
||||
194
dana-2.0/include/WritePad.h
Normal file
@ -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__
|
||||
46
dana-2.0/poser/AlphaSmart/Dana.skin
Normal file
@ -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
|
||||
|
||||
|
||||
|
||||
BIN
dana-2.0/poser/AlphaSmart/DanaSkin_1x.jpg
Normal file
|
After Width: | Height: | Size: 447 KiB |
BIN
dana-2.0/poser/AlphaSmart/DanaSkin_2x.jpg
Normal file
|
After Width: | Height: | Size: 746 KiB |
BIN
dana-2.0/poser/Emulator.exe
Normal file
BIN
dana-2.0/poser/Mac Palm OS Emulator.sit
Normal file
39
dana-2.0/poser/ReadMe POSER.txt
Normal file
@ -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.
|
||||
|
||||