Back to index

unity  6.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
nux::StaticCairoText Class Reference

#include <StaticCairoText.h>

Collaboration diagram for nux::StaticCairoText:
Collaboration graph
[legend]

List of all members.

Classes

struct  Impl

Public Types

enum  EllipsizeState { NUX_ELLIPSIZE_END, NUX_ELLIPSIZE_START, NUX_ELLIPSIZE_MIDDLE, NUX_ELLIPSIZE_NONE }
enum  AlignState {
  NUX_ALIGN_LEFT, NUX_ALIGN_CENTRE, NUX_ALIGN_RIGHT, NUX_ALIGN_TOP = NUX_ALIGN_LEFT,
  NUX_ALIGN_BOTTOM = NUX_ALIGN_RIGHT
}

Public Member Functions

 StaticCairoText (std::string const &text, NUX_FILE_LINE_PROTO)
 ~StaticCairoText ()
void PreLayoutManagement ()
long PostLayoutManagement (long layoutResult)
void Draw (GraphicsEngine &gfxContext, bool forceDraw)
void DrawContent (GraphicsEngine &gfxContext, bool forceDraw)
void PostDraw (GraphicsEngine &gfxContext, bool forceDraw)
void SetText (std::string const &text)
void SetTextColor (Color const &textColor)
void SetTextEllipsize (EllipsizeState state)
void SetTextAlignment (AlignState state)
void SetTextVerticalAlignment (AlignState state)
void SetFont (std::string const &font)
void SetLines (int maximum_lines)
std::string GetText () const
Color GetTextColor () const
int GetLineCount () const
int GetBaseline () const
void GetTextExtents (int &width, int &height) const
Size GetTextExtents () const
void SetAcceptKeyNavFocus (bool accept)

Public Attributes

sigc::signal< void,
StaticCairoText * > 
sigTextChanged
sigc::signal< void,
StaticCairoText * > 
sigTextColorChanged
sigc::signal< void,
StaticCairoText * > 
sigFontChanged

Protected Member Functions

virtual bool AcceptKeyNavFocus ()

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (StaticCairoText, View)

Private Attributes

Implpimpl

Detailed Description

Definition at line 33 of file StaticCairoText.h.


Member Enumeration Documentation

Enumerator:
NUX_ALIGN_LEFT 
NUX_ALIGN_CENTRE 
NUX_ALIGN_RIGHT 
NUX_ALIGN_TOP 
NUX_ALIGN_BOTTOM 

Definition at line 45 of file StaticCairoText.h.

Enumerator:
NUX_ELLIPSIZE_END 
NUX_ELLIPSIZE_START 
NUX_ELLIPSIZE_MIDDLE 
NUX_ELLIPSIZE_NONE 

Definition at line 37 of file StaticCairoText.h.


Constructor & Destructor Documentation

nux::StaticCairoText::StaticCairoText ( std::string const &  text,
NUX_FILE_LINE_PROTO   
)

Definition at line 154 of file StaticCairoText.cpp.

  : View(NUX_FILE_LINE_PARAM)
  , pimpl(new Impl(this, text))
{
  SetMinimumSize(1, 1);
  SetAcceptKeyNavFocusOnMouseDown(false);
}

Definition at line 163 of file StaticCairoText.cpp.

{
  delete pimpl;
}

Member Function Documentation

bool nux::StaticCairoText::AcceptKeyNavFocus ( ) [protected, virtual]

Definition at line 542 of file StaticCairoText.cpp.

void nux::StaticCairoText::Draw ( GraphicsEngine &  gfxContext,
bool  forceDraw 
)

Definition at line 235 of file StaticCairoText.cpp.

{
  Geometry const& base = GetGeometry();

  if (pimpl->texture2D_.IsNull() ||
      pimpl->cached_base_.width != base.width ||
      pimpl->cached_base_.height != base.height)
  {
    pimpl->cached_base_.width = base.width;
    pimpl->cached_base_.height = base.height;
    pimpl->UpdateTexture();
  }

  gfxContext.PushClippingRectangle(base);

  gPainter.PaintBackground(gfxContext, base);

  TexCoordXForm texxform;
  texxform.SetWrap(TEXWRAP_REPEAT, TEXWRAP_REPEAT);
  texxform.SetTexCoordType(TexCoordXForm::OFFSET_COORD);

  unsigned int alpha = 0, src = 0, dest = 0;

  gfxContext.GetRenderStates().GetBlend(alpha, src, dest);
  gfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

  Color col = color::Black;
  col.alpha = 0;
  gfxContext.QRP_Color(base.x,
                       base.y,
                       base.width,
                       base.height,
                       col);

  gfxContext.QRP_1Tex(base.x,
                      base.y + ((base.height - pimpl->cached_extent_.height) / 2),
                      base.width,
                      base.height,
                      pimpl->texture2D_->GetDeviceTexture(),
                      texxform,
                      pimpl->text_color_);

  gfxContext.GetRenderStates().SetBlend(alpha, src, dest);

  gfxContext.PopClippingRectangle();
}

Here is the call graph for this function:

void nux::StaticCairoText::DrawContent ( GraphicsEngine &  gfxContext,
bool  forceDraw 
)

Definition at line 282 of file StaticCairoText.cpp.

{
  // intentionally left empty
}

Definition at line 340 of file StaticCairoText.cpp.

{
  return pimpl->baseline_;
}

Here is the caller graph for this function:

Definition at line 335 of file StaticCairoText.cpp.

{
  return pimpl->actual_lines_;
}
std::string nux::StaticCairoText::GetText ( ) const

Definition at line 303 of file StaticCairoText.cpp.

{
  return pimpl->text_;
}

Here is the caller graph for this function:

Definition at line 308 of file StaticCairoText.cpp.

{
  return pimpl->text_color_;
}
void nux::StaticCairoText::GetTextExtents ( int &  width,
int &  height 
) const

Definition at line 350 of file StaticCairoText.cpp.

{
  Size s = pimpl->GetTextExtents();
  width = s.width;
  height = s.height;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 345 of file StaticCairoText.cpp.

{
  return pimpl->GetTextExtents();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::StaticCairoText::PostDraw ( GraphicsEngine &  gfxContext,
bool  forceDraw 
)

Definition at line 287 of file StaticCairoText.cpp.

{
  // intentionally left empty
}
long nux::StaticCairoText::PostLayoutManagement ( long  layoutResult)

Definition at line 210 of file StaticCairoText.cpp.

{
  long result = 0;

  Geometry const& geo = GetGeometry();

  int old_width = pimpl->pre_layout_size_.width;
  if (old_width < geo.width)
    result |= eLargerWidth;
  else if (old_width > geo.width)
    result |= eSmallerWidth;
  else
    result |= eCompliantWidth;

  int old_height = pimpl->pre_layout_size_.height;
  if (old_height < geo.height)
    result |= eLargerHeight;
  else if (old_height > geo.height)
    result |= eSmallerHeight;
  else
    result |= eCompliantHeight;

  return result;
}

Definition at line 193 of file StaticCairoText.cpp.

{
  Geometry geo = GetGeometry();
  pimpl->pre_layout_size_.width = geo.width;
  pimpl->pre_layout_size_.height = geo.height;

  SetBaseSize(pimpl->cached_extent_.width,
              pimpl->cached_extent_.height);

  if (pimpl->texture2D_.IsNull())
  {
    pimpl->UpdateTexture();
  }

  View::PreLayoutManagement();
}

Here is the call graph for this function:

Definition at line 537 of file StaticCairoText.cpp.

void nux::StaticCairoText::SetFont ( std::string const &  font)

Definition at line 325 of file StaticCairoText.cpp.

{
  pimpl->font_ = font;
  pimpl->need_new_extent_cache_ = true;
  Size s = GetTextExtents();
  SetMinimumHeight(s.height);
  NeedRedraw();
  sigFontChanged.emit(this);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::StaticCairoText::SetLines ( int  maximum_lines)

Definition at line 186 of file StaticCairoText.cpp.

{
  pimpl->lines_ = lines;
  pimpl->UpdateTexture();
  QueueDraw();
}

Here is the call graph for this function:

void nux::StaticCairoText::SetText ( std::string const &  text)

Definition at line 292 of file StaticCairoText.cpp.

{
  if (pimpl->text_ != text)
  {
    pimpl->text_ = text;
    pimpl->need_new_extent_cache_ = true;
    pimpl->UpdateTexture();
    sigTextChanged.emit(this);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 174 of file StaticCairoText.cpp.

{
  pimpl->align_ = state;
  NeedRedraw();
}

Here is the caller graph for this function:

void nux::StaticCairoText::SetTextColor ( Color const &  textColor)

Definition at line 313 of file StaticCairoText.cpp.

{
  if (pimpl->text_color_ != textColor)
  {
    pimpl->text_color_ = textColor;
    pimpl->UpdateTexture();
    QueueDraw();

    sigTextColorChanged.emit(this);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file StaticCairoText.cpp.

{
  pimpl->ellipsize_ = state;
  NeedRedraw();
}

Here is the caller graph for this function:

Definition at line 180 of file StaticCairoText.cpp.

{
  pimpl->valign_ = state;
  QueueDraw();
}

Member Data Documentation

Definition at line 99 of file StaticCairoText.h.

Definition at line 90 of file StaticCairoText.h.

Definition at line 88 of file StaticCairoText.h.

Definition at line 89 of file StaticCairoText.h.


The documentation for this class was generated from the following files: