XmCreateOptionMenu and const. labelsize ?

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

8 posts / 0 new
Last post
XmCreateOptionMenu and const. labelsize ?

Submitted by walter on Thu, 02/25/2010 - 15:39. General Questions
Hi all,
i would like to have a constant width for all OptionLabels.
I have tried without success:

n = 0;
XtSetArg (args[n], XmNwidth, 250); n++;
XtSetArg (args[n], XmNheight, 250); n++;
XtSetArg (args[n], XmNsubMenuId, *pulldown); n++;
XtSetArg (args[n], XmNmenuHistory,menu[0]._t ); n++;
*cascade = XmCreateOptionMenu(main_rc, menu[0]._S , args, n);
XtManageChild (*cascade);

note i can expand all menu[0]._S to the same size by adding spaces but i can not handle changes via resources.

fredk

I do not understand your problem. All items in an option menu are always the same size.

What do you mean by "without success"? What does your menu look like? What do you want it to look like?

For example, the popup might be:
|aaa |
|bbbbbb|
|cccc |
are all the same size (I am assuming you are viewing this using a fixed-width font).

Seems odd to specify a height of 250. Let it default to the height the font requires.

fredk

I see the reply editor uses a fixed-width font, but the viewer uses proportional. My example should have all of the vertical bars in line. So I'll show it using underscores to represent blank areas:
|aaa___|
|bbb___|
|cccccc|

walter

I will try ascii-art:

The menu basicly looks like that:

+----------+
| +------+ |
| | ITEM | |
| +------+ |
| +------+ |
| | ITEM | |
| +------+ |
| +------+ |
| | ITEM | |
| +------+ |
+----------+

The click on ITEM shows the menu (does not realy matter here).

This works fine as all ITEM label are the same length
"aa__","aaaa","aaab" ,.....

When they have different length like:
"aa", "bbbb","ab", ....

the result look more like:

+----------+
| +----+ |
| | aa | |
| +----+ |
| +------+ |
| | bbbb | |
| +------+ |
| +----+ |
| | ab | |
| +----+ |
+----------+

(the reality is worse than that here and centered).

My idea was to use a fixed size what did not work, and i do not understand WHY and HOW to fix that (exept adding spaces)

fredk

You did not show what you WANT it to look like.

If the items have different lengths, they cannot be made to look the same length.

You say you can 'fix' it by adding spaces. Do you mean you want the items right-justified, or center justified? To do that, set the XmNalignment resource of each of the menu items to XmALIGNMENT_END or XmALIGNMENT_CENTER.

walter

I want them with equal width, independent of the label (string) lenght. The should simply keep the size i set.
I realy what to get rid of those spaces i need to keep
them in shape.

Bonus if the label string (text) is centererd.

+------------+
| +--------+ |
| | ABCD | |
| +--------+ |
+------------+
| +--------+ |
| | AB | |
| +--------+ |
+-------------+
Expected formating for strings "ABCD" and "AB".

fredk

When you create the menu items, just specify XmNalignment to be XmALIGNMENT_CENTER

walter

Hi, did some experiments with XmALIGNMENT_CENTER but it does not solve my problem here is the sequence I use this for the layout:

iframe =XtVaCreateWidget( "iframe",
xmFrameWidgetClass,
rowcol,
NULL);
main_rc =XtVaCreateWidget( "main_rc",
rowColumnWidgetClass, iframe,
XmNorientation,
XmHORIZONTAL,
NULL);

loop over
setup_menu()

___________________

setup_menu()

pulldown = XmCreatePulldownMenu(main_rc,"PULL",args,n);

loop over entries:
{
menu[i]._t=XmCreatePushButton(pulldown menu[i]._S),NULL,0);
addcallback ...
}

XtSetArg (args[n], XmNsubMenuId, pulldown); n++;
XtSetArg (args[n], XmNmenuHistory,menu[0]._t ); n++;
cascade = XmCreateOptionMenu(main_rc, menu[0]._S , args, n)

for now i did changes in the setup_menu() code to prevend
size changes in the option menu. Do i something wrong ?
The width is obvious determinated by the max(strlen) with XmCreatePushButton() but i want a fixed width.