int renderCurrent() { int h = 1; MAExtent e = maGetScrSize(); Dimensions screen; screen.width = EXTENT_X(e); screen.height = EXTENT_Y(e); maSetClipRect(0, 0, screen.width, screen.height); maSetColor(BLACK); maFillRect(0, 0, screen.width, screen.height); maSetColor(0xffffff); sprintf(buff, "Write the following string"); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+= EXTENT_Y(mExtent); sprintf(buff, "%s", matchString.c_str()); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); sprintf(buff, "end"); mExtent = maGetTextSize(buff); maDrawText(screen.width - EXTENT_X(mExtent),screen.height-EXTENT_Y(mExtent),buff); return h; }
void KeyBaseCase::showErrorScreen(int errorCode) { MAExtent e = maGetScrSize(); Dimensions screen; screen.width = EXTENT_X(e); screen.height = EXTENT_Y(e); maSetClipRect(0, 0, screen.width, screen.height); maSetColor(BLACK); maFillRect(0, 0, screen.width, screen.height); int oldCol = maSetColor(0xff0000); const char* testName = name.c_str(); maDrawText(4, 0, testName); int testNameHeight = EXTENT_Y(maGetTextSize(testName)); if(FUNC_OUT_OF_MEMORY_ALLOC == errorCode) maDrawText(4, testNameHeight+2, "Out of Memory"); else if(FUNC_OUT_OF_MEMORY_RESOURCE == errorCode) maDrawText(4, testNameHeight+2, "Couldn't create resource"); else if(FUNC_SYSCALL_ERROR == errorCode) maDrawText(4, testNameHeight+2, "A syscall wasn't called correctly"); else if(FUNC_SYSCALL_NOT_SUPPORTED == errorCode) maDrawText(4, testNameHeight+2, "Unsupported feature"); else maDrawText(4, testNameHeight+2, "Unknown error!"); maDrawText(4, testNameHeight*2+4, "press key or screen to continue"); maUpdateScreen(); maSetColor(oldCol); }
void keyReleaseEvent(int keyCode) { if(keyCode == MAK_CLEAR) { if(currentLength!=0)currentLength--; currentString[currentLength] = 0; int h = renderCurrent(); sprintf(buff, "%s", currentString); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); renderCursor(h, EXTENT_X(mExtent)); } if(keyCode == MAK_SOFTRIGHT) { const char* ms = matchString.c_str(); if(strcmp(ms, currentString) == 0) assert(name, true); else assert(name, false); MAUtil::Environment::getEnvironment().removeKeyListener(this); //printf("charInput test finished\n"); suite->runNextCase(); } }
char *Controller::getText(char *dest, int maxSize) { int x = _output->getX(); int y = _output->getY(); int w = EXTENT_X(maGetTextSize("YNM")); int h = _output->textHeight(); dest[0] = '\0'; _runMode = modal_state; IFormWidget *formWidget = _output->createLineInput(dest, maxSize, x, y, w, h); _output->redraw(); maShowVirtualKeyboard(); while (isModal()) { MAEvent event = processEvents(EVENT_WAIT_INFINITE, EVENT_TYPE_KEY_PRESSED); if (event.type == EVENT_TYPE_KEY_PRESSED) { dev_clrkb(); if (isModal()) { if (event.key == 10) { _runMode = run_state; } else { _output->edit(formWidget, event.key); } } } } // paint the widget result onto the backing screen if (dest[0]) { _output->print(dest); } delete formWidget; return dest; }
void InitConsole(void) { int i; char string[128]; sConsole.screenSize = maGetScrSize(); maSetClipRect(0, 0, EXTENT_X(sConsole.screenSize), EXTENT_Y(sConsole.screenSize)); //sConsole.fontHeight = EXTENT_Y(maGetTextSize("gl")); // this is actually even more safe: for(i = 0; i < 95; i++) string[i] = i + 32; string[127] = 0; sConsole.fontHeight = EXTENT_Y(maGetTextSize(string)); sConsole.height = EXTENT_Y(sConsole.screenSize) / sConsole.fontHeight; sConsole.cursorPos.x = 0; sConsole.cursorPos.y = sConsole.height - 1; sConsole.firstLine = 0; sConsole.postponedLineFeed = 0; sConsole.lines = (ConLine*)malloc(sizeof(ConLine) * sConsole.height); for (i = 0; i < sConsole.height; i++) memset(sConsole.lines[i].line, 0, sizeof(ConLine)); sConsole.initialized = 1; }
void characterChanged(char c) { int h = renderCurrent(); currentString[currentLength] = c; currentString[currentLength+1] = 0; sprintf(buff, "%s", currentString); mExtent = maGetTextSize(buff); maDrawText(1,h,buff); h+=EXTENT_Y(mExtent); renderCursor(h, EXTENT_X(mExtent)-8); }
char *System::getText(char *dest, int maxSize) { int x = _output->getX(); int y = _output->getY(); int w = EXTENT_X(maGetTextSize("YNM")); int h = _output->textHeight(); int charWidth = _output->getCharWidth(); FormInput *widget = new FormLineInput(NULL, NULL, maxSize, true, x, y, w, h); widget->setFocus(true); int bg = _output->getBackgroundColor(); int fg = _output->getColor(); if (bg != DEFAULT_BACKGROUND || fg != DEFAULT_FOREGROUND) { widget->setColor(bg, fg); } else { widget->setColor(FOCUS_COLOR, DEFAULT_FOREGROUND); } _output->addInput(widget); _output->redraw(); _state = kModalState; maShowVirtualKeyboard(); showCursor(kIBeam); while (isModal()) { MAEvent event = getNextEvent(); if (event.type == EVENT_TYPE_KEY_PRESSED) { dev_clrkb(); if (isModal()) { int sw = _output->getScreenWidth(); switch (event.key) { case SB_KEY_ENTER: _state = kRunState; break; case SB_KEY_MENU: break; default: if (widget->edit(event.key, sw, charWidth)) { _output->redraw(); } } } } } const char *result = widget->getText(); if (result) { strcpy(dest, result); } else { dest[0] = '\0'; } // paint the widget result onto the backing screen if (dest[0]) { _output->setXY(x, y); _output->print(dest); } showCursor(kArrow); _output->removeInput(widget); delete widget; return dest; }
int osd_textwidth(const char *str) { MAExtent textSize = maGetTextSize(str); return EXTENT_X(textSize); }