glcomplabel.c 1.2 KB

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