LocalEnvironment Class Reference

Provide access to the locale settings Camelot is running under. More...

#include <localenv.h>

List of all members.

Static Public Member Functions

static BOOL UpdateCachedInfo ()
 Call to (re)cache info held in this class. Obviously call on startup, and also when the user changes the machine settings.
static void GetNumberOfDecimalPlaces (UINT32 *DecimalPlaces)
 Call the OS to get the number of decimal places we should use to display numbers. Default is 2.
static void GetThousandsSeparator (StringBase *String)
 Call the OS to get the character used as a thousands separator. Default separator is ",".
static void GetDecimalPointChar (StringBase *String)
 Call the OS to get the character used as a decimal point character. Default decimal point character is ".".
static void SystemDateToString (StringBase *String, time_t *Time)
 Produce a formatted string representing a date. The format to use is read from the OS (and thus is locale dependent).
static void SystemTimeToString (StringBase *String, time_t *Time)
 Produce a formatted string representing a time. The format to use is read from the OS (and thus is locale dependent).
static UINT32 GetMouseDoubleClickDelay ()
 Gets the maximum time allowed between two clicks that make up a double click.
static UINT32 GetXMouseDoubleClickMove ()
 Returns the maximum allowed movment (in mouse units) between two clicks that compose a double click.
static UINT32 GetYMouseDoubleClickMove ()
 Returns the maximum allowed movment (in mouse units) between two clicks that compose a double click.

Static Protected Attributes

static UINT32 MouseDoubleClickDelay
static UINT32 XMouseDoubleClickMove
static UINT32 YMouseDoubleClickMove

Private Member Functions

 CC_DECLARE_MEMDUMP (LocalEnvironment)


Detailed Description

Provide access to the locale settings Camelot is running under.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/08/94

Definition at line 116 of file localenv.h.


Member Function Documentation

LocalEnvironment::CC_DECLARE_MEMDUMP LocalEnvironment   )  [private]
 

void LocalEnvironment::GetDecimalPointChar StringBase String  )  [static]
 

Call the OS to get the character used as a decimal point character. Default decimal point character is ".".

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/1/95
Parameters:
String - pointer to the string to store the decimal point character in. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 207 of file localenv.cpp.

00208 {
00209     *String = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
00210 }

UINT32 LocalEnvironment::GetMouseDoubleClickDelay  )  [static]
 

Gets the maximum time allowed between two clicks that make up a double click.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Max time (in milliseconds) allowed between two clicks composing a double click

Errors: -

See also:
-

Definition at line 416 of file localenv.cpp.

00417 {
00418     return MouseDoubleClickDelay;
00419 }

void LocalEnvironment::GetNumberOfDecimalPlaces UINT32 DecimalPlaces  )  [static]
 

Call the OS to get the number of decimal places we should use to display numbers. Default is 2.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/08/94
Parameters:
DecimalPlaces - pointer to the UINT32 to store the number found in. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 144 of file localenv.cpp.

00145 {
00146     TCHAR TS[8];
00147 
00148 
00149 PORTNOTE("other","Removed GetProfileString usage")
00150 #if defined(__MSW__)
00151     GetProfileString("intl", "iDigits", "2", TS, sizeof(TS));
00152 #else
00153 #if 0
00154 // AMB removed libiconv usage
00155     struct lconv *lc;
00156     lc = localeconv();
00157     TRACEUSER( "luke", _T("iDigits = %d\n"), lc->frac_digits );
00158     *DecimalPlaces = (UINT32)lc->frac_digits;
00159     return;
00160 #else //0
00161     TS[0]=_T('2');
00162     TS[1]=0;
00163 #endif //0
00164 #endif
00165 
00166     // Convert the string into a number that the string represents which we
00167     // can then return to the caller.
00168     TCHAR* pszMark;
00169     *DecimalPlaces = camStrtol( TS, &pszMark, 10 );
00170 }

void LocalEnvironment::GetThousandsSeparator StringBase String  )  [static]
 

Call the OS to get the character used as a thousands separator. Default separator is ",".

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/08/94
Parameters:
String - pointer to the string to store the separator in. [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 187 of file localenv.cpp.

00188 {
00189     *String = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER);
00190 }

UINT32 LocalEnvironment::GetXMouseDoubleClickMove  )  [static]
 

Returns the maximum allowed movment (in mouse units) between two clicks that compose a double click.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Max horizontal movement allowed between two clicks composing a double click

Errors: -

See also:
-

Definition at line 436 of file localenv.cpp.

00437 {
00438     return XMouseDoubleClickMove;
00439 }

UINT32 LocalEnvironment::GetYMouseDoubleClickMove  )  [static]
 

Returns the maximum allowed movment (in mouse units) between two clicks that compose a double click.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Max vertical movement allowed between two clicks composing a double click

Errors: -

See also:
-

Definition at line 456 of file localenv.cpp.

00457 {
00458     return YMouseDoubleClickMove;
00459 }

void LocalEnvironment::SystemDateToString StringBase String,
time_t *  Time
[static]
 

