PictureWidget Class Reference

#include <picture_widget.h>

Inheritance diagram for PictureWidget:

Inheritance graph
[legend]
Collaboration diagram for PictureWidget:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PictureWidget (const Rectanglei &rect)
 PictureWidget (const Rectanglei &rect, const std::string resource_id)
 ~PictureWidget ()
void SetSurface (const Surface &s, bool enable_scaling=false)
void SetNoSurface ()
void Draw (const Point2i &mousePosition, Surface &surf) const
void SetSizePosition (const Rectanglei &rect)
void Disable ()

Private Attributes

bool disabled
Spritespr

Detailed Description

Definition at line 29 of file picture_widget.h.


Constructor & Destructor Documentation

PictureWidget::PictureWidget ( const Rectanglei rect  ) 

Definition at line 27 of file picture_widget.cpp.

00027                                                     : Widget(rect)
00028 {
00029   spr = NULL;
00030   disabled = false;
00031 }

PictureWidget::PictureWidget ( const Rectanglei rect,
const std::string  resource_id 
)

Definition at line 33 of file picture_widget.cpp.

00033                                                                            : Widget(rect)
00034 {
00035   spr = NULL;
00036   disabled = false;
00037 
00038   Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false);
00039   Surface tmp = resource_manager.LoadImage(res, resource_id);
00040   SetSurface(tmp, false);  
00041   resource_manager.UnLoadXMLProfile( res);
00042 }

Here is the call graph for this function:

PictureWidget::~PictureWidget (  ) 

Definition at line 44 of file picture_widget.cpp.

00045 {
00046   if (spr != NULL)
00047     delete spr;
00048 }


Member Function Documentation

void PictureWidget::Disable (  ) 

Definition at line 98 of file picture_widget.cpp.

00099 {
00100   disabled = true;
00101 }

Here is the caller graph for this function:

void PictureWidget::Draw ( const Point2i mousePosition,
Surface surf 
) const [virtual]

Implements Widget.

Definition at line 76 of file picture_widget.cpp.

00078 {
00079   if (spr != NULL) {
00080     int x = GetPositionX() + ( GetSizeX()/2 ) - (spr->GetWidth()/2);
00081     int y = GetPositionY() + ( GetSizeY()/2 ) - (spr->GetHeight()/2);
00082 
00083     spr->Blit ( surf, x, y);
00084 
00085     // Draw a transparency mask
00086     if (disabled) {
00087       surf.BoxColor(Rectanglei(x,y,spr->GetWidth(),spr->GetHeight()),
00088                     defaultOptionColorBox);
00089     }
00090   }
00091 }

Here is the call graph for this function:

void PictureWidget::SetNoSurface (  ) 

Definition at line 66 of file picture_widget.cpp.

00067 {
00068   need_redrawing = true;
00069 
00070   if (spr != NULL)
00071     delete spr;
00072 
00073   spr = NULL;
00074 }

Here is the caller graph for this function:

void PictureWidget::SetSizePosition ( const Rectanglei rect  )  [virtual]

Implements Widget.

Definition at line 93 of file picture_widget.cpp.

00094 {
00095   StdSetSizePosition(rect);
00096 }

Here is the call graph for this function:

void PictureWidget::SetSurface ( const Surface s,
bool  enable_scaling = false 
)

Definition at line 50 of file picture_widget.cpp.

00051 {
00052   need_redrawing = true;
00053 
00054   if (spr != NULL)
00055     delete spr;
00056 
00057   spr = new Sprite(s);
00058   if (enable_scaling) {
00059     float scale = std::min( float(GetSizeY())/spr->GetHeight(),
00060                             float(GetSizeX())/spr->GetWidth() ) ;
00061   
00062     spr->Scale (scale, scale);
00063   }
00064 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool PictureWidget::disabled [private]

Definition at line 32 of file picture_widget.h.

Sprite* PictureWidget::spr [private]

Definition at line 33 of file picture_widget.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:10:35 2007 for Wormux by  doxygen 1.4.7