Subversion Repositories svn1

Rev

Rev 112 | Rev 126 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 - 1
#include "mainwindow.h"
2
#include "ui_mainwindow.h"
3
#include "qmconfigure.h"
95 david 4
#include "qmconfclass.h"
104 - 5
#include "qmconfwinners.h"
112 david 6
#include "teamdisplay.h"
94 - 7
 
8
MainWindow *mw = NULL;
9
 
10
MainWindow::MainWindow(QWidget *parent) :
11
    QMainWindow(parent),
12
    ui(new Ui::MainWindow)
13
{
14
    ui->setupUi(this);
15
    document = new QTextDocument("Hello\nHello");
16
    ui->textEdit->setDocument ( document );
17
    cr = new QTextCursor( document );
18
    clearScreen();
19
    mw = this;
20
 
21
    QmConfigure *qcnf = new QmConfigure();
22
    ui->tabWidget->addTab(qcnf, "Configure");
104 - 23
    ui->tabWidget->addTab( new QmConfClass, "Class");
24
    ui->tabWidget->addTab( new QmConfWinners, "Winners");
112 david 25
    ui->tabWidget->addTab( new teamDisplay, "Team Data");
125 - 26
 
27
    ui->mainToolBar->addAction("Test");
28
    ui->menuBar->addAction("MenuTest");
29
 
30
    QMenu *m1 = new QMenu ("Menu1");
31
    m1->addAction("M1.A1");
32
    ui->menuBar->addMenu(m1);
33
 
34
 
94 - 35
}
36
 
37
MainWindow::~MainWindow()
38
{
39
    delete ui;
40
}
41
 
42
void MainWindow::changeEvent(QEvent *e)
43
{
44
    QMainWindow::changeEvent(e);
45
    switch (e->type()) {
46
    case QEvent::LanguageChange:
47
        ui->retranslateUi(this);
48
        break;
49
    default:
50
        break;
51
    }
52
}
53
 
54
void MainWindow::clearScreen(void)
55
{
56
    for ( int ii = 0; ii < 24; ii++)
57
    {
58
        for (int jj = 0; jj < 80; jj++)
59
        {
60
         cr->insertText(" ");
61
        }
62
        cr->insertText(".\n");
63
    }
64
    cr->movePosition(QTextCursor::Start,QTextCursor::MoveAnchor,1);
65
}
66
 
67
void MainWindow::setPosn( int x, int y)
68
{
69
    cr->movePosition(QTextCursor::Start,QTextCursor::MoveAnchor,1);
70
    cr->movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,y);
71
    cr->movePosition(QTextCursor::Right,QTextCursor::MoveAnchor,x);
72
}
73
 
74
void MainWindow::insertText( const char * text)
75
{
76
    cr->insertText(text);
77
}
78
 
79
/*========================================================================
80
 *
81
 *  Position the cursor on the screen
82
 *
83
 *  Purpose:
84
 *      This function is called to Position the cursor on the screen
85
 *
86
 *  Parameters:
87
 *      x               col number
88
 *      y               line number
89
 *
90
 *  Returns:
91
 *      Nothing
92
 *
93
 *========================================================================*/
94
 
95
void cur( int x, int y )
96
{
97
   mw->setPosn(x,y);
98
}
99
 
100
/*========================================================================
101
 *
102
 *  Clears the vdu screen
103
 *
104
 *  Purpose:
105
 *      This function is called to Clears the vdu screen
106
 *      From the Microsoft Web Site
107
 *
108
 *  Parameters:
109
 *      None
110
 *
111
 *  Returns:
112
 *      Nothing
113
 *
114
 *========================================================================*/
115
 
116
void clearscreen( void )
117
{
118
  mw->clearScreen();
119
}
120
 
121
#include    <stdio.h>
122
int printf( const char *format, ... )
123
{
124
    va_list     ap;
125
    char        pp[200];
126
    int         len;
127
 
128
 
129
 
130
    va_start( ap, format );
131
    len = vsprintf( pp, format, ap );
132
    va_end( ap );
133
    mw->insertText(pp);
134
    return ( len );
135
}
136