nanogui: backgrounds and stippling.
Subject:
backgrounds and stippling.
From:
tj ####@####.####
Date:
10 May 2004 21:41:12 +0100
Message-Id: <409FE8D1.60506@comcast.net>
I am having trouble understanding the relationship between a windows
background when created and the backgound of a device context.
I create a window with a red background. In the expose event I create a
device context and set it's forground to black and it's background to
white. I then set a stipple pattern and set node to stipple. I then draw
a filled rectangle. The problem is is the stipple is pattern uses black
as the foreground, but the background part is RED, not white. It seems
to be using the windows original background color of red instead of the
device context background color of white. Here is the code:
#include <stdio.h>
#include "nano-X.h"
static GR_BITMAP g_stipple2[] = {
0x4000,
0x8000
};
int main(int argc, char *argv[])
{
GR_WINDOW_ID wid; /* window id */
GR_GC_ID gc; /* graphics context id */
GR_GC_INFO gcip;
GR_EVENT event; /* current event */
GR_SCREEN_INFO si; /* screen information */
GR_WINDOW_INFO winInfo;
if (GrOpen() < 0) {
fprintf(stderr, "Cannot open graphics\n");
exit(1);
}
wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0,
320, 240, 1,GR_RGB(255,0,0), GR_RGB(0,0,0));
GrGetWindowInfo (wid, &winInfo);
GrSelectEvents (wid, GR_EVENT_MASK_EXPOSURE);
GrMapWindow(wid);
while (1) {
GrGetNextEvent(&event);
switch (event.type) {
case GR_EVENT_TYPE_EXPOSURE:
gc = GrNewGC();
GrSetGCForeground(gc, GR_RGB(0,0,0));
GrSetGCBackground(gc, GR_RGB(255, 255, 255));
GrSetGCFillMode(gc, GR_FILL_STIPPLE);
GrSetGCStipple(gc, g_stipple2, 2, 2);
GrFillRect(wid, gc, 20, 20, 280, 200);
GrDestroyGC(gc);
break;
}
}
}
Why is the stipple not using the device context's background color of white?
tj