/usr/include/CEGUI/elements/CEGUIItemListBase.h is in libcegui-mk2-dev 0.7.6-2ubuntu4.
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 | /***********************************************************************
filename: CEGUIItemListBase.h
created: 31/3/2005
author: Tomas Lindquist Olsen (based on original Listbox code by Paul D Turner)
purpose: Interface to base class for ItemListBase widgets
*************************************************************************/
/***************************************************************************
* 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 _CEGUIItemListBase_h_
#define _CEGUIItemListBase_h_
#include "../CEGUIBase.h"
#include "../CEGUIWindow.h"
#include "CEGUIItemListBaseProperties.h"
#include "CEGUIItemEntry.h"
#include <vector>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4251)
#endif
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Base class for ItemListBase window renderer.
*/
class CEGUIEXPORT ItemListBaseWindowRenderer : public WindowRenderer
{
public:
/*!
\brief
Constructor
*/
ItemListBaseWindowRenderer(const String& name);
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering list items.
\return
Rect object describing the window relative area of the that is to be used for rendering
the items.
*/
virtual Rect getItemRenderArea(void) const = 0;
};
/*!
\brief
Base class for item list widgets.
*/
class CEGUIEXPORT ItemListBase : public Window
{
public:
static const String EventNamespace; //!< Namespace for global events
/*!
\brief
Sort modes for ItemListBase
*/
enum SortMode
{
Ascending,
Descending,
UserSort
};
//!< Sorting callback type
typedef bool (*SortCallback)(const ItemEntry* a, const ItemEntry* b);
/*************************************************************************
Constants
*************************************************************************/
// event names
/** Event fired when the contents of the list is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the ItemListBase whose contents
* has changed.
*/
static const String EventListContentsChanged;
/** Event fired when the sort enabled state of the list is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the ItemListBase whose sort enabled mode
* has been changed.
*/
static const String EventSortEnabledChanged;
/** Event fired when the sort mode of the list is changed.
* Handlers are passed a const WindowEventArgs reference with
* WindowEventArgs::window set to the ItemListBase whose sorting mode
* has been changed.
*/
static const String EventSortModeChanged;
/*************************************************************************
Accessor Methods
*************************************************************************/
/*!
\brief
Return number of items attached to the list
\return
the number of items currently attached to this list.
*/
size_t getItemCount(void) const {return d_listItems.size();}
/*!
\brief
Return the item at index position \a index.
\param index
Zero based index of the item to be returned.
\return
Pointer to the ItemEntry at index position \a index in the list.
\exception InvalidRequestException thrown if \a index is out of range.
*/
ItemEntry* getItemFromIndex(size_t index) const;
/*!
\brief
Return the index of ItemEntry \a item
\param item
Pointer to a ItemEntry whos zero based index is to be returned.
\return
Zero based index indicating the position of ItemEntry \a item in the list.
\exception InvalidRequestException thrown if \a item is not attached to this list.
*/
size_t getItemIndex(const ItemEntry* item) const;
/*!
\brief
Search the list for an item with the specified text
\param text
String object containing the text to be searched for.
\param start_item
ItemEntry where the search is to begin, the search will not include \a item. If \a item is
NULL, the search will begin from the first item in the list.
\return
Pointer to the first ItemEntry in the list after \a item that has text matching \a text. If
no item matches the criteria NULL is returned.
\exception InvalidRequestException thrown if \a item is not attached to this list box.
*/
ItemEntry* findItemWithText(const String& text, const ItemEntry* start_item);
/*!
\brief
Return whether the specified ItemEntry is in the List
\return
true if ItemEntry \a item is in the list, false if ItemEntry \a item is not in the list.
*/
bool isItemInList(const ItemEntry* item) const;
/*!
\brief
Return whether this window is automatically resized to fit its content.
\return
true if automatic resizing is enabled, false if it is disabled.
*/
bool isAutoResizeEnabled() const {return d_autoResize;}
/*!
\brief
Returns 'true' if the list is sorted
*/
bool isSortEnabled(void) const {return d_sortEnabled;}
/*!
\brief
Get sort mode.
*/
SortMode getSortMode(void) const {return d_sortMode;}
/*!
\brief
Get user sorting callback.
*/
SortCallback getSortCallback(void) const {return d_sortCallback;}
/*************************************************************************
Manipulator Methods
*************************************************************************/
/*!
\brief
Initialise the Window based object ready for use.
\note
This must be called for every window created. Normally this is handled automatically by the WindowFactory for each Window type.
\return
Nothing
*/
virtual void initialiseComponents(void);
/*!
\brief
Remove all items from the list.
Note that this will cause items, which does not have the 'DestroyedByParent' property set to 'false', to be deleted.
*/
void resetList(void);
/*!
\brief
Add the given ItemEntry to the list.
\param item
Pointer to the ItemEntry to be added to the list. Note that it is the passed object that is added to the
list, a copy is not made. If this parameter is NULL, nothing happens.
\return
Nothing.
*/
void addItem(ItemEntry* item);
/*!
\brief
Insert an item into the list before a specified item already in the list.
Note that if the list is sorted, the item may not end up in the
requested position.
\param item
Pointer to the ItemEntry to be inserted. Note that it is the passed
object that is added to the list, a copy is not made. If this parameter
is NULL, nothing happens.
\param position
Pointer to a ItemEntry that \a item is to be inserted before. If this
parameter is NULL, the item is inserted at the start of the list.
\return
Nothing.
*/
void insertItem(ItemEntry* item, const ItemEntry* position);
/*!
\brief
Removes the given item from the list. If the item is has the 'DestroyedByParent' property set to 'true', the item will be deleted.
\param item
Pointer to the ItemEntry that is to be removed. If \a item is not attached to this list then nothing
will happen.
\return
Nothing.
*/
void removeItem(ItemEntry* item);
/*!
\brief
Causes the list to update it's internal state after changes have been made to one or more
attached ItemEntry objects.
It should not be necessary to call this from client code, as the ItemEntries themselves call it if their parent is an ItemListBase.
\param resort
'true' to redo the list sorting as well.
'false' to only do layout and perhaps auto resize.
(defaults to 'false')
\return
Nothing.
*/
void handleUpdatedItemData(bool resort=false);
/*!
\brief
Set whether or not this ItemListBase widget should automatically resize to fit its content.
\param setting
Boolean value that if true enables automatic resizing, if false disables automatic resizing.
\return
Nothing.
*/
void setAutoResizeEnabled(bool setting);
/*!
\brief
Resize the ItemListBase to exactly fit the content that is attached to it.
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering items.
\return
Nothing
*/
virtual void sizeToContent(void) {sizeToContent_impl();}
/*!
\brief
Triggers a ListContentsChanged event.
These are not fired during initialisation for optimization purposes.
*/
virtual void endInitialisation(void);
/*!
\brief
method called to perform extended laying out of attached child windows.
The system may call this at various times (like when it is resized for
example), and it may be invoked directly where required.
\return
Nothing.
*/
virtual void performChildWindowLayout(void);
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering list items.
\return
Rect object describing the window relative area of the that is to be used for rendering
the items.
*/
Rect getItemRenderArea(void) const;
/*!
\brief
Returns a pointer to the window that all items are directed too.
\return
A pointer to the content pane window, or 'this' if children are added
directly to this window.
*/
Window* getContentPane(void) const {return d_pane;}
/*!
\brief
Notify this ItemListBase that the given item was just clicked.
Internal function - NOT to be used from client code.
*/
virtual void notifyItemClicked(ItemEntry*) {}
/*!
\brief
Notify this ItemListBase that the given item just changed selection state.
Internal function - NOT to be used from client code.
*/
virtual void notifyItemSelectState(ItemEntry*, bool) {}
/*!
\brief
Set whether the list should be sorted (by text).
*/
void setSortEnabled(bool setting);
/*!
\brief
Set mode to be used when sorting the list.
\param mode
SortMode enum.
*/
void setSortMode(SortMode mode);
/*!
\brief
Set a user callback as sorting function
\param mode
SortCallback
*/
void setSortCallback(SortCallback cb);
/*!
\brief
Sort the list.
\param relayout
True if the item layout should be redone after the sorting.
False to only sort the internal list. Nothing more.
This parameter defaults to true and should generally not be
used in client code.
*/
void sortList(bool relayout=true);
/*************************************************************************
Construction and Destruction
*************************************************************************/
/*!
\brief
Constructor for ItemListBase base class.
*/
ItemListBase(const String& type, const String& name);
/*!
\brief
Destructor for ItemListBase base class.
*/
virtual ~ItemListBase(void);
protected:
/*************************************************************************
Abstract Implementation Functions (must be provided by derived class)
*************************************************************************/
/*!
\brief
Resize the ItemListBase to exactly fit the content that is attached to it.
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering items.
\return
Nothing
*/
virtual void sizeToContent_impl(void);
/*!
\brief
Returns the Size in unclipped pixels of the content attached to this ItemListBase that is attached to it.
\return
Size object describing in unclipped pixels the size of the content ItemEntries attached to this menu.
*/
virtual Size getContentSize() const = 0;
/*!
\brief
Return a Rect object describing, in un-clipped pixels, the window relative area
that is to be used for rendering list items.
\return
Rect object describing the window relative area of the that is to be used for rendering
the items.
*/
//virtual Rect getItemRenderArea_impl(void) const = 0;
/*!
\brief
Setup size and position for the item widgets attached to this ItemListBase
\return
Nothing.
*/
virtual void layoutItemWidgets() = 0;
/*************************************************************************
Implementation Functions
*************************************************************************/
/*!
\brief
Remove all items from the list.
\note
Note that this will cause items with the 'DestroyedByParent' property set to 'true', to be deleted.
\return
- true if the list contents were changed.
- false if the list contents were not changed (list already empty).
*/
bool resetList_impl(void);
/*!
\brief
Return whether this window was inherited from the given class name at some point in the inheritance hierarchy.
\param class_name
The class name that is to be checked.
\return
true if this window was inherited from \a class_name. false if not.
*/
virtual bool testClassName_impl(const String& class_name) const
{
if (class_name=="ItemListBase") return true;
return Window::testClassName_impl(class_name);
}
// validate window renderer
virtual bool validateWindowRenderer(const String& name) const
{
return (name == EventNamespace);
}
/*!
\brief
Returns the SortCallback that's really going to be used for the sorting operation.
*/
SortCallback getRealSortCallback(void) const;
/*************************************************************************
New event handlers
*************************************************************************/
/*!
\brief
Handler called internally when the list contents are changed
*/
virtual void onListContentsChanged(WindowEventArgs& e);
/*!
\brief
Handler called internally when sorting gets enabled.
*/
virtual void onSortEnabledChanged(WindowEventArgs& e);
/*!
\brief
Handler called internally when the sorting mode is changed.
*/
virtual void onSortModeChanged(WindowEventArgs& e);
/*************************************************************************
Overridden Event handlers
*************************************************************************/
virtual void onParentSized(WindowEventArgs& e);
//virtual void onChildRemoved(WindowEventArgs& e);
//virtual void onDestructionStarted(WindowEventArgs& e);
/*************************************************************************
Implementation Data
*************************************************************************/
typedef std::vector<ItemEntry*> ItemEntryList;
ItemEntryList d_listItems; //!< list of items in the list.
//!< True if this ItemListBase widget should automatically resize to fit its content. False if not.
bool d_autoResize;
//!< Pointer to the content pane (for items), 0 if we're not using one
Window* d_pane;
//!< True if this ItemListBase is sorted. False if not.
bool d_sortEnabled;
//!< The current sorting mode applied if sorting is enabled.
SortMode d_sortMode;
//!< The user sort callback or 0 if none.
SortCallback d_sortCallback;
//!< True if the list needs to be resorted.
bool d_resort;
private:
/*************************************************************************
Static Properties for this class
*************************************************************************/
static ItemListBaseProperties::AutoResizeEnabled d_autoResizeEnabledProperty;
static ItemListBaseProperties::SortEnabled d_sortEnabledProperty;
static ItemListBaseProperties::SortMode d_sortModeProperty;
/*************************************************************************
Private methods
*************************************************************************/
void addItemListBaseProperties(void);
/*!
\brief
Add given window to child list at an appropriate position
*/
virtual void addChild_impl(Window* wnd);
/*!
\brief
Handler to manage items being removed from the content pane.
If there is one!
*/
bool handle_PaneChildRemoved(const EventArgs& e);
};
} // End of CEGUI namespace section
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // end of guard _CEGUIItemListBase_h_
|