Layout questions

Online Status

I'm designing a window that currently looks like this Screenshot.

Here's the code how the window and the layout is created:

  pRangeSelectWindow->pWinObject = NewObject(WINDOW_GetClass(), NULL,
    WA_Title, "MultiRename: Select name part",
    WA_Activate, TRUE,
    WA_CloseGadget, TRUE,
    WA_DepthGadget, TRUE,
    WA_DragBar, TRUE,
    WA_SizeGadget, TRUE,
    WA_Width, 500,
    WA_Height, 180,
    WA_AutoAdjust, TRUE,
    WINDOW_GadgetHelp, TRUE,
    WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_GADGETUP,
    WINDOW_Layout, pMainLayout = NewObject(LAYOUT_GetClass(), NULL,
      LAYOUT_EvenSize, TRUE,
      LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
      LAYOUT_SpaceOuter, TRUE,
      LAYOUT_BevelStyle, BVS_GROUP,
      LAYOUT_DeferLayout, TRUE,   /* this tag instructs layout.gadget to
                                   * defer GM_LAYOUT and GM_RENDER and ask
                                   * the application to do them. This
                                   * lessens the load on input.device
                                   */
      LAYOUT_AddChild, m_ppGadgets[GID_STRING] = NewObject(STRING_GetClass(), NULL,
        GA_ID, GID_STRING,
        GA_RelVerify, TRUE,
        GA_TabCycle, TRUE,
      TAG_DONE),
      CHILD_Label, NewObject(LABEL_GetClass(), NULL,
        LABEL_Text, "Select the characters to be inserted",
      TAG_DONE),
      LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
        LAYOUT_EvenSize, TRUE,
        LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
        LAYOUT_AddChild, m_ppGadgets[GID_BTN_OK] = NewObject(BUTTON_GetClass(), NULL,
          GA_ID, GID_BTN_OK,
          GA_RelVerify, TRUE,
          GA_Text, (ULONG)"Ok",
          BUTTON_TextPadding, TRUE,
        TAG_DONE),
        CHILD_WeightedWidth, 1,
        LAYOUT_AddChild, NewObject(LABEL_GetClass(), NULL,
          LABEL_Text, "",
        TAG_DONE),
        CHILD_WeightedWidth, 100,
        LAYOUT_AddChild, m_ppGadgets[GID_BTN_CLOSE] = NewObject(BUTTON_GetClass(), NULL,
          GA_ID, GID_BTN_CLOSE,
          GA_RelVerify, TRUE,
          GA_Text, (ULONG)"Close",
          BUTTON_TextPadding, TRUE,
        TAG_DONE),
        CHILD_WeightedWidth, 1,
      TAG_DONE),
      CHILD_WeightedHeight, 0,
    TAG_DONE),
    TAG_DONE);

I have some questions regarding the layout.

  1. I would like the LABEL_Text, "Select the characters to be inserted" to be placed above (and not left of) the String gadget, directly into the vertical layout. How could this be achieved?
  2. Is it possible for the window to open automatically in the vertical size required by the layout? (The SizeGadget would then make no sense and be deactivated)

Online Status

AFAIK there is no 'direct' way of determining where the child label position can be altered under OS 3.2 - it will appear on the left side of the string gadget anyway.
OS 4.1 has tags for that purpose, but they won't work under OS 3.2:
/* Vertical alignment types (OS4ONLY). */
#define LVALIGN_BOTTOM 0
#define LVALIGN_BASELINE 1

So gaining what you want would mean to add the label and the string gadget within a vertical layout.

Online Status

1) If i understand you correctly you should not use CHILD_Label for this purpose. Instead simply

LAYOUT_AddImage, NewObject(LABEL_GetClass(), NULL,
LABEL_Text, "Select the characters to be inserted",
TAG_DONE),

before adding the string gadget

2) the window does open in the size required if your window is window.class and not just a simple intuition window. There is a little twist to it because some gadgets like lists don't require much vertical space so if you want it to be higher you specify a size, but otherwise just don't and it will have the right size

Online Status

And Michael's comment is correct but not what you asked about so disregard

Online Status

This fixed it, thank you!

And regarding 2) it already was a window.class object - but your comment inspired me to try removing the WA_Height, which was set to a fixed size. And then it worked:-)