Jump to content

DCL Questions


WPerciful

Recommended Posts

I have 2 questions about a dialog box I wrote.

1. The drop down boxes aren’t wide enough to display all of the text. How do I fix this?

2. Currently in order to select a second line in the list box you have to hold down the shift key. How can I change it so that the selections remain selected without holding down the control key?

 

The command that luanches the dcl

(defun c:bprint ( / )
(setq retlist1 nil)
;;;	 lm:directorydialog
;;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;;
(setq thedirectory (lm:directorydialog "Select folder: " nil 0)) 
(if (/= thedirectory nil)
	(setq List1 (vl-directory-files thedirectory "*.dwg"))
	end
)
(setq List2 (list ""))
(batch thedirectory List1 List2)
(if (/= retlist1 nil)
	(progn
		(if (/= (findfile "BPlotData.txt") nil)
			(setq filedata 
				(readfile 
					(findfile "BPlotData.txt")
				)
				files (cdr filedata)
				batchplotfiles (list )
			)
		)
		(foreach file files
			(setq batchplotfiles
				(append batchplotfiles
					(list 
						(strcat "open \"" thedirectory "\\" file "\"  (mybatchprint) ZOOM E close Y")
					)
				)
			)
		)
		(makefile 
			(strcat
				(strcat "C:\\Users\\" (getvar "loginname") "\\Documents")
				"\\"
				"BatchPlot.scr"
			)
			batchplotfiles
		)
		(command "_.script" 
			(strcat "C:\\Users\\" (getvar "loginname") "\\Documents\\BatchPlot.scr")
		)
	)
)	
)

 

The function the runs the dcl

