#include #include #include "parse.h" #include "image.h" #include "animate.h" #include "text.h" void frame_parse_img(Frame *f, Tag *tag) { TagOpt *opt; char *name = NULL; int align = ALIGN_NONE; BlockFormatInfo *bfi = frame_get_blockformatinfo(f); BlockStyleInfo *bsi = frame_get_blockstyleinfo(f); if (bfi->paragraph) { if (bsi->text_align == ALIGN_NONE) { /* »ú²¼¤² */ bfi->cur_x += 20; } bfi->paragraph = 0; } for (opt = tag->opt; opt; opt=opt->next) { if (!opt->oi) continue; switch (opt->oi->id) { case OPT_alt: break; case OPT_width: break; case OPT_height: break; case OPT_border: break; case OPT_align: { OptInfo *i = GetOptInfo(opt->val); if (i) { switch (i->id) { case OPT_top: align = ALIGN_TOP; break; case OPT_middle: align = ALIGN_MIDDLE; break; case OPT_absmiddle: align = ALIGN_ABSMIDDLE; break; case OPT_bottom: align = ALIGN_BOTTOM; break; case OPT_left: align = ALIGN_LEFT; break; case OPT_right: align = ALIGN_RIGHT; break; default: break; } } } break; case OPT_src: name = opt->val; break; default: break; } } if (!tag->data) if (name != NULL) { FILE *fp; Animate *a; a = animate_new(); if ((fp = frame_file_open(f,name))) { if (anim_gif_read_stream(a, fp) == 0) { animate_attach_win(a, f->dpy, f->win); animate_realize(a); animate_go(a); tag->data = a; } else animate_delete(a); fclose(fp); } } if (tag->data) frame_add_image(f, tag->data, 0, 0, 0, align); } void frame_parse_basefont(Frame *f, Tag *tag) { int size = 0; TagOpt *opt = tag->opt; for(;opt;opt = opt->next) { if (!opt->oi) continue; if (opt->oi->id == OPT_size) size = atoi(opt->val); } if (size > 0 && size < 8) f->basefont = size; } void frame_parse_hr(Frame *f, Tag *tag) { TagOpt *opt; BlockFormatInfo *bfi = frame_get_blockformatinfo(f); BlockStyleInfo *bsi = frame_get_blockstyleinfo(f); int width = WIDTH; int size = 2; for (opt = tag->opt; opt; opt=opt->next) { if (!opt->oi) continue; switch (opt->oi->id) { case OPT_width: width = parse_size(opt->val, width); break; case OPT_size: size = atoi(opt->val); break; default: break; } } frame_add_hr(f, bsi->text_align, width, size); } void frame_parse_br(Frame *f, Tag *tag) { int mode = BR_NORMAL; TagOpt *opt = tag->opt; for(;opt;opt = opt->next) { if (!opt->oi) continue; if (opt->oi->id == OPT_clear) { OptInfo *i = GetOptInfo(opt->val); if (i) { switch (i->id) { case OPT_left: mode = BR_LEFT; break; case OPT_right: mode = BR_RIGHT; break; case OPT_all: mode = BR_ALL; break; case OPT_none: mode = BR_NORMAL; break; default: break; } } } } frame_add_lf(f, mode); }