b311480e |
1 | -- Created on: 1998-07-28 |
2 | -- Created by: Christian CAILLET |
3 | -- Copyright (c) 1998-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | class ListEditor from IFSelect inherits TShared from MMgt |
24 | |
25 | ---Purpose : A ListEditor is an auxiliary operator for Editor/EditForm |
26 | -- I.E. it works on parameter values expressed as strings |
27 | -- |
28 | -- For a parameter which is a list, it may not be edited in once |
29 | -- by just setting a new value (as a string) |
30 | -- |
31 | -- Firstly, a list can be long (and tedious to be accessed flat) |
32 | -- then requires a better way of accessing |
33 | -- |
34 | -- Moreover, not only its VALUES may be changed (SetValue), but |
35 | -- also its LENGTH : items may be added or removed ... |
36 | -- |
37 | -- Hence, the way of editing a parameter as a list is : |
38 | -- - edit it separately, with the help of a ListEditor |
39 | -- - it remains possible to prepare a new list of values apart |
40 | -- - then give the new list in once to the EditForm |
41 | -- |
42 | -- An EditList is produced by the Editor, with a basic definition |
43 | -- This definition (brought by this class) can be redefined |
44 | -- Hence the Editor may produce a specific ListEditor as needed |
45 | |
46 | uses CString, HAsciiString from TCollection, |
47 | HSequenceOfHAsciiString from TColStd, |
48 | HSequenceOfInteger from TColStd, |
49 | TypedValue from Interface, InterfaceModel from Interface |
50 | |
51 | is |
52 | |
53 | Create returns ListEditor; |
54 | ---Purpose : Creates a ListEditor with absolutely no constraint |
55 | |
56 | Create (def : TypedValue; max : Integer = 0) returns ListEditor; |
57 | ---Purpose : Creates a ListEditor, for which items of the list to edit are |
58 | -- defined by <def>, and <max> describes max length : |
59 | -- 0 (D) means no limit |
60 | -- value > 0 means : no more the <max> items are allowed |
61 | |
62 | LoadModel (me : mutable; model : InterfaceModel); |
63 | ---Purpose : Loads a Model. It is used to check items of type Entity(Ident) |
64 | |
65 | LoadValues (me : mutable; vals : HSequenceOfHAsciiString); |
66 | ---Purpose : Loads the original values for the list |
67 | -- Remark : If its length is mor then MaxLength, editions remain |
68 | -- allowed, except Add |
69 | |
70 | SetTouched (me : mutable); |
71 | ---Purpose : Declares this ListEditor to have been touched (whatever action) |
72 | |
73 | ClearEdit (me : mutable); |
74 | ---Purpose : Clears all editions already recorded |
75 | |
76 | --- Editing : can be specialised |
77 | |
78 | LoadEdited (me : mutable; list : HSequenceOfHAsciiString) |
79 | returns Boolean is virtual; |
80 | ---Purpose : Loads a new list to replace the older one, in once ! |
81 | -- By default (can be redefined) checks the length of the list |
82 | -- and the value of each item according to the def |
83 | -- Items are all recorded as Modified |
84 | -- |
85 | -- If no def has been given at creation time, no check is done |
86 | -- Returns True when done, False if checks have failed ... a |
87 | -- specialisation may also lock it by returning always False ... |
88 | |
89 | SetValue (me : mutable; num : Integer; val : HAsciiString) |
90 | returns Boolean is virtual; |
91 | ---Purpose : Sets a new value for the item <num> (in edited list) |
92 | -- <val> may be a Null Handle, then the value will be cleared but |
93 | -- not removed |
94 | -- Returns True when done. False if <num> is out of range or if |
95 | -- <val> does not satisfy the definition |
96 | |
97 | AddValue (me : mutable; val : HAsciiString; atnum : Integer = 0) |
98 | returns Boolean is virtual; |
99 | ---Purpose : 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 | |
104 | Remove (me : mutable; num : Integer = 0; howmany : Integer = 1) |
105 | returns Boolean is virtual; |
106 | ---Purpose : Removes items from the list |
107 | -- By default removes one item. Else, count given by <howmany> |
108 | -- Remove from rank <num> included. By default, from the end |
109 | -- Returns True when done, False (and does not work) if case of |
110 | -- out of range of if <howmany> is greater than current length |
111 | |
112 | -- Results |
113 | |
114 | OriginalValues (me) returns HSequenceOfHAsciiString; |
115 | ---Purpose : Returns the value from which the edition started |
116 | |
117 | EditedValues (me) returns HSequenceOfHAsciiString; |
118 | ---Purpose : Returns the result of the edition |
119 | |
120 | |
121 | |
122 | NbValues (me; edited : Boolean = Standard_True) returns Integer; |
123 | ---Purpose : Returns count of values, edited (D) or original |
124 | |
125 | Value (me; num : Integer; edited : Boolean = Standard_True) |
126 | returns HAsciiString; |
127 | ---Purpose : Returns a value given its rank. Edited (D) or Original |
128 | -- A Null String means the value is cleared but not removed |
129 | |
130 | IsChanged (me; num : Integer) returns Boolean; |
131 | ---Purpose : Tells if a value (in edited list) has been changed, i.e. |
132 | -- either modified-value, or added |
133 | |
134 | IsModified (me; num : Integer) returns Boolean; |
135 | ---Purpose : Tells if a value (in edited list) has been modified-value |
136 | -- (not added) |
137 | |
138 | IsAdded (me; num : Integer) returns Boolean; |
139 | ---Purpose : Tells if a value (in edited list) has been added (new one) |
140 | |
141 | |
142 | IsTouched (me) returns Boolean; |
143 | ---Purpose : Tells if at least one edition (SetValue-AddValue-Remove) has |
144 | -- been recorded |
145 | |
146 | fields |
147 | |
148 | themax : Integer; |
149 | thedef : TypedValue; |
150 | thetouc : Integer; -- global IsTouched |
151 | theorig : HSequenceOfHAsciiString; |
152 | theedit : HSequenceOfHAsciiString; |
153 | thestat : HSequenceOfInteger; |
154 | themodl : InterfaceModel; |
155 | |
156 | end ListEditor; |