Produce a formatted string representing a date. The format to use is read from the OS (and thus is locale dependent).

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com> (but copied from Andy's code)
Date:
31/08/94
Parameters:
String - pointer to the string to store the time in. [INPUTS] Time - the time and date in an ANSI time_t structure.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
SystemTimeToString

Definition at line 229 of file localenv.cpp.

00230 {
00231     TCHAR c;
00232     TCHAR TimeFormat[40];
00233     TCHAR Temp[40];
00234     TCHAR Bodge[2];
00235     LPTCHAR p = TimeFormat;
00236     tm* TimeParts = localtime(Time);
00237     INT32 digits;
00238 
00239     GetProfileString("Intl", "sShortDate", "dd/MM/yy", TimeFormat, sizeof(TimeFormat));
00240     String->Empty();
00241     Bodge[1] = 0;
00242 
00243     while (c=*p++)
00244     {
00245         Bodge[0] = c;
00246         TCHAR* AnotherBodge = CharUpper(Bodge);
00247         TCHAR uc = *AnotherBodge;
00248         digits = 1;
00249 
00250         // this code relies on the same case being used throughout the field (e.g. ddDD will fail)
00251         while (c == *p)
00252         {
00253             c = *p++;
00254             digits ++;
00255         }
00256         switch (uc)
00257         {
00258             case TEXT('D') :
00259                 if (digits == 1)
00260                 {
00261                     wsprintf(Temp, "%d", TimeParts->tm_mday);
00262                 }
00263                 else
00264                 {
00265                     wsprintf(Temp, "%02d", TimeParts->tm_mday);
00266                 }
00267                 break;  
00268             case TEXT('M') :
00269                 if (digits == 1)
00270                 {
00271                     wsprintf(Temp, "%d", TimeParts->tm_mon+1);
00272                 }
00273                 else
00274                 {
00275                     wsprintf(Temp, "%02d", TimeParts->tm_mon+1);
00276                 }
00277                 break;  
00278             case TEXT('Y') :
00279                 if (digits == 2)
00280                 {
00281                     wsprintf(Temp, "%02d", TimeParts->tm_year % 100);
00282                 }
00283                 else
00284                 {
00285                     wsprintf(Temp, "%d", TimeParts->tm_year+1900);
00286                 }
00287                 break;
00288         }
00289         *String += Temp;
00290         if (*p != 0)
00291         {
00292             Bodge[0] = *p++;
00293             *String += Bodge;
00294         }
00295     }
00296 }

void LocalEnvironment::SystemTimeToString StringBase String,
time_t *  Time
[static]
 

Produce a formatted string representing a time. The format to use is read from the OS (and thus is locale dependent).

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com> (but copied from Andy's code)
Date:
31/08/94
Parameters:
String - pointer to the string to store the time in. [INPUTS] Time - the time and date in an ANSI time_t structure.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
SystemDateToString

Definition at line 316 of file localenv.cpp.

00317 {
00318     TCHAR Format[20];
00319     TCHAR Temp[40];
00320     TCHAR Separator[10];
00321     INT32 Hours;
00322     BOOL Trail = FALSE;
00323     tm* TimeParts = localtime(Time);
00324 
00325     Hours = TimeParts->tm_hour;
00326 
00327     GetProfileString("Intl", "iTime", "", Format, sizeof(Format));
00328     if (Format[0]=='0')
00329     {   // 12 hour clock wanted
00330         if (Hours>=12)
00331         {
00332             Trail = TRUE;
00333         }
00334         if (Hours>12)
00335         {
00336             Hours -= 12;
00337         }
00338     }
00339     else
00340     {   // 24 hour format
00341         Trail = TRUE;               
00342     }
00343     GetProfileString("Intl", "iTLZero", "1", Format, sizeof(Format));
00344     if (Format[0]=='1')
00345     {   // leading zeros please
00346         wsprintf(Temp, "%02d", Hours);
00347     }
00348     else
00349     {
00350         wsprintf(Temp, "%d", Hours);
00351     }
00352     *String = Temp;
00353     GetProfileString("Intl", "sTime", ":", Separator, sizeof(Separator));
00354     wsprintf(Temp, "%s%02d%s%02d", Separator, TimeParts->tm_min,
00355                                                             Separator, TimeParts->tm_sec);
00356     *String += Temp;
00357     if ((TimeParts->tm_hour < 12) && GetProfileString("Intl", "s1159", "",
00358                                                                     Format, sizeof(Format)))
00359     {
00360         wsprintf(Temp, "%s", Format);
00361         *String += Temp;
00362     }
00363     if (Trail && GetProfileString("Intl", "s2359", "", Format, sizeof(Format)))
00364     {
00365         wsprintf(Temp, "%s", Format);
00366         *String += Temp;
00367     }
00368 }

BOOL LocalEnvironment::UpdateCachedInfo  )  [static]
 

Call to (re)cache info held in this class. Obviously call on startup, and also when the user changes the machine settings.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Errors: -

See also:
-

Definition at line 385 of file localenv.cpp.

00386 {
00387     // Get max time between two clicks making double clicks
00388 PORTNOTE("other","Removed GetProfileString usage")
00389 #ifndef EXCLUDE_FROM_XARALX
00390     MouseDoubleClickDelay = ::GetProfileInt("Windows","DoubleClickSpeed", 452);
00391 #else
00392     MouseDoubleClickDelay = 452;
00393 #endif
00394 
00395     // Get max movement between two clicks making double clicks
00396     XMouseDoubleClickMove = wxSystemSettings::GetMetric( wxSYS_DCLICK_X );
00397     YMouseDoubleClickMove = wxSystemSettings::GetMetric( wxSYS_DCLICK_X );
00398 
00399     return TRUE;
00400 }


Member Data Documentation

UINT32 LocalEnvironment::MouseDoubleClickDelay [static, protected]
 

Definition at line 132 of file localenv.h.

UINT32 LocalEnvironment::XMouseDoubleClickMove [static, protected]
 

Definition at line 133 of file localenv.h.

UINT32 LocalEnvironment::YMouseDoubleClickMove [static, protected]
 

Definition at line 134 of file localenv.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:05 2007 for Camelot by  doxygen 1.4.4