Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-11-01
4
Medium Priority
?
391 Views
Last Modified: 2012-06-27
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);
}
0
Comment
Question by:jimdgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
DreamWarrior earned 500 total points
ID: 12475240
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
 
LVL 11

Assisted Solution

by:cup
cup earned 500 total points
ID: 12481284
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question