예제 #1
0
파일: extent1.c 프로젝트: billpage/fricas
static void
compute_rm_extent(TextNode *node)
{
    if (gInLine && node->space)
        text_x += inter_word_space;
    node->x = text_x;
    node->y = text_y;
    rm_top_group();
}
예제 #2
0
파일: extent1.c 프로젝트: billpage/fricas
static void
compute_em_extent(TextNode *node)
{
    if (gInLine && node->space)
        text_x += inter_word_space;
    node->x = text_x;
    node->y = text_y;
    if (gTopOfGroupStack->cur_font == gEmFont)
        rm_top_group();
    else
        em_top_group();
}
예제 #3
0
int
max_x(TextNode * node, int Ender)
{
    max_x_value = 0;
    for (; node != NULL; node = node->next) {
        if (Ender == Endtokens) {
            if (node->type >= Endtokens)
                return max_x_value;
        }
        else if (node->type == Ender)
            return max_x_value;
        switch (node->type) {
          case Lsquarebrace:
          case Rsquarebrace:
          case Word:
            max_x_value = max(max_x_value, node->x + word_width(node));
            break;
          case Verbatim:
          case Spadsrctxt:
            max_x_value = max(max_x_value, node->x + verbatim_width(node));
            break;
          case Punctuation:
            max_x_value = max(max_x_value, node->x + punctuation_width(node));
            break;
          case Dash:
            max_x_value = max(max_x_value, node->x + width_of_dash(node));
            break;
          case HSpace:
            max_x_value = max(max_x_value, node->x +
                              (node->data.node != NULL ? atoi(node->data.node->data.text) : 1));
            break;
          case Space:
            max_x_value = max(max_x_value, node->x +
                           (gTopOfGroupStack->cur_font->max_bounds.width) *
                              (node->data.node != NULL ? atoi(node->data.node->data.text) : 1));
            break;
          case Group:
            push_group_stack();
            break;
          case BoldFace:
            bf_top_group();
            break;
          case Emphasize:
            if (gTopOfGroupStack->cur_font == gRmFont)
                em_top_group();
            else
                rm_top_group();
            break;
          case It:
            em_top_group();
            break;
          case Rm:
          case Sl:
          case Tt:
            rm_top_group();
            break;
          case Endgroup:
            pop_group_stack();
            break;
          case Controlbitmap:
          case Inputbitmap:
            if (node->width == -1)
                insert_bitmap_file(node);
            max_x_value = max(max_x_value, node->x + node->width);
            break;
          case Inputpixmap:
            if (node->width == -1)
                insert_pixmap_file(node);
            max_x_value = max(max_x_value, node->y + node->width);
            break;
          default:
            break;
        }
    }
    return cur_height;
}
예제 #4
0
int
text_width(TextNode * node, int Ender)
{
    int twidth = 0, num_words;

    for (num_words = 0; node != NULL; num_words++, node = node->next) {
        if (Ender == Endtokens) {
            if (node->type == Endtokens)
                return twidth;
        }
        else if (node->type == Ender)
            return twidth;

        switch (node->type) {
          case Macro:
          case Pound:
            if (node->space && gInLine)
                twidth += inter_word_space;
            break;
          case Punctuation:
            twidth += punctuation_width(node);
            break;
          case Dash:
            if (gInLine && node->space)
                twidth += inter_word_space;
            twidth += width_of_dash(node);
            break;
          case Verbatim:
          case Spadsrctxt:
            twidth += verbatim_width(node);
            break;
          case Lsquarebrace:
          case Rsquarebrace:
          case Word:
            twidth += word_width(node);
            break;
          case Box:
            twidth += 2 * box_space;
            break;
          case Link:
          case Downlink:
          case Memolink:
          case Windowlink:
          case LispMemoLink:
          case Lispwindowlink:
          case Lisplink:
          case Unixlink:
          case Spadcall:
          case Spadcallquit:
          case Qspadcall:
          case Qspadcallquit:
          case LispDownLink:
          case Lispcommand:
          case Lispcommandquit:
          case Spadlink:
          case Spaddownlink:
          case Spadmemolink:
          case Unixcommand:
          case Upbutton:
          case Returnbutton:
          case Description:
            push_active_group();
            break;
          case Endbutton:
          case Endspadcommand:
          case Enddescription:
            pop_group_stack();
            break;
          case Endlink:
            pop_group_stack();
            break;
          case Inputstring:
            twidth += input_string_width(node);
            break;
          case SimpleBox:
          case Radiobox:
            twidth += node->width + ((node->space) ? inter_word_space : 0);
            break;
          case Spadcommand:
          case Spadgraph:
            push_spad_group();
            break;
          case VSpace:
            break;
          case HSpace:
            twidth +=
                (node->data.node != NULL ? atoi(node->data.node->data.text) : 1);
            break;
          case Space:
            twidth += (gTopOfGroupStack->cur_font->max_bounds.width) *
                (node->data.node != NULL ? atoi(node->data.node->data.text) : 1);
            break;
          case Tab:
            twidth = (gTopOfGroupStack->cur_font->max_bounds.width) *
                (node->data.node != NULL ? atoi(node->data.node->data.text) : 1);
            break;
          case Table:
            twidth = gWindow->width - left_margin - right_margin_space;
            break;
          case Tableitem:
          case Group:
            twidth += (node->space) ? inter_word_space : 0;
            push_group_stack();
            break;
          case BoldFace:
            if (node->space)
                twidth += inter_word_space;
            bf_top_group();
            break;
          case Emphasize:
            if (node->space)
                twidth += inter_word_space;
            if (gTopOfGroupStack->cur_font == gRmFont)
                em_top_group();
            else
                rm_top_group();
            break;
          case It:
            if (node->space)
                twidth += inter_word_space;
            em_top_group();
            break;
          case Rm:
          case Sl:
          case Tt:
            if (node->space)
                twidth += inter_word_space;
            rm_top_group();
            break;
          case Endgroup:
            pop_group_stack();
            break;
          case Controlbitmap:
          case Inputbitmap:
            if (node->width == -1)
                insert_bitmap_file(node);
            twidth += node->width;
            break;
          case Inputpixmap:
            if (node->width == -1)
                insert_pixmap_file(node);
            twidth += node->width;
            break;
          case Mbox:
          case Indent:
          case Endmacro:
          case Free:
          case Bound:
          case Beep:
          case Item:
          case Titem:
          case Beginitems:
          case Noop:
          case Endinputbox:
          case Fi:
          case Ifcond:
          case Endif:
          case Begintitems:
          case Enditems:
          case Endtitems:
          case Endtableitem:
          case Endtable:
          case Endparameter:
          case Endbox:
          case Endheader:
          case Endfooter:
          case Endscrolling:
          case Endverbatim:
          case Endspadsrc:
            break;
          case Newline:
            /* WOw, I guess I should ertunr a really big number */
            twidth += gWindow->width;
            break;
          default:

            /*
             * fprintf(stderr, "Unknown nodetype %d in text_width\n",
             * node->type);
             */
            break;
        }
    }
    return twidth;
}
예제 #5
0
void
show_text(TextNode *node, int Ender)
{
    /*int twidth, len;*/
    /*int otext_x, otext_y, t;*/
    /*XFontStruct *old_font;*/
    /*int old_color;*/

    for (; node != NULL; node = node->next) {
        switch (node->type) {
        case 0:
        case Beginitems:
        case Begintitems:
        case Bound:
        case Center:
        case Free:
        case HSpace:
        case Indent:
        case Indentrel:
        case Item:
        case Macro:
        case Mbox:
        case Newline:
        case Noop:
        case Par:
        case Pound:
        case Rbrace:
        case Space:
        case Tab:
        case Table:
        case Titem:
        case VSpace:
            break;

        case Dash:
        case Fi:
        case Ifcond:
            if (visible(node->y, node->height)) {
                if (strlen(node->data.text) > 1) {
                    XDrawLine(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC, node->x,
                              node->y + gRegionOffset + y_off
                              - gTopOfGroupStack->cur_font->descent -
                              word_off_height,
                              node->x + node->width,
                              node->y + gRegionOffset + y_off - word_off_height -
                              gTopOfGroupStack->cur_font->descent);
                }
                else {
                    XDrawString(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC, node->x, node->y +
                                gRegionOffset - gTopOfGroupStack->cur_font->descent + y_off,
                                node->data.text, 1);
                }
            }
            else {
                if (above(node->y))
                    need_scroll_up_button = 1;
                else if (below(node->y))
                    need_scroll_down_button = 1;
            }
            break;

        case Lsquarebrace:
        case Math:
        case Punctuation:
        case Rsquarebrace:
        case Spadsrctxt:
        case WindowId:
        case Word:
            if (visible(node->y, node->height))
                XDrawString(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC, node->x, node->y +
                            gRegionOffset - gTopOfGroupStack->cur_font->descent + y_off,
                            node->data.text, node->width);
            else {
                if (above(node->y))
                    need_scroll_up_button = 1;
                else if (below(node->y))
                    need_scroll_down_button = 1;
            }
            break;

        case Verbatim:
            push_group_stack();
            tt_top_group();
            if (visible(node->y, node->height))
                XDrawString(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC, node->x, node->y +
                            gRegionOffset - gTopOfGroupStack->cur_font->descent + y_off,
                            node->data.text, node->width);
            else {
                if (above(node->y))
                    need_scroll_up_button = 1;
                else if (below(node->y))
                    need_scroll_down_button = 1;
            }
            pop_group_stack();
            break;

        case Horizontalline:
            if (visible(node->y, node->height)) {
                line_top_group();
                XDrawLine(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC, 0,
                          node->y + gRegionOffset + y_off,
                          gWindow->width,
                          node->y + gRegionOffset + y_off);
                pop_group_stack();
            }
            else {
                if (above(node->y))
                    need_scroll_up_button = 1;
                else if (below(node->y))
                    need_scroll_down_button = 1;
            }
            break;

        case Box:
            if (visible(node->y, node->height))
                XDrawRectangle(gXDisplay, gWindow->fDisplayedWindow, gWindow->fStandardGC,
                               node->x,
                               node->y + gRegionOffset + y_off - node->height,
                               node->width,
                               node->height);
            else {
                if (above(node->y))
                    need_scroll_up_button = 1;
                else if (below(node->y))
                    need_scroll_down_button = 1;
            }
            break;


        case Downlink:
        case Link:
        case LispDownLink:
        case LispMemoLink:
        case Lispcommand:
        case Lispcommandquit:
        case Lisplink:
        case Lispwindowlink:
        case Memolink:
        case Qspadcall:
        case Qspadcallquit:
        case Returnbutton:
        case Spadcall:
        case Spadcallquit:
        case Spaddownlink:
        case Spadlink:
        case Spadmemolink:
        case Unixcommand:
        case Unixlink:
        case Upbutton:
        case Windowlink:
            if (pix_visible(node->y, node->height))
                show_link(node);
            break;

        case Spadcommand:
        case Spadgraph:
        case Spadsrc:
            show_spadcommand(node);
            break;

        case Pastebutton:
            if (visible(node->y, node->height))
                show_pastebutton(node);
            break;

        case Paste:
            show_paste(node);
            break;

        case Group:
        case Tableitem:
            push_group_stack();
            break;

        case Controlbitmap:
            show_image(node, gWindow->fControlGC);
            break;

        case Inputbitmap:
            show_image(node, gWindow->fStandardGC);
            break;

        case Inputpixmap:
            show_image(node, gWindow->fStandardGC);
            break;

        case BoldFace:
            bf_top_group();
            break;

        case Emphasize:
            if (gTopOfGroupStack->cur_font == gRmFont)
                em_top_group();
            else
                rm_top_group();
            break;

        case It:
            em_top_group();
            break;

        case Sl:
        case Rm:
            rm_top_group();
            break;

        case Tt:
            tt_top_group();
            break;

        case Inputstring:
            show_input(node);
            break;

        case Radiobox:
        case SimpleBox:
            show_simple_box(node);
            break;

        case Beep:
            LoudBeepAtTheUser();
            break;

        case Description:
            bf_top_group();
            break;

        case Endspadsrc:
        case Endspadcommand:
            gInAxiomCommand = 1;
        case Endtableitem:
        case Enddescription:
        case Endpastebutton:
        case Endlink:
        case Endbutton:
        case Endgroup:
            pop_group_stack();
        case Endverbatim:
        case Endmath:
        case Endbox:
        case Endtable:
        case Endmbox:
        case Endparameter:
        case Endpaste:
        case Endinputbox:
        case Endcenter:
        case Endmacro:
        case Endif:
        case Endtitems:
        case Enditems:

            /*
             * Now since I can show specific regions of the text, then at
             * this point I should check to see if I am the end
             */
            if (node->type == Ender)
                return;
            break;
        case Endfooter:
        case Endscrolling:
        case Endheader:
        case Endtitle:

            /*
             * regardless of what ender I have, I always terminate showing
             * with one of these
             */
            return;
        default:
            fprintf(stderr, "Show_text: Unknown Node Type %d\n", node->type);
            break;
        }
    }
}
예제 #6
0
static void
show_link(TextNode *node)
{
    /* XFontStruct *old_font;*/
    XWindowChanges wc;
    /*int twidth, boxwidth, old_color;*/
    int active;

    switch (node->type) {
    case Upbutton:
        if (!need_up_button) {
            XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x,
                       node->y - node->height + gRegionOffset,
                       node->width, node->height, 0);
            active = 0;
        }
        else
            active = 1;
        break;
    case Returnbutton:
        if (!need_return_button) {
            XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x,
                       node->y - node->height + gRegionOffset,
                       node->width, node->height, 0);
            active = 0;
        }
        else
            active = 1;
        break;
    case Helpbutton:
        if (!need_help_button) {
            XClearArea(gXDisplay, gWindow->fDisplayedWindow, node->x,
                       node->y - node->height + gRegionOffset,
                       node->width, node->height, 0);
            active = 0;
        }
        else
            active = 1;
        break;
    default:
        active = 1;
        break;
    }

    if (active) {
        ButtonList *bl = alloc_button_list();

        push_active_group();
        wc.x = node->x;
        wc.y = node->y - node->height + y_off + gRegionOffset;
        wc.height = node->height;
        wc.width = node->width - trailing_space(node->next);
        bl->x0 = wc.x;
        bl->y0 = wc.y;
        bl->x1 = bl->x0 + wc.width;
        bl->y1 = bl->y0 + wc.height;
        bl->link = node->link;
        if (!not_in_scroll) {
            bl->y0 += gWindow->page->top_scroll_margin + scroll_top_margin;
            bl->y1 += gWindow->page->top_scroll_margin + scroll_top_margin;
            bl->next = gWindow->page->s_button_list;
            gWindow->page->s_button_list = bl;
        }
        else {
            bl->next = gWindow->page->button_list;
            gWindow->page->button_list = bl;
        }
    }
    else
        rm_top_group();
}