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 * pxModalDialogWindowCreate(){ // X0, Y0 - координаты расположения виджетов u16 usX, usY; xThisWnd = pxWindowCreate(WINDOW_MODAL); vWidgetSetBgColor(xThisWnd, ColorEcgBackground, FALSE); vWindowSetOnOpenHandler(xThisWnd, prvOnOpenHandler); vWindowSetOnOpenRequestHandler(xThisWnd, prvOnOpenRequestHandler); vWindowSetOnCloseHandler(xThisWnd, prvOnCloseHandler); vWindowSetOnCloseRequestHandler(xThisWnd, prvOnCloseRequestHandler); xMessageHeader = pxLabelCreate(0, 0, usWidgetGetW(xThisWnd), usStatusBarGetH(), "ModalDialogHeader", FONT_ASCII_16_X, 0, xThisWnd); vWidgetSetBgColor(xMessageHeader, ColorMessageHeaderBackground, FALSE); vLabelSetTextAlign(xMessageHeader, LABEL_ALIGN_CENTER); vLabelSetVerticalAlign(xMessageHeader, LABEL_ALIGN_MIDDLE); vLabelSetTextColor(xMessageHeader, ColorMessageHeaderText); usY = (usInterfaceGetWindowH() * 4 )/10 - usStatusBarGetH(); xMessage = pxLabelCreate(0, usWidgetGetH(xMessageHeader), usWidgetGetW(xThisWnd), usY, "ModalDialogText", FONT_ASCII_16_X, MODAL_DIALOG_MAX_MSG_LENGTH, xThisWnd); bLabelSetMultiline(xMessage, TRUE); vLabelSetTextAlign(xMessage, LABEL_ALIGN_CENTER); vLabelSetVerticalAlign(xMessage, LABEL_ALIGN_MIDDLE); usY = usWidgetGetY1(xMessage, FALSE); xPBar = pxProgressBarCreate(PB_BORDER, usY, usWidgetGetW(xThisWnd) - PB_BORDER * 2, 30, xThisWnd); vProgressBarSetProcExec(xPBar, 55); usY = (usInterfaceGetWindowH()/2 + LCD_TsBtn_SIZE/3); usX = 0; for(int c = 0; c < MODAL_DIALOG_MAX_BUTTONS; c++){ xButtons[c] = pxMenuButtonCreate(usX, usY, pxPictureGet(Pic_ButtonOk), "", prvButtonHandler, xThisWnd); usX += LCD_TsBtn_SIZE; vWidgetHide(xButtons[c]); } return xThisWnd; }