Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: jonssonj on February 21, 2006, 05:31:07 PM
-
Hello!
I have opened a custom screen and my own window in c-code. Now I would like to change the background color of the window.
How do I change the background color from the default to white?
BR
JJ
-
@jonssonj
If your window is borderless you can just:
SetRast(win->RPort, 2);
However, if your window has borders then you need to account for them:
{
LONG l, t, w, h;
l = win->BorderLeft;
t = win->BorderTop;
w = win->Width - win->BorderLeft - win->BorderRight;
h = win->Height - win->BorderTop - win->BorderBottom;
if (w > 0 && h > 0)
{
/* White background */
SetAPen(win->RPort, 2);
RectFill(win->RPort, l, t, l + w - 1, t + h - 1);
...
}
}
Another possibility is using WA_BackFill and custom backfill hook.
Here's slightly more complex example showing how it is possible to handle custom colour rendering on any public screen: simplewindow.c (http://www.iki.fi/sintonen/src/misc/simplewindow.c)
-
Thanks a lot Piru!
I will come back with more questions. I have started a little project just to learn me the Amiga GUI stuff.
BR
JJ