void windMLAllDemos(void) { UGL_BOOL windMLFlag = UGL_FALSE; UGL_FB_INFO fbInfo; UGL_EVENT event; UGL_EVENT_SERVICE_ID eventServiceId; UGL_EVENT_Q_ID qId; UGL_INPUT_EVENT * pInputEvent; UGL_INPUT_DEVICE_ID keyboardDevId; UGL_DEVICE_ID devId; UGL_GC_ID gc; UGL_FONT_ID fontId; UGL_FONT_DEF fontDef; UGL_FONT_DRIVER_ID fontDrvId; UGL_ORD textOrigin = UGL_FONT_TEXT_UPPER_LEFT; int displayHeight, displayWidth; int textWidth, textHeight; static UGL_CHAR * message = "Do you want to use WindML exclusively ? (y/n) "; uglInitialize(); uglDriverFind (UGL_DISPLAY_TYPE, 0, (UGL_UINT32 *)&devId); uglDriverFind (UGL_KEYBOARD_TYPE, 0, (UGL_UINT32 *)&keyboardDevId); uglDriverFind (UGL_EVENT_SERVICE_TYPE, 0, (UGL_UINT32 *)&eventServiceId); qId = uglEventQCreate (eventServiceId, 100); gc = uglGcCreate(devId); uglDriverFind (UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32 *)&fontDrvId); uglFontDriverInfo(fontDrvId, UGL_FONT_TEXT_ORIGIN, &textOrigin); uglFontFindString(fontDrvId, "familyName=Helvetica; pixelSize = 18", &fontDef); if ((fontId = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL) { printf("Font not found. Exiting.\n"); return; } uglInfo(devId, UGL_FB_INFO_REQ, &fbInfo); displayWidth = fbInfo.width; displayHeight = fbInfo.height; uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL, &colorTable[BLACK].uglColor, 1); uglColorAlloc(devId, &colorTable[RED].rgbColor, UGL_NULL, &colorTable[RED].uglColor, 1); uglBackgroundColorSet(gc, colorTable[BLACK].uglColor); uglForegroundColorSet(gc, colorTable[RED].uglColor); uglFontSet(gc, fontId); uglTextSizeGet(fontId, &textWidth, &textHeight, -1, message); uglTextDraw(gc, (displayWidth - textWidth) / 2, (displayHeight - textHeight) / 2 - textHeight, -1, message); /* flushQ(); */ if (uglEventGet (qId, &event, sizeof (event), UGL_WAIT_FOREVER) != UGL_STATUS_Q_EMPTY) { pInputEvent = (UGL_INPUT_EVENT *)&event; if (pInputEvent->header.type == UGL_EVENT_TYPE_KEYBOARD && pInputEvent->modifiers & UGL_KEYBOARD_KEYDOWN) { switch(pInputEvent->type.keyboard.key) { case 'Y': case 'y': windMLFlag = UGL_TRUE; break; default: windMLFlag = UGL_FALSE; } } } uglFontDestroy (fontId); uglGcDestroy (gc); uglEventQDestroy (eventServiceId, qId); uglDeinitialize(); windMLPoint(windMLFlag); windMLLine(windMLFlag); windMLFlip(windMLFlag); windMLCube(windMLFlag); windMLBounce(windMLFlag); windMLGears(windMLFlag); windMLIcoTorus(windMLFlag); windMLOlympic(windMLFlag); windMLTexCube(windMLFlag); windMLTexCyl(windMLFlag); windMLTeapot(windMLFlag); windMLStencil(windMLFlag); windMLDrawPix(windMLFlag); windMLAccum(windMLFlag); return; }
UGL_LOCAL void * wwmCreate ( WIN_MGR_ID winMgrId, UGL_DEVICE_ID displayId, UGL_INPUT_SERVICE_ID inputServiceId ) { void * pResult; WIN_APP_ID appId; WIN_ID rootWinId; UGL_COLOR * pColorTable; UGL_MODE_INFO modeInfo; UGL_REG_DATA * pRegData; UGL_FONT_DRIVER_ID fntDrvId; UGL_FONT_DEF fntDef; UGL_CDDB_ID * pCursorTable; UGL_FONT_ID * pFntTable; UGL_ORD textOrigin; UGL_ORD i; /* Allocate window manager colors */ pColorTable = UGL_CALLOC(WIN_NUM_STANDARD_COLORS, sizeof(UGL_COLOR)); uglInfo(displayId, UGL_MODE_INFO_REQ, &modeInfo); if (modeInfo.clutSize == 0) { uglColorAlloc( displayId, (UGL_ARGB *) wwmRGBColorTable, UGL_NULL, pColorTable, WIN_NUM_STANDARD_COLORS ); } else if (modeInfo.clutSize == WIN_NUM_STANDARD_COLORS) { for (i = 0; i < WIN_NUM_STANDARD_COLORS; i++) { uglColorAlloc( displayId, (UGL_ARGB *) &wwmRGBColorTable[i], &i, &pColorTable[i], 1 ); } } /* Set color table */ winMgrColorTableSet(winMgrId, pColorTable, WIN_NUM_STANDARD_COLORS); /* Initialize cursor */ uglCursorInit(displayId, 32, 32, modeInfo.width / 2, modeInfo.height / 2); /* Initialize cursor table */ pCursorTable = UGL_CALLOC(WIN_NUM_STANDARD_CURSORS, sizeof(UGL_CDDB_ID)); pCursorTable[WIN_CURSOR_INDEX_ARROW] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibArrow ); pCursorTable[WIN_CURSOR_INDEX_EDIT] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibEdit ); pCursorTable[WIN_CURSOR_INDEX_WAIT] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibWait ); pCursorTable[WIN_CURSOR_INDEX_INVALID] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibInvalid ); pCursorTable[WIN_CURSOR_INDEX_MOVE] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibMove ); pCursorTable[WIN_CURSOR_INDEX_SIZE_HORIZ] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibSizeHoriz ); pCursorTable[WIN_CURSOR_INDEX_SIZE_LEFT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_HORIZ]; pCursorTable[WIN_CURSOR_INDEX_SIZE_RIGHT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_HORIZ]; pCursorTable[WIN_CURSOR_INDEX_SIZE_VERT] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibSizeVert ); pCursorTable[WIN_CURSOR_INDEX_SIZE_TOP] = pCursorTable[WIN_CURSOR_INDEX_SIZE_VERT]; pCursorTable[WIN_CURSOR_INDEX_SIZE_BOTTOM] = pCursorTable[WIN_CURSOR_INDEX_SIZE_VERT]; pCursorTable[WIN_CURSOR_INDEX_SIZE_TL_BR] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibSizeDiagTlBr ); pCursorTable[WIN_CURSOR_INDEX_SIZE_TOP_LEFT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_TL_BR]; pCursorTable[WIN_CURSOR_INDEX_SIZE_BOTTOM_RIGHT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_TL_BR]; pCursorTable[WIN_CURSOR_INDEX_SIZE_TR_BL] = uglCursorBitmapCreate( displayId, (UGL_CDIB *) &wwmCDibSizeDiagTrBl ); pCursorTable[WIN_CURSOR_INDEX_SIZE_TOP_RIGHT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_TR_BL]; pCursorTable[WIN_CURSOR_INDEX_SIZE_BOTTOM_LEFT] = pCursorTable[WIN_CURSOR_INDEX_SIZE_TR_BL]; /* Set cursor table */ winMgrCursorTableSet(winMgrId, pCursorTable, WIN_NUM_STANDARD_CURSORS); /* Setup current cursor */ uglCursorImageSet(displayId, pCursorTable[WIN_CURSOR_INDEX_ARROW]); uglCursorOn(displayId); pRegData = uglRegistryFind(UGL_FONT_ENGINE_TYPE, UGL_NULL, 0, 0); if (pRegData != UGL_NULL) { fntDrvId = (UGL_FONT_DRIVER_ID) pRegData->data; pFntTable = UGL_CALLOC(WIN_NUM_STANDARD_FONTS, sizeof(UGL_FONT_ID)); uglFontFindString(fntDrvId, WWM_SYSTEM_FONT, &fntDef); pFntTable[WIN_FONT_INDEX_SYSTEM] = uglFontCreate(fntDrvId, &fntDef); uglFontFindString(fntDrvId, WWM_SMALL_FONT, &fntDef); pFntTable[WIN_FONT_INDEX_SMALL] = uglFontCreate(fntDrvId, &fntDef); uglFontFindString(fntDrvId, WWM_FIXED_FONT, &fntDef); pFntTable[WIN_FONT_INDEX_FIXED] = uglFontCreate(fntDrvId, &fntDef); textOrigin = UGL_FONT_TEXT_UPPER_LEFT; uglFontInfo( pFntTable[WIN_FONT_INDEX_SYSTEM], UGL_FONT_TEXT_ORIGIN_SET, &textOrigin ); uglFontInfo( pFntTable[WIN_FONT_INDEX_SMALL], UGL_FONT_TEXT_ORIGIN_SET, &textOrigin ); uglFontInfo( pFntTable[WIN_FONT_INDEX_FIXED], UGL_FONT_TEXT_ORIGIN_SET, &textOrigin ); winMgrFontTableSet(winMgrId, pFntTable, WIN_NUM_STANDARD_FONTS); } else { winMgrFontTableSet(winMgrId, UGL_NULL, 0); } appId = winAppCreate( "wwm", WWM_APP_PRIORITY, WWM_APP_STACK_SIZE, 0, UGL_NULL ); if (appId == UGL_NULL) { pResult = UGL_NULL; } else { /* Create and set window class for frame */ winMgrFrameClassSet(winMgrId, wwmFrameClassCreate()); /* Create root window */ rootWinId = winCreate( appId, UGL_NULL_ID, WIN_ATTRIB_VISIBLE, 0, 0, 0, 0, UGL_NULL, 0, UGL_NULL ); if (rootWinId == UGL_NULL) { pResult = UGL_NULL; } else { /* Add root window callback and set root window */ winCbAdd(rootWinId, 0, 0, wwmRootWinCb, UGL_NULL); winMgrRootWinSet(winMgrId, rootWinId); pResult = displayId; } } return pResult; }