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

📄 xdriver.c

📁 占星术4.0源码
💻 C
📖 第 1 页 / 共 3 页
字号:
        xscreen = loresmode;
        XBegin();
        chartx = config.numxpixels;
        charty = config.numypixels;
        if (chartx > charty)
          chartx = charty;
        if (ISEGA(xscreen))
          chartx = EGATOVGA(chartx);
				else if (ISCGA(xscreen))
					chartx = CGATOVGA(chartx);
        if ((modex == MODEv || modex == MODEw) && xtext &&
          !(exdisplay & DASHv0))
          chartx += SIDET;
        xresize = TRUE;
      }
#endif
    }

    /* Physically resize window if we've changed the size parameters. */

    if (xresize) {
      xresize = FALSE;
#ifdef X11
      XResizeWindow(disp, window, chartx, charty);
      XFreePixmap(disp, pixmap);
      pixmap = XCreatePixmap(disp, window, chartx, charty, depth);
#else
      if (config.numxpixels > chartx)
        offsetx = (config.numxpixels - chartx) >> 1;
      else {
        if (xcorner % 3 == 1)
          offsetx = 0;
        else if (xcorner % 3 == 0)
          offsetx = -chartx + config.numxpixels;
        else
          offsetx = -(chartx - config.numxpixels) / 2;
      }
      if (config.numypixels > charty)
        offsety = (config.numypixels - charty) >> 1;
      else {
        if (xcorner > 6)
          offsety = 0;
        else if (xcorner < 4)
          offsety = -charty + config.numypixels;
        else
          offsety = -(charty - config.numypixels) / 2;
      }
#endif
      xredraw = TRUE;
    }

    /* Recast chart if the chart information has changed any. */

    if (xcast) {
      xcast = FALSE;
      SetCore(Mon, Day, Yea, Tim, Zon, Lon, Lat);
      if (relation)
        CastRelation(FALSE);
      else
        CastChart(TRUE);
      xredraw = TRUE;
    }
    if (xnow && !xpause)
      xredraw = TRUE;

    /* Update the screen if anything has changed since last time around. */

    if (xredraw) {
      xredraw = FALSE;

      /* If we're in animation mode, change the chart info appropriately. */

      if (xnow)
        Animate(xnow, dir);
#ifdef X11
      XFillRectangle(disp, pixmap, pmgc, 0, 0, chartx, charty);
#else /* MSG */
#ifdef MOUSE
      SetPtrVis(HIDE);
#endif
      if (config.numvideopages > 1)
        _setactivepage(_getactivepage() == 0);
#endif /* MSG */
      XChart();
#ifdef X11
      XSync(disp, 0);
      XCopyArea(disp, pixmap, window, gc, 0, 0, chartx, charty, 0, 0);
#else /* MSG */
      if (config.numvideopages > 1)
        _setvisualpage(_getactivepage());
#ifdef MOUSE
      if (!xnow)
        SetPtrVis(SHOW);
#endif
#endif /* MSG */
    }  /* if */

    /* Now process what's on the event queue, i.e. any keys pressed, etc. */

