summaryrefslogtreecommitdiff
path: root/src/Graphic2d/Graphic2d_Paragraph.cdl
blob: 23c8cdda792dfbb9707c737372925ed21d7fa704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341

-- File:	Graphic2d_Paragraph.cdl
-- Created:	Mon Jun 12 16:36:51 1995
-- Author:	Gerard GRAS
--		<gg@azimox>
-- Update:	GG 20/08/98 PERFORMANCE
--		Change Update() method by ComputeMinMax() method 

---Copyright:	 Matra Datavision 1993

class Paragraph from Graphic2d inherits Primitive from Graphic2d

	---Version:

	---Purpose: The primitive Paragraph
	--	    contains a row column of editable texts
	--	    each text can have a different color and font index.

	---Keywords: Primitive, Paragraph, Text
	---Warning:
	---References:

uses
	Drawer				from Graphic2d,
	GraphicObject			from Graphic2d,
	TypeOfAlignment			from Graphic2d,
	PlaneAngle			from Quantity,
	Ratio				from Quantity,
	Factor				from Quantity,
	Length				from Quantity,
	ExtendedString			from TCollection,
	SequenceOfInteger		from TColStd,
	SequenceOfShortReal		from TShort,
	SequenceOfExtendedString	from TColStd,
	CardinalPoints			from Aspect,
	FStream				from Aspect,
	IFStream			from Aspect

raises
	OutOfRange from Standard

