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

📄 addrlist.c

📁 我的Palm OS 5 SDK zhCN_PIMApps代码。 使用codewarrior 开发环境
💻 C
📖 第 1 页 / 共 4 页
字号:
	while (row < numRows)
	{
		TblSetRowUsable (tblP, row, false);
		row++;
	}

	PrvListUpdateScrollButtons(frmP);
}


/***********************************************************************
 *
 * FUNCTION:    PrvListSelectCategory
 *
 * DESCRIPTION: This routine handles selection, creation and deletion of
 *              categories form the Details Dialog.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    The index of the new category.
 *
 *              The following global variables are modified:
 *                     CurrentCategory
 *                     ShowAllCategories
 *                     CategoryName
 *
 * REVISION HISTORY:
 *         Name   Date      Description
 *         ----   ----      -----------
 *         art   06/05/95   Initial Revision
 *			  gap	  08/13/99   Update to use new constant categoryDefaultEditCategoryString.
 *
 ***********************************************************************/
UInt16 PrvListSelectCategory (void)
{
	FormType* frmP;
	TableType* tblP;
	UInt16 category;
	Boolean categoryEdited;

	// Process the category popup list.
	category = CurrentCategory;

	frmP = FrmGetActiveForm();
	categoryEdited = CategorySelect (AddrDB, frmP, ListCategoryTrigger,
									 ListCategoryList, true, &category, CategoryName, 1, categoryDefaultEditCategoryString);

	if (category == dmAllCategories)
		ShowAllCategories = true;
	else
		ShowAllCategories = false;

	if ( categoryEdited || (category != CurrentCategory))
	{
		ToolsChangeCategory (category);

		// Display the new category.
		PrvListLoadTable(frmP);
		tblP = ToolsGetFrmObjectPtr(frmP, ListTable);
		TblEraseTable(tblP);
		TblDrawTable(tblP);

		PrvListClearLookupString();

		// By changing the category the current record is lost.
		CurrentRecord = noRecord;
	}

	return (category);
}


/***********************************************************************
 *
 * FUNCTION:    PrvListNextCategory
 *
 * DESCRIPTION: This routine display the next category,  if the last
 *              catagory is being displayed
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    nothing
 *
 *              The following global variables are modified:
 *                     CurrentCategory
 *                     ShowAllCategories
 *                     CategoryName
 *
 * REVISION HISTORY:
 *         Name   Date      Description
 *         ----   ----      -----------
 *         art   9/15/95   Initial Revision
 *         rsf   9/20/95   Copied from To Do
 *
 ***********************************************************************/
void PrvListNextCategory (void)
{
	UInt16 category;
	TableType* tblP;
	ControlType* ctlP;
	FormType* frmP;

	category = CategoryGetNext (AddrDB, CurrentCategory);

	if (category != CurrentCategory)
	{
		if (category == dmAllCategories)
			ShowAllCategories = true;
		else
			ShowAllCategories = false;

		ToolsChangeCategory (category);

		// Set the label of the category trigger.
		frmP = FrmGetActiveForm();
		ctlP = ToolsGetFrmObjectPtr(frmP, ListCategoryTrigger);
		CategoryGetName (AddrDB, CurrentCategory, CategoryName);
		CategorySetTriggerLabel(ctlP, CategoryName);


		// Display the new category.
		PrvListLoadTable(frmP);
		tblP = ToolsGetFrmObjectPtr(frmP, ListTable);
		TblEraseTable(tblP);
		TblDrawTable(tblP);

		// By changing the category the current record is lost.
		CurrentRecord = noRecord;
	}
}


/***********************************************************************
 *
 * FUNCTION:    PrvListScroll
 *
 * DESCRIPTION: This routine scrolls the list of names and phone numbers
 *              in the direction specified.
 *
 * PARAMETERS:  direction	- up or dowm
 *              units		- unit amount to scroll
 *              byLine		- if true, list scrolls in line units
 *									- if false, list scrolls in page units
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *			Name		Date		Description
 *			----		----		-----------
 *			art		6/5/95	Initial Revision
 *       frigino	8/14/97	Modified to scroll by line or page in units
 *       gap   	10/12/99	Close command bar before processing scroll
 *       gap   	10/15/99	Clean up selection handling after scroll
 *       gap   	10/25/99	Optimized scrolling to only redraw if item position changed
 *
 ***********************************************************************/
