#define DrawText | ( | hdc, | |||
text, | |||||
n, | |||||
rc, | |||||
format | ) | DrawTextEx2 (hdc, text, n, rc, 0, format, NULL) |
Draws a formatted text in a rectangle.
Defined as a macro calling DrawTextEx2 passing nIndent as 0 and firstline as NULL.
#define DrawTextEx | ( | hdc, | |||
text, | |||||
n, | |||||
rc, | |||||
indent, | |||||
format | ) | DrawTextEx2 (hdc, text, n, rc, indent, format, NULL) |
Draws a formatted text in a rectangle.
Defined as a macro calling DrawTextEx2 passing firstline as NULL.
#define GetTextAboveLineExtra | ( | hdc | ) | GetDCAttr (hdc, DC_ATTR_ALINE_EXTRA) |
Retrieves the current spacing above line for the DC.
#define GetTextAlign | ( | hdc | ) | GetDCAttr (hdc, DC_ATTR_TEXT_ALIGN) |
Retrieves the current text-alignment flags of a DC.
hdc | The device context. |
1. Apply the bitwise OR operator to the flag and its related flags, grouped as follows:
2. Apply the bitwise-AND operator to the result and the return value of GetTextAlign.
3. Test for the equality of this result and the flag.
#define GetTextBellowLineExtra | ( | hdc | ) | GetDCAttr (hdc, DC_ATTR_BLINE_EXTRA) |
Retrieves the current spacing bellow line for the DC.
#define GetTextCharacterExtra | ( | hdc | ) | GetDCAttr (hdc, DC_ATTR_CHAR_EXTRA) |
Retrieves the current intercharacter spacing for the DC.
#define SetTextAboveLineExtra | ( | hdc, | |||
extra | ) | SetDCAttr (hdc, DC_ATTR_ALINE_EXTRA, (DWORD) extra) |
Sets the spacing above line for the DC and returns the old value.
#define SetTextAlign | ( | hdc, | |||
ta_flags | ) | SetDCAttr (hdc, DC_ATTR_TEXT_ALIGN, (DWORD)ta_flags) |
Sets text-alignment flags of a DC.
hdc | The device context. | |
ta_flags | The flags specify the relationship between a point and a rectangle that bounds the text. The point can be either the current position or coordinates specified by a text-output function. The rectangle that bounds the text is defined by the adjacent character cells in the text string. The ta_flags parameter can be one or more flags from the following three categories. Choose only one flag from each category. |
The first category affects text alignment in the x-direction:
The second category affects text alignment in the y-direction:
The third category determines whether the current position is updated when text is written:
#define SetTextBellowLineExtra | ( | hdc, | |||
extra | ) | SetDCAttr (hdc, DC_ATTR_BLINE_EXTRA, (DWORD) extra) |
Sets the spacing bellow line for the DC and returns the old value.
#define SetTextCharacterExtra | ( | hdc, | |||
extra | ) | SetDCAttr (hdc, DC_ATTR_CHAR_EXTRA, (DWORD) extra) |
Sets the intercharacter spacing for the DC and returns the old spacing value.
#define TabbedTextOut | ( | hdc, | |||
x, | |||||
y, | |||||
text | ) | TabbedTextOutLen (hdc, x, y, text, -1) |
Outputs formatted text.
Defined as a macro calling TabbedTextOutLen passing len as -1.
#define TextOut | ( | hdc, | |||
x, | |||||
y, | |||||
text | ) | TextOutLen (hdc, x, y, text, -1) |
typedef struct _DTFIRSTLINE DTFIRSTLINE |
First line information of DrawTextEx2
int GUIAPI DrawTextEx2 | ( | HDC | hdc, | |
const char * | pText, | |||
int | nCount, | |||
RECT * | pRect, | |||
int | nIndent, | |||
UINT | nFormat, | |||
DTFIRSTLINE * | firstline | |||
) |
Draws a formatted text in a rectangle.
This function draws formatted text (pText) in the specified rectangle (pRect). It formats the text according to the specified method (through nFormat, including expanding tabs, justifying characters, breaking lines, and so forth).
hdc | The device context. | |
pText | The formatted text. | |
nCount | The length of the text. If it is less than 0, MiniGUI will treat it as a null-terminated string. | |
pRect | The output rectangle. | |
nIndent | The indent value of the first line. | |
nFormat | The methods used to format the text. MiniGUI support the following method to format text so far: |
firstline | If not null, DrawTextEx2 will only calculate the first line will be output in the rectangle, and return the number of the characters and the output width. |
Example:
void OnModeDrawText (HDC hdc) { RECT rc1, rc2, rc3, rc4; const char* szBuff1 = "This is a good day. \n" "This text is drawn by calling DrawText."; const char* szBuff2 = "This is a good day. \n" "This text is drawn by calling DrawText."; const char* szBuff3 = "Single line text, center."; const char* szBuff4 = "This text is drawn by calling DrawText."; rc1.left = 1; rc1.top = 1; rc1.right = 401; rc1.bottom = 101; rc2.left = 0; rc2.top = 110; rc2.right = 401; rc2.bottom = 351; rc3.left = 0; rc3.top = 361; rc3.right = 401; rc3.bottom = 451; rc4.left = 0; rc4.top = 461; rc4.right = 401; rc4.bottom = 551; SetBkColor (hdc, COLOR_lightwhite); Rectangle (hdc, rc1.left, rc1.top, rc1.right, rc1.bottom); Rectangle (hdc, rc2.left, rc2.top, rc2.right, rc2.bottom); Rectangle (hdc, rc3.left, rc3.top, rc3.right, rc3.bottom); Rectangle (hdc, rc4.left, rc4.top, rc4.right, rc4.bottom); InflateRect (&rc1, -1, -1); InflateRect (&rc2, -1, -1); InflateRect (&rc3, -1, -1); InflateRect (&rc4, -1, -1); SelectFont (hdc, logfontgb12); DrawText (hdc, szBuff1, -1, &rc1, DT_NOCLIP | DT_CENTER | DT_WORDBREAK); SelectFont (hdc, logfontgb16); DrawText (hdc, szBuff2, -1, &rc2, DT_NOCLIP | DT_RIGHT | DT_WORDBREAK); SelectFont (hdc, logfontgb24); DrawText (hdc, szBuff3, -1, &rc3, DT_NOCLIP | DT_SINGLELINE | DT_CENTER | DT_VCENTER); SelectFont (hdc, logfontgb16); DrawTextEx (hdc, szBuff4, -1, &rc4, 32, DT_NOCLIP | DT_LEFT | DT_WORDBREAK); }
int GUIAPI GetFontHeight | ( | HDC | hdc | ) |
Retrieves the height of the current logical font in a DC.
This function retrieves the height of the current logical font in the DC hdc.
hdc | The device context. |
Retrieves the last text output position.
hdc | The device context. | |
pt | The last text output position will be returned through this pointer. |
int GUIAPI GetMaxFontWidth | ( | HDC | hdc | ) |
Retrieves the maximal character width of the current logical font in a DC.
This function retrieves the maximal character width of the current logical font in the DC hdc.
hdc | The device context. |
Computes the output extent of a formatted text.
This function computes the output extent of the formatted text (spText) with length of len. This function returns the extent in a SIZE struct pointed to by pSize and the width of text as the return value. The output extent will be affected by the default tab size if there are some TAB characters in the text.
hdc | The device context. | |
spText | The pointer to the string of text. | |
len | The length of the text. | |
pSize | The output extent will be returned through this buffer. |
Computes the output extent of a string of text.
This function computes the output extent of the text (spText) with length of len. This function returns the extent in a SIZE struct pointed to by pSize and the width of text as the return value.
hdc | The device context. | |
spText | The pointer to the string of text. | |
len | The length of the text. | |
pSize | The output extent will be returned through this buffer. |
int GUIAPI TabbedTextOutEx | ( | HDC | hdc, | |
int | x, | |||
int | y, | |||
const char * | spText, | |||
int | nCount, | |||
int | nTabPositions, | |||
int * | pTabPositions, | |||
int | nTabOrigin | |||
) |
Writes a character string at a specified location, expanding tabs to the values specified in an anrry of tab-stop positions.
This function writes the string spText with length of nCount at a specified locations, expanding tabs to the value spcified in the array pTabPositions of tab-stop positions. The output will start a new line if there is a line feed character '
' in the text.
hdc | The device context. | |
x | x,y: The output start position. | |
y | x,y: The output start position. | |
spText | The formatted text. | |
nCount | The length of the text. If it is less than 0, MiniGUI will treat it as a null-terminated string. | |
nTabPositions | The length of the array of the tab-stop positions. | |
pTabPositions | The array of the tab-stop positions. | |
nTabOrigin | The origin of the tab-stops. |
int GUIAPI TabbedTextOutLen | ( | HDC | hdc, | |
int | x, | |||
int | y, | |||
const char * | spText, | |||
int | len | |||
) |
Outputs a formatted text.
This function outputs the formatted text spText with length of len at (x,y). This function returns the width of text. The output will start a new line if there is a line feed character '
' in the text. The output will be affected by the default tab size if there are some TAB characters in the text.
hdc | The device context. | |
x | x,y: The output start position. | |
y | x,y: The output start position. | |
spText | The formatted text. | |
len | The length of the text. If it is less than 0, MiniGUI will treat it as a null-terminated string. |
int GUIAPI TextOutLen | ( | HDC | hdc, | |
int | x, | |||
int | y, | |||
const char * | spText, | |||
int | len | |||
) |
Outputs a string of text.
This function outputs the text spText with length of len at a (x,y). This function returns the width of text.
hdc | The device context. | |
x | x,y: The output start position. | |
y | x,y: The output start position. | |
spText | The string of the text. | |
len | The length of the text. If it is less than 0, MiniGUI will treat it as a null-terminated string. |
int GUIAPI TextOutOmitted | ( | HDC | hdc, | |
int | x, | |||
int | y, | |||
const char * | mtext, | |||
int | len, | |||
int | max_extent | |||
) |
Outputs a string of text with omitted format.
This function outputs the text mtext with length of len at a (x,y) with omitted format, if width of the text more than max_extent.This function returns the output width of the text.
hdc | The device context. | |
x | x,y: The output start position. | |
y | x,y: The output start position. | |
mtext | The string of the text. | |
len | The length of the text. If it is less than 0, MiniGUI will treat it as a null-terminated string. | |
max_extent | The max extent of output text. |