2 /* $Id: layout.ccg,v 1.3 2006/05/30 17:14:21 murrayc Exp $ */
6 * Copyright 1998-2002 The gtkmm Development Team
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.
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.
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.
23 #include <pango/pangocairo.h>
28 Layout::Layout(const Glib::RefPtr<Context>& context)
30 Glib::Object(G_OBJECT(pango_layout_new(context->gobj())))
33 Glib::RefPtr<Layout> Layout::create(const Cairo::RefPtr<Cairo::Context>& context)
35 return Glib::wrap( pango_cairo_create_layout(context->cobj()) );
38 void Layout::update_from_cairo_context(const Cairo::RefPtr<Cairo::Context>& context)
40 pango_cairo_update_layout(context->cobj(), gobj());
43 void Layout::set_text(const Glib::ustring& text)
45 pango_layout_set_text(gobj(), text.c_str(), text.bytes());
48 void Layout::set_markup(const Glib::ustring& markup)
50 return pango_layout_set_markup(gobj(), markup.c_str(), markup.bytes());
53 void Layout::set_markup(const Glib::ustring& markup, gunichar accel_marker, gunichar& accel_char)
55 return pango_layout_set_markup_with_accel(gobj(), markup.c_str(), markup.bytes(), accel_marker, &accel_char);
58 Glib::ArrayHandle<PangoLogAttr> Layout::get_log_attrs() const
61 PangoLogAttr* pAttrs = 0;
63 pango_layout_get_log_attrs(const_cast<PangoLayout*>(gobj()), &pAttrs, &n_attrs);
65 return Glib::ArrayHandle<PangoLogAttr>(pAttrs, n_attrs, Glib::OWNERSHIP_SHALLOW);
68 Rectangle Layout::index_to_pos(int index) const
71 pango_layout_index_to_pos(const_cast<PangoLayout*>(gobj()), index, pos.gobj());
75 Rectangle Layout::get_cursor_strong_pos(int index) const
78 pango_layout_get_cursor_pos(const_cast<PangoLayout*>(gobj()), index, strong_pos.gobj(), 0);
82 Rectangle Layout::get_cursor_weak_pos(int index) const
85 pango_layout_get_cursor_pos(const_cast<PangoLayout*>(gobj()), index, 0, weak_pos.gobj());
89 Rectangle Layout::get_ink_extents() const
91 Rectangle ink_extents;
92 pango_layout_get_extents(const_cast<PangoLayout*>(gobj()), ink_extents.gobj(), 0);
96 Rectangle Layout::get_logical_extents() const
98 Rectangle logical_extents;
99 pango_layout_get_extents(const_cast<PangoLayout*>(gobj()), 0, logical_extents.gobj());
100 return logical_extents;
103 Rectangle Layout::get_pixel_ink_extents() const
105 Rectangle ink_extents;
106 pango_layout_get_pixel_extents(const_cast<PangoLayout*>(gobj()), ink_extents.gobj(), 0);
110 Rectangle Layout::get_pixel_logical_extents() const
112 Rectangle logical_extents;
113 pango_layout_get_pixel_extents(const_cast<PangoLayout*>(gobj()), 0, logical_extents.gobj());
114 return logical_extents;
117 void Layout::get_iter(LayoutIter& iter)
119 iter.assign_gobj(pango_layout_get_iter(gobj()));
122 void Layout::unset_font_description()
124 pango_layout_set_font_description(gobj(), 0);
127 void Layout::add_to_cairo_context(const Cairo::RefPtr<Cairo::Context>& context)
129 pango_cairo_layout_path(context->cobj(), gobj());
132 } /* namespace Pango */