1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005-2014 TextEditor.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
21 ***************************************************************************/
23 #include <proto/graphics.h>
30 LONG
TextLengthNew(struct RastPort
*rp
, const char *string
, ULONG count
, LONG tabSizePixels
)
33 const char *tptr
= string
;
34 const char *tptr0
= string
;
45 // we parsed the string until the end
46 // add the remaining characters' width
48 result
+= TextLength(rp
, tptr0
, count0
);
52 // check the next character
56 // we found a TAB, calculate the characters' width so far
58 result
+= TextLength(rp
, tptr0
, count0
);
63 // add the size of a TAB
64 result
+= tabSizePixels
;
79 ULONG
TextFitNew(struct RastPort
*rp
, const char *string
, ULONG strLen
, struct TextExtent
*textExtent
, const struct TextExtent
*constrainingExtent
, LONG strDirection
, LONG constrainingBitWidth
, LONG constrainingBitHeight
, LONG tabSizePixels
)
83 const char *tptr
= string
;
84 const char *tptr0
= string
;
94 // we parsed the string until the end
95 // add the number of fitting remaining characters
96 result
+= TextFit(rp
, tptr0
, strLen0
, textExtent
, (struct TextExtent
*)constrainingExtent
, strDirection
, constrainingBitWidth
, constrainingBitHeight
);
100 // check the next character
104 // we found a TAB, calculate the number of fitting characters so far
106 result
+= TextFit(rp
, tptr0
, strLen0
, textExtent
, (struct TextExtent
*)constrainingExtent
, strDirection
, constrainingBitWidth
, constrainingBitHeight
);
108 // substract the width of the maximum width
109 constrainingBitWidth
-= TextLengthNew(rp
, tptr0
, strLen0
+1, tabSizePixels
);
110 // bail out if no space is left
111 if(constrainingBitWidth
<= 0)
131 void TextNew(struct RastPort
*rp
, const char *string
, ULONG count
, LONG tabSizePixels
)
133 const char *tptr
= string
;
134 const char *tptr0
= string
;
145 // we parsed the string until the end
146 // print out the remaining characters
147 Text(rp
, tptr0
, count0
);
151 // check the next character
155 // we found a TAB, print out the characters so far
157 Text(rp
, tptr0
, count0
);
162 // advance the rastport's cursor position
163 rp
->cp_x
+= tabSizePixels
;