1 /*
2    NSParagraphStyle.h
3 
4      NSParagraphStyle and NSMutableParagraphStyle hold paragraph style
5      information NSTextTab holds information about a single tab stop
6 
7    Copyright (C) 1996,1999 Free Software Foundation, Inc.
8 
9    Author:  Daniel Böhringer <boehring@biomed.ruhr-uni-bochum.de>
10    Date: August 1998
11    Update: Richard Frith-Macdonald <richard@brainstorm.co.uk> March 1999
12 
13    This file is part of the GNUstep GUI Library.
14 
15    This library is free software; you can redistribute it and/or
16    modify it under the terms of the GNU Lesser General Public
17    License as published by the Free Software Foundation; either
18    version 2 of the License, or (at your option) any later version.
19 
20    This library is distributed in the hope that it will be useful,
21    but WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
23    Lesser General Public License for more details.
24 
25    You should have received a copy of the GNU Lesser General Public
26    License along with this library; see the file COPYING.LIB.
27    If not, see <http://www.gnu.org/licenses/> or write to the
28    Free Software Foundation, 51 Franklin Street, Fifth Floor,
29    Boston, MA 02110-1301, USA.
30 */
31 
32 #ifndef _GNUstep_H_NSParagraphStyle
33 #define _GNUstep_H_NSParagraphStyle
34 #import <GNUstepBase/GSVersionMacros.h>
35 
36 #import <Foundation/NSObject.h>
37 #import <AppKit/NSText.h>
38 
39 typedef enum _NSTextTabType {
40   NSLeftTabStopType = 0,
41   NSRightTabStopType,
42   NSCenterTabStopType,
43   NSDecimalTabStopType
44 } NSTextTabType;
45 
46 enum _NSLineBreakMode {		/* What to do with long lines */
47   NSLineBreakByWordWrapping = 0,     	/* Wrap at word boundaries, default */
48   NSLineBreakByCharWrapping,		/* Wrap at character boundaries */
49   NSLineBreakByClipping,		/* Simply clip */
50   NSLineBreakByTruncatingHead,	/* Truncate at head of line: "...wxyz" */
51   NSLineBreakByTruncatingTail,	/* Truncate at tail of line: "abcd..." */
52   NSLineBreakByTruncatingMiddle	/* Truncate middle of line:  "ab...yz" */
53 };
54 typedef NSUInteger NSLineBreakMode;
55 
56 enum _NSWritingDirection {
57     NSWritingDirectionNaturalDirection,
58     NSWritingDirectionLeftToRight,
59     NSWritingDirectionRightToLeft
60 };
61 enum {
62   NSWritingDirectionNatural = NSWritingDirectionNaturalDirection
63 };
64 typedef NSInteger NSWritingDirection;
65 
66 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
67 APPKIT_EXPORT NSString *NSTabColumnTerminatorsAttributeName;
68 #endif
69 
70 @interface NSTextTab : NSObject <NSCopying, NSCoding>
71 {
72   NSTextTabType	_tabStopType;
73   NSDictionary *_options;
74   NSTextAlignment _alignment;
75   float	_location;
76 }
77 
78 - (id) initWithType: (NSTextTabType)type  location: (CGFloat)loc;
79 - (CGFloat) location;
80 - (NSTextTabType) tabStopType;
81 
82 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
83 - (id) initWithTextAlignment: (NSTextAlignment)align
84                     location: (CGFloat)loc
85                      options: (NSDictionary *)options;
86 - (NSTextAlignment) alignment;
87 - (NSDictionary *) options;
88 #endif
89 
90 @end
91 
92 @interface NSParagraphStyle : NSObject <NSCopying, NSMutableCopying, NSCoding>
93 {
94   NSMutableArray *_tabStops;
95   NSArray *_textBlocks;
96   NSArray *_textLists;
97   float _lineSpacing;
98   float _paragraphSpacing;
99   float _headIndent;
100   float _tailIndent;
101   float _firstLineHeadIndent;
102   float _minimumLineHeight;
103   float _maximumLineHeight;
104   float _paragraphSpacingBefore;
105   float _defaultTabInterval;
106   float _hyphenationFactor;
107   float _lineHeightMultiple;
108   float _tighteningFactorForTruncation;
109   NSTextAlignment _alignment;
110   NSLineBreakMode _lineBreakMode;
111   NSWritingDirection _baseDirection;
112   int _headerLevel;
113 }
114 
115 + (NSParagraphStyle*) defaultParagraphStyle;
116 
117 /*
118  *	"Leading": distance between the bottom of one line fragment and top
119  *	of next (applied between lines in the same container).
120  *	Can't be negative. This value is included in the line fragment
121  *	heights in layout manager.
122  */
123 - (CGFloat) lineSpacing;
124 
125 /*
126  *	Distance between the bottom of this paragraph and top of next.
127  */
128 - (CGFloat) paragraphSpacing;
129 
130 - (NSTextAlignment) alignment;
131 
132 /*
133  *	The following values are relative to the appropriate margin
134  *	(depending on the paragraph direction)
135  */
136 
137 /*
138  *	Distance from margin to front edge of paragraph
139  */
140 - (CGFloat) headIndent;
141 
142 /*
143  *	Distance from margin to back edge of paragraph; if negative or 0,
144  *	from other margin
145  */
146 - (CGFloat) tailIndent;
147 
148 /*
149  *	Distance from margin to edge appropriate for text direction
150  */
151 - (CGFloat) firstLineHeadIndent;
152 
153 /*
154  *	Distance from margin to tab stops
155  */
156 - (NSArray *)tabStops;
157 
158 /*
159  *	Line height is the distance from bottom of descenders to to
160  *	of ascenders; basically the line fragment height. Does not include
161  *	lineSpacing (which is added after this computation).
162  */
163 - (CGFloat) minimumLineHeight;
164 
165 /*
166  *	0 implies no maximum.
167  */
168 - (CGFloat) maximumLineHeight;
169 - (NSLineBreakMode) lineBreakMode;
170 
171 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
172 /*
173  *      Returns the writing direction of "language", which is an ISO 639
174  *      two- or three letter code, e.g. "en", or an ISO language-region
175  *      format, e.g. "en_GB"
176  */
177 + (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language;
178 - (NSWritingDirection) baseWritingDirection;
179 #endif
180 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
181 - (CGFloat) defaultTabInterval;
182 - (CGFloat) lineHeightMultiple;
183 - (CGFloat) paragraphSpacingBefore;
184 #endif
185 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
186 - (NSInteger) headerLevel;
187 - (float) hyphenationFactor;
188 - (NSArray *) textBlocks;
189 - (NSArray *) textLists;
190 - (float) tighteningFactorForTruncation;
191 #endif
192 
193 @end
194 
195 @interface NSMutableParagraphStyle : NSParagraphStyle
196 {
197 }
198 
199 - (void) setLineSpacing: (CGFloat)aFloat;
200 - (void) setParagraphSpacing: (CGFloat)aFloat;
201 - (void) setAlignment: (NSTextAlignment)newAlignment;
202 - (void) setFirstLineHeadIndent: (CGFloat)aFloat;
203 - (void) setHeadIndent: (CGFloat)aFloat;
204 - (void) setTailIndent: (CGFloat)aFloat;
205 - (void) setLineBreakMode: (NSLineBreakMode)mode;
206 - (void) setMinimumLineHeight: (CGFloat)aFloat;
207 - (void) setMaximumLineHeight: (CGFloat)aFloat;
208 - (void) addTabStop: (NSTextTab*)anObject;
209 - (void) removeTabStop: (NSTextTab*)anObject;
210 - (void) setTabStops: (NSArray*)array;
211 - (void) setParagraphStyle: (NSParagraphStyle*)obj;
212 
213 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
214 - (void) setBaseWritingDirection: (NSWritingDirection)direction;
215 #endif
216 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
217 - (void) setDefaultTabInterval: (CGFloat)interval;
218 - (void) setLineHeightMultiple: (CGFloat)factor;
219 - (void) setParagraphSpacingBefore: (CGFloat)spacing;
220 #endif
221 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
222 - (void) setHeaderLevel: (NSInteger)level;
223 - (void) setHyphenationFactor: (float)factor;
224 - (void) setTextBlocks: (NSArray *)blocks;
225 - (void) setTextLists: (NSArray *)lists;
226 - (void) setTighteningFactorForTruncation: (float)factor;
227 #endif
228 
229 @end
230 
231 #endif // _GNUstep_H_NSParagraphStyle
232