static void compute_pastebutton_extent(TextNode *node) { int twidth; push_active_group(); /* First see if we should leave a little space in front of myself * */ if (gInLine && node->space) text_x += inter_word_space; twidth = text_width(node->next, Endpastebutton); if (gInLine && node->space) text_x += inter_word_space; if (text_x + twidth > right_margin && gInLine) { start_newline(present_line_height, node); text_x = indent; } node->x = text_x; node->y = text_y; paste_node = node; return; }
static void show_pastebutton(TextNode *node) { /*XFontStruct *old_font;*/ XWindowChanges wc; /*int twidth, boxwidth, old_color;*/ /*int active;*/ 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); #ifdef DEBUG fprintf(stderr, "Configure in show_link %d %d %d %d\n", wc.x, wc.y, wc.width, wc.height); #endif XConfigureWindow(gXDisplay, node->link->win, CWX | CWY | CWHeight | CWWidth, &wc); XMapWindow(gXDisplay, node->link->win); }
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; }
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(); }
void showTitleBar(void) { XWindowChanges wc; int height, hbw = (int) gWindow->border_width / 2; XImage *image; /* * the first thing we do is pop up all the windows and * place them properly */ if (gWindow->page->title->height != twheight) height = gWindow->page->title->height; else height = twheight; push_active_group(); /* configure and map button number 1 */ wc.x = 0; wc.y = 0; wc.height = twheight; wc.width = twwidth; XConfigureWindow(gXDisplay, gWindow->fTitleBarButton1, CWX | CWY | CWHeight | CWWidth, &wc); XMapWindow(gXDisplay, gWindow->fTitleBarButton1); image = tw1image; XPutImage(gXDisplay, gWindow->fTitleBarButton1, gWindow->BUTTGC, image, 0, 0, 0, 0, image->width, image->height); /* configure and map button number 2 */ wc.x += twwidth + gWindow->border_width; XConfigureWindow(gXDisplay, gWindow->fTitleBarButton2, CWX | CWY | CWHeight | CWWidth, &wc); XMapWindow(gXDisplay, gWindow->fTitleBarButton2); image = need_help_button ? tw2image : noopimage; XPutImage(gXDisplay, gWindow->fTitleBarButton2, gWindow->BUTTGC, image, 0, 0, 0, 0, image->width, image->height); /* configure and map button number 4 */ wc.x = gWindow->width - twwidth; XConfigureWindow(gXDisplay, gWindow->fTitleBarButton4, CWX | CWY | CWHeight | CWWidth, &wc); XMapWindow(gXDisplay, gWindow->fTitleBarButton4); image = need_up_button ? tw4image : noopimage; XPutImage(gXDisplay, gWindow->fTitleBarButton4, gWindow->BUTTGC, image, 0, 0, 0, 0, image->width, image->height); /* configure and map button number 3 */ wc.x = wc.x - twwidth - gWindow->border_width; XConfigureWindow(gXDisplay, gWindow->fTitleBarButton3, CWX | CWY | CWHeight | CWWidth, &wc); XMapWindow(gXDisplay, gWindow->fTitleBarButton3); image = need_return_button ? tw3image : noopimage; XPutImage(gXDisplay, gWindow->fTitleBarButton3, gWindow->BUTTGC, image, 0, 0, 0, 0, image->width, image->height); gWindow->fDisplayedWindow = gWindow->fMainWindow; gDisplayRegion = Title; gRegionOffset = 0; y_off = 0; pop_group_stack(); show_text(gWindow->page->title->next, Endheader); /* Now draw the box around the title */ line_top_group(); #if BITMAPS2D XDrawRectangle(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, gWindow->page->title->x, -hbw, wc.x - gWindow->page->title->x - hbw, height + 2 * hbw); #endif XDrawLine(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, 0, height + hbw, gWindow->width, height + hbw); #if BITMAPS2D /* Now draw the lines down the middle */ XDrawLine(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, twwidth + hbw, 0, twwidth + hbw, height); XDrawLine(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, gWindow->width - twwidth - hbw, 0, gWindow->width - twwidth - hbw, height); #endif pop_group_stack(); #if BITMAPS2D /* now fill the areas under the bitmaps if we have to */ if (gWindow->page->title->height > twheight) { push_active_group(); height = height - twheight; XFillRectangle(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, 0, twheight, twwidth, height); XFillRectangle(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, twwidth + gWindow->border_width, twheight, twwidth, height); XFillRectangle(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, gWindow->width - 2 * twwidth - gWindow->border_width, twheight, twwidth, height); XFillRectangle(gXDisplay, gWindow->fMainWindow, gWindow->fStandardGC, gWindow->width - twwidth, twheight, twwidth, height); pop_group_stack(); } #endif }