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

📄 wfnttest.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 2 页
字号:
    return UGL_TRUE;    }/**************************************************************************** wtstPause - wait for input from keyboard and update display ** This routine 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.** RETURNS:  ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL void wtstPause (void)    {    UGL_MSG msg;    char ch;    UGL_FOREVER        {        #if 0        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;        #endif        UGL_BOOL dopaint = TRUE;       while(read(fd, &ch, 1) > 0)      	{       	if((ch == 'q') || (ch == 'Q'))	      {		dopaint = UGL_FALSE;		break;    	       }		if((ch == 'k') || (ch == 'K'))		{		       if(fontNum > 0)		       {			     dopaint = PrevPopulatedPage();			     fontNum -= 1;		       }							}		if((ch == 'j' )|| (ch == 'J'))		{		    if(fontNum < 128)		    	{			dopaint = NextPopulatedPage();			 fontNum += 1;			 }							}		break;      	}        if(dopaint)             pagePaint();        if (stopTest)        	{            break;        	}    	}            }#if defined(WINDML_NATIVE) && defined(__unix__)/**************************************************************************** main - start of demo program for unix native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/int main (int argc, char *argv [])    {    windMLTestFont ();    return (0);    }#elif defined(WINDML_NATIVE) && defined(_WIN32)/**************************************************************************** WinMain - start of demo program for windows native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                   LPSTR lpCmdLine, int nShowCmd)    {    uglWin32Parameters(hInstance, hPrevInstance, lpCmdLine, nShowCmd);    windMLTestFont();    return (0);    }#else/**************************************************************************** wfnttest - demonstrate font/text handling** This routine demonstrates the font and text handling.  ** This example program demonstrates how to:**\ml *\m Initialize WindML*\m Identify the graphics device and input devices*\m Identify the font engine presence*\m Determine the resolution of the display*\m Create a graphics context*\m Allocate colors*\m Find fonts that are available *\m Determine the metrics for the font  *\m Display available fonts*\m Releasing all resources and terminating a WindML application.*\me** RETURNS: ** ERRNO: N/A** SEE ALSO: wfnttestStop() **/void wfnttest (void)    {   fd = open("/tyCo/0", 2, 0644);    ioctl (fd, FIOSETOPTIONS, OPT_ECHO | OPT_CRMOD | OPT_TANDEM | \			 OPT_MON_TRAP | OPT_7_BIT | OPT_ABORT );        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/**************************************************************************** wfnttestStop - stop the font/text example program** This routine stops the font/text example program.** RETURNS: ** ERRNO: N/A** SEE ALSO: wfnttest() **/void wfnttestStop (void)    {    close(fd);   uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);   uglForegroundColorSet(gc, colorTable[BLACK].uglColor);uglRectangle(gc,0, 0, displayWidth - 1, displayHeight - 1);	    stopTest = 1;    }/**************************************************************************** windMLTestFont - the font demo program ** This routine initializes the graphics device and input device and then* displays the first font page and then awaits operator input.** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/int windMLTestFont (void)    {    UGL_REG_DATA *pRegistryData;    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;        }    pRegistryData = uglRegistryFind (UGL_DISPLAY_TYPE, 0, 0, 0);    if (pRegistryData == UGL_NULL)        {	printf("Display not found.\n");	uglDeinitialize();	return UGL_STATUS_ERROR;	}    devId = (UGL_DEVICE_ID)pRegistryData->id;    if (devId == UGL_NULL)        {        printf("uglRegistryFind failed.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;        }#if 0    pRegistryData = uglRegistryFind (UGL_INPUT_SERVICE_TYPE, 0, 0, 0);    if (pRegistryData == UGL_NULL)        {        printf("Input service not found.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;	}    inputServiceId = (UGL_INPUT_SERVICE_ID)pRegistryData->id;    if (inputServiceId == UGL_NULL)        {        printf("uglRegistryFind failed.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;        }#endif    pRegistryData = uglRegistryFind (UGL_FONT_ENGINE_TYPE, 0, 0, 0);    if (pRegistryData == UGL_NULL)      {        printf("Font engine not found.\n");        uglDeinitialize();        return UGL_STATUS_ERROR;      }    fontDrvId = (UGL_FONT_DRIVER_ID)pRegistryData->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 + -