📄 test1.c
字号:
/* $Header: /cvsroot/lesstif/lesstif/test/Xm-2.0/notebook/test1.c,v 1.10 2002/05/01 15:47:32 amai Exp $ */#include <stdio.h>#include <stdlib.h>#include <Xm/Xm.h>#include <Xm/Form.h>#include <Xm/Label.h>#include <Xm/List.h>#include <Xm/MenuShell.h>#include <Xm/Notebook.h>#include <Xm/PushB.h>#include <Xm/RowColumn.h>#include <Xm/ScrolledW.h>#include <Xm/Separator.h>#include <Xm/TextF.h>#include "../../common/Test.h"voidcheck_geometry(Widget w){ static int result_index = 0;static XtWidgetGeometry Expected[] = {/* result test 0 */{ CWWidth | CWHeight , 4, 23, 639, 565, 0,0,0 }, /* test1.motif */{ CWWidth | CWHeight , 4, 23, 639, 565, 0,0,0 }, /* notebook */{ CWWidth | CWHeight | CWX | CWY, 446, 507, 94, 29, 0,0,0 }, /* PageScroller */{ CWWidth | CWHeight | CWX | CWY, 20, 2, 54, 25, 0,0,0 }, /* NBTextField */{ CWWidth | CWHeight | CWX | CWY, -20, -20, 20, 20, 0,0,0 }, /* MajorTabScrollerNext */{ CWWidth | CWHeight | CWX | CWY, -20, -20, 20, 20, 0,0,0 }, /* MajorTabScrollerPrevious */{ CWWidth | CWHeight | CWX | CWY, -20, -20, 20, 20, 0,0,0 }, /* MinorTabScrollerNext */{ CWWidth | CWHeight | CWX | CWY, -20, -20, 20, 20, 0,0,0 }, /* MinorTabScrollerPrevious */{ CWWidth | CWHeight | CWX | CWY, -500, -504, 500, 504, 0,0,0 }, /* configureWindow */{ CWWidth | CWHeight | CWX | CWY, 383, 160, 99, 30, 0,0,0 }, /* moveDownButton */{ CWWidth | CWHeight | CWX | CWY, 259, 160, 99, 30, 0,0,0 }, /* moveUpButton */{ CWWidth | CWHeight | CWX | CWY, 10, 160, 99, 30, 0,0,0 }, /* addDBButton */{ CWWidth | CWHeight | CWX | CWY, 10, 200, 482, 20, 0,0,0 }, /* separator2 */{ CWWidth | CWHeight | CWX | CWY, 134, 160, 100, 30, 0,0,0 }, /* deleteButton */{ CWWidth | CWHeight | CWX | CWY, 10, 426, 480, 20, 0,0,0 }, /* separator1 */{ CWWidth | CWHeight | CWX | CWY, 222, 380, 268, 36, 0,0,0 }, /* dbDescFileTf */{ CWWidth | CWHeight | CWX | CWY, 222, 332, 268, 36, 0,0,0 }, /* dbFileTf */{ CWWidth | CWHeight | CWX | CWY, 10, 383, 200, 43, 0,0,0 }, /* label5 */{ CWWidth | CWHeight | CWX | CWY, 10, 331, 202, 42, 0,0,0 }, /* label4 */{ CWWidth | CWHeight | CWX | CWY, 10, 280, 202, 41, 0,0,0 }, /* label3 */{ CWWidth | CWHeight | CWX | CWY, 222, 280, 268, 35, 0,0,0 }, /* optionMenu1 */{ CWWidth | CWHeight | CWX | CWY, 3, 3, 10, 29, 0,0,0 }, /* OptionLabel */{ CWWidth | CWHeight | CWX | CWY, 16, 3, 103, 29, 0,0,0 }, /* OptionButton */{ CWWidth | CWHeight | CWX | CWY, 222, 230, 268, 36, 0,0,0 }, /* dbNameTf */{ CWWidth | CWHeight | CWX | CWY, 10, 230, 202, 40, 0,0,0 }, /* label2 */{ CWWidth | CWHeight | CWX | CWY, 10, 50, 481, 100, 0,0,0 }, /* scrolledWindow1 */{ CWWidth | CWHeight | CWX | CWY, 0, 0, 15, 104, 0,0,0 }, /* VertScrollBar */{ CWWidth | CWHeight | CWX | CWY, 0, 0, 481, 100, 0,0,0 }, /* dbList */{ CWWidth | CWHeight | CWX | CWY, 10, 10, 101, 30, 0,0,0 }, /* label1 */{ CWWidth | CWHeight | CWX | CWY, 230, 456, 115, 31, 0,0,0 }, /* cancelButton */{ CWWidth | CWHeight | CWX | CWY, 20, 456, 115, 31, 0,0,0 }, /* applyButton */{ CWWidth | CWHeight | CWX | CWY, 0, 0, 1, 1, 0,0,0 }, /* menuShell */{ CWWidth | CWHeight | CWX | CWY, 0, 0, 78, 25, 0,0,0 }, /* pulldownMenu5 */{ CWWidth | CWHeight | CWX | CWY, 2, 2, 74, 21, 0,0,0 }, /* pushButton5 */{ CWWidth | CWHeight | CWX | CWY, -90, -25, 90, 25, 0,0,0 }, /* ConfigurePage */{ CWWidth | CWHeight | CWX | CWY, 40, 3, 500, 504, 0,0,0 }, /* tf */{ CWWidth | CWHeight | CWX | CWY, 540, 10, 90, 25, 0,0,0 }, /* Editor */{ CWWidth | CWHeight | CWX | CWY, -36, -25, 36, 25, 0,0,0 }, /* quit */{ CWWidth | CWHeight | CWX | CWY, 545, 38, 90, 25, 0,0,0 }, /* Quit */};#if 0 PrintDetails2(w, NULL);#else if (result_index <= 0) { PrintDetails2(w, Expected); fflush(stdout); result_index ++; }#endif}void Quit(Widget w, XtPointer client, XtPointer call){ exit(0);}Widget CreateConfigureWindow(Widget parent);Widget form, toplevel, deleteButton, dbDescFileTf, dbFileTf, DBOptionMenu, dbNameTf, dbList;intmain(int argc, char **argv){ Widget toplevel, nb, b, tf, cw; XtAppContext app; Arg al[10]; int ac; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "Notebook", NULL, 0, &argc, argv, NULL, NULL); ac = 0; XtSetArg(al[ac], XmNbindingType, XmSPIRAL); ac++; nb = XmCreateNotebook(toplevel, "notebook", al, ac); ac = 0; XtSetArg(al[ac], XmNnotebookChildType, XmPAGE); ac++; XtSetArg(al[ac], XmNpageNumber, 1); ac++; tf = XmCreateTextField(nb, "tf", al, ac); XtManageChild(tf); ac = 0; XtSetArg(al[ac], XmNnotebookChildType, XmPAGE); ac++; XtSetArg(al[ac], XmNpageNumber, 2); ac++; b = XmCreatePushButton(nb, "quit", al, ac); XtManageChild(b); XtAddCallback(b, XmNactivateCallback, Quit, NULL); cw = CreateConfigureWindow(nb); XtManageChild(cw); ac = 0; XtSetArg(al[ac], XmNpageNumber, 0); ac++; XtSetValues(cw, al, ac); ac = 0; XtSetArg(al[ac], XmNpageNumber, 0); ac++; b = XmCreatePushButton(nb, "ConfigurePage", al, ac); XtManageChild(b); ac = 0; XtSetArg(al[ac], XmNpageNumber, 1); ac++; b = XmCreatePushButton(nb, "Editor", al, ac); XtManageChild(b); ac = 0; XtSetArg(al[ac], XmNpageNumber, 2); ac++; b = XmCreatePushButton(nb, "Quit", al, ac); XtManageChild(b); XtManageChild(nb); XtRealizeWidget(toplevel); check_geometry(toplevel); LessTifTestMainLoop(toplevel); exit(0);}#define LARGE_WIDTH 400#define LARGE_HEIGHT 500#define SMALL_WIDTH 200#define SMALL_HEIGHT 250/* * Function: * CONVERT(w, from_string, to_type, to_size, success); * Description: * A converter wrapper for convenience from BuilderXcessory. * Input: * w - Widget : the widget to use for conversion * from_string - char * : the string to convert from * to_type - char * : the type to convert to * to_size - int : the size of the conversion result * success - Boolean* : Set to the result value of the conversion * Output: * None */XtPointer CONVERT(Widget w, char *from_string, char * to_type, int to_size, Boolean * success){ XrmValue fromVal, toVal; /* resource holders */ Boolean convResult; /* return value */ unsigned char oByte; /* one byte result */ unsigned short tByte; /* two byte result */ XtPointer fByte; /* four byte result */ XtPointer aByte; /* allocated result */ /* * Zero it. */ fByte = aByte = NULL; *success = False; /* * Sometimes we do not know this at code output. */ if (to_size == 0) { if (!strcmp(to_type, XmRXmString) || !strcmp(to_type, XmRXmStringTable)) { to_size = sizeof(XtPointer); } else { to_size = strlen(from_string); } } /* * Set up the list. */ fromVal.size = strlen(from_string) + 1; fromVal.addr = from_string; switch( to_size ) { case 1: toVal.size = sizeof(unsigned char); toVal.addr = (XtPointer)&oByte; break; case 2: toVal.size = sizeof(unsigned short); toVal.addr = (XtPointer)&tByte; break; default: toVal.size = sizeof(XtPointer); toVal.addr = (XtPointer)&fByte; break; } convResult = XtConvertAndStore(w, XmRString, &fromVal, to_type, &toVal); if( convResult ) { switch( to_size ) { case 1: fByte = (XtPointer)((int)oByte); break; case 2: fByte = (XtPointer)((int)tByte); break; default: break; } } /* * Conversion will fail if we need more than 4 bytes. * For strings it will fail always the first time. */ if( !convResult && toVal.size != to_size ) { /* * Need to allocate more space for this one. */ toVal.addr = (XtPointer)XtMalloc(toVal.size); fByte = aByte = toVal.addr; convResult = XtConvertAndStore(w, XmRString, &fromVal, to_type, &toVal); } /* * Free any thing useless we may have allocated. */ if( !convResult ) { XtFree((char*)aByte); aByte = NULL; } /* * Return the result. */ *success = convResult; /*SUPPRESS 80*/ return(fByte);}/* * Function: CreateConfigureWindow() * Create configureWindow hierarchy of widgets.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -