Hi,
I am having a problem that I cannot seem to trace, so I'm calling
for help.
The lib/Xbae/examples/list/list2 example program allows you to
play with resizing rows in an Xbae matrix. This requires that
resizable rows is compiled in, of course.
The problem is that resizing the last row doesn't work right.
The text still appears completely, while background is correctly
clipped. Observe this in list2 by starting the app, scrolling
completely down, then enter 9 in the left textfield (row number),
5 in the second textfield (the new height, in pixels), and then
hitting the button to the lower right. The background will become
partially gray (this is good, the background is clipped as it
should), but the text still appears completely.
Attached is also a small example program (test1.c) which shows that
clipping text is possible.
I've already tried printing the GC's function field, thinking it
might be different in lib/Xbae/src/Draw.c and test1.c, but it
shows the same value (3).
Does anyone have a clue ?
Danny
--
Danny Backx ([EMAIL PROTECTED] [EMAIL PROTECTED])
Home page : http://users.skynet.be/danny.backx
Projects: LessTif (http://www.lesstif.org)
Oleo (http://www.gnu.org/software/oleo/oleo.html)
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/DrawnB.h>
void HiCB(Widget w,XtPointer client_data,XtPointer call_data);
int
main(int argc, char **argv)
{
XtAppContext theApp;
Widget toplevel;
Widget butt;
toplevel = XtVaAppInitialize(&theApp, "drawn", NULL, 0,
&argc, argv, NULL, NULL);
butt= XtVaCreateManagedWidget("Button1", xmDrawnButtonWidgetClass, toplevel,
XmNwidth, 100,
XmNheight, 100,
NULL);
XtAddCallback(butt,XmNarmCallback,HiCB,NULL);
XtAddCallback(butt,XmNdisarmCallback,HiCB,NULL);
XtAddCallback(butt,XmNactivateCallback,HiCB,NULL);
XtAddCallback(butt,XmNexposeCallback,HiCB,NULL);
XtAddCallback(butt,XmNresizeCallback,HiCB,NULL);
XtRealizeWidget(toplevel);
XtAppMainLoop(theApp);
exit(0);
}
void draw(Widget w, Window win, Dimension width, Dimension height, Pixel color)
{
GC gc;
XFontSet fs;
XRectangle clipht;
char **x, *y;
int z;
Font f;
XGCValues v;
unsigned long mask;
gc = XtAllocateGC(w, 0,0, NULL, 0,0);
clipht.height = 40;
clipht.width = 200;
clipht.x = 0;
clipht.y = 0;
XSetClipRectangles(XtDisplay(w), gc, 0, 0, &clipht, 1, Unsorted);
XSetForeground(XtDisplayOfObject(w),
gc,
color);
fs = XCreateFontSet(XtDisplay(w), "lucidasans-24", &x, &z, &y);
f = XLoadFont(XtDisplay(w), "lucidasans-24");
XSetFont(XtDisplay(w), gc, f);
/* NOTE: the skip is per Motif -- no effort is made to avoid the shadows */
XDrawRectangle(XtDisplayOfObject(w), win, gc,
10, 10, width - 20, height - 20);
// XmbDrawString(XtDisplay(w), win, fs, gc, 20, 50, "This is it", 10);
XDrawString(XtDisplay(w), win, gc, 20, 50, "This is it", 10);
mask = GCFunction;
XGetGCValues(XtDisplay(w), gc, mask, &v);
fprintf(stderr, "GCValues: operand %x\n", v.function);
// XSetClipMask(XtDisplay(mw), gc, None);
XtReleaseGC(w, gc);
}
void HiCB(Widget w,XtPointer client_data,XtPointer call_data)
{
XmDrawnButtonCallbackStruct *cbs = (XmDrawnButtonCallbackStruct *)call_data;
Dimension width, height;
Pixel color;
XtVaGetValues(w,
XmNwidth, &width,
XmNheight, &height,
XmNforeground, &color,
NULL);
switch (cbs->reason) {
case XmCR_ARM:
printf("Widget armed\n");
break;
case XmCR_DISARM:
printf("Widget disarmed\n");
break;
case XmCR_ACTIVATE:
printf("Widget activated\n");
break;
case XmCR_EXPOSE:
printf("Widget exposed\n");
draw(w, cbs->window, width, height, color);
break;
case XmCR_RESIZE:
printf("Widget resized\n");
draw(w, cbs->window, width, height, color);
break;
default:
printf("callback for unknown reason\n");
}
}