backport this one too
[mono.git] / mcs / class / System.Drawing / System.Drawing / StringFormat.jvm.cs
1 //
2 // System.Drawing.StringFormat.cs
3 //
4 // Authors:
5 //   Dennis Hayes (dennish@Raytek.com)
6 //   Miguel de Icaza (miguel@ximian.com)
7 //   Jordi Mas i Hernandez (jordi@ximian.com)
8 //
9 // Copyright (C) 2002 Ximian, Inc (http://www.ximian.com)
10 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32 using System;
33 using System.Drawing.Text;
34
35 namespace System.Drawing
36 {
37         /// <summary>
38         /// Summary description for StringFormat.
39         /// </summary>
40         public sealed class StringFormat : IDisposable, ICloneable
41         {
42                 private static StringFormat genericDefault;
43                 private int language = 0;
44                 internal CharacterRange [] CharRanges;
45
46                 //local storage
47                 internal StringAlignment alignment;
48                 internal StringAlignment linealignment;
49                 internal HotkeyPrefix prefix;
50                 internal StringFormatFlags flags;
51                 internal StringDigitSubstitute subst;
52                 internal StringTrimming trimming;
53                 internal float firstTabOffset;
54                 internal float [] tabStops;
55                 
56                 public StringFormat()
57                 {                                          
58                         
59                 }               
60                 
61                 public StringFormat(StringFormatFlags options, int lang)
62                 {
63                                 flags = options;
64                                 LineAlignment =  StringAlignment.Near;
65                                 Alignment =  StringAlignment.Near;                      
66                                 language = lang;
67                 }
68                 
69                 public StringFormat(StringFormatFlags options):this(options,0)
70                 {
71                 }
72                 
73 //              ~StringFormat()
74 //              {       
75 //                      Dispose ();
76 //              }
77                 
78                 public void Dispose()
79                 {       
80                 }
81
82
83                 public StringFormat (StringFormat source)
84                 {
85                         Alignment = source.Alignment;
86                         LineAlignment = source.LineAlignment;
87                         HotkeyPrefix = source.HotkeyPrefix;
88                         subst = source.subst;
89                         flags = source.flags;
90                 }
91
92                 
93                 public StringAlignment Alignment 
94                 {
95                         get 
96                         {
97                                 return alignment;
98                         }
99
100                         set 
101                         {
102                                 alignment = value;
103                         }
104                 }
105
106                 public StringAlignment LineAlignment 
107                 {
108                         get 
109                         {
110                                 return linealignment;
111                         }
112                         set 
113                         {
114                                 linealignment = value;
115                         }
116                 }
117
118                 public StringFormatFlags FormatFlags 
119                 {
120                         get 
121                         {                               
122                                 return flags;
123                         }
124
125                         set 
126                         {
127                                 flags = value;
128                         }
129                 }
130
131                 public HotkeyPrefix HotkeyPrefix 
132                 {
133                         get 
134                         {                               
135                                 return prefix;
136                         }
137
138                         set 
139                         {
140                                 prefix = value;
141                         }
142                 }
143
144
145                 public StringTrimming Trimming 
146                 {
147                         get 
148                         {
149                                 return trimming;
150                         }
151
152                         set 
153                         {
154                                 trimming = value;
155                         }
156                 }
157
158                 public static StringFormat GenericDefault 
159                 {
160                         get 
161                         {
162                                 return genericDefault;
163                         }
164                 }
165                 
166                 
167                 public int DigitSubstitutionLanguage 
168                 {
169                         get
170                         {
171                                 return language;
172                         }
173                 }
174
175                 
176                 public static StringFormat GenericTypographic 
177                 {
178                         get 
179                         {
180                                 throw new NotImplementedException();
181                         }
182                 }
183
184                 public StringDigitSubstitute  DigitSubstitutionMethod  
185                 {
186                         get 
187                         {
188                                 return subst;     
189                         }
190                 }
191
192
193                 public void SetMeasurableCharacterRanges (CharacterRange [] range)
194                 {
195                         CharRanges=(CharacterRange [])range.Clone();
196                 }
197
198                 internal CharacterRange [] GetCharRanges
199                 {
200                         get 
201                         {
202                                 return(CharRanges);
203                         }
204                 }
205         
206                 public object Clone()
207                 {
208                         throw new NotImplementedException();
209                 }
210
211                 public override string ToString()
212                 {
213                         return "[StringFormat, FormatFlags=" + this.FormatFlags.ToString() + "]";
214                 }
215                 
216                 public void SetTabStops(float firstTabOffset, float[] tabStops)
217                 {
218                         this.firstTabOffset = firstTabOffset;
219                         this.tabStops = tabStops;
220                 }
221
222                 public void SetDigitSubstitution(int language,  StringDigitSubstitute substitute)
223                 {
224                         subst = substitute;
225                 }
226
227                 public float[] GetTabStops(out float firstTabOffset)
228                 {
229                         firstTabOffset = this.firstTabOffset;
230                         return this.tabStops;
231                 }
232
233         }
234 }