Added different textures for each ptolemaic camel rank
[0ad.git] / source / gui / IGUITextOwner.h
blobdc5cbf422b3e6f4775a09f2b775cf9cdc0cb2872
1 /* Copyright (C) 2009 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
19 GUI Object Base - Text Owner
21 --Overview--
23 Interface class that enhance the IGUIObject with
24 cached CGUIStrings. This class is not at all needed,
25 and many controls that will use CGUIStrings might
26 not use this, but does help for regular usage such
27 as a text-box, a button, a radio button etc.
29 --More info--
31 Check GUI.h
35 #ifndef INCLUDED_IGUITEXTOWNER
36 #define INCLUDED_IGUITEXTOWNER
38 //--------------------------------------------------------
39 // Includes / Compiler directives
40 //--------------------------------------------------------
41 #include "GUI.h"
43 //--------------------------------------------------------
44 // Macros
45 //--------------------------------------------------------
47 //--------------------------------------------------------
48 // Types
49 //--------------------------------------------------------
51 //--------------------------------------------------------
52 // Declarations
53 //--------------------------------------------------------
55 /**
56 * Framework for handling Output text.
58 * @see IGUIObject
60 class IGUITextOwner : virtual public IGUIObject
62 public:
63 IGUITextOwner();
64 virtual ~IGUITextOwner();
66 /**
67 * Adds a text object.
69 void AddText(SGUIText * text);
71 /**
72 * @see IGUIObject#HandleMessage()
74 virtual void HandleMessage(SGUIMessage &Message);
76 /**
77 * @see IGUIObject#UpdateCachedSize()
79 virtual void UpdateCachedSize();
81 /**
82 * Draws the Text.
84 * @param index Index value of text. Mostly this will be 0
85 * @param color
86 * @param pos Position
87 * @param z Z value
88 * @param clipping Clipping rectangle, don't even add a parameter
89 * to get no clipping.
91 virtual void DrawText(int index, const CColor& color, const CPos& pos, float z, const CRect& clipping = CRect());
93 /**
94 * Test if mouse position is over an icon
96 virtual bool MouseOverIcon();
98 protected:
101 * Setup texts. Functions that sets up all texts when changes have been made.
103 virtual void SetupText()=0;
106 * Whether the cached text is currently valid (if not then SetupText will be called by Draw)
108 bool m_GeneratedTextsValid;
111 * Texts that are generated and ready to be rendered.
113 std::vector<SGUIText*> m_GeneratedTexts;
116 * Calculate the position for the text, based on the alignment.
118 void CalculateTextPosition(CRect &ObjSize, CPos &TextPos, SGUIText &Text);
121 #endif