找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 687|回复: 2

[其他]:简化对话框的编制工作

[复制链接]
发表于 2004-1-17 13:36:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
设计思路:
给每个控件定义特定的性质,再由程序去根据不同的性质来处理数据,对话框关闭后可以从总数据表中抽取数据进行进一步的运算。作为实例,现在处理edit_box toggle radio_button button四种控件。

总体数据表*DCL-DATA*格式为
(控件key值 (0 。空间类型)(1 。首次进入对话的缺省值)(2 。可能的更多数据表如表内容等)(3 。控件为真时变灰的其他控件)

edit_box
("EnterValue" (0 . "edit_box")(1 . "12.0") (2 . ":REAL"))
2项: 表示输入文本框内的数据类型: ":REAL" ":INT",如果为任意文本,没有2项

toggle
("ToggleEnter" (0 . "toggle")(1 . "0") (3 . (list "accept" "help" "orthers")))
3项:表示ToggleEnter为1时需要变灰的控件列表,
2项:因为只能为1或0,所以没有定义2项

radio_button
("RadioMain" (0 . "radio_button")(1 . "Radio1") (2 . (list "Radio1" "Radio2" "Radio3"))
             (3 . (list "Radio1" "Radio3") (list "accept" "help" "orthers"))\
)
对于radio_button,只需要定义其上级控件key值,所有属于一个主控件的所有radio_button的key值列表在2项
3项:共分为两部分,第一部分为radio_button的key值列表,表示选定这些key值时需要将第二部分的控件列表变灰。

button
("Button" (0 . "button")(1 . -1) (2 . "(Action_PickButton)"))
1项:表示Done_dialog ID值,如果对话框不关闭,为任意负整数
2项:表示相对应得操控函数,自己加变量(变量的传递要再设计)

LISP/DCL codes

  1. (Defun vldcl-init (DCLFile DCLName)
  2.   (cond        ((= (type DCLFile) 'STR)
  3.          (if (setq *DCLID* (findfile DCLFile))
  4.            (progn
  5.              (setq *DCLID* (load_dialog DCLFile))
  6.              (new_dialog DCLName *DCLID*)
  7.            )
  8.          )
  9.         )
  10.         ((null DCLFile)
  11.          (if *DCLID*
  12.            (unload_dialog *DCLID*)
  13.          )
  14.          (setq *DCLID* nil)
  15.         )
  16.         (t (setq *DCLID* nil))
  17.   )
  18.   *DCLID*
  19. )
  20. (Defun vldcl-update (id val / data)
  21. ;;; update *DCL-DATA*
  22.   (if (setq data (cdr (assoc id *DCL-DATA*)))
  23.     (setq data             (subst (cons 1 val) (assoc 1 data) data)
  24.           *DCL-DATA* (subst (cons id data) (assoc id *DCL-DATA*) *DCL-DATA*)
  25.     )
  26.   )
  27. )
  28. (Defun vldcl-update2 (key val)
  29. ;;; UPdate *DCL-DONEDIALOG*
  30.   (if (null (cdr (assoc val *DCL-DONEDIALOG*)))
  31.     (setq *DCL-DONEDIALOG* (cons (cons val key) *DCL-DONEDIALOG*))
  32.     (setq *DCL-DONEDIALOG*
  33.            (subst (cons val key)
  34.                   (assoc val *DCL-DONEDIALOG*)
  35.                   *DCL-DONEDIALOG*
  36.            )
  37.     )
  38.   )
  39.   (action_tile key (strcat "(done_dialog " (itoa val) ")"))
  40. )
  41. (Defun vldcl-getvalue (key / rtn)
  42.   (setq rtn (cdr (assoc 1 (cdr (assoc key *DCL-DATA*)))))
  43.   (if (/= (type rtn) 'STR)
  44.     (setq rtn "")
  45.   )
  46.   rtn
  47. )
  48. (Defun vldcl-samestrlen        (str proto char / ipro ist rtn)
  49.   (setq        istr (strlen str)
  50.         ipro (strlen proto)
  51.         rtn  str
  52.   )
  53.   (if (> istr ipro)
  54.     (setq rtn (substr str 1 ipro))
  55.     (repeat (- ipro istr)
  56.       (setq rtn (strcat rtn char))
  57.     )
  58.   )
  59.   rtn
  60. )
  61. (Defun vldcl-settile (/ data key ktype kval kpval item)
  62.   (foreach data        *DCL-DATA*
  63.     (setq key        (car data)
  64.           data        (cdr data)
  65.           ktype        (cdr (assoc 0 data))
  66.           kval        (cdr (assoc 1 data))
  67.           kpval        (cdr (assoc 2 data))
  68.     )
  69.     (cond
  70.       ((= ktype "edit_box")
  71.        (cond
  72.          ((= kpval ":INT")
  73.           (vldcl-editbox-int key kval)
  74.           (action_tile key "(vldcl-editbox-int $key $value)")
  75.          )
  76.          ((= kpval ":REAL")
  77.           (vldcl-editbox-real key kval)
  78.           (action_tile key "(vldcl-editbox-real $key $value)")
  79.          )
  80.          (vldcl-editbox-string key kval)
  81.          (t (action_tile key "(vldcl-editbox-string $key $value)"))
  82.        )
  83.       )
  84.       ((= ktype "toggle")
  85.        (vldcl-toggle key kval)
  86.        (action_tile key "(vldcl-toggle $key $value)")
  87.       )
  88.       ((= ktype "button")
  89.        (if (> kval 1)
  90.          (vldcl-update2 key kval)
  91.        )
  92.        (if (< kval 0)
  93.          (action_tile key kpval)
  94.        )
  95.        (if (> kval 1)
  96.          (progn
  97.            (setq done (list kval key kpval))
  98.            (if (null (cdr (assoc kval *DCL-DONEDIALOG*)))
  99.              (setq *DCL-DONEDIALOG*
  100.                     (cons done
  101.                           *DCL-DONEDIALOG*
  102.                     )
  103.              )
  104.              (setq *DCL-DONEDIALOG*
  105.                     (subst
  106.                       done
  107.                       (assoc kval *DCL-DONEDIALOG*)
  108.                       *DCL-DONEDIALOG*
  109.                     )
  110.              )
  111.            )
  112.          )
  113.        )
  114.       )
  115.       ((= ktype "radio_button")
  116.        (vldcl-radio key kval)
  117.        (foreach        item kpval
  118.          (action_tile
  119.            item
  120.            (strcat "(vldcl-radio \042" key "\042 $key)")
  121.          )
  122.        )
  123.       )
  124.     )
  125.   )
  126. )
  127. (Defun vldcl-list (key data index)
  128.   (start_list key)
  129.   (mapcar 'add_list data)
  130.   (end_list)
  131.   (set_tile key index)
  132. )
  133. (Defun vldcl-button (key / func)
  134.   (if (eval (read (setq func (strcat "action_" key))))
  135.     (eval (read (strcat "(" func ")")))
  136.   )
  137. )
  138. (Defun vldcl-radio (key val / gray keyx mode item func)
  139.   (set_tile key val)
  140.   (vldcl-update key val)
  141.   (if (setq gray (cdr (assoc 3 (cdr (assoc key *DCL-DATA*)))))
  142.     (progn
  143.       (setq keyx (nth 0 gray)
  144.             gray (nth 1 gray)
  145.       )
  146.       (if (member val keyx)
  147.         (setq mode 1)
  148.         (setq mode 0)
  149.       )
  150.       (foreach item gray
  151.         (mode_tile item mode)
  152.       )
  153.     )
  154.   )
  155.   (if (eval (read (setq func (strcat "action_" val))))
  156.     (eval (read (strcat "(" func ")")))
  157.   )
  158. )
  159. (Defun vldcl-toggle (key val / keyx func)
  160.   (set_tile key val)
  161.   (vldcl-update key val)
  162.   (foreach keyx        (cdr (assoc 3 (cdr (assoc key *DCL-DATA*))))
  163.     (mode_tile keyx (abs (1- (read val))))
  164.   )
  165.   (if (eval (read (setq func (strcat "action_" key))))
  166.     (eval (read (strcat "(" func ")")))
  167.   )
  168. )
  169. (Defun vldcl-editbox-int (key val1 / val0 func)
  170.   (setq        val0 (vldcl-getvalue key)
  171.         val1 (get_tile key)
  172.   )
  173.   (if (/= (itoa (read val1)) val1)
  174.     (set_tile key val0)
  175.     (vldcl-update key val1)
  176.   )
  177.   (if (eval (read (setq func (strcat "action_" key))))
  178.     (eval (read (strcat "(" func ")")))
  179.   )
  180. )
  181. (Defun vldcl-editbox-real (key val1 / val0 func)
  182.   (setq        val0 (vldcl-getvalue key)
  183.         val1 (get_tile key)
  184.   )
  185.   (if (null (numberp (read val1)))
  186.     (set_tile key val0)
  187.     (vldcl-update key val1)
  188.   )
  189.   (if (eval (read (setq func (strcat "action_" key))))
  190.     (eval (read (strcat "(" func ")")))
  191.   )
  192. )
  193. (Defun vldcl-editbox-string (key val / func)
  194.   (vldcl-update key val)
  195.   (if (eval (read (setq func (strcat "action_" key))))
  196.     (eval (read (strcat "(" func ")")))
  197.   )
  198. )
  199. (Defun vldcl-graytile (keys val / key)
  200.   (foreach key keys
  201.     (mode_tile key val)
  202.   )
  203. )
  204. (Defun vldcl-actiontile        (/ id done key)
  205.   (foreach done        *DCL-DONEDIALOG*
  206.     (setq id  (nth 0 done)
  207.           key (nth 1 done)
  208.     )
  209.     (action_tile key (strcat "(done_dialog " (itoa id) ")"))
  210.   )
  211. )
  212. (Defun vldcl-donedialog        (/ key)
  213.   (if (setq key (cdr (assoc *DCLRTN* *DCL-DONEDIALOG*)))
  214.     (if        (eval (read (setq key (nth 1 key))))
  215.       (eval (read key))
  216.     )
  217.   )
  218. )


  219. (Defun c:xx (/                     *DCLID*             *DCL-DATA*
  220.              *DCL-DONEDIALOG*                     *DCLRTN*
  221.              action_pickx    action_picky
  222.             )
  223.   (defun action_pickx ()
  224.     (getstring "\n Close dialog to enter string:")
  225.   )
  226.   (defun action_picky ()
  227.     (alert "SDfsdg")
  228.   )

  229.   (setq        *DCL-DATA*
  230.          (list
  231.            (cons "DistX"
  232.                  (list (cons 0 "edit_box") (cons 1 "0.0") (cons 2 ":REAL"))
  233.            )
  234.            (cons "DistY"
  235.                  (list (cons 0 "edit_box") (cons 1 "0.0") (cons 2 ":REAL"))
  236.            )
  237.            (cons "ToggleAttribute"
  238.                  (list (cons 0 "toggle") (cons 1 "1"))
  239.            )
  240.            (cons "ToggleDefault"
  241.                  (list (cons 0 "toggle")
  242.                        (cons 1 "1")
  243.                        (cons 3 (list "help"))
  244.                  )
  245.            )
  246.            (cons "ToggleRow2Col"
  247.                  (list (cons 0 "toggle")
  248.                        (cons 1 "1")
  249.                        (cons 3 (list "help"))
  250. ;;; Gray tiles
  251.                  )
  252.            )
  253.            (cons
  254.              "RadioX"
  255.              (list (cons 0 "radio_button")
  256.                    (cons 1 "AutoX")
  257.                    (cons 2 (list "AutoX" "UserX" "IgnoreX" "PickX"))
  258.                    (cons 3
  259.                          (list (list "AutoX" "IgnoreX") (list "DistX" "PickX"))
  260.                    )
  261. ;;; Gray tiles
  262.              )
  263.            )
  264.            (cons
  265.              "RadioY"
  266.              (list (cons 0 "radio_button")
  267.                    (cons 1 "AutoY")
  268.                    (cons 2 (list "AutoY" "UserY" "IgnoreY" "PickY"))
  269.                    (cons 3
  270.                          (list (list "AutoY" "IgnoreY") (list "DistY" "PickY"))
  271.                    )
  272. ;;; Gray tiles
  273.              )
  274.            )
  275.            (cons "PickX"
  276.                  (list (cons 0 "button")
  277.                        (cons 1 2)
  278.                        (cons 2 "(action_pickx)")
  279.                  )
  280.            )
  281.            (cons "PickY"
  282.                  (list (cons 0 "button")
  283.                        (cons 1 -1)
  284.                        (cons 2 "(action_picky)")
  285.                  )
  286.            )

  287.          )
  288.         *DCLRTN* 10
  289.   )
  290.   (while (> *DCLRTN* 0)
  291.     (vldcl-init "g:/test.dcl" "Main")
  292.     (vldcl-settile)
  293.     (vldcl-actiontile)
  294.     (setq *DCLRTN* (start_dialog))
  295.     (vldcl-donedialog)
  296.     (alert "end")
  297.     (vldcl-init nil nil)
  298.   )
  299. ;;;(get data from *DCL-DATA* and run orther operations/functions
  300. )
  301. (c:xx)


  302. ;| DCL files
  303. dcl_settings : default_dcl_settings { audit_level=0; }
  304. Main : dialog {
  305.       label="[KozMos OASis-XLS/VTM]: 设定" ;
  306.       : boxed_row {        
  307.          label="虚拟表格文本行列分隔设定" ;
  308.          : boxed_radio_column {
  309.             key="RadioX" ;
  310.             label="X方向[列]" ;
  311.             : radio_button {
  312.                key="AutoX" ;
  313.                label="自动检测" ;
  314.             }
  315.             : radio_button {
  316.                key="IgnoreX" ;
  317.                label="忽略列分隔" ;
  318.             }
  319.             : radio_button {
  320.                key="UserX" ;
  321.                label="用户指定" ;
  322.             }
  323.             : button {
  324.                key="PickX" ;
  325.                label="点取距离 <" ;
  326.             }
  327.             : edit_box {
  328.                key="DistX" ;
  329.                label="X:" ;
  330.             }
  331.          }
  332.          : boxed_radio_column {
  333.             key="RadioY" ;
  334.             label="Y方向[行]" ;
  335.             : radio_button {
  336.                key="AutoY" ;
  337.                label="自动检测" ;
  338.             }
  339.             : radio_button {
  340.                key="IgnoreY" ;
  341.                label="忽略行分隔" ;
  342.             }
  343.             : radio_button {
  344.                key="UserY" ;
  345.                label="用户指定" ;
  346.             }
  347.             : button {
  348.                key="PickY" ;
  349.                label="点取距离 <" ;
  350.             }
  351.             : edit_box {
  352.                key="DistY" ;
  353.                label="Y:" ;
  354.             }
  355.          }
  356.       }
  357.       : row {
  358.          : boxed_column {
  359.             label="虚拟表格文本高级设定" ;
  360.             : toggle {
  361.                key="ToggleAttribute" ;
  362.                label="允许编辑块内属性" ;
  363.             }
  364.             : toggle {
  365.                key="ToggleDefault" ;
  366.                label="保存当前设定为缺省" ;
  367.             }
  368.             : toggle {
  369.                key="ToggleRow2Col" ;
  370.                label="转化单行为单列" ;
  371.             }
  372.             : button {
  373.                key="SortPoint" ;
  374.                label="分隔定位点..." ;
  375.             }
  376.          }
  377.          : boxed_column {
  378.             label="操作命令";
  379.             : button {
  380.                key="help" ;
  381.                label="帮助..." ;
  382.             }
  383.             : button {
  384.                key="accept" ;
  385.                label="选择实体 <" ;
  386.                is_default=true ;
  387.             }
  388.             : button {
  389.                key="cancel" ;
  390.                label="取消" ;
  391.                is_cancel=true ;
  392.             }
  393.          }
  394.       }      
  395.       errtile ;
  396.    }
  397. Sort : dialog {
  398.    label="[KozMos OASis-XLS/VTM]: 文本定位点" ;
  399.    : image {
  400.       color=white ;
  401.       key="Image" ;
  402.       width=15 ;
  403.       height=6 ;
  404.    }
  405.    : text {
  406.       label="蓝色矩形框表示文本范围框";
  407.    }
  408.    : boxed_row {
  409.       label="计算文本分隔使用定位点" ;
  410.       : boxed_radio_column {
  411.          key="SortX" ;
  412.          label="水平方向[X]" ;
  413.          : radio_button {
  414.             key="Left" ;
  415.             label="左" ;
  416.          }
  417.          : radio_button {
  418.             key="Center" ;
  419.             label="中" ;
  420.          }
  421.          : radio_button {
  422.             key="Right" ;
  423.             label="右" ;
  424.          }
  425.       }
  426.       : boxed_radio_column {
  427.          key="SortY" ;
  428.          label="垂直方向[Y]" ;
  429.          : radio_button {
  430.             key="Upper" ;
  431.             label="上" ;
  432.          }
  433.          : radio_button {
  434.             key="Middle" ;
  435.             label="中" ;
  436.          }
  437.          : radio_button {
  438.             key="Lower" ;
  439.             label="下" ;
  440.          }
  441.       }
  442.    }
  443.    ok_cancel;
  444.    errtile;
  445. }
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-1-18 21:02:21 | 显示全部楼层
好文居然没人顶?
支持一下。
以后慢慢消化,3q
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2004-1-18 21:15:46 | 显示全部楼层
通用对话框?下了再看。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 22:38 , Processed in 0.170315 second(s), 36 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表