STEMWIN text base display notes

Display character at specified position

void GUI_DispStringAt(const char GUI_FAR * s, int x, int y);
s String to display.
x The client window X position (unit: pixels) to write to.
y The client window Y position (unit: pixels) to be written.

At the specified position in the current window, horizontally center the string as argument using the current font.

In fact, it is just centered display, just to give the midpoint position (x, y)
void GUI_DispStringHCenterAt(const char GUI_FAR * s, int x, int y);

Display text in specified window

#

**void GUI_DispStringInRectWrap(const char GUI_UNI_PTR * s,
GUI_RECT * pRect,
int TextAlign,
GUI_WRAPMODE WrapMode);**


GUI_SetTextMode(GUI_TM_TRANS);  //透明文本  背景透明
GUI_SetColor(GUI_WHITE);
        GUI_FillRectEx(&Rect);    用白色填充区域
        GUI_SetColor(GUI_BLACK);  文本字体颜色黑色
**GUI_DispStringInRectWrap(acText,&Rect,GUI_TA_LEFT,aWm[i]);**//在当前窗口指定的矩形区域内显示字符串(并可自动换行)


> ## 下面的函数三个参数:文本,区域,对齐方式,换行模式 ##

> GUI_DispStringInRectWrap(acText,&Rect,GUI_TA_LEFT,aWm[i]);
void emwin_texttest(void)
{
    int i;
    char acText[]   = "This example demostrates text wrapping";
    GUI_RECT Rect   ={100,140,159,199}; //定义矩形显示区域
    GUI_WRAPMODE aWm[] = {GUI_WRAPMODE_NONE,
                          GUI_WRAPMODE_CHAR,
                          GUI_WRAPMODE_WORD};

    GUI_SetBkColor(GUI_BLUE);       //设置背景颜色
    GUI_Clear();                    //清屏  相当于用蓝色填充整个屏幕
    GUI_SetFont(&GUI_Font24_ASCII); //设置字体  字体中等大小
    GUI_SetColor(GUI_YELLOW);       //设置前景色(如文本,画线等颜色)
    GUI_DispString("HELLO WORD!");

    GUI_SetFont(&GUI_Font8x16);     //设置字体  偏小适合作为文本字体
    GUI_SetPenSize(10);             //设置笔大小  粗笔
    GUI_SetColor(GUI_RED);          //红色字体
    GUI_DrawLine(100,50,200,100);   //绘线
    GUI_DrawLine(100,130,200,50);   //绘线    画两根交叉线
    GUI_SetBkColor(GUI_BLACK);      //设置黑色背景   字体部分背景颜色
    GUI_SetColor(GUI_WHITE);        //设置字体颜色为白色
    GUI_SetTextMode(GUI_TM_NORMAL); //正常模式
    GUI_DispStringHCenterAt("GUI_TM_NORMAL",150,50);
    GUI_SetTextMode(GUI_TM_REV);    //反转文本  **反转意思是:字体和背景颜色反过来**
    GUI_DispStringHCenterAt("GUI_TM_REV"   ,150,66);
    GUI_SetTextMode(GUI_TM_TRANS);  //透明文本  **背景透明的**
    GUI_DispStringHCenterAt("GUI_TM_TRANS" ,150,82);
    GUI_SetTextMode(GUI_TM_XOR);    //异或文本   **字体颜色和交叉部分颜色按照颜色叠加显示**
    GUI_DispStringHCenterAt("GUI_TM_XOR"   ,150,98);
    GUI_SetTextMode(GUI_TM_TRANS|GUI_TM_REV);//透明反转文本
    GUI_DispStringHCenterAt("GUI_EM_TRANS|GUI_TM_REV",150,114);

    GUI_SetTextMode(GUI_TM_TRANS);  //透明文本
    for(i=0;i<3;i++)
    {
        GUI_SetColor(GUI_WHITE);
        GUI_FillRectEx(&Rect);
        GUI_SetColor(GUI_BLACK);
        GUI_DispStringInRectWrap(acText,&Rect,GUI_TA_LEFT,aWm[i]);//在当前窗口指定的矩形区域内显示字符串(并可自动换行)
        Rect.x0 += 70;
        Rect.x1 += 70;
    }   
}

Invert means: the font and background colors are reversed

GUI_SetTextMode(GUI_TM_REV); //Reverse text

transparent text background transparent

GUI_SetTextMode(GUI_TM_TRANS); //Transparent text

XOR text The font color and the color of the intersection part are displayed in accordance with the color overlay

GUI_SetTextMode(GUI_TM_XOR);

Awi[] in the program is the newline mode

If you do not perform automatic line wrapping, it will be a line, and it will not be displayed when it is full.

GUI_WRAPMODE_NONE

Automatically wrap the text according to the word is to wrap the line when the line is full

GUI_WRAPMODE_WORD //Common mode

Automatically wrap text according to characters A string occupies one line

GUI_WRAPMODE_CHAR //One character occupies one line and one line is not enough, it occupies two lines

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325770289&siteId=291194637