~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/openbios/arch/unix/plugins/plugin_qt/plugin_qt.cpp

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* tag: qt plugin framebuffer class
 
2
 *
 
3
 * Copyright (C) 2003 Stefan Reinauer
 
4
 *
 
5
 * See the file "COPYING" for further information about
 
6
 * the copyright and warranty status of this work.
 
7
 */
 
8
 
 
9
#include "plugin_qt.h"
 
10
#include "logo.xpm"
 
11
 
 
12
#include <iostream>
 
13
 
 
14
static const int sizex=640;
 
15
static const int sizey=480;
 
16
static const int depth=8;
 
17
 
 
18
static unsigned char color[256][3]={
 
19
        { 0x00, 0x00, 0x00 },
 
20
        { 0x00, 0x00, 0xaa },
 
21
        { 0x00, 0xaa, 0x00 },
 
22
        { 0x00, 0xaa, 0xaa },
 
23
        { 0xaa, 0x00, 0x00 },
 
24
        { 0xaa, 0x00, 0xaa },
 
25
        { 0xaa, 0x55, 0x00 },
 
26
        { 0xaa, 0xaa, 0xaa },
 
27
        { 0x55, 0x55, 0x55 },
 
28
        { 0x55, 0x55, 0xff },
 
29
        { 0x55, 0xff, 0x55 },
 
30
        { 0x55, 0xff, 0xff },
 
31
        { 0xff, 0x55, 0x55 },
 
32
        { 0xff, 0x55, 0xff },
 
33
        { 0xff, 0xff, 0x55 },
 
34
        { 0xff, 0xff, 0xff },
 
35
};
 
36
 
 
37
FrameBufferWidget::FrameBufferWidget(QWidget *parent, const char * name)
 
38
: QWidget(parent, name, Qt::WType_TopLevel)
 
39
{
 
40
        setCaption ("OpenBIOS");
 
41
        setIcon(QPixmap(logo));
 
42
 
 
43
        QPopupMenu *file = new QPopupMenu (this);
 
44
 
 
45
        file->insertItem( "E&xit",  this, SLOT(quit()), CTRL+Key_Q );
 
46
 
 
47
        QPopupMenu *help = new QPopupMenu( this );
 
48
        help->insertItem("&About OpenBIOS", this, SLOT(about()), CTRL+Key_H );
 
49
        help->insertItem( "About &Qt", this, SLOT(aboutQt()) );
 
50
 
 
51
        menu = new QMenuBar( this );
 
52
        Q_CHECK_PTR( menu );
 
53
        menu->insertItem( "&File", file );
 
54
        menu->insertSeparator();
 
55
        menu->insertItem( "&Help", help );
 
56
        menu->setSeparator( QMenuBar::InWindowsStyle );
 
57
 
 
58
        setFixedSize(sizex,sizey+menu->heightForWidth(sizex));
 
59
 
 
60
        buffer.create(sizex, sizey, depth, 256);
 
61
 
 
62
        for (int i=16; i < 256; i++) {
 
63
                color[i][0]=i;
 
64
                color[i][1]=i;
 
65
                color[i][2]=i;
 
66
        }
 
67
 
 
68
        for (int i=0; i< 256; i++)
 
69
                buffer.setColor(i, qRgb(color[i][0], color[i][1], color[i][2]));
 
70
 
 
71
        buffer.fill( 0 );
 
72
 
 
73
        updatetimer=new QTimer(this);
 
74
        connect( updatetimer, SIGNAL(timeout()), this, SLOT(update()) );
 
75
        updatetimer->start(200,FALSE);
 
76
 
 
77
        setMouseTracking( TRUE );
 
78
}
 
79
 
 
80
unsigned char * FrameBufferWidget::getFrameBuffer(void)
 
81
{
 
82
        return buffer.bits();
 
83
}
 
84
 
 
85
void FrameBufferWidget::paintEvent ( QPaintEvent * )
 
86
{
 
87
        QPainter p( this );
 
88
        p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
 
89
}
 
90
 
 
91
void FrameBufferWidget::about()
 
92
{
 
93
        QMessageBox::about( this, "About OpenBIOS",
 
94
                          "              Welcome to OpenBIOS 1.01\n"
 
95
                          "  IEEE 1275-1994 Open Firmware implementation\n\n"
 
96
                          "written by Stefan Reinauer <stepan@openbios.org>\n\n"
 
97
                          "                http://www.openbios.org/\n");
 
98
}
 
99
 
 
100
void FrameBufferWidget::aboutQt()
 
101
{
 
102
        QMessageBox::aboutQt( this, "OpenBIOS" );
 
103
}
 
104
 
 
105
void FrameBufferWidget::quit()
 
106
{
 
107
        extern volatile int gui_running;
 
108
        extern volatile int interruptforth;
 
109
 
 
110
        gui_running=0;
 
111
        interruptforth=1;
 
112
 
 
113
        qApp->quit();
 
114
}
 
115
 
 
116
void FrameBufferWidget::update()
 
117
{
 
118
        QPainter p( this );
 
119
        p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
 
120
}
 
121
 
 
122
void FrameBufferWidget::keyPressEvent(QKeyEvent * e)
 
123
{
 
124
        int a=e->ascii();
 
125
        if (a) {
 
126
                std::cout << " key '" << e->text() << "' pressed" << std::endl;
 
127
        }
 
128
}