Back to index

nux  3.0.0
Public Member Functions | Private Member Functions | Private Attributes
nux::UXTheme Class Reference

#include <Theme.h>

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

List of all members.

Public Member Functions

 UXTheme ()
 ~UXTheme ()
const PainterImageGetImage (UXStyleImageRef style)
Rect GetImageGeometry (UXStyleImageRef style)

Private Member Functions

void LoadPainterImages ()
BaseTextureLoad2DTextureFile (const char *filename)
BaseTextureLoad2DTextureFileGenerateAlpha (const char *filename, int red, int green, int blue)

Private Attributes

std::list< PainterImage * > m_PainterImageList

Detailed Description

Load textures and other data for user interface rendering.

Definition at line 136 of file Theme.h.


Constructor & Destructor Documentation

Definition at line 197 of file Theme.cpp.

Here is the call graph for this function:

Definition at line 202 of file Theme.cpp.

  {
    std::list<PainterImage*>::iterator it;
    for (it = m_PainterImageList.begin(); it != m_PainterImageList.end(); it++)
    {
      (*it)->texture->UnReference();
      delete(*it);
    }
    m_PainterImageList.clear();
  }

Member Function Documentation

Definition at line 288 of file Theme.cpp.

  {
    std::list<PainterImage *>::iterator it;

    for (it = m_PainterImageList.begin(); it != m_PainterImageList.end(); it++)
    {
      if ((*it)->style == style)
      {
        return (*it);
      }
    }

    return 0;
  }

Here is the caller graph for this function:

Definition at line 303 of file Theme.cpp.

  {
    std::list<PainterImage *>::iterator it;

    for (it = m_PainterImageList.begin(); it != m_PainterImageList.end(); it++)
    {
      if ((*it)->style == style)
      {
        unsigned int width = (*it)->texture->GetWidth();
        unsigned int height = (*it)->texture->GetHeight();
        return Rect(0, 0, width, height);
      }
    }

    nuxDebugMsg("[GraphicsEngine::GetImageGeometry] Cannot find UXStyleImageRef");
    return Rect(0, 0, 0, 0);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

BaseTexture * nux::UXTheme::Load2DTextureFile ( const char *  filename) [private]

Definition at line 321 of file Theme.cpp.

  {
    BaseTexture* texture2D = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
    NBitmapData *BitmapData = LoadImageFile(filename);

    if (BitmapData)
    {
      texture2D->Update(BitmapData);
      delete BitmapData;
    }
    return texture2D;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

BaseTexture * nux::UXTheme::Load2DTextureFileGenerateAlpha ( const char *  filename,
int  red,
int  green,
int  blue 
) [private]

Definition at line 334 of file Theme.cpp.

  {
    return 0;
  }
void nux::UXTheme::LoadPainterImages ( ) [private]

Definition at line 213 of file Theme.cpp.

  {
    NString file_search = "Painter.xml";
    NString painter_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(file_search.GetTCharPtr());

    if (painter_filename == "")
    {
      nuxCriticalMsg("[GraphicsEngine::LoadPainterImages] Can't find Painter.xml file.");
      return;
    }

    TiXmlDocument doc(painter_filename.GetTCharPtr());
    doc.LoadFile();

    TiXmlHandle docHandle( &doc );
    TiXmlElement *data = docHandle.FirstChild(TCHARToUTF8("PaintData")).Element();
    TiXmlElement *image = 0;

    for (image = data->FirstChildElement(TCHARToUTF8("Image")); image; image = image->NextSiblingElement(TCHARToUTF8("Image")))
    {
      PainterImage *pimage = new PainterImage;
      Memset(pimage, 0, sizeof(PainterImage));

      NString style = image->Attribute(TCHARToUTF8("style"));

      pimage->style = GetStyleImageRef(style.GetTCharPtr());

      // If the attributes border_left, border_right, border_top, border_bottom are not present, assume they are equal to 0;
      pimage->border_left = pimage->border_right = pimage->border_top = pimage->border_bottom = 0;

      image->Attribute(TCHARToUTF8("border_left"), &pimage->border_left);
      image->Attribute(TCHARToUTF8("border_right"), &pimage->border_right);
      image->Attribute(TCHARToUTF8("border_top"),  &pimage->border_top);
      image->Attribute(TCHARToUTF8("border_bottom"), &pimage->border_bottom);


      const char *draw_borders_only = image->Attribute(TCHARToUTF8("border_only"));

      if (draw_borders_only == 0)
      {
        pimage->draw_borders_only = true;
      }
      else
      {
        if (strcmp(TCHARToUTF8("false"), draw_borders_only) == 0)
        {
          pimage->draw_borders_only = false;
        }
        else
        {
          pimage->draw_borders_only = true;
        }
      }

      if (1)
      {
        BaseTexture* device_texture;

        NString filename = image->Attribute(TCHARToUTF8("Name"));
        NString texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.GetTCharPtr());
        device_texture = Load2DTextureFile(texture_filename.GetTCharPtr());

        pimage->texture = device_texture;
      }
      else
      {
        NString filename = image->Attribute(TCHARToUTF8("Name"));
        NString texture_filename = NUX_FIND_RESOURCE_LOCATION_NOFAIL(filename.GetTCharPtr());
        pimage->texture = Load2DTextureFile(texture_filename.GetTCharPtr());
      }

      m_PainterImageList.push_back(pimage);
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 152 of file Theme.h.


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