home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / SUPPORT / DDCOLOR.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1995-02-08  |  6.0 KB  |  190 lines

  1. ; Next available MSG number is    24 
  2. ; MODULE_ID DDCOLOR_LSP_
  3. ;;;
  4. ;;;    ddcolor.lsp
  5. ;;;    
  6. ;;;    Copyright (C) 1990, 1992, 1994 by Autodesk, Inc.
  7. ;;;
  8. ;;;    Permission to use, copy, modify, and distribute this software
  9. ;;;    for any purpose and without fee is hereby granted, provided
  10. ;;;    that the above copyright notice appears in all copies and
  11. ;;;    that both that copyright notice and the limited warranty and
  12. ;;;    restricted rights notice below appear in all supporting
  13. ;;;    documentation.
  14. ;;;
  15. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  16. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  17. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  18. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  19. ;;;    UNINTERRUPTED OR ERROR FREE.
  20. ;;;
  21. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  22. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  23. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  24. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  25. ;;;
  26. ;;;.
  27. ;;;
  28. ;;;----------------------------------------------------------------------------
  29. ;;;    DESCRIPTION
  30. ;;;     
  31. ;;;    Chromatic Pallete style color selection dialog.
  32. ;;;    
  33. ;;;    Globals:
  34. ;;;    
  35. ;;;          chroma_color - Integer color index.  The last value selected
  36. ;;;              by the user in chroma dialog.  It is not cleared or reset
  37. ;;;              by a cancel.  Only used for communication between callback
  38. ;;;              functions and the (chroma) funciton.
  39. ;;;    
  40. ;;;    Depends on the definitions for the dialog provided in chroma.dcl.
  41. ;;;    
  42. ;;;
  43. ;;; C:DDCOLOR -- Dialogue front end to the CECOLOR sysvar.  Uses the chroma 
  44. ;;; pallete style color selector.
  45. ;;;
  46. ;;; ===========================================================================
  47. ;;; ===================== load-time error checking ============================
  48. ;;;
  49.  
  50.   (defun ai_abort (app msg)
  51.      (defun *error* (s)
  52.         (if old_error (setq *error* old_error))
  53.         (princ)
  54.      )
  55.      (if msg
  56.        (alert (strcat " Error en la aplicaci≤n: "
  57.                       app
  58.                       " \n\n  "
  59.                       msg
  60.                       "  \n"
  61.               )
  62.        )
  63.      )
  64.      (exit)
  65.   )
  66.  
  67. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  68. ;;; and then try to load it.
  69. ;;;
  70. ;;; If it can't be found or it can't be loaded, then abort the
  71. ;;; loading of this file immediately, preserving the (autoload)
  72. ;;; stub function.
  73.  
  74.   (cond
  75.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  76.  
  77.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  78.         (ai_abort "DDCOLOR"
  79.                   (strcat "Imposible localizar el archivo AI_UTILS.LSP."
  80.                           "\n Compruebe el directorio de soporte.")))
  81.  
  82.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  83.         (ai_abort "DDCOLOR" "Imposible cargar el archivo AI_UTILS.LSP"))
  84.   )
  85.  
  86.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  87.       (ai_abort "DDCOLOR" nil)         ; a Nil <msg> supresses
  88.   )                                    ; ai_abort's alert box dialog.
  89.  
  90. ;;; ==================== end load-time operations ===========================
  91.  
  92. (defun c:ddcolor (/ co_oce clrx co_err co_oer lay_clr)
  93.  
  94.   ;; Main Color function, called by setup code.
  95.   (defun ddcolor_main()
  96.  
  97.     (graphscr)
  98.   
  99.     ;; Get the color of the current layer, for possible BYLAYER color swatch.
  100.     (setq lay_clr (cdr (assoc 62 (tblsearch "layer" (getvar "clayer")))))
  101.  
  102.     ;; Call the dialog here...
  103.     (setq clr (acad_colordlg (cstoci (getvar "cecolor")) T lay_clr))
  104.  
  105.     (if clr
  106.       (setvar "CECOLOR" (citocs clr)))
  107.   )
  108.  
  109.   ;;;
  110.   ;;; CSTOCI -- Color string to color index
  111.   ;;;   Convert an arbitrary case string into a color index.
  112.   ;;;   Returns nil if string is not a valid color.
  113.   ;;;
  114.   (defun cstoci (str)
  115.     (setq str (strcase str))
  116.     (cond
  117.      ((= str "ROJO")        1)
  118.      ((= str "AMARILLO")     2)
  119.      ((= str "VERDE")      3)
  120.      ((= str "CIANO")       4)
  121.      ((= str "AZUL")       5)
  122.      ((= str "MAGENTA")    6)
  123.      ((= str "BLANCO")      7)
  124.      ((= str ;|MSG0|;"BYLAYER")  256)
  125.      ((= str ;|MSG0|;"BYBLOCK")    0)
  126.      ((= str "PORCAPA") 256)
  127.      ((= str "PORBLOQUE")   0)
  128.      ((and (< 0 (atoi str)) (> 256 (atoi str))) (atoi str))
  129.      (nil))
  130.   )
  131.  
  132.  
  133.   ;;;
  134.   ;;; CITOCS -- Convert color index into standard color name.
  135.   ;;;    Will return the standard and logical color names as text
  136.   ;;;    strings.  Returns nil for out-of-range color indicies.
  137.   ;;;
  138.   (defun citocs(i)
  139.     (cond
  140.      ((= i 0)   "PORBLOQUE")
  141.      ((= i 1)   "rojo")
  142.      ((= i 2)   "amarillo")
  143.      ((= i 3)   "verde")
  144.      ((= i 4)   "ciano")
  145.      ((= i 5)   "azul")
  146.      ((= i 6)   "magenta")
  147.      ((= i 7)   "blanco")
  148.      ((= i 256) "PORCAPA")
  149.      ((and (< 0 i) (> 256 i)) (itoa i))
  150.      (nil))
  151.   )
  152.  
  153.   ;; Start of ddcolor
  154.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  155.         old_error  *error*            ; save current error function
  156.         *error* ai_error              ; new error function
  157.   )
  158.  
  159.   (setvar "cmdecho" 0)
  160.  
  161.   (cond
  162.      (  (not (ai_trans)))                        ; transparent OK
  163.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  164.  
  165.      (t (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  166.                  (/= 8 (logand 8 (getvar "cmdactive")))
  167.             )
  168.          (ai_undo_push)
  169.         )
  170.  
  171.         (ddcolor_main)                          ; proceed!
  172.  
  173.         (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  174.                  (/= 8 (logand 8 (getvar "cmdactive")))
  175.             )
  176.          (ai_undo_pop)
  177.         )
  178.      )
  179.   )
  180.  
  181.   (setq *error* old_error) 
  182.   (setvar "cmdecho" old_cmd)
  183.   (princ)
  184.  
  185. )
  186.  
  187. ;;;----------------------------------------------------------------------------
  188. (princ "  DDCOLOR cargado.  ")
  189. (princ)
  190.