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; }
static void prvDlgShowActive(){ xModalDialog * xDlg = xMDActive; if(!xDlg){ //return; vInterfaceCloseWindow(WINDOW_MODAL); //TODO: выставить кол-во активных диалогов в 0 } char cBtnCnt = strlen(xDlg->sDialogConfig); xModalDialogPictureSet xPicSet; char * sBtns = xDlg->sDialogConfig; xMenuButton * xBtn; u16 betweenBtnsX, usX, usY; prvResetDlgWnd(); betweenBtnsX = (usInterfaceGetW() - cBtnCnt * usWidgetGetW(xButtons[0])) / (cBtnCnt + 1); usY = usWidgetGetY0(xButtons[0], FALSE); usX = betweenBtnsX; pcLabelSetText(xMessageHeader, xDlg->sHdr); pcLabelSetText(xMessage, xDlg->sMsg); prvShowPB(xDlg); for(int c = 0; c < cBtnCnt; c++){ xBtn = xButtons[c]; xPicSet = prvGetPicSet(sBtns[c]); bWidgetMoveTo(xBtn, usX, usY); vWidgetShow(xBtn); pxMenuButtonSetMainPic(xBtn, xPicSet.xPicMain); pxMenuButtonSetPushPic(xBtn, xPicSet.xPicMainPress); pxMenuButtonSetLabelText(xBtn, xPicSet.strLabel); usX += betweenBtnsX + usWidgetGetW(xBtn); } }
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; }
bool bWidgetSetBgPicture(xWidget *pxW, unsigned short const* pusBgPicture){ if(!pxW) return FALSE; bool bInvalidateParent = FALSE; if(usPictureGetW(pusBgPicture) < usWidgetGetW(pxW) || usPictureGetH(pusBgPicture) < usWidgetGetH(pxW)) bInvalidateParent = TRUE; if(!bWidgetResize(pxW, usPictureGetW(pusBgPicture), usPictureGetH(pusBgPicture))) return FALSE; //do not invalidate if picture is not changed if(pxW->pusBgPicture != pusBgPicture){ pxW->pusBgPicture = pusBgPicture; vWidgetInvalidate(pxW); } if(!pusBgPicture || bInvalidateParent) pxW->bInvalidateParent = TRUE; return TRUE; };