is
	-------------------------
	-- Category: Constructors
	-------------------------

	Create (aGraphicObject: GraphicObject from Graphic2d;
		X, Y: Real from Standard;
		anAngle: PlaneAngle from Quantity = 0.0;
		anOffset: CardinalPoints from Aspect = Aspect_CP_Center;
                aScale: Factor from Quantity = 1.0)
	returns mutable Paragraph from Graphic2d;
	---Level: Public
	---Purpose: Creates a paragraph in a graphic object <aGraphicObject>
	--	    The reference point is <X>, <Y>.
	--	    The orientation angle is <anAngle>.
	--	    The offset position of the reference point is <aPosition> 
	--	    depending of the size of paragraph.
	--	    The paragraph scale.
	--	    Angles are measured counterclockwise with 0 radian
	--	    at 3 o'clock.
	--  Warning: a paragraph can be orientable.slantable and zoomable 
	-- only when this options are enable regardless of the graphic driver.
	-- i.e: Xw driver does not,but Xdps or PS driver does.
	---Category: Constructors

	---------------------------------------------------
	-- Category: Methods to modify the class definition
	---------------------------------------------------

	SetSlant (me: mutable; aSlant: PlaneAngle from Quantity = 0.0)
	is static;
	---Level: Public
	---Purpose: Sets the slant angle of the paragraph <me>.
        ---Category: Paragraph management

	SetSpacing(me: mutable; aSpacing: Ratio from Quantity = 0.5)
	is static;
	---Level: Public
	---Purpose: Sets the line spacing ratio for the paragraph <me>.
	--	    the spacing height between two lines depends of
	--	    the spacing factor apply on the height of the line currently	--	    writen.
        ---Category: Paragraph management

	SetMargin(me: mutable; aMargin: Length from Quantity = 0.0)
	is static;
	---Level: Public
	---Purpose: Sets the fixed margin for the paragraph <me>.
        ---Category: Paragraph management

        SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_False)
        is static;
	---Level: Public
        ---Purpose: The paragraph <me> follows the scale factor of the view
        --          if the flag is Standard_True.
        ---Category: Zoom management


	SetFrameColorIndex (me:mutable; anIndex: Integer from Standard = 0)
	is static;
	---Level: Public
	---Purpose: Sets the frame color index for the paragraph <me>.
        --  Warning: Note that the paragraph frame is drawn only when index 
	--	   is > 0.
        ---Category: Paragraph management

        SetFrameWidthIndex (me:mutable; anIndex: Integer from Standard = 0)
        is static;
        ---Level: Public
        ---Purpose: Sets the width index for the frame of the paragraph <me>.
        --          default width is 0 (1 pixel out line frame is drawn).

	SetHidingColorIndex (me:mutable; anIndex: Integer from Standard = 0)
	is static;
	---Level: Public
	---Purpose: Sets the hiding color index for the paragraph <me>.
        --  Warning: Note that the paragraph background is filled only when index 
	--	is >= 0.
	--	 A value of 0 permits to drawn the paragraph background with
	--	the current view background color.
        ---Category: Paragraph management

	SetCurrentColorIndex (me:mutable; anIndex: Integer from Standard = 1)
	is static;
	---Level: Public
	---Purpose: Sets the current color index for the paragraph <me>.
        --  Warning: Note that the index 0 can be undefined as a ColorMapEntry,
        --        in this case the default color is taken.
        ---Category: Paragraph management

        SetCurrentFontIndex (me:mutable; anIndex: Integer from Standard = 0;
                                aHScale: Length from Quantity = 1.0;
                                aWScale: Length from Quantity = 1.0)
        is static;
        ---Level: Public
        ---Purpose: Sets the current font index and scales for the paragraph <me>.
        --  Warning: Note that the index 0 can be undefined as a FontMapEntry ,
        --         in this case the default system text font is taken.
        ---Category: Paragraph management

	SetCurrentAlignment (me:mutable; anAlignment: TypeOfAlignment from Graphic2d = 
							Graphic2d_TOA_LEFT)
	is static;
	---Level: Public
	---Purpose: Sets the current text alignment for the paragraph <me>.
        ---Category: Paragraph management

	SetCurrentUnderline (me:mutable; isUnderlined: Boolean from Standard =
						Standard_False)
	is static;
	---Level: Public
	---Purpose: Sets the current text underline flag for the paragraph <me>.
        ---Category: Paragraph management

	AddText (me: mutable; aText: ExtendedString from TCollection;
	     		      aRow: Integer from Standard = 0;
	     		      aColumn: Integer from Standard = 0)
        is static;
	---Level: Public
	---Purpose: Adds a text at a row-column position in the paragraph <me>
	-- with the current Color,Font,Alignment attributes
	-- at the position <aColumn,aRow> if <aColumn> and <aRow> are > 0
	--  or at the end of the line if <aColumn> is 0, 
	--  or at the end of the paragraph if <aRow> is 0.
        ---Category: Paragraph management

	ChangeText (me: mutable; aText: ExtendedString from TCollection;
	     		      aRow: Integer from Standard;
	     		      aColumn: Integer from Standard)
        is static;
	---Level: Public
	---Purpose: Changes a text in the paragraph at a row-column position,
	--	    don't change the attributes of the text.
	--  Warning: May do nothing if the row-column don't exist in the
	--	   paragraph.
        ---Category: Paragraph management

        Clear (me: mutable) is static;
        ---Level: Public   
        ---Purpose: Clear ALL the text in the paragraph <me>.
        ---Category: Paragraph management

	--------------------------
	-- Category: Draw and Pick
	--------------------------

	Draw (me : mutable; aDrawer: Drawer from Graphic2d)
	is static protected;
	---Level: Internal
	---Purpose: Draws the paragraph <me>.

	Pick (me : mutable; X, Y: ShortReal from Standard;
		aPrecision: ShortReal from Standard;
		aDrawer: Drawer from Graphic2d)
	returns Boolean from Standard
	is static protected;
	---Level: Internal
	---Purpose: Returns Standard_True if the paragraph <me> is picked,
	--	    Standard_False if not.

    
        ----------------------------
        -- Category: Inquire methods
        ----------------------------
 
        IsZoomable (me)
                returns Boolean from Standard is static;
        ---Level: Internal
        ---Purpose: Returns Standard_True if the Paragraph <me> follows
        --          the scale factor of the view.
        ---Category: Zoom management

        Size (me; aWidth,aHeight: out Length from Quantity) is static;
        ---Level: Public
        ---Purpose: Returns the size of the paragraph <me> .
        ---Category: Paragraph management

        Position (me; X,Y: out Length from Quantity) is static;
        ---Level: Public
        ---Purpose: Returns the paragraph position.

        Offset (me; Dx,Dy: out Length from Quantity) 
	returns CardinalPoints from Aspect is static;
        ---Level: Public
        ---Purpose: Returns the paragraph Offset.

        Angle (me) returns PlaneAngle from Quantity is static;
        ---Level: Public
        ---Purpose: Returns the paragraph orientation.

        Slant (me) returns PlaneAngle from Quantity is static;
        ---Level: Public
        ---Purpose: Returns the paragraph slant.

        Spacing (me) returns Ratio from Quantity is static;
        ---Level: Public
        ---Purpose: Returns the paragraph spacing ratio.

        Margin (me) returns Length from Quantity is static;
        ---Level: Public
        ---Purpose: Returns the paragraph margin value.

        HidingColorIndex (me) returns Integer from Standard is static;
        ---Level: Public
        ---Purpose: Returns the paragraph hiding color index.

        FrameColorIndex (me) returns Integer from Standard is static;
        ---Level: Public
        ---Purpose: Returns the paragraph frame color index.

        FrameWidthIndex (me) returns Integer from Standard is static;
        ---Level: Public
        ---Purpose: Returns the paragraph frame width index.

	    Text( me; aRank: Integer from Standard;
		      aRow,aColumn: out Integer from Standard;
		      aColorIndex,aFontIndex: out Integer from Standard;
		      anAlignment: out TypeOfAlignment from Graphic2d)
        returns ExtendedString from TCollection
	    ---Level: Public
	    ---Purpose: Returns the text string and attributes of rank <aRank>.
	       raises OutOfRange is static;
	    ---Trigger: if aRank is < 1 or > Length().
        ---Category: Paragraph management

        TextSize (me; aRank: Integer from Standard;
	              aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity)
                returns Boolean from Standard
        ---Level: Public
        ---Purpose: Returns Standard_True if the current Driver used is enabled
        --         to get the right size and offsets in the
        --         world size parameter <aWidth>,<aHeight>,<anXoffset>,<anYoffset>
        --         depending of the attributes of the paragraph text position
    	--	    <aRank> and the current scale of the view.
        --          NOTE that the text offsets defines the relative position of the
        --         of the text string origin from the lower left corner of the text
        --         boundary limits.
	       raises OutOfRange is static;
	    ---Trigger: if aRank is < 1 or > Length().
        ---Category: Paragraph management

	    Length (me) returns Integer is static;
	    ---Level: Public
	    ---Purpose: Returns the number of Text of the paragraph <me>.

	    MaxRow (me) returns Integer is static;
	    ---Level: Public
	    ---Purpose: Returns the number of Row of the paragraph <me>.

	    MaxColumn (me) returns Integer is static;
	    ---Level: Public
	    ---Purpose: Returns the number of Column of the paragraph <me>.

        ----------------------------
        -- Category: Private methods
        ----------------------------

        ComputeMinMax (me : mutable)
                returns Boolean from Standard is redefined static;
        ---Level: Internal
        ---Purpose: Computes the MinMax of the paragraph if possible.

	----------------------------------------------------------------------

	Save( me; aFStream: in out FStream from Aspect ) is virtual;
