WDS_String

WDS_String

wds

1998 12-05


CLASS

WDS_String - extended general purpose character string


SYNOPSIS

Class WDS_String is an extension of EW_String, adding functionality. Many WDS widgets will expect WDS_String's and will probably fail if pure EW_String's are used.


PUBLIC MEMBER FUNCTIONS

Inheritance from class EW_String



void SetStyle(long set)

void SetStyleIncluding(long set)

void SetStyleExcluding(long set)

long GetStyle(void)
Set/Get the style used when the string is drawn. The members SetStyleIncluding() and SetStyleExcluding() set or clear only the bits corresponding to value in set. Currently acceptable OR'able values for set are as follows. Enumeration values are given for clarity; they are subject to change.



WDS_STRING_STYLE_NULL 0 No special styling.
WDS_STRING_STYLE_3D 1 Adds a shadow by drawing the string offset and in black before drawing the string normally. This can make the string much easier to read, but consumes twice the rendering time.
WDS_STRING_STYLE_UNDERLINE 2 The entire string will be underlined.
WDS_STRING_STYLE_BOLD 4 Creates a bold-like effect by drawing a displaced copy. Like WDS_STRING_STYLE_3D, this can double the rendering time. This is entirely different from, and probably inferior to, requesting an actual bold font.



void SetEditable(long set)

long GetEditable(void)
Set/Get the ability to edit the string.



void SetHighlight(long set)

long GetHighlight(void)
Set/Get the effect of diagonal background hashing.



long GetNumberLines(EW_Window *root,long width)
For a given width, returns the number of lines that would result if drawn.



long GetStringSpace(EW_Window *root,long *width)
Without the specific width limitations as in GetNumberLines(), returns the number of lines that would result if drawn. Also sets width to the width of the widest line, in pixels. Multiple lines can occur, for example, if there are newlines in the string.



void SetDisplayChar(long set)

char GetDisplayChar(void)
Set the character (in ASCII) to be displayed instead of each real character in the string, such as when hiding passwords. When set is the value zero, characters are drawn normally.



void SetCursorColor(long fg,long bg)

void GetCursorColor(long *fg,long *bg)
Set/Get the color used to show the "marked" or "selected" region of the string.



void SetConfirmCallback(WDS_String_ConfirmCallback fp,long flags)
Set a callback function to be called whenever the string changes to confirm that it is valid, changing it if neccessary.
WDS_String_ConfirmCallback is defined as
typedef long (*WDS_String_ConfirmCallback)(WDS_String *,long).
The function pointer fp can point to any function, but WDS_String defines several applicable static functions for this use including:

The flags for these functions may be the OR'ed sum of the following. Enumeration values are given for clarity; they are subject to change.



WDS_CONFIRM_NULL 0x00 No special flags.
WDS_CONFIRM_ALLOW_EMPTY 0x01 Empty strings are not reformatted.
WDS_CONFIRM_MARK_INVALID 0x02 Limits the efforts to correct inappropriate strings. Instead of valiantly attempting to parse these strings, replace them with text indicating they are invalid.
WDS_CONFIRM_LEAD_ZERO 0x04 Where appropriate use leading zeros to maintain consistant length, such as with months and days in dates.
WDS_CONFIRM_USA 0x00 Use dates common in the US, such as 12-31-1997. (default)
WDS_CONFIRM_ISO 0x08 Use ISO 8601 dates, such as 1997-12-31. The optional hyphens are included for clarity.
WDS_CONFIRM_DASH 0x00 Use a '-' as the date delimiter, such as 7-4-1776. (default)
WDS_CONFIRM_STROKE 0x10 Use a '/' as the date delimiter, such as 7/4/1776.
WDS_CONFIRM_AMPM 0x00 Use 12 hour times with am and pm, such as 5:37pm. (default)
WDS_CONFIRM_24HR 0x20 Use 24 hour "military" times, such as 1837 for 6:37pm.
WDS_CONFIRM_SECONDS 0x40 Display seconds in time strings.
WDS_CONFIRM_NANP 0x08 Display phone numbers in US NANP: 800 123-4567
WDS_CONFIRM_NANP_PRETTY 0x0c Display phone numbers in US NANP with parentheses: (800) 123-4567
WDS_CONFIRM_CCITT 0x10 Display phone numbers in international CCITT with a period separator: 12.3456789 The prefix may have 2 to 8 digits.
WDS_CONFIRM_MAP_CHAR 0x20 For phone numbers, map letter characters into numbers using the US standard.


These given callbacks are fairly capable of interpreting input data in various formats. For example, even in USA/AMPM mode, ConfirmDateTime() will interpret an ISO date 9707191343 into "7-19-1997 1:43:00pm". The confirmation flags are mostly intended to define output, but can bias input interpretation as well. If there are multiple interpretations, such as a date 01-02-03 (Jan 2, 2003 or Feb 3, 2001), the callback will use the input format matching it's confirmation flags. Note that even though date subfields can be automatically reordered, ConfirmDateTime() always assumes that the date preceeds the time.
If a ConfirmDateTime() contains a single region of whitespace between non-whitespace characters, then that region is always used to split the date and time. For dates and times, single digit values without delimiters must have a leading zero. For example, 1-2-97 is acceptable, but 1297 is not, but could be entered as 010297.
Using delimiters (generally anything except digits, including whitespace) between values can help the interpretation in many cases.
To help prevent misinterpretation, it is recommended that users and software inputs always state full four-digit years, especially on and after the year 2000. This is particularly important if seconds are specified in a date-time field.
Without delimiters, it is assumed that all dates post-date 1231 AD.
Day/Month/Year and Year/Day/Month are explicitly NOT recognized. The date algorithm accounts for the post-1700 leap year centenary exception and quadcentenary counter-exception, as well as the fact that the period Sept 3-13, 1752 never occurred.


For ConfirmPhone() , the default (with flags set to WDS_CONFIRM_NULL) is up to 15 numerical digits with no formatting. Reasonable methods are used to interpret incomplete input. Leading zeros, where appropriate, are retained. Character digits A through Y, except Q (lowercase and uppercase) are optionally mapped into numeric digits using the US standard.


ConfirmSSN() conforms to a US Social Security Number, the generally accepted unique identifier for a US citizen. The first nine numeric digits are used. Extra digits are discarded. Insufficient digits results in trailing zeros. Non-numeric characters are not used in the interpretation. Output appears with dashes added, such as 012-34-5678.


ConfirmLong(), ConfirmFloat(), and ConfirmDouble() recognize exponential notation and suffix multipliers. For exponential notation, the letter E (lowercase or uppercase) refers to "times ten to the power of" as in 1.2E9 or 3.4e-12. For suffix multipliers, the first non-whitespace character after the number can be interpreted as a metric-like scalar. For example, "5.2k" will be converted into 5200. The following characters are currently recognized, shown here in grouped increasing magnitude:
Aa Ff p Nn Uu m Cc% d D Hh Kk M Gg Tt P Xx, refering to

The standard character 'e' for exa is not available since it conflicts with the exponential notation and 'da' for deca since it is not a single character. Note that many computer related references arguably misuse the terms kilo, mega, and giga as mulitples of 1024.


FILES

wds/str.h WDS string header file


SEE ALSO

WDS_Widget(3), WDS_intro(3), EW_String(3)


NOTES

WDS_String() could be expanded to accomodate more complex formatting.