void PrvListScroll (WinDirectionType direction, UInt16 units, Boolean byLine)
{
	TableType* tblP;
	FormType* frmP;
	UInt16 rowsInPage;
	UInt16 newTopVisibleRecord;
	UInt16 prevTopVisibleRecord = TopVisibleRecord;


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

	frmP = FrmGetActiveForm();
	tblP = ToolsGetFrmObjectPtr(frmP, ListTable);
	// Safe. There must be at least one row in the table.
	rowsInPage = PrvListNumberOfRows(tblP) - 1;
	newTopVisibleRecord = TopVisibleRecord;

	// Scroll the table down.
	if (direction == winDown)
	{
		// Scroll down by line units
		if (byLine)
		{
			// Scroll down by the requested number of lines
			if (!ToolsSeekRecord (&newTopVisibleRecord, units, dmSeekForward))
			{
				// Tried to scroll past bottom. Goto last record
				newTopVisibleRecord = dmMaxRecordIndex;
				ToolsSeekRecord (&newTopVisibleRecord, 1, dmSeekBackward);
			}
		}
		// Scroll in page units
		else
		{
			// Try scrolling down by the requested number of pages
			if (!ToolsSeekRecord (&newTopVisibleRecord, units * rowsInPage, dmSeekForward))
			{
				// Hit bottom. Try going backwards one page from the last record
				newTopVisibleRecord = dmMaxRecordIndex;
				if (!ToolsSeekRecord (&newTopVisibleRecord, rowsInPage, dmSeekBackward))
				{
					// Not enough records to fill one page. Goto the first record
					newTopVisibleRecord = 0;
					ToolsSeekRecord (&newTopVisibleRecord, 0, dmSeekForward);
				}
			}
		}
	}
	// Scroll the table up
	else
	{
		// Scroll up by line units
		if (byLine)
		{
			// Scroll up by the requested number of lines
			if (!ToolsSeekRecord (&newTopVisibleRecord, units, dmSeekBackward))
			{
				// Tried to scroll past top. Goto first record
				newTopVisibleRecord = 0;
				ToolsSeekRecord (&newTopVisibleRecord, 0, dmSeekForward);
			}
		}
		// Scroll in page units
		else
		{
			// Try scrolling up by the requested number of pages
			if (!ToolsSeekRecord (&newTopVisibleRecord, units * rowsInPage, dmSeekBackward))
			{
				// Hit top. Goto the first record
				newTopVisibleRecord = 0;
				ToolsSeekRecord (&newTopVisibleRecord, 0, dmSeekForward);
			}
		}
	}


	// Avoid redraw if no change
	if (TopVisibleRecord != newTopVisibleRecord)
	{
		TopVisibleRecord = newTopVisibleRecord;
		CurrentRecord = noRecord;  	// scrolling always deselects current selection
		PrvListLoadTable(frmP);

		// Need to compare the previous top record to the current after PrvListLoadTable
		// as it will adjust TopVisibleRecord if drawing from newTopVisibleRecord will
		// not fill the whole screen with items.
		if (TopVisibleRecord != prevTopVisibleRecord)
			TblRedrawTable(tblP);
	}
}


/***********************************************************************
 *
 * FUNCTION:    PrvListSelectRecord
 *
 * DESCRIPTION: Selects (highlights) a record on the table, scrolling
 *              the record if neccessary.  Also sets the CurrentRecord.
 *
 * PARAMETERS:  frmP			IN	form
 *				recordNum 		IN 	record to select
 *				forceSelection	IN	force selection
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *         	Name   	Date      	Description
 *        	----   	----      	-----------
 *        	roger  	6/30/95   	Initial Revision
 *			aro		9/25/00		Add frmP as a parameter for frmUpdateEvent
 *								Add a boolean to force selection
 *
 ***********************************************************************/
void PrvListSelectRecord( FormType* frmP, UInt16 recordNum, Boolean forceSelection )
{
	Int16 row, column;
	TableType* tblP;
	UInt16 attr;

	if (recordNum == noRecord)
		return;
	ErrFatalDisplayIf (recordNum >= DmNumRecords(AddrDB), "Record outside AddrDB");


	tblP = ToolsGetFrmObjectPtr(frmP, ListTable);

	if (PrivateRecordVisualStatus > showPrivateRecords)
	{
		// If the record is hidden stop trying to show it.
		if (!DmRecordInfo(AddrDB, recordNum, &attr, NULL, NULL) && (attr & dmRecAttrSecret))
		{
			CurrentRecord = noRecord;
			TblUnhighlightSelection(tblP);
			return;
		}
	}



	// Don't change anything if the same record is selected
	if ((TblGetSelection(tblP, &row, &column)) &&
		(recordNum == TblGetRowID (tblP, row)) &&
		(!forceSelection))
	{
		return;
	}


	// See if the record is displayed by one of the rows in the table
	// A while is used because if TblFindRowID fails we need to
	// call it again to find the row in the reloaded table.
	while (!TblFindRowID(tblP, recordNum, &row))
	{

		// Scroll the view down placing the item
		// on the top row
		TopVisibleRecord = recordNum;

		// Make sure that TopVisibleRecord is visible in CurrentCategory
		if (CurrentCategory != dmAllCategories)
		{
			// Get the category and the secret attribute of the current record.
			DmRecordInfo (AddrDB, TopVisibleRecord, &attr, NULL, NULL);
			if ((attr & dmRecAttrCategoryMask) != CurrentCategory)
			{
				ErrNonFatalDisplay("Record not in CurrentCategory");
				CurrentCategory = (attr & dmRecAttrCategoryMask);
			}
		}

		PrvListLoadTable(frmP);
		TblRedrawTable(tblP);
	}


	// Select the item
	if (forceSelection)
	{
		TblUnhighlightSelection(tblP);
		TblSelectItem (tblP, row, nameAndNumColumn);
	}

	CurrentRecord = recordNum;
}


