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

📄 addrview.c

📁 我的Palm OS 5 SDK zhCN_PIMApps代码。 使用codewarrior 开发环境
💻 C
📖 第 1 页 / 共 5 页
字号:
					UInt16 len;
					UInt16 posOffsetFromBeginningOfLine;

					if ( selectPos >= RecordViewLines[i].offset )	// If the beginning of the selection is within the current line
					{
						pos = selectPos;
						posOffsetFromBeginningOfLine = selectPos - RecordViewLines[i].offset;
					}
					else	// The beginning of the selection is within one of the previous lines
					{
						pos = RecordViewLines[i].offset;
						posOffsetFromBeginningOfLine = 0;
					}
					
					if ( selectPos + selectLen < RecordViewLines[i].offset + RecordViewLines[i].length )	// If the end of the selection is within the current line or within one of the previous lines
					{
						if ( selectPos + selectLen >=  RecordViewLines[i].offset + posOffsetFromBeginningOfLine )	// <=> selectPos + selectLen - RecordViewLines[i].offset - posOffsetFromBeginningOfLine (Not to have len < 0)
							len = selectPos + selectLen - RecordViewLines[i].offset - posOffsetFromBeginningOfLine;
						else
							len = 0;
					}
					else	// The end of the selection is within one of the next lines
					{
						len = RecordViewLines[i].length - posOffsetFromBeginningOfLine;
					}
					
					TraceOutput(TL(appErrorClass, "PrvViewDraw() - offset = %hu, length = %hu, selectPos = %hu, selectLen = %hu, pos = %hu, len = %hu, posOffsetFromBeginningOfLine = %hu", RecordViewLines[i].offset, RecordViewLines[i].length, selectPos, selectLen, pos, len, posOffsetFromBeginningOfLine));
					PrvViewDrawSelectedText(i, pos, len, y);
				}
			}
		}
	}

	MemPtrUnlock(appInfoPtr);
	FntSetFont (curFont);
	WinPopDrawState ();

	if (!drawOnlySelectField)
	{
		// Now show/hide the scroll arrows
		scrollableUp = TopRecordViewLine != 0;
		scrollableDown = i < RecordViewLastLine;


		// Update the scroll button.
		upIndex = FrmGetObjectIndex(frmP, RecordUpButton);
		downIndex = FrmGetObjectIndex(frmP, RecordDownButton);
		FrmUpdateScrollers(frmP, upIndex, downIndex, scrollableUp, scrollableDown);
	}
}


/***********************************************************************
 *
 * FUNCTION:    PrvViewDrawBusinessCardIndicator
 *
 * DESCRIPTION: Draw the business card indicator if the current record is
 * the business card.
 *
 * PARAMETERS:  formP - the form containing the business card indicator
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *         Name   Date      Description
 *         ----   ----      -----------
 *         roger  10/22/97  Initial Revision
 *
 ***********************************************************************/
void PrvViewDrawBusinessCardIndicator (FormPtr formP)
{
	UInt32 uniqueID;

	DmRecordInfo (AddrDB, CurrentRecord, NULL, &uniqueID, NULL);
	if (BusinessCardRecordID == uniqueID)
		FrmShowObject(formP, FrmGetObjectIndex (formP, RecordViewBusinessCardBmp));
	else
		FrmHideObject(formP, FrmGetObjectIndex (formP, RecordViewBusinessCardBmp));

}


/***********************************************************************
 *
 * FUNCTION:    PrvViewUpdate
 *
 * DESCRIPTION: Update the record view and redraw it.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *		Name   Date      	Description
 *		----   ----      	-----------
 *		roger   10/18/95  	Initial Revision
 *		aro		09/26/00	Add frmP as an argument
 *		FPa		11/15/00	Fixed bug #44838
 *
 ***********************************************************************/
void PrvViewUpdate( FormType* frmP )
{
	PrvViewErase(frmP);
	PrvViewDraw(frmP, 0, 0, 0, false);
	PrvViewDrawBusinessCardIndicator(frmP);
}

/***********************************************************************
 *
 * FUNCTION:    PrvViewScrollOnePage
 *
 * DESCRIPTION: Scrolls the record view by one page less one line unless
 * we scroll from RecordViewLastLine (used by scroll code).
 *
 * PARAMETERS:  newTopRecordViewLine - top line of the display
 *              direction - up or dowm
 *
 * RETURNED:    new newTopRecordViewLine one page away
 *
 * REVISION HISTORY:
 *         Name   Date      Description
 *         ----   ----      -----------
 *			roger		6/22/95	Initial Revision
 *			roger		8/2/95	Reworked to handle half height blank lines.
 *			roger		10/30/95	Reworked to obey FntLineHeight
 *			roger		10/31/95	Broke out of PrvViewScroll
 *
 ***********************************************************************/
