zoukankan      html  css  js  c++  java
  • 6. 显示文字

    6.1 基本例程

    GUI_DispString("Hello world!");  // 写满后不会自动换行

    6.2 绘图模式

    GUI_SetColor()         // 设置前景颜色
    GUI_SetBkColor()      // 设置背景颜色
    GUI_SetTextMode()    // 选择文字模式
    • Normal text    // GUI_TM_NORMAL 
    • Reverse text    // GUI_TM_NORMAL 
    • Transparent text   // GUI_TM_TRANS
    • XOR texttext   // GUI_TM_XOR

    Example

    GUI_SetFont(&GUI_Font8x16);
    GUI_SetBkColor(GUI_BLUE);
    GUI_Clear();
    GUI_SetPenSize(10);
    GUI_SetColor(GUI_RED);
    GUI_DrawLine(80, 10, 240, 90);
    GUI_DrawLine(80, 90, 240, 10);
    GUI_SetBkColor(GUI_BLACK);
    GUI_SetColor(GUI_WHITE);
    GUI_SetTextMode(GUI_TM_NORMAL);
    GUI_DispStringHCenterAt("GUI_TM_NORMAL" , 160, 10);
    GUI_SetTextMode(GUI_TM_REV);
    GUI_DispStringHCenterAt("GUI_TM_REV" , 160, 26);
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_DispStringHCenterAt("GUI_TM_TRANS" , 160, 42);
    GUI_SetTextMode(GUI_TM_XOR);
    GUI_DispStringHCenterAt("GUI_TM_XOR" , 160, 58);
    GUI_SetTextMode(GUI_TM_TRANS | GUI_TM_REV);
    GUI_DispStringHCenterAt("GUI_TM_TRANS | GUI_TM_REV", 160, 74);

     Screenshot of above example

     6.3  位置

    GUI_GotoX()        
    GUI_GotoY()
    GUI_GotoXY()

    6.4 文本API

    Routine

    Description

    Displaying text

    GUI_DispCEOL()

    Clears the current line from the current position to the end.

    GUI_DispChar()

    Displays a single character.

    GUI_DispCharAt()

    Displays a single character at the specified position.

    GUI_DispChars()

    Displays a character a specified number of times.

    GUI_DispString()

    Displays a string.

    GUI_DispStringAt()

    Displays a string at the specified position.

    GUI_DispStringAtCEOL()

    Displays a string at the specified position and clears the cur-rent line to the end.

    GUI_DispStringHCenterAt()

    Displays a string centered horizontally at the given position.

    GUI_DispStringInRect()

    Displays a string in the specified rectangle.

    GUI_DispStringInRectEx()

    Displays a string rotated in the specified rectangle.

    GUI_DispStringInRectWrap()

    Displays a string wrapped in the specified rectangle.

    GUI_DispStringinRectWrapEx()

    Displays a string rotated and wrapped in the specified rectan-gle.

    GUI_DispStringLen()

    Displays a string at the current position with specified number of characters.

    GUI_WrapGetNumLines()

    Returns the number lines required to display the given stringusing the given wrap mode at the given size.

    Drawing modes

    GUI_GetTextMode()

    Returns the currently set drawing mode.

    GUI_SetTextMode()

    Sets the drawing mode.

    GUI_SetTextStyle()

    Sets the style to be used.

    GUI_SetClearTextRectMode()

    Enables clear rect mode when displaying a string in a rectan-gle.

    Alignment

    GUI_GetTextAlign()

    Returns the currently set text alignment.

    GUI_SetLBorder()

    Sets the size of the left border to be used after line feeds.

    GUI_SetTextAlign()

    Sets the text alignment.

    Position

    GUI_DispNextLine()

    Moves the cursor to the beginning of the next line.

    GUI_GotoX()

    Sets the X-position.

    GUI_GotoXY()

    Sets the X- and Y-position.

    GUI_GotoY()

    Sets the Y-position.

    GUI_GetDispPosX()

    Returns the current X-position.

    GUI_GetDispPosY()

    Returns the current Y-position.

    6.4.1 显示文本

     

        GUI_RECT Rect = { 10, 10, 40, 80 };
        char acText[] = "Rotated
    text";
        GUI_SetTextMode(GUI_TM_XOR);
        GUI_FillRectEx(&Rect);
        GUI_DispStringInRectEx(acText, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER,
            strlen(acText), GUI_ROTATE_CCW);

     

     

        GUI_WRAPMODE aWm[] = { GUI_WRAPMODE_NONE, GUI_WRAPMODE_CHAR, GUI_WRAPMODE_WORD };
        GUI_RECT Rect = { 10, 10, 59, 59 };
        char acText[] = "This example demonstrates text wrapping";
        int i;
        GUI_SetTextMode(GUI_TM_TRANS);
        for (i = 0; i < 3; i++) {
            GUI_SetColor(GUI_BLUE);
            GUI_FillRectEx(&Rect);
            GUI_SetColor(GUI_WHITE);
            GUI_DispStringInRectWrap(acText, &Rect, GUI_TA_LEFT, aWm[i]);
            Rect.x0 += 60;
            Rect.x1 += 60;
        }

    6.4.2 绘图模式

    char GUI_SetTextStyle(char Style);

    6.4.3 对齐

  • 相关阅读:
    DataItem,gridview,repeater数据控件数据绑定
    repeater没有数据显示暂无数据,无记录
    Javascript操作Cookie的脚本 — CookieHelper
    <script>标签应该放到</body>标签之前
    IEnumerable 和 IQueryable 区别
    【three.js练习程序】鼠标滚轮缩放
    【three.js练习程序】动画效果,100个方块随机运动
    【three.js练习程序】随机生成100个方块
    树莓派练习程序(寻迹模块)
    树莓派练习程序(声音检测)
  • 原文地址:https://www.cnblogs.com/qiyuexin/p/10420877.html
Copyright © 2011-2022 走看看