summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/arch/unix/plugins/plugin_qt/plugin_qt.cpp
blob: 07234dc0afd93ba66d41aec45e7a3f470e41e790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* tag: qt plugin framebuffer class
 *
 * Copyright (C) 2003 Stefan Reinauer
 *
 * See the file "COPYING" for further information about
 * the copyright and warranty status of this work.
 */

#include "plugin_qt.h"
#include "logo.xpm"

#include <iostream>

static const int sizex=640;
static const int sizey=480;
static const int depth=8;

static unsigned char color[256][3]={
	{ 0x00, 0x00, 0x00 },
	{ 0x00, 0x00, 0xaa },
	{ 0x00, 0xaa, 0x00 },
	{ 0x00, 0xaa, 0xaa },
	{ 0xaa, 0x00, 0x00 },
	{ 0xaa, 0x00, 0xaa },
	{ 0xaa, 0x55, 0x00 },
	{ 0xaa, 0xaa, 0xaa },
	{ 0x55, 0x55, 0x55 },
	{ 0x55, 0x55, 0xff },
	{ 0x55, 0xff, 0x55 },
	{ 0x55, 0xff, 0xff },
	{ 0xff, 0x55, 0x55 },
	{ 0xff, 0x55, 0xff },
	{ 0xff, 0xff, 0x55 },
	{ 0xff, 0xff, 0xff },
};

FrameBufferWidget::FrameBufferWidget(QWidget *parent, const char * name)
: QWidget(parent, name, Qt::WType_TopLevel)
{
	setCaption ("OpenBIOS");
	setIcon(QPixmap(logo));

	QPopupMenu *file = new QPopupMenu (this);

	file->insertItem( "E&xit",  this, SLOT(quit()), CTRL+Key_Q );

	QPopupMenu *help = new QPopupMenu( this );
	help->insertItem("&About OpenBIOS", this, SLOT(about()), CTRL+Key_H );
	help->insertItem( "About &Qt", this, SLOT(aboutQt()) );

	menu = new QMenuBar( this );
	Q_CHECK_PTR( menu );
	menu->insertItem( "&File", file );
	menu->insertSeparator();
	menu->insertItem( "&Help", help );
	menu->setSeparator( QMenuBar::InWindowsStyle );

	setFixedSize(sizex,sizey+menu->heightForWidth(sizex));

	buffer.create(sizex, sizey, depth, 256);

	for (int i=16; i < 256; i++) {
		color[i][0]=i;
		color[i][1]=i;
		color[i][2]=i;
	}

	for (int i=0; i< 256; i++)
		buffer.setColor(i, qRgb(color[i][0], color[i][1], color[i][2]));

	buffer.fill( 0 );

	updatetimer=new QTimer(this);
	connect( updatetimer, SIGNAL(timeout()), this, SLOT(update()) );
	updatetimer->start(200,FALSE);

	setMouseTracking( TRUE );
}

unsigned char * FrameBufferWidget::getFrameBuffer(void)
{
	return buffer.bits();
}

void FrameBufferWidget::paintEvent ( QPaintEvent * )
{
	QPainter p( this );
	p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
}

void FrameBufferWidget::about()
{
	QMessageBox::about( this, "About OpenBIOS",
			  "              Welcome to OpenBIOS 1.01\n"
			  "  IEEE 1275-1994 Open Firmware implementation\n\n"
			  "written by Stefan Reinauer <stepan@openbios.org>\n\n"
			  "                http://www.openbios.org/\n");
}

void FrameBufferWidget::aboutQt()
{
	QMessageBox::aboutQt( this, "OpenBIOS" );
}

void FrameBufferWidget::quit()
{
	extern volatile int gui_running;
	extern volatile int interruptforth;

	gui_running=0;
	interruptforth=1;

	qApp->quit();
}

void FrameBufferWidget::update()
{
	QPainter p( this );
	p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
}

void FrameBufferWidget::keyPressEvent(QKeyEvent * e)
{
	int a=e->ascii();
	if (a) {
		std::cout << " key '" << e->text() << "' pressed" << std::endl;
	}
}