XSetForeground (g_display, gc, g_colors[GRAY].pixel);
XSetFillStyle (g_display, gc, FillSolid);
XFillRectangle (g_display, get_x_window_id (button), gc,
3, 3, rect_size.width - 6, rect_size.height - 6);
//XFlushGC (g_display, gc);
//XFlush (g_display);
XSetForeground (g_display, gc, g_colors[BLACK].pixel);
XDrawRectangle (g_display, get_x_window_id (button), gc, 4,
4, 8 - 1, 8 - 1);
It still doesn't work using the flush functions. I even went as far and
closing the GC and creating a new one between the 2 calls but still no go.
If I comment out the XFillRectangle call, XDrawRectangle works fine. This
code worked fine on previous version of X but for some reason now it stopped
working. I am using X version X.Org X Server 1.6.1 with the proprietary ATI
display driver.
Also if I use XDrawLine() instead of XDrawRectangle() the lines are drawn.
Any ideas what could be wrong?
Thanks in advance,
Charlie
I don't have these, so I can only offer generic suggestions.
Since assuming that all the variables you didn't tell us about have
"reasonable" values is usually a mistake when debugging other people's
code, ...
> For some reason XDrawRectangle() refuses to draw over an area drawn with
> XFillRectangle(). Here is the code snippet:
>
> XSetForeground (g_display, gc, g_colors[GRAY].pixel);
> XSetFillStyle (g_display, gc, FillSolid);
> XFillRectangle (g_display, get_x_window_id (button), gc,
> 3, 3, rect_size.width - 6, rect_size.height - 6);
You didn't say what values rect_size.{width,height} have.
Do you get the same result when you use constants?
> //XFlushGC (g_display, gc);
> //XFlush (g_display);
>
> XSetForeground (g_display, gc, g_colors[BLACK].pixel);
> XDrawRectangle (g_display, get_x_window_id (button), gc, 4,
> 4, 8 - 1, 8 - 1);
>
> It still doesn't work using the flush functions.
What about when you put the flush functions after the XDrawRectangle?
What happens if you offset the XDrawRectangle coordinates so that the
rectangle is wholly or partly outside the filled rectangle?
> I even went as far and closing the GC and creating a new one between the
> 2 calls but still no go.
You haven't said what your GC's other properties are, but ...
> Also if I use XDrawLine() instead of XDrawRectangle() the lines are drawn.
AFAIK, XDrawRectangle and XDrawLine use the same GC components, so if you
really exactly replaced the XDrawRectangle with 4 XDrawLine calls or 1
XDrawLines() call, and the latter work where the former didn't, and if
these are the last X calls you make, then I'm back to thinking XFlush().
HTH,
-WBE
> Charlie <nos...@embarqmail.com> posted:
>> For some reason XDrawRectangle() refuses to draw over an area drawn with
>> XFillRectangle(). Here is the code snippet:
>>
>> XSetForeground (g_display, gc, g_colors[GRAY].pixel);
>> XSetFillStyle (g_display, gc, FillSolid);
>> XFillRectangle (g_display, get_x_window_id (button), gc,
>> 3, 3, rect_size.width - 6, rect_size.height - 6);
>
> You didn't say what values rect_size.{width,height} have.
> Do you get the same result when you use constants?
>
Sorry about that. Here is the same code with constants for position/size:
XSetForeground (g_display, gc, g_colors[color_face].pixel);
XSetFillStyle (g_display, gc, FillSolid);
XFillRectangle (g_display, get_x_window_id (button), gc, 3, 3, 10, 10);
XSetForeground (g_display, gc, g_colors[BLACK].pixel);
XDrawRectangle (g_display, get_x_window_id (button), gc, 4, 4, 7, 7);
>
> What about when you put the flush functions after the XDrawRectangle?
>
Same results
> What happens if you offset the XDrawRectangle coordinates so that the
> rectangle is wholly or partly outside the filled rectangle?
It draws the rectangle correctly anywhere XFillRectangle didn't draw to. It
is like XFillRectangle creates a mask. XDrawRectangle will draw over areas
drawn previously with XDrawLine.
>
>> I even went as far and closing the GC and creating a new one between the
>> 2 calls but still no go.
>
> You haven't said what your GC's other properties are, but ...
>
>> Also if I use XDrawLine() instead of XDrawRectangle() the lines are
>> drawn.
>
> AFAIK, XDrawRectangle and XDrawLine use the same GC components, so if you
> really exactly replaced the XDrawRectangle with 4 XDrawLine calls or 1
> XDrawLines() call, and the latter work where the former didn't, and if
> these are the last X calls you make, then I'm back to thinking XFlush().
>
I found out something else. If I add this line before XDrawRectangle the
rectangle is drawn correctly over top the XFillRectangle area:
XSetLineAttributes (g_display, gc, 1, LineSolid, CapButt, JoinMiter);
Notice the 1 line thickness. I can't use a 1 line thickness with XDrawLine
because it causes the lines not to be drawn. I have to use the default 0
line thickness with XDrawLine. Prior versions of X that I used were fine
with a 1 line thickness with both XDrawLine and XDrawRectangle.
Thanks again,
Charlie
How did you create the GC? Is it shared?
--
Fred K
> On Jul 5, 5:17 am, Charlie <nos...@embarqmail.com> wrote:
>> Winston wrote:
>> > Charlie <nos...@embarqmail.com> posted:
>> >> For some reason XDrawRectangle() refuses to draw over an area drawn
>> >> with XFillRectangle(). Here is the code snippet:
>>
>>
>> XSetForeground (g_display, gc, g_colors[color_face].pixel);
>> XSetFillStyle (g_display, gc, FillSolid);
>> XFillRectangle (g_display, get_x_window_id (button), gc, 3, 3, 10, 10);
>> XSetForeground (g_display, gc, g_colors[BLACK].pixel);
>> XDrawRectangle (g_display, get_x_window_id (button), gc, 4, 4, 7, 7);
>>
>>
>
> How did you create the GC? Is it shared?
>
No. I'm not even sure how to create a shared GC. I just use the GC long
enough to draw on the window after an Expose event then it is discarded.
Can anyone else duplicate this behavior? I'm almost sure I found a bug this
time.
Thanks again,
Charlie
Again, how is the GC created - i.e., where does your variable "gc"
come from?
It *will* make a differnece in how things will be drawn.
Probably with one of these?
XtAllocateGC
XtGetGC
XCreateGC
XDefaultGC
--
Fred K
Sorry, I guess I misunderstood you. Here is how I create the GC:
GC gc;
XGCValues values;
values.fill_rule = WindingRule;
gc = XCreateGC (g_display, get_x_window_id (wix), GCFillRule, &values);
I then add a region mask with:
XSetRegion (g_display, gc, reg);
The region is constructed of areas to draw from Expose messages.
Thanks again,
Charlie