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

📄 dateagenda.c

📁 我的Palm OS 5 SDK zhCN_PIMApps代码。 使用codewarrior 开发环境
💻 C
📖 第 1 页 / 共 5 页
字号:
		FormGadgetType*				inGadgetP,
		UInt16						inCommand,
		void*						inParamP )
#endif

{
	EventType * eventP;
	EventType newEvent;
	ControlType * categoryTriggerP;
	FormType *gadgetFormP;
	UInt16 gadgetIndex;
	RectangleType gadgetBounds;

	// Get the bounds of the gadget from the form
	gadgetFormP = FrmGetActiveForm();
	if (gadgetFormP == NULL)
		return false;
	gadgetIndex = FrmGetObjectIndexFromPtr (gadgetFormP, inGadgetP);
	FrmGetObjectBounds (gadgetFormP, gadgetIndex, &gadgetBounds);

	switch (inCommand)
		{
		case formGadgetDrawCmd:
			{
				WinDrawLine (	gadgetBounds.topLeft.x,
									gadgetBounds.topLeft.y + adjustSeparatorTop,
									gadgetBounds.topLeft.x + gadgetBounds.extent.x - 1,
									gadgetBounds.topLeft.y + adjustSeparatorTop );
				return true;
			}

		case formGadgetEraseCmd:
			WinEraseLine (	gadgetBounds.topLeft.x,
								gadgetBounds.topLeft.y + adjustSeparatorTop,
								gadgetBounds.topLeft.x + gadgetBounds.extent.x - 1,
								gadgetBounds.topLeft.y + adjustSeparatorTop );
			return true;

		case formGadgetHandleEventCmd:
			// Since the gadget can overlap the popup trigger for the to do category,
			// we have to take the gadget enter event generated for a pen down event
			// and convert it back to a pen down event to pass on to the control. If
			// the point is in the bounds of the popup trigger, it will then convert
			// it into a control enter event.
			eventP = (EventType *)inParamP;
			categoryTriggerP = GetObjectPtr(AgendaToDoCategoryTrigger);
			if (eventP->eType == frmGadgetEnterEvent)
			{
				newEvent = *eventP;
				newEvent.eType = penDownEvent;
				return CtlHandleEvent(categoryTriggerP, &newEvent);
			}
		}

	return false;
}


