[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 2004-11-01
4
Medium Priority
?
393 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
2 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

Identify and Prevent Potential Cyber-threats

Become the white hat who helps safeguard our interconnected world. Transform your career future by earning your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

590 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