|
Packit |
78284e |
/* $Id: context.hg,v 1.7 2006/06/10 15:26:24 murrayc Exp $ */
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/* context.h
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* Copyright (C) 1998-1999 The gtkmm Development Team
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* This library is free software; you can redistribute it and/or
|
|
Packit |
78284e |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
78284e |
* License as published by the Free Software Foundation; either
|
|
Packit |
78284e |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
78284e |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
78284e |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
78284e |
* Lesser General Public License for more details.
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
78284e |
* License along with this library; if not, write to the Free
|
|
Packit |
78284e |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
|
|
Packit |
78284e |
|
|
Packit |
78284e |
#include <glibmm/object.h>
|
|
Packit |
78284e |
#include <glibmm/arrayhandle.h>
|
|
Packit |
78284e |
#include <glibmm/listhandle.h>
|
|
Packit |
78284e |
#include <pangomm/fontdescription.h>
|
|
Packit |
78284e |
#include <pangomm/fontmetrics.h>
|
|
Packit |
78284e |
#include <pangomm/fontset.h>
|
|
Packit |
78284e |
#include <pangomm/fontmap.h>
|
|
Packit |
78284e |
#include <pangomm/item.h>
|
|
Packit |
78284e |
#include <pangomm/attrlist.h>
|
|
Packit |
78284e |
#include <pangomm/types.h> //For Matrix
|
|
Packit |
78284e |
#include <pango/pango-context.h>
|
|
Packit |
78284e |
#include <cairomm/context.h>
|
|
Packit |
78284e |
#include <cairomm/fontoptions.h>
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_DEFS(pangomm,pango)
|
|
Packit |
78284e |
_PINCLUDE(glibmm/private/object_p.h)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
namespace Pango
|
|
Packit |
78284e |
{
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_CC_INCLUDE(pango/pango-enum-types.h)
|
|
Packit |
78284e |
_WRAP_ENUM(Direction, PangoDirection)
|
|
Packit |
78284e |
_WRAP_ENUM(GravityHint, PangoGravityHint)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/** A Pango::Context stores global information used to control the itemization process.
|
|
Packit |
78284e |
* You can retrieve a Pango::Context object with Gtk::Widget::create_pango_context() or
|
|
Packit |
78284e |
* Gtk::Widget::get_pango_context(). If you don't use gtkmm call some c function of the
|
|
Packit |
78284e |
* pango backend you intend to use and create a wrapper for the returned context,
|
|
Packit |
78284e |
* e.g. Glib::wrap(pango_x_get_context()).
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* Creating a Pango::Context object is the starting point of every rendering process.
|
|
Packit |
78284e |
* You can either use it to create a high level Pango::Layout object which does all
|
|
Packit |
78284e |
* the hard work for you by passing it into
|
|
Packit |
78284e |
* Pango::Layout::create() or to generate glyph strings from character strings with
|
|
Packit |
78284e |
* the help of itemize() and Pango::Item::shape() subsequently.
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* Which fonts are used for rendering can be influenced by setting the default
|
|
Packit |
78284e |
* font description, language and base direction of the context.
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* If you want to calculate the space some text will need to be displayed you
|
|
Packit |
78284e |
* might find the functions of Pango::FontMetrics useful. Use get_metrics() to
|
|
Packit |
78284e |
* obtain the Pango::FontMetrics object for a specific Pango::FontDescription.
|
|
Packit |
78284e |
* For more detailed calculations in a rendering-system-independant manner
|
|
Packit |
78284e |
* and to determine whether specific characters can be represented by the
|
|
Packit |
78284e |
* font that would be used for a specific Pango::FontDescription load a
|
|
Packit |
78284e |
* Pango::Fontset with load_fontset() (load_font() returns the Pango::Font
|
|
Packit |
78284e |
* that is the closest match for a Pango::FontDescription; however that's not
|
|
Packit |
78284e |
* necessarily the font that will be used for rendering).
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
class Context : public Glib::Object
|
|
Packit |
78284e |
{
|
|
Packit |
78284e |
_CLASS_GOBJECT(Context, PangoContext, PANGO_CONTEXT, Glib::Object, GObject)
|
|
Packit |
78284e |
_IGNORE(pango_context_set_font_map) //PANGO_ENABLE_BACKEND
|
|
Packit |
78284e |
_IGNORE(pango_context_list_families)
|
|
Packit |
78284e |
protected:
|
|
Packit |
78284e |
_CTOR_DEFAULT
|
|
Packit |
78284e |
_IGNORE(pango_context_new)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
public:
|
|
Packit |
78284e |
/** List all available font families for a context.
|
|
Packit |
78284e |
* You can specify one of these as your desired font family in the Pango::FontDesciption
|
|
Packit |
78284e |
* objects you use, e.g. in the default font description of the context.
|
|
Packit |
78284e |
* @return An array of Pango::FontFamily objects.
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
Glib::ArrayHandle< Glib::RefPtr<FontFamily> > list_families() const;
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_IGNORE(pango_context_changed)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(void set_font_map(const Glib::RefPtr<FontMap>& font_map), pango_context_set_font_map)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(Glib::RefPtr<FontMap> get_font_map(), pango_context_get_font_map)
|
|
Packit |
78284e |
_WRAP_METHOD(Glib::RefPtr<const FontMap> get_font_map() const, pango_context_get_font_map)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(guint get_serial() const, pango_context_get_serial)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(Glib::RefPtr<Font> load_font(const FontDescription& desc) const, pango_context_load_font)
|
|
Packit |
78284e |
_WRAP_METHOD(Glib::RefPtr<Fontset> load_fontset(const FontDescription& desc, const Language& language) const, pango_context_load_fontset)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/** Get overall metric information for a particular font description.
|
|
Packit |
78284e |
* The metrics may be substantially different for different scripts. However this
|
|
Packit |
78284e |
* function overload returns the metrics of the entire font.
|
|
Packit |
78284e |
* @param desc A Pango::FontDescription object.
|
|
Packit |
78284e |
* @return A Pango::FontMetrics object.
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
FontMetrics get_metrics(const FontDescription& desc) const;
|
|
Packit |
78284e |
_WRAP_METHOD(FontMetrics get_metrics(const FontDescription& desc, const Language& language) const, pango_context_get_metrics)
|
|
Packit |
78284e |
_WRAP_METHOD(void set_font_description(const FontDescription& desc), pango_context_set_font_description)
|
|
Packit |
78284e |
_WRAP_METHOD(FontDescription get_font_description() const, pango_context_get_font_description)
|
|
Packit |
78284e |
_WRAP_METHOD(Language get_language() const, pango_context_get_language)
|
|
Packit |
78284e |
_WRAP_METHOD(void set_language(const Language& language), pango_context_set_language)
|
|
Packit |
78284e |
_WRAP_METHOD(void set_base_dir(Direction direction), pango_context_set_base_dir)
|
|
Packit |
78284e |
_WRAP_METHOD(Direction get_base_dir() const, pango_context_get_base_dir)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(void set_base_gravity(Gravity gravity), pango_context_set_base_gravity)
|
|
Packit |
78284e |
_WRAP_METHOD(Gravity get_base_gravity() const, pango_context_get_base_gravity)
|
|
Packit |
78284e |
_WRAP_METHOD(Gravity get_gravity() const, pango_context_get_gravity)
|
|
Packit |
78284e |
_WRAP_METHOD(void set_gravity_hint(GravityHint hint), pango_context_set_gravity_hint)
|
|
Packit |
78284e |
_WRAP_METHOD(GravityHint get_gravity_hint() const, pango_context_get_gravity_hint)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(void set_matrix(const Matrix& matrix), pango_context_set_matrix)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
Matrix get_matrix() const;
|
|
Packit |
78284e |
_IGNORE(pango_context_get_matrix)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/** Breaks a piece of text into segments with consistent directional level and shaping engine.
|
|
Packit |
78284e |
* Each byte of @a text will be contained in exactly one of the items in the returned list.
|
|
Packit |
78284e |
* The generated list of items will be in logical order (the start offsets of the items
|
|
Packit |
78284e |
* are ascending).
|
|
Packit |
78284e |
* @param text The text to itemize.
|
|
Packit |
78284e |
* @param attrs The set of attributes that apply.
|
|
Packit |
78284e |
* @return A list of Pango::Item objects.
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
ListHandle_Item itemize(const Glib::ustring& text, const AttrList& attrs) const;
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/** Breaks a piece of text into segments with consistent directional level and shaping engine.
|
|
Packit |
78284e |
* Each byte of @a text will be contained in exactly one of the items in the returned list.
|
|
Packit |
78284e |
* The generated list of items will be in logical order (the start offsets of the items
|
|
Packit |
78284e |
* are ascending).
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* @a cached_iter should be an iterator over @a attrs currently positioned at a range before
|
|
Packit |
78284e |
* or containing @a start_index. @a cached_iter will be advanced to the range covering the
|
|
Packit |
78284e |
* position just after @a start_index + @a length. (i.e. if itemizing in a loop, just keep
|
|
Packit |
78284e |
* passing in the same @a cached_iter).
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* @param text The text to itemize.
|
|
Packit |
78284e |
* @param start_index First byte in @a text to process.
|
|
Packit |
78284e |
* @param length The number of bytes (not characters) to process after @a start_index. This must be >= <tt>0</tt>.
|
|
Packit |
78284e |
* @param attrs The set of attributes that apply to @a text.
|
|
Packit |
78284e |
* @param cached_iter Cached attribute iterator.
|
|
Packit |
78284e |
* @return A list of Pango::Item structures.
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
ListHandle_Item itemize(const Glib::ustring& text, int start_index, int length,
|
|
Packit |
78284e |
const AttrList& attrs, AttrIter& cached_iter) const;
|
|
Packit |
78284e |
|
|
Packit |
78284e |
/** Updates a Pango Context previously created for use with Cairo to
|
|
Packit |
78284e |
* match the current transformation and target surface of a Cairo
|
|
Packit |
78284e |
* Context. If any layouts have been created for the context,
|
|
Packit |
78284e |
* it's necessary to call Pango::Layout::context_changed() on those
|
|
Packit |
78284e |
* layouts.
|
|
Packit |
78284e |
*
|
|
Packit |
78284e |
* @param context A Cairo context, from CairoFontMap::create_context().
|
|
Packit |
78284e |
*/
|
|
Packit |
78284e |
void update_from_cairo_context(const Cairo::RefPtr<Cairo::Context>& context);
|
|
Packit |
78284e |
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(void set_cairo_font_options(const Cairo::FontOptions& options), pango_cairo_context_set_font_options)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
#m4 _CONVERSION(`const cairo_font_options_t*',`Cairo::FontOptions',`Cairo::FontOptions(const_cast< cairo_font_options_t*>($3), false /* take_copy */)')
|
|
Packit |
78284e |
_WRAP_METHOD(Cairo::FontOptions get_font_options() const, pango_cairo_context_get_font_options)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
_WRAP_METHOD(void set_resolution(double dpi), pango_cairo_context_set_resolution)
|
|
Packit |
78284e |
_WRAP_METHOD(double get_resolution() const, pango_cairo_context_get_resolution)
|
|
Packit |
78284e |
|
|
Packit |
78284e |
};
|
|
Packit |
78284e |
|
|
Packit |
78284e |
} /* namespace Pango */
|
|
Packit |
78284e |
|