xConsole * pxConsoleCreate(){ xConsole *pxW; xConsoleProps *xP; u16 usX0, usY0, usX1, usY1; xConsoleWnd = pxWindowCreate(WINDOW_CONSOLE); vWindowSetFullScreen(xConsoleWnd, TRUE); usX0 = 0; usY0 = 0; usX1 = usWidgetGetW(xConsoleWnd); usY1 = usWidgetGetH(xConsoleWnd); if(xDefCon) return NULL; //Console is singleton ATM. if(!xConsoleWnd) return NULL; //У консоли всегда должен быть родитель. Пока должен быть. pxW = pxWidgetAlloc(); if(bWidgetInit(pxW, usX0, usY0, usX1, usY1, xConsoleWnd, TRUE)){ pxW->eType = WidgetConsole; vWidgetSetClickable(pxW, FALSE); vWidgetSetBgColor(pxW, 0, FALSE); xP = pvMemoryMalloc(sizeof(xConsoleProps), MEMORY_EXT); if(!xP) return NULL; xP->ucChXCount = usWidgetGetW(pxW)/CHAR_PLACE_WIDTH; //TODO: Get FontHeight here xP->ucChYCount = usWidgetGetH(pxW)/CHAR_PLACE_HEIGHT; //Using Monotype xP->ucCaretX = 0; xP->ucCaretY = 0; xP->usScroll = 0; xP->xqConsole = xQueueCreate(xP->ucChXCount * xP->ucChYCount, sizeof(char)); if(!xP->xqConsole) return NULL; pxW->pvProp = xP; pxW->pxDrawHandler = prvConsoleDraw; vWriteSetCallback(vConsoleDefPutChar); xDefCon = pxW; return pxW; } vMemoryFree(pxW); return NULL; }
xWidget * pxWidgetCreate(u16 usX0, u16 usY0, u16 usX1, u16 usY1, xWidget *pxWidParent, bool bUseWH){ xWidget *pxW; pxW = pvMemoryMalloc(sizeof(xWidget), MEMORY_EXT); if(!pxW) return NULL; if(bWidgetInit(pxW, usX0, usY0, usX1, usY1, pxWidParent, bUseWH)) return pxW; else{ vMemoryFree(pxW); return NULL; } }
xPictureStack *pxPictureStackCreate(u16 usX, u16 usY, xPicture xPic, xWidget *pxWidParent){ xPictureStack *pxW; xPictureStackProps *xP; xPictureStackItem *xI; pxW = pvMemoryMalloc(sizeof(xWidget), MEMORY_EXT); if(bWidgetInit(pxW, usX, usY, 1, 1, pxWidParent, TRUE)){ bWidgetSetBgPicture(pxW, xPic); xI = pvMemoryMalloc(sizeof(xPictureStackItem), MEMORY_EXT); if(!xI) return NULL; xI->xPic = xPic; xI->pxNext = NULL; xP = pvMemoryMalloc(sizeof(xPictureStackProps), MEMORY_EXT); if(!xP) return NULL; xP->cItemNumber = 0; xP->cItemCount = 1; xP->xItems = xI; pxW->pvProp = xP; pxW->eType = WidgetPictureStack; pxW->pxDrawHandler = prvDraw; return pxW; } else{ vMemoryFree(pxW); return NULL; } }