• C

In C/Motif, how can I control button spaces/sizes in a custom dialog?

I've created a custom dialog so that I can include two buttons (yes/no) as well as a toggle box which allows the user to specify not to popup the dialog and instead select yes as the answer every time.  My problem is 1) there's a lot of space between each button causing the overall dialog to be large, and 2) part of the text for the toggleButton is obscured.  What arguments can correct this?

Code:
void restart_message (char *question)
{
  Widget dialog,form,label,pane,yes_button,no_button,always_restart_check;

  if (debug) printf ("Start of restart_message\n");

  dialog = XtVaCreatePopupShell ("Restart",
                         xmDialogShellWidgetClass, GetTopShell (main_window),
                         XmNdeleteResponse, XmDESTROY,
                         NULL);
  pane = XtVaCreateWidget ("restart_pane", xmPanedWindowWidgetClass, dialog,
                     XmNsashWidth,  1,
                     XmNsashHeight, 1,
                     NULL);
  form = XtVaCreateWidget ("restart_form", xmFormWidgetClass, pane, NULL);
  label = XtVaCreateManagedWidget (question, xmLabelGadgetClass, form,
                           XmNleftAttachment,   XmATTACH_FORM,
                           XmNtopAttachment,    XmATTACH_FORM,
                           XmNrightAttachment, XmATTACH_FORM,
                           NULL);
  XtManageChild (form);
 
  form = XtVaCreateWidget ("action_area", xmFormWidgetClass, pane,
                     XmNwidth,         700,
                     XmNheight,         50,
                     XmNfractionBase,    7,
                     NULL);
 
  yes_button = XtVaCreateManagedWidget ("Yes",
                              xmPushButtonGadgetClass, form,
                              XmNtopAttachment,        XmATTACH_FORM,
                              XmNbottomAttachment,     XmATTACH_FORM,
                              XmNleftAttachment,       XmATTACH_POSITION,
                              XmNleftPosition,         1,
                              XmNrightAttachment,      XmATTACH_POSITION,
                              XmNrightPosition,        2,
                              XmNshowAsDefault,        True,
                              XmNdefaultButtonShadowThickness, 1,
                              NULL);
  XtAddCallback (yes_button, XmNactivateCallback, restart_cb, dialog);
   
  no_button = XtVaCreateManagedWidget ("No",
                               xmPushButtonGadgetClass, form,
                               XmNtopAttachment,        XmATTACH_FORM,
                               XmNbottomAttachment,     XmATTACH_FORM,
                               XmNleftAttachment,       XmATTACH_POSITION,
                               XmNleftPosition,         3,
                               XmNrightAttachment,      XmATTACH_POSITION,
                               XmNrightPosition,        4,
                               XmNshowAsDefault,        False,
                               XmNdefaultButtonShadowThickness, 1,
                               NULL);
  XtAddCallback (no_button, XmNactivateCallback, no_restart_cb, dialog);
 
  always_restart_check = XtVaCreateManagedWidget ("Don't ask, always\nrestart after make",
                                      xmToggleButtonGadgetClass, form,
                                      XmNtopAttachment,        XmATTACH_FORM,
                                      XmNbottomAttachment,     XmATTACH_FORM,
                                      XmNleftAttachment,       XmATTACH_POSITION,
                                      XmNleftPosition,         5,
                                      XmNrightAttachment,      XmATTACH_POSITION,
                                      XmNrightPosition,        6,
                                      XmNshowAsDefault,        False,
                                      XmNdefaultButtonShadowThickness, 1,
                                      NULL);
  XtAddCallback (always_restart_check,XmNvalueChangedCallback, always_restart_cb, dialog);
   
  XtManageChild (form);
  XtManageChild (pane);
  XtPopup (dialog, XtGrabNone);
}
jimdgarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DreamWarriorCommented:
I have found that typically using a form in Motif for things that you desire to be constant in size is generally a bad idea.

My suggestion would be to place a bulletin-board in the second portion of the frame and lay out the buttons exactly as you want them.

However, to be completely honest you may be better off tayloring a message box widget because it'll handle the button layout itself and should allow you to add a toggle button to it.  It also aids in enforcing the Motif style guidelines on your application.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cupCommented:
Try using PushButtonWidgets instead of PushButtonGadgets.  It adds extra windows and increases the size of the program marginally but that may be all you need to get the exact sizes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.