diff options
35 files changed, 1832 insertions, 1162 deletions
diff --git a/html/en/func/text.html b/html/en/func/text.html index 6243325..f3399dc 100644 --- a/html/en/func/text.html +++ b/html/en/func/text.html @@ -37,8 +37,8 @@ canvas:Text(x, y: number, text: string) [in Lua] canvas:fText(x, y: number, text: string) [in Lua] canvas:wText(x, y: number, text: string) (WC) [in Lua]</pre> - <p>Inserts a text in <b><tt>(x,y)</tt></b> according to the current font and - text alignment. It expects an ANSI string with no line breaks.</p> + <p>Draws a text in the position <b><tt>(x,y)</tt></b> according to the current font and + text alignment. It expects an ANSI string. Can have line breaks.</p> <h3>Attributes</h3> <pre class="function"><span class="mainFunction">void <a name="cdFont">cdCanvasFont</a>(cdCanvas* canvas, const char* typeface, int style, int size); [in C]</span> @@ -164,9 +164,21 @@ void wdCanvasGetTextSize(cdCanvas* canvas, const char* text, double *width, doub canvas:GetTextSize(text: string) -> (width, heigth: number) [in Lua] canvas:wGetTextSize(text: string) -> (width, heigth: number) (WC) [in Lua]</pre> - <p>Returns the width and height of a text's minimum box with the currently selected font. If the driver does not - support this kind of query, the values will be given 0 (zero). It is not necessary to provide all return pointers, you - can provide only the desired values and <i><tt>NULL</tt></i> for the others.</p> + <p>Returns the text size independent from orientation. It is + not necessary to provide all return pointers, you can provide only the desired + values and <font>NULL</font> for the others.</p> + +<pre class="function"><span class="mainFunction">void <a name="cdTextBounds">cdCanvasGetTextBounds</a>(cdCanvas* canvas, int x, int y, const char *text, int *rect); [in C]</span> +void wdCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* text, double *rect); (WC) [in C] + +canvas:GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) [in Lua] +canvas:wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) (WC) [in Lua]</pre> + + <p>Returns the oriented bounding rectangle occupied by a text at a given + position. The rectangle has the same dimentions returned by <strong> + GetTextSize</strong>. The rectangle corners are returned in counter-clock wise + order starting with the bottom left corner, arranged (x0,y0,x1,y1,x2,y2,x3,y3).</p> + <pre class="function"><span class="mainFunction">void <a name="cdTextBox">cdCanvasGetTextBox</a>(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax); [in C]</span> void wdCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax); (WC) [in C] @@ -174,18 +186,11 @@ void wdCanvasGetTextBox(cdCanvas* canvas, double x, double y, const char* text, canvas:GetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) [in Lua] canvas:wGetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) (WC) [in Lua]</pre> - <p>Returns the horizontal bounding rectangle of a text box, even if the text has an orientation. It is not necessary + <p>Returns the horizontal bounding rectangle occupied by a text at a given + position. If orientation is not 0 then its area is always larger than the + area of the rectangle returned by <strong>GetTextBounds</strong>. It is not necessary to provide all return pointers, you can provide only the desired values and <i><tt>NULL</tt></i> for the others.</p> -<pre class="function"><span class="mainFunction">void <a name="cdTextBounds">cdCanvasGetTextBounds</a>(cdCanvas* canvas, int x, int y, const char *text, int *rect); [in C]</span> -void wdCanvasGetTextBounds(cdCanvas* canvas, double x, double y, const char* text, double *rect); (WC) [in C] - -canvas:GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) [in Lua] -canvas:wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) (WC) [in Lua]</pre> - - <p>Returns the oriented bounding rectangle of a text box. The rectangle corners are returned in counter-clock wise - order starting with the bottom left corner, (x,y) arranged (x0,y0,x1,y1,x2,y2,x3,y3).</p> - </body> diff --git a/html/en/func/vectortext.html b/html/en/func/vectortext.html index e1b1d6e..84ca128 100644 --- a/html/en/func/vectortext.html +++ b/html/en/func/vectortext.html @@ -9,9 +9,8 @@ <body> <h2 align="center">Vector Text</h2> <p>It is a text that uses a font created only with line segments. It is very - useful to be scaled and very fast. You must set the text size before drawing - any text. The functions ignore the new line character "\n"; only the <font>wdMultiLineVectorText</font> - function will consider this character. The default direction is horizontal from + useful to be scaled and very fast. You must set the text size before drawing + any text. The default direction is horizontal from left to right.</p> <p align="center"><font size="4">Vector Text Parameters</font><br> <img src="../../img/vector_text.gif" align="middle" border="2" width="101" height="91"></p> @@ -26,35 +25,28 @@ canvas:wVectorText(x, y: number, text: string) (WC) [in Lua]</pre> <p>Draws a vector text in position <tt><b>(x,y)</b></tt>, respecting the alignment defined by <font><strong>cdTextAlignment</strong></font>. It ignores the configuration <font><strong>cdBackOpacity</strong></font>, being always - transparent. It also ignores strings with multiple lines. It is ESSENTIAL to + transparent. It accepts strings with multiple lines using <font>'\n'</font>. It is ESSENTIAL to call <font><strong>cdVectorTextSize</strong></font> or <font><strong>cdVectorCharSize</strong></font> - before using <font><strong>cdVectorText</strong></font> or <font><strong>cdMultiLineVetorText</strong></font>.</p> - <pre class="function"><span class="mainFunction">void <a name="cdMultiLineVectorText">cdCanvasMultiLineVectorText</a>(cdCanvas* canvas, int x, int y, const char* text); [in C]</span> -void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C] - -canvas:MultiLineVectorText(x, y: number, text: string) [in Lua] -canvas:wMultiLineVectorText(x, y: number, text: string) (WC) [in Lua]</pre> - <p>Draws a vector text with several lines in position <b><tt>(x,y)</tt></b>, - respecting the alignment defined by <font><strong>cdTextAlignment</strong></font>. - It ignores the configuration <font><strong>cdBackOpacity</strong></font>, being - always transparent. Lines are broken by characters <font>"\n"</font>. Each line - respects the scale defined in <font><strong>cdVectorTextSize</strong></font> or <font> - <strong>cdVectorCharSize</strong></font>. This function's purpose is to make - function <strong><font>cdVectorText</font></strong> more efficient, not being - concerned with multiple lines.</p> + before using this function.</p> + <p>The <strong>wdCanvasVectorText</strong> is the only function that + actually depends on World Coordinates. The other Vector Text functions + although use the "<strong>wd</strong>" prefix they do not depend on World + Coordinates. They are kept with these names for backward compatibility. The + correct prefix would be "<strong>cdf</strong>".</p> <h3>Attributes</h3> <pre class="function"><span class="mainFunction">void <a name="cdVectorTextDirection">cdCanvasVectorTextDirection</a>(cdCanvas* canvas, int x1, int y1, int x2, int y2); [in C]</span> -void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); (WC) [in C] +void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); [in C] canvas:VectorTextDirection(x1, y1, x2, y2: number) [in Lua] -canvas:wVectorTextDirection(x1, y1, x2, y2: number) (WC) [in Lua]</pre> +canvas:wVectorTextDirection(x1, y1, x2, y2: number) [in Lua]</pre> <p>Defines the text direction by means of two points, <b><tt>(x1,y1)</tt></b> and <b> - <tt>(x2,y2)</tt></b>. The default direction is horizontal from left to right.</p> + <tt>(x2,y2)</tt></b>. The default direction is horizontal from left to right. + It is independent from the transformation matrix.</p> <pre class="function"><span class="mainFunction">double* <a name="cdVectorTextTransform">cdCanvasVectorTextTransform</a>(cdCanvas* canvas, const double* matrix); [in C]</span> canvas:VectorTextTransform(matrix: table) -> (old_matrix: table) [in Lua] </pre> <p>Defines a transformation matrix with 6 elements. If the matrix is NULL, no - transformation is set. The default direction is no transformation. The origin + transformation is set. The default is no transformation. The origin is the left bottom corner of matrix. It returns the previous matrix, and the returned vector is only valid until the following call to the function.</p> <p>The matrix contains scale, rotation and translation elements. It is applied after @@ -63,22 +55,33 @@ canvas:VectorTextTransform(matrix: table) -> (old_matrix: table) [in Lua]&nbs <pre>|x'| | scl_x*cos(ang) -sin(ang) trans_x | |x| | 3 4 5| |y'| = | sin(ang) scl_y*cos(ang) trans_y | * |y| with indices | 0 1 2| |1|</pre> - <pre class="function"><span class="mainFunction">void <a name="cdVectorTextSize">cdCanvasVectorTextSize</a>(cdCanvas* canvas, int w, int h, const char * text); [in C]</span> -void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* text); (WC) [in C] + <p>It has the same effect of the <strong> + cdCanvasTransform,</strong> but notice that the indices are different.</p> + <pre class="function"><span class="mainFunction">void <a name="cdVectorTextSize">cdCanvasVectorTextSize</a>(cdCanvas* canvas, int width, int height, const char * text); [in C]</span> +void wdCanvasVectorTextSize(cdCanvas* canvas, double width, double height, const char* text); [in C] -canvas:VectorTextSize(w, h: number, text: string) [in Lua] -canvas:wVectorTextSize(w, h: number, text: string) (WC) [in Lua]</pre> - <p>Modifies the scale of the vector text so that it corresponds to the string of - the bounding box defined by <b><tt>w</tt></b> and <b><tt>h</tt></b>. It ignores - strings with multiple lines.</p> +canvas:VectorTextSize(width, height: number, text: string) [in Lua] +canvas:wVectorTextSize(width, height: number, text: string) [in Lua]</pre> + <p>Modifies the font size of the vector text so that it fits the string in + the box defined by <b><tt>width</tt></b> and <b><tt>height</tt></b>.</p> <pre class="function"><span class="mainFunction">double <a name="cdVectorCharSize">cdCanvasVectorCharSize</a>(cdCanvas* canvas, int size); [in C]</span> -double wdCanvasVectorCharSize(double size); (WC) [in C] +double wdCanvasVectorCharSize(cdCanvas* canvas, double size); [in C] canvas:VectorCharSize(size: number) -> (old_size: number) [in Lua] -canvas:wVectorCharSize(size: number) -> (old_size: number) (WC) [in Lua]</pre> - <p>Sets the height of the characters and adjusts the width according to it. +canvas:wVectorCharSize(size: number) -> (old_size: number) [in Lua]</pre> + <p>Modifies the font size by specifying the height of the characters. Returns the previous value. <strong><tt>CD_QUERY</tt></strong> returns the current value.</p> + <pre class="function"><span class="mainFunction">void <a name="cdVectorFontSize">cdCanvasVectorFontSize</a>(cdCanvas* canvas, double size_x, double size_x); [in C]</span> + +canvas:VectorFontSize(size_x, size_y: number) [in Lua]</pre> + <p>Directly modifies the font size. Set size_x==size_y to maintain the + original aspect ratio of the font.</p> + <pre class="function"><span class="mainFunction">void <a name="cdGetVectorFontSize">cdCanvasGetVectorFontSize</a>(cdCanvas* canvas, double *size_x, double *size_x); [in C]</span> + +canvas:GetVectorFontSize() -> (size_x, size_y: number) [in Lua]</pre> + <p>Returns the font size. It is not necessary to provide all return + pointers, you can provide only the desired values and <font>NULL</font> for the others.</p> <pre class="function"><span class="mainFunction">char* <a name="cdVectorFont">cdCanvasVectorFont</a>(cdCanvas* canvas, const char *filename); [in C]</span> canvas:VectorFont(filename: string) -> (fontname: string) [in Lua]</pre> @@ -94,23 +97,38 @@ canvas:VectorFont(filename: string) -> (fontname: string) [in Lua]</pre> to the default font and returns NULL. The file format is compatible with the GKS file format (text mode).</p> <h3>Properties</h3> - <pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextSize">cdCanvasGetVectorTextSize</a>(cdCanvas* canvas, const char* text, int *w, int *h); [in C]</span> -void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *x, double *y); (WC) [in C] + <pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextSize">cdCanvasGetVectorTextSize</a>(cdCanvas* canvas, const char* text, int *width, int *height); [in C]</span> +void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *width, double *height); [in C] -canvas:GetVectorTextSize(text: string) -> (w, h: number) [in Lua] -canvas:wGetVectorTextSize(text: string) -> (w, h: number) (WC) [in Lua]</pre> - <p>Queries the string's bounding box. Ignores strings with multiple lines. It is +canvas:GetVectorTextSize(text: string) -> (width, height: number) [in Lua] +canvas:wGetVectorTextSize(text: string) -> (width, height: number) [in Lua]</pre> + <p>Returns the text size independent from orientation. It is not necessary to provide all return pointers, you can provide only the desired values and <font>NULL</font> for the others.</p> - <pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextBounds">cdCanvasGetVectorTextBounds</a>(cdCanvas* canvas, char* text, int px, int py, int *rect); [in C]</span> -void wdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect); (WC) [in C] + <pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextBounds">cdCanvasGetVectorTextBounds</a>(cdCanvas* canvas, char* text, int x, int y, int *rect); [in C]</span> +void wdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect); [in C] + +canvas:GetVectorTextBounds(text: string, x, y: number) -> (rect: table) [in Lua] +canvas:wGetVectorTextBounds(text: string, x, y: number) -> (rect: table) [in Lua] </pre> + + <p>Returns the oriented bounding rectangle occupied by a text at a given + position. The rectangle has the same dimentions returned by <strong> + GetVectorTextSize</strong>. The rectangle corners are returned in counter-clock wise + order starting with the bottom left corner, arranged (x0,y0,x1,y1,x2,y2,x3,y3).</p> + + +<pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextBox">cdCanvasGetVectorTextBox</a>(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax); [in C]</span> +void wdCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax); [in C] + +canvas:GetVectorTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) [in Lua] +canvas:wGetVectorTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) [in Lua]</pre> + + <p>Returns the horizontal bounding rectangle occupied by a text at a given + position. If + orientation is not 0 then its area is always larger than the area of the + rectangle returned by <strong>GetVectorTextBounds</strong>. It is not necessary + to provide all return pointers, you can provide only the desired values and <i><tt>NULL</tt></i> for the others.</p> -canvas:GetVectorTextBounds(text: string, px,py: number) -> (rect: table) [in Lua] -canvas:wGetVectorTextBounds(text: string, px,py: number) -> (rect: table) (WC) [in Lua] </pre> - <p>Returns the bounding rectangle of the text specified in the current vector - font, alignment and direction. Eight values are returned, corresponding to - pairs (x,y) of the rectangle's vertices ordered conter-clockwise, starting by - the bottom left corner.</p> <h3>Character Codes</h3> <p>The old GKS format contains ASCII codes so a convertion from ANSI to ASCII is done when possible, unmapped characters are left unchanged, but some rearrage diff --git a/html/en/history.html b/html/en/history.html index 165a75b..25355fc 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -10,12 +10,23 @@ <body> <h1>History of Changes</h1> -<h3>CVS (13/Jun/2008)</h3> +<h3>CVS (22/Jun/2008)</h3> <ul> + <li><span style="color: #0000FF">New:</span> functions <strong> + CanvasGetVectorTextBox, CanvasGetVectorFontSize</strong> and <strong> + CanvasVectorFontSize</strong>.</li> <li><span style="color: #008000">Changed:</span> CD_DBUFFER now activates the buffered canvas before creating the image canvas. If size is 0 then uses 1 and avoid to fail during creation.</li> - <li><span style="color: #FF0000">Fixed:</span> <strong>cdCanvasText</strong> + <li><span style="color: #008000">Changed:</span> + the functions <strong>CanvasVectorText</strong>, <strong>CanvasText</strong> + and <strong>CanvasGetTextSize</strong> now supports line breaks using '\n'. + <strong>CanvasMultiLineVectorText</strong> is now deprecated but kept for + compatibility. + <strong> + <span style="color: #FF0000">IMPORTANT</span></strong> - VectorTextSize now + includes the full line size.</li> + <li><span style="color: #FF0000">Fixed:</span> <strong>CanvasText</strong> for CD_IMAGERGB driver when the foreground color has alpha.</li> </ul> <h3>Version 5.1.1 (15/Dec/2008)</h3> diff --git a/html/wb/wb_usr.lua b/html/wb/wb_usr.lua index bcbaeec..a494653 100644 --- a/html/wb/wb_usr.lua +++ b/html/wb/wb_usr.lua @@ -240,7 +240,7 @@ wb_usr.tree = folder= { { - name= {nl= "GetCanvasSize"}, + name= {nl= "GetSize"}, link= "func/coordinates.html#cdGetCanvasSize" }, { @@ -625,21 +625,21 @@ wb_usr.tree = folder= { { - name= {nl= "FontDim"}, + name= {nl= "GetFontDim"}, link= "func/text.html#cdFontDim" }, { - name= {nl= "TextSize"}, + name= {nl= "GetTextSize"}, link= "func/text.html#cdTextSize" }, { - name= {nl= "TextBox"}, - link= "func/text.html#cdTextBox" + name= {nl= "GetTextBounds"}, + link= "func/text.html#cdTextBounds" }, { - name= {nl= "TextBounds"}, - link= "func/text.html#cdTextBounds" - } + name= {nl= "GetTextBox"}, + link= "func/text.html#cdTextBox" + }, } } } @@ -654,10 +654,6 @@ wb_usr.tree = link= "func/vectortext.html#cdVectorText" }, { - name= {nl= "MultiLineVectorText"}, - link= "func/vectortext.html#cdMultiLineVectorText" - }, - { name= {en= "Attributes"}, folder= { @@ -694,6 +690,10 @@ wb_usr.tree = { name= {nl= "GetVectorTextBounds"}, link= "func/vectortext.html#cdGetVectorTextBounds" + }, + { + name= {nl= "GetVectorTextBox"}, + link= "func/vectortext.html#cdGetVectorTextBox" } } } diff --git a/html/wb_tree.html b/html/wb_tree.html index 74cbc45..19d0fe6 100644 --- a/html/wb_tree.html +++ b/html/wb_tree.html @@ -286,7 +286,7 @@ </div> <p><img src="wb_img/vertline.png"><img name="imgfolder.3.3" src="wb_img/plusnode.png" onclick="toggleFolder('folder.3.3')"> Coordinate System</p> <div id="folder.3.3"> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link48folder.3.3" href="en/func/coordinates.html#cdGetCanvasSize">GetCanvasSize</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link48folder.3.3" href="en/func/coordinates.html#cdGetCanvasSize">GetSize</a></p> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link49folder.3.3" href="en/func/coordinates.html#cdUpdateYAxis">UpdateYAxis</a></p> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link50folder.3.3" href="en/func/coordinates.html#cdMM2Pixel">MM2Pixel</a></p> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link51folder.3.3" href="en/func/coordinates.html#cdPixel2MM">Pixel2MM</a></p> @@ -406,28 +406,28 @@ </div> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img name="imgfolder.4.4.2" src="wb_img/plusnodelast.png" onclick="toggleFolder('folder.4.4.2')"> Properties</p> <div id="folder.4.4.2"> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link125folder.4.4.2" href="en/func/text.html#cdFontDim">FontDim</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link126folder.4.4.2" href="en/func/text.html#cdTextSize">TextSize</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link127folder.4.4.2" href="en/func/text.html#cdTextBox">TextBox</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link128folder.4.4.2" href="en/func/text.html#cdTextBounds">TextBounds</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link125folder.4.4.2" href="en/func/text.html#cdFontDim">GetFontDim</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link126folder.4.4.2" href="en/func/text.html#cdTextSize">GetTextSize</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link127folder.4.4.2" href="en/func/text.html#cdTextBounds">GetTextBounds</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link128folder.4.4.2" href="en/func/text.html#cdTextBox">GetTextBox</a></p> </div> </div> <p><img src="wb_img/vertline.png"><img name="imgfolder.4.5" src="wb_img/plusnode.png" onclick="toggleFolder('folder.4.5')"><a name="link129folder.4.5" class="el" href="en/func/vectortext.html">Vector Text</a></p> <div id="folder.4.5"> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link130folder.4.5" href="en/func/vectortext.html#cdVectorText">VectorText</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link131folder.4.5" href="en/func/vectortext.html#cdMultiLineVectorText">MultiLineVectorText</a></p> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img name="imgfolder.4.5.1" src="wb_img/plusnode.png" onclick="toggleFolder('folder.4.5.1')"> Attributes</p> <div id="folder.4.5.1"> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link132folder.4.5.1" href="en/func/vectortext.html#cdVectorTextDirection">VectorTextDirection</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link133folder.4.5.1" href="en/func/vectortext.html#cdVectorTextTransform">VectorTextTransform</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link134folder.4.5.1" href="en/func/vectortext.html#cdVectorTextSize">VectorTextSize</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link135folder.4.5.1" href="en/func/vectortext.html#cdVectorCharSize">VectorCharSize</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link136folder.4.5.1" href="en/func/vectortext.html#cdVectorFont">VectorFont</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link131folder.4.5.1" href="en/func/vectortext.html#cdVectorTextDirection">VectorTextDirection</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link132folder.4.5.1" href="en/func/vectortext.html#cdVectorTextTransform">VectorTextTransform</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link133folder.4.5.1" href="en/func/vectortext.html#cdVectorTextSize">VectorTextSize</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/node.png"><a class="el" name="link134folder.4.5.1" href="en/func/vectortext.html#cdVectorCharSize">VectorCharSize</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/nodelast.png"><a class="el" name="link135folder.4.5.1" href="en/func/vectortext.html#cdVectorFont">VectorFont</a></p> </div> <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img name="imgfolder.4.5.2" src="wb_img/plusnodelast.png" onclick="toggleFolder('folder.4.5.2')"> Properties</p> <div id="folder.4.5.2"> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link137folder.4.5.2" href="en/func/vectortext.html#cdGetVectorTextSize">GetVectorTextSize</a></p> - <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link138folder.4.5.2" href="en/func/vectortext.html#cdGetVectorTextBounds">GetVectorTextBounds</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link136folder.4.5.2" href="en/func/vectortext.html#cdGetVectorTextSize">GetVectorTextSize</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/node.png"><a class="el" name="link137folder.4.5.2" href="en/func/vectortext.html#cdGetVectorTextBounds">GetVectorTextBounds</a></p> + <p><img src="wb_img/vertline.png"><img src="wb_img/vertline.png"><img src="wb_img/blank.png"><img src="wb_img/nodelast.png"><a class="el" name="link138folder.4.5.2" href="en/func/vectortext.html#cdGetVectorTextBox">GetVectorTextBox</a></p> </div> </div> <p><img src="wb_img/vertline.png"><img name="imgfolder.4.6" src="wb_img/plusnode.png" onclick="toggleFolder('folder.4.6')"><a name="link139folder.4.6" class="el" href="en/func/client.html">Client Images</a></p> diff --git a/include/cd.h b/include/cd.h index b491d84..55ecb45 100644 --- a/include/cd.h +++ b/include/cd.h @@ -169,10 +169,13 @@ void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix); void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s); int cdCanvasVectorCharSize(cdCanvas* canvas, int size); +void cdCanvasVectorFontSize(cdCanvas* canvas, double size_x, double size_y); +void cdCanvasGetVectorFontSize(cdCanvas* canvas, double *size_x, double *size_y); /* vector text properties */ void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char* s, int *x, int *y); void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, int x, int y, int *rect); +void cdCanvasGetVectorTextBox(cdCanvas* canvas, int x, int y, const char *s, int *xmin, int *xmax, int *ymin, int *ymax); /* properties */ void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *ascent, int *descent); diff --git a/include/cd_private.h b/include/cd_private.h index 9ca38ce..14db96e 100644 --- a/include/cd_private.h +++ b/include/cd_private.h @@ -268,6 +268,8 @@ int cdfCheckBoxSize(double *xmin, double *xmax, double *ymin, double *ymax); void cdNormalizeLimits(int w, int h, int *xmin, int *xmax, int *ymin, int *ymax); int cdGetFileName(const char* strdata, char* filename); int cdStrEqualNoCase(const char* str1, const char* str2); +int cdStrLineCount(const char* str); +char* cdStrDup(const char* str); #define _cdCheckCanvas(_canvas) (_canvas!=NULL && ((unsigned char*)_canvas)[0] == 'C' && ((unsigned char*)_canvas)[1] == 'D') #define _cdInvertYAxis(_canvas, _y) (_canvas->h - (_y) - 1) @@ -286,6 +288,8 @@ void cdMatrixInverse(const double* matrix, double* inv_matrix); void cdRotatePoint(cdCanvas* canvas, int x, int y, int cx, int cy, int *rx, int *ry, double sin_teta, double cos_teta); void cdRotatePointY(cdCanvas* canvas, int x, int y, int cx, int cy, int *ry, double sin_theta, double cos_theta); void cdTextTranslatePoint(cdCanvas* canvas, int x, int y, int w, int h, int baseline, int *rx, int *ry); +void cdMovePoint(int *x, int *y, double dx, double dy, double sin_theta, double cos_theta); +void cdfMovePoint(double *x, double *y, double dx, double dy, double sin_theta, double cos_theta); /*************/ /* Fonts */ diff --git a/include/wd.h b/include/wd.h index 83ebe0f..80ee7b0 100644 --- a/include/wd.h +++ b/include/wd.h @@ -66,6 +66,7 @@ double wdCanvasVectorCharSize(cdCanvas* canvas, double size); void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* s); void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* s); void wdCanvasGetVectorTextBounds(cdCanvas* canvas, const char* s, double x, double y, double *rect); +void wdCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char *s, double *xmin, double *xmax, double *ymin, double *ymax); #ifdef __cplusplus } diff --git a/mak.vc9/cd.sln b/mak.vc9/cd.sln index 5274f2f..f416152 100644 --- a/mak.vc9/cd.sln +++ b/mak.vc9/cd.sln @@ -56,6 +56,22 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CDLua5", "CDLua5", "{EFB1BE EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CDLua3", "CDLua3", "{E92DB6FF-5501-4FC0-81D2-00DB8EFA2434}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{162715BD-4DB3-4007-8B50-725C0BD11878}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdtest", "cdtest.vcproj", "{A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}" + ProjectSection(ProjectDependencies) = postProject + {01818D2C-65AF-4D5C-9452-4DFF401C6461} = {01818D2C-65AF-4D5C-9452-4DFF401C6461} + {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} = {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} + {8441F69D-7135-43B2-974F-45C6123C8467} = {8441F69D-7135-43B2-974F-45C6123C8467} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdtestsimple", "cdtestsimple.vcproj", "{82BC36B1-9F7A-41D4-A24F-DBE012378CE6}" + ProjectSection(ProjectDependencies) = postProject + {01818D2C-65AF-4D5C-9452-4DFF401C6461} = {01818D2C-65AF-4D5C-9452-4DFF401C6461} + {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} = {51A96255-7EAB-4F36-A6E5-1BAF6245FA18} + {8441F69D-7135-43B2-974F-45C6123C8467} = {8441F69D-7135-43B2-974F-45C6123C8467} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -85,6 +101,10 @@ Global {01818D2C-65AF-AFDC-4356-1234401C6461}.Debug|Win32.Build.0 = Debug|Win32 {B4823266-DF8C-ABCD-1234-C7688C234EAC}.Debug|Win32.ActiveCfg = Debug|Win32 {B4823266-DF8C-ABCD-1234-C7688C234EAC}.Debug|Win32.Build.0 = Debug|Win32 + {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}.Debug|Win32.ActiveCfg = Debug|Win32 + {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}.Debug|Win32.Build.0 = Debug|Win32 + {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug|Win32.ActiveCfg = Debug|Win32 + {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug|Win32.Build.0 = Debug|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -96,6 +116,8 @@ Global {CB863607-6B6C-0000-0000-123400001234} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} {B4823266-DF8C-ABCD-1234-C7688C234EAC} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} {53FC9752-81C1-4AA6-B366-A7890A2B81F6} = {EFB1BE3C-2981-456B-8E32-928CBDFF7822} + {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9} = {162715BD-4DB3-4007-8B50-725C0BD11878} + {82BC36B1-9F7A-41D4-A24F-DBE012378CE6} = {162715BD-4DB3-4007-8B50-725C0BD11878} EndGlobalSection GlobalSection(DevPartner Solution Properties) = postSolution EndGlobalSection diff --git a/test/cdtest/cdtest.vcproj b/mak.vc9/cdtest.vcproj index 2323676..4cab635 100644 --- a/test/cdtest/cdtest.vcproj +++ b/mak.vc9/cdtest.vcproj @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" - Version="8.00" + Version="9,00" Name="cdtest" ProjectGUID="{A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}" + TargetFrameworkVersion="0" > <Platforms> <Platform @@ -46,7 +47,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\..\include,..\..\..\iup\include" + AdditionalIncludeDirectories="..\include,..\..\iup\include" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;CDTEST_WIN32;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="1" PrecompiledHeaderFile="..\obj/cdtest.pch" @@ -71,14 +72,14 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="comctl32.lib cd.lib cdiup.lib cdgdiplus.lib iup.lib gdiplus.lib cdpdflib.lib" + AdditionalDependencies="freetype6.lib comctl32.lib cd.lib iupcd.lib cdgdiplus.lib iup.lib iupwin.lib gdiplus.lib cdpdflib.lib pdflib.lib" OutputFile="..\bin/cdtest.exe" LinkIncremental="2" SuppressStartupBanner="true" - AdditionalLibraryDirectories="..\..\lib,..\..\..\iup\lib" + AdditionalLibraryDirectories="..\lib,..\..\iup\lib" GenerateDebugInformation="true" ProgramDatabaseFile="..\bin/cdtest.pdb" - SubSystem="2" + SubSystem="1" /> <Tool Name="VCALinkTool" @@ -99,9 +100,6 @@ Name="VCAppVerifierTool" /> <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> @@ -114,35 +112,35 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File - RelativePath="Cdtest.c" + RelativePath="..\test\cdtest\cdtest.c" > </File> <File - RelativePath=".\cdtest.led" + RelativePath="..\test\cdtest\cdtest.led" > </File> <File - RelativePath="cdtest.rc" + RelativePath="..\test\cdtest\cdtest.rc" > </File> <File - RelativePath="cdtest_led.c" + RelativePath="..\test\cdtest\cdtest_led.c" > </File> <File - RelativePath="Colorbar.c" + RelativePath="..\test\cdtest\colorbar.c" > </File> <File - RelativePath="Drivers.c" + RelativePath="..\test\cdtest\drivers.c" > </File> <File - RelativePath="List.c" + RelativePath="..\test\cdtest\list.c" > </File> <File - RelativePath="Rubber.c" + RelativePath="..\test\cdtest\rubber.c" > </File> </Filter> @@ -151,7 +149,7 @@ Filter="h;hpp;hxx;hm;inl" > <File - RelativePath="Cdtest.h" + RelativePath="..\test\cdtest\cdtest.h" > </File> </Filter> diff --git a/test/simple/simple.vcproj b/mak.vc9/cdtestsimple.vcproj index 87a199c..b4e898e 100644 --- a/test/simple/simple.vcproj +++ b/mak.vc9/cdtestsimple.vcproj @@ -2,7 +2,7 @@ <VisualStudioProject ProjectType="Visual C++" Version="9,00" - Name="simple" + Name="cdtestsimple" ProjectGUID="{82BC36B1-9F7A-41D4-A24F-DBE012378CE6}" TargetFrameworkVersion="131072" > @@ -17,7 +17,7 @@ <Configuration Name="Debug|Win32" OutputDirectory="..\bin" - IntermediateDirectory="..\obj\simple" + IntermediateDirectory="..\obj\cdtestsimple" ConfigurationType="1" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" @@ -38,18 +38,18 @@ /> <Tool Name="VCMIDLTool" - TypeLibraryName=".\..\bin/simple.tlb" + TypeLibraryName=".\..\bin/cdtestsimple.tlb" /> <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="..\..\include,..\..\..\iup\include" + AdditionalIncludeDirectories="..\include,..\..\iup\include" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__CD__;simple;_CRT_SECURE_NO_DEPRECATE" RuntimeLibrary="0" - PrecompiledHeaderFile=".\..\obj\simple/simple.pch" - AssemblerListingLocation=".\..\obj\simple/" - ObjectFile=".\..\obj\simple/" - ProgramDataBaseFileName=".\..\obj\simple/" + PrecompiledHeaderFile=".\..\obj\cdtestsimple/cdtestsimple.pch" + AssemblerListingLocation=".\..\obj\cdtestsimple/" + ObjectFile=".\..\obj\cdtestsimple/" + ProgramDataBaseFileName=".\..\obj\cdtestsimple/" WarningLevel="4" SuppressStartupBanner="true" DebugInformationFormat="1" @@ -68,14 +68,14 @@ <Tool Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="freetype6.lib cd.lib iupcd.lib iup.lib comctl32.lib cdgdiplus.lib gdiplus.lib cdpdflib.lib iupcontrols.lib" - OutputFile="..\bin/simple.exe" + AdditionalDependencies="freetype6.lib cd.lib iupcd.lib iup.lib iupwin.lib comctl32.lib cdgdiplus.lib gdiplus.lib cdpdflib.lib iupcontrols.lib" + OutputFile="..\bin/cdtestsimple.exe" LinkIncremental="2" SuppressStartupBanner="true" - AdditionalLibraryDirectories="..\..\lib,..\..\..\iup\lib" + AdditionalLibraryDirectories="..\lib,..\..\iup\lib" GenerateDebugInformation="true" - ProgramDatabaseFile=".\..\bin/simple.pdb" - SubSystem="2" + ProgramDatabaseFile="..\bin/cdtestsimple.pdb" + SubSystem="1" RandomizedBaseAddress="1" DataExecutionPrevention="0" /> @@ -106,23 +106,23 @@ </References> <Files> <File - RelativePath="iupmain.c" + RelativePath="..\test\simple\iupmain.c" > </File> <File - RelativePath="simple.c" + RelativePath="..\test\simple\simple.c" > </File> <File - RelativePath="simple.h" + RelativePath="..\test\simple\simple.h" > </File> <File - RelativePath="simple.led" + RelativePath="..\test\simple\simple.led" > </File> <File - RelativePath="simple_led.c" + RelativePath="..\test\simple\simple_led.c" > </File> </Files> @@ -18,8 +18,8 @@ #include "cdirgb.h" /* This appears only here to avoid changing the cd.h header fo bug fixes */ -#define CD_VERSION_FIX "" -#define CD_VERSION_FIX_NUMBER 0 +#define CD_VERSION_FIX ".1" +#define CD_VERSION_FIX_NUMBER 1 const char cd_ident[] = "$CD: " CD_VERSION CD_VERSION_FIX " " CD_COPYRIGHT " $\n" @@ -46,7 +46,6 @@ int cdVersionNumber(void) static void cd_setdefaultfunc(cdCanvas* canvas) { - /* default simulation functions */ canvas->cxGetTextSize = cdgettextsizeEX; canvas->cxGetFontDim = cdgetfontdimEX; canvas->cxRect = cdrectSIM; @@ -161,7 +160,7 @@ cdCanvas *cdCreateCanvas(cdContext* context, void *data_str) return NULL; } - /* functions that can do nothing, must be before InitTable */ + /* default simulation functions */ cd_setdefaultfunc(canvas); /* initialize canvas table */ @@ -257,7 +256,10 @@ int cdCanvasSimulate(cdCanvas* canvas, int mode) if (mode == CD_QUERY || cdCanvasGetContext(canvas) == CD_IMAGERGB) return sim_mode; + /* default simulation functions */ cd_setdefaultfunc(canvas); + + /* initialize canvas table */ context->cxInitTable(canvas); canvas->sim_mode = mode; @@ -232,6 +232,7 @@ EXPORTS wdCanvasGetTextBox wdCanvasGetTextSize wdCanvasGetVectorTextBounds + wdCanvasGetVectorTextBox wdCanvasGetVectorTextSize wdCanvasGetViewport wdCanvasGetWindow @@ -289,6 +290,8 @@ EXPORTS cdCanvasPlay cdCanvasRegionCombineMode cdCanvasVectorCharSize + cdCanvasVectorFontSize + cdCanvasGetVectorFontSize cdCanvasWriteMode cdCanvasUpdateYAxis cdCanvasInvertYAxis @@ -324,6 +327,7 @@ EXPORTS cdCanvasGetTextBox cdCanvasGetTextSize cdCanvasGetVectorTextBounds + cdCanvasGetVectorTextBox cdCanvasGetVectorTextSize cdCanvasLine cdCanvasLineStyleDashes diff --git a/src/cd_active.c b/src/cd_active.c index 0ae489a..f8229bd 100644 --- a/src/cd_active.c +++ b/src/cd_active.c @@ -1004,4 +1004,3 @@ void wdGetVectorTextBounds(const char* s, double x, double y, double *rect) if (!active_canvas) return; wdCanvasGetVectorTextBounds(active_canvas, s, x, y, rect); } - diff --git a/src/cd_text.c b/src/cd_text.c index a06f9b1..8a5ff81 100644 --- a/src/cd_text.c +++ b/src/cd_text.c @@ -11,13 +11,14 @@ #include <memory.h> #include <math.h> - #include "cd.h" #include "cd_private.h" void cdCanvasText(cdCanvas* canvas, int x, int y, const char *s) { + int num_line; + assert(canvas); assert(s); if (!_cdCheckCanvas(canvas)) return; @@ -34,11 +35,83 @@ void cdCanvasText(cdCanvas* canvas, int x, int y, const char *s) if (canvas->invert_yaxis) y = _cdInvertYAxis(canvas, y); - canvas->cxText(canvas->ctxcanvas, x, y, s); + num_line = cdStrLineCount(s); + if (num_line == 1) + canvas->cxText(canvas->ctxcanvas, x, y, s); + else + { + int i, line_height; + char *p, *q, *new_s; + double cos_theta = 0, sin_theta = 0; + + new_s = cdStrDup(s); + p = new_s; + + canvas->cxGetFontDim(canvas->ctxcanvas, NULL, &line_height, NULL, NULL); + + if (canvas->text_orientation) + { + int align = canvas->text_alignment; + cos_theta = cos(canvas->text_orientation*CD_DEG2RAD); + sin_theta = sin(canvas->text_orientation*CD_DEG2RAD); + + /* position vertically at the first line */ + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST || /* it is relative to the full text */ + align == CD_BASE_LEFT || align == CD_BASE_CENTER || align == CD_BASE_RIGHT) /* it is relative to the first line already */ + { + /* Already at position */ + } + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) /* it is relative to the full text */ + { + cdMovePoint(&x, &y, 0, (num_line-1)*line_height, sin_theta, cos_theta); + } + else /* CD_CENTER || CD_EAST || CD_WEST */ /* it is relative to the full text */ + cdMovePoint(&x, &y, 0, (num_line-1)*line_height/2.0, sin_theta, cos_theta); + } + else + { + int align = canvas->text_alignment; + + /* position vertically at the first line */ + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST || /* it is relative to the full text */ + align == CD_BASE_LEFT || align == CD_BASE_CENTER || align == CD_BASE_RIGHT) /* it is relative to the first line already */ + { + /* Already at position */ + } + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) /* it is relative to the full text */ + { + y += (num_line-1)*line_height; + } + else /* CD_CENTER || CD_EAST || CD_WEST */ /* it is relative to the full text */ + y += ((num_line-1)*line_height)/2; + } + + for(i = 0; i < num_line; i++) + { + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ + + /* Draw the line */ + canvas->cxText(canvas->ctxcanvas, x, y, p); + + /* Advance the string */ + if (q) p = q + 1; + + /* Advance a line */ + if (canvas->text_orientation) + cdMovePoint(&x, &y, 0, -line_height, sin_theta, cos_theta); + else + y -= line_height; + } + + free(new_s); + } } void cdfCanvasText(cdCanvas* canvas, double x, double y, const char *s) { + int num_line; + assert(canvas); assert(s); if (!_cdCheckCanvas(canvas)) return; @@ -55,10 +128,68 @@ void cdfCanvasText(cdCanvas* canvas, double x, double y, const char *s) if (canvas->invert_yaxis) y = _cdInvertYAxis(canvas, y); - if (canvas->cxFText) - canvas->cxFText(canvas->ctxcanvas, x, y, s); + num_line = cdStrLineCount(s); + if (num_line == 1) + { + if (canvas->cxFText) + canvas->cxFText(canvas->ctxcanvas, x, y, s); + else + canvas->cxText(canvas->ctxcanvas, _cdRound(x), _cdRound(y), s); + } else - canvas->cxText(canvas->ctxcanvas, _cdRound(x), _cdRound(y), s); + { + int i, line_height; + char *p, *q, *new_s; + double cos_theta = 0, sin_theta = 0; + + new_s = cdStrDup(s); + p = new_s; + + canvas->cxGetFontDim(canvas->ctxcanvas, NULL, &line_height, NULL, NULL); + + if (canvas->text_orientation) + { + int align = canvas->text_alignment; + cos_theta = cos(canvas->text_orientation*CD_DEG2RAD); + sin_theta = sin(canvas->text_orientation*CD_DEG2RAD); + + /* position vertically at the first line */ + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST || /* it is relative to the full text */ + align == CD_BASE_LEFT || align == CD_BASE_CENTER || align == CD_BASE_RIGHT) /* it is relative to the first line already */ + { + /* Already at position */ + } + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) /* it is relative to the full text */ + { + cdfMovePoint(&x, &y, 0, (num_line-1)*line_height, sin_theta, cos_theta); + } + else /* CD_CENTER || CD_EAST || CD_WEST */ /* it is relative to the full text */ + cdfMovePoint(&x, &y, 0, (num_line-1)*line_height/2.0, sin_theta, cos_theta); + } + + for(i = 0; i < num_line; i++) + { + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ + + /* Draw the line */ + if (canvas->cxFText) + canvas->cxFText(canvas->ctxcanvas, x, y, p); + else + canvas->cxText(canvas->ctxcanvas, _cdRound(x), _cdRound(y), p); + + /* Advance the string */ + if (q) p = q + 1; + + /* Advance a line */ + if (canvas->text_orientation) + cdfMovePoint(&x, &y, 0, -line_height, sin_theta, cos_theta); + else + y -= line_height; + } + + free(new_s); + } } int cdGetFontSizePixels(cdCanvas* canvas, int size) @@ -96,6 +227,7 @@ int cdCanvasFont(cdCanvas* canvas, const char* type_face, int style, int size) assert(canvas); assert(style>=-1 && style<=CD_STRIKEOUT); if (!_cdCheckCanvas(canvas)) return CD_ERROR; + if (!type_face || type_face[0]==0) type_face = canvas->font_type_face; if (style==-1) @@ -235,10 +367,43 @@ void cdCanvasGetFontDim(cdCanvas* canvas, int *max_width, int *height, int *asce void cdCanvasGetTextSize(cdCanvas* canvas, const char *s, int *width, int *height) { + int num_line; + assert(canvas); assert(s); if (!_cdCheckCanvas(canvas)) return; - canvas->cxGetTextSize(canvas->ctxcanvas, s, width, height); + + num_line = cdStrLineCount(s); + if (num_line == 1) + canvas->cxGetTextSize(canvas->ctxcanvas, s, width, height); + else + { + int i, line_height, max_w = 0, w; + char *p, *q, *new_s; + + new_s = cdStrDup(s); + p = new_s; + + canvas->cxGetFontDim(canvas->ctxcanvas, NULL, &line_height, NULL, NULL); + + for(i = 0; i < num_line; i++) + { + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ + + /* Calculate line width */ + canvas->cxGetTextSize(canvas->ctxcanvas, p, &w, NULL); + if (w > max_w) max_w = w; + + /* Advance the string */ + if (q) p = q + 1; + } + + if (width) *width = max_w; + if (height) *height = num_line*line_height; + + free(new_s); + } } void cdTextTranslatePoint(cdCanvas* canvas, int x, int y, int w, int h, int baseline, int *rx, int *ry) @@ -306,6 +471,13 @@ void cdCanvasGetTextBounds(cdCanvas* canvas, int x, int y, const char *s, int *r int w, h, ascent, height, baseline; int xmin, xmax, ymin, ymax; int old_invert_yaxis = canvas->invert_yaxis; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; cdCanvasGetTextSize(canvas, s, &w, &h); cdCanvasGetFontDim(canvas, NULL, &height, &ascent, NULL); diff --git a/src/cd_util.c b/src/cd_util.c index 033fac6..dadb6f4 100644 --- a/src/cd_util.c +++ b/src/cd_util.c @@ -223,6 +223,21 @@ int cdfCheckBoxSize(double *xmin, double *xmax, double *ymin, double *ymax) return 1; } +void cdMovePoint(int *x, int *y, double dx, double dy, double sin_theta, double cos_theta) +{ + double t; + t = cos_theta*dx - sin_theta*dy; + *x += _cdRound(t); + t = sin_theta*dx + cos_theta*dy; + *y += _cdRound(t); +} + +void cdfMovePoint(double *x, double *y, double dx, double dy, double sin_theta, double cos_theta) +{ + *x += cos_theta*dx - sin_theta*dy; + *y += sin_theta*dx + cos_theta*dy; +} + void cdRotatePoint(cdCanvas* canvas, int x, int y, int cx, int cy, int *rx, int *ry, double sin_theta, double cos_theta) { double t; @@ -283,3 +298,38 @@ int cdStrEqualNoCase(const char* str1, const char* str2) return 0; } +/* Copied from IUP3, simply ignore line breaks other than '\n' for CD */ + +int cdStrLineCount(const char* str) +{ + int num_lin = 1; + + if (!str) + return num_lin; + + while(*str != 0) + { + while(*str!=0 && *str!='\n') + str++; + + if (*str=='\n') /* UNIX line end */ + { + num_lin++; + str++; + } + } + + return num_lin; +} + +char* cdStrDup(const char *str) +{ + if (str) + { + int size = strlen(str)+1; + char *newstr = malloc(size); + if (newstr) memcpy(newstr, str, size); + return newstr; + } + return NULL; +} diff --git a/src/cd_vectortext.c b/src/cd_vectortext.c index 9886a3b..0be62af 100644 --- a/src/cd_vectortext.c +++ b/src/cd_vectortext.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <string.h> #include <math.h> +#include <assert.h> #include "cd.h" #include "wd.h" @@ -30,17 +31,18 @@ typedef struct cdCaracter struct _cdVectorFont { + /* font data */ char name[256]; /* font name */ - char file_name[10240]; /* font file name */ + char file_name[10240]; /* font file name */ cdCaracter *chars; /* array of characters */ - int top, /* from baseline to top */ - cap, /* from baseline to cap (top of chars) */ - half, /* half between top and bottom UNUSED */ + cap, /* from baseline to cap (UNUSED) */ + half, /* half between top and bottom (UNUSED) */ bottom; /* from baseline to bottom (negative) */ - double point_size_x, point_size_y; /* internal char size proportional to "top" */ + + /* attributes (independ from font) */ + double size_x, size_y; /* internal font size */ double current_cos, current_sin; /* text direction */ - int space, line_space; /* space between chars and vf_lines */ /* general transformation matrix */ int text_transf; @@ -4206,12 +4208,6 @@ static void vf_setdefaultfont(cdVectorFont *vector_font) vector_font->cap = vf_default_cap; vector_font->half = vf_default_half; vector_font->bottom = vf_default_bottom; - vector_font->point_size_x = 1.0; - vector_font->point_size_y = 1.0; - vector_font->current_cos = 1.0; - vector_font->current_sin = 0.0; - vector_font->space = 1; - vector_font->line_space = 1; } static int vf_readfontfile(FILE *file, cdVectorFont *vector_font) @@ -4293,7 +4289,7 @@ static int vf_readfontstring(const char* file, cdVectorFont *vector_font) sprintf(vector_font->name, "Unknown"); } - /* skip 2 blank vf_lines */ + /* skip 2 blank lines */ file = strstr(file, "\n")+1; /* goto next line */ file = strstr(file, "\n")+1; /* goto next line */ @@ -4335,27 +4331,28 @@ static int vf_readfontstring(const char* file, cdVectorFont *vector_font) return 1; } -static int vf_primlen(cdVectorFont *vector_font, const char* s) +static int vf_textwidth(cdVectorFont *vector_font, const char* s) { - int len = 0; + int width = 0; while (*s) - len += vector_font->chars[(unsigned char)(*(s++))].right + vector_font->space; - return len; + width += vector_font->chars[(unsigned char)(*(s++))].right; + if (width==0) width = 1; + return width; } -static void vf_move_dir(cdVectorFont *vector_font, int *px, int *py, double dx, double dy) +static void vf_move_dir(cdVectorFont *vector_font, int *x, int *y, double dx, double dy) { - *px += cdRound(vector_font->current_cos*dx - vector_font->current_sin*dy); - *py += cdRound(vector_font->current_sin*dx + vector_font->current_cos*dy); + *x += cdRound(vector_font->current_cos*dx - vector_font->current_sin*dy); + *y += cdRound(vector_font->current_sin*dx + vector_font->current_cos*dy); } -static void vf_wmove_dir(cdVectorFont *vector_font, double *px, double *py, double dx, double dy) +static void vf_wmove_dir(cdVectorFont *vector_font, double *x, double *y, double dx, double dy) { - *px += vector_font->current_cos*dx - vector_font->current_sin*dy; - *py += vector_font->current_sin*dx + vector_font->current_cos*dy; + *x += vector_font->current_cos*dx - vector_font->current_sin*dy; + *y += vector_font->current_sin*dx + vector_font->current_cos*dy; } -static void vf_writechar(cdVectorFont *vector_font, char c, int *px, int *py) +static void vf_draw_char(cdVectorFont *vector_font, char c, int *x, int *y) { unsigned char ac = vf_ansi2ascii[(unsigned char)c]; cdOperation *current = vector_font->chars[ac].op; @@ -4363,8 +4360,8 @@ static void vf_writechar(cdVectorFont *vector_font, char c, int *px, int *py) for(m = 0; m < op; m++) { - int ponto_x = *px; - int ponto_y = *py; + int px = *x; + int py = *y; if (current->operation == 'm') { @@ -4372,23 +4369,23 @@ static void vf_writechar(cdVectorFont *vector_font, char c, int *px, int *py) cdCanvasBegin(vector_font->canvas, CD_OPEN_LINES); } - vf_move_dir(vector_font, &ponto_x, &ponto_y, current->x*vector_font->point_size_x, current->y*vector_font->point_size_y); + vf_move_dir(vector_font, &px, &py, current->x*vector_font->size_x, current->y*vector_font->size_y); if (vector_font->text_transf) { - double aux = ponto_x*vector_font->text_matrix[3] + ponto_y*vector_font->text_matrix[4] + vector_font->text_matrix[5]; - ponto_y = cdRound(ponto_x*vector_font->text_matrix[0] + ponto_y*vector_font->text_matrix[1] + vector_font->text_matrix[2]); - ponto_x = _cdRound(aux); + double aux = px*vector_font->text_matrix[3] + py*vector_font->text_matrix[4] + vector_font->text_matrix[5]; + py = cdRound(px*vector_font->text_matrix[0] + py*vector_font->text_matrix[1] + vector_font->text_matrix[2]); + px = _cdRound(aux); } - cdCanvasVertex(vector_font->canvas, ponto_x, ponto_y); + cdCanvasVertex(vector_font->canvas, px, py); current++; } if (m) cdCanvasEnd(vector_font->canvas); } -static void vf_wwritechar(cdVectorFont *vector_font, char c, double *px, double *py) +static void vf_wdraw_char(cdVectorFont *vector_font, char c, double *x, double *y) { unsigned char ac = vf_ansi2ascii[(unsigned char)c]; cdOperation *current = vector_font->chars[ac].op; @@ -4396,8 +4393,8 @@ static void vf_wwritechar(cdVectorFont *vector_font, char c, double *px, double for(m = 0; m < op; m++) { - double ponto_x = *px; - double ponto_y = *py; + double px = *x; + double py = *y; if (current->operation == 'm') { @@ -4405,146 +4402,214 @@ static void vf_wwritechar(cdVectorFont *vector_font, char c, double *px, double cdCanvasBegin(vector_font->canvas, CD_OPEN_LINES); } - vf_wmove_dir(vector_font, &ponto_x, &ponto_y, current->x*vector_font->point_size_x, current->y*vector_font->point_size_y); + vf_wmove_dir(vector_font, &px, &py, current->x*vector_font->size_x, current->y*vector_font->size_y); if (vector_font->text_transf) { - double aux = ponto_x*vector_font->text_matrix[3] + ponto_y*vector_font->text_matrix[4] + vector_font->text_matrix[5]; - ponto_y = ponto_x*vector_font->text_matrix[0] + ponto_y*vector_font->text_matrix[1] + vector_font->text_matrix[2]; - ponto_x = aux; + double aux = px*vector_font->text_matrix[3] + py*vector_font->text_matrix[4] + vector_font->text_matrix[5]; + py = px*vector_font->text_matrix[0] + py*vector_font->text_matrix[1] + vector_font->text_matrix[2]; + px = aux; } - wdCanvasVertex(vector_font->canvas, ponto_x, ponto_y); + wdCanvasVertex(vector_font->canvas, px, py); current++; } if (m) cdCanvasEnd(vector_font->canvas); } -static int vf_lines(char * s) +static void vf_move_to_base(cdVectorFont *vector_font, int *x, int *y, int width) { - int n = 1; - while (*s != 0) + /* move point to baseline/left according to alignment */ + int align = vector_font->canvas->text_alignment; + + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST) { - if (*s == '\n') - { - n++; - *s = 0; - } - s++; + vf_move_dir(vector_font, x, y, 0, -vector_font->top*vector_font->size_y); } - return n; -} - -static void vf_basic_write(cdVectorFont *vector_font, const char* s, int px, int py) -{ - while (*s) + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) { - vf_writechar(vector_font, *s, &px, &py); - vf_move_dir(vector_font, &px, &py, (vector_font->chars[(unsigned char)*s].right + vector_font->space)*vector_font->point_size_x, 0); - s++; + vf_move_dir(vector_font, x, y, 0, -vector_font->bottom*vector_font->size_y); /* bottom is < 0 */ } -} + else if (align == CD_BASE_CENTER || align == CD_BASE_LEFT || align == CD_BASE_RIGHT) + { + /* y = y; */ + } + else /* CD_CENTER || CD_EAST || CD_WEST */ + vf_move_dir(vector_font, x, y, 0, -((double)(vector_font->top+vector_font->bottom)/2.0)*vector_font->size_y); -static void vf_wbasic_write(cdVectorFont *vector_font, const char* s, double px, double py) -{ - while (*s) + if (align == CD_EAST || align == CD_NORTH_EAST || align == CD_SOUTH_EAST || align == CD_BASE_RIGHT) { - vf_wwritechar(vector_font, *s, &px, &py); - vf_wmove_dir(vector_font, &px, &py, (vector_font->chars[(unsigned char)*s].right + vector_font->space)*vector_font->point_size_x, 0); - s++; + vf_move_dir(vector_font, x, y, -width*vector_font->size_x, 0); + } + else if (align == CD_WEST || align == CD_NORTH_WEST || align == CD_SOUTH_WEST || align == CD_BASE_LEFT) + { + /* x = x; */ + } + else /* CD_CENTER || CD_NORTH || CD_SOUTH */ + { + vf_move_dir(vector_font, x, y, -(width*vector_font->size_x)/2.0, 0); } } -static void vf_calc_pos(cdVectorFont *vector_font, int *px, int *py, int prim_len) +static void vf_wmove_to_base(cdVectorFont *vector_font, double *x, double *y, int width) { - int align = cdCanvasTextAlignment(vector_font->canvas, CD_QUERY); + /* move point to baseline/left according to alignment */ + int align = vector_font->canvas->text_alignment; if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST) { - vf_move_dir(vector_font, px, py, 0, -vector_font->top*vector_font->point_size_y); + vf_wmove_dir(vector_font, x, y, 0, -vector_font->top*vector_font->size_y); } else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) { - vf_move_dir(vector_font, px, py, 0, -vector_font->bottom*vector_font->point_size_y); /* bottom is < 0 */ + vf_wmove_dir(vector_font, x, y, 0, -vector_font->bottom*vector_font->size_y); /* bottom is < 0 */ } else if (align == CD_BASE_CENTER || align == CD_BASE_LEFT || align == CD_BASE_RIGHT) { - /* py = py; */ + /* y = y; */ } - else /* center em y */ - vf_move_dir(vector_font, px, py, 0, -(double)(vector_font->cap+vector_font->bottom)/2*vector_font->point_size_y); + else /* CD_CENTER || CD_EAST || CD_WEST */ + vf_wmove_dir(vector_font, x, y, 0, -((double)(vector_font->top+vector_font->bottom)/2.0)*vector_font->size_y); if (align == CD_EAST || align == CD_NORTH_EAST || align == CD_SOUTH_EAST || align == CD_BASE_RIGHT) { - vf_move_dir(vector_font, px, py, -prim_len*vector_font->point_size_x, 0); + vf_wmove_dir(vector_font, x, y, -width*vector_font->size_x, 0); } else if (align == CD_WEST || align == CD_NORTH_WEST || align == CD_SOUTH_WEST || align == CD_BASE_LEFT) { - ; /* px = px; */ + /* x = x; */ + } + else /* CD_CENTER || CD_NORTH || CD_SOUTH */ + { + vf_wmove_dir(vector_font, x, y, -(width*vector_font->size_x)/2.0, 0); } - else /* center em x */ - vf_move_dir(vector_font, px, py, -(prim_len*vector_font->point_size_x)/2, 0); } -static void vf_wcalc_pos(cdVectorFont *vector_font, double *px, double *py, int prim_len) +static void vf_draw_text(cdVectorFont* vector_font, int x, int y, const char* s, int width) { - int align = cdCanvasTextAlignment(vector_font->canvas, CD_QUERY); + vf_move_to_base(vector_font, &x, &y, width); - if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST) - { - vf_wmove_dir(vector_font, px, py, 0, -vector_font->top*vector_font->point_size_y); - } - else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) + while (*s) { - vf_wmove_dir(vector_font, px, py, 0, -vector_font->bottom*vector_font->point_size_y); /* bottom is < 0 */ + vf_draw_char(vector_font, *s, &x, &y); + vf_move_dir(vector_font, &x, &y, (vector_font->chars[(unsigned char)*s].right)*vector_font->size_x, 0); + s++; } - else if (align == CD_BASE_CENTER || align == CD_BASE_LEFT || align == CD_BASE_RIGHT) +} + +static void vf_wdraw_text(cdVectorFont* vector_font, double x, double y, const char* s, int width) +{ + vf_wmove_to_base(vector_font, &x, &y, width); + + while (*s) { - /* py = py; */ + vf_wdraw_char(vector_font, *s, &x, &y); + vf_wmove_dir(vector_font, &x, &y, (vector_font->chars[(unsigned char)*s].right)*vector_font->size_x, 0); + s++; } - else /* center em y */ - vf_wmove_dir(vector_font, px, py, 0, -(double)(vector_font->cap+vector_font->bottom)/2*vector_font->point_size_y); +} - if (align == CD_EAST || align == CD_NORTH_EAST || align == CD_SOUTH_EAST || align == CD_BASE_RIGHT) +static void vf_calc_point(cdVectorFont *vector_font, int start_x, int start_y, int *x, int *y, int dx, int dy) +{ + *x = start_x; + *y = start_y; + + vf_move_dir(vector_font, x, y, dx, dy); + + if (vector_font->text_transf) { - vf_wmove_dir(vector_font, px, py, -prim_len*vector_font->point_size_x, 0); + double aux = *x * vector_font->text_matrix[3] + *y * vector_font->text_matrix[4] + vector_font->text_matrix[5]; + *y = cdRound(*x * vector_font->text_matrix[0] + *y * vector_font->text_matrix[1] + vector_font->text_matrix[2]); + *x = _cdRound(aux); } - else if (align == CD_WEST || align == CD_NORTH_WEST || align == CD_SOUTH_WEST || align == CD_BASE_LEFT) +} + +static void vf_wcalc_point(cdVectorFont *vector_font, double start_x, double start_y, double *x, double *y, double dx, double dy) +{ + *x = start_x; + *y = start_y; + + vf_wmove_dir(vector_font, x, y, dx, dy); + + if (vector_font->text_transf) { - ; /* px = px; */ + double aux = *x * vector_font->text_matrix[3] + *y * vector_font->text_matrix[4] + vector_font->text_matrix[5]; + *y = *x * vector_font->text_matrix[0] + *y * vector_font->text_matrix[1] + vector_font->text_matrix[2]; + *x = aux; } - else /* center em x */ - vf_wmove_dir(vector_font, px, py, -(prim_len*vector_font->point_size_x)/2, 0); } -static void vf_calc_point(cdVectorFont *vector_font, int startx, int starty, int *px, int *py, int dx, int dy) +static int vf_gettextmaxwidth(cdVectorFont* vector_font, const char* s, int num_lin) { - *px = startx; - *py = starty; - vf_move_dir(vector_font, px, py, dx, dy); + int i, max_w = 0, w; + char *p, *q, *new_s; - if (vector_font->text_transf) + new_s = cdStrDup(s); + p = new_s; + + for(i = 0; i < num_lin; i++) { - double aux = *px * vector_font->text_matrix[3] + *py * vector_font->text_matrix[4] + vector_font->text_matrix[5]; - *py = cdRound(*px * vector_font->text_matrix[0] + *py * vector_font->text_matrix[1] + vector_font->text_matrix[2]); - *px = _cdRound(aux); + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ + + /* Calculate line width */ + w = vf_textwidth(vector_font, p); + if (w > max_w) max_w = w; + + /* Advance the string */ + if (q) p = q + 1; } + + free(new_s); + return max_w; } -static void vf_wcalc_point(cdVectorFont *vector_font, double startx, double starty, double *px, double *py, double dx, double dy) +static void vf_gettextsize(cdVectorFont* vector_font, const char* s, int *width, int *height) { - *px = startx; - *py = starty; + int num_lin = cdStrLineCount(s); + if (num_lin == 1) + { + *width = vf_textwidth(vector_font, s); + *height = vector_font->top - vector_font->bottom; + } + else + { + *width = vf_gettextmaxwidth(vector_font, s, num_lin); + *height = num_lin*(vector_font->top - vector_font->bottom); + } +} - vf_wmove_dir(vector_font, px, py, dx, dy); +static void vf_move_to_first(cdVectorFont* vector_font, int align, int *x, int *y, int num_lin, double line_height) +{ + /* position vertically at the first line */ + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST || /* it is relative to the full text */ + align == CD_BASE_LEFT || align == CD_BASE_CENTER || align == CD_BASE_RIGHT) /* it is relative to the first line already */ + { + /* Already at position */ + } + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) /* it is relative to the full text */ + { + vf_move_dir(vector_font, x, y, 0, (num_lin-1)*line_height); + } + else /* CD_CENTER || CD_EAST || CD_WEST */ /* it is relative to the full text */ + vf_move_dir(vector_font, x, y, 0, (num_lin-1)*line_height/2.0); +} - if (vector_font->text_transf) +static void vf_wmove_to_first(cdVectorFont* vector_font, int align, double *x, double *y, int num_lin, double line_height) +{ + /* position vertically at the first line */ + if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST || /* it is relative to the full text */ + align == CD_BASE_LEFT || align == CD_BASE_CENTER || align == CD_BASE_RIGHT) /* it is relative to the first line already */ + { + /* Already at position */ + } + else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) /* it is relative to the full text */ { - double aux = *px * vector_font->text_matrix[3] + *py * vector_font->text_matrix[4] + vector_font->text_matrix[5]; - *py = *px * vector_font->text_matrix[0] + *py * vector_font->text_matrix[1] + vector_font->text_matrix[2]; - *px = aux; + vf_wmove_dir(vector_font, x, y, 0, (num_lin-1)*line_height); } + else /* CD_CENTER || CD_EAST || CD_WEST */ /* it is relative to the full text */ + vf_wmove_dir(vector_font, x, y, 0, (num_lin-1)*line_height/2.0); } static char *cd_getCDDIR(void) @@ -4562,49 +4627,113 @@ static char *cd_getCDDIR(void) cdVectorFont* cdCreateVectorFont(cdCanvas* canvas) { - cdVectorFont* vector_font = calloc(1, sizeof(cdVectorFont)); + cdVectorFont* vector_font; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return NULL; + + vector_font = calloc(1, sizeof(cdVectorFont)); + vector_font->canvas = canvas; + vf_setdefaultfont(vector_font); + + vector_font->size_x = 1.0; + vector_font->size_y = 1.0; + + vector_font->current_cos = 1.0; + vector_font->current_sin = 0.0; + + vector_font->text_transf = 0; + return vector_font; } void cdKillVectorFont(cdVectorFont* vector_font) { + assert(vector_font); + if (!vector_font) return; + if (vector_font->chars && vector_font->chars != vf_default_chars) vf_releasefontchars(vector_font); /* not the default font */ free(vector_font); } -void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2) +char *cdCanvasVectorFont(cdCanvas* canvas, const char *file) { - int dx=x2-x1; - int dy=y2-y1; - double len = sqrt(dx*dx +dy*dy); - cdVectorFont* vector_font = canvas->vector_font; - vector_font->current_sin = dy/len; - vector_font->current_cos = dx/len; -} + cdVectorFont* vector_font; -int cdCanvasVectorCharSize(cdCanvas* canvas, int size) -{ - cdVectorFont* vector_font = canvas->vector_font; - int old_size = cdRound(vector_font->point_size_y*vector_font->top); - if (size == CD_QUERY) - return old_size; + assert(canvas); + assert(file); + if (!_cdCheckCanvas(canvas)) return NULL; - vector_font->point_size_y = size/(double)vector_font->top; - vector_font->point_size_x = size/(double)vector_font->top; + if (file[0] == 0) + return NULL; - return old_size; + vector_font = canvas->vector_font; + if (!file) + { + vf_setdefaultfont(vector_font); + vector_font->file_name[0] = 0; + } + else + { + FILE *font = NULL; + int read_ok; + + /* se arquivo foi o mesmo que o arq. corrente, entao retorna */ + if (strcmp (file, vector_font->file_name) == 0) + return vector_font->name; + + /* abre arq. no dir. corrente */ + font = fopen(file, "r"); + + /* se nao conseguiu, abre arq. no dir. do cd, */ + if (!font && (strlen(file) < 10240 - strlen(cd_getCDDIR()))) + { + char filename[10240]; + sprintf(filename, "%s/%s", cd_getCDDIR(), file); + font = fopen(filename, "r"); + } + + if (font) + read_ok = vf_readfontfile(font, vector_font); + else + read_ok = vf_readfontstring(file, vector_font); + + if (!read_ok) + { + if (font) fclose(font); + vf_setdefaultfont(vector_font); + vector_font->file_name[0] = 0; + return NULL; + } + + /* guarda nome do arquivo que esta' carregado */ + if (font) + { + strcpy(vector_font->file_name, file); + fclose(font); + } + else + strcpy(vector_font->file_name, vector_font->name); + } + + return vector_font->name; } double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix) { - cdVectorFont* vector_font = canvas->vector_font; + cdVectorFont* vector_font; int i; static double old_matrix[6]; + assert(canvas); + assert(matrix); + if (!_cdCheckCanvas(canvas)) return NULL; + + vector_font = canvas->vector_font; if (vector_font->text_transf) { for (i=0; i<6; i++) @@ -4629,131 +4758,250 @@ double* cdCanvasVectorTextTransform(cdCanvas* canvas, const double* matrix) return old_matrix; } -void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char *s, int *px, int *py) +/******************************************************/ +/* vector text em Raster */ +/******************************************************/ + +void cdCanvasVectorTextDirection(cdCanvas* canvas, int x1, int y1, int x2, int y2) +{ + cdVectorFont* vector_font; + int dx, dy; + double len; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return; + + vector_font = canvas->vector_font; + + dx=x2-x1; + dy=y2-y1; + len = sqrt(dx*dx +dy*dy); + if (len == 0) len = 1; + vector_font->current_sin = dy/len; + vector_font->current_cos = dx/len; +} + +void cdCanvasVectorFontSize(cdCanvas* canvas, double size_x, double size_y) { - cdVectorFont* vector_font = canvas->vector_font; - if (px) *px = cdRound(vf_primlen(vector_font, s)*vector_font->point_size_x); - if (py) *py = cdRound(vector_font->top*vector_font->point_size_y); + cdVectorFont* vector_font; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return; + + vector_font = canvas->vector_font; + + vector_font->size_x = size_x; + vector_font->size_y = size_y; } -void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char *s, int px, int py, int *rect) +void cdCanvasGetVectorFontSize(cdCanvas* canvas, double *size_x, double *size_y) { - cdVectorFont* vector_font = canvas->vector_font; - int prim_len = vf_primlen(vector_font, s); - int sx = cdRound(prim_len*vector_font->point_size_x); - int sy = cdRound(vector_font->top*vector_font->point_size_y); + cdVectorFont* vector_font; - vf_calc_pos(vector_font, &px, &py, prim_len); + assert(canvas); + if (!_cdCheckCanvas(canvas)) return; - vf_move_dir(vector_font, &px, &py, 0, vector_font->bottom*vector_font->point_size_y); + vector_font = canvas->vector_font; - vf_calc_point(vector_font, px, py, &rect[0], &rect[1], 0, 0); - vf_calc_point(vector_font, px, py, &rect[2], &rect[3], sx, 0); - vf_calc_point(vector_font, px, py, &rect[4], &rect[5], sx, sy); - vf_calc_point(vector_font, px, py, &rect[6], &rect[7], 0, sy); + if (size_x) *size_x = vector_font->size_x; + if (size_y) *size_y = vector_font->size_y; } -void cdCanvasVectorTextSize(cdCanvas* canvas, int size_x, int size_y, const char* s) +int cdCanvasVectorCharSize(cdCanvas* canvas, int size) { - cdVectorFont* vector_font = canvas->vector_font; - vector_font->point_size_x = size_x/(double)vf_primlen(vector_font, s); - vector_font->point_size_y = size_y/(double)vector_font->top; + cdVectorFont* vector_font; + int old_size; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return 0; + + vector_font = canvas->vector_font; + old_size = cdRound(vector_font->size_y*vector_font->top); + if (size == CD_QUERY) + return old_size; + + vector_font->size_y = size/(double)vector_font->top; + vector_font->size_x = vector_font->size_y; + + return old_size; } -void cdCanvasVectorText(cdCanvas* canvas, int px, int py, const char* s) +void cdCanvasVectorTextSize(cdCanvas* canvas, int s_width, int s_height, const char* s) { - cdVectorFont* vector_font = canvas->vector_font; - int prim_len = vf_primlen(vector_font, s); - vf_calc_pos(vector_font, &px, &py, prim_len); - vf_basic_write(vector_font, s, px, py); + int width, height; + cdVectorFont* vector_font; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; + vf_gettextsize(vector_font, s, &width, &height); + + vector_font->size_x = (double)s_width/(double)width; + vector_font->size_y = (double)s_height/(double)height; } -void cdCanvasMultiLineVectorText(cdCanvas* canvas, int px, int py, const char* s) +void cdCanvasGetVectorTextSize(cdCanvas* canvas, const char *s, int *x, int *y) { - cdVectorFont* vector_font = canvas->vector_font; - double line_height = (vector_font->top - vector_font->bottom + vector_font->line_space) * vector_font->point_size_y; - char buff[MULTILINE_MAXLEN]; - char *str = buff; - int n; + int width, height; + cdVectorFont* vector_font; - int align = cdCanvasTextAlignment(vector_font->canvas, CD_QUERY); /* procura o alinhamento do CD */ + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; - if (strlen(s) >= MULTILINE_MAXLEN) + if (s[0] == 0) return; - strcpy(str, s); - n = vf_lines(str); - if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST) - { - ; /* Already at position */ - } - else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) - { - vf_move_dir(vector_font, &px, &py, 0, (n-1)*line_height); - } - else - vf_move_dir(vector_font, &px, &py, 0, ((double)(n-1)/2)*line_height); + vector_font = canvas->vector_font; + + vf_gettextsize(vector_font, s, &width, &height); + + if (x) *x = cdRound(width*vector_font->size_x); + if (y) *y = cdRound(height*vector_font->size_y); +} + +void cdCanvasGetVectorTextBounds(cdCanvas* canvas, const char *s, int x, int y, int *rect) +{ + cdVectorFont* vector_font; + int sx, sy; + int width, height, num_lin; + double line_height; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; - while (n--) + vf_gettextsize(vector_font, s, &width, &height); + num_lin = height/(vector_font->top - vector_font->bottom); + + sx = cdRound(width*vector_font->size_x); + sy = cdRound(height*vector_font->size_y); + + line_height = (vector_font->top - vector_font->bottom) * vector_font->size_y; + + if (num_lin > 1) { - cdCanvasVectorText(canvas, px, py, str); - str += strlen(str)+1; - vf_move_dir(vector_font, &px, &py, 0, -line_height); + /* position vertically at the first line */ + int align = canvas->text_alignment; + vf_move_to_first(vector_font, align, &x, &y, num_lin, line_height); } + + /* move to bottom/left corner */ + vf_move_to_base(vector_font, &x, &y, width); + vf_move_dir(vector_font, &x, &y, 0, vector_font->bottom*vector_font->size_y); /* from base/left to bottom/left of the first line */ + if (num_lin > 1) + vf_move_dir(vector_font, &x, &y, 0, -(height*vector_font->size_y - line_height)); /* from bottom/left to the bottom of the last line */ + + vf_calc_point(vector_font, x, y, &rect[0], &rect[1], 0, 0); + vf_calc_point(vector_font, x, y, &rect[2], &rect[3], sx, 0); + vf_calc_point(vector_font, x, y, &rect[4], &rect[5], sx, sy); + vf_calc_point(vector_font, x, y, &rect[6], &rect[7], 0, sy); } -char *cdCanvasVectorFont(cdCanvas* canvas, const char *file) +void cdCanvasGetVectorTextBox(cdCanvas* canvas, int x, int y, const char *s, int *xmin, int *xmax, int *ymin, int *ymax) { - cdVectorFont* vector_font = canvas->vector_font; - if (!file) + int rect[8]; + int _xmin, _xmax, _ymin, _ymax; + + cdCanvasGetVectorTextBounds(canvas, s, x, y, rect); + + _xmin = rect[0]; + _ymin = rect[1]; + _xmax = rect[0]; + _ymax = rect[1]; + + if(rect[2] < _xmin) _xmin = rect[2]; + if(rect[4] < _xmin) _xmin = rect[4]; + if(rect[6] < _xmin) _xmin = rect[6]; + + if(rect[3] < _ymin) _ymin = rect[3]; + if(rect[5] < _ymin) _ymin = rect[5]; + if(rect[7] < _ymin) _ymin = rect[7]; + + if(rect[2] > _xmax) _xmax = rect[2]; + if(rect[4] > _xmax) _xmax = rect[4]; + if(rect[6] > _xmax) _xmax = rect[6]; + + if(rect[3] > _ymax) _ymax = rect[3]; + if(rect[5] > _ymax) _ymax = rect[5]; + if(rect[7] > _ymax) _ymax = rect[7]; + + if (xmin) *xmin = _xmin; + if (xmax) *xmax = _xmax; + if (ymin) *ymin = _ymin; + if (ymax) *ymax = _ymax; +} + +void cdCanvasVectorText(cdCanvas* canvas, int x, int y, const char* s) +{ + cdVectorFont* vector_font; + int num_lin, align, width = 0; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; + align = canvas->text_alignment; + + num_lin = cdStrLineCount(s); + if (num_lin == 1) { - vf_setdefaultfont(vector_font); - vector_font->file_name[0] = 0; + if (align != CD_WEST && align != CD_NORTH_WEST && align != CD_SOUTH_WEST && align != CD_BASE_LEFT) + width = vf_textwidth(vector_font, s); /* only necessary for some alignments */ + + vf_draw_text(vector_font, x, y, s, width); } else { - FILE *font = NULL; - int read_ok; + char *p, *q, *new_s; + double line_height = (vector_font->top - vector_font->bottom) * vector_font->size_y; + int i; - /* se arquivo foi o mesmo que o arq. corrente, entao retorna */ - if (strcmp (file, vector_font->file_name) == 0) - return vector_font->name; + if (align != CD_WEST && align != CD_NORTH_WEST && align != CD_SOUTH_WEST && align != CD_BASE_LEFT) + width = vf_gettextmaxwidth(vector_font, s, num_lin); /* only necessary for some alignments */ - /* abre arq. no dir. corrente */ - font = fopen(file, "r"); + /* position vertically at the first line */ + vf_move_to_first(vector_font, align, &x, &y, num_lin, line_height); - /* se nao conseguiu, abre arq. no dir. do cd, */ - if (!font && (strlen(file) < 10240 - strlen(cd_getCDDIR()))) + new_s = cdStrDup(s); + p = new_s; + + for(i = 0; i < num_lin; i++) { - char filename[10240]; - sprintf(filename, "%s/%s", cd_getCDDIR(), file); - font = fopen(filename, "r"); - } + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ - if (font) - read_ok = vf_readfontfile(font, vector_font); - else - read_ok = vf_readfontstring(file, vector_font); + /* Draw the line */ + vf_draw_text(vector_font, x, y, p, width); - if (!read_ok) - { - if (font) fclose(font); - vf_setdefaultfont(vector_font); - vector_font->file_name[0] = 0; - return NULL; - } + /* Advance the string */ + if (q) p = q + 1; - /* guarda nome do arquivo que esta' carregado */ - if (font) - { - strcpy(vector_font->file_name, file); - fclose(font); + /* Advance a line */ + vf_move_dir(vector_font, &x, &y, 0, -line_height); } - else - strcpy(vector_font->file_name, vector_font->name); + + free(new_s); } +} - return vector_font->name; +void cdCanvasMultiLineVectorText(cdCanvas* canvas, int x, int y, const char* s) +{ + cdCanvasVectorText(canvas, x, y, s); } /******************************************************/ @@ -4762,92 +5010,215 @@ char *cdCanvasVectorFont(cdCanvas* canvas, const char *file) void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2) { - cdVectorFont* vector_font = canvas->vector_font; - double dx=x2-x1; - double dy=y2-y1; - double len = sqrt(dx*dx +dy*dy); + cdVectorFont* vector_font; + double dx, dy, len; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return; + + vector_font = canvas->vector_font; + + dx=x2-x1; + dy=y2-y1; + len = sqrt(dx*dx +dy*dy); + if (len == 0) len = 1; vector_font->current_sin = dy/len; vector_font->current_cos = dx/len; } double wdCanvasVectorCharSize(cdCanvas* canvas, double size) { - cdVectorFont* vector_font = canvas->vector_font; - double old_size = vector_font->point_size_y*vector_font->top; + cdVectorFont* vector_font; + double old_size; + + assert(canvas); + if (!_cdCheckCanvas(canvas)) return 0; + + vector_font = canvas->vector_font; + old_size = vector_font->size_y*vector_font->top; if (size == CD_QUERY) return old_size; - vector_font->point_size_y = size/(double)vector_font->top; - vector_font->point_size_x = size/(double)vector_font->top; + vector_font->size_y = size/(double)vector_font->top; + vector_font->size_x = vector_font->size_y; return old_size; } -void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* s) +void wdCanvasVectorTextSize(cdCanvas* canvas, double s_width, double s_height, const char* s) { - cdVectorFont* vector_font = canvas->vector_font; - vector_font->point_size_x = size_x/(double)vf_primlen(vector_font, s); - vector_font->point_size_y = size_y/(double)vector_font->top; + int width, height; + cdVectorFont* vector_font; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; + vf_gettextsize(vector_font, s, &width, &height); + + vector_font->size_x = s_width/(double)width; + vector_font->size_y = s_height/(double)height; } -void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char *s, double *px, double *py) +void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char *s, double *x, double *y) { - cdVectorFont* vector_font = canvas->vector_font; - if (px) *px = vf_primlen(vector_font, s)*vector_font->point_size_x; - if (py) *py = vector_font->top*vector_font->point_size_y; + int width, height; + cdVectorFont* vector_font; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; + + vf_gettextsize(vector_font, s, &width, &height); + + if (x) *x = width*vector_font->size_x; + if (y) *y = height*vector_font->size_y; } -void wdCanvasGetVectorTextBounds(cdCanvas* canvas, const char *s, double px, double py, double *rect) +void wdCanvasGetVectorTextBounds(cdCanvas* canvas, const char *s, double x, double y, double *rect) { - cdVectorFont* vector_font = canvas->vector_font; - int prim_len = vf_primlen(vector_font, s); - double sx = prim_len*vector_font->point_size_x; - double sy = vector_font->top*vector_font->point_size_y; + cdVectorFont* vector_font; + double sx, sy, line_height; + int width, height, num_lin; + + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; + + if (s[0] == 0) + return; + + vector_font = canvas->vector_font; - vf_wcalc_pos(vector_font, &px, &py, prim_len); + vf_gettextsize(vector_font, s, &width, &height); + num_lin = height/(vector_font->top - vector_font->bottom); + + sx = width*vector_font->size_x; + sy = height*vector_font->size_y; + + line_height = (vector_font->top - vector_font->bottom) * vector_font->size_y; + + if (num_lin > 1) + { + /* position vertically at the first line */ + int align = canvas->text_alignment; + vf_wmove_to_first(vector_font, align, &x, &y, num_lin, line_height); + } - vf_wmove_dir(vector_font, &px, &py, 0, vector_font->bottom*vector_font->point_size_y); + /* move to bottom/left corner */ + vf_wmove_to_base(vector_font, &x, &y, width); + vf_wmove_dir(vector_font, &x, &y, 0, vector_font->bottom*vector_font->size_y); /* from base/left to bottom/left of the first line */ + if (num_lin > 1) + vf_wmove_dir(vector_font, &x, &y, 0, -(height*vector_font->size_y - line_height)); /* from bottom/left to the bottom of the last line */ - vf_wcalc_point(vector_font, px, py, &rect[0], &rect[1], 0, 0); - vf_wcalc_point(vector_font, px, py, &rect[2], &rect[3], sx, 0); - vf_wcalc_point(vector_font, px, py, &rect[4], &rect[5], sx, sy); - vf_wcalc_point(vector_font, px, py, &rect[6], &rect[7], 0, sy); + vf_wcalc_point(vector_font, x, y, &rect[0], &rect[1], 0, 0); + vf_wcalc_point(vector_font, x, y, &rect[2], &rect[3], sx, 0); + vf_wcalc_point(vector_font, x, y, &rect[4], &rect[5], sx, sy); + vf_wcalc_point(vector_font, x, y, &rect[6], &rect[7], 0, sy); } -void wdCanvasVectorText(cdCanvas* canvas, double px, double py, const char* s) +void wdCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char *s, double *xmin, double *xmax, double *ymin, double *ymax) { - cdVectorFont* vector_font = canvas->vector_font; - int prim_len = vf_primlen(vector_font, s); - vf_wcalc_pos(vector_font, &px, &py, prim_len); - vf_wbasic_write(vector_font, s, px, py); + double rect[8]; + double _xmin, _xmax, _ymin, _ymax; + + wdCanvasGetVectorTextBounds(canvas, s, x, y, rect); + + _xmin = rect[0]; + _ymin = rect[1]; + _xmax = rect[0]; + _ymax = rect[1]; + + if(rect[2] < _xmin) _xmin = rect[2]; + if(rect[4] < _xmin) _xmin = rect[4]; + if(rect[6] < _xmin) _xmin = rect[6]; + + if(rect[3] < _ymin) _ymin = rect[3]; + if(rect[5] < _ymin) _ymin = rect[5]; + if(rect[7] < _ymin) _ymin = rect[7]; + + if(rect[2] > _xmax) _xmax = rect[2]; + if(rect[4] > _xmax) _xmax = rect[4]; + if(rect[6] > _xmax) _xmax = rect[6]; + + if(rect[3] > _ymax) _ymax = rect[3]; + if(rect[5] > _ymax) _ymax = rect[5]; + if(rect[7] > _ymax) _ymax = rect[7]; + + if (xmin) *xmin = _xmin; + if (xmax) *xmax = _xmax; + if (ymin) *ymin = _ymin; + if (ymax) *ymax = _ymax; } -void wdCanvasMultiLineVectorText(cdCanvas* canvas, double px, double py, const char* s) +void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* s) { - cdVectorFont* vector_font = canvas->vector_font; - double line_height = (vector_font->top - vector_font->bottom + vector_font->line_space)*vector_font->point_size_y; - char buff[MULTILINE_MAXLEN]; - char *str = buff; - int n; + cdVectorFont* vector_font; + int num_lin, align, width = 0; - int align = cdCanvasTextAlignment(vector_font->canvas, CD_QUERY); /* procura o alinhamento do CD */ + assert(canvas); + assert(s); + if (!_cdCheckCanvas(canvas)) return; - if (strlen(s) >= MULTILINE_MAXLEN) + if (s[0] == 0) return; - strcpy(str, s); - n = vf_lines(str); - if (align == CD_NORTH || align == CD_NORTH_EAST || align == CD_NORTH_WEST) - ; /* Already at position */ - else if (align == CD_SOUTH || align == CD_SOUTH_EAST || align == CD_SOUTH_WEST) - vf_wmove_dir(vector_font, &px, &py, 0, (n-1)*line_height); - else - vf_wmove_dir(vector_font, &px, &py, 0, ((double)(n-1)/2)*line_height); + vector_font = canvas->vector_font; + align = canvas->text_alignment; - while (n--) + num_lin = cdStrLineCount(s); + if (num_lin == 1) { - wdCanvasVectorText(canvas, px, py, str); - str += strlen(str)+1; - vf_wmove_dir(vector_font, &px, &py, 0, -line_height); + if (align != CD_WEST && align != CD_NORTH_WEST && align != CD_SOUTH_WEST && align != CD_BASE_LEFT) + width = vf_textwidth(vector_font, s); /* only necessary for some alignments */ + + vf_wdraw_text(vector_font, x, y, s, width); + } + else + { + char *p, *q, *new_s; + double line_height = (vector_font->top - vector_font->bottom) * vector_font->size_y; + int i; + + if (align != CD_WEST && align != CD_NORTH_WEST && align != CD_SOUTH_WEST && align != CD_BASE_LEFT) + width = vf_gettextmaxwidth(vector_font, s, num_lin); /* only necessary for some alignments */ + + /* position vertically at the first line */ + vf_wmove_to_first(vector_font, align, &x, &y, num_lin, line_height); + + new_s = cdStrDup(s); + p = new_s; + + for(i = 0; i < num_lin; i++) + { + q = strchr(p, '\n'); + if (q) *q = 0; /* Cut the string to contain only one line */ + + /* Draw the line */ + vf_wdraw_text(vector_font, x, y, p, width); + + /* Advance the string */ + if (q) p = q + 1; + + /* Advance a line */ + vf_wmove_dir(vector_font, &x, &y, 0, -line_height); + } + + free(new_s); } } + +void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* s) +{ + wdCanvasVectorText(canvas, x, y, s); +} + diff --git a/src/drv/cdcgm.c b/src/drv/cdcgm.c index 4ba0065..2791c24 100644 --- a/src/drv/cdcgm.c +++ b/src/drv/cdcgm.c @@ -519,7 +519,7 @@ static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s) cgm_text( ctxcanvas->cgm, 1 /* final */ , (double)x, (double)y, s ); - cdCanvasGetTextSize(ctxcanvas->canvas, s, &width, &height); + cdgettextsizeEX(ctxcanvas, s, &width, &height); settextbbox (ctxcanvas, (double) x, (double) y, width, height ); } @@ -530,7 +530,7 @@ static void cdftext(cdCtxCanvas *ctxcanvas, double x, double y, const char *s) cgm_text( ctxcanvas->cgm, 1 /* final */ , x, y, s ); - cdCanvasGetTextSize(ctxcanvas->canvas, s, &width, &height); + cdgettextsizeEX(ctxcanvas, s, &width, &height); settextbbox (ctxcanvas, x, y, width, height ); } diff --git a/src/drv/cdpicture.c b/src/drv/cdpicture.c index 9bc5104..3f5598e 100644 --- a/src/drv/cdpicture.c +++ b/src/drv/cdpicture.c @@ -307,12 +307,12 @@ static void primAddAttrib_Text(tPrimNode *prim, cdCanvas *canvas) if (canvas->native_font[0]) { - prim->attrib_buffer = strdup(canvas->native_font); + prim->attrib_buffer = cdStrDup(canvas->native_font); prim->attrib.text.native_font = prim->attrib_buffer; } else { - prim->attrib_buffer = strdup(canvas->font_type_face); + prim->attrib_buffer = cdStrDup(canvas->font_type_face); prim->attrib.text.font_type_face = prim->attrib_buffer; } } @@ -576,7 +576,7 @@ static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *text) primAddAttrib_Text(prim, ctxcanvas->canvas); prim->param.text.x = x; prim->param.text.y = y; - prim->param.text.s = strdup(text); + prim->param.text.s = cdStrDup(text); prim->param_buffer = prim->param.text.s; picAddPrim(ctxcanvas, prim); cdCanvasGetTextBox(ctxcanvas->canvas, x, y, text, &xmin, &xmax, &ymin, &ymax); @@ -591,7 +591,7 @@ static void cdftext(cdCtxCanvas *ctxcanvas, double x, double y, const char *text primAddAttrib_Text(prim, ctxcanvas->canvas); prim->param.textf.x = x; prim->param.textf.y = y; - prim->param.textf.s = strdup(text); + prim->param.textf.s = cdStrDup(text); prim->param_buffer = prim->param.textf.s; picAddPrim(ctxcanvas, prim); cdCanvasGetTextBox(ctxcanvas->canvas, _cdRound(x), _cdRound(y), text, &xmin, &xmax, &ymin, &ymax); diff --git a/src/intcgm/bparse.c b/src/intcgm/bparse.c index ad08179..c0ffada 100644 --- a/src/intcgm/bparse.c +++ b/src/intcgm/bparse.c @@ -179,7 +179,7 @@ int cgmb_intpre ( void ) int cgmb_realpr ( void ) { - short mode, i1; + short mode = 0, i1; long i2, i3; if ( cgmb_e ( &i1 ) ) return 1; @@ -543,7 +543,7 @@ int cgmb_vdcipr ( void ) int cgmb_vdcrpr ( void ) { short i1; - long mode, i2, i3; + long mode = 0, i2, i3; if ( cgmb_e ( &i1 ) ) return 1; if ( cgmb_i ( &i2 ) ) return 1; @@ -1320,7 +1320,7 @@ int cgmb_txftin ( void ) font = (char *) cgm_GetList ( intcgm_text_att.font_list, intcgm_text_att.font_index ); - if ( font==NULL ) font = (char*)strdup ( "SYSTEM" ); + if ( font==NULL ) font = "SYSTEM"; intcgm_text_att.font = 0; for ( i=0; font_array[i]!=NULL; i++ ) diff --git a/src/intcgm/intcgm2.c b/src/intcgm/intcgm2.c index f16c916..b6be7ee 100644 --- a/src/intcgm/intcgm2.c +++ b/src/intcgm/intcgm2.c @@ -1171,7 +1171,7 @@ int cgmb_r ( double *d ) int cgmb_s ( char **str ) { - register unsigned i; + register unsigned i = 0; unsigned char l; unsigned short l1; unsigned short cont; @@ -1206,9 +1206,7 @@ int cgmb_s ( char **str ) } s[i] = '\0'; - *str = (char*)strdup ( s ); - - free ( s ); + *str = s; return 0; } diff --git a/src/intcgm/tparse.c b/src/intcgm/tparse.c index 0402ce6..9bc47b3 100644 --- a/src/intcgm/tparse.c +++ b/src/intcgm/tparse.c @@ -1021,7 +1021,7 @@ int cgmt_txftin ( void ) /* text font index */ font = (char *) cgm_GetList ( intcgm_text_att.font_list, intcgm_text_att.font_index ); - if ( font==NULL ) font = (char*)strdup ( "SYSTEM" ); + if ( font==NULL ) font = "SYSTEM"; intcgm_text_att.font = 0; for ( i=0; font_array[i]!=NULL; i++ ) diff --git a/src/lua5/cdlua5_canvas.c b/src/lua5/cdlua5_canvas.c index 4d38cbf..d04f76f 100644 --- a/src/lua5/cdlua5_canvas.c +++ b/src/lua5/cdlua5_canvas.c @@ -1340,9 +1340,9 @@ static int cdlua5_textorientation(lua_State *L) } /***************************************************************************\ -* cd.FontDim() -> (max_width, max_height, ascent, descent: number) * +* cd.GetFontDim() -> (max_width, max_height, ascent, descent: number) * \***************************************************************************/ -static int cdlua5_fontdim(lua_State *L) +static int cdlua5_getfontdim(lua_State *L) { int max_width; int height; @@ -1358,9 +1358,9 @@ static int cdlua5_fontdim(lua_State *L) } /***************************************************************************\ -* cd.wFontDim() -> (max_width, max_height, ascent, descent: number) * +* cd.wGetFontDim() -> (max_width, max_height, ascent, descent: number) * \***************************************************************************/ -static int wdlua5_fontdim(lua_State *L) +static int wdlua5_getfontdim(lua_State *L) { double max_width; double height; @@ -1376,9 +1376,9 @@ static int wdlua5_fontdim(lua_State *L) } /***************************************************************************\ -* cd.TextSize(text: string) -> (width, heigth: number) * +* cd.GetTextSize(text: string) -> (width, heigth: number) * \***************************************************************************/ -static int cdlua5_textsize(lua_State *L) +static int cdlua5_gettextsize(lua_State *L) { int width; int height; @@ -1389,9 +1389,9 @@ static int cdlua5_textsize(lua_State *L) } /***************************************************************************\ -* cd.wTextSize(text: string) -> (width, heigth: number) * +* cd.wGetTextSize(text: string) -> (width, heigth: number) * \***************************************************************************/ -static int wdlua5_textsize(lua_State *L) +static int wdlua5_gettextsize(lua_State *L) { double width; double height; @@ -1402,9 +1402,9 @@ static int wdlua5_textsize(lua_State *L) } /****************************************************************************\ -* cd.TextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * +* cd.GetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * \****************************************************************************/ -static int cdlua5_textbox(lua_State *L) +static int cdlua5_gettextbox(lua_State *L) { int xmin, xmax, ymin, ymax; int x = luaL_checkint(L, 2); @@ -1420,9 +1420,9 @@ static int cdlua5_textbox(lua_State *L) } /*****************************************************************************\ -* cd.wTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * +* cd.wGetTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * \*****************************************************************************/ -static int wdlua5_textbox(lua_State *L) +static int wdlua5_gettextbox(lua_State *L) { double xmin, xmax, ymin, ymax; double x = luaL_checknumber(L, 2); @@ -1438,9 +1438,9 @@ static int wdlua5_textbox(lua_State *L) } /***************************************************************************************************************\ -* cd.TextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * +* cd.GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * \***************************************************************************************************************/ -static int cdlua5_textbounds(lua_State *L) +static int cdlua5_gettextbounds(lua_State *L) { int rect[8]; int x = luaL_checkint(L, 2); @@ -1460,9 +1460,9 @@ static int cdlua5_textbounds(lua_State *L) } /****************************************************************************************************************\ -* cd.wTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * +* cd.wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * \****************************************************************************************************************/ -static int wdlua5_textbounds(lua_State *L) +static int wdlua5_gettextbounds(lua_State *L) { double rect[8]; double x = luaL_checknumber(L, 2); @@ -1587,6 +1587,28 @@ static int cdlua5_vectortexttransform(lua_State *L) } /***************************************************************************\ +* cd.VectorFontSize(w, h: number, text: string) * +\***************************************************************************/ +static int cdlua5_vectorfontsize(lua_State *L) +{ + cdCanvasVectorFontSize(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3)); + return 0; +} + +/***************************************************************************\ +* cd.GetVectorFontSize(text: string) -> (w, h: number) * +\***************************************************************************/ +static int cdlua5_getvectorfontsize(lua_State *L) +{ + double width; + double height; + cdCanvasGetVectorFontSize(cdlua_checkcanvas(L, 1), &width, &height); + lua_pushnumber(L, width); + lua_pushnumber(L, height); + return 2; +} + +/***************************************************************************\ * cd.VectorTextSize(w, h: number, text: string) * \***************************************************************************/ static int cdlua5_vectortextsize(lua_State *L) @@ -1662,7 +1684,7 @@ static int wdlua5_getvectortextsize(lua_State *L) /***************************************************************************\ * cd.GetVectorTextBounds(s: string, px,py: number) -> (rect: table) * \***************************************************************************/ -static int cdlua5_vectortextbounds(lua_State *L) +static int cdlua5_getvectortextbounds(lua_State *L) { const char* s = luaL_checkstring(L, 2); int x = luaL_checkint(L, 3); @@ -1682,7 +1704,7 @@ static int cdlua5_vectortextbounds(lua_State *L) /***************************************************************************\ * cd.wGetVectorTextBounds(s: string, px,py: number) -> (rect: table) * \***************************************************************************/ -static int wdlua5_vectortextbounds(lua_State *L) +static int wdlua5_getvectortextbounds(lua_State *L) { const char* s = luaL_checkstring(L, 2); double x = luaL_checknumber(L, 3); @@ -1700,6 +1722,42 @@ static int wdlua5_vectortextbounds(lua_State *L) return 1; } +/****************************************************************************\ +* cd.GetVectorTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * +\****************************************************************************/ +static int cdlua5_getvectortextbox(lua_State *L) +{ + int xmin, xmax, ymin, ymax; + int x = luaL_checkint(L, 2); + int y = luaL_checkint(L, 3); + const char* s = luaL_checkstring(L, 4); + + cdCanvasGetVectorTextBox(cdlua_checkcanvas(L, 1), x, y, s, &xmin, &xmax, &ymin, &ymax); + lua_pushnumber(L, xmin); + lua_pushnumber(L, xmax); + lua_pushnumber(L, ymin); + lua_pushnumber(L, ymax); + return 4; +} + +/*****************************************************************************\ +* cd.wGetVectorTextBox(x, y: number, text: string) -> (xmin, xmax, ymin, ymax: number) * +\*****************************************************************************/ +static int wdlua5_getvectortextbox(lua_State *L) +{ + double xmin, xmax, ymin, ymax; + double x = luaL_checknumber(L, 2); + double y = luaL_checknumber(L, 3); + const char* s = luaL_checkstring(L, 4); + + wdCanvasGetVectorTextBox(cdlua_checkcanvas(L, 1), x, y, s, &xmin, &xmax, &ymin, &ymax); + lua_pushnumber(L, xmin); + lua_pushnumber(L, xmax); + lua_pushnumber(L, ymin); + lua_pushnumber(L, ymax); + return 4; +} + /***************************************************************************\ @@ -2249,14 +2307,14 @@ static const struct luaL_reg cdlib_canvas_meta[] = { {"NativeFont" , cdlua5_nativefont}, {"TextAlignment" , cdlua5_textalignment}, {"TextOrientation" , cdlua5_textorientation}, - {"GetFontDim" , cdlua5_fontdim}, - {"wGetFontDim" , wdlua5_fontdim}, - {"GetTextSize" , cdlua5_textsize}, - {"wGetTextSize" , wdlua5_textsize}, - {"GetTextBox" , cdlua5_textbox}, - {"wGetTextBox" , wdlua5_textbox}, - {"GetTextBounds" , cdlua5_textbounds}, - {"wGetTextBounds" , wdlua5_textbounds}, + {"GetFontDim" , cdlua5_getfontdim}, + {"wGetFontDim" , wdlua5_getfontdim}, + {"GetTextSize" , cdlua5_gettextsize}, + {"wGetTextSize" , wdlua5_gettextsize}, + {"GetTextBox" , cdlua5_gettextbox}, + {"wGetTextBox" , wdlua5_gettextbox}, + {"GetTextBounds" , cdlua5_gettextbounds}, + {"wGetTextBounds" , wdlua5_gettextbounds}, /* Vector Text */ {"VectorText" , cdlua5_vectortext}, @@ -2266,6 +2324,8 @@ static const struct luaL_reg cdlib_canvas_meta[] = { {"VectorTextDirection" , cdlua5_vectortextdirection}, {"wVectorTextDirection" , wdlua5_vectortextdirection}, {"VectorTextTransform" , cdlua5_vectortexttransform}, + {"VectorFontSize" , cdlua5_vectorfontsize}, + {"GetVectorFontSize" , cdlua5_getvectorfontsize}, {"VectorTextSize" , cdlua5_vectortextsize}, {"wVectorTextSize" , wdlua5_vectortextsize}, {"VectorCharSize" , cdlua5_vectorcharsize}, @@ -2273,8 +2333,10 @@ static const struct luaL_reg cdlib_canvas_meta[] = { {"VectorFont" , cdlua5_vectorfont}, {"GetVectorTextSize" , cdlua5_getvectortextsize}, {"wGetVectorTextSize" , wdlua5_getvectortextsize}, - {"VectorTextBounds" , cdlua5_vectortextbounds}, - {"wVectorTextBounds" , wdlua5_vectortextbounds}, + {"GetVectorTextBounds" , cdlua5_getvectortextbounds}, + {"wGetVectorTextBounds" , wdlua5_getvectortextbounds}, + {"GetVectorTextBox" , cdlua5_getvectortextbox}, + {"wGetVectorTextBox" , wdlua5_getvectortextbox}, /* Client Images */ {"GetImageRGB" , cdlua5_getimagergb}, diff --git a/src/pdflib/pdflib/p_type3.c b/src/pdflib/pdflib/p_type3.c index 411bd0d..c177443 100644 --- a/src/pdflib/pdflib/p_type3.c +++ b/src/pdflib/pdflib/p_type3.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: p_type3.c,v 1.1 2008/10/17 06:11:49 scuri Exp $ +/* $Id: p_type3.c,v 1.2 2009/06/23 03:18:34 scuri Exp $ * * Routines for Type 3 (user-defined) fonts * @@ -633,7 +633,7 @@ pdf__begin_glyph( /* see comment in p_font.c for explanation */ glyph->width = 1000 * wx * font->ft.matrix.a; - /* if the strdup above fails, cleanup won't touch this slot. */ + /* if the pdc_strdup above fails, cleanup won't touch this slot. */ t3font->next_glyph++; } glyph->pass = t3font->pass; diff --git a/src/sim/cdfontex.c b/src/sim/cdfontex.c index 699b06f..b0617a9 100644 --- a/src/sim/cdfontex.c +++ b/src/sim/cdfontex.c @@ -630,28 +630,16 @@ static void cdGetFontDimEx(int *max_width, int *line_height, int *ascent, int *d static void cdGetTextSizeEx(const char *s, int *width, int *height) { - int i = 0, numlin = 1, max_line_width = 0, line_width = 0; + int i = 0, w = 0; while (s[i] != '\0') { - if (s[i] == '\n') - { - numlin++; - line_width = 0; - } - else - { - line_width += font.CharWidth(s[i]); - } - - if (line_width > max_line_width) - max_line_width = line_width; - + w += font.CharWidth(s[i]); i++; } - if (height) *height = numlin * font.line_height; - if (width) *width = max_line_width; + if (height) *height = font.line_height; + if (width) *width = w; } void cdgetfontdimEX(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent) diff --git a/src/sim/sim_text.c b/src/sim/sim_text.c index 7172e16..86821ce 100644 --- a/src/sim/sim_text.c +++ b/src/sim/sim_text.c @@ -305,8 +305,8 @@ void simGetPenPos(cdCanvas* canvas, int x, int y, const char* s, FT_Matrix *matr int old_invert_yaxis = canvas->invert_yaxis; int w, h, ascent, height, baseline; - cdCanvasGetTextSize(canvas, s, &w, &h); - cdCanvasGetFontDim(canvas, NULL, &height, &ascent, NULL); + cdgettextsizeSIM(canvas->ctxcanvas, s, &w, &h); + cdgetfontdimSIM(canvas->ctxcanvas, NULL, &height, &ascent, NULL); baseline = height - ascent; /* in this case we are always upwards */ diff --git a/src/win32/cdwin.c b/src/win32/cdwin.c index 3a71746..ab8d63e 100644 --- a/src/win32/cdwin.c +++ b/src/win32/cdwin.c @@ -25,6 +25,8 @@ typedef BOOL (CALLBACK* AlphaBlendFunc)( HDC hdcDest, BLENDFUNCTION ftn); static AlphaBlendFunc cdwAlphaBlend = NULL; +static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height); + /* %F Libera memoria e handles alocados pelo driver Windows. */ @@ -967,7 +969,7 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i double cos_teta = cos(teta); double sin_teta = sin(teta); - cdCanvasGetTextSize(ctxcanvas->canvas, s, &w, &h); + cdgettextsize(ctxcanvas, s, &w, &h); wt = w; ht = h; @@ -1163,7 +1165,7 @@ static void cdwCanvasGetTextHeight(cdCanvas* canvas, int x, int y, const char *s int w, h, ascent, height, baseline; int xmin, xmax, ymin, ymax; - cdCanvasGetTextSize(canvas, s, &w, &h); + cdgettextsize(canvas->ctxcanvas, s, &w, &h); cdCanvasGetFontDim(canvas, NULL, &height, &ascent, NULL); baseline = height - ascent; @@ -1247,7 +1249,7 @@ static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s) { /* compensa deficiencia do alinhamento no windows */ int off; - cdCanvasGetTextSize(ctxcanvas->canvas, s, NULL, &h); + cdgettextsize(ctxcanvas, s, NULL, &h); off = h/2 - ctxcanvas->font.descent; if (ctxcanvas->canvas->text_orientation != 0) diff --git a/src/win32/cdwwmf.c b/src/win32/cdwwmf.c index 6b47aa5..0571c9f 100644 --- a/src/win32/cdwwmf.c +++ b/src/win32/cdwwmf.c @@ -76,7 +76,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void* data) ctxcanvas->clip_pnt[3].y = ctxcanvas->clip_pnt[2].y = canvas->h - 1; /* Inicializacao de variaveis particulares para o WMF */ - ctxcanvas->filename = strdup(filename); + ctxcanvas->filename = cdStrDup(filename); } static void cdinittable(cdCanvas* canvas) diff --git a/src/x11/xvertex.c b/src/x11/xvertex.c index 87a05e9..d58af13 100644 --- a/src/x11/xvertex.c +++ b/src/x11/xvertex.c @@ -48,16 +48,19 @@ /* Debugging macros */ #ifdef DEBUG -static int debug=1; +#define DEBUG_PRINT1(a) printf (a) +#define DEBUG_PRINT2(a, b) printf (a, b) +#define DEBUG_PRINT3(a, b, c) printf (a, b, c) +#define DEBUG_PRINT4(a, b, c, d) printf (a, b, c, d) +#define DEBUG_PRINT5(a, b, c, d, e) printf (a, b, c, d, e) #else -static int debug=0; +#define DEBUG_PRINT1(a) (a) +#define DEBUG_PRINT2(a, b) (a, b) +#define DEBUG_PRINT3(a, b, c) (a, b, c) +#define DEBUG_PRINT4(a, b, c, d) (a, b, c, d) +#define DEBUG_PRINT5(a, b, c, d, e) (a, b, c, d, e) #endif /*DEBUG*/ -#define DEBUG_PRINT1(a) if (debug) printf (a) -#define DEBUG_PRINT2(a, b) if (debug) printf (a, b) -#define DEBUG_PRINT3(a, b, c) if (debug) printf (a, b, c) -#define DEBUG_PRINT4(a, b, c, d) if (debug) printf (a, b, c, d) -#define DEBUG_PRINT5(a, b, c, d, e) if (debug) printf (a, b, c, d, e) /* ---------------------------------------------------------------------- */ @@ -126,29 +129,26 @@ static void XRotFreeTextItem(Display *dpy, RotatedTextItem *item); /* ---------------------------------------------------------------------- */ - /**************************************************************************/ -/* Routine to mimic `strdup()' (some machines don't have it) */ +/* Routine to mimic `my_strdup()' (some machines don't have it) */ /**************************************************************************/ static char *my_strdup(const char *str) { char *s; + int len; if(str==NULL) return NULL; - s=(char *)malloc((unsigned)(strlen(str)+1)); + len = (int)strlen(str); + s=(char *)malloc((unsigned)(len+1)); if(s!=NULL) - strcpy(s, str); + memcpy(s, str, len+1); return s; } - -/* ---------------------------------------------------------------------- */ - - /**************************************************************************/ /* Routine to replace `strtok' : this one returns a zero length string if */ /* it encounters two consecutive delimiters */ @@ -285,9 +285,9 @@ static int XRotDrawHorizontalString(Display *dpy, XFontStruct *font, Drawable dr str3=my_strtok(str1, str2); /* loop through each section in the string */ - do { - XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, - &overall); + do + { + XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, &overall); /* where to draw section in x ? */ if(align==XR_TLEFT || align==XR_MLEFT || align==XR_BLEFT || align==XR_LEFT) @@ -307,8 +307,7 @@ static int XRotDrawHorizontalString(Display *dpy, XFontStruct *font, Drawable dr yp+=height; str3=my_strtok((char *)NULL, str2); - } - while(str3!=NULL); + } while(str3!=NULL); free(str1); XFreeGC(dpy, my_gc); @@ -525,8 +524,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub str3=my_strtok(str1, str2); - XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, - &overall); + XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, &overall); item->max_width=overall.rbearing; @@ -1118,8 +1116,7 @@ XPoint *XRotTextExtents(Display* dpy, XFontStruct* font, double angle, int x, in str3=my_strtok(str1, str2); - XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, - &overall); + XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, &overall); max_width=overall.rbearing; @@ -1222,13 +1219,6 @@ int XRotDrawString(Display* dpy, XFontStruct* font, double angle, Drawable drawa RotatedTextItem *item; Pixmap bitmap_to_paint; - /* return early for NULL/empty strings */ - if(text==NULL) - return 0; - - if(strlen(text)==0) - return 0; - /* manipulate angle to 0<=angle<360 degrees */ while(angle<0) angle+=360; diff --git a/test/cdtest/cdtest.c b/test/cdtest/cdtest.c index bf701b9..9180bf4 100644 --- a/test/cdtest/cdtest.c +++ b/test/cdtest/cdtest.c @@ -393,6 +393,8 @@ static void CDTestClose(void) cdKillCanvas(ctgc.wd_canvas); cdKillCanvas(ctgc.iup_canvas); + memset(&ctgc, 0, sizeof(tCTC)); + IupDestroy(IupGetHandle("dlgLB")); IupDestroy(IupGetHandle("dlgAS")); IupDestroy(IupGetHandle("dlgPixel")); @@ -2378,6 +2380,9 @@ int fMotionCB(Ihandle *self, int x, int y, char *r) ignore(self); ignore(r); + if (!ctgc.iup_canvas) + return IUP_DEFAULT; + cdActivate(ctgc.iup_canvas); cdUpdateYAxis(&y); mouse_pos(x, y); @@ -2626,12 +2631,12 @@ void cdtest_loadled(void); /*-------------------------------------------------------------------------*/ /* Rotina principal. */ /*-------------------------------------------------------------------------*/ -void main(void) +int main(int argc, char** argv) { char *err = NULL; /* inicializa o IUP */ - IupOpen(); + IupOpen(&argc, &argv); /* carrega o LED */ #ifdef USE_LED @@ -2658,5 +2663,7 @@ void main(void) CDTestClose(); IupClose(); + + return 0; } diff --git a/test/cdtest/cdtest.sln b/test/cdtest/cdtest.sln deleted file mode 100644 index fb19d0c..0000000 --- a/test/cdtest/cdtest.sln +++ /dev/null @@ -1,16 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cdtest", "cdtest.vcproj", "{A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {A7E49FB8-700A-45EC-9174-FB1C2C7E83C9}.Debug|Win32.Build.0 = Debug|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/cdtest/cdtest_led.c b/test/cdtest/cdtest_led.c index b48b467..b4530b4 100644 --- a/test/cdtest/cdtest_led.c +++ b/test/cdtest/cdtest_led.c @@ -1,10 +1,10 @@ -/* Arquivo gerado automaticamente por ledc 2.5 */ +/* Automatically generated by Iup ledc 2.6 */ #include <stdlib.h> #include <stdarg.h> #include <iup.h> -static Ihandle* named[ 172 ]; +static Ihandle* named[ 172 ]; static Ihandle* decl( char* name, Ihandle* elem, char* first, ...) { @@ -25,7 +25,7 @@ static Ihandle* decl( char* name, Ihandle* elem, char* first, ...) static void image_imgLine (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, @@ -48,12 +48,12 @@ static void image_imgLine (void) decl( "imgLine", IupImage( 18, 18, map ), "0", "BGCOLOR", - "1", "0 0 0", 0 ); + "1", "0 0 0", NULL ); } static void image_imgClip (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, @@ -76,12 +76,12 @@ static void image_imgClip (void) decl( "imgClip", IupImage( 18, 18, map ), "0", "BGCOLOR", - "1", "0 0 0", 0 ); + "1", "0 0 0", NULL ); } static void image_imgImage (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, @@ -106,12 +106,12 @@ static void image_imgImage (void) "0", "BGCOLOR", "1", "0 0 0", "2", "255 255 255", - "3", "153 153 153", 0 ); + "3", "153 153 153", NULL ); } static void image_imgImageRGB (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -136,12 +136,12 @@ static void image_imgImageRGB (void) "0", "BGCOLOR", "1", "255 0 0", "2", "0 255 0", - "3", "0 0 255", 0 ); + "3", "0 0 255", NULL ); } static void image_imgBox (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, @@ -165,12 +165,12 @@ static void image_imgBox (void) decl( "imgBox", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } static void image_imgRect (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, @@ -194,12 +194,12 @@ static void image_imgRect (void) decl( "imgRect", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } static void image_imgSector (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, @@ -223,12 +223,12 @@ static void image_imgSector (void) decl( "imgSector", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } static void image_imgChord (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, @@ -252,12 +252,12 @@ static void image_imgChord (void) decl( "imgChord", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } static void image_imgArc (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -281,12 +281,12 @@ static void image_imgArc (void) decl( "imgArc", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } static void image_imgText (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -310,12 +310,12 @@ static void image_imgText (void) decl( "imgText", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "255 255 255", - "2", "0 0 0", 0 ); + "2", "0 0 0", NULL ); } static void image_imgPoly (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -338,12 +338,12 @@ static void image_imgPoly (void) decl( "imgPoly", IupImage( 18, 18, map ), "0", "BGCOLOR", - "1", "0 0 0", 0 ); + "1", "0 0 0", NULL ); } static void image_imgMark (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -366,12 +366,12 @@ static void image_imgMark (void) decl( "imgMark", IupImage( 18, 18, map ), "0", "BGCOLOR", - "1", "0 0 0", 0 ); + "1", "0 0 0", NULL ); } static void image_imgPixel (void) { - char map[] = { + unsigned char map[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -395,7 +395,7 @@ static void image_imgPixel (void) decl( "imgPixel", IupImage( 18, 18, map ), "0", "BGCOLOR", "1", "0 0 0", - "2", "255 255 255", 0 ); + "2", "255 255 255", NULL ); } @@ -417,66 +417,66 @@ void cdtest_loadled (void) named[0] = decl( "mnOpen", IupMenu( IupItem( "MF...", "cmdPlayMF" ), named[1] = decl( "itPlayCGM", IupItem( "CGM...", "cmdPlayCGM" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[2] = decl( "itPlayEMF", IupItem( "EMF...", "cmdPlayEMF" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[3] = decl( "itPlayWMF", IupItem( "WMF...", "cmdPlayWMF" ), - "ACTIVE", "NO", 0 ), - NULL), 0 ); + "ACTIVE", "NO", NULL ), + NULL), NULL ); named[4] = decl( "mnSave", IupMenu( IupItem( "MF...", "cmdMF" ), named[5] = decl( "itPDF", IupItem( "PDF...", "cmdPDF" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[6] = decl( "itPS", IupItem( "PS...", "cmdPS" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[7] = decl( "itEPS", IupItem( "EPS...", "cmdEPS" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[8] = decl( "itCGMt", IupItem( "CGMt...", "cmdCGMt" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[9] = decl( "itCGMb", IupItem( "CGMb...", "cmdCGMb" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[10] = decl( "itDGN", IupItem( "DGN...", "cmdDGN" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[11] = decl( "itDXF", IupItem( "DXF...", "cmdDXF" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[12] = decl( "itEMF", IupItem( "EMF...", "cmdEMF" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[13] = decl( "itWMF", IupItem( "WMF...", "cmdWMF" ), - "ACTIVE", "NO", 0 ), - NULL), 0 ); + "ACTIVE", "NO", NULL ), + NULL), NULL ); named[14] = decl( "mnFile", IupMenu( - decl( 0, IupSubmenu( "Open", + decl( NULL, IupSubmenu( "Open", named[0] /* mnOpen */ ), - "KEY", "K_O", 0 ), + "KEY", "K_O", NULL ), IupSeparator(), - decl( 0, IupSubmenu( "Save", + decl( NULL, IupSubmenu( "Save", named[4] /* mnSave */ ), - "KEY", "K_S", 0 ), + "KEY", "K_S", NULL ), IupSeparator(), named[15] = decl( "itPrint", IupItem( "Print...", "cmdPrint" ), - "KEY", "K_P", 0 ), + "KEY", "K_P", NULL ), IupSeparator(), - decl( 0, IupItem( "Exit", "cmdFileExit" ), - "KEY", "K_x", 0 ), - NULL), 0 ); + decl( NULL, IupItem( "Exit", "cmdFileExit" ), + "KEY", "K_x", NULL ), + NULL), NULL ); named[16] = decl( "mnEdit", IupMenu( - named[17] = decl( "itEditUndo", IupItem( "Undo", "cmdEditUndo" ), 0 ), + named[17] = decl( "itEditUndo", IupItem( "Undo", "cmdEditUndo" ), NULL ), IupSeparator(), named[18] = decl( "itClipBoard", IupItem( "Copy as EMF/WMF", "cmdClipBoard" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[19] = decl( "itClipBoardBitmap", IupItem( "Copy as Bitmap", "cmdClipBoardBitmap" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[20] = decl( "itClipBoardMetafile", IupItem( "Copy as CD Metafile", "cmdClipBoardMetafile" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), named[21] = decl( "itClipBoardPaste", IupItem( "Paste", "cmdClipBoardPaste" ), - "ACTIVE", "NO", 0 ), + "ACTIVE", "NO", NULL ), IupSeparator(), IupItem( "Clear", "cmdEditClear" ), IupSeparator(), IupItem( "Options...", "cmdOptions" ), - NULL), 0 ); + NULL), NULL ); named[22] = decl( "mnPrimitives", IupMenu( IupItem( "Pixel...", "cmdPixel" ), IupItem( "Mark...", "cmdMark" ), @@ -491,91 +491,91 @@ void cdtest_loadled (void) IupSeparator(), IupItem( "Server Image...", "cmdImage" ), IupItem( "RGB Image...", "cmdImageRGB" ), - NULL), 0 ); + NULL), NULL ); named[23] = decl( "mnDraw", IupMenu( - decl( 0, IupSubmenu( "Primitives", + decl( NULL, IupSubmenu( "Primitives", named[22] /* mnPrimitives */ ), - "KEY", "K_P", 0 ), + "KEY", "K_P", NULL ), IupSeparator(), IupItem( "Clipping...", "cmdClip" ), IupItem( "Attributes...", "cmdAttributes" ), IupSeparator(), - named[24] = decl( "itWDCanvas", IupItem( "Show WD Canvas", "cmdWDCanvas" ), 0 ), - named[25] = decl( "itPICCanvas", IupItem( "Show Picture Canvas", "cmdPICCanvas" ), 0 ), + named[24] = decl( "itWDCanvas", IupItem( "Show WD Canvas", "cmdWDCanvas" ), NULL ), + named[25] = decl( "itPICCanvas", IupItem( "Show Picture Canvas", "cmdPICCanvas" ), NULL ), NULL), - "ISMENU", "YES", 0 ); + "ISMENU", "YES", NULL ); named[26] = decl( "mnHelp", IupMenu( IupItem( "About...", "cmdHelpAbout" ), - NULL), 0 ); + NULL), NULL ); named[27] = decl( "mnMain", IupMenu( - decl( 0, IupSubmenu( "File", + decl( NULL, IupSubmenu( "File", named[14] /* mnFile */ ), - "KEY", "K_mF", 0 ), - decl( 0, IupSubmenu( "Edit", + "KEY", "K_mF", NULL ), + decl( NULL, IupSubmenu( "Edit", named[16] /* mnEdit */ ), - "KEY", "K_mE", 0 ), - decl( 0, IupSubmenu( "Draw", + "KEY", "K_mE", NULL ), + decl( NULL, IupSubmenu( "Draw", named[23] /* mnDraw */ ), - "KEY", "K_mD", 0 ), - decl( 0, IupSubmenu( "Help", + "KEY", "K_mD", NULL ), + decl( NULL, IupSubmenu( "Help", named[26] /* mnHelp */ ), - "KEY", "K_mH", 0 ), - NULL), 0 ); + "KEY", "K_mH", NULL ), + NULL), NULL ); named[28] = decl( "lbStatusLine", IupLabel( "Esta eh a barra de status do CDTest." ), - "EXPAND", "HORIZONTAL", 0 ); + "EXPAND", "HORIZONTAL", NULL ); named[29] = decl( "btLine", IupButton( "", "cmdLine" ), "IMAGE", "imgLine", - "TIP", "Line", 0 ); + "TIP", "Line", NULL ); named[30] = decl( "btBox", IupButton( "", "cmdBox" ), "IMAGE", "imgBox", - "TIP", "Box", 0 ); + "TIP", "Box", NULL ); named[31] = decl( "btRect", IupButton( "", "cmdRect" ), "IMAGE", "imgRect", - "TIP", "Rect", 0 ); + "TIP", "Rect", NULL ); named[32] = decl( "btArc", IupButton( "", "cmdArc" ), "IMAGE", "imgArc", - "TIP", "Arc", 0 ); + "TIP", "Arc", NULL ); named[33] = decl( "btSector", IupButton( "", "cmdSector" ), "IMAGE", "imgSector", - "TIP", "Sector", 0 ); + "TIP", "Sector", NULL ); named[34] = decl( "btChord", IupButton( "", "cmdChord" ), "IMAGE", "imgChord", - "TIP", "Chord", 0 ); + "TIP", "Chord", NULL ); named[35] = decl( "btPixel", IupButton( "", "cmdPixel" ), "IMAGE", "imgPixel", - "TIP", "Pixel", 0 ); + "TIP", "Pixel", NULL ); named[36] = decl( "btMark", IupButton( "", "cmdMark" ), "IMAGE", "imgMark", - "TIP", "Mark", 0 ); + "TIP", "Mark", NULL ); named[37] = decl( "btText", IupButton( "", "cmdText" ), "IMAGE", "imgText", - "TIP", "Text", 0 ); + "TIP", "Text", NULL ); named[38] = decl( "btPoly", IupButton( "", "cmdPoly" ), "IMAGE", "imgPoly", - "TIP", "Polygon", 0 ); + "TIP", "Polygon", NULL ); named[39] = decl( "btImageRGB", IupButton( "", "cmdImageRGB" ), "IMAGE", "imgImageRGB", - "TIP", "RGB Image", 0 ); + "TIP", "RGB Image", NULL ); named[40] = decl( "btImage", IupButton( "", "cmdImage" ), "IMAGE", "imgImage", - "TIP", "Server Image", 0 ); + "TIP", "Server Image", NULL ); named[41] = decl( "btClip", IupButton( "", "cmdClip" ), "IMAGE", "imgClip", - "TIP", "Clipping Area", 0 ); + "TIP", "Clipping Area", NULL ); named[42] = decl( "btCurPrim", IupButton( "", "cmdShowDialog" ), "IMAGE", "imgLine", - "TIP", "Show primitive dialog", 0 ); + "TIP", "Show primitive dialog", NULL ); named[43] = decl( "lbMousePos", IupLabel( "( , )" ), - "SIZE", "90", 0 ); + "SIZE", "90", NULL ); named[44] = decl( "PrimBar", IupVbox( named[42] /* btCurPrim */, - decl( 0, IupFill(), - "SIZE", "20", 0 ), + decl( NULL, IupFill(), + "SIZE", "20", NULL ), named[35] /* btPixel */, named[36] /* btMark */, named[29] /* btLine */, @@ -586,56 +586,56 @@ void cdtest_loadled (void) named[33] /* btSector */, named[34] /* btChord */, named[37] /* btText */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[40] /* btImage */, named[39] /* btImageRGB */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[41] /* btClip */, - decl( 0, IupFill(), - "SIZE", "30", 0 ), + decl( NULL, IupFill(), + "SIZE", "30", NULL ), NULL), - "GAP", "2", 0 ); + "GAP", "2", NULL ); named[45] = decl( "cnvColorBar", IupCanvas( "cmdColorBarRepaint" ), "BUTTON_CB", "cmdColorBarButtonCB", "RESIZE_CB", "cmdColorBarResizeCB", "SIZE", "220x12", "BORDER", "NO", - "EXPAND", "NO", 0 ); + "EXPAND", "NO", NULL ); named[46] = decl( "cnvMain", IupCanvas( "cmdRepaint" ), "MOTION_CB", "cmdMotionCB", "BUTTON_CB", "cmdButtonCB", - "RESIZE_CB", "cmdResizeCB", 0 ); + "RESIZE_CB", "cmdResizeCB", NULL ); named[47] = decl( "DeskTop", IupVbox( - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), IupHbox( - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[44] /* PrimBar */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupVbox( - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), named[43] /* lbMousePos */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[46] /* cnvMain */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), named[45] /* cnvColorBar */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[28] /* lbStatusLine */, NULL), - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), NULL), - decl( 0, IupFill(), - "SIZE", "5", 0 ), - NULL), 0 ); + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + NULL), NULL ); named[48] = decl( "dlgMain", IupDialog( named[47] /* DeskTop */ ), @@ -645,9 +645,9 @@ void cdtest_loadled (void) "K_cZ", "cmdEditUndo", "GETFOCUS_CB", "cmdGetFocusCB", "KILLFOCUS_CB", "cmdKillFocusCB", - "CLOSE_CB", "cmdFileExit", 0 ); + "CLOSE_CB", "cmdFileExit", NULL ); named[49] = decl( "cnvWDCanvas", IupCanvas( "cmdWDRepaint" ), - "BORDER", "NO", 0 ); + "BORDER", "NO", NULL ); named[50] = decl( "dlgWDCanvas", IupDialog( named[49] /* cnvWDCanvas */ ), @@ -655,9 +655,9 @@ void cdtest_loadled (void) "CLISE_CB", "cmdCloseWD", "SIZE", "200x200", "PARENTDIALOG", "dlgMain", - "GAP", "5x5", 0 ); + "GAP", "5x5", NULL ); named[51] = decl( "cnvPICCanvas", IupCanvas( "cmdPICRepaint" ), - "BORDER", "NO", 0 ); + "BORDER", "NO", NULL ); named[52] = decl( "dlgPICCanvas", IupDialog( named[51] /* cnvPICCanvas */ ), @@ -665,46 +665,46 @@ void cdtest_loadled (void) "CLISE_CB", "cmdClosePIC", "SIZE", "200x200", "PARENTDIALOG", "dlgMain", - "GAP", "5x5", 0 ); + "GAP", "5x5", NULL ); named[53] = decl( "btOptionsHide", IupButton( "Hide", "cmdOptionsHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[54] = decl( "tgSimulate", IupToggle( "Simulate", "cmdSimulate" ), "VALUE", "OFF", - "SIZE", "55", 0 ); + "SIZE", "55", NULL ); named[55] = decl( "tgStretchPlay", IupToggle( "Stretch Play", "cmdStretchPlay" ), "VALUE", "OFF", - "SIZE", "70", 0 ); + "SIZE", "70", NULL ); named[56] = decl( "tgNoBuffering", IupToggle( "No buffering", "cmdNoBuffering" ), - "VALUE", "ON", 0 ); - named[57] = decl( "tgImageBuffer", IupToggle( "CD_DBUFFER", "cmdImageBuffer" ), 0 ); - named[58] = decl( "tgRGBBuffer", IupToggle( "CD_DBUFFERRGB", "cmdRGBBuffer" ), 0 ); + "VALUE", "ON", NULL ); + named[57] = decl( "tgImageBuffer", IupToggle( "CD_DBUFFER", "cmdImageBuffer" ), NULL ); + named[58] = decl( "tgRGBBuffer", IupToggle( "CD_DBUFFERRGB", "cmdRGBBuffer" ), NULL ); named[59] = decl( "rdBuffering", IupRadio( IupVbox( named[56] /* tgNoBuffering */, named[57] /* tgImageBuffer */, named[58] /* tgRGBBuffer */, NULL) - ), 0 ); + ), NULL ); named[60] = decl( "OptionsDesktop", IupVbox( - decl( 0, IupVbox( - decl( 0, IupFrame( + decl( NULL, IupVbox( + decl( NULL, IupFrame( named[59] /* rdBuffering */ ), "TITLE", "Buffering:", "MARGIN", "5x5", - "SIZE", "80", 0 ), - decl( 0, IupFill(), - "SIZE", "10", 0 ), + "SIZE", "80", NULL ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), named[54] /* tgSimulate */, named[55] /* tgStretchPlay */, - decl( 0, IupFill(), - "SIZE", "10", 0 ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), named[53] /* btOptionsHide */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), NULL), - "GAP", "2", 0 ), - NULL), 0 ); + "GAP", "2", NULL ), + NULL), NULL ); named[61] = decl( "dlgOptions", IupDialog( named[60] /* OptionsDesktop */ ), @@ -713,7 +713,7 @@ void cdtest_loadled (void) "MAXBOX", "NO", "MINBOX", "NO", "RESIZE", "NO", - "MARGIN", "5x2", 0 ); + "MARGIN", "5x2", NULL ); named[62] = decl( "lstTextAlignment", IupList( "cmdTextAlignment" ), "1", "CD_NORTH", "2", "CD_SOUTH", @@ -729,11 +729,11 @@ void cdtest_loadled (void) "12", "CD_BASE_RIGHT", "DROPDOWN", "YES", "VALUE", "10", - "SIZE", "89", 0 ); + "SIZE", "89", NULL ); named[63] = decl( "txtMarkSize", IupText( "cmdInteger" ), "NC", "4", "SIZE", "20x12", - "VALUE", "10", 0 ); + "VALUE", "10", NULL ); named[64] = decl( "lstMarkType", IupList( "cmdMarkType" ), "1", "CD_PLUS", "2", "CD_STAR", @@ -746,14 +746,14 @@ void cdtest_loadled (void) "9", "CD_HOLLOW_DIAMOND", "DROPDOWN", "YES", "VALUE", "2", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[65] = decl( "lstWriteMode", IupList( "cmdWriteMode" ), "1", "CD_REPLACE", "2", "CD_XOR", "3", "CD_NOT_XOR", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[66] = decl( "lstFontTypeFace", IupList( "cmdFontTypeFace" ), "1", "CD_SYSTEM", "2", "CD_COURIER", @@ -761,27 +761,27 @@ void cdtest_loadled (void) "4", "CD_HELVETICA", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[67] = decl( "lstLineCap", IupList( "cmdLineCap" ), "1", "CD_CAPFLAT", "2", "CD_CAPSQUARE", "3", "CD_CAPROUND", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[68] = decl( "lstLineJoin", IupList( "cmdLineJoin" ), "1", "CD_BEVEL", "2", "CD_MITER", "3", "CD_ROUND", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[69] = decl( "lstFillMode", IupList( "cmdFillMode" ), "1", "CD_EVENODD", "2", "CD_WINDING", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[70] = decl( "lstFontStyle", IupList( "cmdFontStyle" ), "1", "CD_PLAIN", "2", "CD_BOLD", @@ -789,19 +789,19 @@ void cdtest_loadled (void) "4", "CD_BOLD_ITALIC", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[71] = decl( "txtLineWidth", IupText( "cmdInteger" ), "SIZE", "30", "NC", "3", - "VALUE", "1", 0 ); + "VALUE", "1", NULL ); named[72] = decl( "txtFontSize", IupText( "cmdInteger" ), "SIZE", "30", "NC", "3", - "VALUE", "12", 0 ); + "VALUE", "12", NULL ); named[73] = decl( "txtTextOrientation", IupText( "cmdInteger" ), "SIZE", "30", "NC", "3", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[74] = decl( "lstLineStyle", IupList( "cmdLineStyle" ), "1", "CD_CONTINUOUS", "2", "CD_DASHED", @@ -811,19 +811,19 @@ void cdtest_loadled (void) "6", "CD_CUSTOM", "VALUE", "1", "DROPDOWN", "YES", - "SIZE", "80", 0 ); + "SIZE", "80", NULL ); named[75] = decl( "tgSolid", IupToggle( "CD_SOLID", "cmdSolid" ), - "VALUE", "ON", 0 ); - named[76] = decl( "tgHatch", IupToggle( "CD_HATCH", "cmdHatch" ), 0 ); - named[77] = decl( "tgStipple", IupToggle( "CD_STIPPLE", "cmdStipple" ), 0 ); - named[78] = decl( "tgPattern", IupToggle( "CD_PATTERN", "cmdPattern" ), 0 ); + "VALUE", "ON", NULL ); + named[76] = decl( "tgHatch", IupToggle( "CD_HATCH", "cmdHatch" ), NULL ); + named[77] = decl( "tgStipple", IupToggle( "CD_STIPPLE", "cmdStipple" ), NULL ); + named[78] = decl( "tgPattern", IupToggle( "CD_PATTERN", "cmdPattern" ), NULL ); named[79] = decl( "lstOpacity", IupList( "cmdOpacity" ), "1", "CD_OPAQUE", "2", "CD_TRANSPARENT", "VALUE", "2", "DROPDOWN", "YES", "SIZE", "80", - "ACTIVE", "YES", 0 ); + "ACTIVE", "YES", NULL ); named[80] = decl( "lstHatchStyle", IupList( "cmdHatchStyle" ), "1", "CD_HORIZONTAL", "2", "CD_VERTICAL", @@ -834,9 +834,9 @@ void cdtest_loadled (void) "VALUE", "1", "DROPDOWN", "YES", "SIZE", "80", - "ACTIVE", "YES", 0 ); + "ACTIVE", "YES", NULL ); named[81] = decl( "btAttributesHide", IupButton( "Hide", "cmdAttributesHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[82] = decl( "rdInteriorStyle", IupRadio( IupVbox( named[75] /* tgSolid */, @@ -844,110 +844,110 @@ void cdtest_loadled (void) named[77] /* tgStipple */, named[78] /* tgPattern */, NULL) - ), 0 ); + ), NULL ); named[83] = decl( "AttributesDesktop", IupVbox( IupHbox( - decl( 0, IupVbox( + decl( NULL, IupVbox( IupLabel( "Write Mode:" ), named[65] /* lstWriteMode */, - decl( 0, IupFill(), - "SIZE", "4", 0 ), - decl( 0, IupFrame( + decl( NULL, IupFill(), + "SIZE", "4", NULL ), + decl( NULL, IupFrame( IupVbox( IupLabel( "Back Opacity:" ), named[79] /* lstOpacity */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Fill Mode:" ), named[69] /* lstFillMode */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), - decl( 0, IupFrame( + decl( NULL, IupFill(), + "SIZE", "2", NULL ), + decl( NULL, IupFrame( named[82] /* rdInteriorStyle */ ), "TITLE", "Interior Style:", "MARGIN", "5x5", - "SIZE", "80", 0 ), - decl( 0, IupFill(), - "SIZE", "2", 0 ), + "SIZE", "80", NULL ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Hatch Style:" ), named[80] /* lstHatchStyle */, NULL) ), "TITLE", "Fill Attributes", - "MARGIN", "5x5", 0 ), - decl( 0, IupFill(), - "SIZE", "10", 0 ), - decl( 0, IupFrame( + "MARGIN", "5x5", NULL ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), + decl( NULL, IupFrame( IupVbox( IupLabel( "Mark Type:" ), named[64] /* lstMarkType */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Mark Size:" ), named[63] /* txtMarkSize */, NULL) ), "TITLE", "Mark Attributes", - "MARGIN", "5x5", 0 ), - decl( 0, IupFill(), - "SIZE", "10", 0 ), + "MARGIN", "5x5", NULL ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), named[81] /* btAttributesHide */, NULL), - "GAP", "2", 0 ), - decl( 0, IupVbox( - decl( 0, IupFrame( + "GAP", "2", NULL ), + decl( NULL, IupVbox( + decl( NULL, IupFrame( IupVbox( IupLabel( "Font Typeface:" ), named[66] /* lstFontTypeFace */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Font Style:" ), named[70] /* lstFontStyle */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Font Size:" ), named[72] /* txtFontSize */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), - decl( 0, IupLabel( "Text Alignment:" ), - "SIZE", "x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), + decl( NULL, IupLabel( "Text Alignment:" ), + "SIZE", "x9", NULL ), named[62] /* lstTextAlignment */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), - decl( 0, IupLabel( "Text Orientation:" ), - "SIZE", "x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), + decl( NULL, IupLabel( "Text Orientation:" ), + "SIZE", "x9", NULL ), named[73] /* txtTextOrientation */, NULL) ), "TITLE", "Text Attributes", - "MARGIN", "5x5", 0 ), - decl( 0, IupFill(), - "SIZE", "10", 0 ), - decl( 0, IupFrame( + "MARGIN", "5x5", NULL ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), + decl( NULL, IupFrame( IupVbox( IupLabel( "Line Style:" ), named[74] /* lstLineStyle */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Line Width:" ), named[71] /* txtLineWidth */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Line Cap:" ), named[67] /* lstLineCap */, - decl( 0, IupFill(), - "SIZE", "2", 0 ), + decl( NULL, IupFill(), + "SIZE", "2", NULL ), IupLabel( "Line Join:" ), named[68] /* lstLineJoin */, NULL) ), "TITLE", "Line Attributes", - "MARGIN", "5x5", 0 ), + "MARGIN", "5x5", NULL ), NULL), - "GAP", "2", 0 ), + "GAP", "2", NULL ), NULL), - NULL), 0 ); + NULL), NULL ); named[84] = decl( "dlgAttributes", IupDialog( named[83] /* AttributesDesktop */ ), @@ -957,51 +957,51 @@ void cdtest_loadled (void) "MINBOX", "NO", "RESIZE", "NO", "CLOSE_CB", "cmdAttributesHide", - "MARGIN", "5x2", 0 ); + "MARGIN", "5x2", NULL ); named[85] = decl( "txtLBX1", IupText( "cmdInteger" ), "NC", "8", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[86] = decl( "txtLBX2", IupText( "cmdInteger" ), "NC", "8", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[87] = decl( "txtLBY1", IupText( "cmdInteger" ), "NC", "8", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[88] = decl( "txtLBY2", IupText( "cmdInteger" ), "NC", "8", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[89] = decl( "btLBDraw", IupButton( "Draw", "cmdDraw" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[90] = decl( "btLBHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[91] = decl( "LBData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "X1:" ), - "SIZE", "15x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X1:" ), + "SIZE", "15x9", NULL ), named[85] /* txtLBX1 */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y1:" ), - "SIZE", "15x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y1:" ), + "SIZE", "15x9", NULL ), named[87] /* txtLBY1 */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "X2:" ), - "SIZE", "15x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X2:" ), + "SIZE", "15x9", NULL ), named[86] /* txtLBX2 */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y2:" ), - "SIZE", "15x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y2:" ), + "SIZE", "15x9", NULL ), named[88] /* txtLBY2 */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[92] = decl( "LBDeskTop", IupVbox( IupHbox( IupFill(), @@ -1011,12 +1011,12 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[89] /* btLBDraw */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[90] /* btLBHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[93] = decl( "dlgLB", IupDialog( named[92] /* LBDeskTop */ ), @@ -1026,70 +1026,70 @@ void cdtest_loadled (void) "MINBOX", "NO", "RESIZE", "NO", "CLOSE_CB", "cmdMsgHide", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[94] = decl( "txtASXC", IupText( "cmdInteger" ), "NC", "4", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[95] = decl( "txtASYC", IupText( "cmdInteger" ), "NC", "4", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[96] = decl( "txtASW", IupText( "cmdInteger" ), "NC", "4", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[97] = decl( "txtASH", IupText( "cmdInteger" ), "NC", "4", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[98] = decl( "txtASAngle1", IupText( "cmdReal" ), "NC", "10", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[99] = decl( "txtASAngle2", IupText( "cmdReal" ), "NC", "10", "SIZE", "30x12", - "VALUE", "360", 0 ); + "VALUE", "360", NULL ); named[100] = decl( "btASDraw", IupButton( "Draw", "cmdDraw" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[101] = decl( "btASHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[102] = decl( "ASData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "Xc:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Xc:" ), + "SIZE", "30x9", NULL ), named[94] /* txtASXC */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Yc:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Yc:" ), + "SIZE", "30x9", NULL ), named[95] /* txtASYC */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "W:" ), - "SIZE", "30x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "W:" ), + "SIZE", "30x9", NULL ), named[96] /* txtASW */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "H:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "H:" ), + "SIZE", "30x9", NULL ), named[97] /* txtASH */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "Angle1:" ), - "SIZE", "30x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Angle1:" ), + "SIZE", "30x9", NULL ), named[98] /* txtASAngle1 */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Angle2:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Angle2:" ), + "SIZE", "30x9", NULL ), named[99] /* txtASAngle2 */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[103] = decl( "ASDeskTop", IupVbox( IupHbox( IupFill(), @@ -1099,12 +1099,12 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[100] /* btASDraw */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[101] /* btASHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[104] = decl( "dlgAS", IupDialog( named[103] /* ASDeskTop */ ), @@ -1114,32 +1114,32 @@ void cdtest_loadled (void) "MINBOX", "NO", "RESIZE", "NO", "CLOSE_CB", "cmdMsgHide", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[105] = decl( "txtPixelX", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[106] = decl( "txtPixelY", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[107] = decl( "btPixelDraw", IupButton( "Draw", "cmdDraw" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[108] = decl( "btPixelHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[109] = decl( "PixelData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "X:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X:" ), + "SIZE", "10x9", NULL ), named[105] /* txtPixelX */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y:" ), + "SIZE", "10x9", NULL ), named[106] /* txtPixelY */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[110] = decl( "PixelDeskTop", IupVbox( IupHbox( IupFill(), @@ -1149,12 +1149,12 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[107] /* btPixelDraw */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[108] /* btPixelHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[111] = decl( "dlgPixel", IupDialog( named[110] /* PixelDeskTop */ ), @@ -1164,34 +1164,34 @@ void cdtest_loadled (void) "MINBOX", "NO", "RESIZE", "NO", "CLOSE_CB", "cmdMsgHide", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[112] = decl( "txtMarkX", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[113] = decl( "txtMarkY", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[114] = decl( "btMarkDraw", IupButton( "Draw", "cmdDraw" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[115] = decl( "btMarkHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[116] = decl( "MarkData", IupVbox( - decl( 0, IupHbox( + decl( NULL, IupHbox( IupFill(), - decl( 0, IupLabel( "X:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupLabel( "X:" ), + "SIZE", "10x9", NULL ), named[112] /* txtMarkX */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y:" ), + "SIZE", "10x9", NULL ), named[113] /* txtMarkY */, IupFill(), NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[117] = decl( "MarkDeskTop", IupVbox( IupHbox( IupFill(), @@ -1201,12 +1201,12 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[114] /* btMarkDraw */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[115] /* btMarkHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[118] = decl( "dlgMark", IupDialog( named[117] /* MarkDeskTop */ ), @@ -1216,43 +1216,43 @@ void cdtest_loadled (void) "MINBOX", "NO", "RESIZE", "NO", "CLOSE_CB", "cmdMsgHide", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[119] = decl( "txtTextX", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[120] = decl( "txtTextY", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[121] = decl( "txtTextS", IupText( "cmdString" ), "NC", "100", "SIZE", "89x12", - "VALUE", "Text", 0 ); + "VALUE", "Text", NULL ); named[122] = decl( "btTextDraw", IupButton( "Draw", "cmdDraw" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[123] = decl( "btTextHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[124] = decl( "TextData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "X:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X:" ), + "SIZE", "10x9", NULL ), named[119] /* txtTextX */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y:" ), - "SIZE", "10x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y:" ), + "SIZE", "10x9", NULL ), named[120] /* txtTextY */, NULL), - "ALIGNMENT", "ACENTER", 0 ), + "ALIGNMENT", "ACENTER", NULL ), IupHbox( IupVbox( - decl( 0, IupLabel( "Text:" ), - "SIZE", "25x9", 0 ), + decl( NULL, IupLabel( "Text:" ), + "SIZE", "25x9", NULL ), named[121] /* txtTextS */, NULL), NULL), - NULL), 0 ); + NULL), NULL ); named[125] = decl( "TextDeskTop", IupVbox( IupHbox( IupFill(), @@ -1262,12 +1262,12 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[122] /* btTextDraw */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[123] /* btTextHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[126] = decl( "dlgText", IupDialog( named[125] /* TextDeskTop */ ), @@ -1277,15 +1277,15 @@ void cdtest_loadled (void) "MINBOX", "NO", "CLOSE_CB", "cmdMsgHide", "RESIZE", "NO", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[127] = decl( "tgOpenLines", IupToggle( "CD_OPEN_LINES", "cmdOpenLines" ), - "VALUE", "ON", 0 ); - named[128] = decl( "tgClosedLines", IupToggle( "CD_CLOSED_LINES", "cmdClosedLines" ), 0 ); - named[129] = decl( "tgFilled", IupToggle( "CD_FILL", "cmdFill" ), 0 ); - named[130] = decl( "tgClip", IupToggle( "CD_CLIP", "cmdPolyClip" ), 0 ); - named[131] = decl( "tgBezier", IupToggle( "CD_BEZIER", "cmdPolyBezier" ), 0 ); + "VALUE", "ON", NULL ); + named[128] = decl( "tgClosedLines", IupToggle( "CD_CLOSED_LINES", "cmdClosedLines" ), NULL ); + named[129] = decl( "tgFilled", IupToggle( "CD_FILL", "cmdFill" ), NULL ); + named[130] = decl( "tgClip", IupToggle( "CD_CLIP", "cmdPolyClip" ), NULL ); + named[131] = decl( "tgBezier", IupToggle( "CD_BEZIER", "cmdPolyBezier" ), NULL ); named[132] = decl( "btPolyHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[133] = decl( "rdMode", IupRadio( IupVbox( named[127] /* tgOpenLines */, @@ -1294,32 +1294,32 @@ void cdtest_loadled (void) named[130] /* tgClip */, named[131] /* tgBezier */, NULL) - ), 0 ); + ), NULL ); named[134] = decl( "PolyDesktop", IupVbox( - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), IupHbox( IupFill(), - decl( 0, IupFrame( + decl( NULL, IupFrame( IupHbox( - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[133] /* rdMode */, NULL) ), - "TITLE", "Polygon Mode:", 0 ), + "TITLE", "Polygon Mode:", NULL ), IupFill(), NULL), - decl( 0, IupFill(), - "SIZE", "10", 0 ), + decl( NULL, IupFill(), + "SIZE", "10", NULL ), IupHbox( IupFill(), named[132] /* btPolyHide */, IupFill(), NULL), - decl( 0, IupFill(), - "SIZE", "5", 0 ), - NULL), 0 ); + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + NULL), NULL ); named[135] = decl( "dlgPoly", IupDialog( named[134] /* PolyDesktop */ ), @@ -1328,55 +1328,55 @@ void cdtest_loadled (void) "MAXBOX", "NO", "MINBOX", "NO", "RESIZE", "NO", - "CLOSE_CB", "cmdMsgHide", 0 ); + "CLOSE_CB", "cmdMsgHide", NULL ); named[136] = decl( "txtClipXmin", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[137] = decl( "txtClipXmax", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[138] = decl( "txtClipYmin", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[139] = decl( "txtClipYmax", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[140] = decl( "btClipOff", IupButton( "Off", "cmdClipOff" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[141] = decl( "btClipArea", IupButton( "Area", "cmdClipArea" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[142] = decl( "btClipPoly", IupButton( "Polygon", "cmdClipPoly" ), - "SIZE", "50", 0 ); + "SIZE", "50", NULL ); named[143] = decl( "btClipHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[144] = decl( "ClipData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "Xmin:" ), - "SIZE", "25x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Xmin:" ), + "SIZE", "25x9", NULL ), named[136] /* txtClipXmin */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Ymin:" ), - "SIZE", "25x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Ymin:" ), + "SIZE", "25x9", NULL ), named[138] /* txtClipYmin */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "Xmax:" ), - "SIZE", "25x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Xmax:" ), + "SIZE", "25x9", NULL ), named[137] /* txtClipXmax */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Ymax:" ), - "SIZE", "25x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Ymax:" ), + "SIZE", "25x9", NULL ), named[139] /* txtClipYmax */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[145] = decl( "ClipDeskTop", IupVbox( IupHbox( IupFill(), @@ -1386,18 +1386,18 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[140] /* btClipOff */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[141] /* btClipArea */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[142] /* btClipPoly */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[143] /* btClipHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[146] = decl( "dlgClip", IupDialog( named[145] /* ClipDeskTop */ ), @@ -1407,53 +1407,53 @@ void cdtest_loadled (void) "CLOSE_CB", "cmdMsgHide", "MINBOX", "NO", "RESIZE", "NO", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[147] = decl( "txtImageX", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[148] = decl( "txtImageY", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[149] = decl( "txtImageW", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[150] = decl( "txtImageH", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[151] = decl( "btImagePut", IupButton( "Put", "cmdImagePut" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[152] = decl( "btImageGet", IupButton( "Get", "cmdImageGet" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[153] = decl( "btImageHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[154] = decl( "ImageData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "X:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X:" ), + "SIZE", "30x9", NULL ), named[147] /* txtImageX */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y:" ), + "SIZE", "30x9", NULL ), named[148] /* txtImageY */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "Width:" ), - "SIZE", "30x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Width:" ), + "SIZE", "30x9", NULL ), named[149] /* txtImageW */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Height:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Height:" ), + "SIZE", "30x9", NULL ), named[150] /* txtImageH */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[155] = decl( "ImageDeskTop", IupVbox( IupHbox( IupFill(), @@ -1463,15 +1463,15 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[152] /* btImageGet */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[151] /* btImagePut */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[153] /* btImageHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[156] = decl( "dlgImage", IupDialog( named[155] /* ImageDeskTop */ ), @@ -1481,53 +1481,53 @@ void cdtest_loadled (void) "MINBOX", "NO", "CLOSE_CB", "cmdMsgHide", "RESIZE", "NO", - "MARGIN", "5x5", 0 ); + "MARGIN", "5x5", NULL ); named[157] = decl( "txtImageRGBX", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[158] = decl( "txtImageRGBY", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[159] = decl( "txtImageRGBW", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[160] = decl( "txtImageRGBH", IupText( "cmdInteger" ), "NC", "5", "SIZE", "30x12", - "VALUE", "0", 0 ); + "VALUE", "0", NULL ); named[161] = decl( "btImageRGBPut", IupButton( "Put", "cmdImageRGBPut" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[162] = decl( "btImageRGBGet", IupButton( "Get", "cmdImageRGBGet" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[163] = decl( "btImageRGBHide", IupButton( "Hide", "cmdMsgHide" ), - "SIZE", "30", 0 ); + "SIZE", "30", NULL ); named[164] = decl( "ImageRGBData", IupVbox( - decl( 0, IupHbox( - decl( 0, IupLabel( "X:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "X:" ), + "SIZE", "30x9", NULL ), named[157] /* txtImageRGBX */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Y:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Y:" ), + "SIZE", "30x9", NULL ), named[158] /* txtImageRGBY */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - decl( 0, IupHbox( - decl( 0, IupLabel( "Width:" ), - "SIZE", "30x9", 0 ), + "ALIGNMENT", "ACENTER", NULL ), + decl( NULL, IupHbox( + decl( NULL, IupLabel( "Width:" ), + "SIZE", "30x9", NULL ), named[159] /* txtImageRGBW */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), - decl( 0, IupLabel( "Height:" ), - "SIZE", "30x9", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), + decl( NULL, IupLabel( "Height:" ), + "SIZE", "30x9", NULL ), named[160] /* txtImageRGBH */, NULL), - "ALIGNMENT", "ACENTER", 0 ), - NULL), 0 ); + "ALIGNMENT", "ACENTER", NULL ), + NULL), NULL ); named[165] = decl( "ImageRGBDeskTop", IupVbox( IupHbox( IupFill(), @@ -1537,15 +1537,15 @@ void cdtest_loadled (void) IupHbox( IupFill(), named[162] /* btImageRGBGet */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[161] /* btImageRGBPut */, - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), named[163] /* btImageRGBHide */, IupFill(), NULL), - NULL), 0 ); + NULL), NULL ); named[166] = decl( "dlgImageRGB", IupDialog( named[165] /* ImageRGBDeskTop */ ), @@ -1555,30 +1555,30 @@ void cdtest_loadled (void) "MINBOX", "NO", "CLOSE_CB", "cmdMsgHide", "RESIZE", "NO", - "MARGIN", "5x5", 0 ); - named[167] = decl( "btCDTest", IupButton( "Close", "cmdCloseAbout" ), 0 ); + "MARGIN", "5x5", NULL ); + named[167] = decl( "btCDTest", IupButton( "Close", "cmdCloseAbout" ), NULL ); named[168] = decl( "AboutDeskTop", IupHbox( IupFill(), - decl( 0, IupVbox( + decl( NULL, IupVbox( IupLabel( "CD Test 5.3" ), - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), IupLabel( "Antonio Scuri" ), IupLabel( "Diego Nehab" ), - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), IupLabel( "Tecgraf/PUC-Rio" ), - decl( 0, IupFill(), - "SIZE", "5", 0 ), + decl( NULL, IupFill(), + "SIZE", "5", NULL ), IupLabel( "CD Library Version" ), - named[169] = decl( "lblVersion", IupLabel( "" ), 0 ), + named[169] = decl( "lblVersion", IupLabel( "" ), NULL ), named[167] /* btCDTest */, NULL), - "ALIGNMENT", "ACENTER", 0 ), + "ALIGNMENT", "ACENTER", NULL ), IupFill(), NULL), "MARGIN", "5x5", - "GAP", "2", 0 ); + "GAP", "2", NULL ); named[170] = decl( "dlgHelpAbout", IupDialog( named[168] /* AboutDeskTop */ ), @@ -1586,5 +1586,5 @@ void cdtest_loadled (void) "TITLE", "About", "MAXBOX", "NO", "MINBOX", "NO", - "RESIZE", "NO", 0 ); + "RESIZE", "NO", NULL ); } diff --git a/test/simple/iupmain.c b/test/simple/iupmain.c index 7db2672..4eb4a5d 100644 --- a/test/simple/iupmain.c +++ b/test/simple/iupmain.c @@ -1,4 +1,4 @@ - +#include <stdlib.h> #include <iup.h> #include <cd.h> @@ -11,9 +11,9 @@ int cmdExit(void) void simple_loadled (void); -int main(void) +int main(int argc, char** argv) { - IupOpen(); + IupOpen(&argc, &argv); cdInitContextPlus(); @@ -79,5 +79,5 @@ int main(void) IupClose(); - return 1; + return EXIT_SUCCESS; } diff --git a/test/simple/simple.c b/test/simple/simple.c index efdee2e..c9ba361 100644 --- a/test/simple/simple.c +++ b/test/simple/simple.c @@ -511,8 +511,8 @@ int SimpleDrawAll(void) wdWindow(0,1,0,(double)h/(double)w); /* Clear the background to be white */ -// cdBackground(CD_WHITE); - cdBackground(CD_GREEN); + cdBackground(CD_WHITE); +// cdBackground(CD_GREEN); cdClear(); cdLineWidth(3); @@ -831,21 +831,82 @@ int SimpleDrawAll(void) return 0; } +void DrawVectorTextBox(int x, int y, char* text) +{ + int rect[8], draw_box; + + cdLineWidth(1); + cdLineStyle(CD_CONTINUOUS); + + draw_box = 0; + if (draw_box) + { + int xmin, xmax, ymin, ymax; + cdCanvasGetVectorTextBox(cdActiveCanvas(), x, y, text, &xmin, &xmax, &ymin, &ymax); + cdForeground(CD_GREEN); + cdRect(xmin, xmax, ymin, ymax); + + if (cdTextOrientation(CD_QUERY) == 0) + { + cdForeground(CD_RED); + cdLine(xmin, y, xmax, y); + } + } + else + { + /* bounding box */ + cdGetVectorTextBounds(text, x, y, rect); + cdForeground(CD_GREEN); + cdBegin(CD_CLOSED_LINES); + cdVertex(rect[0], rect[1]); + cdVertex(rect[2], rect[3]); + cdVertex(rect[4], rect[5]); + cdVertex(rect[6], rect[7]); + cdEnd(); + } + + /* reference point */ + cdForeground(CD_BLUE); + cdMarkType(CD_PLUS); + cdMarkSize(30); + cdMark(x, y); + + cdForeground(CD_BLACK); + cdVectorText(x, y, text); +} + void DrawTextBox(int x, int y, char* text) { - int xmin, xmax, ymin, ymax; + int rect[8], draw_box; cdLineWidth(1); cdLineStyle(CD_CONTINUOUS); - /* bounding box */ - cdTextBox(x, y, text, &xmin, &xmax, &ymin, &ymax); - cdForeground(CD_GREEN); - cdRect(xmin, xmax, ymin, ymax); + draw_box = 0; + if (draw_box) + { + int xmin, xmax, ymin, ymax; + cdTextBox(x, y, text, &xmin, &xmax, &ymin, &ymax); + cdRect(xmin, xmax, ymin, ymax); - /* baseline */ - cdForeground(CD_RED); - cdLine(xmin, y, xmax, y); + if (cdTextOrientation(CD_QUERY) == 0) + { + cdForeground(CD_RED); + cdLine(xmin, y, xmax, y); + } + } + else + { + /* bounding box */ + cdTextBounds(x, y, text, rect); + cdForeground(CD_GREEN); + cdBegin(CD_CLOSED_LINES); + cdVertex(rect[0], rect[1]); + cdVertex(rect[2], rect[3]); + cdVertex(rect[4], rect[5]); + cdVertex(rect[6], rect[7]); + cdEnd(); + } /* reference point */ cdForeground(CD_BLUE); @@ -859,7 +920,7 @@ void DrawTextBox(int x, int y, char* text) int SimpleDrawTextAlign(void) { - int w, h, i, xoff, yoff; + int w, h, i, xoff, yoff, use_vector; int text_aligment[] = { CD_NORTH, @@ -876,20 +937,37 @@ int SimpleDrawTextAlign(void) CD_BASE_LEFT }; +#if 1 char* text_aligment_str[] = { - "jNorth (Ãy)", - "jSouth (Ãy)", - "jEast (Ãy)", - "jWest (Ãy)", - "jNorth East (Ãy)", - "jNorth West (Ãy)", - "jSouth East (Ãy)", - "jSouth West (Ãy)", - "jCenter (Ãy)", - "jBase Center (Ãy)", - "jBase Right (Ãy)", - "jBase Left (Ãy)" + "North (Ãyj)\nSecond Line (Ãyj)", + "South (Ãyj)\nSecond Line (Ãyj)", + "East (Ãyj)\nSecond Line (Ãyj)", + "West (Ãyj)\nSecond Line (Ãyj)", + "North East (Ãyj)\nSecond Line (Ãyj)", + "North West (Ãyj)\nSecond Line (Ãyj)", + "South East (Ãyj)\nSecond Line (Ãyj)", + "South West (Ãyj)\nSecond Line (Ãyj)", + "Center (Ãyj)\nSecond Line (Ãyj)", + "Base Center (Ãyj)\nSecond Line (Ãyj)", + "Base Right (Ãyj)\nSecond Line (Ãyj)", + "Base Left (Ãyj)\nSecond Line (Ãyj)" }; +#else + char* text_aligment_str[] = { + "North (Ãyj)", + "South (Ãyj)", + "East (Ãyj)", + "West (Ãyj)", + "North East (Ãyj)", + "North West (Ãyj)", + "South East (Ãyj)", + "South West (Ãyj)", + "Center (Ãyj)", + "Base Center (Ãyj)", + "Base Right (Ãyj)", + "Base Left (Ãyj)" + }; +#endif cdGetCanvasSize(&w, &h, 0, 0); @@ -898,26 +976,43 @@ int SimpleDrawTextAlign(void) simple_draw = DRAW_TEXTALIGN; -// cdTextOrientation(45); + use_vector = 0; + + //if (use_vector) + // cdVectorTextDirection(0, 0, 1, 1); + //else + // cdTextOrientation(45); xoff = w/4; yoff = h/7; -//cdFont(CD_TIMES_ROMAN, CD_PLAIN, 14); - cdFont(CD_HELVETICA, CD_PLAIN, 18); + if (use_vector) + cdVectorCharSize(30); + else + { + //cdFont(CD_TIMES_ROMAN, CD_PLAIN, 14); + cdFont(CD_HELVETICA, CD_PLAIN, 18); + } for (i = 0; i < 12; i++) { cdTextAlignment(text_aligment[i]); if (i < 6) { - DrawTextBox(xoff, yoff*(i+1), text_aligment_str[i]); + if (use_vector) + DrawVectorTextBox(xoff, yoff*(i+1), text_aligment_str[i]); + else + DrawTextBox(xoff, yoff*(i+1), text_aligment_str[i]); } else { - DrawTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]); + if (use_vector) + DrawVectorTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]); + else + DrawTextBox(3*xoff, yoff*(i-5), text_aligment_str[i]); } } + cdFlush(); return 0; } @@ -952,13 +1047,10 @@ int SimpleDrawTextFonts(void) cdTextAlignment(CD_CENTER); -// DrawTextFont(CD_COURIER, size, xoff, yoff, "Courier"); - -// DrawTextFont(CD_TIMES_ROMAN, size, xoff, 2*yoff, "Times Roman"); - -// DrawTextFont(CD_HELVETICA, size, xoff, 3*yoff, "Helvetica"); - -// DrawTextFont(CD_SYSTEM, size, xoff, 4*yoff, "System"); + DrawTextFont(CD_COURIER, size, xoff, yoff, "Courier"); + DrawTextFont(CD_TIMES_ROMAN, size, xoff, 2*yoff, "Times Roman"); + DrawTextFont(CD_HELVETICA, size, xoff, 3*yoff, "Helvetica"); + DrawTextFont(CD_SYSTEM, size, xoff, 4*yoff, "System"); { // static char native[50] = "Tecmedia, -60"; @@ -977,10 +1069,10 @@ int SimpleDrawTextFonts(void) //cdNativeFont("Tecmedia, 36"); - cdSetAttribute("ADDFONTMAP", "WingDings=WingDing"); - cdNativeFont("WingDings, 36"); + //cdSetAttribute("ADDFONTMAP", "WingDings=WingDing"); + //cdNativeFont("WingDings, 36"); - cdText(500, 50, "X"); + //cdText(500, 50, "X"); //cdText(500, 50, "abcdefghijklmnopqrstuvwxyz"); //cdText(500, 150, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); //cdText(500, 250, "1234567890"); @@ -996,8 +1088,8 @@ int SimpleDrawTextFonts(void) return 0; } -void SimpleDrawTest(void) -//void SimpleDrawMainTest(void) +//void SimpleDrawTest(void) +void SimpleDrawMainTest(void) { long pattern[16]; /* 4x4 pattern */ int w, h; @@ -1074,31 +1166,49 @@ void SimpleDrawTest(void) void draw_wd(void) { + char* text; + double x, y; + double rect[8]; + cdBackground(CD_WHITE); cdClear(); cdLineStyle(CD_CONTINUOUS); cdLineWidth(1); - wdVectorTextDirection(0, 0, 1, 1); +// wdVectorTextDirection(0, 0, 1, 1); + cdTextAlignment(CD_NORTH_WEST); + +// text = "Vector Text"; + text = "Vector Text\nSecond Line\nThird Line"; + x = 0.25; + y = 0.40; + cdForeground(CD_BLACK); + wdLine(0, 0, 1, 1); + wdLine(0, 1, 1, 0); + + cdForeground(CD_GREEN); + cdMarkType(CD_STAR); + wdMark(x, y); + + cdForeground(CD_BLUE); wdVectorCharSize(0.1); - wdVectorText(0.25, 0.35, "Vector Text"); + wdVectorText(x, y, text); + + cdForeground(CD_RED); + wdGetVectorTextBounds(text, x, y, rect); + cdBegin(CD_CLOSED_LINES); + wdVertex(rect[0], rect[1]); + wdVertex(rect[2], rect[3]); + wdVertex(rect[4], rect[5]); + wdVertex(rect[6], rect[7]); + cdEnd(); - { - double rect[8]; - cdForeground(CD_RED); - wdGetVectorTextBounds("Vector Text", 0.25, 0.35, rect); - cdBegin(CD_CLOSED_LINES); - wdVertex(rect[0], rect[1]); - wdVertex(rect[2], rect[3]); - wdVertex(rect[4], rect[5]); - wdVertex(rect[6], rect[7]); - cdEnd(); - } cdFlush(); } -void SimpleDrawTestHardCopy(void) +void SimpleDrawTest(void) +//void SimpleDrawTestHardCopy(void) { int w, h; cdGetCanvasSize(&w, &h, 0, 0); @@ -1113,10 +1223,11 @@ void SimpleDrawTestHardCopy(void) draw_wd(); - wdHardcopy(CD_CLIPBOARD, "800x600", cdActiveCanvas(), draw_wd ); - cdFlush(); + //wdHardcopy(CD_CLIPBOARD, "800x600", cdActiveCanvas(), draw_wd ); + //cdFlush(); } +//void SimpleDrawTest(void) void SimpleDrawTestImageRGB(void) { int size = 2048*2048; @@ -1139,7 +1250,7 @@ void SimpleDrawTestImageRGB(void) } //void SimpleDrawTest(void) -void SimpleDrawVectorText(void) +void SimpleDrawVectorFont(void) { simple_draw = DRAW_TEST; cdBackground(CD_WHITE); @@ -1149,7 +1260,7 @@ void SimpleDrawVectorText(void) // wdVectorText(0.1, 0.4, "ãõñç áéíóú àèìòù âêîôû äëïöü"); // wdVectorText(0.1, 0.2, "ÃÕÑÇ ÁÉÍÓÚ ÀÈÌÒÙ ÂÊÎÔÛ ÄËÏÖÜ "); - cdVectorFont("../../etc/vectorfont26.txt"); /* original Simplex II */ + cdVectorFont("../etc/vectorfont26.txt"); /* original Simplex II */ { int i; char t[2]; @@ -1198,115 +1309,3 @@ void SimpleDrawVectorText(void) } cdFlush(); } - -typedef struct _point -{ - double x, y; -} point; - -point* load_point_file(const char* file_name, int *count) -{ - float x, y; - point* point_list; - int max_count = 100, dummy; - FILE* file = fopen(file_name, "rb"); - if (!file) - return NULL; - - point_list = malloc(max_count*sizeof(point)); - - /* read header */ - fscanf(file, "##### %d\n", &dummy); - - *count = 0; - while (!feof(file)) - { - if (fscanf(file, "( %g | %g )\n", &x, &y) == 2) - { - if (*count == max_count) - { - max_count += 100; - point_list = realloc(point_list, max_count*sizeof(point)); - } - - point_list[*count].x = x; - point_list[*count].y = y; - - (*count)++; - } - } - - fclose(file); - - return point_list; -} - -point square[4] = { - {100,100}, - {200,100}, - {200,200}, - {100,200}, -}; - -point corner[6] = { - {100,100}, - {200,100}, - {200,200}, - {150,200}, - {150,300}, - {100,300}, -}; - -//void SimpleDrawTest(void) -void SimpleDrawPolygon(void) -{ - int count, i; - point* point_list; - char* file_name; - - simple_draw = DRAW_TEST; - cdBackground(CD_WHITE); - cdClear(); - cdLineStyle(CD_CONTINUOUS); - cdLineWidth(1); - cdInteriorStyle(CD_SOLID); - -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\continentes_geom_id_78_polygon_1_440x512.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\continentes_geom_id_78_polygon_1_558x650.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_2.txt"; - file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_6.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_15.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_34.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_37.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_53.txt"; -// file_name = "D:\\Downloads\\TesteCdCanvas\\example_data\\guanabara_oceano_obj_id_5_geom_id_11_polygon_ring_59.txt"; - -// point_list = square; -// count = 4; -// point_list = corner; -// count = 6; - - point_list = load_point_file(file_name, &count); - if (!point_list) - return; - - cdForeground(CD_BLACK); - cdBegin(CD_CLOSED_LINES); - for (i=0; i<count; i++) - { - cdVertex((int)point_list[i].x, (int)point_list[i].y); - } - cdEnd(); - - cdForeground(CD_RED); - cdBegin(CD_FILL); - for (i=0; i<count; i++) - { - cdVertex((int)point_list[i].x, (int)point_list[i].y); - } - cdEnd(); - - cdFlush(); - - free(point_list); -} diff --git a/test/simple/simple.sln b/test/simple/simple.sln deleted file mode 100644 index fc2222e..0000000 --- a/test/simple/simple.sln +++ /dev/null @@ -1,20 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simple", "simple.vcproj", "{82BC36B1-9F7A-41D4-A24F-DBE012378CE6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - EndGlobalSection - GlobalSection(ProjectDependencies) = postSolution - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug.ActiveCfg = Debug|Win32 - {82BC36B1-9F7A-41D4-A24F-DBE012378CE6}.Debug.Build.0 = Debug|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal |