Adding comments
[situare] / src / ui / panelbar.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6         Pekka Nissinen - pekka.nissinen@ixonos.com
7
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21 */
22
23 #include <QDebug>
24 #include <QPainter>
25 #include <QRegion>
26
27 #include "panelbar.h"
28
29 #include "panelcommon.h"
30
31 const int PANEL_BAR_RECT_X = 0;
32 const int PANEL_BAR_RECT_Y = 0;
33
34 PanelBar::PanelBar(QWidget *parent)
35     : QWidget(parent)
36 {
37     qDebug() << __PRETTY_FUNCTION__;
38
39     m_barTile.load(":/res/images/panel_bar_tile.png");
40     m_menuDropShadowTile.load(":/res/images/menu_bar_drop_shadow.png");
41     m_barRect.setRect(PANEL_BAR_RECT_X, PANEL_BAR_RECT_Y, PANEL_BAR_WIDTH, PANEL_HEIGHT);
42
43     resize(PANEL_BAR_WIDTH, PANEL_HEIGHT);
44 }
45
46 void PanelBar::paintEvent(QPaintEvent *event)
47 {
48     qDebug() << __PRETTY_FUNCTION__;
49
50     Q_UNUSED(event);
51
52     const int MENU_DROP_SHADOW_RECT_X = 0;
53     const int MENU_DROP_SHADOW_RECT_Y = 0;
54
55     QPainter painter(this);
56
57     painter.drawTiledPixmap(m_barRect, m_barTile);
58     painter.drawTiledPixmap(MENU_DROP_SHADOW_RECT_X, MENU_DROP_SHADOW_RECT_Y, PANEL_BAR_WIDTH,
59                             m_menuDropShadowTile.height(), m_menuDropShadowTile);
60 }
61
62 void PanelBar::resizeBar(const QSize &size)
63 {
64     qDebug() << __PRETTY_FUNCTION__;
65
66     m_barRect.setRect(PANEL_BAR_RECT_X, PANEL_BAR_RECT_Y, PANEL_BAR_WIDTH, size.height());
67
68     resize(PANEL_BAR_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
69 }