[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

3281.0. "Using separator widget." by HGOVC::ALFREDLEUNG () Thu Aug 30 1990 04:31

    I hope to know how to insert a horizontal separator widget to the
    middle of a push button widget and a label widget. Suppose both the
    label widget and the push button widget are children of a dialogbox
    widget. What is the procedure to do it? Since I look at the manual
    about separator widget before, there is no argument to control the
    position of the separator widget in order to separate the desired
    widget. What should I do?
    
    Thank.
T.RTitleUserPersonal
Name
DateLines
3281.1one way...DSSDEV::BIBEAULTGrizzly BearThu Aug 30 1990 09:428
   When you put a separator in a menu, the menu automatically takes care of
   the positioning. Not so with a dialog box -- you have to do the position-
   ing yourself. I'd suggest that the easiest way to do this would be to use
   a Form Dialog (Attached Dialog if you're using XUI) and use the attachment
   and offset resources to get things positioned to your satisfaction.

-mike
3281.2HGOVC::ALFREDLEUNGThu Aug 30 1990 12:004
    But where do the separation line appear? Do you means it always show up
    at the middle of the dialog box(if its parent is a dialog box)? But how
    should I do if I have 3 push buttons, I just want the separation line
    display horizontally after the second push button? 
3281.3DSSDEV::BIBEAULTGrizzly BearThu Aug 30 1990 15:4224
    I'm not sure exactly what you're after, but if the following is what you
    are trying to do:

    +----------------------+ 
    | Attached Dialog Box  |    It can be acheived by attaching the left sides
    +----------------------+	of all objects to the dialog box, attaching
    |                      |    Push Button 1 to the dialog box, and attaching
    |    +------------+    |    all subsequent objects to the object above it.
    |    | Push Btn 1 |    |
    |    +------------+    |    E.g. the separator has a top attachment to Push
    |                      |    Button 2...
    |    +------------+    |
    |    | Push Btn 2 |    |
    |    +------------+    |
    |                      |
    |......................|
    |                      |
    |    +------------+    |
    |    | Push Btn 3 |    |
    |    +------------+    |
    |                      |
    +----------------------+

3281.4An example is more than a thousand words.HGOVC::ALFREDLEUNGFri Aug 31 1990 06:38241
    I think your suggestion has no problem when the parent widget is an
    attach dialog box, but how to do if the parent widget is not an attach
    dialog box? As in the following example, I even can't display the
    separator widget. 
    
    Please give me any idea.
    
    Thank.
    
    
/* Simple Example for Widgets*/

#include <stdio.h>
#include <DECwDwtApplProg.h>

#define windowName        "Simple Widgets Examples"
#define windowClass       windowName
#define mainName          "mainWindow"
#define mainWidth         250
#define mainHeight        300
#define dialogName        "workArea"
#define pushName          "pushButton"
#define labelName         "label"
#define pushLabel         "Click Here"
#define helloLabel        "Hello, World!"
#define goodbyeLabel      "Goodbye, World!"

/* variable and structure for pop up manual */

static Widget pop_menu;
static void pop_up();
static char popup_translation[] = "<Btn2Down>: pop_up()";
static XtActionsRec our_action_table[] =
{
   {"pop_up", (caddr_t)pop_up},
};

/* Button activate call back */

static XtCallbackProc ButtonActivated();


/* callback structures */

static DwtCallback activate_callback[] = {
    {ButtonActivated, NULL}, 
    {NULL, NULL}
};

main(argc, argv)
    unsigned int argc;
    char *argv[];
{
    Widget top_level,                   /* top level widget */
      main_widget,                      /* application main widget */
      sep, entry1, entry2, pop_entry1, pop_entry2,
      dialog_box, menu_bar, push_button, comm, label;

    int n;
    Arg args[10];

    /* Initialize the toolkit, and create the top-level widget */

    top_level = XtInitialize(windowName, windowClass, NULL, 0, 
                                        /* no options */
      &argc, argv);                     /* command line */

    /* Create a main window widget */

    main_widget =
      DwtMainWindow(top_level, mainName, 100, 100, mainWidth, mainHeight);

    XtManageChild(main_widget);

    /* Create a menu bar */
    
    menu_bar = DwtMenuBar(main_widget, "menu_bar",  
      0, 0);                 

    XtManageChild(menu_bar);

    /* Create the first entry inside the menu bar */

    entry1 =
      DwtPullDownMenuEntry(menu_bar, "entry1", 0, 0, 
        DwtLatin1String("Selection 1"), 
        NULL, NULL, NULL);
    XtManageChild(entry1);

    /* Create the second entry inside the menu bar */

    entry2 =
      DwtPullDownMenuEntry(menu_bar, "entry2", 0, 0, 
        DwtLatin1String("Selection 2"), 
        NULL, NULL, NULL);
    XtManageChild(entry2);

    /* Create a dialog box */

    n = 0;
    XtSetArg(args[n], DwtNwidth, 150);
    n++; 
    XtSetArg(args[n], DwtNheight, 300);
    n++; 
    XtSetArg(args[n], DwtNunits, DwtPixelUnits);
    n++; 
    dialog_box = DwtDialogBoxCreate(main_widget, dialogName, args, 3);
    XtManageChild(dialog_box);

    /* Create a label in the dialog box */

    label = DwtLabel(dialog_box, labelName, 10, 20,
      DwtLatin1String(helloLabel), NULL);

    activate_callback[0].tag = label;

    XtManageChild(label);

    /* Create a seperator widget between the Label and the Push Button */

    sep = DwtSeparator(dialog_box, "sep", 10, 40,
      DwtOrientationHorizontal);

    n = 0;
    XtSetArg(args[n], DwtNadbTopAttachment, DwtAttachAdb);
    ++n;
    XtSetArg(args[n], DwtNadbTopWidget, label);
    ++n;
    XtSetArg(args[n], DwtNadbTopOffset, 10);
    ++n;
    XtSetValues(sep, args, 3);

    XtManageChild(sep);

    /* Create a Push Button Widget */

    n = 0;
    XtSetArg(args[n], DwtNbordHighlight, True);
    n++; 
    XtSetArg(args[n], DwtNx, 10);
    n++; 
    XtSetArg(args[n], DwtNy, 60);
    n++; 
    XtSetArg(args[n], DwtNactivateCallback, activate_callback);
    n++; 
    XtSetArg(args[n], DwtNlabel, DwtLatin1String("Exit"));
    n++;
    push_button = DwtPushButtonCreate(dialog_box, pushName, args, n);

    XtManageChild(push_button);


    /* Create a command window */

    comm = DwtCommandWindow(main_widget, "comm",  
      DwtLatin1String("comm>"), 5, 0, 0);                 

    XtManageChild(comm);

    /* Set up mb2 to activate pop up manual */
    
    handle_mb2_press(dialog_box);

    /* Realize the widget hierarchy, creating and mapping windows */

    XtRealizeWidget(top_level);

    /* Create a pop up manual */

    pop_menu = DwtMenu(dialog_box, "Pop Up Menu", 
      0, 0, DwtMenuPopup,                       /* x, y, format */
      DwtOrientationVertical,                   /* Orientation */
      NULL, NULL);                      /* no callbacks */

    /* Create two entries inside the pop up menu  */

    pop_entry1 =
      DwtPullDownMenuEntry(pop_menu, "pop_entry1", 0, 0, 
        DwtLatin1String("Selection 1"), 
        NULL, NULL, NULL);
    XtManageChild(pop_entry1);

    pop_entry2 =
      DwtPullDownMenuEntry(pop_menu, "pop_entry2", 0, 0, 
        DwtLatin1String("Selection 2"), 
        NULL, NULL, NULL);
    XtManageChild(pop_entry2);


    /* Wait for something to happen */

    XtMainLoop();                       /* Never returns */
}

static XtCallbackProc ButtonActivated(widget, tag, reason)
    Widget widget;
    Widget tag;
    DwtAnyCallbackStruct *reason;
{
    Arg arg;

    static int changed = False;

    if (changed)
        exit(1);
    else {
        XtSetArg(arg, DwtNlabel, DwtLatin1String(goodbyeLabel));
        XtSetValues(tag, &arg, 1);
        changed = True;
    }
}

/* Routine that will be invoked when user press MB2 inside the dialog box */

static void pop_up(widget, event, params, num_params)
    Widget widget;
    XButtonPressedEvent *event;
    char **params;
    int num_params;
{
    DwtMenuPosition( pop_menu, event);

    XtManageChild( pop_menu );
}

/* Set up the calling of pop_up() routine if user presses MB2 */

handle_mb2_press(widget)
    Widget widget;
{
    Arg arglist[2];

    XtTranslations parsed_t_table;
    XtAddActions(our_action_table, 1);

    parsed_t_table = XtParseTranslationTable(popup_translation);

    XtOverrideTranslations(widget, parsed_t_table );

}
3281.5DSSDEV::BIBEAULTGrizzly BearFri Aug 31 1990 09:419
    I guess the obvious question is, why don't you want to use an adb? It's
    pretty much the same as a db except that it allows the attachment
    resources.

    When not using attachements, you'll need to set the x and y resources
    of the separator explicitly to the proper location within the box.

-mike
3281.6Separator don't separate.HGOVC::ALFREDLEUNGMon Sep 03 1990 07:314
    Help me!!
    
    I still can't display the separator even I change my dialog
    box to become an attach dialog box!!
3281.7Try this.HGABSS::SAMMYKAMSammy Kam, Asia EngineeringMon Sep 03 1990 22:3711
    re : .6,.4
    
>    sep = DwtSeparator(dialog_box, "sep", 10, 40,
>      DwtOrientationHorizontal);
>
>    n = 0;
>    XtSetArg(args[n], DwtNadbTopAttachment, DwtAttachAdb);

    You should specify DwtAttachWidget instead of DwtAttachAdb here.