2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __CAIRO_DOCK_DRAW__
22
#define __CAIRO_DOCK_DRAW__
26
#include "cairo-dock-struct.h"
31
*@file cairo-dock-draw.h This class provides some useful functions to draw with libcairo.
37
/** Create a generic drawing context, to be used as a source context (for instance, for creating a surface).
38
*@param pContainer a container.
39
*@return the context on which to draw. Is never NULL, test it with cairo_status() before use it, and destroy it with cairo_destroy() when you're done with it.
41
cairo_t * cairo_dock_create_drawing_context_generic (CairoContainer *pContainer);
42
#define cairo_dock_create_context_from_window cairo_dock_create_drawing_context_generic
43
#define cairo_dock_create_context_from_container cairo_dock_create_drawing_context_generic
45
/** Create a drawing context to draw on a container. It handles fake transparency.
46
*@param pContainer the container on which you want to draw.
47
*@return the newly allocated context, to be destroyed with 'cairo_destroy'.
49
cairo_t *cairo_dock_create_drawing_context_on_container (CairoContainer *pContainer);
50
#define cairo_dock_create_drawing_context cairo_dock_create_drawing_context_on_container
52
/** Create a drawing context to draw on a part of a container. It handles fake transparency.
53
*@param pContainer the container on which you want to draw
54
*@param pArea part of the container to draw.
55
*@param fBgColor background color (rgba) to fill the area with, or NULL to let it transparent.
56
*@return the newly allocated context, with a clip corresponding to the area, to be destroyed with 'cairo_destroy'.
58
cairo_t *cairo_dock_create_drawing_context_on_area (CairoContainer *pContainer, GdkRectangle *pArea, double *fBgColor);
62
double cairo_dock_calculate_extra_width_for_trapeze (double fFrameHeight, double fInclination, double fRadius, double fLineWidth);
64
/** Compute the path of a rectangle with rounded corners. It doesn't stroke it, use cairo_stroke or cairo_fill to draw the line or the inside.
65
*@param pCairoContext a drawing context; the current matrix is not altered, but the current path is.
66
*@param fRadius radius if the corners.
67
*@param fLineWidth width of the line.
68
*@param fFrameWidth width of the rectangle, without the corners.
69
*@param fFrameHeight height of the rectangle, including the corners.
71
void cairo_dock_draw_rounded_rectangle (cairo_t *pCairoContext, double fRadius, double fLineWidth, double fFrameWidth, double fFrameHeight);
73
/* Trace sur the context un contour trapezoidale aux coins arrondis. Le contour n'est pas dessine, mais peut l'etre a posteriori, et peut servir de cadre pour y dessiner des choses dedans.
74
*@param pCairoContext the context du dessin, contenant le cadre a la fin de la fonction.
75
*@param fRadius le rayon en pixels des coins.
76
*@param fLineWidth l'epaisseur en pixels du contour.
77
*@param fFrameWidth la largeur de la plus petite base du trapeze.
78
*@param fFrameHeight la hauteur du trapeze.
79
*@param fDockOffsetX un decalage, dans le sens de la largeur du dock, a partir duquel commencer a tracer la plus petite base du trapeze.
80
*@param fDockOffsetY un decalage, dans le sens de la hauteur du dock, a partir duquel commencer a tracer la plus petite base du trapeze.
81
*@param sens 1 pour un tracer dans le sens des aiguilles d'une montre (indirect), -1 sinon.
82
*@param fInclination tangente de l'angle d'inclinaison des cotes du trapeze par rapport a la vertical. 0 pour tracer un rectangle.
83
*@param bHorizontal CAIRO_DOCK_HORIZONTAL ou CAIRO_DOCK_VERTICAL suivant l'horizontalité du dock.
85
double cairo_dock_draw_frame (cairo_t *pCairoContext, double fRadius, double fLineWidth, double fFrameWidth, double fFrameHeight, double fDockOffsetX, double fDockOffsetY, int sens, double fInclination, gboolean bHorizontal);
87
/* Dessine les decorations d'un dock a l'interieur d'un cadre prealablement trace sur the context.
88
*@param pCairoContext the context du dessin, est laisse intact par la fonction.
89
*@param pDock le dock sur lequel appliquer les decorations.
90
*@param fOffsetY position du coin haut gauche du cadre, dans le sens de la hauteur du dock.
91
*@param fOffsetX position du coin haut gauche du cadre, dans le sens de la largeur du dock.
92
*@param fWidth largeur du cadre (et donc des decorations)
94
void cairo_dock_render_decorations_in_frame (cairo_t *pCairoContext, CairoDock *pDock, double fOffsetY, double fOffsetX, double fWidth);
97
void cairo_dock_set_icon_scale_on_context (cairo_t *pCairoContext, Icon *icon, gboolean bIsHorizontal, double fRatio, gboolean bDirectionUp);
99
/** Draw an icon and its reflect on a dock. Only draw the icon's image and reflect, and nothing else.
100
*@param icon the icon to draw.
101
*@param pDock the dock containing the icon.
102
*@param pCairoContext a context on the dock, not altered by the function.
104
void cairo_dock_draw_icon_cairo (Icon *icon, CairoDock *pDock, cairo_t *pCairoContext);
106
gboolean cairo_dock_render_icon_notification (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bHasBeenRendered, cairo_t *pCairoContext);
108
/** Draw an icon, according to its current parameters : position, transparency, reflect, rotation, stretching. Also draws its indicators, label, and quick-info. It generates a CAIRO_DOCK_RENDER_ICON notification.
109
*@param icon the icon to draw.
110
*@param pDock the dock containing the icon.
111
*@param pCairoContext a context on the dock, it is altered by the function.
112
*@param fDockMagnitude current magnitude of the dock.
113
*@param bUseText TRUE to draw the labels.
115
void cairo_dock_render_one_icon (Icon *icon, CairoDock *pDock, cairo_t *pCairoContext, double fDockMagnitude, gboolean bUseText);
116
void cairo_dock_render_icons_linear (cairo_t *pCairoContext, CairoDock *pDock);
118
void cairo_dock_render_one_icon_in_desklet (Icon *icon, cairo_t *pCairoContext, gboolean bUseReflect, gboolean bUseText, int iWidth);
121
/** Draw a string linking the center of all the icons of a dock.
122
*@param pCairoContext a context on the dock, not altered by the function.
123
*@param pDock the dock.
124
*@param fStringLineWidth width of the line.
125
*@param bIsLoop TRUE to loop (link the last icon to the first one).
126
*@param bForceConstantSeparator TRUE to consider separators having a constant size.
128
void cairo_dock_draw_string (cairo_t *pCairoContext, CairoDock *pDock, double fStringLineWidth, gboolean bIsLoop, gboolean bForceConstantSeparator);
131
void cairo_dock_draw_surface (cairo_t *pCairoContext, cairo_surface_t *pSurface, int iWidth, int iHeight, gboolean bDirectionUp, gboolean bHorizontal, gdouble fAlpha);
133
/** Erase a drawing context, making it fully transparent. You don't need to erase a newly created context.
134
*@param pCairoContext a drawing context.
136
#define cairo_dock_erase_cairo_context(pCairoContext) do {\
137
cairo_set_source_rgba (pCairoContext, 0.0, 0.0, 0.0, 0.0);\
138
cairo_set_operator (pCairoContext, CAIRO_OPERATOR_SOURCE);\
139
cairo_paint (pCairoContext);\
140
cairo_set_operator (pCairoContext, CAIRO_OPERATOR_OVER); } while (0)
143
void cairo_dock_render_hidden_dock (cairo_t *pCairoContext, CairoDock *pDock);
146
/*#define _cairo_dock_extend_area(area, x, y, w, h) do {\
147
int xmin = MIN (area.x, x);
148
int ymin = MIN (area.y, y);
149
area.width = MAX (area.x + area.width, x + w) - xmin;\
150
area.height = MAX (area.y + area.height, y + h) - ymin;\
151
area.x = MIN (area.x, x);\
152
area.y = MIN (area.y, y); } while (0)
153
#define _cairo_dock_compute_areas_bounded_box(area, area_) _cairo_dock_extend_area (area, area_.x, area_.y, area_.width, area_.height)
155
#define cairo_dock_damage_container_area(pContainer, area) _cairo_dock_compute_areas_bounded_box (pContainer->damageArea, area)
157
#define cairo_dock_damage_icon(pIcon, pContainer) do {\
159
cairo_dock_compute_icon_area (icon, pContainer, &area);\
160
cairo_dock_damage_container_area(pContainer, area); } while (0)
162
#define cairo_dock_damage_container(pContainer) do {\
163
pContainer->damageArea.x = 0;\
164
pContainer->damageArea.y = 0;\
165
if (pContainer->bHorizontal) {\
166
pContainer->damageArea.width = pContainer->iWidth;\
167
pContainer->damageArea.height = pContainer->iHeight; }\
169
pContainer->damageArea.width = pContainer->iHeight;\
170
pContainer->damageArea.height = pContainer->iWidth; }\