Blame pango/src/item.ccg

Packit 78284e
/* Copyright (C) 2002 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
#include <pangomm/font.h>
Packit 78284e
#include <pangomm/attributes.h>
Packit 78284e
#include <pangomm/glyphstring.h>
Packit 78284e
Packit 78284e
namespace Pango
Packit 78284e
{
Packit 78284e
Packit 78284e
Analysis::Analysis()
Packit 78284e
{}
Packit 78284e
Packit 78284e
Analysis::Analysis(const PangoAnalysis* src)
Packit 78284e
:
Packit 78284e
  gobject_ (*src)
Packit 78284e
{}
Packit 78284e
Packit 78284e
SListHandle_Attribute Analysis::get_extra_attrs() const
Packit 78284e
{
Packit 78284e
  return SListHandle_Attribute(gobj()->extra_attrs, Glib::OWNERSHIP_NONE);
Packit 78284e
}
Packit 78284e
Packit 78284e
Packit 78284e
Item::Item(const Item& src)
Packit 78284e
:
Packit 78284e
  gobject_ ((src.gobject_) ? pango_item_copy(src.gobject_) : 0)
Packit 78284e
{}
Packit 78284e
Packit 78284e
Item::Item(PangoItem* castitem, bool make_a_copy)
Packit 78284e
{
Packit 78284e
  // For BoxedType wrappers, make_a_copy is true by default.  The static
Packit 78284e
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
Packit 78284e
  // ensures identical behaviour if the default argument is used.
Packit 78284e
Packit 78284e
  if(make_a_copy)
Packit 78284e
  {
Packit 78284e
    if(castitem)
Packit 78284e
      gobject_ = pango_item_copy(castitem);
Packit 78284e
    else
Packit 78284e
      gobject_ = 0;
Packit 78284e
  }
Packit 78284e
  else
Packit 78284e
  {
Packit 78284e
    // It was given to us by a function which has already made a copy for us to keep.
Packit 78284e
    gobject_ = castitem;
Packit 78284e
  }
Packit 78284e
}
Packit 78284e
Packit 78284e
Item& Item::operator=(const Item& src)
Packit 78284e
{
Packit 78284e
  PangoItem *const new_gobject = (src.gobject_) ? pango_item_copy(src.gobject_) : 0;
Packit 78284e
Packit 78284e
  if(gobject_)
Packit 78284e
    pango_item_free(gobject_);
Packit 78284e
  gobject_ = new_gobject;
Packit 78284e
Packit 78284e
  return *this;
Packit 78284e
}
Packit 78284e
Packit 78284e
Item::~Item()
Packit 78284e
{
Packit 78284e
  if(gobject_)
Packit 78284e
    pango_item_free(gobject_);
Packit 78284e
}
Packit 78284e
Packit 78284e
PangoItem* Item::gobj_copy() const
Packit 78284e
{
Packit 78284e
  return pango_item_copy(gobject_);
Packit 78284e
}
Packit 78284e
Packit 78284e
Analysis Item::get_analysis() const
Packit 78284e
{
Packit 78284e
  return Analysis(&gobj()->analysis);
Packit 78284e
}
Packit 78284e
Packit 78284e
Glib::ustring Item::get_segment(const Glib::ustring& text) const
Packit 78284e
{
Packit 78284e
  const char *const start = text.data() + gobj()->offset;
Packit 78284e
  return Glib::ustring(start, start + gobj()->length);
Packit 78284e
}
Packit 78284e
Packit 78284e
Pango::GlyphString Item::shape(const Glib::ustring& text) const
Packit 78284e
{
Packit 78284e
  return GlyphString(text, get_analysis());
Packit 78284e
}
Packit 78284e
Packit 78284e
} /* namespace Pango */
Packit 78284e
Packit 78284e
Packit 78284e
namespace Glib
Packit 78284e
{
Packit 78284e
Packit 78284e
Pango::Analysis& wrap(PangoAnalysis* object)
Packit 78284e
{
Packit 78284e
  return *reinterpret_cast<Pango::Analysis*>(object);
Packit 78284e
}
Packit 78284e
Packit 78284e
const Pango::Analysis& wrap(const PangoAnalysis* object)
Packit 78284e
{
Packit 78284e
  return *reinterpret_cast<const Pango::Analysis*>(object);
Packit 78284e
}
Packit 78284e
Packit 78284e
Pango::Item wrap(PangoItem* object, bool take_copy)
Packit 78284e
{
Packit 78284e
  return Pango::Item(object, take_copy);
Packit 78284e
}
Packit 78284e
Packit 78284e
} /* namespace Glib */
Packit 78284e