1 /***********************************************************************
2 	created:	13/4/2004
3 	author:		Paul D Turner
4 
5 	purpose:	Interface to base class for MultiColumnList widget
6 *************************************************************************/
7 /***************************************************************************
8  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  *   Permission is hereby granted, free of charge, to any person obtaining
11  *   a copy of this software and associated documentation files (the
12  *   "Software"), to deal in the Software without restriction, including
13  *   without limitation the rights to use, copy, modify, merge, publish,
14  *   distribute, sublicense, and/or sell copies of the Software, and to
15  *   permit persons to whom the Software is furnished to do so, subject to
16  *   the following conditions:
17  *
18  *   The above copyright notice and this permission notice shall be
19  *   included in all copies or substantial portions of the Software.
20  *
21  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  *   OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIMultiColumnList_h_
30 #define _CEGUIMultiColumnList_h_
31 
32 #include "../Base.h"
33 #include "../Window.h"
34 #include "./ListHeader.h"
35 
36 #if defined(_MSC_VER)
37 #	pragma warning(push)
38 #	pragma warning(disable : 4251)
39 #endif
40 
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
46 /*!
47 \brief
48 	Simple grid index structure.
49 */
50 struct CEGUIEXPORT MCLGridRef
51 {
MCLGridRefMCLGridRef52 	MCLGridRef(uint r, uint c) : row(r), column(c) {}
53 
54 	uint	row;		//!< Zero based row index.
55 	uint	column;		//!< Zero based column index.
56 
57 	// operators
58 	MCLGridRef& operator=(const MCLGridRef& rhs);
59 	bool operator<(const MCLGridRef& rhs) const;
60 	bool operator<=(const MCLGridRef& rhs) const;
61 	bool operator>(const MCLGridRef& rhs) const;
62 	bool operator>=(const MCLGridRef& rhs) const;
63 	bool operator==(const MCLGridRef& rhs) const;
64 	bool operator!=(const MCLGridRef& rhs) const;
65 };
66 
67 /*!
68 \brief
69     Base class for the multi column list window renderer.
70 */
71 class CEGUIEXPORT MultiColumnListWindowRenderer : public WindowRenderer
72 {
73 public:
74     /*!
75     \brief
76         Constructor
77     */
78     MultiColumnListWindowRenderer(const String& name);
79 
80     /*!
81     \brief
82         Return a Rect object describing, in un-clipped pixels, the window relative area
83         that is to be used for rendering list items.
84 
85     \return
86         Rect object describing the area of the Window to be used for rendering
87         list box items.
88     */
89     virtual Rectf getListRenderArea(void) const = 0;
90 };
91 
92 /*!
93 \brief
94 	Base class for the multi column list widget.
95 */
96 class CEGUIEXPORT MultiColumnList : public Window
97 {
98 public:
99 	static const String EventNamespace;				//!< Namespace for global events
100     static const String WidgetTypeName;             //!< Window factory name
101 
102 	/*************************************************************************
103 		Constants
104 	*************************************************************************/
105 	// Event names
106     /** Event fired when the selection mode for the list box changes.
107      * Handlers are passed a const WindowEventArgs reference with
108      * WindowEventArgs::window set to the MultiColumnList whose selection mode
109      * has been changed.
110      */
111 	static const String EventSelectionModeChanged;
112     /** Event fired when the nominated select column changes.
113      * Handlers are passed a const WindowEventArgs reference with
114      * WindowEventArgs::window set to the MultiColumnList whose nominated
115      * selection column has been changed.
116      */
117 	static const String EventNominatedSelectColumnChanged;
118     /** Event fired when the nominated select row changes.
119      * Handlers are passed a const WindowEventArgs reference with
120      * WindowEventArgs::window set to the MultiColumnList whose nominated
121      * selection row has been changed.
122      */
123 	static const String EventNominatedSelectRowChanged;
124     /** Event fired when the vertical scroll bar 'force' setting changes.
125      * Handlers are passed a const WindowEventArgs reference with
126      * WindowEventArgs::window set to the MultiColumnList whose vertical scroll
127      * bar mode has been changed.
128      */
129 	static const String EventVertScrollbarModeChanged;
130     /** Event fired when the horizontal scroll bar 'force' setting changes.
131      * Handlers are passed a const WindowEventArgs reference with
132      * WindowEventArgs::window set to the MultiColumnList whose horizontal
133      * scroll bar mode has been changed.
134      */
135 	static const String EventHorzScrollbarModeChanged;
136     /** Event fired when the current selection(s) within the list box changes.
137      * Handlers are passed a const WindowEventArgs reference with
138      * WindowEventArgs::window set to the MultiColumnList whose current
139      * selection has changed.
140      */
141 	static const String EventSelectionChanged;
142     /** Event fired when the contents of the list box changes.
143      * Handlers are passed a const WindowEventArgs reference with
144      * WindowEventArgs::window set to the MultiColumnList whose contents has
145      * changed.
146      */
147 	static const String EventListContentsChanged;
148     /** Event fired when the sort column changes.
149      * Handlers are passed a const WindowEventArgs reference with
150      * WindowEventArgs::window set to the MultiColumnList whose sort column has
151      * been changed.
152      */
153 	static const String EventSortColumnChanged;
154     /** Event fired when the sort direction changes.
155      * Handlers are passed a const WindowEventArgs reference with
156      * WindowEventArgs::window set to the MultiColumnList whose sort direction
157      * has been changed.
158      */
159 	static const String EventSortDirectionChanged;
160     /** Event fired when the width of a column in the list changes.
161      * Handlers are passed a const WindowEventArgs reference with
162      * WindowEventArgs::window set to the MultiColumnList for which a column
163      * width has changed.
164      */
165 	static const String EventListColumnSized;
166     /** Event fired when the column order changes.
167      * Handlers are passed a const WindowEventArgs reference with
168      * WindowEventArgs::window set to the MultiColumnList for which the order
169      * of columns has been changed.
170      */
171 	static const String EventListColumnMoved;
172 
173     /*************************************************************************
174         Child Widget name constants
175     *************************************************************************/
176     static const String VertScrollbarName;   //!< Widget name for the vertical scrollbar component.
177     static const String HorzScrollbarName;   //!< Widget name for the horizontal scrollbar component.
178     static const String ListHeaderName;      //!< Widget name for the list header component.
179 
180 	/*************************************************************************
181 		Enumerations
182 	*************************************************************************/
183 	/*!
184 	\brief
185 		Enumerated values for the selection modes possible with a Multi-column list
186 	*/
187 	enum SelectionMode
188 	{
189 		RowSingle,					// Any single row may be selected.  All items in the row are selected.
190 		RowMultiple,				// Multiple rows may be selected.  All items in the row are selected.
191 		CellSingle,					// Any single cell may be selected.
192 		CellMultiple,				// Multiple cells bay be selected.
193 		NominatedColumnSingle,		// Any single item in a nominated column may be selected.
194 		NominatedColumnMultiple,	// Multiple items in a nominated column may be selected.
195 		ColumnSingle,				// Any single column may be selected.  All items in the column are selected.
196 		ColumnMultiple,				// Multiple columns may be selected.  All items in the column are selected.
197 		NominatedRowSingle,			// Any single item in a nominated row may be selected.
198 		NominatedRowMultiple		// Multiple items in a nominated row may be selected.
199 	};
200 
201 
202 	/*************************************************************************
203 		Accessor Methods
204 	*************************************************************************/
205 	/*!
206 	\brief
207 		Return whether user manipulation of the sort column and direction are enabled.
208 
209 	\return
210 		true if the user may interactively modify the sort column and direction.  false if the user may not
211 		modify the sort column and direction (these can still be set programmatically).
212 	*/
213 	bool	isUserSortControlEnabled(void) const;
214 
215 
216 	/*!
217 	\brief
218 		Return whether the user may size column segments.
219 
220 	\return
221 		true if the user may interactively modify the width of columns, false if they may not.
222 	*/
223 	bool	isUserColumnSizingEnabled(void) const;
224 
225 
226 	/*!
227 	\brief
228 		Return whether the user may modify the order of the columns.
229 
230 	\return
231 		true if the user may interactively modify the order of the columns, false if they may not.
232 	*/
233 	bool	isUserColumnDraggingEnabled(void) const;
234 
235 
236 	/*!
237 	\brief
238 		Return the number of columns in the multi-column list
239 
240 	\return
241 		uint value equal to the number of columns in the list.
242 	*/
243 	uint	getColumnCount(void) const;
244 
245 
246 	/*!
247 	\brief
248 		Return the number of rows in the multi-column list.
249 
250 	\return
251 		uint value equal to the number of rows currently in the list.
252 	*/
253 	uint	getRowCount(void) const;
254 
255 
256 	/*!
257 	\brief
258 		Return the zero based index of the current sort column.  There must be at least one column to successfully call this
259 		method.
260 
261 	\return
262 		Zero based column index that is the current sort column.
263 
264 	\exception	InvalidRequestException		thrown if there are no columns in this multi column list.
265 	*/
266 	uint	getSortColumn(void) const;
267 	uint	getSortColumnID(void) const;
268 
269 	/*!
270 	\brief
271 		Return the zero based column index of the column with the specified ID.
272 
273 	\param col_id
274 		ID code of the column whos index is to be returned.
275 
276 	\return
277 		Zero based column index of the first column whos ID matches \a col_id.
278 
279 	\exception	InvalidRequestException		thrown if no attached column has the requested ID.
280 	*/
281 	uint	getColumnWithID(uint col_id) const;
282 
283 
284 	/*!
285 	\brief
286 		Return the zero based index of the column whos header text matches the specified text.
287 
288 	\param text
289 		String object containing the text to be searched for.
290 
291 	\return
292 		Zero based column index of the column whos header has the specified text.
293 
294 	\exception InvalidRequestException	thrown if no columns header has the requested text.
295 	*/
296 	uint	getColumnWithHeaderText(const String& text) const;
297 
298 
299 	/*!
300 	\brief
301 		Return the total width of all column headers.
302 
303 	\return
304 		Sum total of all the column header widths as a UDim.
305 	*/
306 	UDim getTotalColumnHeadersWidth(void) const;
307 
308 
309 	/*!
310 	\brief
311 		Return the width of the specified column header (and therefore the column itself).
312 
313 	\param col_idx
314 		Zero based column index of the column whos width is to be returned.
315 
316 	\return
317 		Width of the column header at the zero based column index specified by \a col_idx, as a UDim
318 
319 	\exception InvalidRequestException	thrown if \a column is out of range.
320 	*/
321 	UDim getColumnHeaderWidth(uint col_idx) const;
322 
323 
324 	/*!
325 	\brief
326 		Return the currently set sort direction.
327 
328 	\return
329 		One of the ListHeaderSegment::SortDirection enumerated values specifying the current sort direction.
330 	*/
331 	ListHeaderSegment::SortDirection	getSortDirection(void) const;
332 
333 
334 	/*!
335 	\brief
336 		Return the ListHeaderSegment object for the specified column
337 
338 	\param col_idx
339 		zero based index of the column whos ListHeaderSegment is to be returned.
340 
341 	\return
342 		ListHeaderSegment object for the column at the requested index.
343 
344 	\exception InvalidRequestException	thrown if \a col_idx is out of range.
345 	*/
346 	ListHeaderSegment&	getHeaderSegmentForColumn(uint col_idx) const;
347 
348 
349 	/*!
350 	\brief
351 		Return the zero based index of the Row that contains \a item.
352 
353 	\param item
354 		Pointer to the ListboxItem that the row index is to returned for.
355 
356 	\return
357 		Zero based index of the row that contains ListboxItem \a item.
358 
359 	\exception InvalidRequestException	thrown if \a item is not attached to the list box.
360 	*/
361 	uint	getItemRowIndex(const ListboxItem* item) const;
362 
363 
364 	/*!
365 	\brief
366 		Return the current zero based index of the column that contains \a item.
367 
368 	\param item
369 		Pointer to the ListboxItem that the column index is to returned for.
370 
371 	\return
372 		Zero based index of the column that contains ListboxItem \a item.
373 
374 	\exception InvalidRequestException	thrown if \a item is not attached to the list box.
375 	*/
376 	uint	getItemColumnIndex(const ListboxItem* item) const;
377 
378 
379 	/*!
380 	\brief
381 		Return the grid reference for \a item.
382 
383 	\param item
384 		Pointer to the ListboxItem whos current grid reference is to be returned.
385 
386 	\return
387 		MCLGridRef object describing the current grid reference of ListboxItem \a item.
388 
389 	\exception InvalidRequestException	thrown if \a item is not attached to the list box.
390 	*/
391 	MCLGridRef	getItemGridReference(const ListboxItem* item) const;
392 
393 
394 	/*!
395 	\brief
396 		Return a pointer to the ListboxItem at the specified grid reference.
397 
398 	\param grid_ref
399 		MCLGridRef object that describes the position of the ListboxItem to be returned.
400 
401 	\return
402 		Pointer to the ListboxItem at grid reference \a grid_ref.
403 
404 	\exception InvalidRequestException	thrown if \a grid_ref is invalid for this list box.
405 	*/
406 	ListboxItem*	getItemAtGridReference(const MCLGridRef& grid_ref) const;
407 
408 
409 	/*!
410 	\brief
411 		return whether ListboxItem \a item is attached to the column at index \a col_idx.
412 
413 	\param item
414 		Pointer to the ListboxItem to look for.
415 
416 	\param col_idx
417 		Zero based index of the column that is to be searched.
418 
419 	\return
420 		- true if \a item is attached to list box column \a col_idx.
421 		- false if \a item is not attached to list box column \a col_idx.
422 
423 	\exception InvalidRequestException	thrown if \a col_idx is out of range.
424 	*/
425 	bool	isListboxItemInColumn(const ListboxItem* item, uint col_idx) const;
426 
427 
428 	/*!
429 	\brief
430 		return whether ListboxItem \a item is attached to the row at index \a row_idx.
431 
432 	\param item
433 		Pointer to the ListboxItem to look for.
434 
435 	\param row_idx
436 		Zero based index of the row that is to be searched.
437 
438 	\return
439 		- true if \a item is attached to list box row \a row_idx.
440 		- false if \a item is not attached to list box row \a row_idx.
441 
442 	\exception InvalidRequestException	thrown if \a row_idx is out of range.
443 	*/
444 	bool	isListboxItemInRow(const ListboxItem* item, uint row_idx) const;
445 
446 
447 	/*!
448 	\brief
449 		return whether ListboxItem \a item is attached to the list box.
450 
451 	\param item
452 		Pointer to the ListboxItem to look for.
453 
454 	\return
455 		- true if \a item is attached to list box.
456 		- false if \a item is not attached to list box.
457 	*/
458 	bool	isListboxItemInList(const ListboxItem* item) const;
459 
460 
461 	/*!
462 	\brief
463 		Return the ListboxItem in column \a col_idx that has the text string \a text.
464 
465 	\param text
466 		String object containing the text to be searched for.
467 
468 	\param col_idx
469 		Zero based index of the column to be searched.
470 
471 	\param start_item
472 		Pointer to the ListboxItem where the exclusive search is to start, or NULL to search from the top of the column.
473 
474 	\return
475 		Pointer to the first ListboxItem in column \a col_idx, after \a start_item, that has the string \a text.
476 
477 	\exception InvalidRequestException	thrown if \a start_item is not attached to the list box, or if \a col_idx is out of range.
478 	*/
479 	ListboxItem*	findColumnItemWithText(const String& text, uint col_idx, const ListboxItem* start_item) const;
480 
481 
482 	/*!
483 	\brief
484 		Return the ListboxItem in row \a row_idx that has the text string \a text.
485 
486 	\param text
487 		String object containing the text to be searched for.
488 
489 	\param row_idx
490 		Zero based index of the row to be searched.
491 
492 	\param start_item
493 		Pointer to the ListboxItem where the exclusive search is to start, or NULL to search from the start of the row.
494 
495 	\return
496 		Pointer to the first ListboxItem in row \a row_idx, after \a start_item, that has the string \a text.
497 
498 	\exception InvalidRequestException	thrown if \a start_item is not attached to the list box, or if \a row_idx is out of range.
499 	*/
500 	ListboxItem*	findRowItemWithText(const String& text, uint row_idx, const ListboxItem* start_item) const;
501 
502 
503 	/*!
504 	\brief
505 		Return the ListboxItem that has the text string \a text.
506 
507 	\note
508 		List box searching progresses across the columns in each row.
509 
510 	\param text
511 		String object containing the text to be searched for.
512 
513 	\param start_item
514 		Pointer to the ListboxItem where the exclusive search is to start, or NULL to search the whole list box.
515 
516 	\return
517 		Pointer to the first ListboxItem, after \a start_item, that has the string \a text.
518 
519 	\exception InvalidRequestException	thrown if \a start_item is not attached to the list box.
520 	*/
521 	ListboxItem*	findListItemWithText(const String& text, const ListboxItem* start_item) const;
522 
523 
524 	/*!
525 	\brief
526 		Return a pointer to the first selected ListboxItem attached to this list box.
527 
528 	\note
529 		List box searching progresses across the columns in each row.
530 
531 	\return
532 		Pointer to the first ListboxItem attached to this list box that is selected, or NULL if no item is selected.
533 	*/
534 	ListboxItem*	getFirstSelectedItem(void) const;
535 
536 
537 	/*!
538 	\brief
539 		Return a pointer to the next selected ListboxItem after \a start_item.
540 
541 	\note
542 		List box searching progresses across the columns in each row.
543 
544 	\param start_item
545 		Pointer to the ListboxItem where the exclusive search is to start, or NULL to search the whole list box.
546 
547 	\return
548 		Pointer to the first selected ListboxItem attached to this list box, after \a start_item, or NULL if no item is selected.
549 
550 	\exception InvalidRequestException	thrown if \a start_item is not attached to the list box.
551 	*/
552 	ListboxItem*	getNextSelected(const ListboxItem* start_item) const;
553 
554 
555 	/*!
556 	\brief
557 		Return the number of selected ListboxItems attached to this list box.
558 
559 	return
560 		uint value equal to the number of ListboxItems attached to this list box that are currently selected.
561 	*/
562 	uint	getSelectedCount(void) const;
563 
564 
565 	/*!
566 	\brief
567 		Return whether the ListboxItem at \a grid_ref is selected.
568 
569 	\param grid_ref
570 		MCLGridRef object describing the grid reference that is to be examined.
571 
572 	\return
573 		- true if there is a ListboxItem at \a grid_ref and it is selected.
574 		- false if there is no ListboxItem at \a grid_ref, or if the item is not selected.
575 
576 	\exception InvalidRequestException	thrown if \a grid_ref contains an invalid grid position.
577 	*/
578 	bool	isItemSelected(const MCLGridRef& grid_ref) const;
579 
580 
581 	/*!
582 	\brief
583 		Return the ID of the currently set nominated selection column to be used when in one of the NominatedColumn*
584 		selection modes. There must be at least one column to successfully call this method.
585 
586 	\note
587 		You should only ever call this when getColumnCount() returns > 0.
588 
589 	\return
590 		ID code of the nominated selection column.
591 	*/
592 	uint	getNominatedSelectionColumnID(void) const;
593 
594 
595 	/*!
596 	\brief
597 		Return the index of the currently set nominated selection column to be used when in one of the NominatedColumn*
598 		selection modes.
599 
600 	\return
601 		Zero based index of the nominated selection column.
602 	*/
603 	uint	getNominatedSelectionColumn(void) const;
604 
605 
606 	/*!
607 	\brief
608 		Return the index of the currently set nominated selection row to be used when in one of the NominatedRow*
609 		selection modes.
610 
611 	\return
612 		Zero based index of the nominated selection column.
613 	*/
614 	uint	getNominatedSelectionRow(void) const;
615 
616 
617 	/*!
618 	\brief
619 		Return the currently set selection mode.
620 
621 	\return
622 		One of the MultiColumnList::SelectionMode enumerated values specifying the current selection mode.
623 	*/
624 	MultiColumnList::SelectionMode	getSelectionMode(void) const;
625 
626 
627 	/*!
628 	\brief
629 		Return whether the vertical scroll bar is always shown.
630 
631 	\return
632 		- true if the scroll bar will always be shown even if it is not required.
633 		- false if the scroll bar will only be shown when it is required.
634 	*/
635 	bool	isVertScrollbarAlwaysShown(void) const;
636 
637 
638 	/*!
639 	\brief
640 		Return whether the horizontal scroll bar is always shown.
641 
642 	\return
643 		- true if the scroll bar will always be shown even if it is not required.
644 		- false if the scroll bar will only be shown when it is required.
645 	*/
646 	bool	isHorzScrollbarAlwaysShown(void) const;
647 
648 
649 	/*!
650 	\brief
651 		Return the ID code assigned to the requested column.
652 
653 	\param col_idx
654 		Zero based index of the column whos ID code is to be returned.
655 
656 	\return
657 		Current ID code assigned to the column at the requested index.
658 
659 	\exception InvalidRequestException	thrown if \a col_idx is out of range
660 	*/
661 	uint	getColumnID(uint col_idx) const;
662 
663 
664 	/*!
665 	\brief
666 		Return the ID code assigned to the requested row.
667 
668 	\param row_idx
669 		Zero based index of the row who's ID code is to be returned.
670 
671 	\return
672 		Current ID code assigned to the row at the requested index.
673 
674 	\exception InvalidRequestException	thrown if \a row_idx is out of range
675 	*/
676 	uint	getRowID(uint row_idx) const;
677 
678 
679 	/*!
680 	\brief
681 		Return the zero based row index of the row with the specified ID.
682 
683 	\param row_id
684 		ID code of the row who's index is to be returned.
685 
686 	\return
687 		Zero based row index of the first row who's ID matches \a row_id.
688 
689 	\exception	InvalidRequestException		thrown if no row has the requested ID.
690 	*/
691 	uint	getRowWithID(uint row_id) const;
692 
693 
694     /*!
695     \brief
696         Return a Rect object describing, in un-clipped pixels, the window relative area
697         that is to be used for rendering list items.
698 
699     \return
700         Rect object describing the area of the Window to be used for rendering
701         list box items.
702     */
703     Rectf getListRenderArea(void) const;
704 
705 
706     /*!
707     \brief
708         Return a pointer to the vertical scrollbar component widget for this
709         MultiColumnList.
710 
711     \return
712         Pointer to a Scrollbar object.
713 
714     \exception UnknownObjectException
715         Thrown if the vertical Scrollbar component does not exist.
716     */
717     Scrollbar* getVertScrollbar() const;
718 
719     /*!
720     \brief
721         Return a pointer to the horizontal scrollbar component widget for this
722         MultiColumnList.
723 
724     \return
725         Pointer to a Scrollbar object.
726 
727     \exception UnknownObjectException
728         Thrown if the horizontal Scrollbar component does not exist.
729     */
730     Scrollbar* getHorzScrollbar() const;
731 
732     /*!
733     \brief
734         Return a pointer to the list header component widget for this
735         MultiColumnList.
736 
737     \return
738         Pointer to a ListHeader object.
739 
740     \exception UnknownObjectException
741         Thrown if the list header component does not exist.
742     */
743     ListHeader* getListHeader() const;
744 
745     /*!
746     \brief
747         Return the sum of all row heights in pixels.
748     */
749     float   getTotalRowsHeight(void) const;
750 
751     /*!
752     \brief
753         Return the pixel width of the widest item in the given column
754     */
755     float   getWidestColumnItemWidth(uint col_idx) const;
756 
757     /*!
758     \brief
759         Return, in pixels, the height of the highest item in the given row.
760     */
761     float   getHighestRowItemHeight(uint row_idx) const;
762 
763     /*!
764     \brief
765         Get whether or not column auto-sizing (autoSizeColumnHeader()) will use
766         the list header segment size.
767 
768     \return
769         Return true if the header segment will be included in the width
770         calculation.
771     */
772     bool getAutoSizeColumnUsesHeader() const;
773 
774 	/*************************************************************************
775 		Manipulator Methods
776 	*************************************************************************/
777 	/*!
778 	\brief
779 		Initialise the Window based object ready for use.
780 
781 	\note
782 		This must be called for every window created.  Normally this is handled automatically by the WindowFactory for each Window type.
783 
784 	\return
785 		Nothing
786 	*/
787 	virtual void	initialiseComponents(void);
788 
789 
790 	/*!
791 	\brief
792 		Remove all items from the list.
793 
794 		Note that this will cause 'AutoDelete' items to be deleted.
795 	*/
796 	void	resetList(void);
797 
798 
799 	/*!
800 	\brief
801 		Add a column to the list box.
802 
803 	\param text
804 		String object containing the text label for the column header.
805 
806 	\param col_id
807 		ID code to be assigned to the column header.
808 
809 	\param width
810 		UDim describing the initial width to be set for the column.
811 
812 	\return
813 		Nothing.
814 	*/
815 	void	addColumn(const String& text, uint col_id, const UDim& width);
816 	void	addColumn(const String& value);
817 
818 	/*!
819 	\brief
820 		Insert a new column in the list.
821 
822 	\param text
823 		String object containing the text label for the column header.
824 
825 	\param col_id
826 		ID code to be assigned to the column header.
827 
828 	\param width
829 		UDim describing the initial width to be set for the column.
830 
831 	\param position
832 		Zero based index where the column is to be inserted.  If this is greater than the current
833 		number of columns, the new column is inserted at the end.
834 
835 	\return
836 		Nothing.
837 	*/
838 	void	insertColumn(const String& text, uint col_id, const UDim& width, uint position);
839 
840 
841 	/*!
842 	\brief
843 		Removes a column from the list box.  This will cause any ListboxItem using the autoDelete option in the column to be deleted.
844 
845 	\param col_idx
846 		Zero based index of the column to be removed.
847 
848 	\return
849 		Nothing.
850 
851 	\exception InvalidRequestException	thrown if \a col_idx is invalid.
852 	*/
853 	void	removeColumn(uint col_idx);
854 
855 
856 	/*!
857 	\brief
858 		Removes a column from the list box.  This will cause any ListboxItem using the autoDelete option in the column to be deleted.
859 
860 	\param col_id
861 		ID code of the column to be deleted.
862 
863 	\return
864 		Nothing.
865 
866 	\exception InvalidRequestException	thrown if no column with \a col_id is available on this list box.
867 	*/
868 	void	removeColumnWithID(uint col_id);
869 
870 
871 	/*!
872 	\brief
873 		Move the column at index \a col_idx so it is at index \a position.
874 
875 	\param col_idx
876 		Zero based index of the column to be moved.
877 
878 	\param position
879 		Zero based index of the new position for the column.
880 
881 	\return
882 		Nothing.
883 
884 	\exception InvalidRequestException	thrown if \a col_idx is invalid.
885 	*/
886 	void	moveColumn(uint col_idx, uint position);
887 
888 
889 	/*!
890 	\brief
891 		Move the column with ID \a col_id so it is at index \a position.
892 
893 	\param col_id
894 		ID code of the column to be moved.
895 
896 	\param position
897 		Zero based index of the new position for the column.
898 
899 	\return
900 		Nothing.
901 
902 	\exception InvalidRequestException	thrown if no column with \a col_id is available on this list box.
903 	*/
904 	void	moveColumnWithID(uint col_id, uint position);
905 
906 
907 	/*!
908 	\brief
909 		Add an empty row to the list box.
910 
911 	\param row_id
912 		ID code to be assigned to the new row.
913 
914 	\note
915 		If the list is being sorted, the new row will appear at an appropriate position according to the sorting being
916 		applied.  If no sorting is being done, the new row will appear at the bottom of the list.
917 
918 	\return
919 		Initial zero based index of the new row.
920 	*/
921 	uint	addRow(uint row_id = 0);
922 
923 
924 	/*!
925 	\brief
926 		Add a row to the list box, and set the item in the column with ID \a col_id to \a item.
927 
928 	\note
929 		If the list is being sorted, the new row will appear at an appropriate position according to the sorting being
930 		applied.  If no sorting is being done, the new row will appear at the bottom of the list.
931 
932 	\param item
933 		Pointer to a ListboxItem to be used as the initial contents for the column with ID \a col_id.
934 
935 	\param col_id
936 		ID code of the column whos initial item is to be set to \a item.
937 
938 	\param row_id
939 		ID code to be assigned to the new row.
940 
941 	\return
942 		Initial zero based index of the new row.
943 
944 	\exception InvalidRequestException	thrown if no column with the specified ID is attached to the list box.
945 	*/
946 	uint	addRow(ListboxItem* item, uint col_id, uint row_id = 0);
947 
948 
949 	/*!
950 	\brief
951 		Insert an empty row into the list box.
952 
953 	\note
954 		If the list is being sorted, the new row will appear at an appropriate position according to the sorting being
955 		applied.  If no sorting is being done, the new row will appear at the specified index.
956 
957 	\param row_idx
958 		Zero based index where the row should be inserted.  If this is greater than the current number of rows, the row is
959 		appended to the list.
960 
961 	\param row_id
962 		ID code to be assigned to the new row.
963 
964 	\return
965 		Zero based index where the row was actually inserted.
966 	*/
967 	uint	insertRow(uint row_idx, uint row_id = 0);
968 
969 
970 	/*!
971 	\brief
972 		Insert a row into the list box, and set the item in the column with ID \a col_id to \a item.
973 
974 	\note
975 		If the list is being sorted, the new row will appear at an appropriate position according to the sorting being
976 		applied.  If no sorting is being done, the new row will appear at the specified index.
977 
978 	\param item
979 		Pointer to a ListboxItem to be used as the initial contents for the column with ID \a col_id.
980 
981 	\param col_id
982 		ID code of the column whos initial item is to be set to \a item.
983 
984 	\param row_idx
985 		Zero based index where the row should be inserted.  If this is greater than the current number of rows, the row is
986 		appended to the list.
987 
988 	\param row_id
989 		ID code to be assigned to the new row.
990 
991 	\return
992 		Zero based index where the row was actually inserted.
993 
994 	\exception InvalidRequestException	thrown if no column with the specified ID is attached to the list box.
995 	*/
996 	uint	insertRow(ListboxItem* item, uint col_id, uint row_idx, uint row_id = 0);
997 
998 
999 	/*!
1000 	\brief
1001 		Remove the list box row with index \a row_idx.  Any ListboxItem in row \a row_idx using autoDelete mode will be deleted.
1002 
1003 	\param row_idx
1004 		Zero based index of the row to be removed.
1005 
1006 	\return
1007 		Nothing.
1008 
1009 	\exception InvalidRequestException	thrown if \a row_idx is invalid.
1010 	*/
1011 	void	removeRow(uint row_idx);
1012 
1013 
1014 	/*!
1015 	\brief
1016 		Set the ListboxItem for grid reference \a position.
1017 
1018 	\param item
1019 		Pointer to the ListboxItem to be set at \a position.
1020 
1021 	\param position
1022 		MCLGridRef describing the grid reference of the item to be set.
1023 
1024 	\return
1025 		Nothing.
1026 
1027 	\exception InvalidRequestException	thrown if \a position contains an invalid grid reference.
1028 	*/
1029 	void	setItem(ListboxItem* item, const MCLGridRef& position);
1030 
1031 
1032 	/*!
1033 	\brief
1034 		Set the ListboxItem for the column with ID \a col_id in row \a row_idx.
1035 
1036 	\param item
1037 		Pointer to the ListboxItem to be set into the list.
1038 
1039 	\param col_id
1040 		ID code of the column to receive \a item.
1041 
1042 	\param row_idx
1043 		Zero based index of the row to receive \a item.
1044 
1045 	\return
1046 		Nothing.
1047 
1048 	\exception InvalidRequestException	thrown if no column with ID \a col_id exists, or of \a row_idx is out of range.
1049 	*/
1050 	void	setItem(ListboxItem* item, uint col_id, uint row_idx);
1051 
1052 
1053 	/*!
1054 	\brief
1055 		Set the selection mode for the list box.
1056 
1057 	\param sel_mode
1058 		One of the MultiColumnList::SelectionMode enumerated values specifying the selection mode to be used.
1059 
1060 	\return
1061 		Nothing.
1062 
1063 	\exception	InvalidRequestException	thrown if the value specified for \a sel_mode is invalid.
1064 	*/
1065 	void	setSelectionMode(MultiColumnList::SelectionMode sel_mode);
1066 
1067 
1068 	/*!
1069 	\brief
1070 		Set the column to be used for the NominatedColumn* selection modes.
1071 
1072 	\param	col_id
1073 		ID code of the column to be used in NominatedColumn* selection modes.
1074 
1075 	\return
1076 		Nothing.
1077 
1078 	\exception InvalidRequestException	thrown if no column has ID code \a col_id.
1079 	*/
1080 	void	setNominatedSelectionColumnID(uint col_id);
1081 
1082 
1083 	/*!
1084 	\brief
1085 		Set the column to be used for the NominatedColumn* selection modes.
1086 
1087 	\param	col_idx
1088 		zero based index of the column to be used in NominatedColumn* selection modes.
1089 
1090 	\return
1091 		Nothing.
1092 
1093 	\exception InvalidRequestException	thrown if \a col_idx is out of range.
1094 	*/
1095 	void	setNominatedSelectionColumn(uint col_idx);
1096 
1097 
1098 	/*!
1099 	\brief
1100 		Set the row to be used for the NominatedRow* selection modes.
1101 
1102 	\param	row_idx
1103 		zero based index of the row to be used in NominatedRow* selection modes.
1104 
1105 	\return
1106 		Nothing.
1107 
1108 	\exception InvalidRequestException	thrown if \a row_idx is out of range.
1109 	*/
1110 	void	setNominatedSelectionRow(uint row_idx);
1111 
1112 
1113 	/*!
1114 	\brief
1115 		Set the sort direction to be used.
1116 
1117 	\param direction
1118 		One of the ListHeaderSegment::SortDirection enumerated values specifying the sort direction to be used.
1119 
1120 	\return
1121 		Nothing.
1122 	*/
1123 	void	setSortDirection(ListHeaderSegment::SortDirection direction);
1124 
1125 
1126 	/*!
1127 	\brief
1128 		Set the column to be used as the sort key.
1129 
1130 	\param col_idx
1131 		Zero based index of the column to use as the key when sorting the list items.
1132 
1133 	\return
1134 		Nothing.
1135 
1136 	\exception InvalidRequestException	thrown if col_idx is out of range.
1137 	*/
1138 	void	setSortColumn(uint col_idx);
1139 
1140 
1141 	/*!
1142 	\brief
1143 		Set the column to be used as the sort key.
1144 
1145 	\param col_id
1146 		ID code of the column to use as the key when sorting the list items.
1147 
1148 	\return
1149 		Nothing.
1150 
1151 	\exception InvalidRequestException	thrown if col_id is invalid for this list box.
1152 	*/
1153 	void	setSortColumnByID(uint col_id);
1154 
1155 
1156 	/*!
1157 	\brief
1158 		Set whether the vertical scroll bar should always be shown, or just when needed.
1159 
1160 	\param setting
1161 		- true to have the vertical scroll bar shown at all times.
1162 		- false to have the vertical scroll bar appear only when needed.
1163 
1164 	\return
1165 		Nothing.
1166 	*/
1167 	void	setShowVertScrollbar(bool setting);
1168 
1169 
1170 	/*!
1171 	\brief
1172 		Set whether the horizontal scroll bar should always be shown, or just when needed.
1173 
1174 	\param setting
1175 		- true to have the horizontal scroll bar shown at all times.
1176 		- false to have the horizontal scroll bar appear only when needed.
1177 
1178 	\return
1179 		Nothing.
1180 	*/
1181 	void	setShowHorzScrollbar(bool setting);
1182 
1183 
1184 	/*!
1185 	\brief
1186 		Removed the selected state from any currently selected ListboxItem attached to the list.
1187 
1188 	\return
1189 		Nothing.
1190 	*/
1191 	void	clearAllSelections(void);
1192 
1193 
1194 	/*!
1195 	\brief
1196 		Sets or clears the selected state of the given ListboxItem which must be attached to the list.
1197 
1198 	\note
1199 		Depending upon the current selection mode, this may cause other items to be selected, other
1200 		items to be deselected, or for nothing to actually happen at all.
1201 
1202 	\param item
1203 		Pointer to the attached ListboxItem to be affected.
1204 
1205 	\param state
1206 		- true to put the ListboxItem into the selected state.
1207 		- false to put the ListboxItem into the de-selected state.
1208 
1209 	\return
1210 		Nothing.
1211 
1212 	\exception InvalidRequestException	thrown if \a item is not attached to the list box.
1213 	*/
1214 	void	setItemSelectState(ListboxItem* item, bool state);
1215 
1216 
1217 	/*!
1218 	\brief
1219 		Sets or clears the selected state of the ListboxItem at the given grid reference.
1220 
1221 	\note
1222 		Depending upon the current selection mode, this may cause other items to be selected, other
1223 		items to be deselected, or for nothing to actually happen at all.
1224 
1225 	\param grid_ref
1226 		MCLGridRef object describing the position of the item to be affected.
1227 
1228 	\param state
1229 		- true to put the ListboxItem into the selected state.
1230 		- false to put the ListboxItem into the de-selected state.
1231 
1232 	\return
1233 		Nothing.
1234 
1235 	\exception InvalidRequestException	thrown if \a grid_ref is invalid for this list box.
1236 	*/
1237 	void	setItemSelectState(const MCLGridRef& grid_ref, bool state);
1238 
1239 
1240 	/*!
1241 	\brief
1242 		Inform the list box that one or more attached ListboxItems have been externally modified, and
1243 		the list should re-sync its internal state and refresh the display as needed.
1244 
1245 	\return
1246 		Nothing.
1247 	*/
1248 	void	handleUpdatedItemData(void);
1249 
1250 
1251 	/*!
1252 	\brief
1253 		Set the width of the specified column header (and therefore the column itself).
1254 
1255 	\param col_idx
1256 		Zero based column index of the column whos width is to be set.
1257 
1258 	\param width
1259 		UDim value specifying the new width for the column.
1260 
1261 	\return
1262 		Nothing.
1263 
1264 	\exception InvalidRequestException	thrown if \a column is out of range.
1265 	*/
1266 	void	setColumnHeaderWidth(uint col_idx, const UDim& width);
1267 
1268 
1269 	/*!
1270 	\brief
1271 		Set whether user manipulation of the sort column and direction are enabled.
1272 
1273 	\param setting
1274 		- true if the user may interactively modify the sort column and direction.
1275 		- false if the user may not modify the sort column and direction (these can still be set programmatically).
1276 
1277 	\return
1278 		Nothing.
1279 	*/
1280 	void	setUserSortControlEnabled(bool setting);
1281 
1282 
1283 	/*!
1284 	\brief
1285 		Set whether the user may size column segments.
1286 
1287 	\param setting
1288 		- true if the user may interactively modify the width of columns.
1289 		- false if the user may not change the width of the columns.
1290 
1291 	\return
1292 		Nothing.
1293 	*/
1294 	void	setUserColumnSizingEnabled(bool setting);
1295 
1296 
1297 	/*!
1298 	\brief
1299 		Set whether the user may modify the order of the columns.
1300 
1301 	\param setting
1302 		- true if the user may interactively modify the order of the columns.
1303 		- false if the user may not modify the order of the columns.
1304 	*/
1305 	void	setUserColumnDraggingEnabled(bool setting);
1306 
1307 
1308 	/*!
1309 	\brief
1310 		Automatically determines the "best fit" size for the specified column and sets
1311 		the column width to the same.
1312 
1313 	\param col_idx
1314 		Zero based index of the column to be sized.
1315 
1316 	\return
1317 		Nothing.
1318 
1319 	\exception InvalidRequestException	thrown if \a col_idx is out of range.
1320 	*/
1321 	void	autoSizeColumnHeader(uint col_idx);
1322 
1323 
1324 	/*!
1325 	\brief
1326 		Set the ID code assigned to a given row.
1327 
1328 	\param row_idx
1329 		Zero based index of the row who's ID code is to be set.
1330 
1331 	\param row_id
1332 		ID code to be assigned to the row at the requested index.
1333 
1334 	\return
1335 		Nothing.
1336 
1337 	\exception InvalidRequestException	thrown if \a row_idx is out of range
1338 	*/
1339 	void	setRowID(uint row_idx, uint row_id);
1340 
1341     /*!
1342     \brief
1343         Ensure the specified item is made visible within the multi-column
1344         listbox.
1345 
1346     \param item
1347         Pointer to the ListboxItem to be made visible in the multi-column
1348         listbox.
1349 
1350     \return
1351         Nothing.
1352 
1353     \exception  InvalidRequestException thrown if \a item is not attached to
1354                 this multicolumnlist.
1355     */
1356     void ensureItemIsVisible(const ListboxItem* item);
1357 
1358     /*!
1359     \brief
1360         Ensure the item at the specified grid coordinate is visible within the
1361         multi-column listbox.
1362 
1363     \param grid_ref
1364         MCLGridRef object holding the grid coordinate that is to be made
1365         visible.
1366 
1367     \return
1368         Nothing.
1369     */
1370     void ensureItemIsVisible(const MCLGridRef& grid_ref);
1371 
1372     /*!
1373     \brief
1374         Ensure that the row of the \a item is visible within the multi-column
1375         listbox.
1376 
1377     \note
1378         This doesn't necessarily make \a item visible.
1379 
1380     \param item
1381         Pointer to the ListboxItem whose row is to be made visible in the
1382         multi-column listbox.
1383 
1384     \return
1385         Nothing.
1386     */
1387     void ensureItemRowIsVisible(const ListboxItem* item);
1388 
1389     /*!
1390     \brief
1391         Ensure that the column of \a item is visible within the multi-column
1392         listbox.
1393 
1394     \note
1395         This doesn't necessarily make \a item visible.
1396 
1397     \param item
1398         Pointer to the ListboxItem whose column is to be made visible in the
1399         multi-column listbox.
1400 
1401     \return
1402         Nothing.
1403     */
1404     void ensureItemColumnIsVisible(const ListboxItem* item);
1405 
1406     /*!
1407     \brief
1408         Ensure that the row with index \a row_idx is visible within the
1409         multi-column listbox.
1410 
1411     \param row_id
1412         row_idx is the zero-based index of the row to be made visible.
1413 
1414     \return
1415         Nothing.
1416     */
1417     void ensureRowIsVisible(uint row_idx);
1418 
1419     /*!
1420     \brief
1421         Ensure that the column with ID \a column_idx is visible within the
1422         multi-column listbox.
1423 
1424     \param column_idx
1425         column_idx is the zero-based index of the column to be made visible.
1426 
1427     \return
1428         Nothing.
1429     */
1430     void ensureColumnIsVisible(uint column_idx);
1431 
1432     /*!
1433     \brief
1434         Instruct column auto-sizing (autoSizeColumnHeader()) to also use the
1435         list header segment size.
1436 
1437     \param include_header
1438         Whether method autoSizeColumnHeader() also should use the size of the
1439         column header segment.
1440 
1441     \return
1442         Nothing.
1443     */
1444     void setAutoSizeColumnUsesHeader(bool include_header);
1445 
1446 
1447 	/*************************************************************************
1448 		Construction and Destruction
1449 	*************************************************************************/
1450 	/*!
1451 	\brief
1452 		Constructor for the Multi-column list base class
1453 	*/
1454 	MultiColumnList(const String& type, const String& name);
1455 
1456 
1457 	/*!
1458 	\brief
1459 		Destructor for the multi-column list base class.
1460 	*/
1461 	virtual ~MultiColumnList(void);
1462 
1463 
1464 protected:
1465 	/*************************************************************************
1466 		Implementation Functions (abstract interface)
1467 	*************************************************************************/
1468 	/*!
1469 	\brief
1470 		Return a Rect object describing, in un-clipped pixels, the window relative area
1471 		that is to be used for rendering list items.
1472 
1473 	\return
1474 		Rect object describing the area of the Window to be used for rendering
1475 		list box items.
1476 	*/
1477 	//virtual	Rect	getListRenderArea_impl(void) const		= 0;
1478 
1479 
1480 	/*************************************************************************
1481 		Implementation Functions
1482 	*************************************************************************/
1483 	/*!
1484 	\brief
1485 		display required integrated scroll bars according to current state of the list box and update their values.
1486 	*/
1487 	void	configureScrollbars(void);
1488 
1489 
1490 	/*!
1491 	\brief
1492 		select all strings between positions \a start and \a end.  (inclusive).  Returns true if something was modified.
1493 	*/
1494 	bool	selectRange(const MCLGridRef& start, const MCLGridRef& end);
1495 
1496 
1497 	/*!
1498 	\brief
1499 		Clear the selected state for all items (implementation)
1500 
1501 	\return
1502 		true if some selections were cleared, false nothing was changed.
1503 	*/
1504 	bool	clearAllSelections_impl(void);
1505 
1506 
1507 	/*!
1508 	\brief
1509 		Return the ListboxItem under the given window local pixel co-ordinate.
1510 
1511 	\return
1512 		ListboxItem that is under window pixel co-ordinate \a pt, or NULL if no
1513 		item is under that position.
1514 	*/
1515 	ListboxItem*	getItemAtPoint(const Vector2f& pt) const;
1516 
1517 
1518 	/*!
1519 	\brief
1520 		Set select state for the given item.  This appropriately selects other
1521 		items depending upon the select mode.  Returns true if something is
1522 		changed, else false.
1523 	*/
1524 	bool	setItemSelectState_impl(const MCLGridRef grid_ref, bool state);
1525 
1526 
1527 	/*!
1528 	\brief
1529 		Set select state for all items in the given row
1530 	*/
1531 	void	setSelectForItemsInRow(uint row_idx, bool state);
1532 
1533 
1534 	/*!
1535 	\brief
1536 		Set select state for all items in the given column
1537 	*/
1538 	void	setSelectForItemsInColumn(uint col_idx, bool state);
1539 
1540 
1541 	/*!
1542 	\brief
1543 		Move the column at index \a col_idx so it is at index \a position.  Implementation version which does not move the
1544 		header segment (since that may have already happened).
1545 
1546 	\exception InvalidRequestException	thrown if \a col_idx is invalid.
1547 	*/
1548 	void	moveColumn_impl(uint col_idx, uint position);
1549 
1550 
1551 	/*!
1552 	\brief
1553 		Remove all items from the list.
1554 
1555 	\note
1556 		Note that this will cause 'AutoDelete' items to be deleted.
1557 
1558 	\return
1559 		- true if the list contents were changed.
1560 		- false if the list contents were not changed (list already empty).
1561 	*/
1562 	bool	resetList_impl(void);
1563 
1564     // overrides function in base class.
1565     virtual bool validateWindowRenderer(const WindowRenderer* renderer) const;
1566 
1567     // overrides function in base class.
1568     int writePropertiesXML(XMLSerializer& xml_stream) const;
1569 
1570     /*!
1571     \brief
1572         Causes the internal list to be (re)sorted.
1573     */
1574     void resortList();
1575 
1576 	/*************************************************************************
1577 		New event handlers for multi column list
1578 	*************************************************************************/
1579 	/*!
1580 	\brief
1581 		Handler called when the selection mode of the list box changes
1582 	*/
1583 	virtual	void	onSelectionModeChanged(WindowEventArgs& e);
1584 
1585 
1586 	/*!
1587 	\brief
1588 		Handler called when the nominated selection column changes
1589 	*/
1590 	virtual	void	onNominatedSelectColumnChanged(WindowEventArgs& e);
1591 
1592 
1593 	/*!
1594 	\brief
1595 		Handler called when the nominated selection row changes.
1596 	*/
1597 	virtual	void	onNominatedSelectRowChanged(WindowEventArgs& e);
1598 
1599 
1600 	/*!
1601 	\brief
1602 		Handler called when the vertical scroll bar 'force' mode is changed.
1603 	*/
1604 	virtual	void	onVertScrollbarModeChanged(WindowEventArgs& e);
1605 
1606 
1607 	/*!
1608 	\brief
1609 		Handler called when the horizontal scroll bar 'force' mode is changed.
1610 	*/
1611 	virtual	void	onHorzScrollbarModeChanged(WindowEventArgs& e);
1612 
1613 
1614 	/*!
1615 	\brief
1616 		Handler called when the current selection changes.
1617 	*/
1618 	virtual	void	onSelectionChanged(WindowEventArgs& e);
1619 
1620 
1621 	/*!
1622 	\brief
1623 		Handler called when the list contents is changed.
1624 	*/
1625 	virtual	void	onListContentsChanged(WindowEventArgs& e);
1626 
1627 
1628 	/*!
1629 	\brief
1630 		Handler called when the sort column changes.
1631 	*/
1632 	virtual	void	onSortColumnChanged(WindowEventArgs& e);
1633 
1634 
1635 	/*!
1636 	\brief
1637 		Handler called when the sort direction changes.
1638 	*/
1639 	virtual	void	onSortDirectionChanged(WindowEventArgs& e);
1640 
1641 
1642 	/*!
1643 	\brief
1644 		Handler called when a column is sized.
1645 	*/
1646 	virtual	void	onListColumnSized(WindowEventArgs& e);
1647 
1648 
1649 	/*!
1650 	\brief
1651 		Handler called when the column order is changed.
1652 	*/
1653 	virtual	void	onListColumnMoved(WindowEventArgs& e);
1654 
1655 
1656 	/*************************************************************************
1657 		Overridden Event handlers
1658 	*************************************************************************/
1659 	virtual	void	onFontChanged(WindowEventArgs& e);
1660 	virtual void	onSized(ElementEventArgs& e);
1661 	virtual void	onMouseButtonDown(MouseEventArgs& e);
1662 	virtual	void	onMouseWheel(MouseEventArgs& e);
1663 
1664 
1665 	/*************************************************************************
1666 		Handlers for subscribed events
1667 	*************************************************************************/
1668 	bool	handleHeaderScroll(const EventArgs& e);
1669 	bool	handleHeaderSegMove(const EventArgs& e);
1670 	bool	handleColumnSizeChange(const EventArgs& e);
1671 	bool	handleHorzScrollbar(const EventArgs& e);
1672 	bool	handleVertScrollbar(const EventArgs& e);
1673 	bool	handleSortColumnChange(const EventArgs& e);
1674 	bool	handleSortDirectionChange(const EventArgs& e);
1675 	bool	handleHeaderSegDblClick(const EventArgs& e);
1676 
1677     /*!
1678     \brief
1679         Struct used internally to represent a row in the list and also to ease
1680         sorting of the rows.
1681     */
1682 	struct ListRow
1683 	{
1684 		typedef	std::vector<ListboxItem*
1685             CEGUI_VECTOR_ALLOC(ListboxItem*)> RowItems;
1686 		RowItems	d_items;
1687 		uint		d_sortColumn;
1688 		uint		d_rowID;
1689 
1690 		// operators
1691 		ListboxItem* const& operator[](uint idx) const	{return d_items[idx];}
1692 		ListboxItem*&	operator[](uint idx) {return d_items[idx];}
1693 		bool	operator<(const ListRow& rhs) const;
1694 		bool	operator>(const ListRow& rhs) const;
1695 	};
1696 
1697 
1698 	/*!
1699 	\brief
1700 		std algorithm predicate used for sorting in descending order
1701 	*/
1702 	static bool pred_descend(const ListRow& a, const ListRow& b);
1703 
1704 
1705 	/*************************************************************************
1706 		Implementation Data
1707 	*************************************************************************/
1708 	// scrollbar settings.
1709 	bool	d_forceVertScroll;		//!< true if vertical scrollbar should always be displayed
1710 	bool	d_forceHorzScroll;		//!< true if horizontal scrollbar should always be displayed
1711 
1712 	// selection abilities.
1713 	SelectionMode	d_selectMode;	//!< Holds selection mode (represented by settings below).
1714 	uint	d_nominatedSelectCol;	//!< Nominated column for single column selection.
1715 	uint	d_nominatedSelectRow;	//!< Nominated row for single row selection.
1716 	bool	d_multiSelect;			//!< Allow multiple selections.
1717 	bool	d_fullRowSelect;		//!< All items in a row are selected.
1718 	bool	d_fullColSelect;		//!< All items in a column are selected.
1719 	bool	d_useNominatedRow;		//!< true if we use a nominated row to select.
1720 	bool	d_useNominatedCol;		//!< true if we use a nominated col to select.
1721 	ListboxItem*	d_lastSelected;	//!< holds pointer to the last selected item (used in range selections)
1722 
1723     uint    d_columnCount;          //!< keeps track of the number of columns.
1724 
1725 	// storage of items in the list box.
1726 	typedef std::vector<ListRow
1727         CEGUI_VECTOR_ALLOC(ListRow)> ListItemGrid;
1728 	ListItemGrid	d_grid;			//!< Holds the list box data.
1729 
1730     //! whether header size will be considered when auto-sizing columns.
1731     bool d_autoSizeColumnUsesHeader;
1732 
1733     friend class MultiColumnListWindowRenderer;
1734 
1735 
1736 private:
1737 	/*************************************************************************
1738 		Private methods
1739 	*************************************************************************/
1740 	void	addMultiColumnListProperties(void);
1741 };
1742 
1743 
1744 template<>
1745 class PropertyHelper<MultiColumnList::SelectionMode>
1746 {
1747 public:
1748     typedef MultiColumnList::SelectionMode return_type;
1749     typedef return_type safe_method_return_type;
1750     typedef MultiColumnList::SelectionMode pass_type;
1751     typedef String string_return_type;
1752 
getDataTypeName()1753     static const String& getDataTypeName()
1754     {
1755         static String type("SelectionMode");
1756 
1757         return type;
1758     }
1759 
fromString(const String & str)1760     static return_type fromString(const String& str)
1761     {
1762         MultiColumnList::SelectionMode mode;
1763 
1764         if (str == "RowMultiple")
1765         {
1766             mode = MultiColumnList::RowMultiple;
1767         }
1768         else if (str == "ColumnSingle")
1769         {
1770             mode = MultiColumnList::ColumnSingle;
1771         }
1772         else if (str == "ColumnMultiple")
1773         {
1774             mode = MultiColumnList::ColumnMultiple;
1775         }
1776         else if (str == "CellSingle")
1777         {
1778             mode = MultiColumnList::CellSingle;
1779         }
1780         else if (str == "CellMultiple")
1781         {
1782             mode = MultiColumnList::CellMultiple;
1783         }
1784         else if (str == "NominatedColumnSingle")
1785         {
1786             mode = MultiColumnList::NominatedColumnSingle;
1787         }
1788         else if (str == "NominatedColumnMultiple")
1789         {
1790             mode = MultiColumnList::NominatedColumnMultiple;
1791         }
1792         else if (str == "NominatedRowSingle")
1793         {
1794             mode = MultiColumnList::NominatedRowSingle;
1795         }
1796         else if (str == "NominatedRowMultiple")
1797         {
1798             mode = MultiColumnList::NominatedRowMultiple;
1799         }
1800         else
1801         {
1802             mode = MultiColumnList::RowSingle;
1803         }
1804         return mode;
1805     }
1806 
toString(pass_type val)1807     static string_return_type toString(pass_type val)
1808     {
1809         switch(val)
1810         {
1811         case MultiColumnList::RowMultiple:
1812             return String("RowMultiple");
1813             break;
1814 
1815         case MultiColumnList::ColumnSingle:
1816             return String("ColumnSingle");
1817             break;
1818 
1819         case MultiColumnList::ColumnMultiple:
1820             return String("ColumnMultiple");
1821             break;
1822 
1823         case MultiColumnList::CellSingle:
1824             return String("CellSingle");
1825             break;
1826 
1827         case MultiColumnList::CellMultiple:
1828             return String("CellMultiple");
1829             break;
1830 
1831         case MultiColumnList::NominatedColumnSingle:
1832             return String("NominatedColumnSingle");
1833             break;
1834 
1835         case MultiColumnList::NominatedColumnMultiple:
1836             return String("NominatedColumnMultiple");
1837             break;
1838 
1839         case MultiColumnList::NominatedRowSingle:
1840             return String("NominatedRowSingle");
1841             break;
1842 
1843         case MultiColumnList::NominatedRowMultiple:
1844             return String("NominatedRowMultiple");
1845             break;
1846 
1847         default:
1848             return String("RowSingle");
1849             break;
1850         }
1851     }
1852 };
1853 
1854 
1855 } // End of  CEGUI namespace section
1856 
1857 #if defined(_MSC_VER)
1858 #	pragma warning(pop)
1859 #endif
1860 
1861 #endif	// end of guard _CEGUIMultiColumnList_h_
1862