(defun batch ( mydir lista listb / prin )
(setq dir mydir
	poplist1 (list )
	mylist1 lista
	mylist2 listb
)
(setq poplist1 (getplotters)
	poplist2 (getplotstyles)
)
(if (not (setq dcl_id (load_dialog "batch.dcl")))
	(progn
		(alert "The DCL file could not be loaded!")
		(exit)
	)
	(progn
		(if (not (new_dialog "batch" dcl_id))
			(progn
				(alert "The BATCH definition could not be loaded!")
				(exit)
			)
			(progn
				
				(start_list "poplist1" 3)
				(mapcar 'add_list poplist1)
				(end_list)

				(start_list "poplist2" 3)
				(mapcar 'add_list poplist2)
				(end_list)
				
				(start_list "mylist1" 3)
				(mapcar 'add_list mylist1)
				(end_list)
				
				(action_tile "pickdir" " (setq pickdir \"Yes\")(done_dialog 1)")
				(action_tile "accept" "(saveVars)(done_dialog 2)")
				(action_tile "cancel" "(done_dialog 3)")
				
				(setq ddiag (start_dialog))
				
				(unload_dialog dcl_id)
				
				
				(if (= ddiag 1)
					(princ "\nSelect directory . . . ")
				)
				
				(if (= ddiag 2)
					(princ "\nPlease wait. . . ")
				)
				
				(if (= ddiag 3)
					(princ "\nBatch print has been cancelled! ")
				)
			)
		)
	)
)
(princ)
)

 

 

The DLC code

batch
: dialog
{
:	boxed_column
{
	: row 
	{
		: popup_list
		{
			label ="Choose printer";
			key = "poplist1";
			height = 15;
			width = 30;
			multiple_select = true;
			fixed_width_font = true;
			value = "0";
		}
	}
	: row 
	{
		: popup_list
		{
			label ="Choose plot style table";
			key = "poplist2";
			height = 15;
			width = 30;
			multiple_select = true;
			fixed_width_font = true;
			value = "0";
		}
	}
	: list_box
	{
		label ="Choose Item";
		key = "mylist1";
		height = 15;
		width = 25;
		multiple_select = true;
		fixed_width_font = true;
		value = "";
	}
	: row 
	{ 
		: button 
		{ 
			key = "accept";
			label = " Print ";
			is_default = true;
		}  
		: button 
		{ 
			key = "cancel";
			label = " Cancel ";
			is_default = false;
			is_cancel = true;
		}
	}
}
}

Link to comment
Share on other sites

On question 2,

 

That behaviour is the standard way to select in a listbox.

 

It is hardcoded into the listbox, short of writing your own

it would be difficult to change and certainly not advisable.

 

ymg

Link to comment
Share on other sites

To increase the width of the DCL file , just add the attribute width = 66 ; any number you'd prefer at the top of the file and after the first bracket but do not go more than one hundred or so .

To avoid the multiple selection with the control button , just remove the attribute multiple_select = true; from the list box .

 

Note : also remove the multiple_select attribute from the popup_list since the previously attribute is not supported in popup_list .

Link to comment
Share on other sites

To avoid the multiple selection with the control button

 

Tharwat,

 

I don't know if I misunderstood, but I believe what WPerciful wants is to be able to select multiple but without pressing Control or Shift.

 

ymg

Link to comment
Share on other sites

Tharwat,

 

I don't know if I misunderstood, but I believe what WPerciful wants is to be able to select multiple but without pressing Control or Shift.

 

ymg

 

Let's wait for the OP's response :)

Link to comment
Share on other sites

Tharwat,

 

I don't know if I misunderstood, but I believe what WPerciful wants is to be able to select multiple but without pressing Control or Shift.

 

ymg

 

Yes.

 

To increase the width of the DCL file , just add the attribute width = 66 ; any number you'd prefer at the top of the file and after the first bracket but do not go more than one hundred or so .

To avoid the multiple selection with the control button , just remove the attribute multiple_select = true; from the list box .

 

Not sure I understand where to change that at.

Edited by WPerciful
Spelling
Link to comment
Share on other sites

Not sure I understand where to change that at.

 

For the width, as Tharwat told you, at Top of File (See example in code windows below)

 

For the multiple selections, better forget this one. It is always a bad idea to go against

standard interfaces.

 

ymg

 

batch
: dialog{
       width = 66;
:	boxed_column
{
	: row 
	{
		: popup_list
		{
			label ="Choose printer         ";
			key = "poplist1";
			height = 15;
			width = 30;
			multiple_select = true;
			fixed_width_font = true;
			value = "0";
		}
	}

Link to comment
Share on other sites

2. Currently in order to select a second line in the list box you have to hold down the shift key. How can I change it so that the selections remain selected without holding down the control key?

 

It's possible, but you have to roll your own...

 

[color=GREEN];; Multiple list box selection without the use of CTRL / SHIFT  -  Lee Mac[/color]
[color=GREEN];; For academic purposes only; not for use in a commercial application.[/color]

([color=BLUE]defun[/color] c:example ( [color=BLUE]/[/color] *error* cnt dch dcl des sel )

   ([color=BLUE]defun[/color] *error* ( msg )
       ([color=BLUE]if[/color] ([color=BLUE]=[/color] 'file ([color=BLUE]type[/color] des))
           ([color=BLUE]close[/color] des)
       )
       ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 dch)
           ([color=BLUE]unload_dialog[/color] dch)
       )
       ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 'str ([color=BLUE]type[/color] dcl)) ([color=BLUE]setq[/color] dcl ([color=BLUE]findfile[/color] dcl)))
           ([color=BLUE]vl-file-delete[/color] dcl)
       )
       ([color=BLUE]if[/color] ([color=BLUE]and[/color] msg ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg [color=BLUE]t[/color]) [color=MAROON]"*break,*cancel*,*exit*"[/color])))
           ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nError: "[/color] msg))
       )
       ([color=BLUE]princ[/color])
   )
   
   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] dcl ([color=BLUE]vl-filename-mktemp[/color] [color=BLUE]nil[/color] [color=BLUE]nil[/color] [color=MAROON]".dcl"[/color]))
           ([color=BLUE]setq[/color] des ([color=BLUE]open[/color] dcl [color=MAROON]"w"[/color]))
           ([color=BLUE]foreach[/color] x
              '(
                   [color=MAROON]"tmp : dialog"[/color]
                   [color=MAROON]"{"[/color]
                   [color=MAROON]"    label = \"List Box Example\";"[/color]
                   [color=MAROON]"    spacer;"[/color]
                   [color=MAROON]"    : list_box"[/color]
                   [color=MAROON]"    {"[/color]
                   [color=MAROON]"        key = \"lst\";"[/color]
                   [color=MAROON]"        width = 45;"[/color]
                   [color=MAROON]"        height = 20;"[/color]
                   [color=MAROON]"        fixed_width = true;"[/color]
                   [color=MAROON]"        fixed_height = true;"[/color]
                   [color=MAROON]"        multiple_select = true;"[/color]
                   [color=MAROON]"    }"[/color]
                   [color=MAROON]"    spacer;"[/color]
                   [color=MAROON]"    ok_only;"[/color]
                   [color=MAROON]"}"[/color]
               )
               ([color=BLUE]write-line[/color] x des)
           )
           ([color=BLUE]not[/color] ([color=BLUE]setq[/color] des ([color=BLUE]close[/color] des)))
           ([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] dch ([color=BLUE]load_dialog[/color] dcl)))
           ([color=BLUE]new_dialog[/color] [color=MAROON]"tmp"[/color] dch)
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]start_list[/color] [color=MAROON]"lst"[/color])
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] cnt 15)
               ([color=BLUE]add_list[/color] ([color=BLUE]strcat[/color] [color=MAROON]"Item Number "[/color] ([color=BLUE]itoa[/color] ([color=BLUE]-[/color] 15 ([color=BLUE]setq[/color] cnt ([color=BLUE]1-[/color] cnt))))))
           )
           ([color=BLUE]end_list[/color])
           ([color=BLUE]setq[/color] sel ([color=BLUE]set_tile[/color] [color=MAROON]"lst"[/color] [color=MAROON]"0"[/color]))
           ([color=BLUE]action_tile[/color] [color=MAROON]"lst"[/color]
               ([color=BLUE]vl-prin1-to-string[/color]
                  '(
                       ([color=BLUE]lambda[/color] ( a b [color=BLUE]/[/color] tmp )
                           ([color=BLUE]set_tile[/color] [color=MAROON]"lst"[/color] [color=MAROON]""[/color])
                           ([color=BLUE]setq[/color] sel
                               ([color=BLUE]if[/color]
                                   ([color=BLUE]setq[/color] tmp
                                       ([color=BLUE]vl-remove-if[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]and[/color] ([color=BLUE]member[/color] x a) ([color=BLUE]member[/color] x b)))
                                           ([color=BLUE]append[/color] a b)
                                       )
                                   )
                                   ([color=BLUE]set_tile[/color] [color=MAROON]"lst"[/color]
                                       ([color=BLUE]vl-string-trim[/color] [color=MAROON]"()"[/color]
                                           ([color=BLUE]vl-princ-to-string[/color] ([color=BLUE]vl-sort[/color] tmp '[color=BLUE]<[/color]))
                                       )
                                   )
                               )
                           )
                       )
                       ([color=BLUE]read[/color] ([color=BLUE]strcat[/color] [color=MAROON]"("[/color] ([color=BLUE]cond[/color] (sel) ([color=MAROON]""[/color])) [color=MAROON]")"[/color]))
                       ([color=BLUE]read[/color] ([color=BLUE]strcat[/color] [color=MAROON]"("[/color] $value [color=MAROON]")"[/color]))
                   )
               )
           )            
           ([color=BLUE]start_dialog[/color])
       )
   )
   (*error* [color=BLUE]nil[/color])
   ([color=BLUE]princ[/color])
)

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...