📄 addrlist.c
字号:
FrmDeleteForm (alert);
if (buttonHit == DeleteAddrCancel)
return (false);
// Remember the "save backup" checkbox setting.
SaveBackup = archive;
// Clear the highlight on the selection before deleting the item.
table = ToolsGetObjectPtr (ListTable);
TblUnhighlightSelection(table);
ToolsDeleteRecord(archive);
return (true);
}
/***********************************************************************
*
* FUNCTION: PrvListDoCommand
*
* DESCRIPTION: This routine performs the menu command specified.
*
* PARAMETERS: command - menu item id
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* art 6/5/95 Initial Revision
* jmp 10/01/99 Changed call to DmOpenDatabaseByTypeCreator() to
* AddrGetDatabase().
* jwm 1999-10-8 After deleting a record, highlight the new selection and
* clear the now possibly completely wrong lookup field.
* hou 2000-11-28 bug #44076 correction: ListOptionsSecurityCmd returns true
*
***********************************************************************/
Boolean PrvListDoCommand (UInt16 command)
{
UInt16 newRecord;
UInt16 numCharsToHilite;
Boolean wasHiding;
UInt16 mode;
switch (command)
{
case ListRecordBeamBusinessCardCmd:
MenuEraseStatus (0);
ToolsAddrBeamBusinessCard(AddrDB);
return true;
case ListRecordBeamCategoryCmd:
MenuEraseStatus (0);
TransferSendCategory(AddrDB, CurrentCategory, exgBeamPrefix, NoDataToBeamAlert);
return true;
case ListRecordSendCategoryCmd:
MenuEraseStatus (0);
TransferSendCategory(AddrDB, CurrentCategory, exgSendPrefix, NoDataToSendAlert);
return true;
case ListRecordDuplicateAddressCmd:
if (CurrentRecord == noRecord)
{
//FrmAlert ();
return true;
}
newRecord = ToolsDuplicateCurrentRecord (&numCharsToHilite, false);
// If we have a new record take the user to be able to edit it
// automatically.
if (newRecord != noRecord)
{
NumCharsToHilite = numCharsToHilite;
CurrentRecord = newRecord;
FrmGotoForm (EditView);
}
return true;
case ListRecordDialCmd:
{
UInt16 phoneIndex;
Err error;
AddrDBRecordType record;
MemHandle recordH;
if (CurrentRecord == noRecord)
{
SndPlaySystemSound (sndError);
return true;
}
error = AddrDBGetRecord (AddrDB, CurrentRecord, &record, &recordH);
if (error)
{
ErrNonFatalDisplay ("Record not found");
return false;
}
phoneIndex = record.options.phones.displayPhoneForList;
// Release the record.
MemHandleUnlock(recordH);
DialListShowDialog(CurrentRecord, phoneIndex, 0);
return true;
}
case ListRecordDeleteRecordCmd:
if (CurrentRecord != noRecord)
{
if (PrvListDeleteRecord ())
{
PrvListClearLookupString ();
PrvListUpdateDisplay (updateRedrawAll | updateSelectCurrentRecord);
}
}
else
SndPlaySystemSound (sndError);
return true;
case ListRecordBeamRecordCmd:
if (CurrentRecord != noRecord)
{
MenuEraseStatus (0);
TransferSendRecord(AddrDB, CurrentRecord, exgBeamPrefix, NoDataToBeamAlert);
}
else
SndPlaySystemSound (sndError);
return true;
case ListOptionsFontCmd:
{
FontID newFont;
MenuEraseStatus(0);
newFont = ToolsSelectFont(AddrListFont);
// The update event for font changed is post so when the
// item is highlighted in the updateEvent handler, the drawing was made with a bad font
// So force unhighlight here
if (newFont != AddrListFont)
{
TblUnhighlightSelection(ToolsGetObjectPtr(ListTable));
// now set the new font
AddrListFont = newFont;
}
return true;
}
case ListOptionsListByCmd:
MenuEraseStatus (0);
PrvListClearLookupString();
FrmPopupForm (PreferencesDialog);
return true;
case ListOptionsEditCustomFldsCmd:
MenuEraseStatus (0);
FrmPopupForm (CustomEditDialog);
return true;
case ListOptionsSecurityCmd:
wasHiding = (PrivateRecordVisualStatus == hidePrivateRecords);
PrivateRecordVisualStatus = SecSelectViewStatus();
if (wasHiding != (PrivateRecordVisualStatus == hidePrivateRecords))
{
// Close the application's data file.
DmCloseDatabase (AddrDB);
mode = (PrivateRecordVisualStatus == hidePrivateRecords) ?
dmModeReadWrite : (dmModeReadWrite | dmModeShowSecret);
AddrDBGetDatabase(&AddrDB, mode);
ErrFatalDisplayIf(!AddrDB,"Can't reopen DB");
}
//For safety, simply reset the currentRecord
TblReleaseFocus (ToolsGetObjectPtr (ListTable));
PrvListUpdateDisplay (updateRedrawAll | updateSelectCurrentRecord);
//updateSelectCurrentRecord will cause currentRecord to be reset to noRecord if hidden or masked
return true; // Hou: bug #44076 correction: used to be "break;" -> caused the event to not be handled
case ListOptionsAboutCmd:
MenuEraseStatus (0);
AbtShowAbout (sysFileCAddress);
return true;
default:
break;
}
return false;
}
/***********************************************************************
*
* FUNCTION: PrvListHandleRecordSelection
*
* DESCRIPTION: This routine handles table selection in the list view,
* either selecting the name to go to RecordView, or selecting
* the phone number to dial.
*
*
* PARAMETERS: event - pointer to the table enter event
*
* RETURNED: whether the event was handled
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* peter 05/08/00 Initial Revision
* aro 06/22/00 Add dialing checking and feature
* aro 9/25/00 Disable selection when entering the table
*
***********************************************************************/
Boolean PrvListHandleRecordSelection( EventType* event )
{
TablePtr table;
Int16 row, column, phoneX;
Boolean isSelected, isPenDown;
UInt16 recordNum;
Err error;
AddrDBRecordType record;
MemHandle recordH;
FontID currFont;
Char * phone;
RectangleType bounds, numberBounds;
Coord x, y;
UInt16 phoneIndex;
// Disable the current selection
CurrentRecord = noRecord;
// Check if "Enable tap-dialing" is set in prefs
if (!EnableTapDialing)
return false;
table = event->data.tblSelect.pTable;
row = event->data.tblSelect.row;
column = event->data.tblSelect.column;
// If the column being tapped on isn't the name and number column,
// let the table handle selection to view the note.
if (column != nameAndNumColumn)
return false;
// If the record is masked, dialing is impossible, so just let
// the table handle selection.
if (TblRowMasked(table, row))
return false;
// Extract the x coordinate of the start of the phone number for this row.
// This was computed and stored in the row data when the row was drawn.
phoneX = TblGetRowData(table, row);
// If the user tapped on the name rather than the number, or on the space between them,
// let the table handle selection so the user gets to view the record.
if (event->screenX < phoneX)
return false;
// Get the record number that corresponds to the table item to draw.
// The record number is stored in the "intValue" field of the item.
recordNum = TblGetRowID (table, row);
error = AddrDBGetRecord (AddrDB, recordNum, &record, &recordH);
if (error)
{
ErrNonFatalDisplay ("Record not found");
return false;
}
phoneIndex = record.options.phones.displayPhoneForList;
phone = record.fields[phone1 + phoneIndex];
// If there is no phone number, if the phone is not part of supported
// dial phone number, let the table handle selection.
if ((phone == chrNull) || (!ToolsIsPhoneIndexSupported(&record, phoneIndex)) )
goto CleanUpAndLeaveUnhandled;
// The user tapped on the phone number, so instead of letting the
// table handle selection, we highlight just the phone number.
// First, deselect the row if it is selected.
CurrentRecord = noRecord;
TblUnhighlightSelection(table);
// Set up the drawing state the way we want it.
WinPushDrawState();
WinSetBackColor(UIColorGetTableEntryIndex(UIFieldBackground));
WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
currFont = FntSetFont (AddrListFont);
TblGetItemBounds (table, row, column, &bounds);
numberBounds = bounds;
numberBounds.extent.x -= phoneX - numberBounds.topLeft.x; // Maintain same right side.
numberBounds.topLeft.x = phoneX;
// Extend left side of selection rectangle one pixel since we have the room.
// It'd be great if we could extend the right side as well, so that the 'W'
// for Work numbers wouldn't touch the edge of the selection rectangle, but
// then it'd hit up against the note icon.
numberBounds.topLeft.x--;
numberBounds.extent.x ++;
// Draw the phone number selected.
PrvListReplaceTwoColors(&numberBounds, 0,
UIObjectForeground, UIFieldBackground, UIObjectSelectedForeground, UIObjectSelectedFill);
isSelected = true;
do {
PenGetPoint (&x, &y, &isPenDown);
if (RctPtInRectangle (x, y, &numberBounds))
{
if (! isSelected)
{
isSelected = true;
PrvListReplaceTwoColors(&numberBounds, 0,
UIObjectForeground, UIFieldBackground, UIObjectSelectedForeground, UIObjectSelectedFill);
}
}
else if (isSelected)
{
isSelected = false;
PrvListReplaceTwoColors(&numberBounds, 0,
UIObjectSelectedForeground, UIObjectSelectedFill, UIObjectForeground, UIFieldBackground);
}
} while (isPenDown);
if (isSelected)
PrvListReplaceTwoColors(&numberBounds, 0,
UIObjectSelectedForeground, UIObjectSelectedFill, UIObjectForeground, UIFieldBackground);
// Restore the previous drawing state.
FntSetFont (currFont);
WinPopDrawState();
// Release the record.
MemHandleUnlock(recordH);
if (isSelected)
{
// Make it the current item
CurrentRecord = recordNum;
// Dial the number.
return DialListShowDialog(recordNum, phoneIndex, 0);
}
return true; // Don't let the table do any selection
CleanUpAndLeaveUnhandled:
// Release the record.
MemHandleUnlock(recordH);
return false;
}
/***********************************************************************
*
* FUNCTION: PrvListReplaceTwoColors
*
* DESCRIPTION: This routine does a selection or deselection effect by
* replacing foreground and background colors with a new pair
* of colors. In order to reverse the process, you must pass
* the colors in the opposite order, so that the current
* and new colors are known to this routine. This routine
* correctly handling the cases when two or more of these
* four colors are the same, but it requires that the
* affected area of the screen contains neither of the
* given NEW colors, unless these colors are the same as
* one of the old colors.
*
* PARAMETERS: rP - pointer to a rectangle to 'invert'
* cornerDiam - corner diameter
* oldForeground - UI color currently used for foreground
* oldBackground - UI color currently used for background
* newForeground - UI color that you want for foreground
* newBackground - UI color that you want for background
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* peter 05/19/00 Initial Revision
*
***********************************************************************/
void PrvListReplaceTwoColors (const RectangleType *rP, UInt16 cornerDiam, UIColorTableEntries oldForeground, UIColorTableEntries oldBackground, UIColorTableEntries newForeground, UIColorTableEntries newBackground)
{
WinPushDrawState();
WinSetDrawMode(winSwap);
WinSetPatternType (blackPattern);
if (UIColorGetTableEntryIndex(newBackground) == UIColorGetTableEntryIndex(oldForeground))
if (UIColorGetTableEntryIndex(newForeground) == UIColorGetTableEntryIndex(oldBackground))
{
// Handle the case when foreground and background colors change places,
// such as on black and white systems, with a single swap.
WinSetBackColor(UIColorGetTableEntryIndex(oldBackground));
WinSetForeColor(UIColorGetTableEntryIndex(oldForeground));
WinPaintRectangle(rP, cornerDiam);
}
else
{
// Handle the case when the old foreground and the new background
// are the same, using two swaps.
WinSetBackColor(UIColorGetTableEntryIndex(oldForeground));
WinSetForeColor(UIColorGetTableEntryIndex(oldBackground));
WinPaintRectangle(rP, cornerDiam);
WinSetBackColor(UIColorGetTableEntryIndex(oldBackground));
WinSetForeColor(UIColorGetTableEntryIndex(newForeground));
WinPaintRectangle(rP, cornerDiam);
}
else if (UIColorGetTableEntryIndex(oldBackground) == UIColorGetTableEntryIndex(newForeground))
{
// Handle the case when the old background and the new foreground
// are the same, using two swaps.
WinSetBackColor(UIColorGetTableEntryIndex(newForeground));
WinSetForeColor(UIColorGetTableEntryIndex(oldForeground));
WinPaintRectangle(rP, cornerDiam);
WinSetBackColor(UIColorGetTableEntryIndex(newBackground));
WinSetForeColor(UIColorGetTableEntryIndex(oldForeground));
WinPaintRectangle(rP, cornerDiam);
}
else
{
// Handle the case when no two colors are the same, as is typically the case
// on color systems, using two swaps.
WinSetBackColor(UIColorGetTableEntryIndex(oldBackground));
WinSetForeColor(UIColorGetTableEntryIndex(newBackground));
WinPaintRectangle(rP, cornerDiam);
WinSetBackColor(UIColorGetTableEntryIndex(oldForeground));
WinSetForeColor(UIColorGetTableEntryIndex(newForeground));
WinPaintRectangle(rP, cornerDiam);
}
WinPopDrawState();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -