I have written the below sample program to create a form which contains 3 labels [vertically] in a PanedWindow.
I have set the XmNheight using XtVaSetValues before realizing the widgets, to set the height for each label and it worked correctly.
Each Labels shown the height of 100, 50 and 150 respectively in the Paned Window with sashes in between.
#include
#include
void main(int argc, char **argv)
{
XtAppContext app;
Widget appshell,the_win,labels[3];
appshell = XtVaAppInitialize (&app, "Pane", NULL, 0, &argc, argv, NULL, NULL);
//Create the Pane
the_win = XmCreatePanedWindow(appshell, "PanedWin", NULL, 0);
XtManageChild(the_win);
//Create Labels
labels[0] = XmCreateLabel(the_win, "Label1",NULL,0 );
labels[1] = XmCreateLabel(the_win, "Label2",NULL,0 );
labels[2] = XmCreateLabel(the_win, "Label3",NULL,0 );
XtManageChildren(labels, 3);
//Set the Label heights
XtVaSetValues( labels[0], XmNheight, 100, NULL );
XtVaSetValues( labels[1], XmNheight, 50, NULL );
XtVaSetValues( labels[2], XmNheight, 150, NULL );
//Realize widget
XtRealizeWidget(appshell);
XtAppMainLoop(app);
}
Suppose, if I have to realize the widget first and then I have to adjust the height of labels, then how it should be?
Please see the rewritten program below. I have set the XmNallowResize to True for the Pane and then tried adjusting the height. But it did
not work for me. Now all the lables are shown with default height. It is not taking the heights which I set explicitly [ as 100, 50 and 150].
What is wrong with it?
#include
#include
void main(int argc, char **argv)
{
XtAppContext app;
Widget appshell,the_win,labels[3];
appshell = XtVaAppInitialize (&app, "Pane", NULL, 0, &argc, argv, NULL, NULL);
//Create the Pane
the_win = XmCreatePanedWindow(appshell, "PanedWin", NULL, 0);
XtManageChild(the_win);
//Create Labels
labels[0] = XmCreateLabel(the_win, "Label1",NULL,0 );
labels[1] = XmCreateLabel(the_win, "Label2",NULL,0 );
labels[2] = XmCreateLabel(the_win, "Label3",NULL,0 );
XtManageChildren(labels, 3);
//Realize widget
XtRealizeWidget(appshell);
XtVaSetValues( the_win, XmNallowResize, True, NULL );
//Set the Label heights
XtVaSetValues( labels[0], XmNheight, 100, NULL );
XtVaSetValues( labels[1], XmNheight, 50, NULL );
XtVaSetValues( labels[2], XmNheight, 150, NULL );
XtAppMainLoop(app);
}
System Details :- Solaris Sparc 5.9
Compiler : cc
Please help me to solve this out.
Tue, 08/07/2012 - 15:31
#1
How to adjust the size of PanedWindow children after realizing the parent?
You have two problems. The first is that an XmPanedWindow does not have an XmNallowResize resource - that resource is a constraint resource for its children. So you have to set XmNallowResize to True on each of the labels, not on the paned window.
Second, the default XmNallowShellResize resource for a Shell is False; you must set it to True for your shell (appshell) in order for the shell to allow the paned window to resize after its children request a resize.
Thank you very much your response. Now it is clear.