Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

pge::gui::Component Class Reference

#include <Component.h>

Inheritance diagram for pge::gui::Component:

Inheritance graph
[legend]
Collaboration diagram for pge::gui::Component:

Collaboration graph
[legend]

Public Member Functions

 Component (int x, int y, int width, int height)
 Constructor.

virtual ~Component (void)
 Destructor.

void render (void)
 Called when the object should render itself.

void setBackgroundColor (const Vector4f &color)
Vector4f getBackgroundColor (void)
void setPosition (Vector2i position)
Vector2i getPosition (void)
void setDimension (const Vector2i &dimension)
Vector2i getDimension (void)
void setTextureEnabled (bool texEnabled)
bool isTextureEnabled (void)
void setTexture (Texture *texture)

Static Public Member Functions

Vector2i convertToGLCoords (const Vector2i &coords)
Vector2i convertToGLCoords (int x, int y)

Private Attributes

Vector2i m_position
Vector2i m_dimension
Vector4f m_backgroundColor
Texturem_texture
bool m_textureEnabled

Constructor & Destructor Documentation

pge::gui::Component::Component int  x,
int  y,
int  width,
int  height
 

Constructor.

Definition at line 19 of file Component.cpp.

References m_backgroundColor, m_dimension, m_position, m_texture, and m_textureEnabled.

00019                                                                         {
00020                         m_position = Vector2i(x, y);
00021                         m_dimension = Vector2i(width, height);
00022                         m_backgroundColor = Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
00023                         m_texture = NULL;
00024                         m_textureEnabled = false;
00025 
00026                 }

pge::gui::Component::~Component void   )  [virtual]
 

Destructor.

Definition at line 34 of file Component.cpp.

00034                                           {
00035                 }


Member Function Documentation

Vector2i pge::gui::Component::convertToGLCoords int  x,
int  y
[static]
 

Definition at line 193 of file Component.cpp.

00193                                                                   {
00194                         return Vector2i(x, CoreEngine::getInstance()->getResolutionHeight() - y);
00195                 }

Vector2i pge::gui::Component::convertToGLCoords const Vector2i coords  )  [static]
 

Definition at line 183 of file Component.cpp.

References pge::Vector2i::m_v.

00183                                                                             {
00184                         return Vector2i(coords.m_v[0], CoreEngine::getInstance()->getResolutionHeight() - coords.m_v[1]);
00185                 }

Vector4f pge::gui::Component::getBackgroundColor void   ) 
 

Definition at line 103 of file Component.cpp.

References m_backgroundColor.

00103                                                            {
00104                         return m_backgroundColor;
00105                 }

Vector2i pge::gui::Component::getDimension void   ) 
 

Definition at line 143 of file Component.cpp.

References m_dimension.

Referenced by pge::gui::TextBox::render().

00143                                                      {
00144                         return m_dimension;
00145                 }

Vector2i pge::gui::Component::getPosition void   ) 
 

Definition at line 123 of file Component.cpp.

References m_position.

Referenced by pge::gui::TextEdit::render(), and pge::gui::TextBox::render().

00123                                                     {
00124                         return m_position;
00125                 }

bool pge::gui::Component::isTextureEnabled void   ) 
 

Definition at line 163 of file Component.cpp.

References m_textureEnabled.

00163                                                      {
00164                         return m_textureEnabled;
00165                 }

void pge::gui::Component::render void   )  [virtual]
 

Called when the object should render itself.

Implements pge::IRenderableObject.

Reimplemented in pge::gui::TextBox, and pge::gui::TextEdit.

Definition at line 43 of file Component.cpp.

References m_backgroundColor, m_dimension, m_position, m_texture, m_textureEnabled, pge::Vector2i::m_v, and pge::Vector4f::m_v.

00043                                            {
00044                         // Render the background of the component
00045 
00046                         // Handle texturing
00047                         if(m_textureEnabled) {
00048                                 renderer::setTexture(m_texture);
00049                         } else {
00050                                 renderer::setTextureUnitEnabled(GL_TEXTURE0, false);
00051                         }
00052 
00053                         // If alpha is not 1.0f, then enable blending
00054                         if(m_backgroundColor.m_v[3] != 1.0f) {
00055                                 renderer::setBlendingEnabled(true);
00056                                 renderer::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00057                         }
00058 
00059                         // Render background as colored quad.
00060                         renderer::color4f(m_backgroundColor);
00061 
00062                         if(m_textureEnabled) {
00063                                 glBegin(GL_QUADS);
00064                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1]), 0.0f, 0.0f);
00065                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1] + m_dimension.m_v[1]),
00066                                         0.0f, 1.0f);
00067                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1]
00068                                 + m_dimension.m_v[1]), 1.0f, 1.0f);
00069                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1]),
00070                                         1.0f, 0.0f);
00071                                 glEnd();
00072                         } else {
00073                                 glBegin(GL_QUADS);
00074                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1]));
00075                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0], m_position.m_v[1] + m_dimension.m_v[1]));
00076                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1]
00077                                 + m_dimension.m_v[1]));
00078                                 renderer::vertex2i(Component::convertToGLCoords(m_position.m_v[0] + m_dimension.m_v[0], m_position.m_v[1]));
00079                                 glEnd();
00080                         }
00081                         if(m_backgroundColor.m_v[3] != 1.0f) {
00082                                 renderer::setBlendingEnabled(false);
00083                                 renderer::color4f(1.0f, 1.0f, 1.0f, 1.0f);
00084                         }
00085                 }

void pge::gui::Component::setBackgroundColor const Vector4f color  ) 
 

Definition at line 93 of file Component.cpp.

References m_backgroundColor.

Referenced by pge::gui::Console::Console(), and pge::gui::SceneAnalyseGUI::SceneAnalyseGUI().

00093                                                                         {
00094                         m_backgroundColor = color;
00095                 }

void pge::gui::Component::setDimension const Vector2i dimension  ) 
 

Definition at line 133 of file Component.cpp.

References m_dimension.

00133                                                                       {
00134                         m_dimension = dimension;
00135                 }

void pge::gui::Component::setPosition Vector2i  position  ) 
 

Definition at line 113 of file Component.cpp.

References m_position.

00113                                                              {
00114                         m_position = position;
00115                 }

void pge::gui::Component::setTexture Texture texture  ) 
 

Definition at line 173 of file Component.cpp.

References m_texture.

00173                                                            {
00174                         m_texture = texture;
00175                 }

void pge::gui::Component::setTextureEnabled bool  texEnabled  ) 
 

Definition at line 153 of file Component.cpp.

References m_textureEnabled.

00153                                                                  {
00154                         m_textureEnabled = texEnabled;
00155                 }


Field Documentation

Vector4f pge::gui::Component::m_backgroundColor [private]
 

Definition at line 71 of file Component.h.

Referenced by Component(), getBackgroundColor(), render(), and setBackgroundColor().

Vector2i pge::gui::Component::m_dimension [private]
 

Definition at line 70 of file Component.h.

Referenced by Component(), getDimension(), render(), and setDimension().

Vector2i pge::gui::Component::m_position [private]
 

Definition at line 69 of file Component.h.

Referenced by Component(), getPosition(), render(), and setPosition().

Texture* pge::gui::Component::m_texture [private]
 

Definition at line 72 of file Component.h.

Referenced by Component(), render(), and setTexture().

bool pge::gui::Component::m_textureEnabled [private]
 

Definition at line 73 of file Component.h.

Referenced by Component(), isTextureEnabled(), render(), and setTextureEnabled().


The documentation for this class was generated from the following files:
Generated on Mon Oct 16 12:09:56 2006 for Phobosengine by doxygen 1.3.4