Page 1 of 3
Specify the exact position of a window in a screen
Posted: Sat Dec 14, 2013 8:52 pm
by AmiHyperion
Hello,
as the topic title say, how can i specify the exact window position?
I know there are some constants defined (TOPLEFT, CENTERSCREEN, etc), but there's a way to specify the exact position?
Thank you
Re: Specify the exact position of a window in a screen
Posted: Sat Dec 14, 2013 9:29 pm
by salass00
WA_Left and WA_Top tags.
Re: Specify the exact position of a window in a screen
Posted: Fri Jan 03, 2014 10:25 am
by AmiHyperion
Assuming that i want to set the window position to the TopRight.
I know there is the WINDOW_Position, WPOS_TOPLEFT tag that move the window at topleft. But what if i want to move to the top only? I mean, just below the WorkBench title bar or custom screen title bar?
If i set manually the top position (WA_Top,30), for example, would this be a relative position, wouldn't it? Probably based on the height of the AmigaOS titlebar or customscreen title bar, subject to change with different theme.
Re: Specify the exact position of a window in a screen
Posted: Sat Jan 18, 2014 9:59 am
by gazelle
I think WA_Left and WA_Top are absolute screen coordinates of the window not relative.
If you want to position your window right below the titlebar of the screen you need to get the screenpointer and use the BarHeight value for that.
Code: Select all
...
struct Screen *screen;
int32 posX;
/* the default public screen */
screen = IIntuition->LockPubScreen(NULL);
if (screen)
{
/* plus one, see <intuition/screens.h> */
posX = screen->BarHeight + 1;
...
IIntuition->UnlockPubScreen(NULL, screen);
}
...
Re: Specify the exact position of a window in a screen
Posted: Sat Jan 18, 2014 5:13 pm
by salass00
As gazelle says the WA_Left and WA_Top values are the absolute x and y coordinates for the top left corner of your window. It is how you position your window if none of the predefined WINDOW_Position modes is suitable.
To place the window just below the title bar just set WA_Top to "screen->BarHeight + 1".
Re: Specify the exact position of a window in a screen
Posted: Mon Jan 20, 2014 12:39 pm
by AmiHyperion
Thank you for the info. I solved in a different way. I'll post the code as soon as i get back to my Amiga.
@Salass00
I sent you a PM on os4coding.
Re: Specify the exact position of a window in a screen
Posted: Mon Feb 17, 2014 12:59 pm
by AmiHyperion
What about positioning gadgets?
It is possible to specify the exact position?
Edit: found this in the wiki:
"The position and dimensions of the gadget's select box are defined in the Gadget structure. The LeftEdge, TopEdge, Width and Height values can be absolute numbers or values relative to the size of the window."
Still valid?
Re: Specify the exact position of a window in a screen
Posted: Wed Feb 19, 2014 4:59 pm
by AmiHyperion
What should i change to specify the exact position of this image button?
Code: Select all
LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
IIntuition->NewObject(NULL, "button.gadget",
GA_ID, OBJ_BUT1,
BUTTON_BevelStyle, BVS_NONE,
BUTTON_Transparent, TRUE,
BUTTON_RenderImage, gadgets[OBJ_BUT1_UNSEL] = /*BitMapObject,*/
IIntuition->NewObject(NULL, "bitmap.image",
BITMAP_SourceFile, "images/AUP.png",
BITMAP_DisabledSourceFile, "images/Object1.png",
BITMAP_Screen, scr,
BITMAP_Masking, TRUE,
TAG_END),
/*BitMapEnd,*/
BUTTON_SelectImage, gadgets[OBJ_BUT1_SEL] = /*BitMapObject,*/
IIntuition->NewObject(NULL, "bitmap.image",
BITMAP_SourceFile, "images/Object1.png",
BITMAP_Screen, scr,
BITMAP_Masking, TRUE,
TAG_END),
Re: Specify the exact position of a window in a screen
Posted: Wed Feb 19, 2014 8:06 pm
by AmiHyperion
i tried to add GA_Left and GA_Top to specify the exact position, but the gadget appears always in the middle of the screen
LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
IIntuition->NewObject(NULL, "button.gadget",
GA_ID, OBJ_BUT1,
GA_Left, 10,
GA_Top, 10,
Re: Specify the exact position of a window in a screen
Posted: Wed Feb 19, 2014 9:14 pm
by salass00
@AmiHyperion
You should be able to use LAYOUT_NoLayout tag if you want to manually position all gadgets/images added to a layout. Not that I see why you want to do this. If you let layout.gadget handle the positioning it will care of all the boring stuff like font sensitivity and such while if you do it yourself you will have to do this stuff manually.