author | zecke <zecke> | 2003-09-03 10:04:28 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-03 10:04:28 (UTC) |
commit | a0dc2e500265eff0e76934cf02ef2aedb90cec0d (patch) (unidiff) | |
tree | 29ea16c8a8808552e2ea4d4fc17d117feebdd909 /examples/applet/simpleimpl.h | |
parent | 88d625d9695582d57852f94581f71bb18c00a8a1 (diff) | |
download | opie-a0dc2e500265eff0e76934cf02ef2aedb90cec0d.zip opie-a0dc2e500265eff0e76934cf02ef2aedb90cec0d.tar.gz opie-a0dc2e500265eff0e76934cf02ef2aedb90cec0d.tar.bz2 |
Add an Example Applet Now Tux grins from your Taskbar ;)
Diffstat (limited to 'examples/applet/simpleimpl.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/applet/simpleimpl.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/examples/applet/simpleimpl.h b/examples/applet/simpleimpl.h new file mode 100644 index 0000000..8459c96 --- a/dev/null +++ b/examples/applet/simpleimpl.h | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * You may use, modify and distribute without any limitation | ||
3 | */ | ||
4 | |||
5 | /** | ||
6 | * Opie and Qtopia uses a component system called QCOM | ||
7 | * which was first part of the Qt 3.0 API but was made | ||
8 | * prviate during the betas. Opie and Qtopia still use it | ||
9 | * and we're happy with it. | ||
10 | * Every starts with the QUnknownInterface. It supports functions | ||
11 | * for reference counting and the most important one | ||
12 | * is for a query. Every QCOM interface got a global unique id ( GUID,UUID ) | ||
13 | * query is used to see if a interface is supported by | ||
14 | * a dynamic shared object ( dso / plugin ) | ||
15 | * For tasks like loading Applications, InputMethods, Today, MenuButton, | ||
16 | * Taskbar, Style, Email Client there are specefic Interfaces you | ||
17 | * need to implement. The interfaces inherits from QUnknownInterface and | ||
18 | * you'll need inherit from the interface. | ||
19 | * As example we will use the Taskbar interface | ||
20 | */ | ||
21 | |||
22 | #ifndef SIMPLE_OPIE_EXAMPLE_APPLET_H | ||
23 | #define SIMPLE_OPIE_EXAMPLE_APPLET_H | ||
24 | |||
25 | /* | ||
26 | * The taskbar applet interfaces wants us to implement position() and applet() | ||
27 | * additionally we need to implement add(), release() and queryInterface for QUnknownInterface | ||
28 | * luckiy there is a macro for the reference counting | ||
29 | * We provide an Implementation of the interface. | ||
30 | */ | ||
31 | #include <qwidget.h> | ||
32 | #include <qpe/taskbarappletinterface.h> | ||
33 | |||
34 | |||
35 | /* | ||
36 | * Because we only draw an Icon in a fixed width and height | ||
37 | * we declare and define SimpleApplet here and you could use QLabel | ||
38 | * setPixmap or use QWidget and draw yourself. | ||
39 | * You might also want to reimplement mouse*Event to use some simple actions | ||
40 | */ | ||
41 | class SimpleApplet : public QWidget { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | SimpleApplet(QWidget *parent); | ||
45 | ~SimpleApplet(); | ||
46 | private: | ||
47 | void mousePressEvent( QMouseEvent* ); | ||
48 | void paintEvent( QPaintEvent* ); | ||
49 | QPixmap *m_pix; | ||
50 | }; | ||
51 | |||
52 | class SimpleAppletImpl : public TaskbarAppletInterface { | ||
53 | public: | ||
54 | |||
55 | SimpleAppletImpl(); | ||
56 | virtual ~SimpleAppletImpl(); | ||
57 | |||
58 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
59 | |||
60 | QWidget *applet( QWidget* parent ); | ||
61 | int position()const; | ||
62 | |||
63 | /* | ||
64 | * macro for reference countint | ||
65 | * if reference drops to zero | ||
66 | * delete this is called | ||
67 | */ | ||
68 | Q_REFCOUNT | ||
69 | }; | ||
70 | |||
71 | |||
72 | #endif | ||