X and Y coordinates become default(0) after XtManageChildren - Motif

This is a discussion on X and Y coordinates become default(0) after XtManageChildren - Motif ; Hello I have a small problem regarding a form and two widgets attached on it. So mainly, I want to display this two widgets in that form on a timer callback: XtAppAddTimeOut(app_context, (unsigned long) 3000, /* milliseconds */ display_widgets, client_data) ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: X and Y coordinates become default(0) after XtManageChildren

  1. X and Y coordinates become default(0) after XtManageChildren

    Hello
    I have a small problem regarding a form and two widgets attached on it.
    So mainly, I want to display this two widgets in that form on a timer
    callback:
    XtAppAddTimeOut(app_context,
    (unsigned long) 3000, /* milliseconds */
    display_widgets,
    client_data) ;
    Practically, I'm seting XtManageChildren for each of this widget (which
    is a XmText, btw) in display_widgets function, which comes at 3
    seconds. In this function I have an if statement for letting me display
    the widgets (XtManageChildren) and on the next call of this function,
    I'm doing XtUnmanageChildren (for disappear). My problem is that I'm
    setting for each of these two widgets a different X and Y values. For
    the first widgt it's ok, but for the second widget, after it does
    XtManageChildren, the XmNx and XmNy values become default (0 and 0).
    Why it doesn't let me specify the wanted values for X and Y
    coordinates?
    Help me please !!


  2. Re: X and Y coordinates become default(0) after XtManageChildren

    All widgets (except shells) are subject to getting moved around /
    resized by their parent widgets (called Managers - Forms, RowColumns,
    BulletinBoards, etc).

    Most manager widgets do not accept setting XmNx and XmNy from their
    children to arrange them - they have other ways of arranging them
    (usually specified with "constraint" resources).

    If you want to set XmNx and XmNy of your widgets, they could be in a
    BulletinBoard, which will not ignore XmNx and XmNy.


  3. Re: X and Y coordinates become default(0) after XtManageChildren


    Rob wrote:
    > All widgets (except shells) are subject to getting moved around /
    > resized by their parent widgets (called Managers - Forms, RowColumns,
    > BulletinBoards, etc).
    >
    > Most manager widgets do not accept setting XmNx and XmNy from their
    > children to arrange them - they have other ways of arranging them
    > (usually specified with "constraint" resources).
    >
    > If you want to set XmNx and XmNy of your widgets, they could be in a
    > BulletinBoard, which will not ignore XmNx and XmNy.


    Thank you for response. I'm able now to set X and Y of these text
    widget on the XmForm. I followed the next steps:
    - set the form as resizable:
    XtSetArg(al[ac], XmNresizable, TRUE); ac++;
    - had to attach all the widgets to the left and top of the form
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    - whenever I wanted to change x and y of a text widget, I had to set
    the left and top attachments to NONE:
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;

    After this, I was able to set x and y:
    XtSetArg(al[ac], XmNx, myX); ac++;
    XtSetArg(al[ac], XmNy, myY; ac++;

    So far so good. I saw in the documentation that XmForm inherits
    XmBulletinBoard. I'll try with BulletinBoard also.
    But now I'm having a strange problem. I'm setting also the width and
    height for these text widgets. So, on my callback (which comes at every
    4 seconds), I put (just for test) 8 text widgets (with different
    coordinates and sizes). At the first appeal of this timer callback, all
    the sizes are correct (x, y, w, and h). But on the next they are messed
    up, even if I'm setting the same sizes (same x, y w, h). On the third
    appeal, everuthing is back OK... and so on. I'm printing on screen
    everything I'm putting in "al" array, and after I'm setting values
    (XtSetValues(widget, al, ac) ), I'm taking the actual values with
    XtVaGetValues. So I compare what I want to set with what was actually
    set and I see that is wrong (on every even appeal of my timer
    callback).
    Any hint please? Thank you so much


  4. Re: X and Y coordinates become default(0) after XtManageChildren

    XmForm does layout itself; use a bulletin board widget directly if you
    want to control the layout.

  5. Re: X and Y coordinates become default(0) after XtManageChildren

    I allready tried to use BulletinBoard and I can see the same behavior.
    Anyway, it should work with form also. I mean, the code is exactly the
    same, nothing is changing dynamicaly. At 4 seconds, the callback
    function does XtSetValue with exactly the same X, Y, W and H for a
    widget. Yet, at every two calls of this callback function, the W and H
    are modified after XtSetValues. It's so strange....
    I'm puting the code that exists in my calback function, maybe someone
    can see the problem. I know that is pretty large and I'm sorry for
    this.
    area it is a XmLabel
    screen_layout it's a XmBulletinBoard

    Thank you and have a great day/night

    void display_widgets_temp(XtPointer client_data, XtIntervalId *id)
    {
    Arg al[50];
    int ac = 0;
    GEOM *Geom= (GEOM*)client_data;
    char pszTemp[50]; sprintf(pszTemp,"Callback_%d", Geom->nX);
    XmString xmstrings[1];


    //COMMON definitions for widgets
    XrmValue from_value, to_value;
    if (DefaultDepthOfScreen(DefaultScreenOfDisplay(displ ay)) != 1) {
    from_value.addr = "#ffffffffffff" ;
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (screen_layout, XmRString, &from_value, XmRPixel,
    &to_value);
    if ( to_value.addr )
    {
    XtSetArg(al[ac], XmNforeground, *(Pixel *) to_value.addr); ac++;
    }
    }
    if (DefaultDepthOfScreen(DefaultScreenOfDisplay(displ ay)) != 1) {
    from_value.addr = "#000000000000" ;
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (screen_layout, XmRString, &from_value, XmRPixel,
    &to_value);
    if ( to_value.addr )
    {
    XtSetArg(al[ac], XmNbackground, *(Pixel *) to_value.addr); ac++;
    }
    }
    if (DefaultDepthOfScreen(DefaultScreenOfDisplay(displ ay)) != 1) {
    from_value.addr = "#ffffffffffff" ;
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (screen_layout, XmRString, &from_value, XmRPixel,
    &to_value);
    if ( to_value.addr )
    {
    XtSetArg(al[ac], XmNtopShadowColor, *(Pixel *) to_value.addr); ac++;
    }
    }
    if (DefaultDepthOfScreen(DefaultScreenOfDisplay(displ ay)) != 1) {
    from_value.addr = "#ffffffffffff" ;
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (screen_layout, XmRString, &from_value, XmRPixel,
    &to_value);
    if ( to_value.addr )
    {
    XtSetArg(al[ac], XmNbottomShadowColor, *(Pixel *) to_value.addr);
    ac++;
    }
    }
    from_value.addr =
    "-monotype-arial-medium-r-normal--0-120-0-0-p-0-iso8859-10";

    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (screen_layout, XmRString, &from_value, XmRFontList,
    &to_value);
    if ( to_value.addr )
    {
    XtSetArg(al[ac], XmNfontList, *(XmFontList *) to_value.addr); ac++;
    }
    XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
    XtSetArg(al[ac], XmNmarginWidth, 0); ac++;
    //end of COMMON
    char *pszRcvdMsg = new char[1000];sprintf(pszRcvdMsg," COMMUNICATION
    ERROR %d", Geom->nX);

    XtSetArg(al[ac], XmNx, 180); ac++;
    XtSetArg(al[ac], XmNy, 140); ac++;
    XtSetArg(al[ac], XmNwidth, 220); ac++;
    XtSetArg(al[ac], XmNheight, 150); ac++;
    printf("al structure: \n");
    for(int k = 0; k < ac; k++)
    printf("al[%d] = name - %s | val - %d\n", k, al[k].name, al[k].value
    );

    xmstrings[0] = XmStringCreateLtoR ( pszRcvdMsg,
    (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    //TODO: only for debug
    Position w=0, h=0, x=0, y=0, r = 0, b = 0, l = 0, t = 0;
    XtVaGetValues(area, XmNwidth, &w, XmNheight, &h, XmNx, &x, XmNy, &y,
    XmNbottomAttachment, &b, XmNrightAttachment, &r, XmNleftAttachment, &l,
    XmNtopAttachment, &t, NULL);
    printf("For area before XtSetValues: X = %d | Y = %d| W = %d | H = %d
    | r = %d | b = %d| l = %d | t = %d|\n", x, y, w, h, r, b, l, t);

    XtSetValues(area, al, ac);

    XtVaGetValues(area, XmNwidth, &w, XmNheight, &h, XmNx, &x, XmNy, &y,
    XmNbottomAttachment, &b, XmNrightAttachment, &r, XmNleftAttachment, &l,
    XmNtopAttachment, &t, NULL);
    printf("After XtSetValues: X = %d | Y = %d| W = %d | H = %d | r = %d |
    b = %d| l = %d | t = %d|\n", x, y, w, h, r, b, l, t);

    Geom->nX+=20;

    XtAppAddTimeOut(app_context,
    (unsigned long) 4000, /* milliseconds */
    display_widgets_temp,
    (XtPointer*)Geom) ;
    delete[] pszRcvdMsg;
    }


+ Reply to Thread