(defun c:tt();此部分是测试代码用
(dcl_bg_load)
)
;-------------------------------------
(defun dcl_bg_load(/ *error* dcl_file dcl_id dialog_return key keys)
(vl-load-com)
(progn;;;自定义函数
;-------------------------------------
(defun BF-MListBox-Remrow(/ bf-list-removeindex)
;;;名称:BF-List-RemoveIndex
;;;说明:按索引删除列表的项,leemac
;;;参数:lst:列表
;;;参数:index:索引,从0开始
;;;返回:删除索引项之后的列表
;;;示例:(BF-List-RemoveIndex '(0 1 2 3) 1)
(defun BF-List-RemoveIndex (lst index / i)
(setq i -1)
(vl-remove-if '(lambda (x) (= (setq i (1+ i)) index)) lst)
)
(mapcar
(function
(lambda (tkey)
(set
(read tkey)
(BF-List-RemoveIndex (read tkey) (atoi (get_tile tkey)))
)
(SetContrLst tkey (read tkey))
)
)
(list "序号" "规格" "长度" "材质" "数量")
)
)
(defun BF-MListBox-Selsam(tkey)
(foreach x (vl-remove tkey (list "序号" "规格" "长度" "材质" "数量"))
(set_tile x (get_tile tkey))
)
)
(defun MBF-ListBox-Additm()
(foreach
x
(mapcar
'list
(list "序号" "规格" "长度" "材质" "数量")
(mapcar
'append
(list 序号 规格 长度 材质 数量)
(mapcar
(function (lambda (x) (if (= "" (get_tile x)) (list " ") (list (get_tile x)))))
(list "编辑A" "编辑B" "编辑C" "编辑D" "编辑E")
)
)
)
(apply 'SetContrLst x)
(set (read (car x)) (cadr x))
)
)
(defun Start_dcl_bg_Keys(key value istart);控件值初始化
(cond
((= key "序号");;;{" 序号"} (普通列表)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(BF-MListBox-Selsam key)
)
((= key "规格");;;{" 规格"} (普通列表)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(BF-MListBox-Selsam key)
)
((= key "长度");;;{" 长度"} (普通列表)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(BF-MListBox-Selsam key)
)
((= key "材质");;;{" 材质"} (普通列表)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()(BF-MListBox-Selsam key)
)
((= key "数量");;;{" 数量"} (普通列表)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(BF-MListBox-Selsam key)
)
((= key "编辑A");;;{""} (输入框)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()
)
((= key "编辑B");;;{""} (输入框)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()
)
((= key "编辑C");;;{""} (输入框)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()
)
((= key "编辑D");;;{""} (输入框)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()
)
((= key "编辑E");;;{""} (输入框)
(if (and istart (eval (read (strcat key "_bak")))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
()
)
)
(prin1)
)
;-------------------------------------
(defun Action_dcl_bg_Keys(key value);全部控件的点击动作触发
(cond
((= key "accept");;;{"确认按钮"}
(Get_dcl_bg_Data)
(done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "cancel");;;{"取消按钮"}
(done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
)
((= key "读取");;;{"读取"} (按钮)
(Get_dcl_bg_Data)
()
)
((= key "清除");;;{"清除"} (按钮)
(Get_dcl_bg_Data)
()
)
((= key "编辑行");;;{"编辑行"} (按钮)
(Get_dcl_bg_Data)
()
)
((= key "删除行");;;{"删除行"} (按钮)
(Get_dcl_bg_Data)
(BF-MListBox-Remrow)
)
((= key "添加行");;;{"添加行"} (按钮)
(Get_dcl_bg_Data)
(MBF-ListBox-Additm)
)
(T
(Start_dcl_bg_Keys key value nil);;;其余控件的点击动作触发
)
)
(prin1)
)
;-------------------------------------
(defun Get_dcl_bg_Data(/ key);临时生成Dcl文件 返回文件名
(foreach key keys
(set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
)
)
;-------------------------------------
(defun Write_Dcl_dcl_bg(/ Dcl_File file str)
(setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
(setq file (open Dcl_File "w"))
(foreach str '(
"dcl_bg:dialog {"
" label = \"材料输入选项 - From:Dcl-To-Lsp Win_V1.0.5\" ;"
" width = 20 ;"
" :column {"
" :boxed_row {"
" label = \"材料信息\" ;"
" :list_box {"
" height = 25 ;"
" key = \"序号\" ;"
" label = \" 序号\" ;"
" width = 5 ;"
" horizontal_margin = none ;"
" }"
" :list_box {"
" key = \"规格\" ;"
" label = \" 规格\" ;"
" alignment = centered ;"
" horizontal_margin = none ;"
" width = 15 ;"
" }"
" :list_box {"
" key = \"长度\" ;"
" label = \" 长度\" ;"
" horizontal_margin = none ;"
" width = 10 ;"
" }"
" :list_box {"
" key = \"材质\" ;"
" label = \" 材质\" ;"
" horizontal_margin = none ;"
" width = 10 ;"
" }"
" :list_box {"
" key = \"数量\" ;"
" label = \" 数量\" ;"
" horizontal_margin = none ;"
" width = 5 ;"
" }"
" :column {"
" spacer_1;"
" :button {"
" key = \"读取\" ;"
" label = \"读取\" ;"
" }"
" :button {"
" key = \"清除\" ;"
" label = \"清除\" ;"
" }"
" :button {"
" key = \"编辑行\" ;"
" label = \"编辑行\" ;"
" }"
" :button {"
" key = \"删除行\" ;"
" label = \"删除行\" ;"
" }"
" spacer_1;"
" }"
" }"
" :boxed_row {"
" :row {"
" :edit_box {"
" key = \"编辑A\" ;"
" label = \"\" ;"
" horizontal_margin = none ;"
" edit_width = 5 ;"
" }"
" :edit_box {"
" key = \"编辑B\" ;"
" label = \"\" ;"
" horizontal_margin = none ;"
" edit_width = 15 ;"
" }"
" :edit_box {"
" key = \"编辑C\" ;"
" label = \"\" ;"
" horizontal_margin = none ;"
" edit_width = 10 ;"
" }"
" :edit_box {"
" key = \"编辑D\" ;"
" label = \"\" ;"
" horizontal_margin = none ;"
" edit_width = 10 ;"
" }"
" :edit_box {"
" key = \"编辑E\" ;"
" label = \"\" ;"
" horizontal_margin = none ;"
" edit_width = 5 ;"
" }"
" spacer_1;"
" spacer_1;"
" :button {"
" key = \"添加行\" ;"
" label = \"添加行\" ;"
" }"
" }"
" }"
" }"
" ok_cancel;"
"}"
)
(write-line str file)
)
(close file)
Dcl_File
)
;-------------------------------------
(defun *error*(msg)
;(foreach key keys;;;释放每个控件变量---可根据个人需要决定是否注释,默认注释!
; (set (read (strcat key "_bak")) nil)
;)
(princ "\n命令: *取消*")
(prin1)
)
;->->-下拉列表初始化函数->->-
(defun SetContrLst(key lst)
(start_list key);下拉列表 {key} 初始化
(mapcar 'add_list lst);添加列表项
(end_list)
(prin1)
)
;-<-<-下拉列表初始化函数-<-<-
;->->-图像初始化函数->->-
;(defun SetContrImg(key imgname)
; (start_image key);图像 {key} 初始化
; (fill_image 0 0 (dimx_tile key) (dimy_tile key) 0);图像填充黑色背景
; (slide_image 0 0 (dimx_tile key) (dimy_tile key) imgname);图像显示SLD幻灯片
; (end_image)
; (prin1)
;)
;-<-<-图像初始化函数-<-<-
)
(setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl_dcl_bg))));对话框加载
(vl-file-delete Dcl_File);加载后删除DCL文件
(setq Dialog_Return 8)
(while (> Dialog_Return 7) ;循环控制对话框是否结束
(new_dialog "dcl_bg" dcl_id);建立窗体
;--->--->---对话框初始化--->--->---
(setq keys '("序号" "规格" "长度" "材质" "数量" "读取" "清除" "编辑行" "删除行" "编辑A" "编辑B" "编辑C" "编辑D" "编辑E" "添加行""accept" "cancel" "help" "info"));列表全部控件名称
(foreach x (list "序号" "规格" "长度" "材质" "数量")
(set (read x) keys)
)
;->->-下拉列表初始化->->-
(SetContrLst "序号" keys);下拉列表 {"序号"}初始化
(SetContrLst "规格" keys);下拉列表 {"规格"}初始化
(SetContrLst "长度" keys);下拉列表 {"长度"}初始化
(SetContrLst "材质" keys);下拉列表 {"材质"}初始化
(SetContrLst "数量" keys);下拉列表 {"数量"}初始化
;-<-<-下拉列表初始化完成-<-<-
;(action_tile "accept" "(done_dialog 1)")
;(action_tile "cancel" "(done_dialog 0)")
(foreach key keys;全部控件的初始化
(Start_dcl_bg_Keys key nil T)
)
(foreach key keys;;;全部控件的点击动作触发
(action_tile key "(Action_dcl_bg_Keys $key $value)");;;点击动作 $reason
)
;---<---<---对话框初始化完成---<---<---
(setq Dialog_Return (start_dialog));开启对话框(用户可见)
)
(unload_dialog dcl_id);退出时卸载对话框
(cond
((< 0 Dialog_Return 7) (princ "\n确定"))
((= Dialog_Return 0) (princ "\n*取消*"))
)
;(foreach key keys;;;释放每个控件变量---可根据个人需要决定是否注释,默认注释!
; (set (read (strcat key "_bak")) nil)
;)
(prin1);防止函数回显
)