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.
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]={
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 );
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
++) {
68 for (int i
=0; i
< 256; i
++)
69 buffer
.setColor(i
, qRgb(color
[i
][0], color
[i
][1], color
[i
][2]));
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)
85 void FrameBufferWidget::paintEvent ( QPaintEvent
* )
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
;
116 void FrameBufferWidget::update()
119 p
.drawImage(0,menu
->heightForWidth(sizex
),buffer
, 0,0, sizex
, sizey
);
122 void FrameBufferWidget::keyPressEvent(QKeyEvent
* e
)
126 std::cout
<< " key '" << e
->text() << "' pressed" << std::endl
;