Link to: header | other data directory
Copyright Turtle Creek Software 1996-2006. All Rights Reserved.
Comments
DB_ObjectClassInfo
basic persistent information about a class. This is used for accounts and
transactions that need to remember custom fields, active records and calculators
that are based on the class.
This class manages accounting class info for the Goldenseal job cost accounting software,
project management software, construction
estimating software
and construction project estimating software.
This is the place to permanently store anything that applies to a variety of
classes.
Another place for class info is DB_ClassDescriptor. It is the repository for
static member field info (read in from MEMB resources), and contains many static
functions related to class characteristics. Info in DB_ClassDescriptor is
NOT stored in the database, but we read it in from the resources every time
the program opens.
SUPERCLASS = DB_PersistentObject
Constructor
/*********************************************************************************
default constructor
*********************************************************************************/
DB_ObjectClassInfo::DB_ObjectClassInfo()
{
mOwnerID = 0;
mCurrentRecord = 0;
mCurrentPrintForm = 0;
mDefaultIconID = 0; // TCS 6/22/02
mRecentFormType = 0;
mWindowState = triState_Off;
mWindowOrder = 0;
mWindowIsStored = false;
mShowsBlankDate = false;
mIsCurrentlyDisplayed = false; // TCS 4/11/01
mWasChangedRemotely = false;
mNeedsMainAccount = false; // TCS 4/16/01 (no interface to set yet)
mNeedsJobAccount = false;
mNeedsCategory = false;
mWindowIsShaded = false;
mWindowIsDocked = false; // TCS 9/23/02
mNewShowsTemplates = false; // TCS 11/27/03
mWindowBounds.top = 40;
mWindowBounds.left = 40;
mWindowBounds.bottom = 240;
mWindowBounds.right = 340;
mDockedWindowBounds.top = 0; // TCS 9/23/02
mDockedWindowBounds.left = 0;
mDockedWindowBounds.bottom = 0;
mDockedWindowBounds.right = 0;
mWindowParams = 0;
mOpenToBreakdown = 0; // TCS 3/11/03
mNewRowCostArea = 0;
mRecentPrintRange = 0;
mExpansionEnum = 0;
mExpansionMoney = 0;
mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}
Source Code
/*********************************************************************************
GetFileLength
return the file length to reserve for this object
*********************************************************************************/
NeoSize DB_ObjectClassInfo::GetFileLength(const CNeoFormat *aFormat) const
{
NeoVersion version = GetVersion();
NeoSize rectSize = sizeof(TCS_Rect);
NeoSize shortSize = sizeof(UInt16);
NeoSize moneySize = sizeof(CMoney);
NeoSize tagSize = sizeof(TagType);
if (version == 1)
{
return THE_SUPERCLASS::GetFileLength(aFormat) +
ARRAY_FILE_SIZE(mCustomFieldArray) +
cFileLength;
}
else // TCS 2/21/03
{
return THE_SUPERCLASS::GetFileLength(aFormat) +
ARRAY_FILE_SIZE(mCustomFieldArray) +
ARRAY_FILE_SIZE(mIndexedFieldArray) +
mSpareText.LongFileLength(cMaximumTextLen) +
cFileLength;
}
}
/*********************************************************************************
GetMemberValue
return the value of the member with the given tag
*********************************************************************************/
Boolean DB_ObjectClassInfo::GetMemberValue(const NeoTag aTag, const NeoTag aType,
void *aValue) const
{
switch (aTag)
{
case tag_currentrecord:
return ConvertMember(&mCurrentRecord, type_objectid, aValue, aType);
break;
case tag_currentprintform:
return ConvertMember(&mCurrentPrintForm, type_objectid, aValue, aType);
break;
case tag_owner:
return ConvertMember(&mOwnerID, type_objectid, aValue, aType); // bugfix TCS 4/11/01
break;
case tag_opentobreakdown: // TCS 3/11/03
{
UInt8 menuID = DB_ClassDescriptor::GetBreakdownMenuID(GetDBID());
return ConvertEnumMember(mOpenToBreakdown, menuID, aValue, aType);
}
break;
case tag_newrowcostarea: // TCS 3/11/03
return ConvertEnumMember(mNewRowCostArea, MENU_MasterCostTypes, aValue, aType);
break;
/*case tag_helptext: // TCS 2/21/03
return ConvertMember(&mHelpText, type_longcstring, aValue, aType);
break;*/
case tag_name: // TCS 9/23/02
case tag_menuname:
{
CTextString outName = DB_ClassDescriptor::GetClassNamePlural(GetDBID());
return ConvertMember(&outName, type_cstring, aValue, aType);
}
break;
// other members are accessed by direct calls. We really don't need
// this method at all, since this class never appears in windows
default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
SetMemberValue
set the value of the member with the given tag
*********************************************************************************/
Boolean DB_ObjectClassInfo::SetMemberValue(const NeoTag aTag, const NeoTag aType,
const void *aValue)
{
switch (aTag)
{
case tag_currentrecord:
return ConvertMember(aValue, aType, &mCurrentRecord, type_objectid);
break;
case tag_currentprintform:
return ConvertMember(aValue, aType, &mCurrentPrintForm, type_objectid);
break;
case tag_owner:
return ConvertMember(aValue, aType, &mOwnerID, type_objectid); // bugfix TCS 4/11/01
break;
case tag_opentobreakdown: // TCS 3/11/03
return ConvertMember(aValue, aType, &mOpenToBreakdown, type_enum);
break;
case tag_newrowcostarea: // TCS 3/11/03
return ConvertMember(aValue, aType, &mNewRowCostArea, type_enum);
break;
/*case tag_helptext: // TCS 2/21/03
return SafeConvertString(aValue, aType, &mHelpText, type_longcstring);
break;*/
// other members are accessed by direct calls. We really don't need
// this method at all, since it never appears in windows
default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************
ReadObject
read the persistent object's data in from a stream
*********************************************************************************/
void DB_ObjectClassInfo::ReadObject(CNeoStream *aStream, const NeoTag aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
CNeoDebugImport checker(aStream, this, cCheckTooSmall); // TCS 2/24/00
THE_SUPERCLASS::ReadObject(aStream, aTag);
if (!IsIOValid()) // TCS 2/5/02
return;
NeoVersion version = GetVersion();
ReadMemberArrayFromStream(aStream, mCustomFieldArray, cHasSafetyTag);
if (version > 1) // TCS 2/21/03
{
ReadTagArrayFromStream(aStream, mIndexedFieldArray, cHasSafetyTag);
ReadLongTextFromStream(aStream, &mSpareText);
}
/// aStream->ReadChunk(&mOwnerID, cFileLength);
mOwnerID = aStream->ReadID(); // mfs_sa rev 20feb2k3
mCurrentRecord = aStream->ReadID();
mCurrentPrintForm = aStream->ReadID();
mDefaultIconID = aStream->ReadID();
mRecentFormType = aStream->ReadChar();
mWindowState = aStream->ReadChar();
mWindowOrder = aStream->ReadChar();
*((UInt8*)&mWindowOrder + sizeof(mWindowOrder)) = aStream->ReadBits(7); // --Bitfield
mWindowBounds.top = aStream->ReadUShort();
mWindowBounds.left = aStream->ReadUShort();
mWindowBounds.bottom = aStream->ReadUShort();
mWindowBounds.right = aStream->ReadUShort();
mDockedWindowBounds.top = aStream->ReadUShort();
mDockedWindowBounds.left = aStream->ReadUShort();
mDockedWindowBounds.bottom = aStream->ReadUShort();
mDockedWindowBounds.right = aStream->ReadUShort();
mWindowParams = aStream->ReadUShort();
mRecentPrintRange = aStream->ReadChar();
mOpenToBreakdown = aStream->ReadChar();
mNewRowCostArea = aStream->ReadChar();
mExpansionEnum = aStream->ReadChar();
mExpansionMoney.ReadFromStream(aStream);
mEndSafetyTag = aStream->ReadEndSafetyTag(this);
if (!IsValidEndTag(mEndSafetyTag)) // TCS 9/8/02
ReportDamagedObject(GetDBClassID(), GetDBID());
}/*********************************************************************************
WriteObject
write the persistent object's data to a stream
*********************************************************************************/
void DB_ObjectClassInfo::WriteObject(CNeoStream *aStream, const NeoTag aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));
// make sure we have valid data to write TCS 9/8/02
if (!IsValidEndTag(mEndSafetyTag))
{
ReportDamagedObject(GetDBClassID(), GetDBID());
mEndSafetyTag = tag_endsafetytag; // rev TCS 11/26/02
}
NeoVersion version = GetVersion();
CNeoDebugExport checker(aStream, this, cCheckTooSmall);
THE_SUPERCLASS::WriteObject(aStream, aTag);
WriteMemberArrayToStream(aStream, mCustomFieldArray, cHasSafetyTag);
if (version > 1) // TCS 2/21/03
{
WriteTagArrayToStream(aStream, mIndexedFieldArray, cHasSafetyTag);
WriteLongTextToStream(aStream, &mSpareText, cMaximumTextLen);
}
/// aStream->WriteChunk(&mOwnerID, cFileLength);
aStream->WriteID(mOwnerID); // mfs_sa rev 20feb2k3
aStream->WriteID(mCurrentRecord);
aStream->WriteID(mCurrentPrintForm);
aStream->WriteID(mDefaultIconID);
aStream->WriteChar(mRecentFormType);
aStream->WriteChar(mWindowState);
aStream->WriteChar(mWindowOrder);
aStream->WriteChar(*((UInt8*)&mWindowOrder + sizeof(mWindowOrder))); // --Bitfield
aStream->WriteUShort(mWindowBounds.top);
aStream->WriteUShort(mWindowBounds.left);
aStream->WriteUShort(mWindowBounds.bottom);
aStream->WriteUShort(mWindowBounds.right);
aStream->WriteUShort(mDockedWindowBounds.top);
aStream->WriteUShort(mDockedWindowBounds.left);
aStream->WriteUShort(mDockedWindowBounds.bottom);
aStream->WriteUShort(mDockedWindowBounds.right);
aStream->WriteUShort(mWindowParams);
aStream->WriteChar(mRecentPrintRange);
aStream->WriteChar(mOpenToBreakdown);
aStream->WriteChar(mNewRowCostArea);
aStream->WriteChar(mExpansionEnum);
mExpansionMoney.WriteToStream(aStream);
aStream->WriteEndSafetyTag(mEndSafetyTag, this);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
IsValidCustomTag TCS 2/21/99
return whether the given tag is a valid custom tag. That means it has the
correct format(c001 to c999) and is not already in use
*********************************************************************************/
Boolean DB_ObjectClassInfo::IsValidCustomTag(const TagType inTag)
{
// first check for valid text
if (CCalculatorList::GetCalculatorClassID(inTag) != id_ObjectClassInfo)
return false;
if (!CCalculatorList::GetCalculatorItemID(inTag))
return false;
// now look through custom tags
if (DB_ClassDescriptor::HasCustomField(inTag))
return false;
else
return true;
}
/*********************************************************************************
AddCustomField TCS 6/2/99
add a new custom field. We shouldn't have to worry about whether the field
is already there.
*********************************************************************************/
Boolean DB_ObjectClassInfo::AddCustomField(const SMemberInfo &memberInfo)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectTempRemover remover (this); // TCS 8/26/03
if (remover.WasRemoved())
{
mCustomFieldArray.Append(memberInfo);
}
return true;
}
/*********************************************************************************
RemoveCustomField TCS 6/2/99
remove a custom field
*********************************************************************************/
/*Boolean DB_ObjectClassInfo::RemoveCustomField(const TagType tag)
{
// first let's find the item
SInt32 index = 0;
SMemberInfo memberInfo;
TMemberArrayIterator iterator(mCustomFieldArray);
while (iterator.Next(memberInfo))
{
if (memberInfo.tag == tag)
{
index = iterator.GetCurrentIndex();
break;
}
}
if (index)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
gDBFile->TempRemoveObject(this);
mCustomFieldArray.RemoveItemAt(index);
gDBFile->TempAddObject(this);
MakeDirty();
return true;
}
else
return false;
}*/
/*********************************************************************************
GetCustomFieldIndex TCS 6/3/99
return the position index of the custom field with the given tag
*********************************************************************************/
SInt32 DB_ObjectClassInfo::GetCustomFieldIndex(const TagType tag)
{
SMemberInfo memberInfo;
TMemberArrayIterator iterator(mCustomFieldArray);
while (iterator.Next(memberInfo))
{
if (memberInfo.tag == tag)
{
return iterator.GetCurrentIndex();
}
}
// if we got this far, no custom field with that tag
return 0;
}
/*********************************************************************************
GetCustomFieldInfo TCS 2/11/03
fill in custom field info for the custom field with the given tag, and
return success
*********************************************************************************/
Boolean DB_ObjectClassInfo::GetCustomFieldInfo(const TagType tag, SMemberInfo &memberInfo)
{
TMemberArrayIterator iterator(mCustomFieldArray);
while (iterator.Next(memberInfo))
{
if (memberInfo.tag == tag)
{
return true;
}
}
// if we got this far, no custom field with that tag
return false;
}
/*********************************************************************************
FetchCustomFieldInfo TCS 6/2/99
fetch info about the nth custom field
*********************************************************************************/
Boolean DB_ObjectClassInfo::FetchCustomFieldInfo(const SInt32 index, SMemberInfo &memberInfo)
{
if (mCustomFieldArray.GetCount() >= index)
{
return mCustomFieldArray.FetchItemAt(index, memberInfo);
}
else
return false;
}
/*********************************************************************************
UpdateDescriptor TCS 6/4/99
update custom fields in the class descriptor
*********************************************************************************/
void DB_ObjectClassInfo::UpdateDescriptor()
{
if (DB_ClassDescriptor::HasDescriptor(GetDBID())) // TCS 5/1/02
{
DB_ClassDescriptor *descriptor = DB_ClassDescriptor::GetClassDescriptor(GetDBID());
TCS_FailNILMsg(descriptor, TCS_GetErrString(errID_BadDescriptor));
SMemberInfo memberInfo;
TMemberArrayIterator iterator(mCustomFieldArray);
while (iterator.Next(memberInfo))
{
descriptor->AddCustomField(memberInfo);
}
}
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
SetCurrentRecordID TCS rev 5/26/99
store the currently displayed record
*********************************************************************************/
void DB_ObjectClassInfo::SetCurrentRecordID(const DBid inID)
{
mCurrentRecord = inID;
MakeDirty();
}
/*********************************************************************************
SetOwnerID TCS 5/26/99 rev 9/30/00
store the currently displayed owner ID. This is used for bank
transactions if only one account is being shown. For other classes it is
not needed.
*********************************************************************************/
void DB_ObjectClassInfo::SetOwnerID(const DBid inID)
{
mOwnerID = inID;
MakeDirty();
}
/*********************************************************************************
SetFormType TCS 6/1/99
store the currently displayed form type
*********************************************************************************/
void DB_ObjectClassInfo::SetFormType(const DBClass inID)
{
mRecentFormType = inID;
MakeDirty();
}
/*********************************************************************************
SetIsCurrentlyDisplayed TCS moved 11/28/00
store the current display status for this class. We formerly set window
position info here, but that is now done separately.
*********************************************************************************/
void DB_ObjectClassInfo::SetIsCurrentlyDisplayed(const Boolean inValue)
{
mIsCurrentlyDisplayed = inValue;
MakeDirty();
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
StoreWindowInfo (static) TCS 11/28/00
store the window location for the given class ID
*********************************************************************************/
Boolean DB_ObjectClassInfo::StoreWindowInfo(const DBClass inClass, const SWindowPosInfo inInfo,
const UInt8 order)
{
if (!gDBFile) // TCS 4/10/01
return false;
if (gIsClient) // TCS 4/9/03
return false;
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
info->SetWindowInfo(inInfo, order);
return true;
}
else
return false;
}
/*********************************************************************************
StoreFormType (static) TCS 2/28/01
store the current display form type for the given class ID
*********************************************************************************/
Boolean DB_ObjectClassInfo::StoreFormType(const DBClass inClass, const UInt8 formType)
{
if (!gDBFile) // TCS 4/10/01
return false;
if (gIsClient) // TCS 4/9/03
return false;
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
info->SetFormType(formType);
return true;
}
else
return false;
}
/*********************************************************************************
FetchWindowInfo (static) TCS 11/28/00
fetch the window location for the given class ID
*********************************************************************************/
Boolean DB_ObjectClassInfo::FetchWindowInfo(const DBClass outClass, SWindowPosInfo &outInfo,
UInt8 &order)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, outClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
return info->GetWindowInfo(outInfo, order);
}
else
return false;
}
/*********************************************************************************
SetWindowInfo TCS 11/28/00
store the window location for the given class ID
*********************************************************************************/
void DB_ObjectClassInfo::SetWindowInfo(const SWindowPosInfo inInfo, const UInt8 order)
{
mWindowState = inInfo.isVisible;
mWindowBounds = inInfo.bounds;
mDockedWindowBounds = inInfo.dockBounds; // TCS 9/23/02
/*mWindowBounds.top = inInfo.bounds.top;
mWindowBounds.left = inInfo.bounds.left;
mWindowBounds.bottom = inInfo.bounds.bottom;
mWindowBounds.right = inInfo.bounds.right;
mDockedWindowBounds.top = inInfo.dockBounds.top; // TCS 9/16/02
mDockedWindowBounds.left = inInfo.dockBounds.left;
mDockedWindowBounds.bottom = inInfo.dockBounds.bottom;
mDockedWindowBounds.right = inInfo.dockBounds.right;*/
mWindowParams = inInfo.windowParams;
mWindowIsShaded = inInfo.isShaded;
mWindowIsDocked = inInfo.isDocked; // TCS 9/23/02
mWindowIsStored = true; // rev TCS 4/10/01
mWindowOrder = order;
MakeDirty();
}
/*********************************************************************************
GetWindowInfo TCS 11/28/00
fetch the window location for the given class ID
*********************************************************************************/
Boolean DB_ObjectClassInfo::GetWindowInfo(SWindowPosInfo &outInfo, UInt8 &outOrder)
{
ETriState visState = triState_Off;
if (mWindowState == triState_On)
visState = triState_On;
else if (mWindowState == triState_Latent)
visState = triState_Latent;
outInfo.isVisible = visState;
outInfo.bounds = mWindowBounds;
outInfo.dockBounds = mDockedWindowBounds; // TCS 9/23/02
outInfo.windowParams = mWindowParams;
outInfo.windowID = GetDBID();
outOrder = mWindowOrder;
outInfo.isShaded = mWindowIsShaded; // TCS 7/23/01
outInfo.isDocked = mWindowIsDocked; // TCS 9/23/02
return mWindowIsStored; // rev TCS 4/11/01
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************
AutoEntersDate (static) TCS 4/11/01
does the given class auto-enter today's date?
*********************************************************************************/
Boolean DB_ObjectClassInfo::AutoEntersDate(const DBClass inClass)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
return info->AutoEntersDate();
}
else
return false;
}
/*********************************************************************************
SetAutoEntersDate (static) TCS 4/11/01
does the given class auto-enter today's date?
*********************************************************************************/
void DB_ObjectClassInfo::SetAutoEntersDate(const DBClass inClass, const Boolean inValue)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
info->SetAutoEntersDate(inValue);
info->MakeDirty(); // bugfix 8/8/01
// give audible feedback TCS 3/11/03
if (DB_PersistentObject::GetPrefsBoolean(id_InterfacePrefs, tag_playsoundatsave))
TCS_MakeSound(SND_Bip);
}
}
/*********************************************************************************
NewShowsTemplates (static) TCS 11/27/03
should we show templates when the user clicks the New button?
*********************************************************************************/
Boolean DB_ObjectClassInfo::NewShowsTemplates(const DBClass inClass)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
return info->NewShowsTemplates();
}
else
return false;
}
/*********************************************************************************
SetNewShowsTemplates (static) TCS 11/27/03
set whether the new button shows templates for this class
*********************************************************************************/
void DB_ObjectClassInfo::SetNewShowsTemplates(const DBClass inClass, const Boolean inValue)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
info->SetNewShowsTemplates(inValue);
info->MakeDirty();
// give audible feedback
if (DB_PersistentObject::GetPrefsBoolean(id_InterfacePrefs, tag_playsoundatsave))
TCS_MakeSound(SND_Bip);
}
}
/*********************************************************************************
GetOpenToBreakdown (static) TCS 3/11/03
return the breakdown that we show for new records
*********************************************************************************/
UInt8 DB_ObjectClassInfo::GetOpenToBreakdown(const DBClass inClass)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
UInt8 outValue = 0;
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
outValue = info->GetOpenToBreakdown();
}
if (outValue)
return outValue;
else
return breakdown_longform;
}
/*********************************************************************************
SetOpenToBreakdown (static) TCS 3/11/03
set the breakdown that we show to start, in a new record
*********************************************************************************/
void DB_ObjectClassInfo::SetOpenToBreakdown(const DBClass inClass, const UInt8 inValue)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
info->SetOpenToBreakdown(inValue);
info->MakeDirty();
// give audible feedback TCS 3/11/03
if (DB_PersistentObject::GetPrefsBoolean(id_InterfacePrefs, tag_playsoundatsave))
TCS_MakeSound(SND_Bip);
}
}
/*********************************************************************************
GetCustomFieldCount (static) TCS 2/7/02
get the number of custom fields specified for the given class
*********************************************************************************/
SInt32 DB_ObjectClassInfo::GetCustomFieldCount(const DBClass inClass)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
return info->GetCustomFieldCount();
}
else
return 0;
}
/*********************************************************************************
GetCustomFieldName (static) TCS 12/5/02
get the name of the given custom field for the given class
*********************************************************************************/
CTextString DB_ObjectClassInfo::GetCustomFieldName(const DBClass inClass, const UInt8 index)
{
TCS_FailNILMsg(gDBFile, TCS_GetErrString(errID_BadFile));
DB_ObjectClassInfo *info = TCS_SAFE_CAST(gDBFile->GetOneObject(id_ObjectClassInfo, inClass),
DB_ObjectClassInfo);
if (info)
{
DB_ObjectWatcher watcher(info);
return info->FetchCustomFieldName(index);
}
else
return cEmptyString;
}
/*********************************************************************************
FetchCustomFieldName TCS 12/5/02
get the name of the given custom field
*********************************************************************************/
CTextString DB_ObjectClassInfo::FetchCustomFieldName(const UInt8 index) const
{
SMemberInfo memberInfo;
if (mCustomFieldArray.FetchItemAt(index, memberInfo))
{
CTextString outName = CTextString(memberInfo.memberName);
return outName;
}
else
return cEmptyString;
}
/*********************************************************************************
FillDataReport TCS 9/7/02
fill in a diagnostic table that shows data field values.
*********************************************************************************/
void DB_ObjectClassInfo::FillDataReport(CTCS_Table *table, CNeoStream *stream) const
{
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
TCS_FailNILMsg(stream, TCS_GetErrString(errID_BadStream));
THE_SUPERCLASS::FillDataReport(table, stream);
NeoVersion version = GetVersion();
FillFieldArrayRow(table, stream, "mCustomFieldArray", mCustomFieldArray, false);
SInt32 fieldCount = mCustomFieldArray.GetCount();
if (fieldCount > 0) // TCS 12/19/02
{
CTextString labelString;
for (SInt32 index = 1; index <= fieldCount; index++)
{
labelString = TCS_GetStockString(stockID_CustomField);
labelString.AppendWithSpace(index);
FillFieldTableRow(table, stream, labelString, sizeof(SMemberInfo), cTwoDashString);
}
}
if (version > 1) // TCS 2/21/03
{
FillFieldArrayRow(table, stream, "mIndexedFieldArray", mIndexedFieldArray);
FillFieldStringRow(table, stream, TCS_GetStockString(stockID_Expansion), mSpareText, true);
}
FillFieldTableRow(table, stream, "mOwnerID", cLongSize, mOwnerID);
FillFieldTableRow(table, stream, "mCurrentRecord", cLongSize, mCurrentRecord);
FillFieldTableRow(table, stream, "mCurrentPrintForm", cLongSize, mCurrentPrintForm);
FillFieldTableRow(table, stream, "mDefaultIconID", cLongSize, mDefaultIconID);
FillFieldTableRow(table, stream, "mRecentFormType", cCharSize, SInt32(mRecentFormType));
FillFieldTableRow(table, stream, "mWindowState", cCharSize, SInt32(mWindowState));
FillFieldTableRow(table, stream, "mWindowOrder", cCharSize, SInt32(mWindowOrder));
FillFieldBitRow(table, stream, "mWindowIsStored", mWindowIsStored, true);
FillFieldBitRow(table, stream, "mShowsBlankDate", mShowsBlankDate);
FillFieldBitRow(table, stream, "mNeedsMainAccount", mNeedsMainAccount);
FillFieldBitRow(table, stream, "mNeedsJobAccount", mNeedsJobAccount);
FillFieldBitRow(table, stream, "mNeedsCategory", mNeedsCategory);
FillFieldBitRow(table, stream, "mWindowIsShaded", mWindowIsShaded);
FillFieldBitRow(table, stream, "mWindowIsDocked", mWindowIsDocked);
FillFieldBitRow(table, stream, "mNewShowsTemplates", mNewShowsTemplates);
FillFieldTableRow(table, stream, "window top", cShortSize, mWindowBounds.top);
FillFieldTableRow(table, stream, "window left", cShortSize, mWindowBounds.left);
FillFieldTableRow(table, stream, "window bottom", cShortSize, mWindowBounds.bottom);
FillFieldTableRow(table, stream, "window right", cShortSize, mWindowBounds.right);
FillFieldTableRow(table, stream, "dock top", cShortSize, mDockedWindowBounds.top);
FillFieldTableRow(table, stream, "dock left", cShortSize, mDockedWindowBounds.left);
FillFieldTableRow(table, stream, "dock bottom", cShortSize, mDockedWindowBounds.bottom);
FillFieldTableRow(table, stream, "dock right", cShortSize, mDockedWindowBounds.right);
FillFieldTableRow(table, stream, "mWindowParams", cShortSize, SInt32(mWindowParams));
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mRecentPrintRange));
FillFieldTableRow(table, stream, "mOpenToBreakdown", cCharSize, SInt32(mOpenToBreakdown));
FillFieldTableRow(table, stream, "mNewRowCostArea", cCharSize, SInt32(mNewRowCostArea));
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, mExpansionEnum);
FillFieldStockRow(table, stream, stockID_Expansion, cMoneySize, mExpansionMoney.GetNumberString());
FillEndSafetyTag(table, stream, mEndSafetyTag);
}
|