[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2267.0. "Using DwtAttachedDB() and missing PushButtons?" by WPOMM2::ZAMBOTTI () Tue Feb 13 1990 20:28

Hi fellow guru techs,

I've written a simple XUI toolkit program that takes its input from stdin and
displays that input in a List Box and allows the user to select multilple
entries then finally if the user hits the OK Push Button his selections are
output to stdout.

This allows you to do some really neat things like :

        tar cv `ls -1 | select` # sorry VMS users

This command would allow you to "select" from a directory list the files that
you want to save to a tar.

Now my problem!  I have used the DwtDwtAttachDB(), DwtListBox() and two
DwtPushButton() widgets and have arranged them like so :

        +-Select------------------+
        |+---------------------+-+|
        ||                     |#||
        ||                     |#||
        ||       List Box      |#||
        ||                     |#||
        ||                     | ||
        ||                     | ||
        ||                     | ||
        ||                     | ||
        |+---------------------+-+|
        |+-----------++----------+|
        ||  CANCEL   ||    OK    ||
        |+-----------++----------+|
        +-------------------------+

Both buttons are attached to the top of the List Box and the bottom of the
(Attached) Dialog Box.  The cancel button is left attached to the Dialog Box
and is not right attached at all.  The ok button is right attached to the Dialog
x and left attached to the cancel button, like so :

        ||                       | ||
        |+-----------------------+-+|
        |      ^             ^      |
        | +----------+ +----------+ |
        |<|  CANCEL  +<|    OK    +>|
        | +----------+ +----------+ |
        |      v             v      |
        +---------------------------+

My problem is the attached dialog box does not correctly size itself when select
starts.  Both my buttons are hidden and I must resize the window in order to see
and use them.  When my application start I only see :

        +-Select------------------+
        |+---------------------+-+|
        ||                     |#||
        ||                     |#||
        ||       List Box      |#||
        ||                     |#||
        ||                     | ||
        ||                     | ||
        ||                     | ||
        ||                     | ||
        |+---------------------+-+|
        +-------------------------+

Is there some attachment or arguement I have missed ?  Or how do I just plainly
get my buttons to be displayed when select starts?

any help,

Walter Zambotti.
T.RTitleUserPersonal
Name
DateLines
2267.1Font Units or Pixel Units?EXLIB::DLUGOSZOpen foot, Insert MouthTue Feb 13 1990 20:5417
    Hi Walter,
    
    The default units for positioning within a dialog box are font units
    rather than pixels. If you specified the locations of the children
    assumming pixels, that's likley the problem.
    
    To use pixels instead of font units set DwtNunits to DwtPixelUnits
    (or units = DwtPixelUnits for UIL).
    
    To use the default font units you'll just have to rescale your 
    thinking a bit. An X font unit is 1/2 the width of the dialog
    boxes font (DwtNfont) and a Y font is 1/8 the width.
    
    Ron
    
                                                                      
    
2267.2Maybe but I don't think so !WPOMM2::ZAMBOTTITue Feb 13 1990 22:2850
Hi Ron,

I not sure I exactly follow your drift as I have used an Attached Dialog Box not
just a Dialog Box and all the positioning is described as relative to something
else such as a border or another widget.

I'll include the code fragment I used below :

    TopLevel = XtInitialize(Option.Name, "MainClass", NULL, 0, &ArgCnt, ArgList) ;

    WorkArea = DwtAttachedDB(TopLevel, "Select", FALSE, 0, 0, DwtLatin1String("Select"), DwtWorkarea, NULL, NULL) ;
    CancelButton = DwtPushButton(WorkArea, "Button1", 0, 0, DwtLatin1String("Cancel"), CancelButtonCallbacks, NULL) ;
    OKButton = DwtPushButton(WorkArea, "Button2", 0, 0, DwtLatin1String("OK"), OKButtonCallbacks, NULL) ;
    ListBox = DwtListBox(WorkArea, "List", 0, 0, ItemList, ItemCnt, Option.Lines, ListBoxCallbacks, NULL, FALSE, FALSE) ;
    XtSetArg(Args[0], DwtNsingleSelection, FALSE) ;
    XtSetValues(ListBox, Args, 1) ;

    XtSetArg(Args[0], DwtNadbTopAttachment, DwtAttachWidget) ;
    XtSetArg(Args[1], DwtNadbTopWidget, ListBox) ;
    XtSetArg(Args[2], DwtNadbTopOffset, 2) ;
    XtSetArg(Args[3], DwtNadbBottomAttachment, DwtAttachAdb) ;
    XtSetArg(Args[4], DwtNadbBottomOffset, 1) ;
    XtSetArg(Args[5], DwtNadbLeftAttachment, DwtAttachAdb) ;
    XtSetArg(Args[6], DwtNadbLeftOffset, 1) ;
    XtSetValues(CancelButton, Args, 7) ;
    XtSetArg(Args[5], DwtNadbLeftAttachment, DwtAttachWidget) ;
    XtSetArg(Args[6], DwtNadbLeftWidget, CancelButton) ;
    XtSetArg(Args[7], DwtNadbLeftOffset, 1) ;
    XtSetArg(Args[8], DwtNadbRightAttachment, DwtAttachAdb) ;
    XtSetArg(Args[9], DwtNadbRightOffset, 1) ;
    XtSetValues(OKButton, Args, 10) ;

    XtManageChild(ListBox) ;
    XtManageChild(OKButton) ;
    XtManageChild(CancelButton) ;
    XtManageChild(WorkArea) ;

    XtRealizeWidget(TopLevel) ;
    XtMainLoop() ;
}

I hope this help you to help me further because at the moment I am having a hard
time making any attachments at all within dialog boxes.

See the next reply +.1 for another example of attachments that don't seem to
work properly.

thanks for the input,

Walter
2267.3Another failing attachments example.WPOMM2::ZAMBOTTITue Feb 13 1990 23:13120
Hi again,

I thought I would experiment with a more simple example of attachments so I
might stumble upon the answer!

I decided to design a simple Attached Dialog Box with the following layout :


		+-AttachedDB----------------------------------+
                |        ^                      ^             |
		|<-My Label Widget :<-_my_Simple_Text_widget_ |
		|                                             |
		|   +------------+           +-------------+  |
		|<--| ok button ^|           |^ cancel but.|->|
		|   +------------+           +-------------+  |
                |          v                           v      |
		+---------------------------------------------+

	The ^, v, -->, <-- are arrows denoting the desired attachments.

As you can see there are five widgets here, they are :

	Attached Dialog Box widget
	Label widget
	Simple Text widget
	Push Button widget (1)
	Push Button widget (2)

I created the display using the following code :

    WorkArea = DwtAttachedDB(TopLevel, "Select", FALSE, 0, 0, DwtLatin1String("Select"), DwtWorkarea, NULL, NULL) ;

    CancelButton = DwtPushButton(WorkArea, "Button1", 0, 0, DwtLatin1String("Cancel"), CancelButtonCallbacks, NULL) ;
    XtSetArg(Args[0], DwtNadbBottomAttachment, DwtAttachAdb) ;
    XtSetArg(Args[1], DwtNadbBottomOffset, 1) ;
    XtSetArg(Args[2], DwtNadbLeftAttachment, DwtAttachAdb) ;
    XtSetArg(Args[3], DwtNadbLeftOffset, 1) ;
    XtSetArg(Args[4], DwtNadbTopAttachment, DwtAttachSelf) ;
    XtSetArg(Args[5], DwtNadbTopOffset, 16) ;
    XtSetValues(CancelButton, Args, 6) ;

    OKButton = DwtPushButton(WorkArea, "Button2", 0, 0, DwtLatin1String("OK"), OKButtonCallbacks, NULL) ;
    XtSetArg(Args[0], DwtNadbBottomAttachment, DwtAttachAdb) ;
    XtSetArg(Args[1], DwtNadbBottomOffset, 1) ;
    XtSetArg(Args[2], DwtNadbRightAttachment, DwtAttachAdb) ;
    XtSetArg(Args[3], DwtNadbRightOffset, 1) ;
    XtSetArg(Args[4], DwtNadbTopAttachment, DwtAttachSelf) ;
    XtSetArg(Args[5], DwtNadbTopOffset, 16) ;
    XtSetValues(CancelButton, Args, 6) ;

    CustomerPrompt = DwtLabel(WorkArea, "CustomerPrompt", 0, 0, DwtLatin1String("Customer name : "), NULL) ;
    XtSetArg(Args[0], DwtNadbTopAttachment, DwtAttachAdb) ;
    XtSetArg(Args[1], DwtNadbTopOffset, 1) ;
    XtSetArg(Args[2], DwtNadbLeftAttachment, DwtAttachAdb) ;
    XtSetArg(Args[3], DwtNadbLeftOffset, 1) ;
    XtSetValues(CancelButton, Args, 4) ;

    CustomerName = DwtSText(WorkArea, "CustomerName", 0, 0, 40, 1, "*") ;
    XtSetArg(Args[0], DwtNadbTopAttachment, DwtAttachAdb) ;
    XtSetArg(Args[1], DwtNadbTopOffset, 1) ;
    XtSetArg(Args[2], DwtNadbLeftAttachment, DwtAttachWidget) ;
    XtSetArg(Args[3], DwtNadbLeftWidget, CustomerPrompt) ;
    XtSetArg(Args[4], DwtNadbLeftOffset, 1) ;
    XtSetValues(CancelButton, Args, 5) ;

    XtManageChild(CustomerPrompt) ;
    XtManageChild(CustomerName) ;
    XtManageChild(OKButton) ;
    XtManageChild(CancelButton) ;
    XtManageChild(WorkArea) ;

    XtRealizeWidget(TopLevel) ;
    XtMainLoop() ;
}

Anyway instead of getting what I described above I instead get.


		+-AttachedDB----------------------------------+
		|+------+                        +-----------+|     
		||ok but|bel Widget : e_Text_Widg|cancel but.||
		|+------+                        +-----------+|
		+---------------------------------------------+

And resided :

		+-AttachedDB--------------------------------------+
		|+------+                        +---------------+|     
		||ok but|bel Widget : e_Text_Widg|cancel button  ||
		|+------+                        |               ||
		|                                |               ||
		|                                |               ||
		|                                +---------------+|
		+-------------------------------------------------+

In case its a little hard to decide what in the window here is a verbal
description.

The Label widget has been position in the top left hand corner, this is correct.

The Simple Text widget has also been placed in the top left hand corner.  This 
is not what was intented but instead to have its left edge attached to the right
edge of the label widget.

The OK Push Button widget has also been placed in the top left hand corner. And
again what was intended was to attach its bottom edge to the bottom edge of the
Attached Dialog Box.

The Cancel Push Button has been placed in the top right hand corner and grows
when resized to fill the right hand edge.  What was intented weas to have this
button in the lower right hand corner.  I have attatched its top edge to its
own (self) bottom edge but this seems to have been ignored!


If anyone can give me any pointers as how to use attachments properly that would
be great.

need help,

Walter Zambotti
2267.4A short explanation of opposing attachments...R2ME2::OBRYANWhen in doubt, let the user decide.Wed Feb 14 1990 01:27108
re:.0

>Both buttons are attached to the top of the List Box and the bottom of the
>(Attached) Dialog Box.  The cancel button is left attached to the Dialog Box
>and is not right attached at all.  The ok button is right attached to the Dialog
>x and left attached to the cancel button, like so :
>
>        ||                       | ||
>        |+-----------------------+-+|
>        |      ^             ^      |
>        | +----------+ +----------+ |
>        |<|  CANCEL  +<|    OK    +>|
>        | +----------+ +----------+ |
>        |      v             v      |
>        +---------------------------+

First, a word of explanation about attachments.  When you attach opposing sides
of any widget ( left&right or top&bottom ), you defeat that widget's normal
(internal) sizing ( width or height ), leaving the responsibility for size
determination (of the corresponding dimension) in the hands of the ADB.  If you
fail to give the ADB any boundary conditions for these dimensions, the ADB
will (typically) default the dimension to 0.
    In your example, you have forced the ADB to determine the height of both
push buttons (via top AND bottom attachments), and since the ADB has nothing
else below the list box with a non-zero size, it let the button heights
go to 0.  I'm guessing that, in your example, you'd like to have the buttons
default to their normal height.  If this is the case, simply kill the bottom
attachments for both buttons.  (The ADB will expand to encompass the buttons.)
    Also, from your diagram, I get the impression you'd like the buttons to
be 1/2 the width of the list box above it.  With the attachments described,
you will end up with a Cancel button of "normal" width, and a very wide OK
button (i.e. the left/right attachments on the OK button force the width to
be from the Cancel button's right side to the right side of the ADB.)  If the
"buttonwidth = 1/2 width of the list box" scenario is correct, then you should
consider these attachments:
	left attach Cancel to ADB
	right attach Cancel to POSITION 50 (DwtAttachPosition type)
	left attach OK to POSITION 50
	right attach OK to ADB

        ||                       | ||
        |+-----------------------+-+|
        |      ^             ^      |
        | +--------+    +---------+ |
        |<| CANCEL |>50<|   OK    +>|
        | +--------+    +---------+ |
        +---------------------------+

In case you're interested, I have included a UIL declaration describing this
below.  Good luck.

Michael
----------------------------------------
    foo_PopADB	: popup_attached_db 
    {
	arguments
	{
	    ...
	    default_button = push_button OK_Btn;
	    cancel_button = push_button Cancel_Btn;
	};
	controls
	{
	    list_box	xxx_List;
	    push_button	Cancel_Btn;
	    push_button	OK_Btn;
	};
    }; ! foo_PopADB

    xxx_List	: list_box 
    {
	    ...
    }; ! xxx_List

    Cancel_Btn	: push_button gadget
    {
	arguments
	{
	    adb_left_attachment = DwtAttachAdb;
 	    adb_left_offset	= 1;
	    adb_top_attachment	= DwtAttachWidget;
	    adb_top_widget	= list_box xxx_List;
 	    adb_top_offset	= 2;
	    adb_right_attachment = DwtAttachPosition;
	    adb_right_position	= 50;
 	    adb_right_offset	= 2;
	    label_label = k_tst_Cancel_Btn_str;
	};
	...
    }; ! Cancel_Btn

    OK_Btn	: push_button gadget
    {
	arguments
	{
	    adb_left_attachment = DwtAttachPosition;
	    adb_left_position	= 50;
 	    adb_left_offset	= 2;
	    adb_top_attachment	= DwtAttachWidget;
	    adb_top_widget	= list_box xxx_List;
 	    adb_top_offset	= 2;
	    adb_right_attachment = DwtAttachAdb;
 	    adb_right_offset	= 1;
	    label_label = k_tst_OK_Btn_str;
	};
	...
    }; ! OK_Btn
2267.5Why not use a selection widget?GOSOX::RYANDECwindows MailWed Feb 14 1990 08:090
2267.6Topic author responses...WPOMM2::ZAMBOTTIWed Feb 14 1990 21:2614
re .4

Thanks a million, perfect I suspected the zero size default but wasn't sure
on how to overcome it and your explanation was great.  Although I'm not sure
why you chose to right attach the cancel button to '50' ???

re. 5

Because a Selection Widget has a Label Widget and Text Entry Widget that I
dont need.  Unless you can't turn that part off or something!

thanks all,

Walter
2267.7Position attachments...R2ME2::OBRYANWhen in doubt, let the user decide.Thu Feb 15 1990 00:1116
re:.6

>  Although I'm not sure why you chose to right attach the cancel button to
	 '50' ???

I neglected to discuss the Position type of attachment.  The Position type
allows designers to attach ADB children to (percentage) positions within the
ADB itself, in contrast to attaching them to (say) other children or sides of
the ADB.  I took your original diagram at face value, assuming you wanted equal
sized push buttons spanning 1/2 of the dialog width.  Attaching the right side
of one button, and the left side of the other, at the "50 percent" position
guarantees that the buttons will be of equal size and will be anchored at the
center of the box, even if the ADB is resized later.

Michael