UInt16 PrvViewScrollOnePage (Int16 newTopRecordViewLine, WinDirectionType direction)
{
	Int16 offset;
	FontID curFont;
	FormPtr frm;
	Int16 largeFontLineHeight;
	Int16 stdFontLineHeight;
	Int16 currentLineHeight;
	RectangleType r;
	Int16 recordViewDisplayHeight;


	// setup stuff
	curFont = FntSetFont (largeBoldFont);
	largeFontLineHeight = FntLineHeight();
	FntSetFont (AddrRecordFont);
	stdFontLineHeight = FntLineHeight();
	FntSetFont (curFont);

	frm = FrmGetActiveForm();
	FrmGetObjectBounds(frm, FrmGetObjectIndex(frm, RecordViewDisplay), &r);
	recordViewDisplayHeight = r.extent.y;
	if (newTopRecordViewLine != RecordViewLastLine)
		recordViewDisplayHeight -= stdFontLineHeight;   // less one one line


	if (direction == winUp)
		offset = -1;
	else
		offset = 1;


	while (recordViewDisplayHeight >= 0 &&
		   (newTopRecordViewLine > 0 || direction == winDown) &&
		   (newTopRecordViewLine < (RecordViewLastLine - 1) || direction == winUp))
	{
		newTopRecordViewLine += offset;
		if (newTopRecordViewLine < RecordViewFirstPlainLine)
			currentLineHeight = largeFontLineHeight;
		else
			currentLineHeight = stdFontLineHeight;

		recordViewDisplayHeight -= PrvViewCalcNextLine(newTopRecordViewLine,
													   currentLineHeight);
	};

// Did we go too far?
if (recordViewDisplayHeight < 0)
{
	// The last line was too much so remove it
	newTopRecordViewLine -= offset;

	// Also remove any lines which don't have a height
	while (PrvViewCalcNextLine(newTopRecordViewLine, 2) == 0)
	{
		newTopRecordViewLine -= offset;   // skip it
	}
}

return newTopRecordViewLine;
}


/***********************************************************************
 *
 * FUNCTION:    PrvViewScroll
 *
 * DESCRIPTION: Scrolls the record view
 *
 * PARAMETERS:  direction - up or dowm
 *
 * RETURNED:    true if the event was handled and should not be passed
 *              to a higher level handler.
 *
 * REVISION HISTORY:
 *			Name	Date		Description
 *			----	----		-----------
 *			roger	06/22/95	Initial Revision
 *			roger	08/02/95	Reworked to handle half height blank lines.
 *			roger	10/30/95	Reworked to obey FntLineHeight
 *			gap		10/12/99	Close command bar before processing scroll
 *			FPa		11/15/00	Fixed bug #44838
 *
 ***********************************************************************/
void PrvViewScroll (WinDirectionType direction)
{
	Int16 lastRecordViewLine;
	UInt16 newTopRecordViewLine;
	UInt16 category;
	UInt16 recordNum;
	Int16 seekDirection;
	UInt16	attr;
	FormType* frmP;

	// Before processing the scroll, be sure that the command bar has been closed.
	MenuEraseStatus (0);
	newTopRecordViewLine = TopRecordViewLine;

	if (direction == winUp)
	{
		newTopRecordViewLine = PrvViewScrollOnePage (newTopRecordViewLine, direction);
	}
	else
	{
		// Simple two part algorithm.
		// 1) Scroll down one page
		// 2) Scroll up one page from the bottom
		// Use the higher of the two positions
		// Find the line one page down

		newTopRecordViewLine = PrvViewScrollOnePage (newTopRecordViewLine, direction);

		// Find the line at the top of the last page
		// (code copied to PrvViewMakeVisible).
		lastRecordViewLine = PrvViewScrollOnePage (RecordViewLastLine, winUp);

		// We shouldn't be past the top line of the last page
		if (newTopRecordViewLine > lastRecordViewLine)
			newTopRecordViewLine = lastRecordViewLine;
	}

	// Get the active form
	frmP = FrmGetActiveForm();

	if (newTopRecordViewLine != TopRecordViewLine)
	{
		TopRecordViewLine = newTopRecordViewLine;

		PrvViewErase(frmP);
		PrvViewDraw(frmP, 0, 0, 0, false);
	}

	// If we couldn't scroll then scroll to the next record.
	else
	{
		// Move to the next or previous record.
		if (direction == winUp)
		{
			seekDirection = dmSeekBackward;
		}
		else
		{
			seekDirection = dmSeekForward;
		}

		if (ShowAllCategories)
			category = dmAllCategories;
		else
			category = CurrentCategory;

		recordNum = CurrentRecord;

		//skip masked records.
		while (!DmSeekRecordInCategory (AddrDB, &recordNum, 1, seekDirection, category) &&
			   !DmRecordInfo (AddrDB, recordNum, &attr, NULL, NULL) &&
			   ((attr & dmRecAttrSecret) && PrivateRecordVisualStatus == maskPrivateRecords))
		{
		}
		if (recordNum == CurrentRecord) return;
		
		// Don't show first/last record if it's private and we're masking.
		if (!DmRecordInfo (AddrDB, recordNum, &attr, NULL, NULL) &&
			   ((attr & dmRecAttrSecret) && PrivateRecordVisualStatus == maskPrivateRecords))
			return;

		SndPlaySystemSound (sndInfo);

		CurrentRecord = recordNum;
		
	  	PrvViewInit(frmP);
  	  	
		PrvViewUpdate(frmP);
	}
}


