PixelLightAPI  .
Graphics.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Graphics.h                                     *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLGUI_GRAPHICS_H__
00024 #define __PLGUI_GRAPHICS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Container/List.h>
00032 #include <PLMath/Vector2i.h>
00033 #include "PLGui/PLGui.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Forward declarations                                  ]
00038 //[-------------------------------------------------------]
00039 namespace PLCore {
00040     class String;
00041 }
00042 namespace PLGraphics {
00043     class Color4;
00044 }
00045 namespace PLGui {
00046     class Gui;
00047     class GraphicsHint;
00048     class GraphicsImpl;
00049     class Image;
00050     class Font;
00051 }
00052 
00053 
00054 //[-------------------------------------------------------]
00055 //[ Namespace                                             ]
00056 //[-------------------------------------------------------]
00057 namespace PLGui {
00058 
00059 
00060 //[-------------------------------------------------------]
00061 //[ Classes                                               ]
00062 //[-------------------------------------------------------]
00063 /**
00064 *  @brief
00065 *    Graphics class
00066 *
00067 *  @note
00068 *    - Implementation of the bridge design pattern, this class is the abstraction
00069 */
00070 class Graphics {
00071 
00072 
00073     //[-------------------------------------------------------]
00074     //[ Public functions                                      ]
00075     //[-------------------------------------------------------]
00076     public:
00077         /**
00078         *  @brief
00079         *    Constructor
00080         *
00081         *  @param[in] cGui
00082         *    Owner GUI
00083         *
00084         *  @remarks
00085         *    This function creates a new graphics implementation by calling the appropriate functions
00086         *    from cGui. This is useful e.g. for offscreen graphics objects. The implementation will be
00087         *    deleted along with the graphics object itself.
00088         */
00089         PLGUI_API Graphics(Gui &cGui);
00090 
00091         /**
00092         *  @brief
00093         *    Constructor
00094         *
00095         *  @param[in] cGui
00096         *    Owner GUI
00097         *  @param[in] cGraphicsImpl
00098         *    Reference to graphics implementation
00099         *
00100         *  @remarks
00101         *    This function takes an already created graphics implementation and embeds it inside
00102         *    the graphics object. This implementation will not be deleted automatically!
00103         */
00104         PLGUI_API Graphics(Gui &cGui, GraphicsImpl &cGraphicsImpl);
00105 
00106         /**
00107         *  @brief
00108         *    Destructor
00109         */
00110         PLGUI_API ~Graphics();
00111 
00112         /**
00113         *  @brief
00114         *    Get owner GUI
00115         *
00116         *  @return
00117         *    Pointer to GUI object (never a null pointer)
00118         */
00119         PLGUI_API Gui *GetGui() const;
00120 
00121         /**
00122         *  @brief
00123         *    Get implementation
00124         *
00125         *  @return
00126         *    Pointer to platform  specific implementation
00127         */
00128         PLGUI_API GraphicsImpl *GetImpl() const;
00129 
00130         /**
00131         *  @brief
00132         *    Get hints
00133         *
00134         *  @return
00135         *    List of hints
00136         */
00137         PLGUI_API const PLCore::List<GraphicsHint*> &GetHints();
00138 
00139         /**
00140         *  @brief
00141         *    Add a hint
00142         *
00143         *  @param[in] pHint
00144         *    GraphicsHint for the GUI renderer
00145         */
00146         PLGUI_API void AddHint(GraphicsHint *pHint);
00147 
00148         /**
00149         *  @brief
00150         *    Draws a line
00151         *
00152         *  @param[in] cColor
00153         *    Color of the line
00154         *  @param[in] vPos1
00155         *    Start position
00156         *  @param[in] vPos2
00157         *    End position
00158         *  @param[in] nWidth
00159         *    Line width
00160         */
00161         PLGUI_API void DrawLine(const PLGraphics::Color4 &cColor, const PLMath::Vector2i &vPos1, const PLMath::Vector2i &vPos2, PLCore::uint32 nWidth = 1);
00162 
00163         /**
00164         *  @brief
00165         *    Draws a rectangle
00166         *
00167         *  @param[in] cColor
00168         *    Color of the line
00169         *  @param[in] vPos1
00170         *    First corner
00171         *  @param[in] vPos2
00172         *    Second corner
00173         *  @param[in] nRoundX
00174         *    Rounded border in X direction
00175         *  @param[in] nRoundY
00176         *    Rounded border in Y direction
00177         *  @param[in] nWidth
00178         *    Line width
00179         */
00180         PLGUI_API void DrawRect(const PLGraphics::Color4 &cColor, const PLMath::Vector2i &vPos1, const PLMath::Vector2i &vPos2, PLCore::uint32 nRoundX = 0, PLCore::uint32 nRoundY = 0, PLCore::uint32 nWidth = 1);
00181 
00182         /**
00183         *  @brief
00184         *    Draws a filled box
00185         *
00186         *  @param[in] cColor
00187         *    Color of the box
00188         *  @param[in] vPos1
00189         *    First corner
00190         *  @param[in] vPos2
00191         *    Second corner
00192         *  @param[in] nRoundX
00193         *    Rounded border in X direction
00194         *  @param[in] nRoundY
00195         *    Rounded border in Y direction
00196         */
00197         PLGUI_API void DrawBox(const PLGraphics::Color4 &cColor, const PLMath::Vector2i &vPos1, const PLMath::Vector2i &vPos2, PLCore::uint32 nRoundX = 0, PLCore::uint32 nRoundY = 0);
00198 
00199         /**
00200         *  @brief
00201         *    Draws a filled box with a color gradient
00202         *
00203         *  @param[in] cColor1
00204         *    First color
00205         *  @param[in] cColor2
00206         *    Second color
00207         *  @param[in] fAngle
00208         *    Clockwise angle of the gradient color (in degrees). 0° means from left to right.
00209         *  @param[in] vPos1
00210         *    First corner
00211         *  @param[in] vPos2
00212         *    Second corner
00213         */
00214         PLGUI_API void DrawGradientBox(const PLGraphics::Color4 &cColor1, const PLGraphics::Color4 &cColor2, float fAngle, const PLMath::Vector2i &vPos1, const PLMath::Vector2i &vPos2);
00215 
00216         /**
00217         *  @brief
00218         *    Draws an image
00219         *
00220         *  @param[in] cImage
00221         *    Image to draw
00222         *  @param[in] vPos
00223         *    Image position
00224         *  @param[in] vSize
00225         *    Image size
00226         *
00227         *  @note
00228         *    - If vSize = (0 0), the image size is used
00229         */
00230         PLGUI_API void DrawImage(const Image &cImage, const PLMath::Vector2i &vPos, const PLMath::Vector2i &vSize);
00231 
00232         /**
00233         *  @brief
00234         *    Draws an tiled image
00235         *
00236         *  @param[in] cImage
00237         *    Image to draw
00238         *  @param[in] vPos
00239         *    Image position
00240         *  @param[in] vSize
00241         *    Image size
00242         *
00243         *  @note
00244         *    - If vSize = (0 0), the image size is used
00245         */
00246         PLGUI_API void DrawTiledImage(const Image &cImage, const PLMath::Vector2i &vPos, const PLMath::Vector2i &vSize);
00247 
00248         /**
00249         *  @brief
00250         *    Draws a text
00251         *
00252         *  @param[in] cFont
00253         *    Font to use
00254         *  @param[in] cTextColor
00255         *    Text color
00256         *  @param[in] cBkColor
00257         *    Background color
00258         *  @param[in] vPos
00259         *    Text position
00260         *  @param[in] sText
00261         *    Text
00262         */
00263         PLGUI_API void DrawText(const Font &cFont, const PLGraphics::Color4 &cTextColor, const PLGraphics::Color4 &cBkColor, const PLMath::Vector2i &vPos, const PLCore::String &sText);
00264 
00265         /**
00266         *  @brief
00267         *    Gets the width of a given text in the current font
00268         *
00269         *  @param[in] cFont
00270         *    Font to use
00271         *  @param[in] sText
00272         *    Text to get the width of
00273         *
00274         *  @return
00275         *    The width of the given text using the given font
00276         */
00277         PLGUI_API PLCore::uint32 GetTextWidth(const Font &cFont, const PLCore::String &sText);
00278 
00279         /**
00280         *  @brief
00281         *    Gets the height of a given text in the current font
00282         *
00283         *  @param[in] cFont
00284         *    Font to use
00285         *  @param[in] sText
00286         *    Text to get the height of
00287         *
00288         *  @return
00289         *    The height of the given text using the given font
00290         */
00291         PLGUI_API PLCore::uint32 GetTextHeight(const Font &cFont, const PLCore::String &sText);
00292 
00293 
00294     //[-------------------------------------------------------]
00295     //[ Protected data                                        ]
00296     //[-------------------------------------------------------]
00297     protected:
00298         Gui                         *m_pGui;            /**< GUI instance */
00299         GraphicsImpl                *m_pGraphicsImpl;   /**< Graphics implementation object */
00300         bool                         m_bManageImpl;     /**< If 'true', m_pGraphicsImpl will be destroyed in destructor */
00301         PLCore::List<GraphicsHint*>  m_lstHints;        /**< Rendering hints */
00302 
00303 
00304 };
00305 
00306 
00307 //[-------------------------------------------------------]
00308 //[ Namespace                                             ]
00309 //[-------------------------------------------------------]
00310 } // PLGui
00311 
00312 
00313 #endif // __PLGUI_GRAPHICS_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:56
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported