1 #include "config.h"
2 #include "ywindow.h"
3 #include "applet.h"
4 #include "yxapp.h"
5 #include "default.h"
6
~Picturer()7 Picturer::~Picturer()
8 {
9 }
10
IApplet(Picturer * picturer,YWindow * parent)11 IApplet::IApplet(Picturer *picturer, YWindow *parent) :
12 YWindow(parent),
13 isVisible(false),
14 fPicturer(picturer),
15 fPixmap(None)
16 {
17 addStyle(wsNoExpose | wsToolTipping);
18 addEventMask(VisibilityChangeMask);
19 }
20
~IApplet()21 IApplet::~IApplet()
22 {
23 freePixmap();
24 }
25
freePixmap()26 void IApplet::freePixmap()
27 {
28 if (fPixmap) {
29 XFreePixmap(xapp->display(), fPixmap);
30 fPixmap = None;
31 }
32 }
33
handleVisibility(const XVisibilityEvent & visib)34 void IApplet::handleVisibility(const XVisibilityEvent& visib)
35 {
36 bool prev = isVisible;
37 isVisible = (visib.state != VisibilityFullyObscured);
38 if (prev < isVisible)
39 repaint();
40 }
41
repaint()42 void IApplet::repaint()
43 {
44 if (isVisible && visible() && fPicturer->picture())
45 showPixmap();
46 }
47
getPixmap()48 Drawable IApplet::getPixmap()
49 {
50 if (fPixmap == None)
51 fPixmap = createPixmap();
52 return fPixmap;
53 }
54
showPixmap()55 void IApplet::showPixmap() {
56 Graphics g(fPixmap, width(), height(), depth());
57 paint(g, YRect(0, 0, width(), height()));
58 setBackgroundPixmap(fPixmap);
59 clearWindow();
60 }
61
configure(const YRect2 & r)62 void IApplet::configure(const YRect2& r) {
63 if (r.resized())
64 freePixmap();
65 if (None == fPixmap && 1 < r.width() && 1 < r.height())
66 repaint();
67 }
68
69