home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / DDGRIPS.LSP < prev    next >
Encoding:
Text File  |  1992-09-08  |  9.0 KB  |  288 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;   DDGRIPS.LSP  ¬⌐Ñ╗ 0.5
  3. ;;;
  4. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  5. ;;;
  6. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  7. ;;;   ¡∞½h :
  8. ;;;
  9. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  10. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  11. ;;;
  12. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  13. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  14. ;;;
  15. ;;;
  16. ;;;----------------------------------------------------------------------------
  17. ;;;
  18. ;;; ===========================================================================
  19. ;;; ===================== load-time error checking ============================
  20. ;;;
  21.  
  22.   (defun ai_abort (app msg)
  23.      (defun *error* (s)
  24.         (if old_error (setq *error* old_error))
  25.         (princ)
  26.      )
  27.      (if msg
  28.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  29.                       app
  30.                       " \n\n  "
  31.                       msg
  32.                       "  \n"
  33.               )
  34.        )
  35.      )
  36.      (exit)
  37.   )
  38.  
  39. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  40. ;;; and then try to load it.
  41. ;;;
  42. ;;; If it can't be found or it can't be loaded, then abort the
  43. ;;; loading of this file immediately, preserving the (autoload)
  44. ;;; stub function.
  45.  
  46.   (cond
  47.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  48.  
  49.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  50.         (ai_abort "DDGRIPS"
  51.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  52.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  53.  
  54.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  55.         (ai_abort "DDGRIPS" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  56.   )
  57.  
  58.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  59.       (ai_abort "DDGRIPS" nil)         ; a Nil <msg> supresses
  60.   )                                    ; ai_abort's alert box dialog.
  61.  
  62. ;;; ==================== end load-time operations ===========================
  63.  
  64. ;;;----------------------------------------------------------------------------
  65. ;;; The Main routine.
  66. ;;;----------------------------------------------------------------------------
  67. (defun c:ddgrips( /
  68.                   do_cool        gripcolor      x1             grips_var
  69.                   cmd            gripsize       x2             gripblock_var
  70.                   cnum           do_hot         hotcolor       x_grip
  71.                   colorint       image_col      x_swatch
  72.                   coolcolor      do_setvars     y_grip
  73.                   dcl_id         draw_size      temp_color     y_swatch
  74.                   globals        whichgrip      ddgrips_main   what_next
  75.                   gripsize_init  hotcolor_init  coolcolor_init
  76.                   gripblock_init grips_init     undo_init
  77.                 )
  78.   ;;
  79.   ;; Disable gripblock when grips are disabled.
  80.   ;;
  81.   (defun grips()
  82.     (if (= "1" (get_tile "grips"))
  83.       (mode_tile "gripblock" 0)
  84.       (mode_tile "gripblock" 1)
  85.     )
  86.   )
  87.   ;;
  88.   ;; Pass an integer and draw a square of that size in the gripsize image tile.
  89.   ;;
  90.   (defun draw_size (intsize)
  91.     (setq x1 (- (/ x_grip 2) (1+ intsize) ))
  92.     (setq x2 (+ (/ x_grip 2) (1+ intsize) ))
  93.     (setq y1 (- (/ y_grip 2) (1+ intsize) ))
  94.     (setq y2 (+ (/ y_grip 2) (1+ intsize) ))
  95.     (start_image "grip_image")
  96.     (fill_image 0 0 x_grip y_grip -2)
  97.     (vector_image x1 y1 x2 y1 coolcolor)
  98.     (vector_image x2 y1 x2 y2 coolcolor)
  99.     (vector_image x2 y2 x1 y2 coolcolor)
  100.     (vector_image x1 y2 x1 y1 coolcolor)
  101.     (end_image)
  102.   )
  103.   ;;
  104.   ;;  Select cool color from color dialogue.
  105.   ;;
  106.   (defun do_cool()
  107.     (if (setq temp_color (acad_colordlg coolcolor nil))
  108.       (progn
  109.         (setq coolcolor temp_color)
  110.         (set_tile "cool_text" (gripcolor coolcolor "cool"))
  111.         (start_image "cool_image")
  112.         (fill_image 0 0 x_swatch y_swatch (image_col coolcolor "cool"))
  113.         (end_image)
  114.         (draw_size gripsize)
  115.       )
  116.     )
  117.   )
  118.   ;;
  119.   ;;  Select cool color from color dialogue.
  120.   ;;
  121.   (defun do_hot()
  122.     (if (setq temp_color (acad_colordlg hotcolor nil))
  123.       (progn
  124.         (setq hotcolor temp_color)
  125.         (set_tile "hot_text" (gripcolor hotcolor "hot"))
  126.         (start_image "hot_image")
  127.         (fill_image  0  0  x_swatch y_swatch (image_col hotcolor "hot"))
  128.         (end_image)
  129.       )
  130.     )
  131.   )
  132.   ;;
  133.   ;; If color is zero pass correct color number.
  134.   ;;
  135.   (defun image_col(colorint whichgrip)
  136.      (cond
  137.        ((and (= 0 colorint) (= whichgrip "cool")) 5)
  138.        ((and (= 0 colorint) (= whichgrip "hot")) 1)
  139.        (t colorint)
  140.     )
  141.   )
  142.   ;;
  143.   ;; Pass an integer and recieve a string stating the color name if it is
  144.   ;; one of AutoCAD's standard colors, else just a string containing the
  145.   ;; number.
  146.   ;;
  147.   (defun gripcolor(colorint whichgrip)
  148.      (cond
  149.        ((and (= 0 colorint) (= whichgrip "cool")) "5 - Blue")
  150.        ((and (= 0 colorint) (= whichgrip "hot")) "1 - Red")
  151.        ((= 1 colorint) "1 - Red")
  152.        ((= 2 colorint) "2 - Yellow")
  153.        ((= 3 colorint) "3 - Green")
  154.        ((= 4 colorint) "4 - Cyan")
  155.        ((= 5 colorint) "5 - Blue")
  156.        ((= 6 colorint) "6 - Magenta")
  157.        ((= 7 colorint) "7 - White")
  158.        (t (itoa colorint))
  159.      )
  160.   )
  161.   ;;
  162.   ;;  If OK, set all setvars to selected values.
  163.   ;;
  164.   (defun do_setvars()
  165.     (if (/= grips_var grips_init)
  166.       (setvar "grips" (atoi grips_var))
  167.     )
  168.     (if (/= gripblock_var gripblock_init)
  169.       (setvar "gripblock" (atoi gripblock_var))
  170.     )
  171.     (if (/= coolcolor coolcolor_init)
  172.       (setvar "gripcolor" coolcolor)
  173.     )
  174.     (if (/= hotcolor hotcolor_init)
  175.       (setvar "griphot" hotcolor)
  176.     )
  177.     (if (/= gripsize gripsize_init)
  178.       (setvar "gripsize" (1+ gripsize))
  179.     )
  180.   )
  181.   ;;
  182.   ;; Put up the dialogue.
  183.   ;;
  184.   (defun ddgrips_main()
  185.  
  186.     (if (not (new_dialog "ddgrips" dcl_id)) (exit))
  187.  
  188.     (setq coolcolor (getvar "gripcolor")
  189.           coolcolor_init coolcolor     ; remember initial value
  190.           hotcolor (getvar "griphot")
  191.           hotcolor_init hotcolor       ; remember initial value
  192.     )
  193.  
  194.     ;; Get current settings of variables.
  195.     (set_tile "grips" (setq grips_init (itoa (getvar "grips"))))
  196.     (set_tile "gripblock" (setq gripblock_init (itoa (getvar "gripblock"))))
  197.  
  198.     (setq grips_var grips_init)
  199.     (setq gripblock_var gripblock_init)
  200.  
  201.     (grips)
  202.  
  203.     (set_tile "cool_text" (gripcolor coolcolor "cool"))
  204.     (set_tile "hot_text" (gripcolor hotcolor "hot"))
  205.  
  206.     ;; The gripsize variable must be within 1 - 20 for display within the image
  207.     ;; tile.  The gripsize variable will only be updated if the user moves
  208.     ;; the slider bar (0 - 19).
  209.     (setq gripsize (1- (getvar "gripsize")))
  210.  
  211.     (if (< 19 gripsize) (setq gripsize 19))
  212.     (if (> 0 gripsize) (setq gripsize 0))
  213.     (setq gripsize_init gripsize)
  214.  
  215.  
  216.     (set_tile "grip_slider" (itoa gripsize))
  217.  
  218.     (setq x_swatch (dimx_tile "cool_image"))
  219.     (setq y_swatch (dimy_tile "cool_image"))
  220.  
  221.     (setq x_grip (dimx_tile "grip_image"))
  222.     (setq y_grip (dimy_tile "grip_image"))
  223.  
  224.     (start_image "cool_image")
  225.     (fill_image  0  0  x_swatch y_swatch (image_col coolcolor "cool"))
  226.     (end_image)
  227.  
  228.     (start_image "hot_image")
  229.     (fill_image  0  0  x_swatch y_swatch (image_col hotcolor "hot"))
  230.     (end_image)
  231.  
  232.     (draw_size gripsize)
  233.  
  234.     (action_tile "default_mode" "(set_default)")
  235.     (action_tile "grips" "(setq grips_var $value)(grips)")
  236.     (action_tile "gripblock" "(setq gripblock_var $value)")
  237.     (action_tile "cool_color" "(do_cool)")
  238.     (action_tile "hot_color" "(do_hot)")
  239.     (action_tile "grip_slider" "(draw_size (setq gripsize (atoi $value)))")
  240.     (action_tile "help" "(acad_helpdlg \"acad.hlp\" \"ddgrips\")")
  241.     (action_tile "accept" "(done_dialog 1)")
  242.  
  243.     (setq what_next (start_dialog))
  244.  
  245.     (cond
  246.       ((= 1 what_next)
  247.         (do_setvars)
  248.       )
  249.     )
  250.   )
  251.  
  252.   ;; Set up error function.
  253.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  254.         old_error  *error*            ; save current error function
  255.         *error* ai_error              ; new error function
  256.   )
  257.  
  258.   (setvar "cmdecho" 0)
  259.  
  260.   (cond
  261.      (  (not (ai_transd)))                       ; transparent OK
  262.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  263.      (  (not (setq dcl_id (ai_dcl "ddgrips"))))  ; is .DCL file loaded?
  264.      (t (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  265.                  (/= 8 (logand 8 (getvar "cmdactive")))
  266.             )
  267.          (ai_undo_push)
  268.         )
  269.         (ddgrips_main)                           ; proceed!
  270.         (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  271.                  (/= 8 (logand 8 (getvar "cmdactive")))
  272.             )
  273.          (ai_undo_pop)
  274.         )
  275.      )
  276.   )
  277.  
  278.  
  279.   (setq *error* old_error)
  280.   (setvar "cmdecho" old_cmd)
  281.   (princ)
  282. )
  283. ;;;----------------------------------------------------------------------------
  284. (princ "  íuDDGRIPSívñw╕ⁿñJíC")
  285. (princ)
  286.  
  287.  
  288.