File: applet.h

package info (click to toggle)
literki 0.0.0+20100113.git1da40724-1.2
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 3,444 kB
  • ctags: 1,153
  • sloc: cpp: 5,263; makefile: 72
file content (62 lines) | stat: -rw-r--r-- 1,694 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _APPLET_H
#define _APPLET_H

#include "display.h"
#include "vibrator.h"

typedef std::string AppAction;

struct AppletWindowParams {
    AppletWindowParams(int width_p, int height_p, int width_l, int height_l, MyDisplay& d, std::string font, int size)
	:width_portrait(width_p), height_portrait(height_p), width_landscape(width_l), height_landscape(height_l), disp(d), font_path(font), font_size(size){}
    int width_landscape;
    int height_landscape;
    int width_portrait;
    int height_portrait;
    MyDisplay& disp;
    std::string font_path;
    int font_size;
};

class Applet {
  public:
    Applet(AppletWindowParams params);
    virtual ~Applet(){}
    enum Position { NORTH, SOUTH, SOUTH_EAST, SOUTH_WEST, NORTH_EAST, NORTH_WEST };
    void SetPosition(Position p);
    void SetBackground(XColor col);
    void SetForeground(XColor col);
    void Show();
    void Hide();
    bool Hidden();
    void Refresh();
    virtual AppAction OnMousePress(int x, int y){ return "";}
    virtual AppAction OnMouseMove(int x, int y){ return "";}
    virtual AppAction OnMouseRelease(int x, int y){ return "";}
    virtual void OnShow(){}
    virtual void OnHide(){}
    enum Rotation { LANDSCAPE, PORTRAIT };
    void WindowRotate(Rotation r);
    virtual void OnRotate(Rotation r) = 0;

    void SetTransparent(bool trans);
    void ToggleTransparent();
    bool IsTransparent();

    bool IsWindowOwner(Window xwin);
    void SetVibrator(Vibrator* vib);
    void Vibrate();


  protected:
    int GetCurrentWidth();
    int GetCurrentHeight();
    MyWindow win;
    Position pos;
    bool hidden;
    Rotation rot;
    AppletWindowParams params;
    Vibrator* vibrator;
};

#endif