📄 garray.c
字号:
static void ClassInitialize (void);static void Initialize (Widget, Widget, ArgList, Cardinal *);static void Destroy (Widget);static void Resize (Widget);static Boolean SetValues (Widget, Widget, Widget, ArgList, Cardinal *);static XtGeometryResult GeometryManager ( Widget, XtWidgetGeometry *, XtWidgetGeometry *);static void ChangeManaged (Widget);static void InsertChild (Widget);static void DeleteChild (Widget);static void dolayout (ArrayWidget, int);ArrayClassRec arrayClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &compositeClassRec, /* class_name */ "Array", /* widget_size */ sizeof(ArrayRec), /* class_initialize */ ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber (resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ Resize, /* expose */ XtInheritExpose, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* composite_class fields */ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ InsertChild, /* delete_child */ DeleteChild, /* extension */ NULL }, { /* array_class fields */ /* dummy */ 0 }};WidgetClass arrayWidgetClass = (WidgetClass)&arrayClassRec;int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) { ArrayWidget aw; aw = (ArrayWidget) widget->w; (*func) (data, &aw->array.data); dolayout (aw, TRUE); return 0;}int Gawsetmode (Gwidget_t *widget, int mode) { ArrayWidget aw; aw = (ArrayWidget) widget->w; aw->array.batchmode = mode; dolayout (aw, TRUE); return 0;}int Gawgetmode (Gwidget_t *widget) { ArrayWidget aw; aw = (ArrayWidget) widget->w; return aw->array.batchmode;}void Gawdefcoordscb (int wi, Gawdata_t *dp) { Gawcarray_t *cp; int sx, sy, csx, csy, ci; sx = dp->sx, sy = dp->sy; csx = csy = 0; for (ci = 0; ci < dp->cj; ci++) { cp = &dp->carray[ci]; if (!cp->flag) continue; cp->ox = csx, cp->oy = csy; if (dp->type == G_AWVARRAY) cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs; else cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs; } if (dp->type == G_AWVARRAY) dp->sy = csy; else dp->sx = csx;}static void ClassInitialize (void) { XtAddConverter ( XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, 0 );}static void Initialize ( Widget reqw, Widget neww, ArgList args, Cardinal *num_args) { ArrayWidget aw; aw = (ArrayWidget) neww; if (aw->array.orientation == XtorientVertical) aw->array.data.type = G_AWVARRAY; else aw->array.data.type = G_AWHARRAY; aw->array.data.carray = Marrayalloc ((long) CHILDINCR * CHILDSIZE); aw->array.data.cn = CHILDINCR; aw->array.data.cj = 0; aw->array.batchmode = FALSE; if (aw->core.width == 0) aw->core.width = 100; if (aw->core.height == 0) aw->core.height = 100;}static void Destroy (Widget w) { ArrayWidget aw; aw = (ArrayWidget) w; Marrayfree (aw->array.data.carray); aw->array.data.cn = aw->array.data.cj = 0;}static void Resize (Widget w) { dolayout ((ArrayWidget) w, FALSE);}static Boolean SetValues ( Widget curw, Widget reqw, Widget neww, ArgList args, Cardinal *num_args) { ArrayWidget curaw; ArrayWidget newaw; curaw = (ArrayWidget) curw; newaw = (ArrayWidget) neww; if (curaw->array.orientation != newaw->array.orientation) { if (newaw->array.orientation == XtorientVertical) newaw->array.data.type = G_AWVARRAY; else newaw->array.data.type = G_AWHARRAY; dolayout (newaw, TRUE); return TRUE; } return FALSE;}static XtGeometryResult GeometryManager ( Widget w, XtWidgetGeometry *req, XtWidgetGeometry *rep) { Dimension width, height; if (req->request_mode & ~(CWX | CWY | CWWidth | CWHeight)) return XtGeometryNo; if (req->request_mode & (CWX | CWY | CWWidth | CWHeight)) { width = (req->request_mode & CWWidth) ? req->width : w->core.width; height = (req->request_mode & CWHeight) ? req->height : w->core.height; w->core.width = width, w->core.height = height; dolayout ((ArrayWidget) XtParent (w), TRUE); return XtGeometryYes; } return XtGeometryYes;}static void ChangeManaged (Widget w) { ArrayWidget aw; aw = (ArrayWidget) w; if (!aw->array.batchmode) dolayout (aw, TRUE);}static void InsertChild (Widget w) { ArrayWidget aw; CompositeWidgetClass sclass; sclass = (CompositeWidgetClass) compositeWidgetClass; (*sclass->composite_class.insert_child) (w); aw = (ArrayWidget) XtParent (w); if (aw->array.data.cj == aw->array.data.cn) { aw->array.data.carray = Marraygrow ( aw->array.data.carray, (long) (aw->array.data.cn + CHILDINCR) * CHILDSIZE ); aw->array.data.cn += CHILDINCR; } aw->array.data.carray[aw->array.data.cj++].w = w;}static void DeleteChild (Widget w) { ArrayWidget aw; CompositeWidgetClass sclass; int ci; sclass = (CompositeWidgetClass) compositeWidgetClass; (*sclass->composite_class.delete_child) (w); aw = (ArrayWidget) XtParent (w); for (ci = 0; ci < aw->array.data.cj; ci++) if (aw->array.data.carray[ci].w == w) break; if (ci < aw->array.data.cj) { for (; ci + 1 < aw->array.data.cj; ci++) aw->array.data.carray[ci].w = aw->array.data.carray[ci + 1].w; aw->array.data.cj--; }}static void dolayout (ArrayWidget aw, int flag) { XtWidgetGeometry req, ret_req; Gawdata_t *dp; Gawcarray_t *cp; int sx, sy, ci; if (aw->array.batchmode) return; dp = &aw->array.data; for (ci = 0; ci < dp->cj; ci++) { if (!XtIsManaged (dp->carray[ci].w)) { dp->carray[ci].flag = 0; continue; } cp = &dp->carray[ci]; cp->flag = 1; cp->ox = cp->w->core.x; cp->oy = cp->w->core.y; cp->sx = cp->w->core.width; cp->sy = cp->w->core.height; cp->bs = cp->w->core.border_width; } dp->sx = aw->core.width, dp->sy = aw->core.height; XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp); if ((sx = dp->sx) < MINAWSIZE) sx = MINAWSIZE; if ((sy = dp->sy) < MINAWSIZE) sy = MINAWSIZE; if (flag && (aw->core.width != sx || aw->core.height != sy)) { req.width = sx, req.height = sy; req.request_mode = CWWidth | CWHeight; if (XtMakeGeometryRequest ( (Widget) aw, &req, &ret_req ) == XtGeometryAlmost) { req = ret_req; XtMakeGeometryRequest ((Widget) aw, &req, &ret_req); dp->sx = req.width, dp->sy = req.height; XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp); } } for (ci = 0; ci < dp->cj; ci++) { cp = &dp->carray[ci]; if (!cp->flag) continue; XtConfigureWidget (cp->w, cp->ox, cp->oy, cp->sx, cp->sy, cp->bs); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -