00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <stdlib.h>
00013 #include <string.h>
00014
00015 #include "xytext.h"
00016 #include "xymath.h"
00017
00018 const char* xy_id_xytext_cpp="$Id: xytext.cpp,v 1.15 1999/12/09 21:47:46 rborges Exp $";
00019 const int XYText::_underline_gap = 2;
00020
00021 XYText::XYText (const char* text,
00022 XYCoordinate x,
00023 XYCoordinate y,
00024 long color,
00025 Typeface font,
00026 Style style,
00027 Alignment alignment,
00028 Orientation orientation,
00029 xybool underline,
00030 xybool visible)
00031 : XYObject(x, y, visible),
00032 _text(text ? strdup((char*)text) : (char*)NULL),
00033 _color(color),
00034 _font(font),
00035 _style(style),
00036 _alignment(alignment),
00037 _orientation(orientation),
00038 _underline(underline)
00039 {
00040 }
00041
00042 XYText::XYText (const char* text,
00043 XYCoordinate x,
00044 XYCoordinate y,
00045 xybool visible)
00046 : XYObject(x, y, visible),
00047 _text(text ? strdup((char*)text) : (char*)NULL),
00048 _color(XY_BLACK),
00049 _font(XYText::timesRoman),
00050 _style(XYText::plain),
00051 _alignment(XYText::center),
00052 _orientation(XYText::horizontal),
00053 _underline(xyfalse)
00054 {
00055 }
00056
00057 XYText::XYText (const char* text,
00058 long color,
00059 Typeface font,
00060 Style style,
00061 Alignment alignment,
00062 Orientation orientation,
00063 xybool underline,
00064 xybool visible)
00065 : XYObject(0, 0, visible),
00066 _text(text ? strdup((char*)text) : (char*)NULL),
00067 _color(color),
00068 _font(font),
00069 _style(style),
00070 _alignment(alignment),
00071 _orientation(orientation),
00072 _underline(underline)
00073 {
00074 }
00075
00076 XYText::XYText (long color,
00077 Typeface font,
00078 Style style,
00079 Alignment alignment,
00080 Orientation orientation,
00081 xybool underline,
00082 xybool visible)
00083 :
00084 XYObject(0.0, 0.0, visible),
00085 _text((char *)NULL),
00086 _color(color),
00087 _font(font),
00088 _style(style),
00089 _alignment(alignment),
00090 _orientation(orientation),
00091 _underline(underline)
00092 {
00093 }
00094
00095 XYText::~XYText (void)
00096 {
00097 if (_text) free (_text);
00098 }
00099
00100 void XYText::text (const char* s)
00101 {
00102 if (_text) free (_text);
00103 _text = s ? strdup((char*)s) : (char*)NULL;
00104 }
00105
00106 char* XYText::text (void) const
00107 {
00108 return _text;
00109 }
00110
00111 void XYText::color (long c)
00112 {
00113 _color = c;
00114 }
00115
00116 long XYText::color (void) const
00117 {
00118 return _color;
00119 }
00120
00121 void XYText::font (Typeface f)
00122 {
00123 _font = f;
00124 }
00125
00126 int XYText::font (void) const
00127 {
00128 return _font;
00129 }
00130
00131 void XYText::style (Style sl)
00132 {
00133 _style = sl;
00134 }
00135
00136 int XYText::style (void) const
00137 {
00138 return _style;
00139 }
00140
00141 void XYText::align (Alignment a)
00142 {
00143 _alignment = a;
00144 }
00145
00146 int XYText::align (void) const
00147 {
00148 return _alignment;
00149 }
00150
00151 void XYText::orientation (Orientation o)
00152 {
00153 _orientation = o;
00154 }
00155
00156 int XYText::orientation (void) const
00157 {
00158 return _orientation;
00159 }
00160
00161 void XYText::underline (xybool u)
00162 {
00163 _underline = u;
00164 }
00165
00166 xybool XYText::underline (void) const
00167 {
00168 return _underline;
00169 }
00170
00171 void XYText::operator= (const XYText &t)
00172 {
00173 if (_text != NULL)
00174 free (_text);
00175
00176 memcpy (this, &t, sizeof(this));
00177 _text = t._text ? strdup((char*)t._text) : (char*)NULL;
00178 }
00179
00180 xybool XYText::pick (int px, int py)
00181 {
00182 if (visible() == xyfalse)
00183 return xyfalse;
00184
00185
00186 int x1, y1, x2, y2;
00187 boundingBox (x1, y1, x2, y2);
00188
00189 return mtPointInRect (px, py, x1, y1, x2, y2);
00190 }
00191
00192 xybool XYText::fence (int x2, int y2, int x3, int y3)
00193 {
00194 if (visible() == xyfalse)
00195 return xyfalse;
00196
00197
00198 int x0, y0, x1, y1;
00199 boundingBox (x0, y0, x1, y1);
00200
00201 return mtInclude (x0, y0, x1, y1, x2, y2, x3, y3);
00202 }
00203
00204
00205 void XYText::insertAction (XYGraph* )
00206 {
00207 }
00208
00209
00210 void XYText::removeAction (XYGraph* )
00211 {
00212 }