summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2003-04-16 22:22:31 (UTC)
committer mickeyl <mickeyl>2003-04-16 22:22:31 (UTC)
commit14db7d7d1ea99b8d9715f11daaa3ca9f4d8a554a (patch) (unidiff)
treed56c4f8eb14e9706df4746b77351e5a41e436c77 /libopie2
parentde7f71c5c362fbefdf3cfa004e7e6f6d5615d475 (diff)
downloadopie-14db7d7d1ea99b8d9715f11daaa3ca9f4d8a554a.zip
opie-14db7d7d1ea99b8d9715f11daaa3ca9f4d8a554a.tar.gz
opie-14db7d7d1ea99b8d9715f11daaa3ca9f4d8a554a.tar.bz2
add OTaskbarAppletWrapper for reducing the repetition of boiler-plate-code
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/opieui.pro6
-rw-r--r--libopie2/opieui/otaskbarapplet.cpp32
-rw-r--r--libopie2/opieui/otaskbarapplet.h129
3 files changed, 165 insertions, 2 deletions
diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro
index ba85766..996e1a0 100644
--- a/libopie2/opieui/opieui.pro
+++ b/libopie2/opieui/opieui.pro
@@ -1,46 +1,48 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = ocompletionbox.h \ 4HEADERS = ocompletionbox.h \
5 ocombobox.h \ 5 ocombobox.h \
6 oeditlistbox.h \ 6 oeditlistbox.h \
7 olineedit.h \ 7 olineedit.h \
8 olistview.h \ 8 olistview.h \
9 oimageeffect.h \ 9 oimageeffect.h \
10 opixmapeffect.h \ 10 opixmapeffect.h \
11 opopupmenu.h \ 11 opopupmenu.h \
12 opixmapprovider.h \ 12 opixmapprovider.h \
13 oselector.h \ 13 oselector.h \
14 oversatileview.h \ 14 oversatileview.h \
15 oversatileviewitem.h \ 15 oversatileviewitem.h \
16 #ojanuswidget.h \ 16 #ojanuswidget.h \
17 odialog.h \ 17 odialog.h \
18 oseparator.h 18 oseparator.h \
19 otaskbarapplet.h
19 20
20SOURCES = ocompletionbox.cpp \ 21SOURCES = ocompletionbox.cpp \
21 ocombobox.cpp \ 22 ocombobox.cpp \
22 oeditlistbox.cpp \ 23 oeditlistbox.cpp \
23 olineedit.cpp \ 24 olineedit.cpp \
24 olistview.cpp \ 25 olistview.cpp \
25 oimageeffect.cpp \ 26 oimageeffect.cpp \
26 opixmapeffect.cpp \ 27 opixmapeffect.cpp \
27 opopupmenu.cpp \ 28 opopupmenu.cpp \
28 opixmapprovider.cpp \ 29 opixmapprovider.cpp \
29 oselector.cpp \ 30 oselector.cpp \
30 oversatileview.cpp \ 31 oversatileview.cpp \
31 oversatileviewitem.cpp \ 32 oversatileviewitem.cpp \
32 #ojanuswidget.cpp \ 33 #ojanuswidget.cpp \
33 odialog.cpp \ 34 odialog.cpp \
34 oseparator.cpp 35 oseparator.cpp \
36 otaskbarapplet.cpp
35 37
36INTERFACES = 38INTERFACES =
37TARGET = opieui2 39TARGET = opieui2
38VERSION = 1.8.1 40VERSION = 1.8.1
39INCLUDEPATH += $(OPIEDIR)/include 41INCLUDEPATH += $(OPIEDIR)/include
40DEPENDPATH += $(OPIEDIR)/include 42DEPENDPATH += $(OPIEDIR)/include
41LIBS += -lopiecore2 43LIBS += -lopiecore2
42MOC_DIR = moc 44MOC_DIR = moc
43OBJECTS_DIR = obj 45OBJECTS_DIR = obj
44 46
45include ( $(OPIEDIR)/include.pro ) 47include ( $(OPIEDIR)/include.pro )
46 48
diff --git a/libopie2/opieui/otaskbarapplet.cpp b/libopie2/opieui/otaskbarapplet.cpp
new file mode 100644
index 0000000..a67356d
--- a/dev/null
+++ b/libopie2/opieui/otaskbarapplet.cpp
@@ -0,0 +1,32 @@
1/*
2                 This file is part of the Opie Project
3
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32// Empty on purpose until we shipped Opie 1.0 (see otaskbarapplet.h for explanation)
diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h
new file mode 100644
index 0000000..686b91a
--- a/dev/null
+++ b/libopie2/opieui/otaskbarapplet.h
@@ -0,0 +1,129 @@
1/*
2                 This file is part of the Opie Project
3
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#ifndef OTASKBARAPPLET_H
33#define OTASKBARAPPLET_H
34
35#include <qpe/taskbarappletinterface.h>
36
37/*======================================================================================
38 * OTaskbarAppletWrapper
39 *======================================================================================*/
40
41template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface
42{
43 public:
44 OTaskbarAppletWrapper():_applet( 0 ), ref( 0 )
45 {
46 }
47
48 virtual ~OTaskbarAppletWrapper()
49 {
50 delete _applet;
51 }
52
53 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface )
54 {
55 qDebug( "OTaskbarAppletWrapper::queryInterface()" );
56 *iface = 0;
57 if ( uuid == IID_QUnknown )
58 *iface = this;
59 else if ( uuid == IID_TaskbarApplet )
60 *iface = this;
61
62 if ( *iface ) (*iface)->addRef();
63 return QS_OK;
64 }
65
66 Q_REFCOUNT
67
68 virtual T* applet( QWidget* parent )
69 {
70 if ( !_applet ) _applet = new T( parent );
71 return _applet;
72 }
73
74 virtual int position() const
75 {
76 return T::position();
77 }
78
79 private:
80 T* _applet;
81 ulong ref;
82};
83
84#include <qframe.h>
85#include <qwidget.h>
86#include <qpe/qpeapplication.h>
87
88class QMouseEvent;
89
90/*======================================================================================
91 * OTaskbarApplet
92 *======================================================================================*/
93
94// Must be inline until after we shipped Opie 1.0
95
96// Having OTaskBarApplet reside in libopieui2 is not possible
97// until we link the launcher binary against libopieui2 -
98// otherwise the necessary symbols are not present, when
99// the dynamic loader [dlopen] tries to resolve an applet which
100// inherits OTaskbarApplet
101
102class OTaskbarApplet : public QWidget
103{
104 public:
105 OTaskbarApplet( QWidget* parent, const char* name = 0 ):QWidget( parent, name )
106 {
107 setFixedHeight( 18 );
108 setFixedWidth( 14 );
109 }
110
111 virtual ~OTaskbarApplet()
112 {
113 }
114
115 protected:
116 virtual void popup( QWidget* widget )
117 {
118 QPoint curPos = mapToGlobal( QPoint( 0, 0 ) );
119 int w = widget->sizeHint().width();
120 int x = curPos.x() - (w/2 );
121 if ( (x+w) > QPEApplication::desktop()->width() )
122 x = QPEApplication::desktop()->width()-w;
123 widget->move( x, curPos.y()-widget->sizeHint().height() );
124 widget->show();
125 }
126};
127
128#endif
129