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