2008-10-02 18:47:02 +00:00
|
|
|
/**************************************************************************
|
2008-10-30 15:39:24 +00:00
|
|
|
* Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
|
2009-01-17 14:07:56 +00:00
|
|
|
*
|
2008-10-30 15:39:24 +00:00
|
|
|
* base class for all graphical objects (panel, taskbar, task, systray, clock, ...).
|
2009-01-17 14:07:56 +00:00
|
|
|
* Area is at the begining of each object (&object == &area).
|
|
|
|
*
|
2008-10-30 15:39:24 +00:00
|
|
|
* Area manage the background and border drawing, size and padding.
|
2010-01-09 00:11:01 +00:00
|
|
|
* Each Area has one Pixmap (pix).
|
2009-01-17 14:07:56 +00:00
|
|
|
*
|
2009-02-13 21:54:42 +00:00
|
|
|
* Area manage the tree of all objects. Parent object drawn before child object.
|
2008-10-30 15:39:24 +00:00
|
|
|
* panel -> taskbars -> tasks
|
|
|
|
* -> systray -> icons
|
2008-11-08 20:23:42 +00:00
|
|
|
* -> clock
|
2009-01-17 14:07:56 +00:00
|
|
|
*
|
2009-02-11 22:25:53 +00:00
|
|
|
* draw_foreground(obj) and resize(obj) are virtual function.
|
2008-10-02 18:47:02 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef AREA_H
|
|
|
|
#define AREA_H
|
|
|
|
|
2009-01-18 22:12:41 +00:00
|
|
|
#include <glib.h>
|
2008-10-02 18:47:02 +00:00
|
|
|
#include <X11/Xlib.h>
|
2009-01-18 22:12:41 +00:00
|
|
|
#include <cairo.h>
|
|
|
|
#include <cairo-xlib.h>
|
2008-10-02 18:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-20 20:48:00 +00:00
|
|
|
double color[3];
|
|
|
|
double alpha;
|
|
|
|
int width;
|
|
|
|
int rounded;
|
2008-10-02 18:47:02 +00:00
|
|
|
} Border;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-20 20:48:00 +00:00
|
|
|
double color[3];
|
|
|
|
double alpha;
|
2008-10-02 18:47:02 +00:00
|
|
|
} Color;
|
|
|
|
|
2009-01-17 14:07:56 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-20 20:48:00 +00:00
|
|
|
Color back;
|
|
|
|
Border border;
|
2010-01-09 00:11:01 +00:00
|
|
|
} Background;
|
|
|
|
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2010-08-07 12:17:56 +00:00
|
|
|
// way to calculate the size
|
|
|
|
// SIZE_BY_LAYOUT objects : taskbar and task
|
|
|
|
// SIZE_BY_CONTENT objects : clock, battery, launcher, systray
|
|
|
|
enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT };
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
typedef struct {
|
2009-12-17 11:08:14 +00:00
|
|
|
// coordinate relative to panel window
|
2009-09-20 20:48:00 +00:00
|
|
|
int posx, posy;
|
|
|
|
// width and height including border
|
|
|
|
int width, height;
|
2010-01-09 00:11:01 +00:00
|
|
|
Pixmap pix;
|
|
|
|
Background *bg;
|
2009-01-05 21:01:05 +00:00
|
|
|
|
2009-09-20 20:48:00 +00:00
|
|
|
// list of child : Area object
|
|
|
|
GSList *list;
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2010-09-18 18:06:29 +00:00
|
|
|
// object visible on screen.
|
|
|
|
// An object (like systray) could be enabled but hidden (because no tray icon).
|
2009-02-28 23:04:53 +00:00
|
|
|
int on_screen;
|
2010-08-07 12:17:56 +00:00
|
|
|
// way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
|
|
|
|
int size_mode;
|
|
|
|
// need to calculate position and width
|
2009-02-10 23:16:10 +00:00
|
|
|
int resize;
|
2009-09-20 20:48:00 +00:00
|
|
|
// need redraw Pixmap
|
|
|
|
int redraw;
|
|
|
|
// paddingxlr = horizontal padding left/right
|
|
|
|
// paddingx = horizontal padding between childs
|
|
|
|
int paddingxlr, paddingx, paddingy;
|
|
|
|
// parent Area
|
|
|
|
void *parent;
|
|
|
|
// panel
|
|
|
|
void *panel;
|
|
|
|
|
|
|
|
// each object can overwrite following function
|
2010-01-09 00:11:01 +00:00
|
|
|
void (*_draw_foreground)(void *obj, cairo_t *c);
|
2010-09-23 18:09:30 +00:00
|
|
|
// update area's content and update size (width/heith).
|
|
|
|
// return '1' if size changed, '0' otherwise.
|
2010-09-16 23:24:25 +00:00
|
|
|
int (*_resize)(void *obj);
|
2010-09-25 21:18:47 +00:00
|
|
|
// after pos/size changed, the rendering engine will call _on_change_layout(Area*)
|
|
|
|
int on_changed;
|
|
|
|
void (*_on_change_layout)(void *obj);
|
2009-11-16 17:17:53 +00:00
|
|
|
const char* (*_get_tooltip_text)(void *obj);
|
2008-10-02 18:47:02 +00:00
|
|
|
} Area;
|
|
|
|
|
2010-09-21 09:54:19 +00:00
|
|
|
// on startup, initialize fixed pos/size
|
|
|
|
void init_rendering(void *obj, int pos);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2010-09-21 09:54:19 +00:00
|
|
|
void rendering(void *obj);
|
2010-08-10 13:18:17 +00:00
|
|
|
void size_by_content (Area *a);
|
2010-09-18 10:41:34 +00:00
|
|
|
void size_by_layout (Area *a, int pos, int level);
|
2008-10-02 18:47:02 +00:00
|
|
|
// draw background and foreground
|
2009-01-05 21:01:05 +00:00
|
|
|
void refresh (Area *a);
|
2010-08-10 13:18:17 +00:00
|
|
|
|
2010-09-21 09:54:19 +00:00
|
|
|
// generic resize for SIZE_BY_LAYOUT objects
|
|
|
|
int resize_by_layout(void *obj);
|
|
|
|
|
2009-01-05 21:01:05 +00:00
|
|
|
// set 'redraw' on an area and childs
|
|
|
|
void set_redraw (Area *a);
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2010-09-22 19:33:10 +00:00
|
|
|
// hide/unhide area
|
|
|
|
void hide(Area *a);
|
|
|
|
void show(Area *a);
|
|
|
|
|
2010-01-09 00:11:01 +00:00
|
|
|
// draw pixmap
|
|
|
|
void draw (Area *a);
|
|
|
|
void draw_background (Area *a, cairo_t *c);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
|
|
|
void remove_area (Area *a);
|
|
|
|
void add_area (Area *a);
|
2008-11-08 20:23:42 +00:00
|
|
|
void free_area (Area *a);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-01-18 22:12:41 +00:00
|
|
|
// draw rounded rectangle
|
|
|
|
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);
|
2009-12-30 23:27:31 +00:00
|
|
|
|
|
|
|
// clear pixmap with transparent color
|
|
|
|
void clear_pixmap(Pixmap p, int x, int y, int w, int h);
|
2008-10-02 18:47:02 +00:00
|
|
|
#endif
|
|
|
|
|