LRESULT CWndPrompt::WindowProc(HWND hRealWnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_KILLFOCUS: case WM_SETFOCUS: if (CWinClasses::IsEditControl(hRealWnd) && WantPrompt(FALSE)) Invalidate(); break; case WM_PRINT: { LRESULT lr = CSubclassWnd::WindowProc(hRealWnd, msg, wp, lp); DrawPrompt((HDC)wp); return lr; } break; case WM_PAINT: { LRESULT lr = CSubclassWnd::WindowProc(hRealWnd, msg, wp, lp); DrawPrompt(NULL); return lr; } break; } return CSubclassWnd::WindowProc(hRealWnd, msg, wp, lp); }
void CommandLine::DrawFakeCommand(const string& FakeCommand) { DrawPrompt(); SetColor(COL_COMMANDLINE); // TODO: wrap & scroll if too long Text(FakeCommand); }
//***************************************************************************** // // Initialize the application interface. // //***************************************************************************** void UIInit(uint32_t ui32SysClock) { // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "usb-host-keyboard"); // // Set the font for the application. // GrContextFontSet(&g_sContext, g_psFontFixed6x8); // // Calculate the number of characters that will fit on a line. // Make sure to leave a small border for the text box. // g_ui32CharsPerLine = (GrContextDpyWidthGet(&g_sContext) - 16) / GrFontMaxWidthGet(g_psFontFixed6x8); // // Calculate the number of lines per usable text screen. This requires // taking off space for the top and bottom banners and adding a small bit // for a border. // g_ui32LinesPerScreen = (GrContextDpyHeightGet(&g_sContext) - (2*(DISPLAY_BANNER_HEIGHT + 1)) - BUTTON_HEIGHT) / GrFontHeightGet(g_psFontFixed6x8); // // Set up the text scrolling variables. // g_ui32CurrentLine = 0; g_ui32EntryLine = 0; // // Draw the initial prompt on the screen. // DrawPrompt(); // // Initial update of the screen. // UIUpdateStatus(); }
void CommandLine::DisplayObject() { _OT(SysLog(L"[%p] CommandLine::DisplayObject()",this)); const auto CurLength = DrawPrompt(); CmdStr.SetObjectColor(COL_COMMANDLINE,COL_COMMANDLINESELECTED); CmdStr.SetPosition(m_X1 + static_cast<int>(CurLength), m_Y1, m_X2, m_Y2); CmdStr.Show(); GotoXY(m_X2+1,m_Y1); SetColor(COL_COMMANDLINEPREFIX); Text(L'\x2191'); // up arrow }
//***************************************************************************** // // This function prints the character out the screen and into the command // buffer. // // ucChar is the character to print out. // // This function handles all of the detail of printing a character to the // screen and into the command line buffer. // // No return value. // //***************************************************************************** void UIPrintChar(const char cChar) { bool bNewLine; int32_t i32Idx; GrContextForegroundSet(&g_sContext, ClrWhite); bNewLine = true; // // Allow new lines to cause the column to go back to zero. // if(cChar != '\n') { // // Handle when receiving a backspace character. // if(cChar != ASCII_BACKSPACE) { // // This is not a backspace so print the character to the screen. // GrStringDraw(&g_sContext, &cChar, 1, DISPLAY_TEXT_BORDER_H + (GrFontMaxWidthGet(g_psFontFixed6x8) * g_ui32Column), DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)), 1); g_ppcLines[g_ui32CurrentLine][g_ui32Column] = cChar; if(g_ui32Column < g_ui32CharsPerLine) { // // No line wrap yet so move one column over. // g_ui32Column++; bNewLine = false; } } else { // // We got a backspace. If we are at the top left of the screen, // return since we don't need to do anything. // if(g_ui32Column || g_ui32EntryLine) { // // Adjust the cursor position to erase the last character. // if(g_ui32Column > 2) { g_ui32Column--; } // // Print a space at this position then return without fixing up // the cursor again. // GrStringDraw(&g_sContext, " ", 1, DISPLAY_TEXT_BORDER_H + (GrFontMaxWidthGet(g_psFontFixed6x8) * g_ui32Column), DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)), true); g_ppcLines[g_ui32CurrentLine][g_ui32Column] = ' '; } bNewLine = false; } } // // . // if(bNewLine) { g_ui32Column = 0; if(g_ui32EntryLine < (MAX_LINES - 1)) { g_ui32EntryLine++; } else { ScrollText(); } g_ui32CurrentLine++; // // The line has gone past the end so go back to the first line. // if(g_ui32CurrentLine >= MAX_LINES) { g_ui32CurrentLine = 0; } // // Add a prompt to the new line. // if(cChar == '\n') { DrawPrompt(); } else { // // Clear out the current line. // for(i32Idx = 0; i32Idx < MAX_COLUMNS - 1; i32Idx++) { g_ppcLines[g_ui32CurrentLine][i32Idx] = ' '; } g_ppcLines[g_ui32CurrentLine][i32Idx] = 0; GrStringDraw(&g_sContext, g_ppcLines[g_ui32CurrentLine], strlen(g_ppcLines[g_ui32CurrentLine]), DISPLAY_TEXT_BORDER_H, DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER + (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)), 1); } } }