grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / classes / zune / texteditor / mcc / NewGfx.c
blob9b96deed98dfc219322175f6a898926d7fde8f12
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
19 $Id$
21 ***************************************************************************/
23 #include <proto/graphics.h>
25 #include "private.h"
27 #include "Debug.h"
29 /// TextLengthNew
30 LONG TextLengthNew(struct RastPort *rp, const char *string, ULONG count, LONG tabSizePixels)
32 LONG result = 0;
33 const char *tptr = string;
34 const char *tptr0 = string;
35 LONG count0 = 0;
37 ENTER();
41 char c;
43 if(count == 0)
45 // we parsed the string until the end
46 // add the remaining characters' width
47 if(count0 != 0)
48 result += TextLength(rp, tptr0, count0);
49 break;
52 // check the next character
53 c = *tptr++;
54 if(c == '\t')
56 // we found a TAB, calculate the characters' width so far
57 if(count0 != 0)
58 result += TextLength(rp, tptr0, count0);
60 tptr0 = tptr;
61 count0 = 0;
63 // add the size of a TAB
64 result += tabSizePixels;
66 else
67 count0++;
69 count--;
71 while(TRUE);
73 RETURN(result);
74 return(result);
77 ///
78 /// TextFitNew
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)
81 ULONG result = 0;
82 ULONG strLen0 = 0;
83 const char *tptr = string;
84 const char *tptr0 = string;
86 ENTER();
90 char c;
92 if(strLen == 0)
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);
97 break;
100 // check the next character
101 c = *tptr++;
102 if(c == '\t')
104 // we found a TAB, calculate the number of fitting characters so far
105 if(strLen0 != 0)
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)
112 break;
114 result++;
115 tptr0 = tptr;
116 strLen0 = 0;
118 else
119 strLen0++;
121 strLen--;
123 while(TRUE);
125 RETURN(result);
126 return(result);
130 /// TextNew
131 void TextNew(struct RastPort *rp, const char *string, ULONG count, LONG tabSizePixels)
133 const char *tptr = string;
134 const char *tptr0 = string;
135 LONG count0 = 0;
137 ENTER();
141 char c;
143 if(count == 0)
145 // we parsed the string until the end
146 // print out the remaining characters
147 Text(rp, tptr0, count0);
148 break;
151 // check the next character
152 c = *tptr++;
153 if(c == '\t')
155 // we found a TAB, print out the characters so far
156 if(count0 != 0)
157 Text(rp, tptr0, count0);
159 tptr0 = tptr;
160 count0 = 0;
162 // advance the rastport's cursor position
163 rp->cp_x += tabSizePixels;
165 else
166 count0++;
168 count--;
170 while(TRUE);
172 LEAVE();