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

📄 dateagenda.c

📁 我的Palm OS 5 SDK zhCN_PIMApps代码。 使用codewarrior 开发环境
💻 C
📖 第 1 页 / 共 5 页
字号:
	if (apptsH)
		{
		apptsP = MemHandleLock (apptsH);
		for (i = 0; i < Agenda.apptCount; i++)
			{
			if (TimeToInt (apptsP[i].endTime) < TimeToInt (time))
				Agenda.apptTopVisibleIndex = i;
			}

		MemPtrUnlock (apptsP);
		}
}


/***********************************************************************
 *
 * FUNCTION:    AgendaViewSetTopTask
 *
 * DESCRIPTION: This routine determines the first task that should
 *              be visible on the current day.  For all dates other than
 *              today the fisrt time slot of the appointment list
 *              is the first visible appointment.  For today the time
 *              slot that stats before to the current time should be the top
 *              visible time slot.
 *
 * PARAMETERS:  nothing.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			art	6/29/95	Initial Revision
 *
 ***********************************************************************/
static void AgendaViewSetTopTask ()
{
	TopVisibleRecord = 0;
}


static void
AgendaViewLayoutTables (
	FormType*						inFormP,
	UInt16							inApptLineCount,
	UInt16							inToDoLineCount )
{
	RectangleType					scrollableRect;
	RectangleType					apptRect;
	RectangleType					separatorRect;
	RectangleType					todoRect;

	AgendaViewGetScrollableRect (inFormP, &scrollableRect);

	apptRect = scrollableRect;

	AgendaViewLayoutAppointments (inFormP, &apptRect, inApptLineCount);

	separatorRect.topLeft.x = scrollableRect.topLeft.x;
	separatorRect.topLeft.y = apptRect.topLeft.y + apptRect.extent.y;
	separatorRect.extent.x = scrollableRect.extent.x;
	separatorRect.extent.y = scrollableRect.extent.y - apptRect.extent.y;

	AgendaViewLayoutSeparator (inFormP, &separatorRect);

	todoRect.topLeft.x = scrollableRect.topLeft.x;
	todoRect.topLeft.y = separatorRect.topLeft.y + separatorRect.extent.y;
	todoRect.extent.x = scrollableRect.extent.x;
	todoRect.extent.y = scrollableRect.extent.y - apptRect.extent.y - separatorRect.extent.y;

	AgendaViewLayoutTasks (inFormP, &todoRect, inToDoLineCount);
}


static void
AgendaViewLayoutAppointments (
	FormType*						inFormP,
	RectangleType*					ioBoundsP,
	UInt16							inApptLineCount )
{
#pragma unused (inFormP)
	TableType*						tableP;
	UInt16							row;
	UInt16							rowCount;
	RectangleType					bounds;

	tableP = GetObjectPtr (AgendaDatebookTable);
	rowCount = TblGetNumberOfRows (tableP);

	// Set the usability for each row in the table. If there are fewer appointments
	// than rows, the remaining rows will be unusable
	for (row = 0; row < rowCount; row++)
		{
		if ((row < inApptLineCount)
				&& (!TblRowUsable (tableP, row)
						|| (TblGetRowHeight (tableP, row) != Agenda.apptLineHeight)) )
			{
			TblMarkRowInvalid (tableP, row);
			}

		TblSetRowUsable (tableP, row, row < inApptLineCount);
		TblSetRowHeight (tableP, row, Agenda.apptLineHeight);
		}

	// Adjust the table size so that it doesn't overlap the To Do table
	TblGetBounds (tableP, &bounds);
	bounds.extent.y = inApptLineCount * Agenda.apptLineHeight;
	TblSetBounds (tableP, &bounds);
	ioBoundsP->extent.y = inApptLineCount * Agenda.apptLineHeight;
}


static void
AgendaViewLayoutSeparator (
	FormType*						inFormP,
	RectangleType*					ioBoundsP )
{
	RectangleType					dividerBounds;
	UInt16							top = ioBoundsP->topLeft.y;

	AgendaViewObjectSetTop (inFormP, AgendaDivider, top);
	AgendaViewObjectSetTop (inFormP, AgendaToDoCategoryList, top + adjustCategoryTop);
	AgendaViewObjectSetTop (inFormP, AgendaToDoCategoryTrigger, top + adjustCategoryTop);

	FrmGetObjectBounds (inFormP, FrmGetObjectIndex (inFormP, AgendaDivider), &dividerBounds);
	ioBoundsP->topLeft.y = dividerBounds.topLeft.y;
	ioBoundsP->extent.y = dividerBounds.extent.y;
}


static UInt16
AgendaViewObjectSetTop (
	FormType*						inFormP,
	UInt16							inObjectID,
	UInt16							inTop )
{
	RectangleType					bounds;
	UInt16							index;

	index = FrmGetObjectIndex (inFormP, inObjectID);
	FrmGetObjectBounds (inFormP, index, &bounds);
	bounds.topLeft.y = inTop;
	FrmSetObjectBounds (inFormP, index, &bounds);

	return bounds.topLeft.y + bounds.extent.y;
}

static void
AgendaViewLayoutTasks (
	FormType*						inFormP,
	RectangleType*					ioBoundsP,
	UInt16							inToDoLineCount )
{
#pragma unused (inFormP)
	TableType*						tableP;
	UInt16							row;
	UInt16							rowCount;
	RectangleType					bounds;

	tableP = GetObjectPtr (AgendaToDoTable);
	rowCount = TblGetNumberOfRows (tableP);
	TblGetBounds (tableP, &bounds);

	// Set the usability for each row in the table. If there are fewer tasks
	// than rows, the remaining rows will be unusable
	for (row = 0; row < rowCount; row++)
		{
		if ((row < inToDoLineCount)
				&& (!TblRowUsable (tableP, row)
						|| (ioBoundsP->topLeft.y != bounds.topLeft.y)
						|| (TblGetRowHeight (tableP, row) != Agenda.todoLineHeight)) )
			{
			TblMarkRowInvalid (tableP, row);
			}

		TblSetRowUsable (tableP, row, row < inToDoLineCount);
		TblSetRowHeight (tableP, row, Agenda.todoLineHeight);
		}

	// For drawing purposes, the table should extend to the bottom of the
	// displayable area, regardless of the number of displayable lines.
	TblSetBounds (tableP, ioBoundsP);
}


static void
AgendaViewUpdateScroller (
	FormType*						inFormP,
	UInt16							inObjectID,
	UInt16							inAssocObjectID,
	UInt16							inRecordCount,
	UInt16							inVisibleCount,
	UInt16							inLineHeight )
{
	RectangleType					assocBounds;
	UInt16							scrollIndex;
	RectangleType					scrollBounds;
	UInt16							scrollMax;
	Int16								currentValue;
	Int16								currentMin;
	Int16								currentMax;
	Int16								currentPageSize;

	FrmGetObjectBounds (inFormP, FrmGetObjectIndex (inFormP, inAssocObjectID), &assocBounds);

	scrollMax = max (0, (Int32) inRecordCount - inVisibleCount);	// without the typecast, max ignores the 0!!!

	// Resize the scroll bar to be slightly inset from the provided bounds.
	// To avoid runtime warnings (debug only), make sure that it is also
	// at least 1 pixel tall.
	scrollIndex = FrmGetObjectIndex (inFormP, inObjectID);
	FrmGetObjectBounds (inFormP, scrollIndex, &scrollBounds);

	scrollBounds.topLeft.y = assocBounds.topLeft.y + scrollerInset;
	scrollBounds.extent.y = max (1, (Int32) inVisibleCount * inLineHeight - (2 * scrollerInset));
	FrmSetObjectBounds (inFormP, scrollIndex, &scrollBounds);

	SclGetScrollBar (GetObjectPtr (inObjectID), &currentValue, &currentMin,
							&currentMax, &currentPageSize);
	currentValue = min (currentValue, scrollMax);
	SclSetScrollBar (GetObjectPtr (inObjectID), currentValue, 0, scrollMax, inVisibleCount);
}


static void
AgendaViewEraseObject (
	FormType*						inFormP,
	UInt16							inObjectID )
{
	RectangleType					bounds;

	if (FrmVisible(inFormP))
		{
		FrmGetObjectBounds (inFormP, FrmGetObjectIndex (inFormP, inObjectID), &bounds);
		WinEraseRectangle (&bounds, 0);
		}
}


static void
AgendaViewSetScrollThumb (
	FormType*						inFormP,
	UInt16							inObjectID,
	UInt16							inValue )
{
#pragma unused (inFormP)
	ScrollBarType*					scrollBarP;
	Int16								scrollValue;
	Int16								scrollMin;
	Int16								scrollMax;
	Int16								scrollPage;

	scrollBarP = GetObjectPtr (inObjectID);
	SclGetScrollBar (scrollBarP, &scrollValue, &scrollMin, &scrollMax, &scrollPage);
	SclSetScrollBar (scrollBarP, inValue, scrollMin, scrollMax, scrollPage);
}