/***********************************************************************
 *
 * FUNCTION:    PrvListUpdateDisplay
 *
 * DESCRIPTION: This routine update the display of the list view
 *
 * PARAMETERS:  updateCode - a code that indicated what changes have been
 *                           made to the to do list.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *				Name	Date		Description
 *				----	----		-----------
 *				art		6/5/95		Initial Revision
 *				ppo		10/13/99	Fixed bug #22753 (selection not redrawn)
 *				jmp		10/19/99	Changed previous fix to actually to set everything
 *									back up.  The previous change caused bug #23053, and
 *									didn't work in several cases anyway!  Also, optimized
 *									this routine space-wise.
 *				aro		9/26/00		Don't use GetActiveForm for frmRedrawUpdateCode
 *									Fix bug in debug ROM: selection was not restored after Dial or About
 *				fpa		10/26/00	Fixed bug #44352 (Selected line display problem when tapping
 *									menu | Dial, then cancel into Dial Number screen)
 *
 ***********************************************************************/
void PrvListUpdateDisplay( UInt16 updateCode )
{
	TableType* tblP;
	FormType* frmP;

	// Do not use active form here since the update event is broadcasted
	frmP = FrmGetFormPtr(ListView);
	tblP = ToolsGetFrmObjectPtr(frmP, ListTable);

	if (updateCode == frmRedrawUpdateCode)
	{
		TblUnhighlightSelection(tblP);	// Fixed bug #44352. If we don't do that, using a Debug rom, selection is too width when tapping Menu | Dial, then cancel into Dial Number screen (note is selected)
				
		FrmDrawForm(frmP);
		if (CurrentRecord != noRecord)
			PrvListSelectRecord(frmP, CurrentRecord, true);

	}

	if (updateCode & updateRedrawAll ||
		updateCode & updateFontChanged)
	{
		PrvListLoadTable(frmP);
		TblRedrawTable(tblP);
	}

	// Ensure selection is done event when everything is drawn again
	if (updateCode & updateRedrawAll ||
	    updateCode & updateFontChanged ||
		updateCode & updateSelectCurrentRecord)
	{
		if (CurrentRecord != noRecord)
			PrvListSelectRecord(frmP, CurrentRecord, true);
	}
}


/***********************************************************************
 *
 * FUNCTION:    PrvListDeleteRecord
 *
 * DESCRIPTION: This routine deletes an address record. This routine is
 *              called when the delete button in the command bar is
 *              pressed when address book is in list view.  The benefit
 *					 this routine proides over DetailsDeleteRecord is that the
 *					 selection is maintained right up to the point where the address
 *					 is being deleted.
 *
 * PARAMETERS:  nothing
 *
 * RETURNED:    true if the record was delete or archived.
 *
 * REVISION HISTORY:
 *         	Name	Date			Description
 *         	----	----			-----------
 *				gap	11/01/99		new
 *
 ***********************************************************************/
Boolean PrvListDeleteRecord (void)
{
	UInt16	ctlIndex;
	UInt16	buttonHit;
	FormType*	alert;
	Boolean	archive;
	TablePtr	table;


	// Display an alert to comfirm the operation.
	alert = FrmInitForm (DeleteAddrDialog);

	// Set the "save backup" checkbox to its previous setting.
	ctlIndex = FrmGetObjectIndex (alert, DeleteAddrSaveBackup);
	FrmSetControlValue (alert, ctlIndex, SaveBackup);

	buttonHit = FrmDoDialog (alert);

	archive = FrmGetControlValue (alert, ctlIndex);

⌨️ 快捷键说明

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