Specify the exact position of a window in a screen
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Specify the exact position of a window in a screen
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
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
- salass00
- AmigaOS Core Developer
- Posts: 534
- Joined: Sat Jun 18, 2011 4:12 pm
- Location: Finland
- Contact:
Re: Specify the exact position of a window in a screen
WA_Left and WA_Top tags.
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Re: Specify the exact position of a window in a screen
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.
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
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.
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);
}
...
- salass00
- AmigaOS Core Developer
- Posts: 534
- Joined: Sat Jun 18, 2011 4:12 pm
- Location: Finland
- Contact:
Re: Specify the exact position of a window in a screen
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".
To place the window just below the title bar just set WA_Top to "screen->BarHeight + 1".
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Re: Specify the exact position of a window in a screen
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.
@Salass00
I sent you a PM on os4coding.
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Re: Specify the exact position of a window in a screen
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?
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?
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Re: Specify the exact position of a window in a screen
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),
-
- Posts: 28
- Joined: Tue Aug 30, 2011 8:26 am
Re: Specify the exact position of a window in a screen
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,
LAYOUT_AddChild, gadgets[OBJ_BUT1] = /*ButtonObject,*/
IIntuition->NewObject(NULL, "button.gadget",
GA_ID, OBJ_BUT1,
GA_Left, 10,
GA_Top, 10,
- salass00
- AmigaOS Core Developer
- Posts: 534
- Joined: Sat Jun 18, 2011 4:12 pm
- Location: Finland
- Contact:
Re: Specify the exact position of a window in a screen
@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.
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.