/[gnustep]/gnustep/core/gui/Headers/Additions/GNUstepGUI/GSLayoutManager.h
ViewVC logotype

Contents of /gnustep/core/gui/Headers/Additions/GNUstepGUI/GSLayoutManager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Jul 31 23:52:08 2003 UTC (20 years, 8 months ago) by ayers
Branch: MAIN
CVS Tags: gui-0_8_9
File MIME type: text/plain
        Header reorganization - Please refer to ChangeLog

1 /*
2 GSLayoutManager.h
3
4 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
5
6 Author: Alexander Malmberg <alexander@malmberg.org>
7 Date: November 2002 - February 2003
8
9 This file is part of the GNUstep GUI Library.
10
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20
21 You should have received a copy of the GNU Library General Public
22 License along with this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 #ifndef _GNUstep_H_GSLayoutManager
28 #define _GNUstep_H_GSLayoutManager
29
30 #include <Foundation/NSObject.h>
31 #include <Foundation/NSGeometry.h>
32 #include <AppKit/NSFont.h>
33
34 @class GSTypesetter;
35 @class NSTextStorage,NSTextContainer;
36
37 typedef enum
38 {
39 NSGlyphInscribeBase = 0,
40 NSGlyphInscribeBelow = 1,
41 NSGlyphInscribeAbove = 2,
42 NSGlyphInscribeOverstrike = 3,
43 NSGlyphInscribeOverBelow = 4
44 } NSGlyphInscription;
45
46 @interface GSLayoutManager : NSObject
47 {
48 @protected
49 NSTextStorage *_textStorage;
50
51 id _delegate;
52
53 BOOL usesScreenFonts;
54 BOOL backgroundLayoutEnabled;
55 BOOL showsInvisibleCharacters;
56 BOOL showsControlCharacters;
57
58 GSTypesetter *typesetter;
59
60
61 /* Glyph storage */
62
63 /* Skip list of runs */
64 struct GSLayoutManager_glyph_run_head_s *glyphs;
65
66 /* number of runs created from existing text (ie. not as a result of
67 stuff being invalidated) */
68 int glyph_num_end_runs;
69
70
71 /* Layout storage */
72 /* OPT: This is just a simple implementation that should let me figure out
73 how it's supposed to work. It's functional and correct, but it isn't fast. */
74
75 unsigned int layout_glyph, layout_char;
76
77 struct GSLayoutManager_textcontainer_s *textcontainers;
78 int num_textcontainers;
79
80 NSRect extra_rect, extra_used_rect;
81 NSTextContainer *extra_textcontainer;
82
83
84 /* For -rectArrayForGlyphRange:... */
85 NSRect *rect_array;
86 int rect_array_size;
87
88
89 /*
90 Cached run. GSHorizontalTypesetter (and other typesetters, presumably)
91 often walk linearly through the glyphs. Thus, for many methods, we cache
92 the last run so we can quickly get more information for the next glyph.
93 */
94 struct GSLayoutManager_glyph_run_s *cached_run;
95 unsigned int cached_pos, cached_cpos;
96 }
97
98
99 - (NSTextStorage *) textStorage;
100 - (void) setTextStorage: (NSTextStorage *)aTextStorage;
101 - (void) replaceTextStorage: (NSTextStorage *)newTextStorage;
102
103
104 - (id) delegate;
105 - (void) setDelegate: (id)aDelegate;
106
107
108 -(GSTypesetter *) typesetter;
109 -(void) setTypesetter: (GSTypesetter *)typesetter;
110
111
112 - (void) setBackgroundLayoutEnabled: (BOOL)flag;
113 - (BOOL) backgroundLayoutEnabled;
114
115 - (void) setShowsInvisibleCharacters: (BOOL)flag;
116 - (BOOL) showsInvisibleCharacters;
117
118 - (void) setShowsControlCharacters: (BOOL)flag;
119 - (BOOL) showsControlCharacters;
120
121
122 /** Font handling **/
123
124 - (BOOL) usesScreenFonts;
125 - (void) setUsesScreenFonts: (BOOL)flag;
126
127 - (NSFont *) substituteFontForFont: (NSFont *)originalFont;
128
129
130 /*
131 (?)
132 Sent by the NSTextStorage. mask tells us if attributes or characters (or
133 both) have been changed. range is the range of directly modified
134 characters. invalidatedRange is the range of characters affected by the
135 changes (contains range but may be larger due to eg. attribute fixing).
136 If characters have been edited, lengthChange has the text length delta.
137 */
138 - (void) textStorage: (NSTextStorage *)aTextStorage
139 edited: (unsigned int)mask
140 range: (NSRange)range
141 changeInLength: (int)lengthChange
142 invalidatedRange: (NSRange)invalidatedRange;
143
144 @end
145
146
147 @interface GSLayoutManager (glyphs)
148
149 /** Glyph handling **/
150
151 /*
152 Mark the glyphs for the characters in aRange as invalid. lengthChange
153 is the text length delta. If not NULL, the range of characters actually
154 affected (_after_ the change) will be returned in actualRange.
155
156 This method is used internally and should _not_ be called. (It interacts
157 in complex ways with layout invalidation.)
158 */
159 - (void) invalidateGlyphsForCharacterRange: (NSRange)aRange
160 changeInLength: (int)lengthChange
161 actualCharacterRange: (NSRange *)actualRange;
162
163 /*
164 These are internal methods and should _not_ be called.
165 */
166 - (void) insertGlyph: (NSGlyph)aGlyph
167 atGlyphIndex: (unsigned int)glyphIndex
168 characterIndex: (unsigned int)charIndex;
169 - (void) replaceGlyphAtIndex: (unsigned int)glyphIndex
170 withGlyph: (NSGlyph)newGlyph;
171 - (void) deleteGlyphsInRange: (NSRange)aRange;
172 - (void) setCharacterIndex: (unsigned int)charIndex
173 forGlyphAtIndex: (unsigned int)glyphIndex;
174
175
176 /* Returns total number of glyphs. */
177 - (unsigned int) numberOfGlyphs;
178
179 /* Returns the glyph at glyphIndex or raises an NSRangeException if the
180 index is invalid (past the end of the glyphs). */
181 - (NSGlyph) glyphAtIndex: (unsigned int)glyphIndex;
182
183 /* Returns the glyph at glyphIndex and sets isValidIndex to YES if the index
184 is valid. Otherwise, the return value is arbitrary and isValidIndex is set
185 to NO. */
186 - (NSGlyph) glyphAtIndex: (unsigned int)glyphIndex
187 isValidIndex: (BOOL *)isValidIndex;
188
189 /* Copies displayed glyphs to glyphArray for glyphRange. Returns the number
190 of glyphs actually copied to the array. NSRangeException of the range is
191 invalid (extends beyond the end of glyphs). */
192 - (unsigned int) getGlyphs: (NSGlyph *)glyphArray
193 range: (NSRange)glyphRange;
194
195 /* Return the first character for the glyph at glyphIndex.
196 (NSRangeException?) */
197 - (unsigned int) characterIndexForGlyphAtIndex: (unsigned int)glyphIndex;
198
199 /* Returns the range of glyphs for the characters in charRange. If
200 actualRange isn't NULL, the exact range of characters for the glyphs in the
201 returned range is returned there. */
202 - (NSRange) glyphRangeForCharacterRange: (NSRange)charRange
203 actualCharacterRange: (NSRange *)actualCharRange;
204
205 /* Returns the range of characters for the glyphs in glyphRange. Returns
206 the actual glyphs for the characters in the range in actualGlyphRange, if
207 it isn't NULL. */
208 - (NSRange) characterRangeForGlyphRange: (NSRange)glyphRange
209 actualGlyphRange: (NSRange *)actualGlyphRange;
210
211
212 /* These can be used to set arbitrary tags on individual glyphs.
213 Non-negative tags are reserved. You must provide storage yourself (by
214 subclassing). */
215 - (void) setIntAttribute: (int)attributeTag
216 value: (int)anInt
217 forGlyphAtIndex: (unsigned int)glyphIndex;
218 - (int) intAttribute: (int)attributeTag
219 forGlyphAtIndex: (unsigned int)glyphIndex;
220
221
222 /* Returns the font actually used for a range of glyphs. This isn't
223 necessarily the font specified by NSFontAttributeName; both the typesetter
224 and the layout manager can substitute a different font (the typesetter might
225 eg. substitute a smaller font for sub-/super-scripted text, and the layout
226 manager might be substituting screen fonts. */
227 - (NSFont *) effectiveFontForGlyphAtIndex: (unsigned int)glyphIndex
228 range: (NSRange *)range; /* GNUstep extension */
229
230
231 - (void) setDrawsOutsideLineFragment: (BOOL)flag
232 forGlyphAtIndex: (unsigned int)glyphIndex;
233 - (BOOL) drawsOutsideLineFragmentForGlyphAtIndex: (unsigned int) glyphIndex;
234
235 - (void) setNotShownAttribute: (BOOL)flag
236 forGlyphAtIndex: (unsigned int)glyphIndex;
237 - (BOOL) notShownAttributeForGlyphAtIndex: (unsigned int) glyphIndex;
238
239 @end
240
241
242 @interface GSLayoutManager (layout)
243
244 /** Text containers **/
245
246 - (NSArray *) textContainers;
247
248 - (void) addTextContainer: (NSTextContainer *)container;
249 - (void) insertTextContainer: (NSTextContainer*)aTextContainer
250 atIndex: (unsigned int)index;
251 - (void) removeTextContainerAtIndex: (unsigned int)index;
252
253 - (void) textContainerChangedGeometry: (NSTextContainer *)aContainer;
254
255
256 /** Layout **/
257
258 /*
259 This method is used internally and should _not_ be called. (It interacts
260 in complex ways with glyph invalidation, and with itself when doing soft
261 invalidation.)
262 */
263 - (void) invalidateLayoutForCharacterRange: (NSRange)aRange
264 isSoft: (BOOL)flag
265 actualCharacterRange: (NSRange *)actualRange;
266
267
268 - (void) setTextContainer: (NSTextContainer *)aTextContainer
269 forGlyphRange: (NSRange)glyphRange;
270
271 - (void) setLineFragmentRect: (NSRect)fragmentRect
272 forGlyphRange: (NSRange)glyphRange
273 usedRect: (NSRect)usedRect;
274
275 - (void) setLocation: (NSPoint)location
276 forStartOfGlyphRange: (NSRange)glyphRange;
277
278 - (void) setAttachmentSize: (NSSize)attachmentSize
279 forGlyphRange: (NSRange)glyphRange; /* not OPENSTEP */
280
281
282 - (NSTextContainer *) textContainerForGlyphAtIndex: (unsigned int)glyphIndex
283 effectiveRange: (NSRange *)effectiveRange;
284 - (NSRect) lineFragmentRectForGlyphAtIndex: (unsigned int)glyphIndex
285 effectiveRange: (NSRange *)effectiveGlyphRange;
286 - (NSRect) lineFragmentUsedRectForGlyphAtIndex: (unsigned int)glyphIndex
287 effectiveRange: (NSRange *)effectiveGlyphRange;
288
289
290 /*
291 The typesetter may set this to mark where the rectangle the insertion point
292 is to be placed if the insertion point is beyond the last character of the
293 text. The extra text container is reset to nil any time layout is
294 invalidated.
295 */
296 -(void) setExtraLineFragmentRect: (NSRect)linefrag
297 usedRect: (NSRect)used
298 textContainer: (NSTextContainer *)tc;
299
300 -(NSRect) extraLineFragmentRect;
301 -(NSRect) extraLineFragmentUsedRect;
302 -(NSTextContainer *) extraLineFragmentTextContainer;
303
304
305 /* Extension, but without this, there's no way to get the starting locations
306 of the nominally spaced glyphs. */
307 - (NSRange) rangeOfNominallySpacedGlyphsContainingIndex:(unsigned int)glyphIndex
308 startLocation: (NSPoint *)p;
309
310 - (NSRange) rangeOfNominallySpacedGlyphsContainingIndex:(unsigned int)glyphIndex;
311
312 /* The union of all line frag rects' used rects. (TODO: shouldn't this be
313 just the union of all the line frag rects?) */
314 - (NSRect) usedRectForTextContainer: (NSTextContainer *)container;
315
316 - (NSRange) glyphRangeForTextContainer: (NSTextContainer *)container;
317
318
319 - (unsigned int) firstUnlaidCharacterIndex;
320 - (unsigned int) firstUnlaidGlyphIndex;
321 - (void) getFirstUnlaidCharacterIndex: (unsigned int *)charIndex
322 glyphIndex: (unsigned int *)glyphIndex;
323
324
325 /*
326 Basic (and experimental) methods that let the typesetter use soft-invalidated
327 layout information.
328 */
329 -(void) _softInvalidateUseLineFrags: (int)num
330 withShift: (NSSize)shift
331 inTextContainer: (NSTextContainer *)textContainer;
332 -(NSRect) _softInvalidateLineFragRect: (int)index
333 firstGlyph: (unsigned int *)first_glyph
334 nextGlyph: (unsigned int *)next_glyph
335 inTextContainer: (NSTextContainer *)textContainer;
336 -(unsigned int) _softInvalidateFirstGlyphInTextContainer: (NSTextContainer *)textContainer;
337 -(unsigned int) _softInvalidateNumberOfLineFragsInTextContainer: (NSTextContainer *)textContainer;
338
339 @end
340
341
342 @interface NSObject (GSLayoutManagerDelegate)
343 -(void) layoutManager: (GSLayoutManager *)layoutManager
344 didCompleteLayoutForTextContainer: (NSTextContainer *)textContainer
345 atEnd: (BOOL)atEnd;
346 @end
347
348
349 #endif
350

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26