rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / pango / src / layout.ccg
1 // -*- c++ -*-
2 /* $Id: layout.ccg,v 1.3 2006/05/30 17:14:21 murrayc Exp $ */
3
4 /* 
5  *
6  * Copyright 1998-2002 The gtkmm Development Team
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <pango/pangocairo.h>
24
25 namespace Pango
26 {
27
28 Layout::Layout(const Glib::RefPtr<Context>& context)
29 :
30   Glib::Object(G_OBJECT(pango_layout_new(context->gobj())))
31 {}
32
33 Glib::RefPtr<Layout> Layout::create(const Cairo::RefPtr<Cairo::Context>& context)
34 {
35   return Glib::wrap( pango_cairo_create_layout(context->cobj()) );
36 }
37
38 void Layout::update_from_cairo_context(const Cairo::RefPtr<Cairo::Context>& context)
39 {
40   pango_cairo_update_layout(context->cobj(), gobj());
41 }
42
43 void Layout::set_text(const Glib::ustring& text)
44 {
45   pango_layout_set_text(gobj(), text.c_str(), text.bytes());
46 }
47
48 void Layout::set_markup(const Glib::ustring& markup)
49 {
50   return pango_layout_set_markup(gobj(), markup.c_str(), markup.bytes());
51 }
52
53 void Layout::set_markup(const Glib::ustring& markup, gunichar accel_marker, gunichar& accel_char)
54 {
55   return pango_layout_set_markup_with_accel(gobj(), markup.c_str(), markup.bytes(), accel_marker, &accel_char);
56 }
57
58 Glib::ArrayHandle<PangoLogAttr> Layout::get_log_attrs() const
59 {
60   //Get array:
61   PangoLogAttr* pAttrs = 0;
62   int n_attrs = 0;
63   pango_layout_get_log_attrs(const_cast<PangoLayout*>(gobj()), &pAttrs, &n_attrs);
64
65   return Glib::ArrayHandle<PangoLogAttr>(pAttrs, n_attrs, Glib::OWNERSHIP_SHALLOW);
66 }
67
68 Rectangle Layout::index_to_pos(int index) const
69 {
70   Rectangle pos;
71   pango_layout_index_to_pos(const_cast<PangoLayout*>(gobj()), index, pos.gobj());
72   return pos;
73 }
74
75 Rectangle Layout::get_cursor_strong_pos(int index) const
76 {
77   Rectangle strong_pos;
78   pango_layout_get_cursor_pos(const_cast<PangoLayout*>(gobj()), index, strong_pos.gobj(), 0);
79   return strong_pos;
80 }
81
82 Rectangle Layout::get_cursor_weak_pos(int index) const
83 {
84   Rectangle weak_pos;
85   pango_layout_get_cursor_pos(const_cast<PangoLayout*>(gobj()), index, 0, weak_pos.gobj());
86   return weak_pos;
87 }
88
89 Rectangle Layout::get_ink_extents() const
90 {
91   Rectangle ink_extents;
92   pango_layout_get_extents(const_cast<PangoLayout*>(gobj()), ink_extents.gobj(), 0);
93   return ink_extents;
94 }
95
96 Rectangle Layout::get_logical_extents() const
97 {
98   Rectangle logical_extents;
99   pango_layout_get_extents(const_cast<PangoLayout*>(gobj()), 0, logical_extents.gobj());
100   return logical_extents;
101 }
102
103 Rectangle Layout::get_pixel_ink_extents() const
104 {
105   Rectangle ink_extents;
106   pango_layout_get_pixel_extents(const_cast<PangoLayout*>(gobj()), ink_extents.gobj(), 0);
107   return ink_extents;
108 }
109
110 Rectangle Layout::get_pixel_logical_extents() const
111 {
112   Rectangle logical_extents;
113   pango_layout_get_pixel_extents(const_cast<PangoLayout*>(gobj()), 0, logical_extents.gobj());
114   return logical_extents;
115 }
116
117 void Layout::get_iter(LayoutIter& iter)
118 {
119   iter.assign_gobj(pango_layout_get_iter(gobj()));
120 }
121
122 void Layout::unset_font_description()
123 {
124   pango_layout_set_font_description(gobj(), 0);
125 }
126
127 void Layout::add_to_cairo_context(const Cairo::RefPtr<Cairo::Context>& context)
128 {
129   pango_cairo_layout_path(context->cobj(), gobj());
130 }
131
132 } /* namespace Pango */