📄 test56.c
字号:
/* $Header: /cvsroot/lesstif/lesstif/test/Xm/form/test56.c,v 1.15 2001/05/16 09:19:46 amai Exp $ simulate an openDX interactor on the control panel switching from vertical to horizontal then back. */ #include <stdio.h>#include <Xm/Xm.h>#include <Xm/FormP.h>#include <Xm/Label.h>#include "../../common/Test.h"#define IGNORE_TEMPVALUEstatic char *FallBack[] ={ "*.borderWidth: 1", NULL};extern int GlobalErrors;/* Fake Form sub-class *//* Fake FormP.h */typedef enum {FormConstraint, ConstraintInitialize, ConstraintSetValues, GeometryManager, ChangeManaged, QueryGeometry, Geometry} ExpectedType;typedef struct { ExpectedType type; String name; Position x, y; Dimension width, height; unsigned char left_type; String left_widget; int left_percent; int left_offset; int left_value; int left_tempValue; unsigned char right_type; String right_widget; int right_percent; int right_offset; int right_value; int right_tempValue; unsigned char top_type; String top_widget; int top_percent; int top_offset; int top_value; int top_tempValue; unsigned char bottom_type; String bottom_widget; int bottom_percent; int bottom_offset; int bottom_value; int bottom_tempValue; String next_sibling; Boolean sorted; Boolean resizable; Dimension preferred_width; Dimension preferred_height; Dimension form_width; Dimension form_height; unsigned long request_mode; Position geox, geoy; Dimension geowidth, geoheight, geoborder_width;} ExpectedResults;typedef struct { ExpectedResults *expected; int expected_count; int expected_index;} FakeFormPart;typedef struct _FakeFormRec { CorePart core; CompositePart composite; ConstraintPart constraint; XmManagerPart manager; XmBulletinBoardPart bulletin_board; XmFormPart form; FakeFormPart fake_form;} FakeFormRec;typedef struct { XtPointer extension;} FakeFormClassPart;typedef struct _FakeFormClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; XmManagerClassPart manager_class; XmBulletinBoardClassPart bulletin_board_class; XmFormClassPart form_class; FakeFormClassPart fake_form_class;} FakeFormClassRec;extern FakeFormClassRec fakeFormClassRec;/* Fake FormP.h *//* Fake Form.h */#ifndef expectedItems#define expectedItems "expectedItems"#endif#ifndef ExpectedItems#define ExpectedItems "ExpectedItems"#endif#ifndef expectedCount#define expectedCount "expectedCount"#endif#ifndef ExpectedCount#define ExpectedCount "ExpectedCount"#endifextern WidgetClass fakeFormWidgetClass;typedef struct _FakeFormRec *FakeFormWidget;typedef struct _FakeFormClassRec *FakeFormWidgetClass;/* Fake Form.h *//* Fake Form.c */static StringAttachmentType2String(unsigned char type){ switch(type) { case XmATTACH_NONE: return("XmATTACH_NONE"); break; case XmATTACH_FORM: return("XmATTACH_FORM"); break; case XmATTACH_OPPOSITE_FORM: return("XmATTACH_OPPOSITE_FORM"); break; case XmATTACH_WIDGET: return("XmATTACH_WIDGET"); break; case XmATTACH_OPPOSITE_WIDGET: return("XmATTACH_OPPOSITE_WIDGET"); break; case XmATTACH_POSITION: return("XmATTACH_POSITION"); break; case XmATTACH_SELF: return("XmATTACH_SELF"); break; default: return("UNKNOWN"); break; }}static StringType2String(ExpectedType type){ switch(type) { case FormConstraint: return("FormConstraint"); break; case ConstraintInitialize: return("ConstraintInitialize"); break; case ConstraintSetValues: return("ConstraintSetValues"); break; case GeometryManager: return("GeometryManager"); break; case ChangeManaged: return("ChangeManaged"); break; case QueryGeometry: return("QueryGeometry"); break; case Geometry: return("Geometry"); break; default: return("UNKNOWN"); break; }}static voidPrintGeometry(Widget w, XtWidgetGeometry *geo){FakeFormWidget Form = (FakeFormWidget)(w); if (Form->fake_form.expected_index < Form->fake_form.expected_count) { printf("%s(%s) ", Type2String(Geometry), Type2String(Form->fake_form.expected[Form->fake_form.expected_index].type)); if (Form->fake_form.expected[Form->fake_form.expected_index].type != Geometry) { printf("Bad\n"); GlobalErrors++; } else { XtWidgetGeometry tmp; printf("%s(", XdbWidgetGeometry2String(geo)); tmp.request_mode = Form->fake_form.expected[Form->fake_form.expected_index].request_mode; tmp.x = Form->fake_form.expected[Form->fake_form.expected_index].geox; tmp.y = Form->fake_form.expected[Form->fake_form.expected_index].geoy; tmp.width = Form->fake_form.expected[Form->fake_form.expected_index].geowidth; tmp.height = Form->fake_form.expected[Form->fake_form.expected_index].geoheight; printf("%s", XdbWidgetGeometry2String(&tmp)); printf(") "); if (geo->request_mode == Form->fake_form.expected[Form->fake_form.expected_index].request_mode && (!(geo->request_mode & CWX) || (geo->request_mode & CWX && geo->x == Form->fake_form.expected[Form->fake_form.expected_index].geox)) && (!(geo->request_mode & CWY) || (geo->request_mode & CWY && geo->y == Form->fake_form.expected[Form->fake_form.expected_index].geoy)) && (!(geo->request_mode & CWWidth) || (geo->request_mode & CWWidth && geo->width == Form->fake_form.expected[Form->fake_form.expected_index].geowidth)) && (!(geo->request_mode & CWHeight) || (geo->request_mode & CWHeight && geo->height == Form->fake_form.expected[Form->fake_form.expected_index].geoheight)) && (!(geo->request_mode & CWBorderWidth) || (geo->request_mode & CWBorderWidth && geo->border_width == Form->fake_form.expected[Form->fake_form.expected_index].geoborder_width)) ) { printf("Okay\n"); } else { printf("Bad\n"); GlobalErrors++; } } Form->fake_form.expected_index++; } else { printf("{Geometry, \"%s\", %i, %i, %i, %i, ", XtName(w), XtX(w), XtY(w), XtWidth(w), XtHeight(w)); printf("0, \"\", 0,0,0,0,"); printf("0, \"\", 0,0,0,0,"); printf("0, \"\", 0,0,0,0,"); printf("0, \"\", 0,0,0,0,"); printf("\"\", False, False, 0, 0, %d, %d, ", XtWidth(w), XtHeight(w)); printf("0 | "); printf("%s", geo->request_mode & CWX ? "CWX | " : ""); printf("%s", geo->request_mode & CWY ? "CWY | " : ""); printf("%s", geo->request_mode & CWWidth ? "CWWidth | " : ""); printf("%s", geo->request_mode & CWHeight ? "CWHeight | " : ""); printf("%s", geo->request_mode & CWBorderWidth ? "CWBorderWidth | " : ""); printf("%s", geo->request_mode & CWSibling ? "CWSibling | " : ""); printf("%s", geo->request_mode & CWStackMode ? "CWStackMode | " : ""); printf("0,"); printf(" %d, %d,", geo->request_mode & CWX ? geo->x : 0, geo->request_mode & CWY ? geo->y : 0); printf(" %d,", geo->request_mode & CWWidth ? geo->width : 0); printf(" %d,", geo->request_mode & CWHeight ? geo->height : 0); printf(" %d", geo->request_mode & CWBorderWidth ? geo->border_width : 0); printf("},\n"); }}static voidPrintConstraints(Widget w){int i;XmFormConstraint constraints = &(((XmFormConstraintPtr)(w->core.constraints))->form);FakeFormWidget Form = (FakeFormWidget)XtParent(w); if (Form->fake_form.expected_index < Form->fake_form.expected_count) { printf("%s(%s)", Type2String(FormConstraint), Type2String(Form->fake_form.expected[Form->fake_form.expected_index].type)); if (Form->fake_form.expected[Form->fake_form.expected_index].type != FormConstraint) { printf("Bad\n"); GlobalErrors++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -