/* rws 7 Apr 1997 It is best to start this with -geometry +500+500 (or whatever) otherwise the time to place it by the window manager bungs up the first test Is there a event, or callback one can use to figure out when the window has been placed???? */ #include #include #include #include #define TOPLABEL 0 #define BOTLABEL 1 typedef struct { int time; Boolean autoExit; } AppResources_t, *AppResourcesPtr; AppResources_t AppResources; static String FallBack[] = { "*geometry: +500+500", "*borderWidth: 1", NULL}; static XtResource resources[] = { {"time","time",XtRInt,sizeof(int),XtOffset(AppResourcesPtr,time),XtRImmediate, (void *)1000}, {"autoExit","autoExit",XtRBoolean,sizeof(Boolean),XtOffset(AppResourcesPtr,autoExit),XtRImmediate, (void *)False}, }; static XrmOptionDescRec opTable[] = { {"-time",".time",XrmoptionSepArg, NULL}, {"-autoExit",".autoExit",XrmoptionNoArg, "True"}, }; Boolean GlobalResult1 = True; XtWidgetGeometry *ExpectedResults; XtAppContext app; static void FinishTest(Widget W); static Boolean DoAllTests(Widget W); static Boolean Skeleton(Widget W) { WidgetList kids; Cardinal numkids; XtWidgetGeometry Form; XtWidgetGeometry Kid1; XtWidgetGeometry Kid2; XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, XmNx, &Form.x, XmNy, &Form.y, XmNwidth, &Form.width, XmNheight, &Form.height, NULL); XtVaGetValues(kids[TOPLABEL], XmNx, &Kid1.x, XmNy, &Kid1.y, XmNwidth, &Kid1.width, XmNheight, &Kid1.height, XmNborderWidth, &Kid1.border_width, NULL); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); XtVaSetValues(kids[TOPLABEL], NULL); XtVaSetValues(kids[BOTLABEL], NULL); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = Form.x; ExpectedResults[0].y = Form.y; ExpectedResults[0].width = Form.width; ExpectedResults[0].height = Form.height; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = Kid1.x; ExpectedResults[1].y = Kid1.x; ExpectedResults[1].width = Kid1.width; ExpectedResults[1].height = Kid1.height; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].x = Kid2.x; ExpectedResults[2].y = Kid2.y; ExpectedResults[2].width = Kid2.width; ExpectedResults[2].height = Kid2.height; printf("Test ? a skeleton for more tests (does nothing)\n"); FinishTest(W); return(True); } static Boolean Test6(Widget W) { WidgetList kids; Cardinal numkids; XtWidgetGeometry Form; XtWidgetGeometry Kid1; XtWidgetGeometry Kid2; fprintf(stderr, "Test 6 Starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, XmNx, &Form.x, XmNy, &Form.y, XmNwidth, &Form.width, XmNheight, &Form.height, NULL); XtVaGetValues(kids[TOPLABEL], XmNx, &Kid1.x, XmNy, &Kid1.y, XmNwidth, &Kid1.width, XmNheight, &Kid1.height, XmNborderWidth, &Kid1.border_width, NULL); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); XtUnrealizeWidget(XtParent(W)); XtUnrealizeWidget(W); XtUnrealizeWidget(kids[TOPLABEL]); XtUnrealizeWidget(kids[BOTLABEL]); XtUnmanageChild(kids[BOTLABEL]); XtVaSetValues(W, XmNwidth, 215, XmNheight, 0, NULL); XtVaSetValues(kids[TOPLABEL], XmNwidth, 0, XmNheight, 0, NULL); XtVaSetValues(kids[BOTLABEL], XmNwidth, 0, XmNheight, 0, NULL); XtVaSetValues(kids[0], XmNtopAttachment, XmATTACH_NONE, NULL); XtVaSetValues(kids[0], XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_NONE, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, kids[1], XmNleftOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNwidth, 90, XmNheight, 0, NULL); XtVaSetValues(kids[1], XmNbottomAttachment, XmATTACH_FORM, NULL); XtVaSetValues(kids[1], XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_NONE, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_NONE, XmNleftOffset, 10, XmNwidth, 100, XmNheight, 0, NULL); XtManageChild(kids[0]); XtManageChild(kids[1]); XtManageChild(W); XtRealizeWidget(XtParent(W)); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = Form.x; ExpectedResults[0].y = Form.y; ExpectedResults[0].width = Form.width; ExpectedResults[0].height = Form.height; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = Kid1.x; ExpectedResults[1].y = Kid1.x; ExpectedResults[1].width = Kid1.width; ExpectedResults[1].height = Kid1.height; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].x = Kid2.x; ExpectedResults[2].y = Kid2.y; ExpectedResults[2].width = Kid2.width; ExpectedResults[2].height = Kid2.height; printf("Test 6\n"); FinishTest(W); return(True); } static Boolean Test5(Widget W) { WidgetList kids; Cardinal numkids; XtWidgetGeometry Form; XtWidgetGeometry Kid1; XtWidgetGeometry Kid2; fprintf(stderr,"Test 5 starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, XmNx, &Form.x, XmNy, &Form.y, XmNwidth, &Form.width, XmNheight, &Form.height, NULL); XtVaGetValues(kids[TOPLABEL], XmNx, &Kid1.x, XmNy, &Kid1.y, XmNwidth, &Kid1.width, XmNheight, &Kid1.height, XmNborderWidth, &Kid1.border_width, NULL); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); XtUnmanageChild(kids[TOPLABEL]); XtVaSetValues(W, NULL); XtVaSetValues(kids[TOPLABEL], NULL); XtVaSetValues(kids[BOTLABEL], XmNwidth, 100, XmNheight, 50, NULL); XtManageChild(kids[BOTLABEL]); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = Form.x; ExpectedResults[0].y = Form.y; ExpectedResults[0].width = 100 + 2 * Kid2.border_width; ExpectedResults[0].height = 50 + 2 * Kid2.border_width; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = Kid1.x; ExpectedResults[1].y = Kid1.x; ExpectedResults[1].width = Kid1.width; ExpectedResults[1].height = Kid1.height; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].x = Kid2.x; ExpectedResults[2].y = Kid2.y; ExpectedResults[2].width = 100; ExpectedResults[2].height = 50; printf("Test 5\n"); FinishTest(W); return(True); } static Boolean Test4(Widget W) { WidgetList kids; Cardinal numkids; XtWidgetGeometry Form; XtWidgetGeometry Kid1; XtWidgetGeometry Kid2; fprintf(stderr,"Test 4 starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, XmNx, &Form.x, XmNy, &Form.y, XmNwidth, &Form.width, XmNheight, &Form.height, NULL); XtVaGetValues(kids[TOPLABEL], XmNx, &Kid1.x, XmNy, &Kid1.y, XmNwidth, &Kid1.width, XmNheight, &Kid1.height, XmNborderWidth, &Kid1.border_width, NULL); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); XtUnmanageChild(W); XtVaSetValues(kids[BOTLABEL], XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_NONE, NULL); XtVaSetValues(kids[TOPLABEL], XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, kids[1], NULL); XtManageChild(kids[BOTLABEL]); XtManageChild(W); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = Form.x; ExpectedResults[0].y = Form.y; ExpectedResults[0].width = Form.width; ExpectedResults[0].height = Form.height; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = Kid2.width + 2 * Kid2.border_width; ExpectedResults[1].y = Kid1.x; ExpectedResults[1].width = Form.width - Kid2.width - 2 * Kid1.border_width - 2 * Kid2.border_width; ExpectedResults[1].height = Kid1.height; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].x = Kid2.x; ExpectedResults[2].y = 0; ExpectedResults[2].width = Kid2.width; ExpectedResults[2].height = Kid2.height; printf("Test 4\n"); FinishTest(W); return(True); } static Boolean Test3(Widget W) { WidgetList kids; Cardinal numkids; XtWidgetGeometry Form; XtWidgetGeometry Kid1; XtWidgetGeometry Kid2; fprintf(stderr,"Test 3 starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, XmNx, &Form.x, XmNy, &Form.y, XmNwidth, &Form.width, XmNheight, &Form.height, NULL); XtVaGetValues(kids[TOPLABEL], XmNx, &Kid1.x, XmNy, &Kid1.y, XmNwidth, &Kid1.width, XmNheight, &Kid1.height, XmNborderWidth, &Kid1.border_width, NULL); XtVaGetValues(kids[BOTLABEL], XmNx, &Kid2.x, XmNy, &Kid2.y, XmNwidth, &Kid2.width, XmNheight, &Kid2.height, XmNborderWidth, &Kid2.border_width, NULL); XtVaSetValues(kids[TOPLABEL], XmNrightAttachment, XmATTACH_NONE, XmNwidth, Kid1.width * 4, NULL); ExpectedResults[0].request_mode = CWWidth | CWHeight; ExpectedResults[0].x = 0; ExpectedResults[0].y = 0; ExpectedResults[0].width = Kid1.width * 4 + 2 * Kid1.border_width; ExpectedResults[0].height = Form.height; ExpectedResults[1].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[1].x = 0; ExpectedResults[1].y = 0; ExpectedResults[1].width = Kid1.width * 4; ExpectedResults[1].height = Kid1.height; ExpectedResults[2].request_mode = CWX | CWY | CWWidth | CWHeight; ExpectedResults[2].request_mode = 0; ExpectedResults[2].x = 0; ExpectedResults[2].y = 0; ExpectedResults[2].width = 0; ExpectedResults[2].height = 0; printf("Test 3\n"); FinishTest(W); return(True); } static Boolean Test2(Widget W) { Dimension h,w; Dimension ch,cw,bw,mw; Position cx,cy; WidgetList kids; Cardinal numkids; int i; XmString string; XmFontList font_list; fprintf(stderr,"Test 2 starting...\n"); XtVaGetValues(W, XmNchildren, &kids, XmNnumChildren, &numkids, NULL); XtVaSetValues(kids[TOPLABEL], XmNbottomAttachment, XmATTACH_NONE, NULL); for (i = 1; i