Is it possible to edit the code to allow multiple independent columns to be displayed?
I'll post a picture to describe what I mean
;|
Thank you for supporting this "HP:BUTTONS.lsp" DCL library.
This routine allows you to create DCL with multiple buttons associated to DCL action_tile list on the fly.
It creates DCL box with single column x nRows of buttons, 'n' depends on the length of the 'action list'
usage:
(hp:buttons title msg lst width ht)
title = Name caption on top of DCL - string
msg = header or blank "" - string
lst = quoted list or progn list - list
width = Width of the dialod box - integer
ht = height of each button - integer
returns nil or any execution (progn ... ) related to action_tile
Save this file into your support folder, append to your startup autoload routine.
In order to optimize the user experience, it allows maxinum 15 rows however you can abjust depends on screen size.
HP:BUTTONS - v1.0.1
Free LISP by - hanhphuc
email: hanhphuc.diy@outlook.com
|;
(defun hp:buttons ( title msg lst width ht / *error* dcl dd f fn ht i l wd)
(defun *error* (msg) (if f (close f))(if fn (vl-file-delete fn)) )
(if (and
(setq wd (* width 0.8)
l (apply 'mapcar (cons 'list lst))
)
(< (length l) 15 ) ; <<--------------- 15 limited max Row ad just is you have bigger screen
(setq fn (vl-filename-mktemp nil nil ".dcl"))
(setq f (open fn "w"))
)
(progn
(setq i 0)
(foreach str
(append
(list
(strcat "dcl_button : dialog { label = \" "
title
" \"; width = "
(rtos width 2 2)
"; fixed_width = true;"
)
(strcat ": text { value = \"" msg "\"; alignment = left; }" )
": boxed_column { alignment = left ;children_alignment = left ;"
)
(mapcar
'(lambda ($)
(strcat
": button { label = \" "
$
" \"; key = \"key"
(itoa (setq i (1+ i)))
"\" ;width = "
(rtos wd 2 2)
"; fixed_width = true; height = "
(rtos ht 2 2)
"; fixed_height = true; alignment = centered; }"
)
)
(car l)
)
(list
"spacer_1; "
"}"
"ok_only ;}"
)
)
(write-line str f)
)
(close f)
)
(alert "Failed ! ")
)
(if (and (>= (setq dcl (load_dialog fn)) 0)
(new_dialog "dcl_button" dcl)
)
(progn
(setq i 0)
(repeat (1+ (length lst))
(action_tile
(strcat "key" (itoa (setq i (1+ i))))
"(done_dialog (atoi (substr $key 4)))"
)
)
(action_tile
"accept"
"(done_dialog)"
)
(if (not (zerop (setq dd (start_dialog))))
(or
(eval (nth (1- dd) (cadr l)))
(done_dialog)
)
)
(unload_dialog dcl)
)
(unload_dialog dcl)
)
(if fn (vl-file-delete fn))
(princ)
)
;;example :
(defun c:demo ( / lst )
;list format list must be quoted '((<text1> <Expression1>)(<text2> <Expression2 >) etc.. )
; <text> is caption on the button
(setq lst
'(("Test routine" (progn (alert "Test") (textscr)))
("Calculator" (startapp "CALC"))
("Control panel" (startapp "CONTROL"))
("Paint brush" (command "START" "PBRUSH"))
("Temp folder" (command "_START" (strcat (getvar 'tempprefix))))
("Options" (command "+OPTIONS" 6))
("Object snap" (command "+DSETTINGS" 2))
("Appload" (command "_APPLOAD"))
("VLISP" (C:VLIDE))
("Notepad" (startapp "NOTEPAD"))
("Excel" (command "_START" "EXCEL"))
("Google" (command "_BROWSER" "https://www.google.com"))
("DOS mode" (command "_START" "CMD"))
("Registry" (command "_START" "REGEDIT"))
("Help"
(command
"_BROWSER"
"https://www.cadtutor.net/forum/forum/15-autolisp-visual-lisp-amp-dcl/"
)
)
)
)
;;supply parameters in the routine
(hp:buttons
"Example apps" ;title
"hanhphuc" ;header
lst ;list
20 ;dialog width
1.5 ;button height
)
(princ)
)
Thanks