0

I am trying to right align a button.

So far I have this:

#include <iup.h>
#include <stdlib.h>

int close(Ihandle *self) {
    return IUP_CLOSE;
}

int main(int argc, char **argv) {

    Ihandle *button, *quit, *dlg;

    IupOpen(&argc, &argv);

    button = IupButton(NULL, NULL);

    IupSetAttribute(button, "IMAGE", "extras/view.bmp");
    IupSetAttribute(button, "IMAGEPOSITION", "LEFT");

    quit = IupButton(NULL, NULL);
    IupSetAttribute(quit, "IMAGE", "extras/close.bmp");
    IupSetAttribute(quit, "IMAGEPOSITION", "RIGHT");

    IupSetCallback(quit, "ACTION", (Icallback)close);

    dlg = IupDialog(IupVbox(button, quit, NULL));

    IupShow(dlg);
    IupMainLoop();  
    IupClose();

    return EXIT_SUCCESS;
}

But the button does not align to the right.

I have tried the following:

IupSetAttribute(quit, "IMAGEPOSITION", "RIGHT"); and IupSetAttribute(quit, "ALIGNMENT", "ARIGHT"); but the button does not go to the right.

I could set SCREENPOSITON, but I am worried that might not work if run on different size sceens. How do I align my button to the right?

Here is a picture of what I have currantly with where I am aming for the button to end up:

enter image description here

Xantium
  • 11,201
  • 10
  • 62
  • 89
  • 1
    Why your question is "Close Window" if it is about control alignment? – Antonio Scuri Jun 26 '18 at 18:54
  • From IUP documentation: IMAGEPOSITION (non inheritable): Position of the image relative to the text when both are displayed. It is not what you want. – Antonio Scuri Jun 26 '18 at 18:55
  • @AntonioScuri Oh sorry, that was a previous problem I had, but I solved it before posting. Sorry I forgot to correct the title. My question is about right aligning the button. – Xantium Jun 26 '18 at 18:56
  • The two buttons are inside the vbox, so you want to align them to the right of the vbox. Try setting ALIGNMENT=ARIGHT in the Vbox. – Antonio Scuri Jun 26 '18 at 18:58
  • @AntonioScuri I fear you may have misunderstood, I am after the *second*, quit box being right aligned. The first should stay as is (please see the picture above to help you understand). I just tried `vbox = IupVbox(button, quit, NULL); IupSetAttribute(vbox, "ALIGNMENT", "ARIGHT"); dlg = IupDialog(vbox);` it does not seem to align anything to the right. – Xantium Jun 26 '18 at 19:36
  • Would I just need to get what you mentioned above working and then create two `IupVbox`? – Xantium Jun 26 '18 at 19:39
  • Ok. Looking at your picture, if you just need that, you should use a IupHbox box instead, to horizontally distribute the two button. Then to push the second button to the right on the empty space of the dialog you insert an IupFill between the two button in the IupHbox. You will get exactly that result. – Antonio Scuri Jun 27 '18 at 20:17

0 Answers0