/***********************************************************************
 *
 * FUNCTION:    AgendaTitleDraw
 *
 * DESCRIPTION: Draw the current date and time
 *
 * PARAMETERS:  frm - pointer to the agenda view form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	6/4/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaTitleDraw (
	void*								inTableP,
	Int16								inRow,
	Int16								inColumn,
	RectangleType*					inBoundsP )
{
	DateTimeType					now;
	char								timeStr[timeStringLength];
	char								dateStr[longDateStrLength];
	FontID							origFont;
	UInt16							x;
	UInt16							len;

	TimSecondsToDateTime (TimGetSeconds (), &now);

	WinInvertRectangle (inBoundsP, 0);
	origFont = FntSetFont (TblGetItemFont (inTableP, inRow, inColumn));

	switch (inColumn)
		{
		case agendaTitleDateColumn:
			DateToAscii (now.month, now.day, now.year, Agenda.longDateFormat, dateStr);

			x = inBoundsP->topLeft.x + agendaTitleInset;
			WinInvertChars (dateStr, StrLen (dateStr), x, inBoundsP->topLeft.y);
			break;

		case agendaTitleTimeColumn:
			TimeToAscii (now.hour, now.minute, Agenda.timeFormat, timeStr);

			len = StrLen (timeStr);
			x = inBoundsP->topLeft.x + ( inBoundsP->extent.x - FntCharsWidth (timeStr, len) );
			x -= agendaTitleInset;
			WinInvertChars (timeStr,  len, x, inBoundsP->topLeft.y);
			break;
		}

	FntSetFont (origFont);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaViewDrawDate
 *
 * DESCRIPTION: Draw the current date
 *
 * PARAMETERS:  inFormP - pointer to the agenda view form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	6/4/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaViewDrawDate (
	FormType*						inFormP )
{
#pragma unused (inFormP)

	// DOLATER rbb 7/8/99 - Add constants, in DateAgenda.h or DateTime.h, for
	// string length and trim offsets.
	static Char						titleP [dowLongDateStrLength];
	ControlType*					controlP;
	Int8							trimOffset = 0;

	AgendaDateToDOWDM (Date, titleP);


	controlP = (ControlType*) GetObjectPtr (AgendaCurrentDayButton);
	CtlSetLabel (controlP, titleP);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaViewDrawTime
 *
 * DESCRIPTION: Draw the current time
 *
 * PARAMETERS:  inFormP - pointer to the agenda view form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	6/4/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaViewDrawTime (
	FormType*						inFormP )
{
#pragma unused (inFormP)
	static Char						timeStr [timeStringLength];
	DateTimeType 					dateTime;

	TimSecondsToDateTime (Agenda.timeSeconds, &dateTime);
	TimeToAscii (dateTime.hour, dateTime.minute, Agenda.timeFormat, timeStr);

	FrmCopyTitle (inFormP, timeStr);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaViewDrawSeparator
 *
 * DESCRIPTION: Draw the separator line between the calendar and task sections
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	6/4/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaViewDrawSeparator (
	FormType*						inFormP )
{
#pragma unused (inFormP)
	FormGadgetType*					separatorP;
	RectangleType						seperatorBounds, dividingBounds;
	FormGadgetType*					dividingLineP;
	ControlType*						categoryTriggerP;
	IndexedColorType					oldForeColor;

	separatorP = GetObjectPtr (AgendaSeparatorDefaultArea);
	dividingLineP = GetObjectPtr (AgendaDivider);

	FrmGetObjectBounds(inFormP, FrmGetObjectIndex(inFormP, AgendaSeparatorDefaultArea), &seperatorBounds);
	FrmGetObjectBounds(inFormP, FrmGetObjectIndex(inFormP, AgendaDivider), &dividingBounds);

	seperatorBounds.topLeft.y = dividingBounds.topLeft.y;
	seperatorBounds.extent.y = dividingBounds.extent.y;
	WinEraseRectangle (&seperatorBounds, 0);

	oldForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIFormFrame));
	// Call the handler directly, since there is no accessor for the handler
	
#ifdef FORM_GADGET_TYPE_IN_CALLBACK_DEFINED
	// Added for Compatibility with SDK 4.0 update 1
	AgendaDividerDraw ((FormGadgetTypeInCallback*)dividingLineP, formGadgetDrawCmd, 0);
#else
	AgendaDividerDraw ((FormGadgetType*)dividingLineP, formGadgetDrawCmd, 0);
#endif

	// Minns	(dividingLineP->handler) (dividingLineP, formGadgetDrawCmd, 0);
	WinSetForeColor(oldForeColor);

	categoryTriggerP = GetObjectPtr (AgendaToDoCategoryTrigger);
	CtlDrawControl (categoryTriggerP);

}


/***********************************************************************
 *
 * FUNCTION:    AgendaDateToDOWDM
 *
 * DESCRIPTION: Similar to DateToAscii, but accepts DateType and masks
 *					 out century
 *
 * PARAMETERS:
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	06/28/99	Initial Revision
 *			gap	10/10/00 Added a format string list so that the format string
 *								in the agenda view title will respect user's format
 *								setting specified in formats panel.
 *
 ***********************************************************************/