#ifdef X11
    if (XEventsQueued(disp, QueuedAfterFlush /*QueuedAfterReading*/ )) {
      XNextEvent(disp, &event);

      /* Restore what's on window if a part of it gets uncovered. */

      if (event.type == Expose && event.xexpose.count == 0) {
        XSync(disp, 0);
        XCopyArea(disp, pixmap, window, gc, 0, 0, chartx, charty, 0, 0);
      }
      switch (event.type) {

      /* Check for a manual resize of window by user. */

      case ConfigureNotify:
        chartx = event.xconfigure.width;
        charty = event.xconfigure.height;
        XFreePixmap(disp, pixmap);
        pixmap = XCreatePixmap(disp, window, chartx, charty, depth);
        xredraw = TRUE;
        break;
      case MappingNotify:
        XRefreshKeyboardMapping((XMappingEvent PTR)&event);
        break;

#ifdef MOUSE
      /* Process any mouse buttons the user pressed. */

      case ButtonPress:
        buttonx = event.xbutton.x; buttony = event.xbutton.y;
        if (event.xbutton.button == Button1) {
          DrawColor(hilite);
          DrawPoint(buttonx, buttony);
          XSync(disp, 0);
          XCopyArea(disp, pixmap, window, gc, 0, 0, chartx, charty, 0, 0);
        } else if (event.xbutton.button == Button2 &&
          (modex == MODEL || modex == MODEW) && degree == 0) {
          Lon = DEGHALF-(real)(event.xbutton.x-1)/(real)(chartx-2)*DEGREES;
          Lat =  DEGQUAD-(real)(event.xbutton.y-1)/(real)(charty-2)*181.0;
          fprintf(S, "Mouse is at %s.\n", CharLocation(Lon, Lat, 60.0));
        } else if (event.xbutton.button == Button3)
          xbreak = TRUE;
        break;

      /* Check for user dragging any of the mouse buttons across window. */

      case MotionNotify:
        DrawColor(coldrw);
        DrawLine(buttonx, buttony, event.xbutton.x, event.xbutton.y);
        XSync(disp, 0);
        XCopyArea(disp, pixmap, window, gc, 0, 0, chartx, charty, 0, 0);
        buttonx = event.xbutton.x; buttony = event.xbutton.y;
        break;
#endif

      /* Process any keys user pressed in window. */

      case KeyPress:
        length = XLookupString((XKeyEvent PTR)&event, xkey, 10, &key, 0);
        if (length == 1) {
          i = xkey[0];
#else /* MSG */
#ifdef MOUSE
      if (!xnow && GetMouseEvent((EVENT *)&event)) {
        if (event.fsBtn == LEFT_DOWN && buttonx >= 0) {
          SetPtrVis(HIDE);
          DrawColor(coldrw);
          _moveto(buttonx, buttony);
          buttonx = event.x; buttony = event.y;
          _lineto(buttonx, buttony);
        } else if (event.fsBtn == RIGHT_DOWN &&
          (modex == MODEL || modex == MODEW) && degree == 0) {
          Lon = DEGHALF-(real)(event.x-offsetx)/(real)(chartx-2)*DEGREES;
          if (Lon < -DEGHALF)
            Lon = -DEGHALF;
          else if (Lon > DEGHALF)
            Lon = DEGHALF;
          Lat =  DEGQUAD-(real)(event.y-offsety)/(real)(charty-2)*181.0;
          if (Lat < -DEGQUAD)
            Lat = -DEGQUAD;
          else if (Lat > DEGQUAD)
            Lat = DEGQUAD;
          xcast = TRUE;
        } else if (event.fsBtn == MIDDLE_DOWN)
          xbreak = TRUE;
        else {
          buttonx = event.x; buttony = event.y;
        }
        SetPtrVis(SHOW);
      } else
#endif
        if (kbhit()) {
          i = getch();
#endif /* MSG */
          switch (i) {
          case ' ':
            xredraw = TRUE;
            break;
          case 'p':
            xpause = !xpause;
            break;
          case 'r':
            dir = -dir;
            break;
          case 'x':
            xreverse = !xreverse;
            XColorInit();
            xredraw = TRUE;
            break;
          case 'm':
            if (!xmono) {
              xcolor = !xcolor;
#ifdef MSG
              _getvideoconfig((struct videoconfig far *) &config);
#endif
              XColorInit();
              xredraw = TRUE;
            }
            break;
          case 'B':
#ifdef X11
            XSetWindowBackgroundPixmap(disp, root, pixmap);
            XClearWindow(disp, root);
#else
            chartx = config.numxpixels;
            charty = config.numypixels;
            if (modex == MODEv || modex == MODEw || modex == MODEg ||
              (modex == MODEZ && (exdisplay & DASHZ0) > 0) ||
              modex == MODES || modex == MODEG || modex == MODEP) {
              if (chartx > charty)
                chartx = charty;
              if (ISEGA(xscreen))
                chartx = EGATOVGA(chartx);
							else if (ISCGA(xscreen))
                chartx = CGATOVGA(chartx);
              if ((modex == MODEv || modex == MODEw) && xtext &&
                !(exdisplay & DASHv0))
                chartx += SIDET;
            }
            xresize = TRUE;
#endif
            break;
          case 'T':
            xtext = !xtext;
            xredraw = TRUE;
            break;
          case 'i':
            xbonus = !xbonus;
            xredraw = TRUE;
            break;
          case 'b':
            xborder = !xborder;
            xredraw = TRUE;
            break;
          case 'l':
            xlabel = !xlabel;
            xredraw = TRUE;
            break;
          case '<':
            if (scale > 100) {
              scale -= 100;
              xresize = TRUE;
            }
            break;
          case '>':
            if (scale < 300) {
              scale += 100;
              xresize = TRUE;
            }
            break;
          case '[':
            if (modex == MODEG) {
              tilt = tilt > -DEGQUAD ? tilt-11.25 : -DEGQUAD;
              xredraw = TRUE;
            }
            break;
          case ']':
            if (modex == MODEG) {
              tilt = tilt < DEGQUAD ? tilt+11.25 : DEGQUAD;
              xredraw = TRUE;
            }
            break;
          case 'Q':
            if (chartx > charty)
              chartx = charty;
            else
              charty = chartx;
#ifdef MSG
            if (ISEGA(xscreen))
              chartx = EGATOVGA(chartx);
						else if (ISCGA(xscreen))
              chartx = CGATOVGA(chartx);
#endif
            xresize = TRUE;
            break;
          case 'R':
            for (i = 11; i <= 15; i++)
              ignore[i] = !ignore[i];
            ignore[_FOR] = !ignore[_FOR]; ignore[_VTX] = !ignore[_VTX];
            xredraw = TRUE;
            break;
          case 'C':
            operation ^= DASHC;
            for (i = C_LO; i <= C_HI; i++)
              ignore[i] = !ignore[i];
            xcast = TRUE;
            break;
          case 'u':
            operation ^= DASHu;
            for (i = U_LO; i <= U_HI; i++)
              ignore[i] = !ignore[i];
            xcast = TRUE;
            break;
          case 'U':
            universe = !universe;
            for (i = S_LO; i <= S_HI; i++)
              ignore[i] = !ignore[i];
            xcast = TRUE;
            break;
          case 'c':
            if (!relation) {
              relation = DASHr0;
              SetTwin(Mon, Day, Yea, Tim, Zon, Lon, Lat);
            } else
              relation = 0;
            xcast = TRUE;
            break;
          case 's':
            operation ^= DASHs;
            xcast = TRUE;
            break;
          case 'h':
            centerplanet = centerplanet ? 0 : 1;
            xcast = TRUE;
            break;
          case 'f':
            operation ^= DASHf;
            xcast = TRUE;
            break;
          case 'F':
            operation ^= DASH3;
            xcast = TRUE;
            break;
          case '+':
            Animate(4, abs(dir));
            xcast = TRUE;
            break;
          case '-':
            Animate(4, -abs(dir));
            xcast = TRUE;
            break;
          case 'o':
            SetSave(Mon, Day, Yea, Tim, Zon, Lon, Lat);
            break;
          case 'O':
            SetMain(MonX, DayX, YeaX, TimX, ZonX, LonX, LatX);
            xcast = TRUE;
            break;
#ifdef TIME
          case 'n':
            InputData("now");
            SetMain(MM, DD, YY, TT, ZZ, OO, AA);
            xcast = TRUE;
            break;
#endif
          case 'N':                      /* The continuous update animation. */
            xnow = xnow ? 0 : -10;
            break;
          case '!': xnow = -1; break;    /* These are the nine different     */
          case '@': xnow = -2; break;    /* "add time to chart" animations.  */
          case '#': xnow = -3; break;
          case '$': xnow = -4; break;
          case '%': xnow = -5; break;
          case '^': xnow = -6; break;
          case '&': xnow = -7; break;
          case '*': xnow = -8; break;
          case '(': xnow = -9; break;
          case 'V': modex = MODEv; xredraw = TRUE; break; /* Should we go    */
          case 'L': modex = MODEL; xredraw = TRUE; break; /* switch to a     */
          case 'A': modex = MODEg; xredraw = TRUE; break; /* new chart type? */
          case 'Z': modex = MODEZ; xredraw = TRUE; break;
          case 'S': modex = MODES; xredraw = TRUE; break;
          case 'E': modex = MODEE; xredraw = TRUE; break;
          case 'W': modex = MODEW; xredraw = TRUE; break;
          case 'G': modex = MODEG; xredraw = TRUE; break;
          case 'P': modex = MODEP; xredraw = TRUE; break;
#ifdef BIORHYTHM
          case 'Y':               /* Should we switch to biorhythm chart? */
            if (!relation) {
              SetTwin(Mon, Day, Yea, Tim, Zon, Lon, Lat);
            }
            relation = DASHrb;
            modex = MODEb;
            xcast = TRUE;
            break;
#endif
          case '0':
            exdisplay ^= DASHZ0 | DASHEy | DASHXW0;
            modex = (modex == MODEv ? MODEw : (modex == MODEw ? MODEv :
              modex));
            xredraw = TRUE;
            break;
          case 'v': case 'H': case '?':
#ifdef MSG
            _setvideomode(_DEFAULTMODE);
            if (i != 'v')
              _settextrows(43);
#endif
            if (i == 'v')
              ChartLocation();
            else
              XDisplayKeys();
#ifdef MSG
            while (!kbhit())
              ;
            i = getch();
            if (i == 'q' || i == ESCAPE || i == '\3') {
              xbreak = TRUE;
              break;
            }
            XBegin();
            xresize = TRUE;
#endif
            break;
#ifdef MSG
          case '\t':
            if (xscreen == hiresmode)
              xscreen = loresmode;
            else
              xscreen = hiresmode;
            XBegin();
            chartx = config.numxpixels;
            charty = config.numypixels;
            if (chartx > charty)
              chartx = charty;
            if (ISEGA(xscreen))
              chartx = EGATOVGA(chartx);
						else if (ISCGA(xscreen))
              chartx = CGATOVGA(chartx);
            if ((modex == MODEv || modex == MODEw) && xtext &&
              !(exdisplay & DASHv0))
              chartx += SIDET;
            xresize = TRUE;
            break;
#endif
          case '\b':
#ifdef MSG
#ifdef MOUSE
            SetPtrVis(HIDE);
#endif
#endif /* MSG */
            DrawClearScreen();
            break;
#ifdef MOUSE
          case 'z'-'`': coldrw = BLACK;   break;
          case 'e'-'`': coldrw = MAROON;  break;
          case 'f'-'`': coldrw = DKGREEN; break;
          case 'o'-'`': coldrw = ORANGE;  break;

⌨️ 快捷键说明

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