File: glcomppanel.c

package info (click to toggle)
graphviz 14.1.1-1
  • links: PTS
  • area: main
  • in suites: forky
  • size: 139,440 kB
  • sloc: ansic: 142,129; cpp: 11,960; python: 7,770; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (66 lines) | stat: -rw-r--r-- 2,232 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
63
64
65
66
/*************************************************************************
 * Copyright (c) 2011 AT&T Intellectual Property 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: Details at https://graphviz.org
 *************************************************************************/

#include <glcomp/glcomppanel.h>
#include <glcomp/glcompfont.h>
#include <glcomp/glcompset.h>
#include <glcomp/glcomptexture.h>
#include <glcomp/glutils.h>
#include <stdbool.h>
#include <util/alloc.h>

static void glCompPanelDraw(void *o) {
  glCompPanel *p = o;
  glCompRect r;
  glCompCommon ref = p->base.common;
  glCompCalcWidget(p->base.common.parent, &p->base.common, &ref);

  if (!p->base.common.visible)
    return;
  /*draw shadow */
  const float SHADOW_COLOR_R = 0.0f;
  const float SHADOW_COLOR_G = 0.0f;
  const float SHADOW_COLOR_B = 0.0f;
  const float SHADOW_COLOR_A = 0.3f;
  glColor4f(SHADOW_COLOR_R, SHADOW_COLOR_G, SHADOW_COLOR_B, SHADOW_COLOR_A);
  r.h = p->shadowwidth;
  r.w = ref.width;
  r.pos.x = ref.pos.x + p->shadowwidth;
  r.pos.y = ref.pos.y - p->shadowwidth;
  r.pos.z = -0.001f;
  glCompDrawRectangle(&r);
  r.h = ref.height;
  r.w = p->shadowwidth;
  r.pos.x = ref.pos.x + ref.width;
  r.pos.y = ref.pos.y - p->shadowwidth;
  r.pos.z = -0.001f;
  glCompDrawRectangle(&r);
  /*draw panel */
  glCompDrawRectPrism(ref.pos, ref.width, ref.height,
                      p->base.common.borderWidth, ref.color, true);
}

glCompPanel *glCompPanelNew(void *parentObj, float x, float y, float w,
                            float h) {
    glCompPanel *p = gv_alloc(sizeof(glCompPanel));
    glCompInitCommon(&p->base, parentObj, x, y);

    p->shadowwidth = GLCOMPSET_PANEL_SHADOW_WIDTH;
    p->base.common.borderWidth = GLCOMPSET_PANEL_BORDERWIDTH;

    p->base.common.width = w;
    p->base.common.height = h;

    glDeleteFont(&p->base.common.font);
    p->base.common.font = glNewFontFromParent(&p->base, NULL);
    p->text = NULL;
    p->base.common.functions.draw = glCompPanelDraw;
    return p;
}