Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XmComboBox : Wrong Arrow Layout.

7 views
Skip to first unread message

Thomas Lehmann

unread,
Feb 2, 2009, 5:10:09 AM2/2/09
to
Hi!

I have a XmComboBox in a dialog.
It happens - sometimes - that the arrow is not
displayed at the outer right side of the combox.
It looks like the arrow attaches to the right of the
text. Unfortunately it looks very ugly because of
the grey area on the right of the arrow...

| TEXT | \/ |

Please, can somebody help?

regards,
Thomas

arahne

unread,
Feb 2, 2009, 8:30:19 AM2/2/09
to
Thomas Lehmann wrote:

> Please, can somebody help?

Can you post a small piece of code which demonstrates your problem?
Then we can play with it and suggest a solution.

Dušan Peterc
http://www.arahne.si

Thomas Lehmann

unread,
Feb 12, 2009, 3:53:21 AM2/12/09
to

arahne schrieb:


> Thomas Lehmann wrote:
>
> > Please, can somebody help?
>
> Can you post a small piece of code which demonstrates your problem?
> Then we can play with it and suggest a solution.

Took a little time but here is the code:
(two comboboxes, one above the other.
when selecting something at any combobox.
then the arrow buttons of the second will be translated)

CODE:

bool testingTwoComboboxes(Widget parent)
{
if (!parent)
return false;

struct MyCallBack
{
static void selected(Widget, XtPointer data,
XmComboBoxCallbackStruct*)
{
// adjusting content for first combo box.
XmStringTable tableB = (XmStringTable)XtMalloc(2 * sizeof
(XmString));
tableB[0] = XmStringCreateLocalized("SubValue A");
tableB[1] = XmStringCreateLocalized("SubValue B");

Widget widget = (Widget)data;

XtVaSetValues(widget, XmNitemCount , 2
, XmNitems , tableB
, XmNvisibleItemCount, 2
, XmNselectedItem , tableB[0]
, NULL);

// cleanup
XmStringFree(tableB[0]);
XmStringFree(tableB[1]);
XtFree((char*)tableB);
}//pushed
};

// defining initial properties of the widgets.
Arg arguments[10];
Cardinal count = 0;
const bool editable = false;

// switching concrete combobox type
const unsigned int type = (editable) ? XmDROP_DOWN_COMBO_BOX
: XmDROP_DOWN_LIST;

XtSetArg(arguments[count], XmNpositionMode ,
XmZERO_BASED);
++count; XtSetArg(arguments[count], XmNcomboBoxType , type);
++count;

// creating widgets
Widget form = XmCreateForm(parent, "form", 0, NULL);
Widget comboA = XmCreateComboBox(form, "comboA", arguments,
count);
Widget comboB = XmCreateComboBox(form, "comboB", arguments,
count);

// adjusting layout (one above the other)
XtVaSetValues(comboA, XmNleftAttachment , XmATTACH_FORM
, XmNrightAttachment , XmATTACH_FORM
, XmNtopAttachment , XmATTACH_FORM
, NULL);

XtVaSetValues(comboB, XmNleftAttachment , XmATTACH_FORM
, XmNrightAttachment , XmATTACH_FORM
, XmNtopAttachment , XmATTACH_WIDGET
, XmNtopWidget , comboA
, XmNbottomAttachment, XmATTACH_FORM
, NULL);

// adjusting content for first combo box.
XmStringTable tableA = (XmStringTable)XtMalloc(2 * sizeof
(XmString));
tableA[0] = XmStringCreateLocalized("Value A");
tableA[1] = XmStringCreateLocalized("Value B");

XtVaSetValues(comboA, XmNitemCount , 2
, XmNitems , tableA
, XmNvisibleItemCount, 2
, XmNselectedItem , tableA[0]
, NULL);

// cleanup
XmStringFree(tableA[0]);
XmStringFree(tableA[1]);
XtFree((char*)tableA);

XtAddCallback(comboA
,XmNselectionCallback
,(XtCallbackProc)MyCallBack::selected
,comboB);

// show
XtManageChild(form);
XtManageChild(comboA);
XtManageChild(comboB);
return true;
}//testingTwoComboboxes

0 new messages