/* Copyright (C) 2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include _DEFS(pangomm,pango) namespace Pango { class Font; class GlyphString; /** A Pango::Analysis stores information about the properties of a segment of text. * Pango::Analysis is used as an output type only so there is no public default constructor. * You can retrieve an object of this type from an object of type Pango::Item by * calling Pango::Item::get_analysis(). Objects of this class can be used for some * calculations in Pango::GlyphString. */ class Analysis { _CLASS_GENERIC(Analysis, PangoAnalysis) protected: // This class is only used as an output type. Analysis(); public: explicit Analysis(const PangoAnalysis* src); public: // _MEMBER_GET_PTR(engine_shape, shape_engine, EngineShape*, PangoEngineShape*) //We don't wrap the Engine* stuff. // _MEMBER_GET_PTR(engine_lang, lang_engine, EngineLang*, PangoEngineLang*) /** Gets the font used to render this segment. * @return The font used to render this segment. */ _MEMBER_GET_GOBJECT(font, font, Font, PangoFont*) /** Gets the bidrectional level for this segment. * @return The bidirectional level for this segment. */ _MEMBER_GET(level, level, guint8, guint8) /** Gets the language of this segment. * @return The language of this segment. */ _MEMBER_GET(language, language, Language, PangoLanguage*) /** Gets a list of non-font attributes for this segment. * @return A list of non-font attributes for this segment. */ SListHandle_Attribute get_extra_attrs() const; PangoAnalysis* gobj() { return &gobject_; } const PangoAnalysis* gobj() const { return &gobject_; } protected: PangoAnalysis gobject_; }; /** A Pango::Item stores information about a segment of text. * Pango::Item is used as an output type only so there is no public default constructor. * You retrieve objects of this type by calling Pango::Context::itemize() with some text. * The actual rendering of the segment of text that corresponds to a particular Pango::Item * (or some sub-string) into a string of glyphs is done with shape(). * The segment of text that corresponds to a Pango::Item can be computed from the * text passed into Pango::Context::itemize() with get_segment(). Together with * the Pango::Analysis data member that can be accessed with get_analysis() * it is needed for further calculations in Pango::GlyphString. */ class Item { _CLASS_GENERIC(Item, PangoItem) //There is the whole set of functions for _CLASS_BOXEDTYPE but unfortunately PangoItem is not registered as a boxed type and lacks pango_item_get_type... _IGNORE(pango_item_copy,pango_item_free) public: // There is no default constructor. This class is only used as an output type. explicit Item(PangoItem* castitem, bool make_a_copy = true); Item(const Item& src); Item& operator=(const Item& src); ~Item(); // The caller is responsible for freeing it. Use when directly setting fields in structs. PangoItem* gobj_copy() const; public: _WRAP_METHOD(Item split(int split_index, int split_offset), pango_item_split) /** Gets the offset of the segment from the beginning of the string in bytes. * @return The offset of the segment from the beginning of the string in bytes. */ _MEMBER_GET(offset, offset, int, gint) /** Gets the length of the segment in bytes. * @return The length of the segment in bytes. */ _MEMBER_GET(length, length, int, gint) /** Gets the length of the segment in characters. * @return The length of the semgment in characters. */ _MEMBER_GET(num_chars, num_chars, int, gint) /** Gets the properties of the segment. * @return The properties of the segment. */ Analysis get_analysis() const; /** Computes the segment of text that is represented by the item. * @param text The text that has been passed into Pango::Context::itemize(). * @return The sub-string of @a text that corresponds to the item. */ Glib::ustring get_segment(const Glib::ustring& text) const; /** Convert a segment of text into a string of glyphs. * @param text The text to process. This must either be the whole segment of text that corresponds to the item as returned by get_segment() or a sub-string of that segment. You need to pass the same text to the member functions of Pango::GlyphString for further calculations. * @return A Pango::GlyphString object that can be measured or drawn. */ GlyphString shape(const Glib::ustring& text) const; PangoItem* gobj() { return gobject_; } const PangoItem* gobj() const { return gobject_; } protected: PangoItem* gobject_; }; struct ItemTraits { typedef Pango::Item CppType; typedef const PangoItem* CType; typedef PangoItem* CTypeNonConst; static CType to_c_type (const CppType& obj) { return obj.gobj(); } static CType to_c_type (CType ptr) { return ptr; } static CppType to_cpp_type (CType ptr) { return CppType(const_cast(ptr), true); } static void release_c_type (CType ptr) { pango_item_free(const_cast(ptr)); } }; typedef Glib::ListHandle ListHandle_Item; } // namespace Pango namespace Glib { /** @relates Pango::Analysis */ Pango::Analysis& wrap(PangoAnalysis* object); /** @relates Pango::Analysis */ const Pango::Analysis& wrap(const PangoAnalysis* object); /** @relates Pango::Item */ Pango::Item wrap(PangoItem* object, bool take_copy=true); } // namespace Glib