File: utils_pango.c

package info (click to toggle)
ggobi 2.1.9~20091212-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 19,340 kB
  • ctags: 5,083
  • sloc: ansic: 57,242; xml: 30,604; cpp: 833; makefile: 355; java: 225; perl: 201; sh: 122; python: 23
file content (49 lines) | stat: -rw-r--r-- 1,378 bytes parent folder | download | duplicates (4)
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
/*-- utils_gdk.c --*/
/*
 * ggobi
 * Copyright (C) AT&T, Duncan Temple Lang, Dianne Cook 1999-2005
 *
 * ggobi is free software; you may use, redistribute, and/or modify it
 * under the terms of the Common Public License, which is distributed
 * with the source code and displayed on the ggobi web site, 
 * www.ggobi.org.  For more information, contact the authors:
 *
 *   Deborah F. Swayne   dfs@research.att.com
 *   Di Cook             dicook@iastate.edu
 *   Duncan Temple Lang  duncan@wald.ucdavis.edu
 *   Andreas Buja        andreas.buja@wharton.upenn.edu
*/

#include <gtk/gtk.h>
#include "vars.h"
#include "externs.h"
#include <string.h>

/** Lays out the text using the given layout. If 'rect' is non-NULL it contains
	the logical text extents. */
void
layout_text (PangoLayout * layout, const gchar * text, PangoRectangle * rect)
{
  if (text) {
    pango_layout_set_text (layout, text, -1);
    if (rect)
      pango_layout_get_pixel_extents (layout, NULL, rect);
  }
}
void
underline_text (PangoLayout * layout)
{
  PangoAttrList *list;
  PangoAttribute *attr;

  attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
  attr->start_index = 0;
  attr->end_index = strlen (pango_layout_get_text (layout));

  list = pango_attr_list_new ();
  pango_attr_list_insert (list, attr);

  pango_layout_set_attributes (layout, list);

  pango_attr_list_unref (list);
}