static void
AgendaViewRefreshLayoutTasks (
	FormType*						inFormP )
{
	UInt16							oldApptLineCount;

	// This routine is called when the To Do section of the agenda has been altered.
	// Even though only the To Do section has changed, the heuristic divider may
	// need to be repositioned if the Datebook section overflows its default size.

	oldApptLineCount = Agenda.apptLineCount;

	AgendaViewLayout (inFormP, Agenda.apptCount, Agenda.todoCount);

	if (Agenda.apptLineCount != oldApptLineCount)
		{
		AgendaViewFillAppointments (inFormP);
		AgendaViewSetScrollThumb (inFormP, AgendaDatebookScroller, Agenda.apptTopVisibleIndex);
		}

	AgendaViewFillTasks (inFormP);
}


/***********************************************************************
 *
 * FUNCTION:    AgendaApptDrawTime
 *
 * DESCRIPTION: Draw the starting time of an appointment.  This
 *              routine is called by the table object as a callback
 *              routine.
 *
 * PARAMETERS:  table  - pointer to the memo Day table (TablePtr)
 *              row    - row of the table to draw
 *              column - column of the table to draw
 *              bounds - region to draw in
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	6/4/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaApptDrawTime (
	void*								inTableP,
	Int16								inRow,
	Int16								inColumn,
	RectangleType*					inBoundsP )
{
#pragma unused (inColumn)
	UInt16							apptIndex;
	ApptInfoPtr						appts;
	TimeType							startTime;

	// Get the appointment that corresponds to the table item.
	// The index of the appointment in the appointment list is stored
	// as the row id.
	apptIndex = TblGetRowID (inTableP, inRow);

	// When there are no appointments, a special index is stored. If this is the case, don't
	// try to draw the time; the description column will show "No Appointments"
	if (apptIndex != noAppointments)
		{
		// Get the record index of the next appointment
		appts = MemHandleLock (AgendaGetAppointments ());
		startTime = appts[apptIndex].startTime;
		MemPtrUnlock (appts);

		DrawTime (startTime, TimeFormat, apptTimeFont, rightAlign, inBoundsP);
		}
}


/***********************************************************************
 *
 * FUNCTION:    AgendaApptDrawDesc
 *
 * DESCRIPTION: Draw the description of an appointment.  This
 *              routine is called by the table object as a callback
 *              routine.
 *
 * PARAMETERS:  table  - pointer to the memo Day table (TablePtr)
 *              row    - row of the table to draw
 *              column - column of the table to draw
 *              bounds - region to draw in
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			rbb	8/30/99	Initial Revision
 *
 ***********************************************************************/
static void
AgendaApptDrawDesc (
	void*								inTableP,
	Int16								inRow,
	Int16								inColumn,
	RectangleType*					inBoundsP )
{
#pragma unused (inColumn)
	Err								err = errNone;
	UInt16							apptIndex;
	ApptInfoPtr						apptsP;
	UInt16							recordNum;
	MemHandle						recordH = NULL;
	ApptDBRecordType				apptRec;
	MemHandle						textH = NULL;
	Char*								textP = NULL;
	FontID							curFont;
	Char*								tempP;
	UInt16							tempCount = 0;

	// Get the appointment that corresponds to the table item.
	// The index of the appointment in the appointment list is stored
	// as the row id.
	apptIndex = TblGetRowID (inTableP, inRow);

	// When there are no appointments, a special index is stored. If this is the case, don't
	// try to draw the time; the description column will show "No Appointments"
	if (apptIndex != noAppointments)
		{
		// Get the record index of the next appointment
		apptsP = MemHandleLock (AgendaGetAppointments ());
		recordNum = apptsP[apptIndex].recordNum;
		MemPtrUnlock (apptsP);

		// Get the offset and length of the description field
		err = ApptGetRecord (Agenda.apptDB, recordNum, &apptRec, &recordH);

		if ( err == errNone )
			{
			textP = apptRec.description;
			}
		}
	else
		{
		textH = DmGetResource (strRsc, agendaNoAppointmentsStrID);
		textP = MemHandleLock (textH);
		}

	if (textP)
		{
		curFont = FntSetFont (Agenda.apptFont);

		tempP = textP;
		while (*tempP && *tempP != linefeedChr)
			{
			++tempCount;
			++tempP;
			}
		WinDrawTruncChars (textP, tempCount, inBoundsP->topLeft.x, inBoundsP->topLeft.y,
									inBoundsP->extent.x);
		FntSetFont (curFont);
		}

	if (recordH)
		{
		MemHandleUnlock (recordH);
		}

	if (textH)
		{
		MemHandleUnlock (textH);
		DmReleaseResource (textH);
		}
}


#ifdef FORM_GADGET_TYPE_IN_CALLBACK_DEFINED
	// Added for Compatibility with SDK 4.0 update 1
	static Boolean
	AgendaDividerDraw (
		FormGadgetTypeInCallback*	inGadgetP,
		UInt16						inCommand,
		void*						inParamP )
#else
	static Boolean
	AgendaDividerDraw (

⌨️ 快捷键说明

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