/***********************************************************************
 *
 * FUNCTION:    PrvViewMakeVisible
 *
 * DESCRIPTION: Make a selection range visible
 *
 * PARAMETERS:  selectFieldNum - field to show selected text
 *                selectPos - offset into field for start of selected text
 *                selectLen - length of selected text
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *         Name   Date      Description
 *         ----   ----      -----------
 *         roger   8/3/95   Initial Revision
 *
 ***********************************************************************/
void PrvViewMakeVisible (UInt16 selectFieldNum, UInt16 selectPos, UInt16 selectLen)
{
	UInt16 newTopRecordViewLine;
	UInt16 i;


	newTopRecordViewLine = RecordViewLastLine;
	for (i = 0; i < RecordViewLastLine; i++)
	{
		// Does the selected range end here?
		if (RecordViewLines[i].fieldNum == selectFieldNum &&
			RecordViewLines[i].offset <= selectPos + selectLen &&
			selectPos + selectLen <= RecordViewLines[i].offset +
			RecordViewLines[i].length)
		{
			newTopRecordViewLine = i;
		}
	}


	// If the selected range doesn't seem to exist then
	// we shouldn't scroll the view.
	if (newTopRecordViewLine == RecordViewLastLine)
		return;


	// Display as much before the selected text as possible
	newTopRecordViewLine = PrvViewScrollOnePage (newTopRecordViewLine, winUp);

	if (newTopRecordViewLine != TopRecordViewLine)
		TopRecordViewLine = newTopRecordViewLine;
}


/***********************************************************************
 *
 * FUNCTION:    PrvViewPhoneNumberAt
 *
 * DESCRIPTION: Given a point on the screen in the RecordViewDisplay,
 *					 determine whether that point is in a phone number, and if
 *					 so, which one. Phone numbers are defined as linefeed
 *					 separated.
 *
 * PARAMETERS:	x				- x coordinate of point to look at
 *					y				- y coordinate of point to look at
 *					fieldNumP	- result: which field the phone number is in
 *					offsetP		- result: where phone number starts in field
 *					lengthP		- result: how long phone number is
 *
 * RETURNED:	whether there is a phone number at the given point
 *
 * REVISION HISTORY:
 *		Name	Date		Description
 *		----	----		-----------
 *		peter	05/05/00	Initial Revision
 *		peter	05/26/00	Fix bug: Restore font.
 *		aro		06/27/00	Fix bug for non phone field
 *
 ***********************************************************************/
Boolean PrvViewPhoneNumberAt (Int16 x, Int16 y, UInt16 *fieldNumP, UInt16 *offsetP, UInt16 *lengthP)
{
	FormPtr			frm;
	FontID			curFont;
	RectangleType	r;
	Int16				lineY, bottomOfRecordViewDisplay, width, height;
	UInt16			previousNonZeroHeight, currentHeight;
	UInt16			i, j;

	frm = FrmGetActiveForm();
	FrmGetObjectBounds(frm, FrmGetObjectIndex(frm, RecordViewDisplay), &r);

	if (TopRecordViewLine < RecordViewFirstPlainLine)
		curFont = FntSetFont (largeBoldFont);
	else
		curFont = FntSetFont (AddrRecordFont);

	lineY = r.topLeft.y;
	previousNonZeroHeight = 0;
	bottomOfRecordViewDisplay = r.topLeft.y +  r.extent.y;

	for (i = TopRecordViewLine; i < RecordViewLastLine; i++)
	{

⌨️ 快捷键说明

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