helper.hpp

Go to the documentation of this file.
00001 /* $Id: helper.hpp 26584 2008-05-13 15:54:45Z mordante $ */
00002 /*
00003    copyright (C) 2008 by mark de wever <koraq@xs4all.nl>
00004    part of the battle for wesnoth project http://www.wesnoth.org/
00005 
00006    this program is free software; you can redistribute it and/or modify
00007    it under the terms of the gnu general public license version 2
00008    or at your option any later version.
00009    this program is distributed in the hope that it will be useful,
00010    but without any warranty.
00011 
00012    see the copying file for more details.
00013 */
00014 
00015 #ifndef __GUI_WIDGETS_HELPER_HPP_INCLUDED__
00016 #define __GUI_WIDGETS_HELPER_HPP_INCLUDED__
00017 
00018 #include "SDL.h"
00019 
00020 #include <string>
00021 
00022 class surface;
00023 
00024 namespace gui2 {
00025 
00026 // init needs a cfg object later to init the subsystem
00027 bool init();
00028 
00029 struct tpoint
00030 {
00031     tpoint(const int x_, const int y_) : 
00032         x(x_),
00033         y(y_) 
00034         {}
00035 
00036     int x;
00037     int y;
00038 
00039     bool operator==(const tpoint& point) const { return x == point.x && y == point.y; }
00040     bool operator!=(const tpoint& point) const { return x != point.x || y != point.y; }
00041     bool operator<(const tpoint& point) const 
00042         { return x < point.x || (x == point.x && y < point.y); }
00043 
00044     bool operator<=(const tpoint& point) const 
00045         { return x < point.x || (x == point.x && y <= point.y); }
00046         
00047     tpoint operator+(const tpoint& point) const 
00048         { return tpoint(x + point.x, y + point.y); }
00049 
00050     tpoint& operator+=(const tpoint& point);
00051 
00052 };
00053 
00054 
00055 std::ostream &operator<<(std::ostream &stream, const tpoint& point);
00056 
00057 SDL_Rect create_rect(const tpoint& origin, const tpoint& size);
00058 
00059 struct terror 
00060 {
00061     terror(const std::string& msg) : message(msg) {}
00062 
00063     const std::string message;
00064 };
00065 
00066 Uint32 decode_colour(const std::string& colour);
00067 
00068 int decode_font_style(const std::string& style);
00069 
00070 
00071 /**
00072  * Copies a portion of a surface.
00073  *
00074  * Unlike get_surface_portion it copies rather then using SDL_Blit. Using 
00075  * SDL_Blit gives problems with transparent surfaces.
00076  *
00077  * @param background              The surface to safe a portion from, this
00078  *                                surface shouldn't be a RLE surface.
00079  * @param rect                    The part of the surface to copy, the part of
00080  *                                the rect should be entirely on the surface.
00081  *
00082  * @returns                       A copy of the wanted part of the background.
00083  */
00084 surface save_background(const surface& background, const SDL_Rect& rect);
00085 
00086 
00087 /**
00088  * Copies one surface unto another one.
00089  *
00090  * @param restore                The surface to copy to the background.
00091  * @param background             The surface to copy unto.
00092  * @param rect                   The area to copy to on the background.
00093  */
00094 void restore_background(const surface& restorer, 
00095         surface& background,const SDL_Rect& rect);
00096 
00097 } // namespace gui2
00098 
00099 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs