Subversion Repositories svn1

Rev

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