Accounting Software
Small Business Software Estimating Software
Project Management SoftwareProject Estimating SoftwareProject Tracking SoftwareInventory Tracking SoftwareCustomer Tracking SoftwareCustomer Management SoftwareBusiness Management Software

Hardware Environment (Source Code)

Link to: header | other interface directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CTCS_Environment

This class manages info about the basic hardware environment in the
Goldenseal small business accounting software,
project management software, construction accounting software
and construction software.

It's a utility class for handling environment-specific items
such as date formatting and screen size

Superclass: UEnvironment

Source Code

/******************************************************************************

GetFeatureResult

Returns the result for the given feature
inSelector should be a Gestalt selector(usu. with 'Version' suffix)

*******************************************************************************/
SInt32 CTCS_Environment::GetFeatureResult(OSType inSelector)
{
#if TCS_CANUSE_QUICKTIME
SInt32 gestaltResult;
if (::Gestalt(inSelector, &gestaltResult) == noErr)
return gestaltResult;
else
return 0;
#elif TCS_FOR_WINDOWS
NeoUsed(inSelector);
return 0;
#endif
}
/******************************************************************************

GetSystemInfo

Sets up the static member variables v1.4, 12-27-95, 03-18-97

*******************************************************************************/
void CTCS_Environment::GetSystemInfo()
{
#if TCS_CANUSE_QUICKTIME
sIconType = eMacIconFamilies;
SInt32 response;
Boolean tmp;
::Gestalt(gestaltDragMgrAttr, &response);
tmp = ((response & (1L << gestaltDragMgrPresent)) != 0);
#if TCS_FOR_MAC
if (HasGestaltAttribute(gestaltDragMgrAttr, gestaltDragMgrPresent))
sDragManager = eMacDragMgr;
else
sDragManager = eNoDragMgr;
#else
sDragManager = eNoDragMgr; // No drag manager on Windows
#endif
// Get internatinal decimal, etc chars
Intl0Hndl intMarksH = (Intl0Hndl) TCS_GetIntlResource(0);
TStHandleLocker locker((TCS_Handle) intMarksH);
Intl0Rec intMarksR = **intMarksH;
// Get month & day names, etc.
InitCalendarInfo(intMarksR);
// Get the separators & symbols
sDecimalMark += intMarksR.decimalPt;
sThousandsSeparator += intMarksR.thousSep;
sListSeparator += intMarksR.listSep;
sTimeSeparator += intMarksR.timeSep;
sCurrencySymbol += intMarksR.currSym1;
if (intMarksR.currSym2 != cNullChar)
sCurrencySymbol += intMarksR.currSym2;
if (intMarksR.currSym3 != cNullChar)
sCurrencySymbol += intMarksR.currSym3;
sCurrencyFormat = intMarksR.currFmt; // TCS 10/16/02
// Get time cycle
if (intMarksR.timeCycle == timeCycle24)
{
// 24 hour cycle
sTimeCycle = eTimeCycle24;
}
else if (intMarksR.timeCycle == timeCycleZero)
{
// 12 hour cycle, noon & midnight = 0
sTimeCycle = eTimeCycleZero;
}
else if (intMarksR.timeCycle == timeCycle12)
{
// 12 hour cycle, noon & midnight = 12
sTimeCycle = eTimeCycle12;
}
else
{
// Unknown time cycle
sTimeCycle = eTimeCycleUndefined;
}
// Get the time format & suffix strings
sTimeFormat = intMarksR.timeFmt;
for (int i = 0;(i < 4) && (intMarksR.mornStr [i] != cNullChar); i++)
{
sMorningSuffix += intMarksR.mornStr [i];
}
for (int i = 0;(i < 4) && (intMarksR.eveStr [i] != cNullChar); i++)
{
sEveningSuffix += intMarksR.eveStr [i];
}
if (intMarksR.time1Suff != cNullChar)
sTime24Suffix = intMarksR.time1Suff;
if (intMarksR.time2Suff != cNullChar)
sTime24Suffix += intMarksR.time2Suff;
if (intMarksR.time3Suff != cNullChar)
sTime24Suffix += intMarksR.time3Suff;
if (intMarksR.time4Suff != cNullChar)
sTime24Suffix += intMarksR.time4Suff;
if (intMarksR.time5Suff != cNullChar)
sTime24Suffix += intMarksR.time5Suff;
if (intMarksR.time6Suff != cNullChar)
sTime24Suffix += intMarksR.time6Suff;
if (intMarksR.time7Suff != cNullChar)
sTime24Suffix += intMarksR.time7Suff;
if (intMarksR.time8Suff != cNullChar)
sTime24Suffix += intMarksR.time8Suff;
// Check if using metric measurements
sUsingMetric = (intMarksR.metricSys == 255);
#elif TCS_FOR_WINDOWS
sIconType = eNoIcons;
sDragManager = eNoDragMgr;
// %%% Need to find Windows func to get international marks
TCS_NYI("CTCS_Environment::Init");
sDecimalMark = ".";
sThousandsSeparator = ",";
sListSeparator = ";";
sDateSeparator = "/";
sTimeSeparator = ":";
//%%% Need to find windows func to get international month names
for (int i = 0; i < 12; i++)
sMonthNames [i] = "%%% undefined";
ErrorInit();
#endif
// Perform additional initializations
InitNumNames();
InitCurrencyNames();
}/******************************************************************************

InitCalendarInfo

Initializes date format, month names, etc. v1.0, 04-02-97

*******************************************************************************/
#if TCS_CANUSE_QUICKTIME
void CTCS_Environment::InitCalendarInfo(const Intl0Rec & inIntlMarks)
{
Intl1Hndl intl1H = (Intl1Hndl) TCS_GetIntlResource(1);
TStHandleLocker lock((Handle) intl1H);
sDateSeparator = inIntlMarks.dateSep;
// Get date order & date formats
sDateOrder = inIntlMarks.dateOrder;
sShortDateFormat = inIntlMarks.shrtDateFmt;
sLongDateFormat = (**intl1H).lngDateFmt;
sAbbrevLength = (**intl1H).abbrLen;
// Get month names
for (int i = 0; i < cNumMonths; i++)
sMonthNames [i] = (**intl1H).months [i];
// Get Day names
for (int i = 0; i < cNumDays; i++)
sDayNames [i] = (**intl1H).days [i];
// Get long date separators
sLongDateSeparators [date_Preceding] = (**intl1H).st0;
sLongDateSeparators [date_DayNameAndNumber] = (**intl1H).st1;
sLongDateSeparators [date_DayNumberAndMonth] = (**intl1H).st2;
sLongDateSeparators [date_MonthAndYear] = (**intl1H).st3;
sLongDateSeparators [date_Trailing] = (**intl1H).st4;
}
#else
void CTCS_Environment::InitCalendarInfo()
{
}
#endif/******************************************************************************

