Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 13/4/2004 00003 author: Paul D Turner 00004 00005 purpose: Interface to base class for ListHeader widget 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIListHeader_h_ 00030 #define _CEGUIListHeader_h_ 00031 00032 #include "../Base.h" 00033 #include "../Window.h" 00034 #include "./ListHeaderSegment.h" 00035 00036 #if defined(_MSC_VER) 00037 # pragma warning(push) 00038 # pragma warning(disable : 4251) 00039 #endif 00040 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00049 class CEGUIEXPORT HeaderSequenceEventArgs : public WindowEventArgs 00050 { 00051 public: 00052 HeaderSequenceEventArgs(Window* wnd, uint old_idx, uint new_idx) : WindowEventArgs(wnd), d_oldIdx(old_idx), d_newIdx(new_idx) {}; 00053 00054 uint d_oldIdx; 00055 uint d_newIdx; 00056 }; 00057 00062 class CEGUIEXPORT ListHeaderWindowRenderer : public WindowRenderer 00063 { 00064 public: 00069 ListHeaderWindowRenderer(const String& name); 00070 00082 virtual ListHeaderSegment* createNewSegment(const String& name) const = 0; 00083 00095 virtual void destroyListSegment(ListHeaderSegment* segment) const = 0; 00096 }; 00097 00098 00103 class CEGUIEXPORT ListHeader : public Window 00104 { 00105 public: 00106 static const String EventNamespace; 00107 static const String WidgetTypeName; 00108 00109 00110 /************************************************************************* 00111 Constants 00112 *************************************************************************/ 00113 // Event names 00119 static const String EventSortColumnChanged; 00125 static const String EventSortDirectionChanged; 00130 static const String EventSegmentSized; 00135 static const String EventSegmentClicked; 00141 static const String EventSplitterDoubleClicked; 00149 static const String EventSegmentSequenceChanged; 00155 static const String EventSegmentAdded; 00161 static const String EventSegmentRemoved; 00168 static const String EventSortSettingChanged; 00175 static const String EventDragMoveSettingChanged; 00182 static const String EventDragSizeSettingChanged; 00188 static const String EventSegmentRenderOffsetChanged; 00189 00190 // values 00191 static const float ScrollSpeed; 00192 static const float MinimumSegmentPixelWidth; 00193 00194 /************************************************************************* 00195 Child Widget name suffix constants 00196 *************************************************************************/ 00198 static const String SegmentNameSuffix; 00199 00200 00201 /************************************************************************* 00202 Accessor Methods 00203 *************************************************************************/ 00211 uint getColumnCount(void) const; 00212 00213 00226 ListHeaderSegment& getSegmentFromColumn(uint column) const; 00227 00228 00242 ListHeaderSegment& getSegmentFromID(uint id) const; 00243 00244 00255 ListHeaderSegment& getSortSegment(void) const; 00266 uint getSortSegmentID(void) const; 00267 00268 00281 uint getColumnFromSegment(const ListHeaderSegment& segment) const; 00282 00283 00296 uint getColumnFromID(uint id) const; 00297 00298 00309 uint getSortColumn(void) const; 00310 00311 00324 uint getColumnWithText(const String& text) const; 00325 00326 00339 float getPixelOffsetToSegment(const ListHeaderSegment& segment) const; 00340 00341 00355 float getPixelOffsetToColumn(uint column) const; 00356 00357 00365 float getTotalSegmentsPixelExtent(void) const; 00366 00367 00381 UDim getColumnWidth(uint column) const; 00382 00383 00391 ListHeaderSegment::SortDirection getSortDirection(void) const; 00392 00393 00402 bool isSortingEnabled(void) const; 00403 00404 00412 bool isColumnSizingEnabled(void) const; 00413 00414 00422 bool isColumnDraggingEnabled(void) const; 00423 00424 00433 float getSegmentOffset(void) const {return d_segmentOffset;} 00434 00435 00436 /************************************************************************* 00437 Manipulator Methods 00438 *************************************************************************/ 00450 void setSortingEnabled(bool setting); 00451 00452 00463 void setSortDirection(ListHeaderSegment::SortDirection direction); 00464 00465 00478 void setSortSegment(const ListHeaderSegment& segment); 00479 00480 00493 void setSortColumn(uint column); 00494 00495 00508 void setSortColumnFromID(uint id); 00509 00510 00522 void setColumnSizingEnabled(bool setting); 00523 00524 00536 void setColumnDraggingEnabled(bool setting); 00537 00538 00555 void addColumn(const String& text, uint id, const UDim& width); 00556 00557 00578 void insertColumn(const String& text, uint id, const UDim& width, uint position); 00579 00580 00603 void insertColumn(const String& text, uint id, const UDim& width, const ListHeaderSegment& position); 00604 00605 00618 void removeColumn(uint column); 00619 00620 00633 void removeSegment(const ListHeaderSegment& segment); 00634 00635 00652 void moveColumn(uint column, uint position); 00653 00654 00673 void moveColumn(uint column, const ListHeaderSegment& position); 00674 00675 00692 void moveSegment(const ListHeaderSegment& segment, uint position); 00693 00694 00712 void moveSegment(const ListHeaderSegment& segment, const ListHeaderSegment& position); 00713 00714 00727 void setSegmentOffset(float offset); 00728 00729 00746 void setColumnWidth(uint column, const UDim& width); 00747 00748 00749 /************************************************************************* 00750 Construction and Destruction 00751 *************************************************************************/ 00756 ListHeader(const String& type, const String& name); 00757 00758 00763 virtual ~ListHeader(void); 00764 00765 00766 protected: 00767 /************************************************************************* 00768 Abstract Implementation Methods 00769 *************************************************************************/ 00781 //virtual ListHeaderSegment* createNewSegment_impl(const String& name) const = 0; 00782 00783 00795 //virtual void destroyListSegment_impl(ListHeaderSegment* segment) const = 0; 00796 00797 00798 /************************************************************************* 00799 Implementation Methods 00800 *************************************************************************/ 00805 ListHeaderSegment* createInitialisedSegment(const String& text, uint id, const UDim& width); 00806 00807 00812 void layoutSegments(void); 00813 00825 ListHeaderSegment* createNewSegment(const String& name) const; 00826 00827 00839 void destroyListSegment(ListHeaderSegment* segment) const; 00840 00841 // validate window renderer 00842 virtual bool validateWindowRenderer(const WindowRenderer* renderer) const; 00843 00844 /************************************************************************* 00845 New List header event handlers 00846 *************************************************************************/ 00851 virtual void onSortColumnChanged(WindowEventArgs& e); 00852 00853 00858 virtual void onSortDirectionChanged(WindowEventArgs& e); 00859 00860 00865 virtual void onSegmentSized(WindowEventArgs& e); 00866 00867 00872 virtual void onSegmentClicked(WindowEventArgs& e); 00873 00874 00879 virtual void onSplitterDoubleClicked(WindowEventArgs& e); 00880 00881 00886 virtual void onSegmentSequenceChanged(WindowEventArgs& e); 00887 00888 00893 virtual void onSegmentAdded(WindowEventArgs& e); 00894 00895 00900 virtual void onSegmentRemoved(WindowEventArgs& e); 00901 00902 00907 virtual void onSortSettingChanged(WindowEventArgs& e); 00908 00909 00914 virtual void onDragMoveSettingChanged(WindowEventArgs& e); 00915 00916 00921 virtual void onDragSizeSettingChanged(WindowEventArgs& e); 00922 00923 00928 virtual void onSegmentOffsetChanged(WindowEventArgs& e); 00929 00930 /************************************************************************* 00931 handlers for events we subscribe to from segments 00932 *************************************************************************/ 00933 bool segmentSizedHandler(const EventArgs& e); 00934 bool segmentMovedHandler(const EventArgs& e); 00935 bool segmentClickedHandler(const EventArgs& e); 00936 bool segmentDoubleClickHandler(const EventArgs& e); 00937 bool segmentDragHandler(const EventArgs& e); 00938 00939 00940 /************************************************************************* 00941 Implementation Data 00942 *************************************************************************/ 00943 typedef std::vector<ListHeaderSegment* 00944 CEGUI_VECTOR_ALLOC(ListHeaderSegment*)> SegmentList; 00945 SegmentList d_segments; 00946 ListHeaderSegment* d_sortSegment; 00947 bool d_sizingEnabled; 00948 bool d_sortingEnabled; 00949 bool d_movingEnabled; 00950 uint d_uniqueIDNumber; 00951 float d_segmentOffset; 00952 ListHeaderSegment::SortDirection d_sortDir; 00953 00954 00955 private: 00956 /************************************************************************* 00957 Private methods 00958 *************************************************************************/ 00959 void addHeaderProperties(void); 00960 }; 00961 00962 00963 } // End of CEGUI namespace section 00964 00965 00966 #if defined(_MSC_VER) 00967 # pragma warning(pop) 00968 #endif 00969 00970 #endif // end of guard _CEGUIListHeader_h_