📄 rowcol.c
字号:
static void ClassInitialize( void ){ baseClassExtRec.record_type = XmQmotif; XtSetTypeConverter(XmRString, RcRAdjust, _CvtStringToAdjust, NULL, 0, XtCacheAll, NULL); XtSetTypeConverter(XmRString, RcROrient, _CvtStringToOrient, NULL, 0, XtCacheAll, NULL);}/****************************************************************/static void ClassPartInitialize( WidgetClass w_class ){ _XmFastSubclassInit(w_class, XmDRAWING_AREA_BIT); return;}/**************************************************************** * Let pass thru zero size, we'll catch them in Realize ****************/static void Initialize( Widget wreq, Widget wnew, ArgList args, Cardinal *num_args ){ RowColPart *rc = &((RowColWidget)wnew)->rowcol; rc->inResize = False; rc->setWidth = 0; rc->setHeight = 0;#if XmVersion >= 2000 rc->marginWd = MARGIN_DEFAULT; rc->marginHt = MARGIN_DEFAULT;#endif return;}/**************************************************************** * General redisplay function called on exposure events. ****************/static void Redisplay( Widget wid, XEvent *event, Region region ){ RowColWidget rc = (RowColWidget) wid; RowColCallbackStruct cb; #ifdef DEBUG0 printf("RowCol(%s) - Redisplay\n", wid->core.name);#endif cb.reason = XmCR_EXPOSE; cb.event = event; cb.window = XtWindow (rc); XtCallCallbackList ((Widget) rc, rc->rowcol.exposeCallback, &cb); _XmRedisplayGadgets( (Widget) rc, event, region); return;}/**************************************************************** * Invoke the application resize callbacks. ****************/static void Resize( Widget wid ){ RowColPart *rc = &((RowColWidget)wid)->rowcol; RowColCallbackStruct cb; if ( rc->inResize ) return;#if 0 if ( wid->core.width == rc->width && wid->core.height == rc->height ) return;#endif#ifdef DEBUG printf("RowCol(%s) - Resize\n", wid->core.name); printf(" new geometry is %d by %d at %d %d\n", wid->core.width, wid->core.height, wid->core.x, wid->core.y);#endif rc->inResize = True; rc->setWidth = wid->core.width; rc->setHeight = wid->core.height; cb.reason = XmCR_RESIZE; cb.event = NULL; cb.window = XtWindow(wid); XtCallCallbackList(wid, rc->resizeCallback, &cb); rc->inResize = False;#if 0 rc->width = wid->core.width; rc->height = wid->core.height;#endif return;}/************************************************************************ * ConstraintInitialize ************************************************************************/static void ConstraintInitialize( Widget wreq, Widget wnew, ArgList args, Cardinal * num_args ){ RowColConstraintPart *cpart = GetRowColConstraint(wnew); cpart->prefWd = 0; cpart->prefHt = 0;}/**************************************************************** * This function processes key and button presses and releases * belonging to the RowCol.. ****************/void _RowColInput( Widget wid, XEvent *event, String *params, Cardinal *num_params ){ RowColWidget rc = (RowColWidget) wid; RowColCallbackStruct cb; int x, y; Boolean button_event, input_on_gadget, focus_explicit; if ((event->type == ButtonPress) || (event->type == ButtonRelease)) { x = event->xbutton.x; y = event->xbutton.y; button_event = True; } else if (event->type == MotionNotify) { x = event->xmotion.x; y = event->xmotion.y; button_event = True; } else if ((event->type == KeyPress) || (event->type == KeyRelease)) { x = event->xkey.x; y = event->xkey.y; button_event = False; } else return; /* Unrecognized event (cannot determine x, y of pointer).*/ input_on_gadget = (_XmInputForGadget((Widget)rc, x, y) != NULL); focus_explicit = ((_XmGetFocusPolicy((Widget)rc) == XmEXPLICIT) && (rc->composite.num_children != 0)); if (!input_on_gadget) { if ((!focus_explicit) || (button_event)) { cb.reason = XmCR_INPUT; cb.event = event; cb.window = XtWindow( rc); XtCallCallbackList ((Widget) rc, rc->rowcol.inputCallback, &cb); } } return;}/*--------------------------------------------------------------- * Allow all geometry requests. If we don't like them, we'll change them * later anyway. */static XtGeometryResult GeometryManager( Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply){ RowColPart *rpart = &((RowColWidget)XtParent(w))->rowcol; RowColConstraintPart *cpart = GetRowColConstraint(w);#ifdef DEBUG printf("RowCol - GeometryManager\n"); printf(" %s wants to be %d by %d\n", w->core.name, request->width, request->height);#endif/* * Save the preferred size, but refuse the request */ if ( !(request->request_mode & XtCWQueryOnly) ) { RowColGeometryCallbackStruct cb; cb.needWd = (request->request_mode & CWWidth); cb.needHt = (request->request_mode & CWHeight); if ( cb.needWd || cb.needHt ) { cb.widget = w; if ( cb.needWd ) cb.desiredWd = request->width; else cb.desiredWd = w->core.width; if ( cb.needHt ) cb.desiredHt = request->height; else cb.desiredHt = w->core.height; XtCallCallbackList(XtParent(w), rpart->childGeometryCallback, &cb); } } /* End if not a query */ return XtGeometryNo;}/*--------------------------------------------------------------- * Handle change in children */static voidChangeManaged( Widget wid){ RowColWidget rcw = (RowColWidget)wid; _XmNavigChangeManaged(wid); return;}/*--------------------------------------------------------------- * Check for changes. Ask for expose event if necessary. */static Boolean SetValues( Widget wold, /* Values before call */ Widget wreq, /* Values user requested */ Widget wnew, /* Values after base class processing */ ArgList args, Cardinal *num_args ){ RowColPart *rold = &((RowColWidget)wold)->rowcol; RowColPart *rnew = &((RowColWidget)wnew)->rowcol; Boolean otherChange;#ifdef DEBUG printf("RowCol - SetValues\n");#endif/* * If the size has changed, call the Resize function. Any other changes * will get picked up at this time. */ if ( wnew->core.width != wold->core.width || wnew->core.height != wold->core.height ) { Resize(wnew); return False; }/* * If there is any other type of change, ask for a redisplay. */ return (rnew->marginWd != rold->marginWd || rnew->marginHt != rold->marginHt || rnew->wResizePolicy != rold->wResizePolicy || rnew->hResizePolicy != rold->hResizePolicy || rnew->rowAlignment != rold->rowAlignment || rnew->colAlignment != rold->colAlignment || rnew->rowAdjust != rold->rowAdjust || rnew->colAdjust != rold->colAdjust || rnew->orient != rold->orient || rnew->rowResizeOk != rold->rowResizeOk || rnew->colResizeOk != rold->colResizeOk || rnew->uniformRows != rold->uniformRows || rnew->uniformCols != rold->uniformCols || rnew->rowCount != rold->rowCount || rnew->colCount != rold->colCount || rnew->rowSpacing != rold->rowSpacing || rnew->colSpacing != rold->colSpacing);} /* End SetValues *//*--------------------------------------------------------------- * Someone wants to know how big we want to be. */static XtGeometryResult QueryGeometry( Widget wid, XtWidgetGeometry *ask, XtWidgetGeometry *answer ){ RowColGeometryCallbackStruct cb; RowColPart *rpart = &((RowColWidget)wid)->rowcol; Boolean needWd, needHt; Boolean acceptWd, acceptHt;#ifdef DEBUG printf("RowCol(%s) - QueryGeometry with mode %d\n", wid->core.name, ask->request_mode);#endif *answer = *ask;/* * Let the RowColC class calculate the desired size */ needWd = (ask->request_mode & CWWidth) == CWWidth; needHt = (ask->request_mode & CWHeight) == CWHeight; cb.widget = wid; cb.needWd = needWd; cb.needHt = needHt; cb.desiredWd = ask->width; cb.desiredHt = ask->height;#ifdef DEBUG if ( needWd ) printf(" requested width %d\n", ask->width); if ( needHt ) printf(" requested height %d\n", ask->height);#endif XtCallCallbackList(wid, rpart->geometryCallback, &cb);/* * Report the calculated sizes */ answer->request_mode = (CWWidth | CWHeight); answer->width = cb.desiredWd; answer->height = cb.desiredHt;#ifdef DEBUG printf(" our preferred size is %d by %d\n", answer->width, answer->height);#endif/* * Use the calculated sizes */ acceptWd = !needWd || (ask->width == answer->width); acceptHt = !needHt || (ask->height == answer->height); if ( acceptWd && acceptHt ) {#ifdef DEBUG printf(" we're accepting both width and height\n");#endif return XtGeometryYes; } if ( answer->width == wid->core.width && answer->height == wid->core.height ) {#ifdef DEBUG printf(" we're already the size we want to be\n");#endif return XtGeometryNo; }#ifdef DEBUG if ( !acceptWd ) printf(" we're not accepting the width\n"); if ( !acceptHt ) printf(" we're not accepting the height\n");#endif return XtGeometryAlmost;}static XmNavigabilityWidgetNavigable( Widget wid){ /* If a RowCol has no navigable children, then it is being * used as an X Window work area, so allow navigation to it. */ if( wid->core.sensitive && wid->core.ancestor_sensitive && ((XmManagerWidget) wid)->manager.traversal_on ) { XmNavigationType nav_type = ((XmManagerWidget) wid) ->manager.navigation_type; Widget *children = ((XmManagerWidget) wid)->composite.children; unsigned idx = 0; while( idx < ((XmManagerWidget) wid)->composite.num_children ) {#ifndef AIX if( _XmGetNavigability( children[idx]) ) {#endif if( (nav_type == XmSTICKY_TAB_GROUP) || (nav_type == XmEXCLUSIVE_TAB_GROUP) || ( (nav_type == XmTAB_GROUP) && !_XmShellIsExclusive( wid)) ) { return XmDESCENDANTS_TAB_NAVIGABLE; } return XmDESCENDANTS_NAVIGABLE;#ifndef AIX }#endif ++idx; } if( (nav_type == XmSTICKY_TAB_GROUP) || (nav_type == XmEXCLUSIVE_TAB_GROUP) || ( (nav_type == XmTAB_GROUP) && !_XmShellIsExclusive( wid)) ) { return XmTAB_NAVIGABLE; } return XmCONTROL_NAVIGABLE; } return XmNOT_NAVIGABLE;}/**************************************************************** * This function creates and returns a RowCol widget. ****************/Widget CreateRowCol( Widget p, String name, ArgList args, Cardinal n ){ return XtCreateWidget(name, rowColWidgetClass, p, args, n);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -