Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CImage.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2009 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19 CImage
20 */
21 
22 #include "precompiled.h"
23 #include "GUI.h"
24 #include "CImage.h"
25 
26 #include "lib/ogl.h"
27 
28 
29 //-------------------------------------------------------------------
30 // Constructor / Destructor
31 //-------------------------------------------------------------------
33 {
34  AddSetting(GUIST_CGUISpriteInstance, "sprite");
35  AddSetting(GUIST_int, "cell_id");
36  AddSetting(GUIST_CStrW, "tooltip");
37  AddSetting(GUIST_CStr, "tooltip_style");
38 }
39 
41 {
42 }
43 
44 void CImage::Draw()
45 {
46  if (GetGUI())
47  {
48  float bz = GetBufferedZ();
49 
50  CGUISpriteInstance *sprite;
51  int cell_id;
52  GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
53  GUI<int>::GetSetting(this, "cell_id", cell_id);
54 
55  GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
56  }
57 }
void DrawSprite(const CGUISpriteInstance &Sprite, int CellID, const float &Z, const CRect &Rect, const CRect &Clipping=CRect())
Draw GUI Sprite.
Definition: CGUI.cpp:467
static PSRETURN GetSetting(const IGUIObject *pObject, const CStr &Setting, T &Value)
Retrieves a setting by name from object pointer.
Definition: GUIutil.cpp:344
virtual float GetBufferedZ() const
Returns not the Z value, but the actual buffered Z value, i.e.
Definition: IGUIObject.cpp:406
CImage()
Definition: CImage.cpp:32
void AddSetting(const EGUISettingType &Type, const CStr &Name)
Add a setting to m_Settings.
Definition: IGUIObject.cpp:172
virtual ~CImage()
Definition: CImage.cpp:40
CRect m_CachedActualSize
Cached size, real size m_Size is actually dependent on resolution and can have different real outcome...
Definition: IGUIObject.h:434
CGUI * GetGUI()
Definition: IGUIObject.h:388
virtual void Draw()
Draws the Image.
Definition: CImage.cpp:44
static PSRETURN GetSettingPointer(const IGUIObject *pObject, const CStr &Setting, T *&Value)
Definition: GUIutil.cpp:317