19 double scaled = double(unscaled)*scaleFactor;
24 if (value<min) min = value;
25 if (value>max) max = value;
37 p = strtok(buffer, delim);
39 if (!p) failed =
true;
44 Xfig_Eater(
char *buffer_,
const char *delim_) : buffer(buffer_), delim(delim_) {
51 if (failed)
return false;
59 if (failed)
return false;
65 if (failed || !p)
return NULp;
70 void AW_xfig::calc_scaling(
int font_width,
int font_height) {
74 font_scale = font_x_scale>font_y_scale ? font_x_scale : font_y_scale;
80 init(font_width, font_height);
92 init(font_width, font_height);
101 if (filename[0]==
'/') {
102 strcpy(buffer, filename);
103 file = fopen(buffer,
"r");
108 strcpy(buffer, fileInLib);
109 file = fopen(fileInLib,
"r");
118 char *expanded_filename = strdup(buffer);
122 if (!ret || strncmp(
"#FIG", ret, 4)) {
123 error =
"Expected XFIG format";
132 } version = XFIG_UNKNOWN;
134 char *xfig_version = strchr(ret,
' ');
137 error =
"Missing version info";
143 mainVersion = atoi(xfig_version);
145 char *vers_point = strchr(xfig_version,
'.');
148 subVersion = atoi(vers_point);
154 if (mainVersion>3 || (mainVersion==3 && subVersion>2)) {
155 version = XFIG_UNSUPPORTED;
156 error =
"Xfig-format above 3.2 not supported";
159 if (mainVersion==3 && subVersion==2) {
160 version = XFIG_NEW_FORMAT;
163 version = XFIG_OLD_FORMAT;
169 if (!ret) error =
"Unexpected end of file";
178 if (version==XFIG_NEW_FORMAT) {
200 const char *awaited =
NULp;
202 case 0: awaited =
"Landscape";
break;
203 case 1: awaited =
"Center";
break;
204 case 2: awaited =
"Metric";
break;
205 case 3: awaited =
"A4";
break;
206 case 4: awaited =
"";
break;
207 case 5: awaited =
"Single";
break;
208 case 6: awaited =
"-2";
break;
212 if (strncmp(ret, awaited, strlen(awaited))!=0) {
222 int default_dpi = 80;
224 char *p = strtok(ret,
"\t");
225 if (p) dpi = atoi(p);
233 bool got_nextline =
false;
240 int oldx = 0, oldy = 0;
263 oldx = oldy = INT_MAX;
270 if (version==XFIG_OLD_FORMAT && x==9999 && y==9999)
break;
280 if (oldx == INT_MAX && oldy == INT_MAX) {
301 else if (ret[0]==
'4') {
317 if (version==XFIG_OLD_FORMAT) {
350 while (*p==
' ' || *p==
'\t') ++p;
352 char *endf = strchr(p, 1);
356 if (endf2) *endf2 = 0;
361 if (strcmp(p,
"$$") == 0) {
385 xtext->
text = strdup(p);
389 xtext->
font = fontnr;
409 error =
GBS_global_string(
"While reading %s:%i:\nError: %s", expanded_filename, lineNumber, error);
412 free(expanded_filename);
419 error =
GBS_global_string(
"Failed to read XFIG resource (defect installation?)\n"
420 "Reason: %s", error);
422 if (font_width>0 && font_height>0) {
465 for (xtext =
text; xtext; xtext=xtext->
next) {
475 y += (window_size.
b - window_size.
t)-
size_y;
478 else if (str[0] ==
'X') {
479 x += (window_size.
r - window_size.
l)-
size_x;
483 else if (str[2] ==
':' && str[0] ==
'X' && str[1] ==
'Y') {
484 x += (window_size.
r - window_size.
l)-
size_x;
485 y += (window_size.
b - window_size.
t)-
size_y;
498 for (xline =
line[i]; xline; xline=xline->
next) {
507 char fontstring[100];
517 for (xtext =
text; xtext; xtext=xtext->
next) {
virtual void clear(AW_bitset filteri)
const int MAX_XFIG_LENGTH
const AW_screen_area & get_area_size() const
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
void set_line_attributes(int gc, short width, AW_linestyle style)
void set_function(int gc, AW_function function)
struct AW_xfig_line * line[MAX_LINE_WIDTH]
const char * GBS_global_string(const char *templat,...)
AW_xfig(const char *filename, int font_width, int font_height)
void GBS_free_hash(GB_HASH *hs)
char buffer[MESSAGE_BUFFERSIZE]
GB_CSTR GBS_find_string(GB_CSTR cont, GB_CSTR substr, int match_mode)
bool ignore(unsigned count=1)
void set_font(int gc, AW_font fontnr, int size, int *found_size)
void set_foreground_color(int gc, AW_color_idx color)
void GBK_terminate(const char *error) __ATTR__NORETURN
bool line(int gc, const AW::LineVector &Line, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
static void error(const char *msg)
struct AW_xfig_line * next
struct AW_xfig_text * text
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
const int XFIG_DEFAULT_FONT_WIDTH
void create_gcs(AW_device *device, int screen_depth)
int scaleAndRound(int unscaled, double scaleFactor)
void setMinMax(int value, int &min, int &max)
GB_CSTR GB_concat_path_in_ARBLIB(const char *relative_path_left, const char *anypath_right)
const AW_bitset AW_ALL_DEVICES_UNSCALED
void aw_message(const char *msg)
Xfig_Eater(char *buffer_, const char *delim_)
void add_line(int x1, int y1, int x2, int y2, int width)
void print(AW_device *device)
static long aw_xfig_hash_free_loop(const char *, long val, void *)
bool text(int gc, const SizedCstr &cstr, const AW::Position &pos, AW_pos alignment=0.0, AW_bitset filteri=AW_ALL_DEVICES_UNSCALED)
long GBS_read_hash(const GB_HASH *hs, const char *key)
struct AW_xfig_text * next
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
const int XFIG_DEFAULT_FONT_HEIGHT