]> Dogcows Code - chaz/tint2/blob - src/util/area.h
cleanup code
[chaz/tint2] / src / util / area.h
1 /**************************************************************************
2 * Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
3 *
4 * base class for all graphical objects (panel, taskbar, task, systray, clock, ...).
5 * Area is at the begining of each object (&object == &area).
6 *
7 * Area manage the background and border drawing, size and padding.
8 * Each Area has one Pixmap (pix).
9 *
10 * Area manage the tree of all objects. Parent object drawn before child object.
11 * panel -> taskbars -> tasks
12 * -> systray -> icons
13 * -> clock
14 *
15 * draw_foreground(obj) and resize(obj) are virtual function.
16 *
17 **************************************************************************/
18
19 #ifndef AREA_H
20 #define AREA_H
21
22 #include <glib.h>
23 #include <X11/Xlib.h>
24 #include <cairo.h>
25 #include <cairo-xlib.h>
26
27
28 typedef struct
29 {
30 double color[3];
31 double alpha;
32 int width;
33 int rounded;
34 } Border;
35
36
37 typedef struct
38 {
39 double color[3];
40 double alpha;
41 } Color;
42
43 typedef struct
44 {
45 Color back;
46 Border border;
47 } Background;
48
49
50 // way to calculate the size
51 // SIZE_BY_LAYOUT objects : taskbar and task
52 // SIZE_BY_CONTENT objects : clock, battery, launcher, systray
53 enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT };
54
55 typedef struct {
56 // coordinate relative to panel window
57 int posx, posy;
58 // width and height including border
59 int width, height;
60 Pixmap pix;
61 Background *bg;
62
63 // list of child : Area object
64 GSList *list;
65
66 // object visible on screen.
67 // An object (like systray) could be enabled but hidden (because no tray icon).
68 int on_screen;
69 // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
70 int size_mode;
71 // need to calculate position and width
72 int resize;
73 // need redraw Pixmap
74 int redraw;
75 // paddingxlr = horizontal padding left/right
76 // paddingx = horizontal padding between childs
77 int paddingxlr, paddingx, paddingy;
78 // parent Area
79 void *parent;
80 // panel
81 void *panel;
82
83 // each object can overwrite following function
84 void (*_draw_foreground)(void *obj, cairo_t *c);
85 // update area's content and update size (width/heith).
86 // return '1' if size changed, '0' otherwise.
87 int (*_resize)(void *obj);
88 void (*_add_child)(void *obj);
89 int (*_remove_child)(void *obj);
90 const char* (*_get_tooltip_text)(void *obj);
91 } Area;
92
93 // on startup, initialize fixed pos/size
94 void init_rendering(void *obj, int pos);
95
96 void rendering(void *obj);
97 void size_by_content (Area *a);
98 void size_by_layout (Area *a, int pos, int level);
99 // draw background and foreground
100 void refresh (Area *a);
101
102 // generic resize for SIZE_BY_LAYOUT objects
103 int resize_by_layout(void *obj);
104
105 // set 'redraw' on an area and childs
106 void set_redraw (Area *a);
107
108 // hide/unhide area
109 void hide(Area *a);
110 void show(Area *a);
111
112 // draw pixmap
113 void draw (Area *a);
114 void draw_background (Area *a, cairo_t *c);
115
116 void remove_area (Area *a);
117 void add_area (Area *a);
118 void free_area (Area *a);
119
120 // draw rounded rectangle
121 void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
122
123 // clear pixmap with transparent color
124 void clear_pixmap(Pixmap p, int x, int y, int w, int h);
125 #endif
126
This page took 0.034232 seconds and 4 git commands to generate.