Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
glcomppanel.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <glcomp/glcomppanel.h>
12#include <glcomp/glcompfont.h>
13#include <glcomp/glcompset.h>
15#include <glcomp/glutils.h>
16#include <stdbool.h>
17#include <util/alloc.h>
18
19static void glCompPanelDraw(void *o) {
20 glCompPanel *p = o;
21 glCompRect r;
24
25 if (!p->base.common.visible)
26 return;
27 /*draw shadow */
28 const float SHADOW_COLOR_R = 0.0f;
29 const float SHADOW_COLOR_G = 0.0f;
30 const float SHADOW_COLOR_B = 0.0f;
31 const float SHADOW_COLOR_A = 0.3f;
32 glColor4f(SHADOW_COLOR_R, SHADOW_COLOR_G, SHADOW_COLOR_B, SHADOW_COLOR_A);
33 r.h = p->shadowwidth;
34 r.w = ref.width;
35 r.pos.x = ref.pos.x + p->shadowwidth;
36 r.pos.y = ref.pos.y - p->shadowwidth;
37 r.pos.z = -0.001f;
39 r.h = ref.height;
40 r.w = p->shadowwidth;
41 r.pos.x = ref.pos.x + ref.width;
42 r.pos.y = ref.pos.y - p->shadowwidth;
43 r.pos.z = -0.001f;
45 /*draw panel */
46 glCompDrawRectPrism(&ref.pos, ref.width, ref.height,
47 p->base.common.borderWidth, 0.01f, &ref.color, true);
48 /*draw image if there is */
49 if (p->image) {
51 }
52}
53
54glCompPanel *glCompPanelNew(void *parentObj, float x, float y, float w,
55 float h) {
56 glCompPanel *p = gv_alloc(sizeof(glCompPanel));
57 glCompInitCommon(&p->base, parentObj, x, y);
58
61
62 p->base.common.width = w;
63 p->base.common.height = h;
64
67 p->text = NULL;
69 p->image = NULL;
70 return p;
71}
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
Definition alloc.h:47
#define GLCOMPSET_PANEL_SHADOW_WIDTH
Definition glcompdefs.h:37
#define GLCOMPSET_PANEL_BORDERWIDTH
Definition glcompdefs.h:54
glCompFont glNewFontFromParent(glCompObj *o, char *text)
Definition glcompfont.c:70
void glDeleteFont(glCompFont *f)
Definition glcompfont.c:38
static void glCompPanelDraw(void *o)
Definition glcomppanel.c:19
glCompPanel * glCompPanelNew(void *parentObj, float x, float y, float w, float h)
Definition glcomppanel.c:54
void glCompInitCommon(glCompObj *childObj, glCompObj *parentObj, float x, float y)
Definition glcompset.c:114
void glCompDrawRectangle(glCompRect *r)
Definition glutils.c:296
void glCompCalcWidget(glCompCommon *parent, glCompCommon *child, glCompCommon *ref)
Definition glutils.c:195
void glCompDrawRectPrism(glCompPoint *p, float w, float h, float b, float d, glCompColor *c, bool bumped)
Definition glutils.c:306
node NULL
Definition grammar.y:163
void ref(Site *v)
Definition site.c:59
glcompdrawfunc_t draw
Definition glcompdefs.h:160
glCompCallBacks callbacks
Definition glcompdefs.h:193
glCompCallBacks functions
Definition glcompdefs.h:194
void * parent
Definition glcompdefs.h:187
glCompFont font
font to use
Definition glcompdefs.h:189
float borderWidth
Definition glcompdefs.h:182
glCompObj base
Definition glcompdefs.h:205
glCompCommon common
Definition glcompdefs.h:200
float shadowwidth
Definition glcompdefs.h:213
glCompObj base
Definition glcompdefs.h:212
glCompImage * image
Definition glcompdefs.h:215
char * text
Definition glcompdefs.h:214
glCompPoint pos
Definition glcompdefs.h:128