TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: well20152016 on January 16, 2018, 12:09:12 PM

Title: dcl No alignment
Post by: well20152016 on January 16, 2018, 12:09:12 PM
(defun LM:PadBetween ( s1 s2 ch ln )
    (if (< (+ (strlen s1) (strlen s2)) ln)
        (LM:PadBetween (strcat s1 ch) s2 ch ln)
        (strcat s1 s2)
    )
)

(defun c:test()
 (setq lst (list "asd" "该i家" "该i家该i家" "该i家家"))
;;;  (setq lst (list "asd" "dhfdd" "dfaxcghh" "yyyxx"))
 (setq  lst (mapcar '(lambda (x) (list x (itoa (strlen x)))) lst)
   nn  (+ 10 (apply 'max (mapcar '(lambda (x) (strlen (strcat (car x)) (cadr x))) lst)))
        str (mapcar '(lambda (x) (princ "\n")(princ (LM:PadBetween (car x) (cadr x) " " nn))) lst))
 (if (> (setq dcl_id (load_dialog "test.DCL")) 0)
  (progn
  (if (new_dialog "test" dcl_id) (progn
 
   (MTL:DCL-addlist "lll" str  0)
   (setq ok (start_dialog))
  ) )
  (unload_dialog dcl_id)
 ) )
(princ))
Title: Re: dcl No alignment
Post by: roy_043 on January 16, 2018, 12:36:03 PM
Try setting the fixed_width_font attribute of the list_box tile to true.
Title: Re: dcl No alignment
Post by: VovKa on January 16, 2018, 12:43:53 PM
non ascii characters are hard to deal with
just use "\t" as a delimiter and set "tabs" attribute in your dcl
Title: Re: dcl No alignment
Post by: kpblc on January 17, 2018, 12:16:15 AM
VovKa, could you show an example of using 'tabs'? I tried to use '\t' at popup_list and list_box, but i didn't see the correct result. Thanks.
Title: Re: dcl No alignment
Post by: VovKa on January 17, 2018, 05:03:54 AM
VovKa, could you show an example of using 'tabs'? I tried to use '\t' at popup_list and list_box, but i didn't see the correct result. Thanks.
if the problem is that columns with numbers are not aligned to the right then "tabs" will not fix that issue
Code: [Select]
test:dialog {
    label = "test" ;
    :column {
        :list_box {
            key = "lll" ;
            width = 30 ;
            tabs = "10 14";
            tab_truncate = true;
        }
        cancel_button;
    }
}

Code: [Select]
(defun c:test ()
  (setq lst (list "1\t10\t100" "10\t100\t1000" "100\t1000\t10000""1000\t10000\t100000"))
  (if (> (setq dcl_id (load_dialog "test.DCL")) 0)
    (progn (if (new_dialog "test" dcl_id)
     (progn (start_list "lll")
    (mapcar 'add_list lst)
    (end_list)
    (setq ok (start_dialog))
     )
   )
   (unload_dialog dcl_id)
    )
  )
)
Title: Re: dcl No alignment
Post by: Lee Mac on January 17, 2018, 08:01:42 AM
Here (http://lee-mac.com/batte.html) is an example of an application which uses tabs to align list box records into columns, without using a fixed width font.
Title: Re: dcl No alignment
Post by: kpblc on January 17, 2018, 01:35:12 PM
Jesus! Thank you, guys! You make my life comfortable!
Title: Re: dcl No alignment
Post by: well20152016 on January 17, 2018, 07:35:59 PM
Thank you, Friends!
Title: Re: dcl No alignment
Post by: ronjonp on January 17, 2018, 08:35:56 PM
Thanks here too. Cleaned up my filter routine dialog quite a bit. ( based on MP's getvlaatoms )  I definitely stand on the shoulders of giants.  :yes:

Title: Re: dcl No alignment
Post by: Rod on January 17, 2018, 11:19:26 PM
Hey Ron,

any room up there on the shoulders?

Care to share your filter selection by?

Cheers, Rod
Title: Re: dcl No alignment
Post by: ronjonp on January 18, 2018, 09:57:47 AM
Sure ... I'll need to do a bit of housecleaning on the code first though.
Title: Re: dcl No alignment
Post by: Lee Mac on January 18, 2018, 01:25:06 PM
Looks good Ron  :-)
Title: Re: dcl No alignment
Post by: ronjonp on January 18, 2018, 02:20:20 PM
Looks good Ron  :)
Thanks!  :)