--	Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual;

fields

	myX:		ShortReal from Standard;
	myY:		ShortReal from Standard;
	myXoffset:	ShortReal from Standard;
	myYoffset:	ShortReal from Standard;
	myOffset:	CardinalPoints from Aspect;
	myWidth:	ShortReal from Standard;
	myHeight:	ShortReal from Standard;
	myAngle:	ShortReal from Standard;
	mySlant:	ShortReal from Standard;
	mySpacing:	ShortReal from Standard;
	myMargin:	ShortReal from Standard;
	myScale:	ShortReal from Standard;
    myIsZoomable:           Boolean from Standard;
	myFrameColorIndex:	    Integer from Standard;
	myFrameWidthIndex:	    Integer from Standard;
	myHidingColorIndex:	    Integer from Standard;
	myCurrentColorIndex:	Integer from Standard;
	myCurrentFontIndex:	    Integer from Standard;
    myCurrentFontHScale:    ShortReal from Standard;
    myCurrentFontWScale:    ShortReal from Standard;
	myCurrentAlignment:	    TypeOfAlignment from Graphic2d;
	myCurrentUnderline:	    Boolean from Standard;
	myTextStringList:	    SequenceOfExtendedString from TColStd;
	myTextDescriptorList:	SequenceOfInteger from TColStd;
	myTextXpositionList:	SequenceOfShortReal from TShort;
	myTextYpositionList:	SequenceOfShortReal from TShort;
	myTextFheightList:	    SequenceOfShortReal from TShort;
	myTextFoffsetList:	    SequenceOfShortReal from TShort;
    myTextHScaleList:       SequenceOfShortReal from TShort;
    myTextWScaleList:       SequenceOfShortReal from TShort;

end Paragraph from Graphic2d;