Path: utzoo!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!solo.csci.unt.edu!iex!neptune!fm From: fm@neptune.iex.com (Mohammad Faroog) Newsgroups: comp.windows.open-look Subject: OLIT/Stub widget ???? Message-ID: Date: 13 Mar 91 00:39:27 GMT Sender: news@iex.uucp (USENET news) Organization: IEX Corporation Lines: 221 Would you please put some light on stub widget. I want to capture keyboard and mouse events in the stub widget's window. I can capture mouse events but I don't have luck with keyboard event. Do I have to do any black magic. I there a better way to flash a button ( oblongButton ) continously. The way I do it by using XtAppAddTimeOut(). Please send me direct mail. Thanks. My address is : fm@iex.comp Following is the code example : Translation table : *clearButton.label:Clear area *lineButton.label:Draw line *boxButton.label:Draw box *circleButton.label:Draw circle *exitButton.label:Exit editor *drawArea.width:1 *drawArea.height:1 *drawArea.y:50 *drawArea.translations: #override\n\ :eventhandler()\n\ :eventhandler()\n\ :eventhandler()\n\ :eventhandler() ------------------------- #include #include #include #include #include #include #include #include #include #include #define BITMAP_FILE "us.bitmap" XtActionProc EventHandler(w,event,param,num) Widget w; XEvent *event; String *param; Cardinal *num; { puts("in event"); } CBExit(w,client_data,call_data) Widget w; caddr_t client_data, call_data; { exit(); } void main(argc, argv) unsigned int argc; char *argv[]; { Widget w_toplevel, w_form, w_button, w_control, w_draw; int drawImage(); static XtActionsRec new_actions[] = { {"eventhandler",(XtActionProc) EventHandler} }; XtAppContext app_context; w_toplevel = OlInitialize( NULL, /* app name - filled by Xt */ "Ged", /* app class */ NULL, /* option list */ 0, /* # of options */ &argc, /* addr of main argc */ argv /* main argv */ ); app_context = XtWidgetToApplicationContext(w_toplevel); XtAppAddActions(app_context,new_actions,XtNumber(new_actions)); w_form = XtVaCreateManagedWidget( /* create form widget */ "formArea", formWidgetClass, w_toplevel, XtNborderWidth,1, XtNxResizable,FALSE, XtNyResizable, FALSE, NULL ); w_control = XtVaCreateManagedWidget( /* create form widget */ "controlArea", controlAreaWidgetClass, w_form, XtNlayoutType,OL_FIXEDROWS, XtNmeasure, 1, XtNborderWidth,1, NULL ); w_button = XtVaCreateManagedWidget( /* create form widget */ "clearButton", oblongButtonWidgetClass, w_control, NULL ); w_button = XtVaCreateManagedWidget( /* create form widget */ "lineButton", oblongButtonWidgetClass, w_control, NULL ); w_button = XtVaCreateManagedWidget( /* create form widget */ "boxButton", oblongButtonWidgetClass, w_control, NULL ); w_button = XtVaCreateManagedWidget( /* create form widget */ "circleButton", oblongButtonWidgetClass, w_control, NULL ); w_button = XtVaCreateManagedWidget( /* create form widget */ "exitButton", oblongButtonWidgetClass, w_control, NULL ); XtAddCallback(w_button,XtNselect,CBExit,NULL); w_draw = XtVaCreateManagedWidget( "drawArea", stubWidgetClass, w_form, XtNexpose, drawImage, NULL ); (void) XtRealizeWidget(w_toplevel); (void) XtMainLoop(); } drawImage(wid, event, region) Widget wid; XEvent *event; Region region; { XExposeEvent *expose = &event->xexpose; static Pixmap bitmap; static GC gc; static Boolean inited = FALSE; /* * The first time we get called, read in the bitmap * and initialize a graphics context for drawing the image. */ if (inited == FALSE) { XGCValues xgc; Status status; unsigned int width, height; int xhot, yhot; status = XReadBitmapFile( XtDisplay(wid), /* display */ XtWindow(wid), /* any drawable */ BITMAP_FILE, /* file name */ &width, /* returns width */ &height, /* returns height */ &bitmap, /* returns bitmap */ &xhot, /* returns x hotspot */ &yhot /* returns y hotspot */ ); if (status != BitmapSuccess) fprintf(stderr,"XReadBitmapFile Failed\n"); XtVaSetValues( wid, XtNwidth, width, XtNheight, height, NULL); xgc.foreground = XWhitePixelOfScreen(XtScreen(wid)); xgc.background = XBlackPixelOfScreen(XtScreen(wid)); gc = XCreateGC( XtDisplay(wid), /* display */ XtWindow(wid), /* drawable */ GCForeground | GCBackground, /* values to set */ &xgc /* values */ ); inited = TRUE; } XCopyPlane( XtDisplay(wid), /* display */ bitmap, /* bitmap */ XtWindow(wid), /* drawable */ gc, /* graphics context */ expose->x, /* src x */ expose->y, /* src y */ expose->width, /* width */ expose->height, /* height */ expose->x, /* dst x */ expose->y, /* dst y */ 1 /* plane mask */ ); return; } Mohammad.