本帖最后由 Free-Lancer 于 2014-9-10 16:53 编辑
基本搞定 edit_box toggle radio_button 这几个 控件了,以后再用就方便了
![](source/plugin/imc_colorcode/images/loading.gif) - (mapcar '(lambda (x y)
- (if (not (eval x))
- (set x y)
- )
- )
- '($globle_wid $globle_dis $globle_mode $globle_totle)
- '(2.0 1.0 "mid" "0")
- )
- (defun c:tt (/ str fn id tf dg)
- (setq str '("temp:dialog {"
- " label = \"焊肉符号\" ;"
- " :column {"
- " :boxed_column {"
- " label = \"参数\" ;"
- " :edit_box {"
- " key = \"wid\" ;"
- " label = \"宽度\" ;"
- " }"
- " :edit_box {"
- " key = \"dis\" ;"
- " label = \"间距\" ;"
- " }"
- " }"
- " :boxed_row {"
- " label = \"方向\" ;"
- " :radio_button {"
- " key = \"left\" ;"
- " label = \"左\" ;"
- " }"
- " :radio_button {"
- " key = \"mid\" ;"
- " label = \"中\" ;"
- " }"
- " :radio_button {"
- " key = \"right\" ;"
- " label = \"右\" ;"
- " }"
- " }"
- " }"
- " :row{"
- " :toggle{"
- " key = \"tol\";"
- " label = \"整线\";"
- " }"
- " ok_cancel;}"
- " errtile;"
- "}"
- )
- )
- (setq fn (dcl:make str) ;_写出临时 dcl
- id (dcl:load fn "temp") ;_加载 DCL 文件
- )
- ;;set_tile
- ;;设置 string 格式按钮默认值
- (dcl:settile
- '("wid" "dis" "tol")
- (mapcar 'vl-princ-to-string
- (list $globle_wid $globle_dis $globle_totle)
- )
- )
- ;;初始化 radio_button 按钮组
- (DCL:RadioInit '("left" "mid" "right") '$globle_mode)
- ;;检查数字格式的 edit_box
- (DCL:ChkNumIn '("wid" "dis"))
- ;;action_tile
- (DCL:RadioAction '("left" "mid" "right") '$globle_mode)
- ;;数字格式 edit_box 转化为全局变量
- (DCL:EditboxNumAction
- '("wid" "dis")
- '($globle_wid $globle_dis)
- )
- ;;记录 toggle 按钮状态,全局变量
- (DCL:ToggleAction "tol" '$globle_totle)
- ;;ok
- (DCL:Accept) ;_定义 accept and cancel
- ;;Main program
- (if (= (dcl:start id fn) 1)
- (princ "\nOk!")
- )
- (princ)
- )
DCL 控制部分,lib.vlx 已更新
![](source/plugin/imc_colorcode/images/loading.gif) - ;;=============================================================;
- ;; Aciton_tile ;
- ;;=============================================================;
- (defun DCL:ToggleAction (keylst syml)
- (if (eq (type syml) 'LIST)
- (mapcar '(lambda (x y)
- (action_tile
- x
- (strcat "(setq " (vl-symbol-name y) " $value)")
- )
- )
- keylst
- syml
- )
- (action_tile
- keylst
- (strcat "(setq " (vl-symbol-name syml) " $value)")
- )
- )
- )
- ;;数字格式Edit_box 控件Action事件
- (defun DCL:EditboxNumAction (keylst syml)
- (mapcar '(lambda (x y)
- (action_tile x
- (strcat "(setq "
- (vl-symbol-name y)
- "(distof (get_tile \""
- x
- "\")))"
- )
- )
- )
- keylst
- syml
- )
- )
- ;;String 格式 edit_box Action
- (defun DCL:EditboxAction (keylst syml)
- (apply 'strcat
- (mapcar '(lambda (x y)
- (strcat "(setq "
- (vl-symbol-name y)
- "(get_tile \""
- x
- "\"))"
- )
- )
- keylst
- syml
- )
- )
- )
- ;; Radio 组 Action
- ;; keylst ---- radio key list
- ;; def ---- key
- (defun Dcl:RadioAction (keylst sym / actions)
- (foreach x keylst
- (action_tile
- x
- (apply
- 'strcat
- (append
- (list (strcat "(setq " (vl-symbol-name sym) " $key" ")"))
- (mapcar '(lambda (x)
- (strcat "(set_tile " "\"" x "\"" " \"0\")")
- )
- keylst
- )
- (list "(set_tile $key \"1\")")
- )
- )
- )
- )
- )
- ;;多组Radio Action
- (defun Dcl:mRadioAction (lst)
- (mapcar '(lambda (x) (apply 'Dcl:RadioAction x)) lst)
- )
- (defun Dcl:Accept ()
- (action_tile "accept" "(done_dialog 1)")
- (action_tile "cancel" "(done_dialog 0)")
- t
- )
|