home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
felixcad
/
fcaddata.z
/
FLX_PAL.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1996-09-30
|
8KB
|
235 lines
;;; FLX_PAL.LSP
;;; =========================================================================
;;; Palette Manager
;;; =========================================================================
;;; (C)opyright Felix Computer Aided Technologies GmbH 1995-96
;;; =========================================================================
;;; PALMAN ... reads parameter file: <menuname>.PAL !
;;;
;;; Format of the parameter file::
;;; description1
;;; mnp-name1.mnp
;;; description2
;;; mnp-name2.mnp
;;; ...
;;; =========================================================================
(defun FLX_PALMAN ( / prt_list
PAL_START PAL_INIT SET_PAL GET_FNAME GET_FREE_PAL
PAL_GETVAR PAL_TileSet
pal1 pal2 pal3 pal4 pal5 pal6 pal7 pal8 pal9 pal10
p_id ln descrip_list mnp_list pal_new set_new_mnp
cmde mnu_name tmpl)
;;; Prompt List
(setq prt_list (list
"Palette File "
"Parameter File "
" not found!"
"Alert"
))
(if FLX_XLANGUAGE (FLX_XLANGUAGE "_pal" nil))
;--------------------------------------------------------------------------
(defun PAL_START()
(setq cmde (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(if pal_new (progn
(if (findfile set_new_mnp)
(command ".PALOPEN" (strcat "P" (itoa pal_new)) "Auto" set_new_mnp)
(alert
;;;@Palette File @ not found!
(strcat (nth 0 prt_list) set_new_mnp (nth 2 prt_list) )
(nth 3 prt_list) ;;;@Alert
"EXCLAMATION"
)
)
))
(PAL_GETVAR)
(PAL_TileSet pal1 "pal1")
(PAL_TileSet pal2 "pal2")
(PAL_TileSet pal3 "pal3")
(PAL_TileSet pal4 "pal4")
(PAL_TileSet pal5 "pal5")
(PAL_TileSet pal6 "pal6")
(PAL_TileSet pal7 "pal7")
(PAL_TileSet pal8 "pal8")
(PAL_TileSet pal9 "pal9")
(PAL_TileSet pal10 "pal10")
(setvar "CMDECHO" cmde)
)
;--------------------------------------------------------------------------
(defun PAL_INIT ( / el tmpl nr)
(if FLX$WIN95
(progn
(foreach n
'("IDCANCEL" "IDOK" "IDHELP" "paletten"
"setpal1" "setpal2" "setpal3" "setpal4" "setpal5"
"setpal6" "setpal7" "setpal8" "setpal9" "setpal10"
"pal1" "pal2" "pal3" "pal4" "pal5"
"pal6" "pal7" "pal8" "pal9" "pal10"
)
(Dlg_TileSetFont n 2)
)
(Dlg_ListSetTabstops "ListBox1" "20 25 30")
)
(Dlg_ListSetTabstops "ListBox1" "15 18 20")
)
(PAL_TileSet pal1 "pal1")
(PAL_TileSet pal2 "pal2")
(PAL_TileSet pal3 "pal3")
(PAL_TileSet pal4 "pal4")
(PAL_TileSet pal5 "pal5")
(PAL_TileSet pal6 "pal6")
(PAL_TileSet pal7 "pal7")
(PAL_TileSet pal8 "pal8")
(PAL_TileSet pal9 "pal9")
(PAL_TileSet pal10 "pal10")
(Dlg_ListStart "paletten")
(if descrip_list (foreach el descrip_list (Dlg_ListAdd el)))
(Dlg_ListEnd)
(Dlg_TileAction "setpal1" "(setq pal_new 1)(PAL_START)")
(Dlg_TileAction "setpal2" "(setq pal_new 2)(PAL_START)")
(Dlg_TileAction "setpal3" "(setq pal_new 3)(PAL_START)")
(Dlg_TileAction "setpal4" "(setq pal_new 4)(PAL_START)")
(Dlg_TileAction "setpal5" "(setq pal_new 5)(PAL_START)")
(Dlg_TileAction "setpal6" "(setq pal_new 6)(PAL_START)")
(Dlg_TileAction "setpal7" "(setq pal_new 7)(PAL_START)")
(Dlg_TileAction "setpal8" "(setq pal_new 8)(PAL_START)")
(Dlg_TileAction "setpal9" "(setq pal_new 9)(PAL_START)")
(Dlg_TileAction "setpal10" "(setq pal_new 10)(PAL_START)")
(Dlg_TileAction "paletten" "(set_pal)")
(Dlg_TileAction "IDCANCEL" "(setq pal_new nil)(Dlg_DialogDone)")
)
;-------------------------------------------------------------------------
(defun SET_PAL ()
(Dlg_TileMode "setpal1" 0)
(Dlg_TileMode "setpal2" 0)
(Dlg_TileMode "setpal3" 0)
(Dlg_TileMode "setpal4" 0)
(Dlg_TileMode "setpal5" 0)
(Dlg_TileMode "setpal6" 0)
(Dlg_TileMode "setpal7" 0)
(Dlg_TileMode "setpal8" 0)
(Dlg_TileMode "setpal9" 0)
(Dlg_TileMode "setpal10" 0)
(setq set_new_mnp (strcase (nth (atoi $value) mnp_list) T))
(if (= $reason 4) (progn
(setq pal_new (GET_FREE_PAL))
(PAL_START)
))
)
;--------------------------------------------------------------------------
(defun GET_FNAME (pal subs / ret l i)
(if (and (= (type pal) 'STR) (> (strlen pal) 0))
(progn
(setq l (strlen pal) i l)
(while (AND (> i 0) (null ret))
(if (or (= (substr pal i 1) "\\")(= (substr pal i 1) "/"))
(setq ret (substr pal (+ i 1) l))
)
(setq i (- i 1))
)
(if (null ret) (setq ret pal))
)
;;; ELSE
(setq ret "")
)
(if (and subs
(> (strlen ret) 4)
)
(setq ret (substr ret 1 (- (strlen ret) 4)) ))
(if (= (substr ret (- (strlen ret) 4) 1) "_")
(setq ret (strcat
(substr ret 1 (- (strlen ret) 5))(substr ret (- (strlen ret) 3))
))
)
(setq ret (strcase ret T))
)
;--------------------------------------------------------------------------
(defun GET_FREE_PAL ( / f1 i1 s1)
(setq f1 T i1 0 s1 nil)
(while (and f1 (< i1 7))
(setq i1 (1+ i1))
(setq s1 (getvar (strcat "PALETTE" (itoa i1))))
(if (= s1 "")(setq f1 nil))
)
(if f1
(setq i1 nil)
(setq i1 i1)
)
)
;--------------------------------------------------------------------------
(defun PAL_GETVAR()
(setq pal1 (strcase (GET_FNAME (getvar "PALETTE1")) T))
(setq pal2 (strcase (GET_FNAME (getvar "PALETTE2")) T))
(setq pal3 (strcase (GET_FNAME (getvar "PALETTE3")) T))
(setq pal4 (strcase (GET_FNAME (getvar "PALETTE4")) T))
(setq pal5 (strcase (GET_FNAME (getvar "PALETTE5")) T))
(setq pal6 (strcase (GET_FNAME (getvar "PALETTE6")) T))
(setq pal7 (strcase (GET_FNAME (getvar "PALETTE7")) T))
(setq pal8 (strcase (GET_FNAME (getvar "PALETTE8")) T))
(setq pal9 (strcase (GET_FNAME (getvar "PALETTE9")) T))
(setq pal10 (strcase (GET_FNAME (getvar "PALETTE10")) T))
)
;--------------------------------------------------------------------------
(defun PAL_TileSet (pal_no pal_string / pal_no pat_string tmp1 nr)
(if (= pal_no "")
(Dlg_TileSet pal_string "---")
(progn
(if (setq tmpl (member pal_no mnp_list))
(progn
(setq nr (- (length mnp_list) (length tmpl)))
(if (>= nr 0) (setq pal_no (nth nr descrip_list)))
)
(setq pal_no (strcat "<" pal_no ">"))
)
(Dlg_TileSet pal_string pal_no)
)
)
)
;--------------------------------------------------------------------------
(defun *ERROR* (msg)
(setq *ERROR* nil)
(setvar "CMDECHO" 1)
(setvar "FILEDIA" 1)
(princ)
)
; -------------------------------------------------------------------------
; MAIN
; -------------------------------------------------------------------------
(setq pal_new nil set_new_mnp nil)
(PAL_GETVAR)
(setq mnu_name (GET_FNAME (getvar "PDMENUNAME") T ))
(setq p_id (findfile (strcat mnu_name ".pal")))
(if (not p_id) (setq p_id (findfile "toolbar.pal")))
(if (not p_id) (setq p_id (findfile "palette.pal")))
(if (not p_id) (setq p_id (findfile "toolbox.pal")))
(if (not p_id) (setq p_id (findfile "fcad.pal" )))
(if (not p_id)
(alert
;;;@Parameter File @ not found!
(strcat (nth 1 prt_list) mnu_name ".pal" (nth 2 prt_list) )
(nth 3 prt_list) ;;;@Alert
"EXLAMATION"
) ; than
(progn
(setq p_id (open p_id "r"))
(while (setq ln (read-line p_id))
(setq descrip_list (append descrip_list (list ln)))
(if (setq ln (read-line p_id))
(setq mnp_list (append mnp_list (list ln)))
)
)
(close p_id)
(if (FLX_DLGDSP "flx_dlg" "PALETTE" "(FLX_DefaultAction)" "(PAL_INIT)") (princ)(exit))
) ; else
)
(princ)
)
(princ)