/usr/include/cegui-0.8.4/CEGUI/widgets/TreeItem.h is in libcegui-mk2-dev 0.8.4+dfsg-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | /***********************************************************************
created: 5-13-07
author: Jonathan Welch (Based on Code by David Durant)
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUITreeItem_h_
#define _CEGUITreeItem_h_
#include "../Base.h"
#include "../String.h"
#include "../ColourRect.h"
#include "../BasicRenderedStringParser.h"
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Base class for tree items
\deprecated
The CEGUI::Tree, CEGUI::TreeItem and any other associated classes are
deprecated and thier use should be minimised - preferably eliminated -
where possible. It is extremely unfortunate that this widget was ever added
to CEGUI since its design and implementation are poor and do not meet
established standards for the CEGUI project.
\par
While no alternative currently exists, a superior, replacement tree widget
will be provided prior to the final removal of the current implementation.
*/
class CEGUIEXPORT TreeItem : public
AllocatedObject<TreeItem>
{
public:
typedef std::vector<TreeItem*
CEGUI_VECTOR_ALLOC(TreeItem*)> LBItemList;
/*************************************************************************
Constants
*************************************************************************/
//! Default text colour.
static const Colour DefaultTextColour;
//! Default selection brush colour.
static const Colour DefaultSelectionColour;
/*************************************************************************
Construction and Destruction
*************************************************************************/
/*!
\brief
base class constructor
*/
TreeItem(const String& text, uint item_id = 0, void* item_data = 0,
bool disabled = false, bool auto_delete = true);
/*!
\brief
base class destructor
*/
virtual ~TreeItem(void);
/*************************************************************************
Accessors
*************************************************************************/
/*!
\brief
Return a pointer to the font being used by this TreeItem
This method will try a number of places to find a font to be used. If
no font can be found, NULL is returned.
\return
Font to be used for rendering this item
*/
const Font* getFont(void) const;
/*!
\brief
Return the current colours used for text rendering.
\return
ColourRect object describing the currently set colours
*/
ColourRect getTextColours(void) const
{ return d_textCols; }
/*************************************************************************
Manipulator methods
*************************************************************************/
/*!
\brief
Set the font to be used by this TreeItem
\param font
Font to be used for rendering this item
\return
Nothing
*/
void setFont(const Font* font);
/*!
\brief
Set the font to be used by this TreeItem
\param font_name
String object containing the name of the Font to be used for rendering
this item
\return
Nothing
*/
void setFont(const String& font_name);
/*!
\brief
Set the colours used for text rendering.
\param cols
ColourRect object describing the colours to be used.
\return
Nothing.
*/
void setTextColours(const ColourRect& cols)
{ d_textCols = cols; d_renderedStringValid = false; }
/*!
\brief
Set the colours used for text rendering.
\param top_left_colour
Colour (as ARGB value) to be applied to the top-left corner of each text
glyph rendered.
\param top_right_colour
Colour (as ARGB value) to be applied to the top-right corner of each
text glyph rendered.
\param bottom_left_colour
Colour (as ARGB value) to be applied to the bottom-left corner of each
text glyph rendered.
\param bottom_right_colour
Colour (as ARGB value) to be applied to the bottom-right corner of each
text glyph rendered.
\return
Nothing.
*/
void setTextColours(Colour top_left_colour, Colour top_right_colour,
Colour bottom_left_colour, Colour bottom_right_colour);
/*!
\brief
Set the colours used for text rendering.
\param col
colour value to be used when rendering.
\return
Nothing.
*/
void setTextColours(Colour col)
{ setTextColours(col, col, col, col); }
/*!
\brief
return the text string set for this tree item.
Note that even if the item does not render text, the text string can
still be useful, since it is used for sorting tree items.
\return
String object containing the current text for the tree item.
*/
const String& getText() const {return d_textLogical;}
//! return text string with \e visual ordering of glyphs.
const String& getTextVisual() const;
/*!
\brief
Return the text string currently set to be used as the tooltip text for
this item.
\return
String object containing the current tooltip text as sued by this item.
*/
const String& getTooltipText(void) const
{ return d_tooltipText; }
/*!
\brief
Return the current ID assigned to this tree item.
Note that the system does not make use of this value, client code can
assign any meaning it wishes to the ID.
\return
ID code currently assigned to this tree item
*/
uint getID(void) const
{ return d_itemID; }
/*!
\brief
Return the pointer to any client assigned user data attached to this
tree item.
Note that the system does not make use of this data, client code can
assign any meaning it wishes to the attached data.
\return
Pointer to the currently assigned user data.
*/
void* getUserData(void) const
{ return d_itemData; }
/*!
\brief
return whether this item is selected.
\return
- true if the item is selected.
- false if the item is not selected.
*/
bool isSelected(void) const
{ return d_selected; }
/*!
\brief
return whether this item is disabled.
\return
- true if the item is disabled.
- false if the item is enabled.
*/
bool isDisabled(void) const
{ return d_disabled; }
/*!
\brief
return whether this item will be automatically deleted when it is
removed from the tree or when the the tree it is attached to is
destroyed.
\return
- true if the item object will be deleted by the system when it is
removed from the tree, or when the tree it is attached to is
destroyed.
- false if client code must destroy the item after it is removed from
the tree.
*/
bool isAutoDeleted(void) const
{ return d_autoDelete; }
/*!
\brief
Get the owner window for this TreeItem.
The owner of a TreeItem is typically set by the tree widget when an
item is added or inserted.
\return
Ponter to the window that is considered the owner of this TreeItem.
*/
const Window* getOwnerWindow(void)
{ return d_owner; }
/*!
\brief
Return the current colours used for selection highlighting.
\return
ColourRect object describing the currently set colours.
*/
ColourRect getSelectionColours(void) const
{ return d_selectCols; }
/*!
\brief
Return the current selection highlighting brush.
\return
Pointer to the Image object currently used for selection highlighting.
*/
const Image* getSelectionBrushImage(void) const
{ return d_selectBrush; }
/*************************************************************************
Manipulators
*************************************************************************/
/*!
\brief
set the text string for this tree item.
Note that even if the item does not render text, the text string can
still be useful, since it is used for sorting tree items.
\param text
String object containing the text to set for the tree item.
\return
Nothing.
*/
void setText(const String& text);
/*!
\brief
Set the tooltip text to be used for this item.
\param text
String object holding the text to be used in the tooltip displayed for
this item.
\return
Nothing.
*/
void setTooltipText(const String& text)
{ d_tooltipText = text; }
/*!
\brief
Set the ID assigned to this tree item.
Note that the system does not make use of this value, client code can
assign any meaning it wishes to the ID.
\param item_id
ID code to be assigned to this tree item
\return
Nothing.
*/
void setID(uint item_id)
{ d_itemID = item_id; }
/*!
\brief
Set the client assigned user data attached to this lis box item.
Note that the system does not make use of this data, client code can
assign any meaning it wishes to the attached data.
\param item_data
Pointer to the user data to attach to this tree item.
\return
Nothing.
*/
void setUserData(void* item_data)
{ d_itemData = item_data; }
/*!
\brief
Set the selected state for the item.
\param setting
- true if the item is selected.
- false if the item is not selected.
\return
Nothing.
*/
void setSelected(bool setting)
{ d_selected = setting; }
/*!
\brief
Set the disabled state for the item.
\param setting
- true if the item should be disabled.
- false if the item should be enabled.
\return
Nothing.
*/
void setDisabled(bool setting)
{ d_disabled = setting; }
/*!
\brief
Set whether this item will be automatically deleted when it is removed
from the tree, or when the tree it is attached to is destroyed.
\param setting
- true if the item object should be deleted by the system when the it
is removed from the tree, or when the tree it is attached to is
destroyed.
- false if client code will destroy the item after it is removed from
the tree.
\return
Nothing.
*/
void setAutoDeleted(bool setting)
{ d_autoDelete = setting; }
/*!
\brief
Set the owner window for this TreeItem. This is called by the tree
widget when an item is added or inserted.
\param owner
Ponter to the window that should be considered the owner of this
TreeItem.
\return
Nothing
*/
void setOwnerWindow(const Window* owner)
{ d_owner = owner; }
/*!
\brief
Set the colours used for selection highlighting.
\param cols
ColourRect object describing the colours to be used.
\return
Nothing.
*/
void setSelectionColours(const ColourRect& cols)
{ d_selectCols = cols; }
/*!
\brief
Set the colours used for selection highlighting.
\param top_left_colour
Colour (as ARGB value) to be applied to the top-left corner of the
selection area.
\param top_right_colour
Colour (as ARGB value) to be applied to the top-right corner of the
selection area.
\param bottom_left_colour
Colour (as ARGB value) to be applied to the bottom-left corner of the
selection area.
\param bottom_right_colour
Colour (as ARGB value) to be applied to the bottom-right corner of the
selection area.
\return
Nothing.
*/
void setSelectionColours(Colour top_left_colour,
Colour top_right_colour,
Colour bottom_left_colour,
Colour bottom_right_colour);
/*!
\brief
Set the colours used for selection highlighting.
\param col
colour value to be used when rendering.
\return
Nothing.
*/
void setSelectionColours(Colour col)
{ setSelectionColours(col, col, col, col); }
/*!
\brief
Set the selection highlighting brush image.
\param image
Pointer to the Image object to be used for selection highlighting.
\return
Nothing.
*/
void setSelectionBrushImage(const Image* image)
{ d_selectBrush = image; }
/*!
\brief
Set the selection highlighting brush image.
\param name
Name of the image to be used.
\return
Nothing.
*/
void setSelectionBrushImage(const String& name);
/*!
\brief
Tell the treeItem where its button is located.
Calculated and set in Tree.cpp.
\param buttonOffset
Location of the button in screenspace.
*/
void setButtonLocation(Rectf& buttonOffset)
{ d_buttonLocation = buttonOffset; }
Rectf& getButtonLocation(void)
{ return d_buttonLocation; }
bool getIsOpen(void)
{ return d_isOpen; }
void toggleIsOpen(void)
{ d_isOpen = !d_isOpen; }
TreeItem *getTreeItemFromIndex(size_t itemIndex);
size_t getItemCount(void) const
{ return d_listItems.size(); }
LBItemList &getItemList(void)
{ return d_listItems; }
void addItem(TreeItem* item);
void removeItem(const TreeItem* item);
void setIcon(const Image &theIcon)
{ d_iconImage = &theIcon; }
/*************************************************************************
Abstract portion of interface
*************************************************************************/
/*!
\brief
Return the rendered pixel size of this tree item.
\return
Size object describing the size of the tree item in pixels.
*/
virtual Sizef getPixelSize(void) const;
/*!
\brief
Draw the tree item in its current state
\param position
Vector2 object describing the upper-left corner of area that should be
rendered in to for the draw operation.
\param alpha
Alpha value to be used when rendering the item (between 0.0f and 1.0f).
\param clipper
Rect object describing the clipping rectangle for the draw operation.
\return
Nothing.
*/
virtual void draw(GeometryBuffer& buffer, const Rectf& targetRect,
float alpha, const Rectf* clipper) const;
/*!
\brief
Perform any updates needed because the given font's render size has
changed.
\param font
Pointer to the Font whose render size has changed.
\return
- true if some action was taken.
- false if no action was taken (i.e font is not used here).
*/
virtual bool handleFontRenderSizeChange(const Font* const font);
/*************************************************************************
Operators
*************************************************************************/
/*!
\brief
Less-than operator, compares item texts.
*/
virtual bool operator<(const TreeItem& rhs) const
{ return getText() < rhs.getText(); }
/*!
\brief
Greater-than operator, compares item texts.
*/
virtual bool operator>(const TreeItem& rhs) const
{ return getText() > rhs.getText(); }
protected:
/*************************************************************************
Implementation methods
*************************************************************************/
/*!
\brief
Return a ColourRect object describing the colours in \a cols after
having their alpha component modulated by the value \a alpha.
*/
ColourRect getModulateAlphaColourRect(const ColourRect& cols,
float alpha) const;
/*!
\brief
Return a colour value describing the colour specified by \a col after
having its alpha component modulated by the value \a alpha.
*/
Colour calculateModulatedAlphaColour(Colour col, float alpha) const;
//! parse the text visual string into a RenderString representation.
void parseTextString() const;
/*************************************************************************
Implementation Data
*************************************************************************/
//! Text for this tree item. If not rendered, still used for sorting.
String d_textLogical; //!< text rendered by this component.
//! pointer to bidirection support object
BidiVisualMapping* d_bidiVisualMapping;
//! whether bidi visual mapping has been updated since last text change.
mutable bool d_bidiDataValid;
//! Text for the individual tooltip of this item.
String d_tooltipText;
//! ID code assigned by client code.
uint d_itemID;
//! Pointer to some client code data.
void* d_itemData;
//! true if item is selected. false if item is not selected.
bool d_selected;
//! true if item is disabled. false if item is not disabled.
bool d_disabled;
//! true if the system will destroy this item, false if client code will.
bool d_autoDelete;
//! Location of the 'expand' button for the item.
Rectf d_buttonLocation;
//! Pointer to the window that owns this item.
const Window* d_owner;
//! Colours used for selection highlighting.
ColourRect d_selectCols;
//! Image used for rendering selection.
const Image* d_selectBrush;
//! Colours used for rendering the text.
ColourRect d_textCols;
//! Font used for rendering text.
const Font* d_font;
//! Image for the icon to be displayed with this TreeItem.
const Image* d_iconImage;
//! list of items in this item's tree branch.
LBItemList d_listItems;
//! true if the this item's tree branch is opened.
bool d_isOpen;
//! Parser used to produce a final RenderedString from the standard String.
static BasicRenderedStringParser d_stringParser;
//! RenderedString drawn by this item.
mutable RenderedString d_renderedString;
//! boolean used to track when item state changes (and needs re-parse)
mutable bool d_renderedStringValid;
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUITreeItem_h_
|