1 // Created on: 1998-07-28 2 // Created by: Christian CAILLET 3 // Copyright (c) 1998-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 8 // This library is free software; you can redistribute it and/or modify it under 9 // the terms of the GNU Lesser General Public License version 2.1 as published 10 // by the Free Software Foundation, with special exception defined in the file 11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 12 // distribution for complete text of the license and disclaimer of any warranty. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _IFSelect_ListEditor_HeaderFile 18 #define _IFSelect_ListEditor_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_Type.hxx> 22 23 #include <Standard_Integer.hxx> 24 #include <TColStd_HSequenceOfHAsciiString.hxx> 25 #include <TColStd_HSequenceOfInteger.hxx> 26 #include <Standard_Transient.hxx> 27 #include <Standard_Boolean.hxx> 28 class Interface_TypedValue; 29 class Interface_InterfaceModel; 30 class TCollection_HAsciiString; 31 32 class IFSelect_ListEditor; 33 DEFINE_STANDARD_HANDLE(IFSelect_ListEditor, Standard_Transient) 34 35 //! A ListEditor is an auxiliary operator for Editor/EditForm 36 //! I.E. it works on parameter values expressed as strings 37 //! 38 //! For a parameter which is a list, it may not be edited in once 39 //! by just setting a new value (as a string) 40 //! 41 //! Firstly, a list can be long (and tedious to be accessed flat) 42 //! then requires a better way of accessing 43 //! 44 //! Moreover, not only its VALUES may be changed (SetValue), but 45 //! also its LENGTH : items may be added or removed ... 46 //! 47 //! Hence, the way of editing a parameter as a list is : 48 //! - edit it separately, with the help of a ListEditor 49 //! - it remains possible to prepare a new list of values apart 50 //! - then give the new list in once to the EditForm 51 //! 52 //! An EditList is produced by the Editor, with a basic definition 53 //! This definition (brought by this class) can be redefined 54 //! Hence the Editor may produce a specific ListEditor as needed 55 class IFSelect_ListEditor : public Standard_Transient 56 { 57 58 public: 59 60 //! Creates a ListEditor with absolutely no constraint 61 Standard_EXPORT IFSelect_ListEditor(); 62 63 //! Creates a ListEditor, for which items of the list to edit are 64 //! defined by <def>, and <max> describes max length : 65 //! 0 (D) means no limit 66 //! value > 0 means : no more the <max> items are allowed 67 Standard_EXPORT IFSelect_ListEditor(const Handle(Interface_TypedValue)& def, const Standard_Integer max = 0); 68 69 //! Loads a Model. It is used to check items of type Entity(Ident) 70 Standard_EXPORT void LoadModel (const Handle(Interface_InterfaceModel)& model); 71 72 //! Loads the original values for the list. 73 //! Remark : If its length is more then MaxLength, editions remain allowed, except Add 74 Standard_EXPORT void LoadValues (const Handle(TColStd_HSequenceOfHAsciiString)& vals); 75 76 //! Declares this ListEditor to have been touched (whatever action) 77 Standard_EXPORT void SetTouched(); 78 79 //! Clears all editions already recorded 80 Standard_EXPORT void ClearEdit(); 81 82 //! Loads a new list to replace the older one, in once ! 83 //! By default (can be redefined) checks the length of the list 84 //! and the value of each item according to the def 85 //! Items are all recorded as Modified 86 //! 87 //! If no def has been given at creation time, no check is done 88 //! Returns True when done, False if checks have failed ... a 89 //! specialisation may also lock it by returning always False ... 90 Standard_EXPORT virtual Standard_Boolean LoadEdited (const Handle(TColStd_HSequenceOfHAsciiString)& list); 91 92 //! Sets a new value for the item <num> (in edited list) 93 //! <val> may be a Null Handle, then the value will be cleared but 94 //! not removed 95 //! Returns True when done. False if <num> is out of range or if 96 //! <val> does not satisfy the definition 97 Standard_EXPORT virtual Standard_Boolean SetValue (const Standard_Integer num, const Handle(TCollection_HAsciiString)& val); 98 99 //! Adds a new item. By default appends (at the end of the list) 100 //! Can insert before a given rank <num>, if positive 101 //! Returns True when done. False if MaxLength may be overpassed 102 //! or if <val> does not satisfy the definition 103 Standard_EXPORT virtual Standard_Boolean AddValue (const Handle(TCollection_HAsciiString)& val, const Standard_Integer atnum = 0); 104 105 //! Removes items from the list 106 //! By default removes one item. Else, count given by <howmany> 107 //! Remove from rank <num> included. By default, from the end 108 //! Returns True when done, False (and does not work) if case of 109 //! out of range of if <howmany> is greater than current length 110 Standard_EXPORT virtual Standard_Boolean Remove (const Standard_Integer num = 0, const Standard_Integer howmany = 1); 111 112 //! Returns the value from which the edition started 113 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) OriginalValues() const; 114 115 //! Returns the result of the edition 116 Standard_EXPORT Handle(TColStd_HSequenceOfHAsciiString) EditedValues() const; 117 118 //! Returns count of values, edited (D) or original 119 Standard_EXPORT Standard_Integer NbValues (const Standard_Boolean edited = Standard_True) const; 120 121 //! Returns a value given its rank. Edited (D) or Original 122 //! A Null String means the value is cleared but not removed 123 Standard_EXPORT Handle(TCollection_HAsciiString) Value (const Standard_Integer num, const Standard_Boolean edited = Standard_True) const; 124 125 //! Tells if a value (in edited list) has been changed, i.e. 126 //! either modified-value, or added 127 Standard_EXPORT Standard_Boolean IsChanged (const Standard_Integer num) const; 128 129 //! Tells if a value (in edited list) has been modified-value 130 //! (not added) 131 Standard_EXPORT Standard_Boolean IsModified (const Standard_Integer num) const; 132 133 //! Tells if a value (in edited list) has been added (new one) 134 Standard_EXPORT Standard_Boolean IsAdded (const Standard_Integer num) const; 135 136 //! Tells if at least one edition (SetValue-AddValue-Remove) has 137 //! been recorded 138 Standard_EXPORT Standard_Boolean IsTouched() const; 139 140 DEFINE_STANDARD_RTTIEXT(IFSelect_ListEditor,Standard_Transient) 141 142 private: 143 144 Standard_Integer themax; 145 Handle(Interface_TypedValue) thedef; 146 Standard_Integer thetouc; 147 Handle(TColStd_HSequenceOfHAsciiString) theorig; 148 Handle(TColStd_HSequenceOfHAsciiString) theedit; 149 Handle(TColStd_HSequenceOfInteger) thestat; 150 Handle(Interface_InterfaceModel) themodl; 151 152 }; 153 154 #endif // _IFSelect_ListEditor_HeaderFile 155