]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robomon/Widget.cpp
robofsm: Strategy
[eurobot/public.git] / src / robomon / Widget.cpp
1 /*
2  * Widget.cpp                           08/03/29
3  *
4  * A widget template.
5  *
6  * Copyright: (c) 2008 CTU Dragons
7  *            CTU FEE - Department of Control Engineering
8  * Authors: Martin Zidek, Michal Sojka, Tran Duy Khanh
9  * License: GNU GPL v.2
10  */
11
12 #include <QtGui>
13 #include "Widget.h"
14 #include "Painter.h"
15
16 Widget::Widget(Painter *painter, QWidget *parent)
17         : QWidget(parent), painter(painter)
18 {
19         setFixedSize(painter->size());
20         aliasing = RENDER_HINT_ALIASING;
21 }
22
23 void Widget::animate()
24 {
25         /* repaint should be used only if we want to draw immediately, 
26            otherwise update() should be preferred */
27         /*repaint();*/
28         update();
29 }
30
31 void Widget::paintEvent(QPaintEvent *event)
32 {
33         QPainter p;
34         p.begin(this);
35         if (aliasing)
36                 p.setRenderHint(QPainter::Antialiasing);
37         painter->paint(&p, event);
38         p.end();
39 }
40
41 void Widget::setAliasing(bool state)
42 {
43         aliasing = state;
44 }