Debian Codegraph @

lib/glcomp/glcomplabel.c

raw
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 "config.h"
12
13 #include <glcomp/glcomplabel.h>
14 #include <glcomp/glcompfont.h>
15 #include <glcomp/glcompset.h>
16 #include <glcomp/glutils.h>
17 #include <util/alloc.h>
18
19 static void glCompLabelDraw(void *label) {
20 glCompLabel *p = label;
21 glCompCommon ref = p->base.common;
22 glCompCalcWidget(p->base.common.parent, &p->base.common, &ref);
23 glCompRenderText(p->base.common.font, &p->base);
24 }
25
26 glCompLabel *glCompLabelNew(void *par, char *text) {
27 glCompLabel *p = gv_alloc(sizeof(glCompLabel));
28 glCompInitCommon(&p->base, par, 0, 0);
29
30 p->text = gv_strdup(text);
31 glDeleteFont(&p->base.common.font);
32 p->base.common.font = glNewFontFromParent(&p->base, text);
33 p->base.common.functions.draw = glCompLabelDraw;
34
35 return p;
36 }