Reworked version of Forth Source debugger (Mark Cave-Ayland)
[openbios.git] / arch / unix / gui_qt / gui-qt.cpp
blob24c084283a0d6df75c2b1ea888acd38d02dce3f8
1 /* tag: qt user interface fb class
3 * Copyright (C) 2003-2004 Stefan Reinauer
5 * See the file "COPYING" for further information about
6 * the copyright and warranty status of this work.
7 */
9 #include "gui-qt.h"
10 #include "logo.xpm"
12 #include <iostream>
14 static const int sizex=640;
15 static const int sizey=480;
16 static const int depth=8;
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 },
37 FrameBufferWidget::FrameBufferWidget(QWidget *parent, const char * name)
38 : QWidget(parent, name, Qt::WType_TopLevel)
40 setCaption ("OpenBIOS");
41 setIcon(QPixmap(logo));
43 QPopupMenu *file = new QPopupMenu (this);
45 file->insertItem( "E&xit", this, SLOT(quit()), CTRL+Key_Q );
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()) );
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 );
58 setFixedSize(sizex,sizey+menu->heightForWidth(sizex));
60 buffer.create(sizex, sizey, depth, 256);
62 for (int i=16; i < 256; i++) {
63 color[i][0]=i;
64 color[i][1]=i;
65 color[i][2]=i;
68 for (int i=0; i< 256; i++)
69 buffer.setColor(i, qRgb(color[i][0], color[i][1], color[i][2]));
71 buffer.fill( 0 );
73 updatetimer=new QTimer(this);
74 connect( updatetimer, SIGNAL(timeout()), this, SLOT(update()) );
75 updatetimer->start(200,FALSE);
77 setMouseTracking( TRUE );
80 unsigned char * FrameBufferWidget::getFrameBuffer(void)
82 return buffer.bits();
85 void FrameBufferWidget::paintEvent ( QPaintEvent * )
87 QPainter p( this );
88 p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
91 void FrameBufferWidget::about()
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");
100 void FrameBufferWidget::aboutQt()
102 QMessageBox::aboutQt( this, "OpenBIOS" );
105 void FrameBufferWidget::quit()
107 extern volatile int gui_running;
108 extern volatile int runforth;
110 gui_running=0;
111 interruptforth=1;
113 qApp->quit();
116 void FrameBufferWidget::update()
118 QPainter p( this );
119 p.drawImage(0,menu->heightForWidth(sizex),buffer, 0,0, sizex, sizey);
122 void FrameBufferWidget::keyPressEvent(QKeyEvent * e)
124 int a=e->ascii();
125 if (a) {
126 std::cout << " key '" << e->text() << "' pressed" << std::endl;