⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wfnttest.c

📁 vxworks下windml的一些demo程序
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* Print the font number and page number on the banner. */    uglFontSet(gc, fontBanner);    uglForegroundColorSet(gc, colorTable[YELLOW].uglColor);    sprintf(snum, "%s", metric.faceName);    uglTextDraw(gc, 0, bannerHeight, -1, snum);    if (wide)        sprintf(snum, "Font # %5d     Page %5d", fontNum, page);    else        sprintf(snum, "Font # %5d", fontNum);    uglTextDraw(gc, displayWidth >> 1, bannerHeight, -1, snum);    /* Post banner notice that driver is not supporting wide characters. */    if (!wide)        {        sprintf(snum, "Wide character support unavailable");        uglTextDraw(gc, displayWidth >> 1, 0, -1, snum);        }    }UGL_LOCAL UGL_BOOL NextPopulatedPage(void)    {    if (page == maxPage)      return UGL_FALSE;    page += 10;    if (page > maxPage)        page = maxPage;    return UGL_TRUE;    }UGL_LOCAL UGL_BOOL PrevPopulatedPage(void)    {    if (page == 0)        return UGL_FALSE;    page -= 10;    if (page < 0)        page = 0;    return UGL_TRUE;    }/** This is the main message loop for the program.  Primarily it waits for* a key to be pressed and then performs an associated action like* changing pages, or fonts, and then displaying the result.*/UGL_LOCAL void wtstPause(void)    {    UGL_MSG msg;    UGL_FOREVER        {        if (uglInputMsgGet (inputServiceId, &msg, 140 /* mSec */)             != UGL_STATUS_Q_EMPTY)            {            if (msg.type == MSG_KEYBOARD)                {                if (msg.data.keyboard.modifiers & UGL_KBD_KEYDOWN)                    {                    UGL_BOOL dopaint = TRUE;                    /*                    * Use arrow keys, page keys, home and end keys for                    * changing pages.                    */                    if (msg.data.keyboard.key == UGL_UNI_PAGE_UP)                        {                        dopaint = NextPopulatedPage();                        }                    else if (msg.data.keyboard.key == UGL_UNI_UP_ARROW)                        {                        page++;                        if (page > maxPage)                            {                            dopaint = UGL_FALSE;                            page = maxPage;                            }                        }                    else if (msg.data.keyboard.key == UGL_UNI_PAGE_DOWN)                        {                        dopaint = PrevPopulatedPage();                        }                    else if (msg.data.keyboard.key == UGL_UNI_DOWN_ARROW)                        {                        page--;                        if (page < 0)                            {                            dopaint = UGL_FALSE;                            page = 0;                            }                        }                    else if (msg.data.keyboard.key == UGL_UNI_END)                        page = maxPage;                    else if (msg.data.keyboard.key == UGL_UNI_HOME)                        page = 0;                    /* Left and right arrow keys for changing fonts. */                    else if (msg.data.keyboard.key == UGL_UNI_RIGHT_ARROW)                        {                        fontNum++;                        if (fontNum >= fontCount)                            {                            dopaint = UGL_FALSE;                            fontNum = fontCount - 1;                            }                        else                            page = 0;                        }                    else if (msg.data.keyboard.key == UGL_UNI_LEFT_ARROW)                        {                        fontNum--;                        if (fontNum < 0)                            {                            dopaint = UGL_FALSE;                            fontNum = 0;                            }                        else                            page = 0;                        }                    else                       dopaint = UGL_FALSE;                    if (dopaint)                        pagePaint();                    }                }            }        if (stopTest)            break;        }    }#if defined(WINDML_NATIVE) && defined(__unix__)int main (int argc, char *argv [])    {    windMLTestFont ();    return (0);    }#elif defined(WINDML_NATIVE) && defined(_WIN32)int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                   LPSTR lpCmdLine, int nShowCmd)    {    uglWin32Parameters(hInstance, hPrevInstance, lpCmdLine, nShowCmd);    windMLTestFont();    return (0);    }#elsevoid wfnttest (void)    {    stopTest = 0;    printf("Type  wfnttestStop  to end WindML font test program.\n");    uglOSTaskCreate("tWindMLFnt", (UGL_FPTR)windMLTestFont, 110, 		    0, 10240, 0,0,0,0,0);    }#endif/* Stop the program; by signalling the wtstPause function. */void wfnttestStop (void)    {    stopTest = 1;    }/* The main function */UGL_LOCAL int windMLTestFont (void)    {    UGL_FONT_DEF fontDef;    UGL_ORD textOrigin;    /* Text for banner to be printed at the top of the screen. */    char *text = "WindML font test program.  Wind River Systems.";    UGL_MODE_INFO modeInfo;    if (uglInitialize() == UGL_STATUS_ERROR)        {        printf("uglInitialize failed.\n");        return UGL_STATUS_ERROR;        }    devId = (UGL_DEVICE_ID)uglRegistryFind (UGL_DISPLAY_TYPE,  0, 0,0)->id;    if (devId == UGL_NULL)        {        printf("uglRegistryFind failed.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;        }    inputServiceId = (UGL_INPUT_SERVICE_ID)uglRegistryFind (UGL_INPUT_SERVICE_TYPE,  0, 0,0)->id;    if (inputServiceId == UGL_NULL)        {        printf("uglRegistryFind failed.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;        }    fontDrvId =  (UGL_FONT_DRIVER_ID)uglRegistryFind (UGL_FONT_ENGINE_TYPE,  0, 0,0)->id;        if (fontDrvId == UGL_NULL)        {        printf("uglRegistryFind failed.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;        }    uglInfo(devId, UGL_MODE_INFO_REQ, &modeInfo);    displayWidth = modeInfo.width;    displayHeight = modeInfo.height;    gc = uglGcCreate(devId);    textOrigin = UGL_FONT_TEXT_UPPER_LEFT;    uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin);    if (uglFontFindString(fontDrvId, "pixelSize=12", &fontDef) == UGL_STATUS_ERROR)        printf("\nBanner's uglFontFindString failed.\n");    if ((fontBanner = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)        {        printf("Banner's uglFontCreate failed. Exiting.\n");        uglDeinitialize();        return(0);        }    uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL,                    &colorTable[BLACK].uglColor, 1);    uglColorAlloc(devId, &colorTable[BLUE].rgbColor, UGL_NULL,                  &colorTable[BLUE].uglColor, 1);    uglColorAlloc(devId, &colorTable[GREEN].rgbColor, UGL_NULL,                  &colorTable[GREEN].uglColor, 1);    uglColorAlloc(devId, &colorTable[YELLOW].rgbColor,  UGL_NULL,                  &colorTable[YELLOW].uglColor, 1);    uglColorAlloc(devId, &colorTable[WHITE].rgbColor,  UGL_NULL,                  &colorTable[WHITE].uglColor, 1);    /* Set some obnoxious color combination for the banner. */	uglForegroundColorSet(gc, colorTable[YELLOW].uglColor);	uglBackgroundColorSet(gc, colorTable[BLUE].uglColor);    /* Set the font we acquired earlier for the banner. */        uglFontSet(gc, fontBanner);    	uglTextSizeGet(fontBanner, UGL_NULL, &bannerHeight, -1, text);        y = bannerHeight;    x = 0;	uglTextDraw(gc, 0, 0, -1, text);        acquireFonts();    /* Paint the initial glyphs. */    fontNum = 0;    pagePaint();    /* The main message (loop). */    wtstPause();    /* Clean Up */    uglFontDestroy (fontBanner);    for(fontNum = 0; fontNum < fontCount; fontNum++)        {        if (uglFontDestroy (glyphFontId[fontNum]) == UGL_STATUS_ERROR)            printf("Error destroying font number %d.\n",fontNum);        }    uglGcDestroy (gc);    UGL_FREE(glyphFontId);    uglDeinitialize();    return(0);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -