Basic encapsulation of SDL_Surface structure.This is the base class to display something (in rectangular shape) on the screen. More...
#include <Surface.hh>

Classes | |
| struct | ImgSort |
| struct | ZSort |
Public Member Functions | |
| Surface (SDL_Surface *surf, double zoom=1., double angle=0., const std::string &filename="") | |
| Surface (const std::string filename, double zoom=1., double angle=0.) | |
| Surface (int width, int height) | |
| Surface (const Surface &s) | |
| Surface & | operator= (const Surface &s) |
| Point | getPos () const |
| Get the relative position of the surface. | |
| Point | getSize () const |
| Get the size of the surface (width-height). | |
| const Rect & | getRect () const |
| Get the relative surface position. | |
| virtual Rect | getScreenRect () const |
| Get the absolute surface from the point (0, 0) on the screen. | |
| double | getZoom () const |
| double | getAngle () const |
| int | getZ () const |
| SDL_Surface * | getSDLSurface () |
| virtual void | setPos (const Point &pos) |
| void | setPos (int x, int y) |
| void | setSize (const Point &size) |
| virtual void | setZoom (double zoom) |
| virtual void | setAngle (double angle) |
| virtual void | setZ (int z) |
| void | setInheritAlpha (bool enabled) |
| virtual void | enable () |
| Enable this widget. | |
| virtual void | disable () |
| Disable this widget. | |
| bool | isEnabled () const |
| Whether it is enabled or not. | |
| virtual void | show () |
| Show this surface on the screen. | |
| virtual void | hide () |
| Don't display this surface on the screen. | |
| bool | isShown () const |
| void | create (int width, int height, SDL_Surface *ref_surface=NULL) |
| Create an empty SDL Surface of the given size. | |
| void | load (const std::string filename, double zoom=1., double angle=0.) |
| Load a image into this surface (.png, .jpg, .bmp, ...). | |
| void | free () |
| Release associated resources, and detach from parent. | |
| virtual void | update () |
| Method called each frame, to perfom user custom code. | |
| virtual void | blit (Surface &to) |
| virtual void | blit (Surface &to, const Rect &to_rect, const Rect &from_rect) |
Protected Member Functions | |
| virtual void | render () |
| Private method. | |
| virtual Rect | getRenderRect () const |
| Get the relative zone to render on the screen. | |
| void | blitAlpha (SDL_Surface *src_surf, SDL_Surface *dst_surf, SDL_Rect *src_rect, unsigned dst_x, unsigned dst_y) |
| Copy the alpha data to dst_surf. | |
Protected Attributes | |
| SDL_Surface * | surf_ |
| bool | redraw_all_ |
| VirtualSurface * | parent_ |
Friends | |
| class | VirtualSurface |
| class | ResourceCenter |
| std::ostream & | operator<< (std::ostream &os, const Surface &s) |
Basic encapsulation of SDL_Surface structure.
This is the base class to display something (in rectangular shape) on the screen.
A simple example (assuming you already have a SDLWindow):
Surface surf("img/lala.png"); surf.setPos(40, 30); win.getScreen.addChild(&surf);
| void Surface::blitAlpha | ( | SDL_Surface * | src_surf, | |
| SDL_Surface * | dst_surf, | |||
| SDL_Rect * | src_rect, | |||
| unsigned | dst_x, | |||
| unsigned | dst_y | |||
| ) | [protected] |
Copy the alpha data to dst_surf.
| void Surface::create | ( | int | width, | |
| int | height, | |||
| SDL_Surface * | ref_surface = NULL | |||
| ) |
Create an empty SDL Surface of the given size.
Used to do manual rendering with SDL functions and, at the same time, have it in the surface hierarchy.
References VirtualSurface::invalidate().
| void Surface::disable | ( | ) | [virtual] |
Disable this widget.
Reimplemented in sdlvisu::DialogBox, and sdlvisu::VisuPlayer.
References VirtualSurface::invalidate().
Referenced by sdlvisu::Map::clearBlock(), sdlvisu::Map::clearThrow(), sdlvisu::VisuPlayer::disable(), and sdlvisu::ActionPopup::update().
| void Surface::enable | ( | ) | [virtual] |
Enable this widget.
Reimplemented in VirtualSurface, sdlvisu::DialogBox, and sdlvisu::VisuPlayer.
Referenced by sdlvisu::Map::drawBlock(), sdlvisu::Map::drawPath(), sdlvisu::Map::drawThrow(), sdlvisu::VisuPlayer::enable(), and sdlvisu::ActionPopup::update().
| const Rect & Surface::getRect | ( | ) | const |
Get the relative surface position.
Referenced by TextSurface::addText(), SDLWindow::clearScreen(), Sprite::move(), VirtualSurface::removeChild(), Sprite::stopMove(), Sprite::update(), and sdlvisu::ActionPopup::update().
| Rect Surface::getRenderRect | ( | ) | const [protected, virtual] |
Get the relative zone to render on the screen.
getRect() can be larger than we really want to show, or off-screen. By default, return getRect(), but can be overriden.
Reimplemented in VirtualScrollableSurface.
| Rect Surface::getScreenRect | ( | ) | const [virtual] |
Get the absolute surface from the point (0, 0) on the screen.
This is where the surface is render and visible by the user on the screen. This should only be used for events, ie. to compare mouse position (which has absolute position) with this surface position.
Reimplemented in VirtualScrollableSurface.
References getScreenRect().
Referenced by VirtualScrollableSurface::getScreenRect(), getScreenRect(), sdlvisu::VisuPlayer::update(), sdlvisu::InfoBar::update(), sdlvisu::GameButton::update(), sdlvisu::ActionPopup::update(), and sdlvisu::CmdButton::updateStatus().
| void Surface::hide | ( | ) | [virtual] |
Don't display this surface on the screen.
Reimplemented in sdlvisu::ActionPopup.
Referenced by sdlvisu::VisuPlayer::beginTurn(), sdlvisu::CmdButton::CmdButton(), sdlvisu::CmdButton::disable(), sdlvisu::VisuPlayer::finishTurn(), sdlvisu::VisuPlayer::updateStatus(), and sdlvisu::CmdButton::updateStatus().
| virtual void Surface::render | ( | ) | [inline, protected, virtual] |
Private method.
Called after update round, to effectively render images. Don't override it, should only be used by VirtualSurface.
Reimplemented in VirtualSurface.
Referenced by VirtualSurface::render().
| void Surface::show | ( | ) | [virtual] |
Show this surface on the screen.
Reimplemented in VirtualSurface, and sdlvisu::ActionPopup.
Referenced by sdlvisu::InfoBar::addBlockDice(), sdlvisu::VisuPlayer::beginTurn(), sdlvisu::CmdButton::enable(), sdlvisu::VisuPlayer::onEventAction(), sdlvisu::Map::update(), sdlvisu::VisuPlayer::updateStatus(), and sdlvisu::CmdButton::updateStatus().
| void Surface::update | ( | ) | [virtual] |
Method called each frame, to perfom user custom code.
You should override it.
Since a parent is assigned to the surface (and this parent is itself attached by other means to the root screen), this method is called at each frame. It is not called if this surface or one of its parent is disabled. In this method you can do what you want with your object, like processing input, updating other programs attributes, changing surface property, ...
Reimplemented in InputTextSurface, Sprite, TextSurface, VirtualScrollableSurface, VirtualSurface, sdlvisu::ActionPopup, sdlvisu::DialogBox, sdlvisu::GameButton, sdlvisu::InfoBar, sdlvisu::Map, sdlvisu::Panel, and sdlvisu::VisuPlayer.
References VirtualSurface::invalidate().
1.6.3