Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIMultiColumnList.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIMultiColumnList.h
00003         created:        13/4/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Interface to base class for MultiColumnList widget
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUIMultiColumnList_h_
00027 #define _CEGUIMultiColumnList_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "CEGUIListHeader.h"
00032 #include "elements/CEGUIMultiColumnListProperties.h"
00033 
00034 
00035 #if defined(_MSC_VER)
00036 #       pragma warning(push)
00037 #       pragma warning(disable : 4251)
00038 #endif
00039 
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00044 
00049 struct CEGUIBASE_API MCLGridRef
00050 {
00051         MCLGridRef(uint r, uint c) : row(r), column(c) {}
00052 
00053         uint    row;            
00054         uint    column;         
00055 
00056         // operators
00057         MCLGridRef& operator=(const MCLGridRef& rhs);
00058         bool operator<(const MCLGridRef& rhs) const;
00059         bool operator<=(const MCLGridRef& rhs) const;
00060         bool operator>(const MCLGridRef& rhs) const;
00061         bool operator>=(const MCLGridRef& rhs) const;
00062         bool operator==(const MCLGridRef& rhs) const;
00063         bool operator!=(const MCLGridRef& rhs) const;
00064 };
00065 
00066 
00071 class CEGUIBASE_API MultiColumnList : public Window
00072 {
00073 public:
00074         static const String EventNamespace;                             
00075 
00076 
00077         /*************************************************************************
00078                 Constants
00079         *************************************************************************/
00080         // Event names
00081         static const String EventSelectionModeChanged;          
00082         static const String EventNominatedSelectColumnChanged;
00083         static const String EventNominatedSelectRowChanged;     
00084         static const String EventVertScrollbarModeChanged;      
00085         static const String EventHorzScrollbarModeChanged;      
00086         static const String EventSelectionChanged;                      
00087         static const String EventListContentsChanged;                   
00088         static const String EventSortColumnChanged;                     
00089         static const String EventSortDirectionChanged;          
00090         static const String EventListColumnSized;                               
00091         static const String EventListColumnMoved;                               
00092 
00093 
00094         /*************************************************************************
00095                 Enumerations
00096         *************************************************************************/
00101         enum SelectionMode
00102         {
00103                 RowSingle,                                      // Any single row may be selected.  All items in the row are selected.
00104                 RowMultiple,                            // Multiple rows may be selected.  All items in the row are selected.
00105                 CellSingle,                                     // Any single cell may be selected.
00106                 CellMultiple,                           // Multiple cells bay be selected.
00107                 NominatedColumnSingle,          // Any single item in a nominated column may be selected.
00108                 NominatedColumnMultiple,        // Multiple items in a nominated column may be selected.
00109                 ColumnSingle,                           // Any single column may be selected.  All items in the column are selected.
00110                 ColumnMultiple,                         // Multiple columns may be selected.  All items in the column are selected.
00111                 NominatedRowSingle,                     // Any single item in a nominated row may be selected.
00112                 NominatedRowMultiple            // Multiple items in a nominated row may be selected.
00113         };
00114 
00115 
00116         /*************************************************************************
00117                 Accessor Methods
00118         *************************************************************************/
00127         bool    isUserSortControlEnabled(void) const;
00128 
00129 
00137         bool    isUserColumnSizingEnabled(void) const;
00138 
00139 
00147         bool    isUserColumnDraggingEnabled(void) const;
00148 
00149 
00157         uint    getColumnCount(void) const;
00158 
00159 
00167         uint    getRowCount(void) const;
00168 
00169 
00180         uint    getSortColumn(void) const;
00181 
00182         
00195         uint    getColumnWithID(uint col_id) const;
00196 
00197 
00210         uint    getColumnWithHeaderText(const String& text) const;
00211 
00212 
00220         float   getTotalColumnHeadersWidth(void) const;
00221 
00222 
00235         float   getColumnHeaderWidth(uint col_idx) const;
00236 
00237 
00245         ListHeaderSegment::SortDirection        getSortDirection(void) const;
00246 
00247 
00260         ListHeaderSegment&      getHeaderSegmentForColumn(uint col_idx) const;
00261 
00262 
00275         uint    getItemRowIndex(const ListboxItem* item) const;
00276 
00277 
00290         uint    getItemColumnIndex(const ListboxItem* item) const;
00291 
00292 
00305         MCLGridRef      getItemGridReference(const ListboxItem* item) const;
00306 
00307         
00320         ListboxItem*    getItemAtGridReference(const MCLGridRef& grid_ref) const;
00321 
00322 
00339         bool    isListboxItemInColumn(const ListboxItem* item, uint col_idx) const;
00340 
00341 
00358         bool    isListboxItemInRow(const ListboxItem* item, uint row_idx) const;
00359 
00360 
00372         bool    isListboxItemInList(const ListboxItem* item) const;
00373 
00374 
00393         ListboxItem*    findColumnItemWithText(const String& text, uint col_idx, const ListboxItem* start_item) const;
00394 
00395 
00414         ListboxItem*    findRowItemWithText(const String& text, uint row_idx, const ListboxItem* start_item) const;
00415 
00416 
00435         ListboxItem*    findListItemWithText(const String& text, const ListboxItem* start_item) const;
00436 
00437 
00448         ListboxItem*    getFirstSelectedItem(void) const;
00449 
00450 
00466         ListboxItem*    getNextSelected(const ListboxItem* start_item) const;
00467 
00468 
00476         uint    getSelectedCount(void) const;
00477 
00478 
00492         bool    isItemSelected(const MCLGridRef& grid_ref) const;
00493 
00494 
00506         uint    getNominatedSelectionColumnID(void) const;
00507 
00508 
00517         uint    getNominatedSelectionColumn(void) const;
00518 
00519 
00528         uint    getNominatedSelectionRow(void) const;
00529 
00530 
00538         MultiColumnList::SelectionMode  getSelectionMode(void) const;
00539 
00540 
00549         bool    isVertScrollbarAlwaysShown(void) const;
00550 
00551 
00560         bool    isHorzScrollbarAlwaysShown(void) const;
00561 
00562 
00575         uint    getColumnID(uint col_idx) const;
00576 
00577 
00578         /*************************************************************************
00579                 Manipulator Methods
00580         *************************************************************************/
00591         virtual void    initialise(void);
00592 
00593 
00600         void    resetList(void);
00601 
00602 
00619         void    addColumn(const String& text, uint col_id, float width);
00620 
00621 
00642         void    insertColumn(const String& text, uint col_id, float width, uint position);
00643 
00644 
00657         void    removeColumn(uint col_idx);
00658 
00659 
00672         void    removeColumnWithID(uint col_id);
00673 
00674 
00690         void    moveColumn(uint col_idx, uint position);
00691 
00692 
00708         void    moveColumnWithID(uint col_id, uint position);
00709 
00710 
00722         uint    addRow(void);
00723 
00724 
00744         uint    addRow(ListboxItem* item, uint col_id);
00745 
00746 
00762         uint    insertRow(uint row_idx);
00763 
00764 
00788         uint    insertRow(ListboxItem* item, uint col_id, uint row_idx);
00789 
00790 
00803         void    removeRow(uint row_idx);
00804 
00805 
00821         void    setItem(ListboxItem* item, const MCLGridRef& position);
00822 
00823 
00842         void    setItem(ListboxItem* item, uint col_id, uint row_idx);
00843 
00844 
00857         void    setSelectionMode(MultiColumnList::SelectionMode sel_mode);
00858 
00859 
00872         void    setNominatedSelectionColumnID(uint col_id);
00873 
00874 
00887         void    setNominatedSelectionColumn(uint col_idx);
00888 
00889 
00902         void    setNominatedSelectionRow(uint row_idx);
00903 
00904 
00915         void    setSortDirection(ListHeaderSegment::SortDirection direction);
00916 
00917 
00930         void    setSortColumn(uint col_idx);
00931 
00932 
00945         void    setSortColumnByID(uint col_id);
00946 
00947         
00959         void    setShowVertScrollbar(bool setting);
00960 
00961 
00973         void    setShowHorzScrollbar(bool setting);
00974 
00975         
00983         void    clearAllSelections(void);
00984 
00985 
01006         void    setItemSelectState(ListboxItem* item, bool state);
01007 
01008 
01029         void    setItemSelectState(const MCLGridRef& grid_ref, bool state);
01030 
01031         
01040         void    handleUpdatedItemData(void);
01041 
01042 
01058         void    setColumnHeaderWidth(uint col_idx, float width);
01059 
01060 
01072         void    setUserSortControlEnabled(bool setting);
01073 
01074 
01086         void    setUserColumnSizingEnabled(bool setting);
01087 
01088 
01097         void    setUserColumnDraggingEnabled(bool setting);
01098 
01099 
01113         void    autoSizeColumnHeader(uint col_idx);
01114 
01115 
01116         /*************************************************************************
01117                 Construction and Destruction
01118         *************************************************************************/
01123         MultiColumnList(const String& type, const String& name);
01124 
01125 
01130         virtual ~MultiColumnList(void);
01131 
01132 
01133 protected:
01134         /*************************************************************************
01135                 Implementation Functions (abstract interface)
01136         *************************************************************************/
01146         virtual Rect    getListRenderArea(void) const           = 0;
01147 
01148 
01156         virtual ListHeader*     createListHeader(void) const            = 0;
01157  
01158 
01166         virtual Scrollbar*      createVertScrollbar(void) const         = 0;
01167  
01168 
01176         virtual Scrollbar*      createHorzScrollbar(void) const         = 0;
01177 
01178 
01186         virtual void    layoutComponentWidgets()        = 0;
01187 
01188 
01202         virtual void    renderListboxBaseImagery(float z)               = 0;
01203 
01204 
01205         /*************************************************************************
01206                 Implementation Functions
01207         *************************************************************************/
01212         void    addMultiColumnListboxEvents(void);
01213 
01214 
01225         virtual void    drawSelf(float z);
01226 
01227 
01232         void    configureScrollbars(void);
01233 
01234 
01239         bool    selectRange(const MCLGridRef& start, const MCLGridRef& end);
01240 
01241 
01246         float   getTotalRowsHeight(void) const;
01247 
01248 
01253         float   getWidestColumnItemWidth(uint col_idx) const;
01254 
01255 
01260         float   getHighestRowItemHeight(uint row_idx) const;
01261 
01262 
01270         bool    clearAllSelections_impl(void);
01271 
01272 
01281         ListboxItem*    getItemAtPoint(const Point& pt) const;
01282 
01283 
01290         bool    setItemSelectState_impl(const MCLGridRef grid_ref, bool state);
01291 
01292 
01297         void    setSelectForItemsInRow(uint row_idx, bool state);
01298 
01299 
01304         void    setSelectForItemsInColumn(uint col_idx, bool state);
01305 
01306 
01314         void    moveColumn_impl(uint col_idx, uint position);
01315 
01316 
01328         bool    resetList_impl(void);
01329 
01330 
01331         /*************************************************************************
01332                 New event handlers for multi column list
01333         *************************************************************************/
01338         virtual void    onSelectionModeChanged(WindowEventArgs& e);
01339 
01340 
01345         virtual void    onNominatedSelectColumnChanged(WindowEventArgs& e);
01346 
01347 
01352         virtual void    onNominatedSelectRowChanged(WindowEventArgs& e);
01353 
01354 
01359         virtual void    onVertScrollbarModeChanged(WindowEventArgs& e);
01360 
01361 
01366         virtual void    onHorzScrollbarModeChanged(WindowEventArgs& e);
01367 
01368 
01373         virtual void    onSelectionChanged(WindowEventArgs& e);
01374 
01375 
01380         virtual void    onListContentsChanged(WindowEventArgs& e);
01381 
01382 
01387         virtual void    onSortColumnChanged(WindowEventArgs& e);
01388 
01389 
01394         virtual void    onSortDirectionChanged(WindowEventArgs& e);
01395 
01396 
01401         virtual void    onListColumnSized(WindowEventArgs& e);
01402 
01403 
01408         virtual void    onListColumnMoved(WindowEventArgs& e);
01409 
01410 
01411         /*************************************************************************
01412                 Overridden Event handlers
01413         *************************************************************************/
01414         virtual void    onSized(WindowEventArgs& e);
01415         virtual void    onMouseButtonDown(MouseEventArgs& e);
01416         virtual void    onMouseWheel(MouseEventArgs& e);
01417 
01418 
01419         /*************************************************************************
01420                 Handlers for subscribed events
01421         *************************************************************************/
01422         bool    handleHeaderScroll(const EventArgs& e);
01423         bool    handleHeaderSegMove(const EventArgs& e);
01424         bool    handleColumnSizeChange(const EventArgs& e);
01425         bool    handleHorzScrollbar(const EventArgs& e);
01426         bool    handleSortColumnChange(const EventArgs& e);
01427         bool    handleSortDirectionChange(const EventArgs& e);
01428         bool    handleHeaderSegDblClick(const EventArgs& e);
01429 
01430 
01431         /*************************************************************************
01432                 Struct used to wrap a 'row' and ease sorting
01433         *************************************************************************/
01434         struct ListRow
01435         {
01436                 typedef std::vector<ListboxItem*>       RowItems;
01437                 RowItems        d_items;
01438                 uint            d_sortColumn;
01439 
01440                 // operators
01441                 ListboxItem* const& operator[](uint idx) const  {return d_items[idx];}
01442                 ListboxItem*&   operator[](uint idx) {return d_items[idx];}
01443                 bool    operator<(const ListRow& rhs) const;
01444                 bool    operator>(const ListRow& rhs) const;
01445         };
01446 
01447 
01452         static bool pred_descend(const ListRow& a, const ListRow& b);
01453 
01454 
01455         /*************************************************************************
01456                 Implementation Data
01457         *************************************************************************/
01458         // component widgets and settings.
01459         Scrollbar*      d_vertScrollbar;        
01460         Scrollbar*      d_horzScrollbar;        
01461         ListHeader*     d_header;                       
01462         bool    d_forceVertScroll;              
01463         bool    d_forceHorzScroll;              
01464 
01465         // selection abilities.
01466         SelectionMode   d_selectMode;   
01467         uint    d_nominatedSelectCol;   
01468         uint    d_nominatedSelectRow;   
01469         bool    d_multiSelect;                  
01470         bool    d_fullRowSelect;                
01471         bool    d_fullColSelect;                
01472         bool    d_useNominatedRow;              
01473         bool    d_useNominatedCol;              
01474         ListboxItem*    d_lastSelected; 
01475 
01476         // storage of items in the list box.
01477         typedef std::vector<ListRow>            ListItemGrid;
01478         ListItemGrid    d_grid;                 
01479 
01480 
01481 private:
01482         /*************************************************************************
01483                 Static Properties for this class
01484         *************************************************************************/
01485         static MultiColumnListProperties::ColumnsMovable                                d_columnsMovableProperty;
01486         static MultiColumnListProperties::ColumnsSizable                                d_columnsSizableProperty;
01487         static MultiColumnListProperties::ForceHorzScrollbar                    d_forceHorzScrollProperty;
01488         static MultiColumnListProperties::ForceVertScrollbar                    d_forceVertScrollProperty;
01489         static MultiColumnListProperties::NominatedSelectionColumnID    d_nominatedSelectColProperty;
01490         static MultiColumnListProperties::NominatedSelectionRow                 d_nominatedSelectRowProperty;
01491         static MultiColumnListProperties::SelectionMode                                 d_selectModeProperty;
01492         static MultiColumnListProperties::SortColumnID                                  d_sortColumnIDProperty;
01493         static MultiColumnListProperties::SortDirection                                 d_sortDirectionProperty;
01494         static MultiColumnListProperties::SortSettingEnabled                    d_sortSettingProperty;
01495 
01496 
01497         /*************************************************************************
01498                 Private methods
01499         *************************************************************************/
01500         void    addMultiColumnListProperties(void);
01501 };
01502 
01503 } // End of  CEGUI namespace section
01504 
01505 #if defined(_MSC_VER)
01506 #       pragma warning(pop)
01507 #endif
01508 
01509 #endif  // end of guard _CEGUIMultiColumnList_h_

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1