Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
136 user(s) are online (132 user(s) are browsing Forums)

Members: 0
Guests: 136

more...

Support us!

Headlines

 
  Register To Post  

Virtual gadget? (was:[Solved]Plain and simple rectangle)
Quite a regular
Quite a regular


See User information
I posted this question on utilitybase but was told I would get more luck asking Rigo or ssolie over here.

How do I create a simple rectangle (preferably non-fixed) that I can draw something in in a ReAction window??

I have tried Filler, Frame, FillRect but was told Space was the way to go. With the three former I got nothing, not a single pixel. With Space I atleast get my hook called but as expected its parameters doesn't contain any relevant information, such as the very simple x/x/w/h of my object in the window.

I tried using "render->gpr_GInfo->gi_Gadget->LeftEdge" etc. but that gives me the size of the parent group. Very useful... (not).

Tried "render->gpr_GInfo->gi_Domain.Left" etc. but those apparently hold the size of the window. Come on!

How do I do this and why is it so difficult??


Edited by Deniil on 2010/11/23 15:39:48
Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
mm, and yea, I would like a frame around this thing once it is able to draw itself properly. Tried SPACE_BevelStyle,BVS_DISPLAY, for the Space gadget and a few other things but I get nothing.

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Not too shy to talk
Not too shy to talk


See User information
@Deniil

Your function gets the object pointer as second argument. Simply use ((struct Gadget *)o)->LeftEdge, TopEdge, Width and Height or use GetAttr(GA_Left,o,&buffer) etc.

Go to top
Re: Plain and simple rectangle in a ReAction window???
Amigans Defender
Amigans Defender


See User information
@Deniil

space.gadget is easy.

Use:
GetAttr(SPACE_AreaBox, mygadgetptr, (ULONG *)&bbox);
(where bbox is struct IBox *)
to get the dimensions and position in the window's rastport

Then write to the rastport taking care not to write over the edge of the space gadget.

Not sure about the bevels, they should work but I don't think I've ever tried them.

Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
@thomas

Shouldn't the gi_Gadget be the same gadget? That one doesn't have the correct values in the Left/Top/.. fields.

Anyway, I tried GetAttr(GA_Left,o,&buffer) and it worked so only problem left was that it draws over its border. I just hardcoded 2 pixels border to get around that...

@Chris

If the space gadget is easy, there's no hope what so ever getting the virtual gadget to draw itself properly, is there?

Don't I need to specify an AreaBox to be able to use it? Anyway, the GA_Left etc work fine so I'll just leave it at that.

Next problem is a virtual group that basically works as it should but when checkmarks are redrawn (because of external changes) it defaults to the system background (pen 0), not the ReAction background. Also the area around the virtual is drawn in the pen 0 instead of the RA background.

What's wrong here?

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
@thomas

Just tried ((struct Gadget *)o)->LeftEdge to save a few CPU cycles but that doesn't work. I get garbage values and nothing drawn in my gadgets.

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Amigans Defender
Amigans Defender


See User information
@Deniil

Quote:
Don't I need to specify an AreaBox to be able to use it?


No, the gadget fills this in for you with its current dimensions.

Quote:
Anyway, the GA_Left etc work fine so I'll just leave it at that.


I'd be wary of that, that will be the gadget location and size, whereas SPACE_AreaBox gives you the dimensions of the area you are allowed to draw into.

Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
@Deniil

It's easy to get the wrong values. The SpaceBox returns a pointer to an IBox, so you have to give it an address to write that pointer into. If you do this, it'll work:

struct IBox *spacePtr = NULL;

IIntuition->GetAttrs (SpaceGadget,
SPACE_AreaBox, &spacePtr,
TAG_END);
// The GetAttrs call returns a pointer to an internal IBox and writes that pointer into the address that you specify.

printf ("SpaceBox = Y: [%d:%d], X: [%d:%d]\n",
(int16)spacePtr->Top, (int16)spacePtr->Top + (int16)spacePtr->Height - 1,
(int16)spacePtr->Left, (int16)spacePtr->Left + (int16)spacePtr->Width - 1);

The only way to get the right background colour is to use IGraphics->RectFill() to fill the Space gadget before you draw your stuff into it.

If you specify a Bevel, it draws it on the inside of the box, but also occupies a 4-pixel margin around the inside of the box. That margin is redrawn every time the rastport is refreshed, so anything you put within that margin will be erased.

cheers
tony
Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
@tonyw & Chris

I'd give the AreaBox a try. As it sounds, it will rid me of the hardcoded 2-pixel offset I have to use to not draw over the border/bevel. But if AreaBox gives me a 4 pixel offset it would not look good. But I guess it may depend on the border/bevel I use. Mine is 2 pixel so perhaps AreaBox will give me 2 pixels, not 4.

About filling this thing, yes I use RectFill and that is all I need. I simply want to show the user what pen he selected. Simple as that


Now, back to the Virtual gadget! This one cannot seem to draw the correct background for its border and gadgets, although the main area inside the virtual uses the correct background. Is there any special flag I need to set to all children to tell them they are in a virtual group?

Did I mention the virtual gadget is in a page group?

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
This is what virtual looks like.

I am using RefreshVirtualGadget() for all refresh of those gadgets whenever I change them and that corrected some layout issues and clipping, but not the background.

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Virtual gadget? (was:[Solved]Plain and simple rectangle)
Quite a regular
Quite a regular


See User information
BUMP

Could it be that noone has ever used the virtual.gadget, especially not in a page group, if that would make a difference?

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Virtual gadget? (was:[Solved]Plain and simple rectangle)
Just popping in
Just popping in


See User information
@Deniil

Could be, after all there is no example for this in the SDK.
Did you try with a custom backfill hook ?

Go to top
Re: Plain and simple rectangle in a ReAction window???
Just can't stay away
Just can't stay away


See User information
@Deniil

Quote:
I am using RefreshVirtualGadget()

Try also IVirtual->RethinkVirtualSize() or/and ILayout->RethinkLayout(). If you're using Clicktab gadget have you tried also ILayout->RefreshPageGadget() ?

Rock lobster bit me - so I'm here forever
X1000 + AmigaOS 4.1 FE
"Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Go to top
Re: Plain and simple rectangle in a ReAction window???
Quite a regular
Quite a regular


See User information
@centaurz

What should I draw in the custom backfill hook if I created one? In fact, custom is exactly what I don't want in this case, I want the default.

The virtual knows what the default is because it draws the correct background where there is no gadget. It seems like its gadgets fail to get the correct backfill hook when put into a virtual.

@TSK

I could try those. I am using a ClickTab. Perhaps I need to perform a RefreshPageGadget on the virtual itself?

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Plain and simple rectangle in a ReAction window???
Amigans Defender
Amigans Defender


See User information
@Deniil

Quote:

I am using a ClickTab. Perhaps I need to perform a RefreshPageGadget on the virtual itself?

I'd guess so. Refreshing a clicktab.gadget will only refresh the tabs, not the contents of the pages that are associated with the individual tabs. I think.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project