static void
AgendaDateToDOWDM (
	DateType			inDate,
	Char*				outAscii )
{
	UInt16			dateFormatIndex;
	Char 				templateBuffer[maxDateTemplateLen + 1];


	// Convert the current short day of week format selector into an index into the
	// agenda title date formats list.
	if (Agenda.dateFormat > dfYMDWithDashes)
		{
		// The dfMDYWithDashes uses the dfMDYLongWithComma just as the dfMDYWithSlashes
		// does.
		//
		if (ShortDateFormat != dfMDYWithDashes)
			{
			// DOLATER kwk - gross! If we add a new short date format,
			// this will trigger a fatal alert, but only if testing
			// actually runs this code with that format selected.
			ErrNonFatalDisplay("Unknown short date format");
			}

		// Default to the dfMDYWithSlashes format.
		//
		dateFormatIndex = (UInt16)dfMDYWithSlashes;
		}
	else
		dateFormatIndex = (UInt16)Agenda.dateFormat;


	SysStringByIndex(agendaTitleDateFormatsListID, (UInt16)dateFormatIndex, templateBuffer,
							sizeof(templateBuffer) - 1);


	DateTemplateToAscii(templateBuffer, inDate.month, inDate.day, inDate.year + firstYear,
								outAscii, dowLongDateStrLength);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaDayViewScroll
 *
 * DESCRIPTION: This routine scrolls the list of ToDo items
 *              in the direction specified.
 *
 * PARAMETERS:  direction - winUp or dowm
 *              oneLine   - if true the list is scrolled by a single line,
 *                          if false the list is scrolled by a full screen.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			art	2/21/95	Initial Revision
 *			rbb	4/14/99	Uses new ListViewDrawTable
 *
 ***********************************************************************/
static void
AgendaDayViewScroll (
	Int16								delta)
{
	UInt16 							apptIndex;
	UInt16							apptCount;
	UInt16							rowCount;
	UInt16							newIndex;
	TableType* 						tableP;

	if (delta == 0)
		{
		return;
		}

	tableP = GetObjectPtr (AgendaDatebookTable);
	TblReleaseFocus (tableP);

	apptIndex = Agenda.apptTopVisibleIndex;
	apptCount = AgendaGetAppointmentCount();
	rowCount = TblGetLastUsableRow (tableP) + 1;

	ErrFatalDisplayIf (apptIndex == noAppointments, "AgendaDayViewScroll called with no appointments");

	newIndex = max (0, (Int32) apptIndex + delta);
	newIndex = min (newIndex, apptCount - rowCount);

	Agenda.apptTopVisibleIndex = newIndex;

	AgendaViewFillAppointments (FrmGetActiveForm());
	TblRedrawTable (tableP);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaViewGoToDate
 *
 * DESCRIPTION: This routine displays the date picker so that the
 *              user can select a date to navigate to.  If the date
 *              picker is confirmed, the date selected is displayed.
 *
 *              This routine is called when a "go to" button is pressed.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			art	6/29/95	Initial Revision
 *
 ***********************************************************************/
static void
AgendaViewGoToDate ( void )
{
	Char* title;
	MemHandle titleH;
	Int16 month, day, year;

	// Get the title for the date picker dialog box.
	titleH = DmGetResource (strRsc, goToDateTitleStrID);
	title = MemHandleLock (titleH);

	day = Date.day;
	month = Date.month;
	year = Date.year + firstYear;

	// Display the date picker.
	if (SelectDay (selectDayByDay, &month, &day, &year, title))
		{
		Date.day = day;
		Date.month = month;
		Date.year = year - firstYear;

		AgendaViewChangeDate (FrmGetActiveForm(), Date);
		}

	MemHandleUnlock (titleH);
}


#pragma mark -
/***********************************************************************
 *
 * FUNCTION:    AgendaViewInitToDo
 *
 * DESCRIPTION: Initialize the To Do portion of the Agenda view.
 *
 * PARAMETERS:  frm - pointer to the day view form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	5/28/99	Initial Revision
 *
 ***********************************************************************/
void
AgendaViewInitToDo (
	FormPtr							frm )
{
	// Get the To Do prefs
	UInt16 row;
	UInt16 rowsInTable;
	UInt16 width;
	FontID fontID;
	TablePtr table;
	RectangleType r;
	Boolean showCategories = ShowCategories && (CurrentCategory == dmAllCategories);
	ControlPtr ctl;


	table = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, AgendaToDoTable));

	rowsInTable = TblGetNumberOfRows (table);
	for (row = 0; row < rowsInTable; row++)
		{
		TblSetItemStyle (table, row, completedColumn, checkboxTableItem);

⌨️ 快捷键说明

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