⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 .#progect.c.1.81

📁 个人日程管理系统
💻 81
📖 第 1 页 / 共 5 页
字号:
/* -*-Mode:C; tab-width:4; indent-tabs-mode:t; c-file-style:"stroustrup";-*- *//* Main code for Project *///#define ERROR_CHECK_LEVEL 2#include <PalmOS.h>#include <DateGlue.h>#include <TxtGlue.h>#include <FntGlue.h>#include <TsmGlue.h>#include <WinGlue.h>#include "handera/Vga.h"//#include "SonyCLIE.h"#include "link.h"#include "task.h"#include "xb.h"#include "progectdb.h"#include "progectRsc.h"#include "progect.h"#include "flat.h"#include "btm.h"#include "beam.h"// icon support#include "icon.h"// ToDo export support#include "ToDoDB.h"// Memo linking support#include "MemoDB.h"// address linking support#include "AddressDB.h"// Doc export support#include "doc.h"// Category support#include "category.h"// hotsync support#include "aftersync.h"// not used yettypedef enum {tblRedrawAll, tblRedrawTable, tblUpdateRedrawAll, 	tblUpdateRedrawTable} redrawTableType;// for FrmTaskEditParttypedef enum {showValue, hideValue} PartType;// prototypes// eventsvoid           ProgressHandleEvent(void) UISECT;void           PriorityHandleEvent(EventPtr e) UISECT;UInt16         SelectRange(void) UISECT;Boolean        FrmMainMenuHandleEvent(EventPtr e) UISECT;Boolean        FrmMainCtlSelectHandleEvent(EventPtr e) UISECT;Boolean        FrmMainKeyDownHandleEvent(EventPtr e) UISECT;static Boolean FrmMainHandleEvent (EventPtr e) UISECT;static void    UpdateIconButton(void) UISECT;static Boolean FrmTaskEditHandleEvent (EventPtr e) UISECT;static Boolean FrmProjectListHandleEvent (EventPtr e) UISECT;Boolean        HandleChooseNameButtonOK(void) UISECT;static Boolean FrmChooseNameHandleEvent (EventPtr e) UISECT;static Boolean FrmProjectPropertiesHandleEvent (EventPtr e) UISECT;static Boolean FrmMemoExportPropertiesHandleEvent (EventPtr e) UISECT;Boolean        EditMenuHandleEvent(UInt16 menuid, FieldPtr fld) UISECT;void           FrmNoteEditUpdateScroll(void) UISECT;void           FrmNoteEditScrollPage(WinDirectionType direction) UISECT;static Boolean FrmNoteEditHandleEvent (EventPtr e) UISECT;Boolean        FrmFlatCtlSelectHandleEvent(EventPtr e) UISECT;void           ProjectFlatTableUpdate(void) UISECT;static Boolean FrmFlatHandleEvent (EventPtr e) UISECT;static Boolean FrmFlatFilterHandleEvent (EventPtr e) UISECT;static Boolean FrmDisplayPropertiesHandleEvent (EventPtr e) UISECT;static Boolean FrmTaskDefaultsHandleEvent (EventPtr e) UISECT;void           UpdatePopupTrigger(MemPtr trigger, MemPtr list) UISECT;static void    FrmTaskEditPart(PartType part) UISECT;static Boolean ApplicationHandleEvent(EventPtr e);static UInt16 StartApplication(void);static void StopApplication(void);static void EventLoop(void);UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags);static void Search(FindParamsPtr findParams);// icons#define IconNum 16MemHandle gIconHandle[IconNum]; // to hold handles to the bitmaps// GlobalsOSCaps_t OSCaps = {	false, false, false, false, false, false, false, false,	0, false, 0, 160, 160, 0};DmOpenRef gdbP = NULL; // actual databaseDmOpenRef gClip = NULL; // clipboard databaseUInt16 gActualTask = 0; // selected taskUInt16 gLastSelected = 0; // last selected taskUInt32 gFlatOffset = 0; // flat view offset of first itemTaskType gEmptyTask = {	{ // attr		{			0, // level			0, // next			0, // child			0, // opened			0, // prev			0  // reserved		}	}, 	{ // format		{			0,            // hasStartDate			0,            // hasPred			0,            // hasDuration			1,            // hasDueDate			0,            // hasToDo			0,            // hasNote			0,            // hasLink			progressType, // itemType			0,            // hasXB			1,            // newTask			1,            // newFormat			0             // nextFormat		}	},	NO_PRIORITY, // priority	0,           // completed	{ // due date		0, 		0, 		0	}, 	"", // desc	""  // reserved (align)};DateType gNoDate = {0, 0, 0};Char gDateStr[dowLongDateStrLength]; // to store a date stringUInt8 gLevelOffset = 0; // for horizontal scroll and subtree viewingUInt16 gParentTask = 0; // the parent of all tasks for viewing purposes onlyUInt8 gRefLevel = 0; // level of gParentTask;Int16 gLastDownX, gLastDownY;TablePtr gTable; // main form tableLocalID gdbID = 0; // id of opened database (set by OpenDB and CloseDB)Char* namesData = NULL; // used by list selectorChar** names = NULL; // used by list selector// used for date differences calculationsUInt8 gLimits[] = { 0, 1, 2, 3, 4, 5, 6, 7, 14, 21, 28 }; // UInt8 is to saving memory.DateType gToday;UInt32 gTodayDays; // to speed up day comparaisons calculationsUInt16 gCurrentSelection = 0; // current selection in project listChar* docName; // use by FrmChooseNameUInt8 ChooseNameFunction = ChooseNameCreate;UInt16 gProjectTableMaxY = 0;UInt8 gActualNumRows = 11; // number of rows to show// 0.23//UInt16 gNumDeleted = 0;   // nb of deleted records in actual database// PreferencesDateFormatType gDateFormat; // actual date format (from palm, StartApplication)ProjectPrefsType gProjectPrefs = {	DBVERSION, // db format	0, 		// reserved	false,	// hideDoneTasks	true, 	// displayDueDates	true, 	// displayPriorities	false,  // displayYear	false,  // useFatherStatus	true,	// autoSyncToDo	true, 	// flatHideDone	2, 		// flatDated (0 = no, 1 = yes, 2 = not used)	3, 		// flatMinPriority	true, 	// flatOr	true,  	// flatMin	0, 		// boldMinPriority	0,      // boldMinDays	false,  // strikeDoneTasks	false,  // hideDoneProgress	false,  // hideProgress	// taskDefaults	{{{0, 0, 0, 0, 0, 0}}, {{0, 0, 0, 1, 0, 0, 0, progressType, 0, 1, 1, 0}},	NO_PRIORITY, 0, {0, 0, 0}, "", ""},	noSort, // flatSorted	0,      // flatDateLimit	true,   // completionDate	0xffff, // flatCategories	2,      // wordWrapLines	true    // drawTreeLines};CurrentPrefsType gCurrentPrefs; // current prefs, used to restore applic stateSavedPrefsType gSavedPrefs = {true}; // saved prefs, used to restore global                                      // application prefsMemoExportOptionsType gMemoExportPrefs =	{		true,  // exportDone;		true,  // exportProgress;		true,  // exportDueDate;		true,  // exportPriority;		false, // exportNote;		false, // exportOnlyTerminals;		DOC_EXPORT_RAWTEXT // exportDocFormat;	};static UInt16 wVerticalLines[25];/**************************************************************************** * Name : TblGetRowContainingPoint * Desc : Return the table row that bounds the given x & y screen coordinates. *        Returns -1 if there is no usable row that contains the point. * Parm :  * 			-> The table to operate on *          -> x, y screen coordinates * Out  :   <- The row number containing (x, y), or -1 if none. * Auth : hcc, 05.05.2001 ***************************************************************************/Int16 TblGetRowContainingPoint(const TableType *table, UInt16 x, UInt16 y){	RectangleType tableBounds;	Int16 row, lastRow;	UInt16 rowY, rowH;	// Find top Y of the first row.	TblGetBounds(table, &tableBounds);	rowY = tableBounds.topLeft.y;	for(row=0,lastRow = TblGetLastUsableRow(table); row <= lastRow; row++)	{		// NOTE: Initially tried just TblGetItemBounds for each row, but		// the extent.y was always 11, even if the row height was several		// lines long, so now just add up all the heights from the start.		rowH = TblGetRowHeight(table, row);		if(rowY <= y && y < rowY + rowH)			break;		rowY += rowH;	}	if(row > lastRow) // Not in any usable row		row = -1;	DBGMSG((DBB,"TblGetRowContainingPoint row=%d (x=%d, y=%d)\n", row, x, y));	return(row);}/**************************************************************************** * Name : GetObjectPtr * Desc : get a pointer to an object of the current form * Parm :  * 			-> ID of object to get a pointer to * Out  : ptr * Auth : lb, 06.08.2000 ***************************************************************************/MemPtr GetObjectPtr(UInt16 ObjID){	FormPtr frm = FrmGetActiveForm();	return FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, ObjID));} // MemPtr GetObjectPtr(UInt16 ObjID)/**************************************************************************** * Name : Today * Desc : return today's date * Parm :  * Out  : today's date * Auth : lb, 06.08.2000 ***************************************************************************/DateType Today(void){	DateType date;	DateSecondsToDate(TimGetSeconds(), &date);	return date;} // DateType Today(void)/**************************************************************************** * Name : DateInLimit * Desc : return true if passed date is within limit * Parm :  * 			-> date to test * 			-> offset in limits tab * Out  : date is in limit * Auth : lb, 04.10.2000, from a modified version of seagull's original code ***************************************************************************/Boolean DateInLimit(DateType date, UInt8 offset){	static UInt8 limits[] = { 0, 0, 1, 2, 3, 4, 5, 6, 7, 14, 21, 28 }; // UInt8 is to saving memory.	UInt32 days = DateToDays(date);	Boolean overdue = (days < gTodayDays);	UInt32 diff = days > gTodayDays ? 		days - gTodayDays : gTodayDays - days;	if (!offset)		return false;	return ((diff < (UInt32)limits[offset]) || overdue);} // Boolean DateInLimit(DateType date, UInt8 offset)/**************************************************************************** * Name : PrintDueDate * Desc : print the date at given y pos * Parm :  * 			-> the record * 			-> the y position * 			<-> the x position (in = right pos, out = left pos) * Out  :  * Auth : lb, 29.08.2000 * Mod	: lb, 2001-09-06 * 		  	adapt to 0.23 db format ***************************************************************************/void PrintDueDate(TaskStandardFields *p, UInt16 *datePos, UInt16 y){	Char dateStrMem[dowLongDateStrLength+1]; // complete date + '!' + '\0'	Char* dateStr = dateStrMem;	UInt16 dateLen;	DateToAscii(p->dueDate.month, p->dueDate.day, 		p->dueDate.year + YEAR_OFFSET, gDateFormat, dateStrMem); // start 1904	// calc the date length	if (!gProjectPrefs.displayYear)	{		switch(gDateFormat)		{			case dfYMDWithSlashes:			case dfYMDWithDots:			case dfYMDWithDashes:// +++ CHECK THIS +++// This does not look right! Isn't there a better way to do this?// +++ CHECK THIS +++				dateStr += 3;				break;			default:				dateStr[StrLen(dateStr) - 3] = '\0';				break;		}	}	dateLen = StrLen(dateStr);	if (gTodayDays > DateToDays(p->dueDate))	{		// if the task is completed, don't write the !		if (p->completed != 10)		{			dateStr[dateLen++] = '!';			dateStr[dateLen] = '\0';		}	}	*datePos -= FntCharsWidth(dateStr, dateLen);	WinDrawChars(dateStr, dateLen, *datePos, y); // just draw days and month} // void PrintDueDate(TaskStandardFields *p, UInt16 &datePos, UInt16 y)/**************************************************************************** * Name : SetFormTitle * Desc : set the title of the given form * Parm :  * Out  :  * Auth : lb, 31.08.2000 ***************************************************************************/void SetFormTitle (FormPtr frm, Char *title){	#define titleArraySize 33	Char titleArray[titleArraySize];	UInt8 i;	// exit if sanity check fails	if (NULL == title)	{		DBGMSG((DBB, "SetFormTitle - Hey!, What do you think you are "			"doing! You just passed a NULL pointer for title"));		return;	}	// if prepended, skip prepend	if (StrStr(title, gPrepend) == title)	{		title += 5;	}	for (i = 0; i < (titleArraySize -1) && *title; i++)	{		titleArray[i] = *title++;	}	titleArray[i] = '\0';	FrmCopyTitle(frm, titleArray);} // void SetFormTitle (FormPtr frm, Char *title)/**************************************************************************** * Name : DrawWrappedText * Desc : Draw text block, with word wrap in the current font. *        The first line can optionally be indented on both left & right. * Parm : * 			-> string to draw * 			-> x and y top left corner of block *          -> lineLimit: Max # of lines to word wrap. * 			-> widthLimit: (pixels) width of the block to draw in. *          -> indentLeft, indentRight: Amount to indent first line only *          -> strikeThrough: If true, a line will be drawn through text. * Out  :   <- The number of lines of text actually drawn. * Auth : hcc, 05.05.2001, rprice 07.25.2003 ***************************************************************************/int DrawWrappedText(Char *strP, UInt16 x, UInt16 y,					UInt16 lineLimit,					UInt16 widthLimit,					UInt16 indentLeft,					UInt16 indentRight,					Boolean strikeThrough){	Char *msg = strP;      // Cur position in string to print.	UInt8 lineCnt;             // Which line we are on. First = 1.	UInt16 lineLen;            // Number of chars to draw on cur line.	UInt16 curWidthLimit;      // pixels. width limit for cur line.	UInt16 curX;               // pixels. Start X position of text in cur line.	RectangleType rectBounds;  // For erase line's rectangle	Int16 widthToOffset;	widthToOffset = 0;	lineCnt=0;	while (msg && *msg && (lineCnt < lineLimit)) 	{		if(0 == lineCnt)		{			curWidthLimit = widthLimit - indentLeft - indentRight;			curX = x + indentLeft;		}		else		{			curWidthLimit = widthLimit;			curX = x;			RctSetRectangle(&rectBounds, 0, y, OSCaps.screenWidth, 11);			WinEraseRectangle(&rectBounds, 0);		}		widthToOffset = FntWordWrap(msg, curWidthLimit);		if (lineCnt < lineLimit - 1)			WinDrawChars(msg, widthToOffset, curX, y);		else			// On last line. Trunc middle of word and draw ellipses.			DrawTruncText(msg, curX, y, curWidthLimit);				if(strikeThrough)		{		    lineLen = StrLen(msg);			// We redefine curWidthLimit to be the width actually used:			if(lineCnt < lineLimit - 1) // Lines other than last line				curWidthLimit = FntCharsWidth(msg, lineLen);			else // Last line, drawn above via DrawTruncText				FntCharsInWidth(msg, &curWidthLimit, &lineLen,(void *)(&rectBounds)); // last arg is junk ptr			WinDrawLine(x, y + 6, x + curWidthLimit + (curX - x), y + 6);		}		y += FntLineHeight();		msg += widthToOffset;		lineCnt++;	}			return (lineCnt);}/**************************************************************************** * Name : DrawTruncText * Desc : draw a text, trunc if too long * Parm : * 			-> string to draw * 			-> x and y pos to draw * 			-> x limit * Out  :  - * Auth : lb, 12.09.2000 * Mod  : hcc, 05.05.2001 *          Fix ver 3.0 case to consider width of all three dots of ellipsis ***************************************************************************/void DrawTruncText(Char *c, UInt16 x, UInt16 y, UInt16 limit){	Char * ptr = StrChr (c, linefeedChr);	UInt16 titleLen = (ptr == NULL ? StrLen (c) : (UInt16) (ptr - c));	if (OSCaps.ver32)		// best choise. complete nationalized. and got wide screen.		WinDrawTruncChars(c, titleLen, x, y, limit);	else if (OSCaps.ver30)	{   // 99% nationalized. and lost screen width.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -