Subversion Repositories svn1-original

Rev

Rev 99 | Rev 129 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qmconfigure.h"
#include "qmconfclass.h"
#include "qmconfwinners.h"

MainWindow *mw = NULL;

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    document = new QTextDocument("Hello\nHello");
    ui->textEdit->setDocument ( document );
    cr = new QTextCursor( document );
    clearScreen();
    mw = this;

    QmConfigure *qcnf = new QmConfigure();
    ui->tabWidget->addTab(qcnf, "Configure");
    ui->tabWidget->addTab( new QmConfClass, "Class");
    ui->tabWidget->addTab( new QmConfWinners, "Winners");
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void MainWindow::clearScreen(void)
{
    for ( int ii = 0; ii < 24; ii++)
    {
        for (int jj = 0; jj < 80; jj++)
        {
         cr->insertText(" ");
        }
        cr->insertText(".\n");
    }
    cr->movePosition(QTextCursor::Start,QTextCursor::MoveAnchor,1);
}

void MainWindow::setPosn( int x, int y)
{
    cr->movePosition(QTextCursor::Start,QTextCursor::MoveAnchor,1);
    cr->movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,y);
    cr->movePosition(QTextCursor::Right,QTextCursor::MoveAnchor,x);
}

void MainWindow::insertText( const char * text)
{
    cr->insertText(text);
}

/*========================================================================
 *
 *  Position the cursor on the screen
 *
 *  Purpose:
 *      This function is called to Position the cursor on the screen
 *
 *  Parameters:
 *      x               col number
 *      y               line number
 *
 *  Returns:
 *      Nothing
 *
 *========================================================================*/

void cur( int x, int y )
{
   mw->setPosn(x,y);
}

/*========================================================================
 *
 *  Clears the vdu screen
 *
 *  Purpose:
 *      This function is called to Clears the vdu screen
 *      From the Microsoft Web Site
 *
 *  Parameters:
 *      None
 *
 *  Returns:
 *      Nothing
 *
 *========================================================================*/

void clearscreen( void )
{
  mw->clearScreen();
}

#include    <stdio.h>
int printf( const char *format, ... )
{
    va_list     ap;
    char        pp[200];
    int         len;



    va_start( ap, format );
    len = vsprintf( pp, format, ap );
    va_end( ap );
    mw->insertText(pp);
    return ( len );
}