|
1 /*************************************************************************** |
|
2 * Copyright (C) 2006-2008 by Tomasz Ziobrowski * |
|
3 * http://www.3electrons.com * |
|
4 * e-mail: t.ziobrowski@3electrons.com * |
|
5 * * |
|
6 * * |
|
7 * This program is free software; you can redistribute it and/or modify * |
|
8 * it under the terms of the GNU General Public License as published by * |
|
9 * the Free Software Foundation; either version 2 of the License, or * |
|
10 * (at your option) any later version. * |
|
11 * * |
|
12 * This program 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 this program; if not, write to the * |
|
19 * Free Software Foundation, Inc., * |
|
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
|
21 ***************************************************************************/ |
|
22 |
|
23 #ifndef WIDGETWITHBACKGROUND_H |
|
24 #define WIDGETWITHBACKGROUND_H |
|
25 |
|
26 #include <QWidget> |
|
27 |
|
28 class QPixmap; |
|
29 |
|
30 class WidgetWithBackground : public QWidget |
|
31 { |
|
32 Q_OBJECT |
|
33 public: |
|
34 /** Konstruktor */ |
|
35 WidgetWithBackground(QWidget * parent = 0); |
|
36 |
|
37 /** Destruktor - usuwa bitmapkę. */ |
|
38 ~WidgetWithBackground (); |
|
39 |
|
40 /** |
|
41 * Operacja odmalowywania kontrolki - |
|
42 * wkleja bitmapę z tłem na kontrolkę - |
|
43 * generująć ją wcześniej jeżeli zajdzie taka potrzeba. |
|
44 */ |
|
45 void drawBackground (); |
|
46 |
|
47 /** Odmalowywuje kontrolkę bezwarunkowo odmalowywując tło. */ |
|
48 void updateWithBackground (); |
|
49 |
|
50 /** |
|
51 * Zawraca informacje czy kontrolka została zmodyfikowana |
|
52 * Ta informacja jest ustawiana gdy bitmapka tła się zmienia |
|
53 * to znaczy zmienia się rozmiar komponentu lub istnieje |
|
54 * potrzeba przemalowania tła. |
|
55 */ |
|
56 bool doRepaintBackground(); |
|
57 |
|
58 protected: |
|
59 /** Wywołuje paintBackground - odmalowywując tło na nowo */ |
|
60 void repaintBackground(); |
|
61 |
|
62 /** |
|
63 * Odmalowywuje tło kontrolki |
|
64 * @param painter urządzenie na ktróym mamy malować. |
|
65 * @param background to tło kontrolki |
|
66 */ |
|
67 virtual void paintBackground (QPainter & painer) = 0; |
|
68 |
|
69 |
|
70 |
|
71 protected: |
|
72 /** Bufor na tło. */ |
|
73 QPixmap * m_pixmap; |
|
74 /** |
|
75 * Ustawia tą zmienną po zmianie właściwości |
|
76 */ |
|
77 bool m_modified; |
|
78 }; |
|
79 #endif //WIDGETWITHBACKGROUND_H |
|
80 |