1 | /************************************************************************
|
---|
2 | filename: CEGUIFalDimensions.h
|
---|
3 | created: Mon Jun 13 2005
|
---|
4 | author: Paul D Turner <paul@cegui.org.uk>
|
---|
5 | *************************************************************************/
|
---|
6 | /*************************************************************************
|
---|
7 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
8 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2.1 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | *************************************************************************/
|
---|
24 | #ifndef _CEGUIFalDimensions_h_
|
---|
25 | #define _CEGUIFalDimensions_h_
|
---|
26 |
|
---|
27 | #include "falagard/CEGUIFalEnums.h"
|
---|
28 | #include "CEGUIString.h"
|
---|
29 | #include "CEGUIUDim.h"
|
---|
30 |
|
---|
31 | // Start of CEGUI namespace section
|
---|
32 | namespace CEGUI
|
---|
33 | {
|
---|
34 | /*!
|
---|
35 | \brief
|
---|
36 | Abstract interface for a generic 'dimension' class.
|
---|
37 | */
|
---|
38 | class CEGUIEXPORT BaseDim
|
---|
39 | {
|
---|
40 | public:
|
---|
41 | BaseDim();
|
---|
42 |
|
---|
43 | virtual ~BaseDim();
|
---|
44 |
|
---|
45 | /*!
|
---|
46 | \brief
|
---|
47 | Return a value that represents this dimension as absolute pixels.
|
---|
48 |
|
---|
49 | \param wnd
|
---|
50 | Window object that may be used by the specialised class to aid in
|
---|
51 | calculating the final value.
|
---|
52 |
|
---|
53 | \return
|
---|
54 | float value which represents, in pixels, the same value as this BaseDim.
|
---|
55 | */
|
---|
56 | float getValue(const Window& wnd) const;
|
---|
57 |
|
---|
58 | /*!
|
---|
59 | \brief
|
---|
60 | Return a value that represents this dimension as absolute pixels.
|
---|
61 |
|
---|
62 | \param wnd
|
---|
63 | Window object that may be used by the specialised class to aid in
|
---|
64 | calculating the final value (typically would be used to obtain
|
---|
65 | window/widget dimensions).
|
---|
66 |
|
---|
67 | \param container
|
---|
68 | Rect object which describes an area to be considered as the base area
|
---|
69 | when calculating the final value. Basically this means that relative values
|
---|
70 | are calculated from the dimensions of this Rect.
|
---|
71 |
|
---|
72 | \return
|
---|
73 | float value which represents, in pixels, the same value as this BaseDim.
|
---|
74 | */
|
---|
75 | float getValue(const Window& wnd, const Rect& container) const;
|
---|
76 |
|
---|
77 | /*!
|
---|
78 | \brief
|
---|
79 | Create an exact copy of the specialised class and return it as a pointer to
|
---|
80 | a BaseDim object.
|
---|
81 |
|
---|
82 | Since the system needs to be able to copy objects derived from BaseDim, but only
|
---|
83 | has knowledge of the BaseDim interface, this clone method is provided to prevent
|
---|
84 | slicing issues.
|
---|
85 |
|
---|
86 | \return
|
---|
87 | BaseDim object pointer
|
---|
88 | */
|
---|
89 | BaseDim* clone() const;
|
---|
90 |
|
---|
91 | /*!
|
---|
92 | \brief
|
---|
93 | Return the DimensionOperator set for this BaseDim based object.
|
---|
94 |
|
---|
95 | \return
|
---|
96 | One of the DimensionOperator enumerated values representing a mathematical operation to be
|
---|
97 | performed upon this BaseDim using the set operand.
|
---|
98 | */
|
---|
99 | DimensionOperator getDimensionOperator() const;
|
---|
100 |
|
---|
101 | /*!
|
---|
102 | \brief
|
---|
103 | Set the DimensionOperator set for this BaseDim based object.
|
---|
104 |
|
---|
105 | \param op
|
---|
106 | One of the DimensionOperator enumerated values representing a mathematical operation to be
|
---|
107 | performed upon this BaseDim using the set operand.
|
---|
108 |
|
---|
109 | \return
|
---|
110 | Nothing.
|
---|
111 | */
|
---|
112 | void setDimensionOperator(DimensionOperator op);
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | \brief
|
---|
116 | Return a pointer to the BaseDim set to be used as the other operand.
|
---|
117 |
|
---|
118 | \return
|
---|
119 | Pointer to the BaseDim object.
|
---|
120 | */
|
---|
121 | const BaseDim* getOperand() const;
|
---|
122 |
|
---|
123 | /*!
|
---|
124 | \brief
|
---|
125 | Set the BaseDim set to be used as the other operand in calculations for this BaseDim.
|
---|
126 |
|
---|
127 | \param operand
|
---|
128 | sub-class of BaseDim representing the 'other' operand. The given object will be cloned; no
|
---|
129 | transfer of ownership occurrs for the passed object.
|
---|
130 |
|
---|
131 | \return
|
---|
132 | Nothing.
|
---|
133 | */
|
---|
134 | void setOperand(const BaseDim& operand);
|
---|
135 |
|
---|
136 | /*!
|
---|
137 | \brief
|
---|
138 | Writes an xml representation of this BaseDim to \a out_stream.
|
---|
139 |
|
---|
140 | \param out_stream
|
---|
141 | Stream where xml data should be output.
|
---|
142 |
|
---|
143 | \return
|
---|
144 | Nothing.
|
---|
145 | */
|
---|
146 | void writeXMLToStream(OutStream& out_stream) const;
|
---|
147 |
|
---|
148 | protected:
|
---|
149 | /*!
|
---|
150 | \brief
|
---|
151 | Implementataion method to return the base value for this BaseDim. This method should
|
---|
152 | not attempt to apply the mathematical operator; this is handled automatically.
|
---|
153 | */
|
---|
154 | virtual float getValue_impl(const Window& wnd) const = 0;
|
---|
155 |
|
---|
156 | /*!
|
---|
157 | \brief
|
---|
158 | Implementataion method to return the base value for this BaseDim. This method should
|
---|
159 | not attempt to apply the mathematical operator; this is handled automatically by BaseDim.
|
---|
160 | */
|
---|
161 | virtual float getValue_impl(const Window& wnd, const Rect& container) const = 0;
|
---|
162 |
|
---|
163 | /*!
|
---|
164 | \brief
|
---|
165 | Implementataion method to return a clone of this sub-class of BaseDim.
|
---|
166 | This method should not attempt to clone the mathematical operator or operand; theis is
|
---|
167 | handled automatically by BaseDim.
|
---|
168 | */
|
---|
169 | virtual BaseDim* clone_impl() const = 0;
|
---|
170 |
|
---|
171 | /*!
|
---|
172 | \brief
|
---|
173 | Implementataion method to output real xml element name to an OutStream.
|
---|
174 | This method should not write the element opening '<' character, nor close the element, it
|
---|
175 | must write just the element name itself.
|
---|
176 | */
|
---|
177 | virtual void writeXMLElementName_impl(OutStream& out_stream) const = 0;
|
---|
178 |
|
---|
179 | /*!
|
---|
180 | \brief
|
---|
181 | Implementataion method to output xml element attributes to an OutStream.
|
---|
182 | This method should not write the element opening '<' character, nor close the element, it
|
---|
183 | must write just the element attributes.
|
---|
184 | */
|
---|
185 | virtual void writeXMLElementAttributes_impl(OutStream& out_stream) const = 0;
|
---|
186 |
|
---|
187 | private:
|
---|
188 | DimensionOperator d_operator;
|
---|
189 | BaseDim* d_operand;
|
---|
190 | };
|
---|
191 |
|
---|
192 |
|
---|
193 | /*!
|
---|
194 | \brief
|
---|
195 | Dimension type that represents an absolute pixel value. Implements BaseDim interface.
|
---|
196 | */
|
---|
197 | class CEGUIEXPORT AbsoluteDim : public BaseDim
|
---|
198 | {
|
---|
199 | public:
|
---|
200 | /*!
|
---|
201 | \brief
|
---|
202 | Constructor.
|
---|
203 |
|
---|
204 | \param val
|
---|
205 | float value to be assigned to the AbsoluteDim.
|
---|
206 | */
|
---|
207 | AbsoluteDim(float val);
|
---|
208 |
|
---|
209 | /*!
|
---|
210 | \brief
|
---|
211 | Set the current value of the AbsoluteDim.
|
---|
212 | */
|
---|
213 | void setValue(float val);
|
---|
214 |
|
---|
215 | protected:
|
---|
216 | // Implementation of the base class interface
|
---|
217 | float getValue_impl(const Window& wnd) const;
|
---|
218 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
219 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
220 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
221 |
|
---|
222 | BaseDim* clone_impl() const;
|
---|
223 |
|
---|
224 | private:
|
---|
225 | float d_val; //!< holds pixel value for the AbsoluteDim.
|
---|
226 | };
|
---|
227 |
|
---|
228 |
|
---|
229 | /*!
|
---|
230 | \brief
|
---|
231 | Dimension type that represents some dimension of a named Image. Implements BaseDim interface.
|
---|
232 | */
|
---|
233 | class CEGUIEXPORT ImageDim : public BaseDim
|
---|
234 | {
|
---|
235 | public:
|
---|
236 | /*!
|
---|
237 | \brief
|
---|
238 | Constructor.
|
---|
239 |
|
---|
240 | \param imageset
|
---|
241 | String object holding the name of the imagseset which contains the image.
|
---|
242 |
|
---|
243 | \param image
|
---|
244 | String object holding the name of the image.
|
---|
245 |
|
---|
246 | \param dim
|
---|
247 | DimensionType value indicating which dimension of the described image that this ImageDim
|
---|
248 | is to represent.
|
---|
249 | */
|
---|
250 | ImageDim(const String& imageset, const String& image, DimensionType dim);
|
---|
251 |
|
---|
252 | /*!
|
---|
253 | \brief
|
---|
254 | Sets the source image information for this ImageDim.
|
---|
255 |
|
---|
256 | \param imageset
|
---|
257 | String object holding the name of the imagseset which contains the image.
|
---|
258 |
|
---|
259 | \param image
|
---|
260 | String object holding the name of the image.
|
---|
261 |
|
---|
262 | \return
|
---|
263 | Nothing.
|
---|
264 | */
|
---|
265 | void setSourceImage(const String& imageset, const String& image);
|
---|
266 |
|
---|
267 | /*!
|
---|
268 | \brief
|
---|
269 | Sets the source dimension type for this ImageDim.
|
---|
270 |
|
---|
271 | \param dim
|
---|
272 | DimensionType value indicating which dimension of the described image that this ImageDim
|
---|
273 | is to represent.
|
---|
274 |
|
---|
275 | \return
|
---|
276 | Nothing.
|
---|
277 | */
|
---|
278 | void setSourceDimension(DimensionType dim);
|
---|
279 |
|
---|
280 | protected:
|
---|
281 | // Implementation of the base class interface
|
---|
282 | float getValue_impl(const Window& wnd) const;
|
---|
283 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
284 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
285 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
286 | BaseDim* clone_impl() const;
|
---|
287 |
|
---|
288 | private:
|
---|
289 | String d_imageset; //!< name of the Imageset containing the image.
|
---|
290 | String d_image; //!< name of the Image.
|
---|
291 | DimensionType d_what; //!< the dimension of the image that we are to represent.
|
---|
292 | };
|
---|
293 |
|
---|
294 |
|
---|
295 | /*!
|
---|
296 | \brief
|
---|
297 | Dimension type that represents some dimension of a Window/widget. Implements BaseDim interface.
|
---|
298 |
|
---|
299 | When calculating the final pixel value for the dimension, a target widget name is built by
|
---|
300 | appending the name suffix specified for the WidgetDim to the name of the window passed to
|
---|
301 | getValue, we then find the window/widget with that name - the final value of the dimension
|
---|
302 | is taken from this window/widget.
|
---|
303 | */
|
---|
304 | class CEGUIEXPORT WidgetDim : public BaseDim
|
---|
305 | {
|
---|
306 | public:
|
---|
307 | /*!
|
---|
308 | \brief
|
---|
309 | Constructor.
|
---|
310 |
|
---|
311 | \param name
|
---|
312 | String object holding the name suffix for a window/widget.
|
---|
313 |
|
---|
314 | \param dim
|
---|
315 | DimensionType value indicating which dimension of the described image that this ImageDim
|
---|
316 | is to represent.
|
---|
317 | */
|
---|
318 | WidgetDim(const String& name, DimensionType dim);
|
---|
319 |
|
---|
320 | /*!
|
---|
321 | \brief
|
---|
322 | Set the name suffix to use for this WidgetDim.
|
---|
323 |
|
---|
324 | \param name
|
---|
325 | String object holding the name suffix for a window/widget.
|
---|
326 |
|
---|
327 | \return
|
---|
328 | Nothing.
|
---|
329 | */
|
---|
330 | void setWidgetName(const String& name);
|
---|
331 |
|
---|
332 | /*!
|
---|
333 | \brief
|
---|
334 | Sets the source dimension type for this WidgetDim.
|
---|
335 |
|
---|
336 | \param dim
|
---|
337 | DimensionType value indicating which dimension of the described image that this WidgetDim
|
---|
338 | is to represent.
|
---|
339 |
|
---|
340 | \return
|
---|
341 | Nothing.
|
---|
342 | */
|
---|
343 | void setSourceDimension(DimensionType dim);
|
---|
344 |
|
---|
345 | protected:
|
---|
346 | // Implementation of the base class interface
|
---|
347 | float getValue_impl(const Window& wnd) const;
|
---|
348 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
349 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
350 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
351 | BaseDim* clone_impl() const;
|
---|
352 |
|
---|
353 | private:
|
---|
354 | String d_widgetName; //!< Holds target window name suffix.
|
---|
355 | DimensionType d_what; //!< the dimension of the target window that we are to represent.
|
---|
356 | };
|
---|
357 |
|
---|
358 |
|
---|
359 | /*!
|
---|
360 | \brief
|
---|
361 | Dimension type that represents an Unified dimension. Implements BaseDim interface.
|
---|
362 | */
|
---|
363 | class CEGUIEXPORT UnifiedDim : public BaseDim
|
---|
364 | {
|
---|
365 | public:
|
---|
366 | /*!
|
---|
367 | \brief
|
---|
368 | Constructor.
|
---|
369 |
|
---|
370 | \param value
|
---|
371 | UDim holding the value to assign to this UnifiedDim.
|
---|
372 |
|
---|
373 | \param dim
|
---|
374 | DimensionType value indicating what this UnifiedDim is to represent. This is required
|
---|
375 | because we need to know what part of the base Window that the UDim scale component is
|
---|
376 | to operate against.
|
---|
377 | */
|
---|
378 | UnifiedDim(const UDim& value, DimensionType dim);
|
---|
379 |
|
---|
380 | protected:
|
---|
381 | // Implementation of the base class interface
|
---|
382 | float getValue_impl(const Window& wnd) const;
|
---|
383 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
384 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
385 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
386 | BaseDim* clone_impl() const;
|
---|
387 |
|
---|
388 | private:
|
---|
389 | UDim d_value; //!< The UDim value.
|
---|
390 | DimensionType d_what; //!< what we represent.
|
---|
391 | };
|
---|
392 |
|
---|
393 | /*!
|
---|
394 | \brief
|
---|
395 | Dimension type that represents some metric of a Font. Implements BaseDim interface.
|
---|
396 | */
|
---|
397 | class CEGUIEXPORT FontDim : public BaseDim
|
---|
398 | {
|
---|
399 | public:
|
---|
400 | /*!
|
---|
401 | \brief
|
---|
402 | Constructor.
|
---|
403 |
|
---|
404 | \param name
|
---|
405 | String holding the name suffix of the window to be accessed to obtain the font
|
---|
406 | and / or text strings to be used when these items are not explicitly given.
|
---|
407 |
|
---|
408 | \param font
|
---|
409 | String holding the name of the font to use for this dimension. If the string is
|
---|
410 | empty, the font assigned to the window passed to getValue will be used.
|
---|
411 |
|
---|
412 | \param text
|
---|
413 | String holding the text to be measured for horizontal extent. If this is empty,
|
---|
414 | the text from the window passed to getValue will be used.
|
---|
415 |
|
---|
416 | \param metric
|
---|
417 | One of the FontMetricType values indicating what we should represent.
|
---|
418 |
|
---|
419 | \param padding
|
---|
420 | constant pixel padding value to be added.
|
---|
421 | */
|
---|
422 | FontDim(const String& name, const String& font, const String& text, FontMetricType metric, float padding = 0);
|
---|
423 |
|
---|
424 | protected:
|
---|
425 | // Implementation of the base class interface
|
---|
426 | float getValue_impl(const Window& wnd) const;
|
---|
427 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
428 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
429 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
430 | BaseDim* clone_impl() const;
|
---|
431 |
|
---|
432 | private:
|
---|
433 | String d_font; //!< Name of Font. If empty font will be taken from Window.
|
---|
434 | String d_text; //!< String to measure for extents, if empty will use window text.
|
---|
435 | String d_childSuffix; //!< String to hold the name suffix of the window to use for fetching missing font and/or text.
|
---|
436 | FontMetricType d_metric; //!< what metric we represent.
|
---|
437 | float d_padding; //!< padding value to be added.
|
---|
438 | };
|
---|
439 |
|
---|
440 | /*!
|
---|
441 | \brief
|
---|
442 | Dimension type that represents the value of a Window property. Implements BaseDim interface.
|
---|
443 | */
|
---|
444 | class CEGUIEXPORT PropertyDim : public BaseDim
|
---|
445 | {
|
---|
446 | public:
|
---|
447 | /*!
|
---|
448 | \brief
|
---|
449 | Constructor.
|
---|
450 |
|
---|
451 | \param name
|
---|
452 | String holding the name suffix of the window on which the property is to be accessed.
|
---|
453 |
|
---|
454 | \param property
|
---|
455 | String object holding the name of the property this PropertyDim represents the value of.
|
---|
456 | The property named should represent a simple float value.
|
---|
457 | */
|
---|
458 | PropertyDim(const String& name, const String& property);
|
---|
459 |
|
---|
460 | protected:
|
---|
461 | // Implementation of the base class interface
|
---|
462 | float getValue_impl(const Window& wnd) const;
|
---|
463 | float getValue_impl(const Window& wnd, const Rect& container) const;
|
---|
464 | void writeXMLElementName_impl(OutStream& out_stream) const;
|
---|
465 | void writeXMLElementAttributes_impl(OutStream& out_stream) const;
|
---|
466 | BaseDim* clone_impl() const;
|
---|
467 |
|
---|
468 | private:
|
---|
469 | String d_property; //!< Propery that this object represents.
|
---|
470 | String d_childSuffix; //!< String to hold the name suffix of the child to access the property form.
|
---|
471 | };
|
---|
472 |
|
---|
473 | /*!
|
---|
474 | \brief
|
---|
475 | Class representing some kind of dimension.
|
---|
476 |
|
---|
477 | The key thing to understand about Dimension is that it contains not just a dimensional value,
|
---|
478 | but also a record of what the dimension value is supposed to represent. (e.g. a co-ordinate on
|
---|
479 | the x axis, or the height of something).
|
---|
480 | */
|
---|
481 | class CEGUIEXPORT Dimension
|
---|
482 | {
|
---|
483 | public:
|
---|
484 | /*!
|
---|
485 | \brief
|
---|
486 | Constructor
|
---|
487 | */
|
---|
488 | Dimension();
|
---|
489 |
|
---|
490 | /*!
|
---|
491 | \brief
|
---|
492 | Destructor
|
---|
493 | */
|
---|
494 | ~Dimension();
|
---|
495 |
|
---|
496 | /*!
|
---|
497 | \brief
|
---|
498 | Constructor
|
---|
499 |
|
---|
500 | \param dim
|
---|
501 | object based on subclass of BaseDim which holds the dimensional value.
|
---|
502 |
|
---|
503 | \param type
|
---|
504 | DimensionType value indicating what dimension this object is to represent.
|
---|
505 | */
|
---|
506 | Dimension(const BaseDim& dim, DimensionType type);
|
---|
507 |
|
---|
508 | /*!
|
---|
509 | \brief
|
---|
510 | Copy constructor
|
---|
511 | */
|
---|
512 | Dimension(const Dimension& other);
|
---|
513 |
|
---|
514 | /*!
|
---|
515 | \brief
|
---|
516 | Assignment operator
|
---|
517 | */
|
---|
518 | Dimension& operator=(const Dimension& other);
|
---|
519 |
|
---|
520 | /*!
|
---|
521 | \brief
|
---|
522 | return the BaseDim object currently used as the value for this Dimension.
|
---|
523 |
|
---|
524 | \return
|
---|
525 | const reference to the BaseDim sub-class object which contains the value for this Dimension.
|
---|
526 | */
|
---|
527 | const BaseDim& getBaseDimension() const;
|
---|
528 |
|
---|
529 | /*!
|
---|
530 | \brief
|
---|
531 | set the current value for this Dimension.
|
---|
532 |
|
---|
533 | \param dim
|
---|
534 | object based on a subclass of BaseDim which holds the dimensional value.
|
---|
535 |
|
---|
536 | \return
|
---|
537 | Nothing.
|
---|
538 | */
|
---|
539 | void setBaseDimension(const BaseDim& dim);
|
---|
540 |
|
---|
541 | /*!
|
---|
542 | \brief
|
---|
543 | Return a DimensionType value indicating what this Dimension represents.
|
---|
544 |
|
---|
545 | \return
|
---|
546 | one of the DimensionType enumerated values.
|
---|
547 | */
|
---|
548 | DimensionType getDimensionType() const;
|
---|
549 |
|
---|
550 | /*!
|
---|
551 | \brief
|
---|
552 | Sets what this Dimension represents.
|
---|
553 |
|
---|
554 | \param type
|
---|
555 | one of the DimensionType enumerated values.
|
---|
556 |
|
---|
557 | \return
|
---|
558 | Nothing.
|
---|
559 | */
|
---|
560 | void setDimensionType(DimensionType type);
|
---|
561 |
|
---|
562 | /*!
|
---|
563 | \brief
|
---|
564 | Writes an xml representation of this Dimension to \a out_stream.
|
---|
565 |
|
---|
566 | \param out_stream
|
---|
567 | Stream where xml data should be output.
|
---|
568 |
|
---|
569 | \return
|
---|
570 | Nothing.
|
---|
571 | */
|
---|
572 | void writeXMLToStream(OutStream& out_stream) const;
|
---|
573 |
|
---|
574 | private:
|
---|
575 | BaseDim* d_value; //!< Pointer to the value for this Dimension.
|
---|
576 | DimensionType d_type; //!< What we represent.
|
---|
577 | };
|
---|
578 |
|
---|
579 |
|
---|
580 | /*!
|
---|
581 | \brief
|
---|
582 | Class that represents a target area for a widget or imagery component.
|
---|
583 |
|
---|
584 | This is essentially a Rect built out of Dimension objects. Of note is that
|
---|
585 | what would normally be the 'right' and 'bottom' edges may alternatively
|
---|
586 | represent width and height depending upon what the assigned Dimension(s)
|
---|
587 | represent.
|
---|
588 | */
|
---|
589 | class CEGUIEXPORT ComponentArea
|
---|
590 | {
|
---|
591 | public:
|
---|
592 | /*!
|
---|
593 | \brief
|
---|
594 | Return a Rect describing the absolute pixel area represented by this ComponentArea.
|
---|
595 |
|
---|
596 | \param wnd
|
---|
597 | Window object to be used when calculating final pixel area.
|
---|
598 |
|
---|
599 | \return
|
---|
600 | Rect object describing the pixels area represented by this ComponentArea when using \a wnd
|
---|
601 | as a reference for calculating the final pixel dimensions.
|
---|
602 | */
|
---|
603 | Rect getPixelRect(const Window& wnd) const;
|
---|
604 |
|
---|
605 | /*!
|
---|
606 | \brief
|
---|
607 | Return a Rect describing the absolute pixel area represented by this ComponentArea.
|
---|
608 |
|
---|
609 | \param wnd
|
---|
610 | Window object to be used when calculating final pixel area.
|
---|
611 |
|
---|
612 | \param container
|
---|
613 | Rect object to be used as a base or container when converting relative dimensions.
|
---|
614 |
|
---|
615 | \return
|
---|
616 | Rect object describing the pixels area represented by this ComponentArea when using \a wnd
|
---|
617 | and \a container as a reference for calculating the final pixel dimensions.
|
---|
618 | */
|
---|
619 | Rect getPixelRect(const Window& wnd, const Rect& container) const;
|
---|
620 |
|
---|
621 | /*!
|
---|
622 | \brief
|
---|
623 | Writes an xml representation of this ComponentArea to \a out_stream.
|
---|
624 |
|
---|
625 | \param out_stream
|
---|
626 | Stream where xml data should be output.
|
---|
627 |
|
---|
628 | \return
|
---|
629 | Nothing.
|
---|
630 | */
|
---|
631 | void writeXMLToStream(OutStream& out_stream) const;
|
---|
632 |
|
---|
633 | /*!
|
---|
634 | \brief
|
---|
635 | Return whether this ComponentArea fetches it's area via a property on the target window.
|
---|
636 |
|
---|
637 | \return
|
---|
638 | - true if the area comes via a Propery.
|
---|
639 | - false if the area is defined explicitly via the Dimension fields.
|
---|
640 | */
|
---|
641 | bool isAreaFetchedFromProperty() const;
|
---|
642 |
|
---|
643 | /*!
|
---|
644 | \brief
|
---|
645 | Return the name of the property that will be used to determine the pixel area for this ComponentArea.
|
---|
646 |
|
---|
647 | \return
|
---|
648 | String object holding the name of a Propery.
|
---|
649 | */
|
---|
650 | const String& getAreaPropertySource() const;
|
---|
651 |
|
---|
652 | /*!
|
---|
653 | \brief
|
---|
654 | Set the name of the property that will be used to determine the pixel area for this ComponentArea.
|
---|
655 |
|
---|
656 | \param property
|
---|
657 | String object holding the name of a Propery. The property should access a URect type property.
|
---|
658 |
|
---|
659 | \return
|
---|
660 | Nothing.
|
---|
661 | */
|
---|
662 | void setAreaPropertySource(const String& property);
|
---|
663 |
|
---|
664 |
|
---|
665 | Dimension d_left; //!< Left edge of the area.
|
---|
666 | Dimension d_top; //!< Top edge of the area.
|
---|
667 | Dimension d_right_or_width; //!< Either the right edge or the width of the area.
|
---|
668 | Dimension d_bottom_or_height; //!< Either the bototm edge or the height of the area.
|
---|
669 |
|
---|
670 | private:
|
---|
671 | String d_areaProperty; //!< Property to access. Must be a URect style property.
|
---|
672 | };
|
---|
673 |
|
---|
674 | } // End of CEGUI namespace section
|
---|
675 |
|
---|
676 |
|
---|
677 | #endif // end of guard _CEGUIFalDimensions_h_
|
---|