InitNumNames

Gets the number name strings v1.0, 10-21-96

*******************************************************************************/
void CTCS_Environment::InitNumNames()
{
SInt8 index;
// Get the ones place names
for (index = 0; index < 20; index++)
TCS_GetIndString(STRI_OnesNames, index + 1, & (sOnesNumNames [index]));
// Get the tens place names bugfix TCS 9/5/02
for (index = 0; index < 9; index++)
TCS_GetIndString(STRI_TensNames, index + 1, & (sTensNumNames [index]));
// Get the hundred names rev TCS 8/1/02, bugfix TCS 9/5/02
for (index = 0; index < 9; index++)
TCS_GetIndString(STRI_HundredNames, index + 1, & (sHundredsNames [index]));
// Get the thousand names rev TCS 8/1/02, bugfix TCS 9/5/02
for (index = 0; index < 9; index++)
TCS_GetIndString(STRI_ThousandNames, index + 1, & (sThousandsNames [index]));
// Get the large number (thousand, million, etc.) names
for (index = 0; index < 5; index++)
TCS_GetIndString(STRI_LargeNumberNames, index + 1, & (sLargeNumNames [index]));
}/******************************************************************************

InitCurrencyNames v1.1, 10-22-96, 03-18-97 rev TCS 10/16/02

Gets the currency name strings

*******************************************************************************/
void CTCS_Environment::InitCurrencyNames()
{
// Get the currency names
for (SInt8 index = 0; index < cNumCurrencyNames; index++)
TCS_GetIndString(STRI_CurrencyNames, index + 1, & (sCurrencyNames [index]));
}/******************************************************************************

ScreenDepth v1.01, 02-19-96, 02-10-97

Returns the current screen depth

*******************************************************************************/
UInt16 CTCS_Environment::ScreenDepth()
{
#if TCS_CANUSE_QUICKTIME
GDHandle device = ::GetDeviceList();
TCS_FailNILMsg(device, TCS_GetErrString(errID_BadGraphic));
return (**((**device).gdPMap)).pixelSize;
#elif TCS_FOR_WINDOWS
return 1;
#endif
}/******************************************************************************

ScreenSize v1.0, 04-26-96

Passes back a TCS_Rect set to the current screen size

*******************************************************************************/
TCS_Rect CTCS_Environment::ScreenSize()
{
#if TCS_CANUSE_QUICKTIME
GDHandle device = ::GetDeviceList();
TCS_FailNILMsg(device, TCS_GetErrString(errID_BadGraphic));
return (**device).gdRect;
#else
TCS_Rect rect = { 0, 0, 0, 0 };
return rect;
#endif
}/******************************************************************************

GetNegativeStr

Returns negative formatting, v1.0, 01-09-97

inSide refers to the portion of the negative formatting to return
negative_LeftSide returns the string to insert before the value
negative_RightSide returns the string to append to the value
The left or right side, or both, could be an empty string

*******************************************************************************/
/*CTextString CTCS_Environment::GetNegativeStr(SInt8 inSide)
{
if (inSide == negative_LeftSide)

TCS_ASSERTMsg((inSide == negative_LeftSide) || (inSide == negative_RightSide),
TCS_GetErrString(errID_BadString));
return &sNegativeFormat [inSide];
}*//******************************************************************************

GetTimeSuffix

Returns the current time suffix v1.0.1, 03-18-97, 04-02-97

*******************************************************************************/
CTextString CTCS_Environment::GetTimeSuffix()
{
if (sTimeCycle == eTimeCycle24)
{
return sTime24Suffix;
}
else
{
CDate now = CDate::Now();
// Get the current hour to check if it's AM or PM
if (now.GetHour() > 11)
return sEveningSuffix;
else
return sMorningSuffix;
}
}/******************************************************************************

GetMonthName

Returns the name of a month, v1.1, VP 02-19-96, JT 04-02-97
inAbbrev param selects full or abbreviated month name

*******************************************************************************/
CTextString CTCS_Environment::GetMonthName(unsigned char inMonth,
unsigned char inAbbrev)
{
if ((inMonth > 0) && (inMonth <= cNumMonths)) // bugfix TCS 12/27/01
{
if (inAbbrev == name_Abbreviated)
{
CTextString abbrev = sMonthNames[inMonth - 1];
abbrev.GetSubString(&abbrev, 1, sAbbrevLength);
return abbrev;
}
else
{
return sMonthNames [inMonth - 1];
}
}
else
{
return TCS_GetStockString(stockID_BadMonth);
}
}/******************************************************************************

GetDayName

Returns the name of a day, v1.0, 04-02-97
inAbbrev param selects full or abbreviated day name

*******************************************************************************/
CTextString CTCS_Environment::GetDayName(unsigned char inDay,
unsigned char inAbbrev)
{
if ((inDay > 0) && (inDay <= cNumDays)) // bugfix TCS 12/27/01
{
if (inAbbrev == name_Abbreviated)
{
CTextString abbrev = sDayNames[inDay - 1];
abbrev.GetSubString(&abbrev, 1, sAbbrevLength);
return abbrev;
}
else
{
return sDayNames [inDay - 1];
}
}
else
{
return TCS_GetStockString(stockID_BadDay);
}
}/******************************************************************************

GetLongDateSeparator

Returns a long date separator, v1.0, 04-02-97

*******************************************************************************/
CTextString CTCS_Environment::GetLongDateSeparator(UInt8 inPosition)
{
if ((inPosition > 0) && (inPosition < 5))
{
return sLongDateSeparators [inPosition];
}
else
{
return TCS_GetStockString(stockID_BadDay);
}
}
/******************************************************************************

HasLeftCurrencySign TCS 10/16/02

is there a currency sign on the left of money values?

*******************************************************************************/
Boolean CTCS_Environment::HasLeftCurrencySign()
{
return sCurrencyFormat & currSymLead;
}
/******************************************************************************

HasRightCurrencySign TCS 10/16/02

is there a currency sign on the right of money values?

*******************************************************************************/
Boolean CTCS_Environment::HasRightCurrencySign()
{
return !(sCurrencyFormat & currSymLead);
}
/******************************************************************************

PercentChar TCS 10/17/02

get the percent character. We now fetch it from a resource (and grab
only the first character here, if it's multiple char.

*******************************************************************************/
char CTCS_Environment::PercentChar()
{
CTextString percentString = GetPercentSign();
return percentString.GetFirstChar();
}