Jump to content

How to Align text in DCL


rdx

Recommended Posts

DEAR ALL

How to Align text in DCL

 

;;;Temporary dialog box
   (setq f (open (setq tmpdcl (VL-FILENAME-MKTEMP "tmp" "" ".dcl")) "w"))
   (write-line "AutoLayer :dialog {" f)
   (write-line "    :row {" f)
   (write-line "        :toggle {" f)
   (write-line "            key = \"AutoSwitch\" ;" f)
   (write-line "            label = \"Enable automatic switching\" ;" f)
   (write-line "        }" f)
   (write-line "        :button {" f)
   (write-line "            key = \"Add\" ;" f)
   (write-line "            label = \"Add settings\" ;" f)
   (write-line "        }" f)
   (write-line "        :button {" f)
   (write-line "            key = \"Delete\" ;" f)
   (write-line "            label = \"Delet Settings\" ;" f)
   (write-line "        }" f)
   (write-line "        :button {" f)
   (write-line "            key = \"deleteall\" ;" f)
   (write-line "            label = \"Remove all\" ;" f)
   (write-line "        }" f)
   (write-line "    }" f)
   (write-line "    :list_box {" f)
   (write-line "        key = \"cmdlist\" ;" f)
   (write-line "        label = \"    Command            Layer               Color        Line type\" ;" f)
   (write-line "        width = 60 ;" f)
   (write-line "        height = 20 ;" f)
   (write-line "        multiple_select = true ;" f)
   (write-line "    }" f)
   (write-line "    :row {" f)
   (write-line "        :edit_box {" f)
   (write-line "            key = \"cmdstr\" ;" f)
   (write-line "            label = \"Command\" ;" f)
   (write-line "            width = 20 ;" f)
   (write-line "        }" f)
   (write-line "        :edit_box {" f)
   (write-line "            key = \"layerstr\" ;" f)
   (write-line "            label = \"Layers\" ;" f)
   (write-line "            width = 10 ;" f)
   (write-line "        }" f)
   (write-line "    :popup_list {" f)
   (write-line "        key = \"selectlayer\" ;" f)
   (write-line "        label = \"Select Layer\" ;" f)
   (write-line "        width = 20 ;" f)
   (write-line "    }" f)
   (write-line "    }" f)
   (write-line "    :row {" f)
   (write-line "        :edit_box {" f)
   (write-line "            fixed_width = true ;" f)
   (write-line "            is_enabled = false ;" f)
   (write-line "            key = \"color\" ;" f)
   (write-line "            label = \"Color\" ;" f)
   (write-line "            width = 1 ;" f)
   (write-line "        }" f)
   (write-line "        :image {" f)
   (write-line "            height = 1 ;" f)
   (write-line "            key = \"img\" ;" f)
   (write-line "            width = 2 ;" f)
   (write-line "        }" f)
   (write-line "        :button {" f)
   (write-line "            key = \"selectcolor\" ;" f)
   (write-line "            label = \"Select Color\" ;" f)
   (write-line "        }" f)
   (write-line "        :edit_box {" f)
   (write-line "            key = \"ltype\" ;" f)
   (write-line "            is_enabled = false ;" f)
   (write-line "            label = \"linetype\" ;" f)
   (write-line "            width = 20 ;" f)
   (write-line "        }" f)
   (write-line "        :button {" f)
   (write-line "            key = \"selectltype\" ;" f)
   (write-line "            label = \"Select Linetype\" ;" f)
   (write-line "        }" f)
   (write-line "    }" f)
   (write-line "     :row {" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         :button {" f)
   (write-line "             key = \"export\" ;" f)
   (write-line "             label = \"Save Template\" ;" f)
   (write-line "             width = 10 ;" f)
   (write-line "         }" f)
   (write-line "         :button {" f)
   (write-line "             key = \"import\" ;" f)
   (write-line "             label = \"Import Template\" ;" f)
   (write-line "             width = 10 ;" f)
   (write-line "         }" f)
   (write-line "         :button {" f)
   (write-line "             key = \"edit\" ;" f)
   (write-line "             label = \"Modify\" ;" f)
   (write-line "             width = 10 ;" f)
   (write-line "         }" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
   (write-line "         spacer_1;" f)
  (write-line "     }" f)
   (write-line "         ok_cancel_help_errtile;" f)
   ;(write-line "     }" f)
   (write-line "}" f)
   (close f)

Screenshot 2024-06-11 194112.png

Edited by rdx
Link to comment
Share on other sites

I tended to learn from AfraLISP  - SLW210 link.

 

For alignment you might want to consider a combination of row and column codes with a width setting.

 

This is for an example, taken from a grid DCL: an image, under that and lined up a text description, 'next' row is the same again (is actually row 3 because of the text description).

 

  (write-line "    :boxed_column { width = 25; alignment = top;" fo)
  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :image_button {key = Im0; width = 9; height = 5; color = dialog_background; allow_accept = true; alignment = centered;}}" fo)
  (write-line "        :column {width = 15; :image_button {key = Im1; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt0\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt1\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :image_button {key = Im4; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "        :column {width = 15; :image_button {key = Im5; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt4\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt5\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "    }" fo) ; end boxed column

 

 

In yours perhaps the 'command layer colour linetype' should also be split into 4 columns in a single row

 

 

 

It all becomes mental fun when you want columns and rows spanning multiple other rows and columns to get it all lining up.

 

Edited code for readability

Edited by Steven P
  • Thanks 1
Link to comment
Share on other sites

If the goal is making a DWT "export Template" why would you need to keep changing ? Would it not be just as easy to make a script file and edit that ?

 

In  a package we had correct layer linetype and color based on draw an object like a wall or a door etc, behind it was a text file with all the settings 91 different layers. The reason I mention it is that you must still be ridged in setting correct layer so we use menu options to force this. In this house every layer is correct as the set layer has been taken away from the end user. Of course you can still not use the inbuilt functions and draw on wrong layers but no automation.

3dhouse.thumb.png.956c430c8bae97125ce124cb8c0c41d0.png

 

For a recent client request, Text and Dims are in a menu so all objects drawn are to company standards. 

 

You could possibly do a reactor check for "HATCH" and set layer but don't have that code.

  • Like 2
Link to comment
Share on other sites

14 hours ago, Steven P said:

I tended to learn from AfraLISP  - SLW210 link.

 

For alignment you might want to consider a combination of row and column codes with a width setting.

 

This is for an example, taken from a grid DCL: an image, under that and lined up a text description, 'next' row is the same again (is actually row 3 because of the text description).

 

  (write-line "    :boxed_column { width = 25; alignment = top;" fo)
  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :image_button {key = Im0; width = 9; height = 5; color = dialog_background; allow_accept = true; alignment = centered;}}" fo)
  (write-line "        :column {width = 15; :image_button {key = Im1; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt0\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt1\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :image_button {key = Im4; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "        :column {width = 15; :image_button {key = Im5; width = 10; height = 7; color = dialog_background; allow_accept = true;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "      :row {alignment = top;" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt4\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "        :column {width = 15; :text { key = \"Txt5\"; label = \"Func.\"; width = 9;}}" fo)
  (write-line "      }" fo) ; end row

  (write-line "    }" fo) ; end boxed column

 

 

In yours perhaps the 'command layer colour linetype' should also be split into 4 columns in a single row

 

 

 

It all becomes mental fun when you want columns and rows spanning multiple other rows and columns to get it all lining up.

 

Edited code for readability

Dear Steven 

Thansk  sir following your method 

  • Like 2
Link to comment
Share on other sites

slightly off topic , it irritated me edit boxes are only left aligned so just for fun (app doesn't actually  do anything) :

 

image.png.0e88fe129eef83fdb3d7d7d168eddbce.png

 

;;; just for fun , center texts in editboxes - rlx jun'24

(defun c:jff ( / center-factor )
  (create_dialog)
  (princ)
)
;;;|-----------------------------------------------------------------------|
;;;| Just For Fun - Center text in editboxes - rlx jun-2024                |
;;;|-----------------------------------------------------------------------|
;;;|        editbox1                editbox2               editbox3        |
;;;| [                    ]  [                   ]  [                    ] |
;;;|                                                                       |
;;;|                       [ <-- ] [ done ] [ --> ]                        |
;;;|                                                                       |
;;;|-----------------------------------------------------------------------|

;;; dcl_jff input : m = message , l = label list , v = (default) values list
;;; (dcl_jff "Just For Fun - Center text in editboxes - rlx'24"
;;; '("editbox1" "editbox2" "editbox3") '("Dragons" "just wanna" "have fun"))
(defun dcl_jff (m l v / f p d r)
  (and
    (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w"))
    (write-line (strcat "dcl_jff:dialog {label=\"" m "\";:row {") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 0 l)
                        "\";}:edit_box {edit_width=24;key=\"eb1\";}}") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 1 l)
                        "\";}:edit_box {edit_width=24;key=\"eb2\";}}") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 2 l)
                        "\";}:edit_box {edit_width=24;key=\"eb3\";}}}spacer;") p)
    (write-line (strcat ":concatenation {alignment=centered;"
                        ":button {key=\"bt1\";label=\"" (nth 3 l) "\";} spacer;"
                        ":button {is_default=true;key=\"bt2\";label=\"" (nth 4 l) "\";}spacer;"
                        ":button {key=\"bt3\";label=\"" (nth 5 l) "\";}}}") p)
    (not (setq p (close p))) (< 0 (setq d (load_dialog f))) (new_dialog "dcl_jff" d)
    (mapcar '(lambda (x y)(set_tile x y)) '("eb1" "eb2" "eb3") v)
    (CenterEditboxStrings)
    (action_tile "bt1" "(Update_Edit_Box_Center_Factor 1)")
    (action_tile "bt2" "(setq r (list (get_tile \"eb1\")(get_tile \"eb2\")(get_tile \"eb3\")))(done_dialog 1)")
    (action_tile "bt3" "(Update_Edit_Box_Center_Factor 0)")
    (start_dialog)(unload_dialog d)  (vl-file-delete f)
  )
  r
)

(defun Update_Edit_Box_Center_Factor ( i / f )
  (if (null Center-Factor) (setq f 6) (setq f Center-Factor))
  (cond ((= i 1) (setq f (1+ f)))((= i 0) (setq f (1- f)))(t (setq f 1)))
  (if (< f 1)(setq f 1))
  (setq Center-Factor f)
  (CenterEditboxStrings)
)


(defun create_dialog ()
  (alert
    (vl-princ-to-string
      (dcl_jff
        "Just For Fun - Center text in editboxes - rlx'24"
        '("editbox1" "editbox2" "editbox3" " <--- " "Done" " ---> ")
        '("Dragons" "Just Wanna" "Have Fun")
      )
    )
  )
)

(defun CenTileText ($k / v x l) (if (null center-factor)(setq center-factor 6))
  (setq v (vl-string-trim " " (get_tile $k)) l (strlen v) x (fix (/ (dimx_tile $k) center-factor)))
    (if (< l x) (repeat (- x l)(setq v (strcat " " v)))) (set_tile $k v))

(defun CenterEditboxStrings ( / tl ) (setq tl '("eb1" "eb2" "eb3")) (foreach tile tl (CenTileText tile)))

(c:jff)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Posted (edited)
10 hours ago, BIGAL said:

If the goal is making a DWT "export Template" why would you need to keep changing ? Would it not be just as easy to make a script file and edit that ?

 

In  a package we had correct layer linetype and color based on draw an object like a wall or a door etc, behind it was a text file with all the settings 91 different layers. The reason I mention it is that you must still be ridged in setting correct layer so we use menu options to force this. In this house every layer is correct as the set layer has been taken away from the end user. Of course you can still not use the inbuilt functions and draw on wrong layers but no automation.

3dhouse.thumb.png.956c430c8bae97125ce124cb8c0c41d0.png

 

For a recent client request, Text and Dims are in a menu so all objects drawn are to company standards. 

 

You could possibly do a reactor check for "HATCH" and set layer but don't have that code.

DEAR SIR

thanks 

Edited by rdx
Link to comment
Share on other sites

3 hours ago, rlx said:

slightly off topic , it irritated me edit boxes are only left aligned so just for fun (app doesn't actually  do anything) :

 

image.png.0e88fe129eef83fdb3d7d7d168eddbce.png

 

;;; just for fun , center texts in editboxes - rlx jun'24

(defun c:jff ( / center-factor )
  (create_dialog)
  (princ)
)
;;;|-----------------------------------------------------------------------|
;;;| Just For Fun - Center text in editboxes - rlx jun-2024                |
;;;|-----------------------------------------------------------------------|
;;;|        editbox1                editbox2               editbox3        |
;;;| [                    ]  [                   ]  [                    ] |
;;;|                                                                       |
;;;|                       [ <-- ] [ done ] [ --> ]                        |
;;;|                                                                       |
;;;|-----------------------------------------------------------------------|

;;; dcl_jff input : m = message , l = label list , v = (default) values list
;;; (dcl_jff "Just For Fun - Center text in editboxes - rlx'24"
;;; '("editbox1" "editbox2" "editbox3") '("Dragons" "just wanna" "have fun"))
(defun dcl_jff (m l v / f p d r)
  (and
    (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w"))
    (write-line (strcat "dcl_jff:dialog {label=\"" m "\";:row {") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 0 l)
                        "\";}:edit_box {edit_width=24;key=\"eb1\";}}") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 1 l)
                        "\";}:edit_box {edit_width=24;key=\"eb2\";}}") p)
    (write-line (strcat ":column {children_alignment=centered;:text {label=\"" (nth 2 l)
                        "\";}:edit_box {edit_width=24;key=\"eb3\";}}}spacer;") p)
    (write-line (strcat ":concatenation {alignment=centered;"
                        ":button {key=\"bt1\";label=\"" (nth 3 l) "\";} spacer;"
                        ":button {is_default=true;key=\"bt2\";label=\"" (nth 4 l) "\";}spacer;"
                        ":button {key=\"bt3\";label=\"" (nth 5 l) "\";}}}") p)
    (not (setq p (close p))) (< 0 (setq d (load_dialog f))) (new_dialog "dcl_jff" d)
    (mapcar '(lambda (x y)(set_tile x y)) '("eb1" "eb2" "eb3") v)
    (CenterEditboxStrings)
    (action_tile "bt1" "(Update_Edit_Box_Center_Factor 1)")
    (action_tile "bt2" "(setq r (list (get_tile \"eb1\")(get_tile \"eb2\")(get_tile \"eb3\")))(done_dialog 1)")
    (action_tile "bt3" "(Update_Edit_Box_Center_Factor 0)")
    (start_dialog)(unload_dialog d)  (vl-file-delete f)
  )
  r
)

(defun Update_Edit_Box_Center_Factor ( i / f )
  (if (null Center-Factor) (setq f 6) (setq f Center-Factor))
  (cond ((= i 1) (setq f (1+ f)))((= i 0) (setq f (1- f)))(t (setq f 1)))
  (if (< f 1)(setq f 1))
  (setq Center-Factor f)
  (CenterEditboxStrings)
)


(defun create_dialog ()
  (alert
    (vl-princ-to-string
      (dcl_jff
        "Just For Fun - Center text in editboxes - rlx'24"
        '("editbox1" "editbox2" "editbox3" " <--- " "Done" " ---> ")
        '("Dragons" "Just Wanna" "Have Fun")
      )
    )
  )
)

(defun CenTileText ($k / v x l) (if (null center-factor)(setq center-factor 6))
  (setq v (vl-string-trim " " (get_tile $k)) l (strlen v) x (fix (/ (dimx_tile $k) center-factor)))
    (if (< l x) (repeat (- x l)(setq v (strcat " " v)))) (set_tile $k v))

(defun CenterEditboxStrings ( / tl ) (setq tl '("eb1" "eb2" "eb3")) (foreach tile tl (CenTileText tile)))

(c:jff)

 

dear sir

thanks 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...