#include "cliClass.h" #ifdef TURBOVISION void WindowCLI::handleEvent(TEvent &event){ TApplication::handleEvent(event); if (event.what == evCommand){ switch (event.message.command){ case cmAboutCmd: // About Dialog Box aboutDlgBox(); default: // Unknown command return; }; clearEvent (event); }; }; TMenuBar *WindowCLI::initMenuBar(TRect r){ r.b.y = r.a.y + 1; return new TMenuBar(r, *new TSubMenu( "~F~ile", kbAltF, hcNoContext ) + *new TMenuItem( "~A~bout...", cmAboutCmd, kbNoKey, hcNoContext) + newLine() + *new TMenuItem( "E~x~it...", cmQuit, kbAltX, hcNoContext) ); }; void WindowCLI::aboutDlgBox(){ TDialog *aboutBox = new TDialog(TRect(0, 0, 39, 13), "About"); aboutBox->insert( new TStaticText(TRect(9, 2, 30, 9), "\003Direct Memo Access\n\n" // These strings will be "\003C++ Version\n\n" // concatenated by the compiler. "\003Copyright (c) 2018\n\n" // The \003 centers the line. "\003by Gagua" ) ); aboutBox->insert( new TButton(TRect(14, 10, 26, 12), " OK", cmOK, bfDefault) ); aboutBox->options |= ofCentered; executeDialog(aboutBox); }; #else #ifdef NEWT_CLI WindowCLI::WindowCLI( WindowCLI *parent ){ m_oForm = newtForm( NULL, NULL, 0 ); }; WindowCLI::~WindowCLI(){ newtFormDestroy( m_oForm ); }; void WindowCLI::show(){ paint(); }; void WindowCLI::hide(){ newtPopWindow(); }; newtComponent WindowCLI::run(){ struct newtExitStruct es; return newtRunForm( m_oForm );//, &es ); //return es; }; #else #include "../components/base/basicNCursesEngine.h" WindowCLI::WindowCLI( WINDOW *parent ){ m_pParent = parent; m_pWND = NULL; m_pCDKScreen = NULL; //m_iHeight = 3; //m_iWidth = 10; //m_iStartY = ( LINES - m_iHeight )/2; //m_iStartX = ( COLS - m_iWidth )/2; m_sBorder.ls = '|'; m_sBorder.rs = '|'; m_sBorder.ts = '-'; m_sBorder.bs = '-'; m_sBorder.tl = '+'; m_sBorder.tr = '+'; m_sBorder.bl = '+'; m_sBorder.br = '+'; }; WindowCLI::~WindowCLI(){ /* box(local_win, ' ', ' '); : This won't produce the desired * result of erasing the window. It will leave it's four corners * and so an ugly remnant of window. */ wborder( m_pWND, ' ', ' ', ' ',' ',' ',' ',' ',' '); /* The parameters taken are * 1. win: the window on which to operate * 2. ls: character to be used for the left side of the window * 3. rs: character to be used for the right side of the window * 4. ts: character to be used for the top side of the window * 5. bs: character to be used for the bottom side of the window * 6. tl: character to be used for the top left corner of the window * 7. tr: character to be used for the top right corner of the window * 8. bl: character to be used for the bottom left corner of the window * 9. br: character to be used for the bottom right corner of the window */ wrefresh( m_pWND ); delwin( m_pWND ); }; bool WindowCLI::create( int startx, int starty, int width, int height ){ m_iStartX = startx; m_iStartY = starty; m_iWidth = width; m_iHeight = height; m_pWND = newwin( m_iHeight, m_iWidth, m_iStartY, m_iStartX ); if( m_pWND != NULL ) { createBox( true ); wrefresh( m_pWND ); basicNCursesEngine::getInstance()->attachWindow( this ); return true; }; return false; }; void WindowCLI::createBox( bool flag ){ if( flag ){ mvaddch(m_iStartY, m_iStartX, m_sBorder.tl); mvaddch(m_iStartY, m_iStartX + m_iWidth, m_sBorder.tr); mvaddch(m_iStartY + m_iHeight, m_iStartX, m_sBorder.bl); mvaddch(m_iStartY + m_iHeight, m_iStartX + m_iWidth, m_sBorder.br); mvhline(m_iStartY, m_iStartX + 1, m_sBorder.ts, m_iWidth - 1); mvhline(m_iStartY + m_iHeight, m_iStartX + 1, m_sBorder.bs, m_iWidth - 1); mvvline(m_iStartY + 1, m_iStartX, m_sBorder.ls, m_iHeight - 1); mvvline(m_iStartY + 1, m_iStartX + m_iWidth, m_sBorder.rs, m_iHeight - 1); } else { for(int j = m_iStartY; j <= m_iStartY + m_iHeight; ++j) for(int i = m_iStartX; i <= m_iStartX + m_iWidth; ++i) mvaddch(j, i, ' '); }; refresh(); }; bool WindowCLI::addControl( void *obj, EObjectType objectType ){ CTRL *tVar; tVar =( CTRL * ) malloc( sizeof( CTRL )); if( tVar != NULL ) { tVar->CTL = obj; tVar->type = objectType; m_vCTRLs.push_back( tVar ); return true; }; return false; }; #endif // NEWT_CLI #endif