⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xdisplay.c

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/**********Copyright 1990 Regents of the University of California.  All rights reserved.Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group **********/#include "spice.h"#include "cpstd.h"#include "hlpdefs.h"#include "suffix.h"#ifdef HAS_X10extern Display *X_display;  /* so we can switch back, ick, ick, ick J.H. */#endifchar *hlp_boldfontname = BOLD_FONT;char *hlp_regfontname = REG_FONT;char *hlp_italicfontname = ITALIC_FONT;char *hlp_titlefontname = TITLE_FONT;char *hlp_buttonfontname = BUTTON_FONT;char *hlp_displayname = NULL;int hlp_initxpos = START_XPOS;int hlp_initypos = START_YPOS;int hlp_buttonstyle = BS_LEFT;#ifdef HAS_X10static topic *topics = NULL;static Display *xdisplay = NULL;static Cursor cursor, waitcur;static FontInfo *regfont, *boldfont, *italicfont, *titlefont, *buttonfont;static Color fore, back, border;static int lineheight;#define SUB_TOPICS  "Sub-Topics:"#define SEE_ALSO    "See Also:"#include "help.cur"#include "helpmask.cur"#include "wait.cur"#include "waitmask.cur"static void drawtext(), puttitle();static void redraw();static void drawbutton(), calcpos();static button *findbutton();/* Create a new window... */boolhlp_xdisplay(top)    topic *top;{    int width, yoff, y;    toplink *tl;    if (!xdisplay) {        /* Gotta init everything. */        if (!(xdisplay = XOpenDisplay(hlp_displayname))) {            fprintf(stderr, "Error: can't open display\n");            return (false);        }        if (!(cursor = XCreateCursor(help_width, help_height,                help_bits, helpmask_bits, help_x_hot,                help_y_hot, BlackPixel, WhitePixel, GXcopy))) {            fprintf(stderr, "Error: can't create cursor\n");            return (false);        }        if (!(waitcur = XCreateCursor(wait_width, wait_height,                wait_bits, waitmask_bits, wait_x_hot,                 wait_y_hot, BlackPixel, WhitePixel, GXcopy))) {            fprintf(stderr, "Error: can't create cursor\n");            return (false);        }        if (!(regfont = XOpenFont(hlp_regfontname))) {            fprintf(stderr, "Note: can't open font %s\n",                    hlp_regfontname);	    if (!(regfont = XOpenFont("fixed"))) {		fprintf(stderr, "Error: can't open font \"fixed\"\n");		return (false);	    }        }        if (!(boldfont = XOpenFont(hlp_boldfontname))) {            fprintf(stderr, "Note: can't open font %s\n",                    hlp_boldfontname);	    boldfont = regfont;        }        if (!(italicfont = XOpenFont(hlp_italicfontname))) {            fprintf(stderr, "Note: can't open font %s\n",                    hlp_italicfontname);	    italicfont = boldfont;        }        if (!(titlefont = XOpenFont(hlp_titlefontname))) {            fprintf(stderr, "Note: can't open font %s\n",                    hlp_titlefontname);	    titlefont = boldfont;        }        if (!(buttonfont = XOpenFont(hlp_buttonfontname))) {            fprintf(stderr, "Note: can't open font %s\n",                    hlp_buttonfontname);	    buttonfont = boldfont;        }        fore.pixel = BlackPixel;        back.pixel = WhitePixel;        border.pixel = BlackPixel;        lineheight = (regfont->height > boldfont->height) ?                regfont->height : boldfont->height;        lineheight = (lineheight > italicfont->height) ? lineheight :                italicfont->height;    }    XSetDisplay(xdisplay);    if (!top->parent) {        top->xposition = hlp_initxpos;        top->yposition = hlp_initypos;    } else {        top->xposition = top->parent->xposition + X_INCR;        top->yposition = top->parent->yposition + Y_INCR;    }    top->lines = (top->numlines < MAX_LINES) ? top->numlines : MAX_LINES;    top->cols = (top->maxcols < MAX_COLS) ? top->maxcols : MAX_COLS;    width = (regfont->width + boldfont->width + italicfont->width) / 3;    top->xpix = ((top->cols > MIN_COLS) ? top->cols : MIN_COLS) * width +            2 * INT_BORDER;    top->ypix = top->lines * lineheight + 2 * INT_BORDER +            titlefont->height;    /* Better figure out the positions of the buttons... */    for (tl = top->seealso; tl; tl = tl->next) {        tl->button.text = tl->description;        tl->button.tag = tl->place;        if (!tl->button.text)            tl->button.text = "<unknown>";    }    for (tl = top->subtopics; tl; tl = tl->next) {        tl->button.text = tl->description;        tl->button.tag = tl->place;        if (!tl->button.text)            tl->button.text = "<unknown>";    }    calcpos(top->subtopics, top->xpix);    calcpos(top->seealso, top->xpix);    yoff = top->ypix - INT_BORDER;    if (top->subtopics) {        yoff += titlefont->height * 2;        top->sublabypos = yoff - titlefont->height * 3 / 2;        y = yoff;        for (tl = top->subtopics; tl; tl = tl->next) {            tl->button.y += y;            if (yoff < tl->button.y + tl->button.height)                yoff = tl->button.y + tl->button.height;        }    }    if (top->seealso) {        top->salabypos = yoff + titlefont->height / 2;        yoff += titlefont->height * 2;         y = yoff;        for (tl = top->seealso; tl; tl = tl->next) {            tl->button.y += y;            if (yoff < tl->button.y + tl->button.height)                yoff = tl->button.y + tl->button.height;        }    }    top->ypix = yoff + INT_BORDER;    top->but_quit.text = "Quit Help";    top->but_quit.x = top->xpix - INT_BORDER -            XStringWidth(top->but_quit.text, buttonfont, 0, 0);    top->but_quit.y = -1;    top->but_delete.text = "Delete Window";    top->but_delete.x = top->but_quit.x - XStringWidth(top->but_delete.            text, buttonfont, 0, 0) - INT_BORDER;    top->but_delete.y = -1;                top->but_prev.text = "Prev Page";    top->but_prev.x = top->but_delete.x - XStringWidth(top->but_prev.            text, buttonfont, 0, 0) - INT_BORDER;    top->but_prev.y = -1;                top->but_next.text = "Next Page";    top->but_next.x = top->but_prev.x - XStringWidth(top->but_next.            text, buttonfont, 0, 0) - INT_BORDER;    top->but_next.y = -1;                if (!(top->win = XCreateWindow(RootWindow, top->xposition,            top->yposition, top->xpix, top->ypix, BORDER_WIDTH,            BlackPixmap, WhitePixmap))) {        fprintf(stderr, "Error: can't create window\n");        return (false);    }    XDefineCursor(top->win, cursor);    XStoreName(top->win, top->title);    XMapWindow(top->win);    redraw(top, 0, 0, top->xpix, top->ypix);    XSelectInput(top->win, ButtonPressed  | ExposeRegion | ExposeWindow);    top->winlink = topics;    topics = top;    return (true);}/* need to switch back old display pointer J.H. */voidhlp_xclosedisplay(){    XCloseDisplay(xdisplay);    xdisplay = NULL;    XSetDisplay(X_display);}/* Deal with the windows on the screen...  Strange things may happen if there * is also a plot window... */toplink *hlp_xhandle(parent)    topic **parent;{    XEvent event;    XKeyOrButtonEvent *ev = (XKeyOrButtonEvent *) &event;    XExposeEvent *xev = (XExposeEvent *) &event;    topic *top;    button *but;    toplink *tl;    if (!topics) {        *parent = NULL;        return (NULL);    }    for (;;) {        XSetDisplay(xdisplay);        XNextEvent(&event);        for (top = topics; top; top = top->winlink)            if (top->win == event.window)                break;        if (!top) {            /* Probably it's one we just destroyed. */            continue;        }        *parent = top;        switch (event.type) {            case 0:            break;                    case ExposeRegion:            case ExposeWindow:            redraw(top, xev->x, xev->y, xev->width, xev->height);            break;            case ButtonPressed:            if ((but = findbutton(top, ev->x, ev->y))) {                if (but == &top->but_quit) {                    *parent = NULL;                     return (NULL);                 } else if (but == &top->but_delete) {                    return (NULL);                } else if (but == &top->but_next) {                    if (top->curtopline + MAX_LINES >=                            top->numlines) {                        XFeep(0);                        break;                    }                    top->curtopline += SCROLL_INCR;                    XClear(top->win);                    redraw(top, 0, 0, top->xpix,                            top->ypix);                    break;                } else if (but == &top->but_prev) {                    if (top->curtopline == 0) {                        XFeep(0);                        break;                    }                    top->curtopline -= SCROLL_INCR;                    if (top->curtopline < 0)                        top->curtopline = 0;                    XClear(top->win);                    redraw(top, 0, 0, top->xpix,                            top->ypix);                    break;                }                for (tl = top->subtopics; tl; tl = tl->next)                    if (but == &tl->button)                        return (tl);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -