Ejemplo n.º 1
0
void main(int argc, char **argv)
  {
  XtAppContext appContext;
  Widget toplevel, box, topLabel, bottomPanel, helloButton, exitButton;

  toplevel = XtVaAppInitialize(&appContext, "AthenaDemo", NULL, 0, &argc, argv, NULL, NULL);

  box = XtVaCreateManagedWidget("box",boxWidgetClass,toplevel,NULL);
  
  topLabel = XtVaCreateManagedWidget("topLabel", labelWidgetClass, box,
				     XtNlabel," Pick One ",
				     XtNborderWidth, 0,
				     NULL);
  
  bottomPanel = XtVaCreateManagedWidget("bottomPanel", formWidgetClass, box,
					XtNsensitive, True,
					XtNborderWidth, 0,
					NULL);

  helloButton = XtVaCreateManagedWidget("helloButton", commandWidgetClass, bottomPanel,
					XtNlabel," Hello ",
					NULL);

  XtAddCallback(helloButton, XtNcallback, helloHandler, NULL);

  exitButton = XtVaCreateManagedWidget("exitButton", commandWidgetClass, bottomPanel,
				       XtNlabel," Exit ",
				       XtNfromHoriz,helloButton,
				       NULL);

  XtAddCallback(exitButton, XtNcallback, exitHandler, NULL);
  XtRealizeWidget(toplevel);
  XtAppMainLoop(appContext);
  }
Ejemplo n.º 2
0
int
main (int argc, char **argv)
{
  XtAppContext theApp;
  Widget butt1;

  toplevel = XtVaAppInitialize (&theApp, "LessTifTest", NULL, 0,
				&argc, argv, NULL, NULL);

  butt1 = XtVaCreateManagedWidget ("Button1", xmPushButtonWidgetClass, toplevel,
				   NULL, 0);

  XtAddCallback (butt1, XmNactivateCallback, HiCB, NULL);

  XtRealizeWidget (toplevel);

  LessTifTestWaitForIt(toplevel);
  LessTifTestPushButton(butt1);

{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,  507,  323,   54,   25, 0,0,0, /* Button1 */
   CWWidth | CWHeight            ,  490,  308,  100,  100, 0,0,0, /* OK */
   CWWidth | CWHeight | CWX | CWY,   10,   15,   80,   25, 0,0,0, /* OK */
   CWWidth | CWHeight | CWX | CWY,   10,   60,   80,   25, 0,0,0, /* Cancel */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
  LessTifTestMainLoop(toplevel);

  exit (0);
}
Ejemplo n.º 3
0
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel;

  toplevel = XtVaAppInitialize(&theApp, "drawingArea", NULL, 0,
			       &argc, argv, NULL, NULL);

  butt1= XtVaCreateManagedWidget("Button1", xmArrowButtonWidgetClass, toplevel, 
				XmNarrowDirection,dir,
				NULL);

  XtAddCallback(butt1,XmNactivateCallback,HiCB,NULL);

  XtRealizeWidget(toplevel);

  
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   50,   50,   23,   23, 0,0,0, /* Button1 */ 
    };
    PrintDetails(toplevel,Expected);
};
  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 4
0
	int main(int argc, char *argv[])
	{
		int i, n;
		Arg args[10];
		XtAppContext app;
		Widget toplevel, arrow;

		setlocale(LC_ALL, "");

		//建立顶级窗口
		toplevel = XtVaAppInitialize(&app, "ArrowButton", NULL, 0,
			&argc, argv, NULL, NULL);

		//建立多选按钮的布局组件
		n = 0;
		XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT);	n++;
		XtSetArg(args[n], XmNwidth, 100);		n++;
		XtSetArg(args[n], XmNheight, 100);		n++;
		arrow = XmCreateArrowButton(toplevel, "arrow", args, n);
		XtManageChild(arrow);

		//设置回调
		XtAddCallback(arrow, XmNactivateCallback, 
			(XtCallbackProc)callback, NULL);

		//显示窗口
		XtRealizeWidget(toplevel);

		//进入事件循环
		XtAppMainLoop(app);

	}
Ejemplo n.º 5
0
int
main(int argc, char **argv)
{
  Widget toplevel, one, two;
  XtAppContext app;
  XmFontList fontlist;
  XmString xmstr1;
  Dimension w,i,s,l,t,h;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, FallBack, NULL);

  fontlist = XmFontListAppendEntry(NULL,
			   XmFontListEntryCreate("MY_FONT",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

  xmstr1 = XmStringCreateLtoR("Here\nIs\nA\nDefault\nButton", "MY_FONT");

  two = XtVaCreateManagedWidget("Button1", xmBulletinBoardWidgetClass,
				 toplevel, NULL);

  one = XtVaCreateManagedWidget("One", 
                                xmPushButtonGadgetClass, 
                                two, 
				XmNfontList, fontlist, 
				XmNlabelString, xmstr1, 
				XmNshowAsDefault, 1,
				XmNdefaultButtonShadowThickness, 3,
				NULL);

  XtRealizeWidget(toplevel);
  XtVaGetValues(one,
		XmNhighlightThickness, &i,
		XmNshadowThickness, &s,
		XmNmarginWidth, &w,
		XmNmarginHeight, &h,
		XmNmarginLeft, &l,
		XmNmarginTop, &t,
		NULL);

printf("highlight: %d shad: %d marWid: %d marHei: %d marLeft: %d marTop: %d\n",
	 i, s, w, h, l, t);

/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,    0,    0,  113,  143, 0,0,0, /* Button1 */
   CWWidth | CWHeight | CWX | CWY,   10,   10,   92,  122, 0,0,0, /* One */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
LessTifTestMainLoop(toplevel);
  exit(0);
}
Ejemplo n.º 6
0
int
main(int argc, char **argv)
{
  toplevel = XtVaAppInitialize(&app_context, "listTest", NULL, 0,
			       &argc, argv, NULL, NULL);

  push = XmCreatePushButton(toplevel, "push", NULL, 0);
  XtVaSetValues(push, 
		XtVaTypedArg, XmNlabelString,
		XtRString, "Push me !", 9,
		NULL);

  XtAddCallback(push, XmNactivateCallback, Push, box);

  XtManageChild(push);

  XtRealizeWidget(toplevel);

  LessTifTestWaitForIt(toplevel);
  LessTifTestPushButton(push);
  LessTifTestMainLoop(toplevel);

  XtAppMainLoop(app_context);
  exit(0);
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
	Widget	a, b;

	XtSetLanguageProc(NULL, NULL, NULL);
	toplevel = XtVaAppInitialize(&appcontext, "Test", NULL, 0, &argc, argv,
				     NULL, NULL);

/* Create main window */
	form = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel,
		XmNfractionBase,	7,
		XmNwidth,		350,
		XmNheight,		100,
		NULL);

	a = XtVaCreateManagedWidget("label a", xmPushButtonWidgetClass, form,
		XmNx,			50,
		XmNwidth,		100,
		XmNtopAttachment,	XmATTACH_POSITION,
		XmNtopPosition,		1,
		XmNleftAttachment,	XmATTACH_SELF,
		XmNrightAttachment,	XmATTACH_SELF,
		XmNbottomAttachment,	XmATTACH_POSITION,
		XmNbottomPosition,	5,
		NULL);

	b = XtVaCreateManagedWidget("label b", xmPushButtonWidgetClass, form,
		XmNx,			200,
		XmNwidth,		100,
		XmNtopAttachment,	XmATTACH_POSITION,
		XmNtopPosition,		1,
		XmNleftAttachment,	XmATTACH_SELF,
		XmNrightAttachment,	XmATTACH_SELF,
		XmNbottomAttachment,	XmATTACH_POSITION,
		XmNbottomPosition,	5,
		NULL);
	XtManageChild(form);

	XtRealizeWidget(toplevel);

    {
/* Note: the following values are the result of
 * querying the current geometry.
 */
static XtWidgetGeometry Expected[] = {
   {CWWidth | CWHeight            ,    0,    0,  350,  100, 0,0,0, /* mainwindow */},
   {CWWidth | CWHeight | CWX | CWY,   50,   14,  100,   57, 0,0,0, /* menubar */},
   {CWWidth | CWHeight | CWX | CWY,  200,   14,  100,   57, 0,0,0, /* button_0 */},
};

	PrintDetails(toplevel, Expected);
    }

	/*
	XtAppMainLoop(appcontext);
	*/
	LessTifTestMainLoop(toplevel);

	return(0);
}
Ejemplo n.º 8
0
int
main(int argc, char **argv)
{
#ifdef LESSTIF_VERSION
  Widget toplevel;
  XtAppContext app;
  XmFontList fontlist;
  XmString xmstr1 = XmStringCreate("Here is a ", "MY_FONT1");
  XmString xmstr2 = XmStringCreate("different font", "MY_FONT");
  char buf[] = { 0xdf, 0x80, 0x06, 0x00, 0x01, 0x00 };
  XmStringContext context;
  char *text;
  XmStringCharSet cs;
  XmStringDirection dir;
  Boolean sep;

  XmString xmstr = XmStringConcat(xmstr1, xmstr2);

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL);

  fontlist = XmFontListAppendEntry(NULL,
			   XmFontListEntryCreate("MY_FONT",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

  fontlist = XmFontListAppendEntry(fontlist,
			   XmFontListEntryCreate("MY_FONT1",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-r-normal--17-0-75-75-p-*-iso8859-1")));

  asn1_dump((unsigned char *)xmstr);

  printf("SINGLE SEGMENT\n");
  text = NULL;
  cs = "-adobe-helvetica-bold-r-normal--17-0-75-75-p-*-iso8859-1";
  _XmStringSingleSegment(xmstr, &text, &cs);
  printf("text: %s cs: %s\n", text ? text : "(empty)", cs ? cs : "(empty)");

  if (_XmStringIsXmString((XmString)buf))
	printf("IS STRING\n");
  else
	printf("ISN'T STRING\n");

  asn1_dump((unsigned char *)buf);

  XmStringInitContext(&context, xmstr);
  while (XmStringGetNextSegment(context, &text, &cs, &dir, &sep)) {
    printf("%s %s %d %d\n", text ? text : "(null)", cs ? cs : "(null)",
	   dir, sep);
  }
  XmStringFreeContext(context);

  printf("current charset: %s\n", _XmStringGetCurrentCharset());
#endif
  exit(0);
}
Ejemplo n.º 9
0
int
main(int argc, char **argv)
{
    Widget toplevel, rc, one;
    XtAppContext app;

    XtSetLanguageProc(NULL, NULL, NULL);

    toplevel = XtVaAppInitialize(&app, "BubbleButtonTest", NULL, 0, &argc, argv, NULL, NULL);

    rc = XmCreateRowColumn(toplevel, "RC", NULL, 0);

    one = XltCreateBubbleButton(rc, "BubbleButton1", NULL, 0);
    XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
    XtManageChild(one);
    one = XltCreateBubbleButton(rc, "BubbleButton2", NULL, 0);
    XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL);
    XtManageChild(one);

    XtManageChild(rc);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);

    exit(0);
}
Ejemplo n.º 10
0
int
main(int argc, char **argv)
{
  Widget toplevel, one,two;
  XtAppContext app;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "PBG1", NULL, 0, &argc, argv, NULL, NULL);

  two = XtVaCreateManagedWidget("Two", xmBulletinBoardWidgetClass, toplevel, NULL);

  one = XtVaCreateManagedWidget("OneBlueButton", xmPushButtonGadgetClass, two, NULL);

  XtAddCallback(one, XmNactivateCallback, activate_callback, NULL);
  XtAddCallback(one, XmNarmCallback, arm_callback, NULL);
  XtAddCallback(one, XmNdisarmCallback, disarm_callback, NULL);

  XtRealizeWidget(toplevel);
  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	111,	46,	0,0,0,	/* Form */
  	CWWidth | CWHeight | CWX | CWY,	10,	10,	90,	25,	0,0,0,	/* two */
};

  PrintDetails(toplevel, Expected);
  }
  LessTifTestMainLoop(toplevel);
  /*
  XtAppMainLoop(app);
  */

  exit(0);
}
Ejemplo n.º 11
0
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel;

  toplevel = XtVaAppInitialize(&theApp, "toggle1", NULL, 0,
			       &argc, argv, NULL, NULL);

  butt= XtVaCreateManagedWidget("Button1Button1", xmToggleButtonWidgetClass, toplevel, 
				XmNindicatorOn, False,
				XmNshadowThickness, 5,
#if 0
				XmNfillOnSelect, True,
#endif
				NULL);

  XtAddCallback(butt,XmNvalueChangedCallback,HiCB,NULL);

  XtRealizeWidget(toplevel);

/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,    0,    0,  102,   31, 0,0,0, /* Button1Button1 */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 12
0
int main(int argc, char **argv)
{
 XtAppContext app;
 Widget one;
 XmString s1, s2;
 int i;
 

 
 toplevel = XtVaAppInitialize(&app, "test", NULL, 0, &argc, argv, NULL, NULL);

 one = XtVaCreateManagedWidget("Push me",
        xmPushButtonWidgetClass,
        toplevel, NULL);
 
 XtAddCallback(one, XmNactivateCallback, ChangeWindefTitleParameterCB, NULL);
 XtRealizeWidget(toplevel);

 s1 = XmStringCreateLtoR("ala ma pieska", "");
 s2 = XmStringCreateLocalized("ala ma pieska");
 i = XmStringCompare(s1, s2);
 printf("%d\n", i); /* on original Motif should be 1 */

 
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   50,   50,   54,   25, 0,0,0, /* Push me */ 
    };
    PrintDetails( toplevel ,Expected);
};
   LessTifTestMainLoop( toplevel );
   
   exit(0);
}
Ejemplo n.º 13
0
int
main(int argc, char **argv)
{
    Widget toplevel, button;
    XtAppContext app;

    toplevel = XtVaAppInitialize(&app, "Hello", NULL, 0,
				 &argc, argv, fallbacks, NULL);

    button =
	XtVaCreateManagedWidget("pushmePlease", xmPushButtonWidgetClass,
				toplevel, NULL);

    XtAddCallback(button, XmNactivateCallback, mytest, NULL);

    XtRealizeWidget(toplevel);
  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	100,	41,	0,0,0,	/* Form */
  	CWWidth | CWHeight | CWX | CWY,	45,	30,	30,	25,	0,0,0,	/* two */
};

  PrintDetails(toplevel, Expected);
  }
  LessTifTestMainLoop(toplevel);
  /*
    XtAppMainLoop(app);
    */
    exit(0);
}
Ejemplo n.º 14
0
int
main(int argc, char **argv)
{
  Widget toplevel, widget, bb, list;
  XtAppContext app;
  XmString item;
  Arg args[10];
  int n = 0;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "ComBox", NULL, 0, &argc, argv, NULL, NULL);

  bb = XmCreateBulletinBoard(toplevel, "bb", NULL, 0);
  XtManageChild(bb);

  XtSetArg(args[n], XmNwidth, 100); n++;
  XtSetArg(args[n], XmNheight, 100); n++;
  widget = XmCreateDrawnButton(bb, "drawnButton", args, n);

  XtAddCallback(widget, XmNexposeCallback, (XtCallbackProc) onExpose,
                (XtPointer)bb);

  XtManageChild(widget);

  XtRealizeWidget(toplevel);

  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 15
0
int
main(int argc, char **argv)
{
	Widget		toplevel, spb, bb, list, tf;
	XtAppContext	app;
	XmString	item;
	Arg			al[10];
	int			ac;

	XtSetLanguageProc(NULL, NULL, NULL);

	toplevel = XtVaAppInitialize(&app, "SpinBox", NULL, 0,
		&argc, argv, NULL, NULL);

	bb = XmCreateForm(toplevel, "bb", NULL, 0);
	XtManageChild(bb);

	XtRealizeWidget(toplevel);

	ac = 0;
	spb = XmCreateSpinBox(bb, "spinbox", al, ac);
	XtAddCallback(spb, XmNvalueChangedCallback, ModifyVerify, NULL);

	ac = 0;
	XtSetArg(al[ac], XmNspinBoxChildType, XmNUMERIC); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 1); ac++;
	tf = XmCreateTextField(spb, "tf", al, ac);
	XtManageChild(tf);

	XtManageChild(spb);

	LessTifTestMainLoop(toplevel);

	exit(0);
}
Ejemplo n.º 16
0
int
main(int argc, char **argv)
{
  XtAppContext app;
  Widget toplevel, box;

  toplevel = XtVaAppInitialize(&app, "listTest", NULL, 0,
 		               &argc, argv, NULL, NULL);

  box = XmCreateSelectionBox(toplevel, "Box", NULL, 0);

  XtManageChild(box);

  XtRealizeWidget(toplevel);

  
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   56,   72,  220,  297, 0,0,0, /* Box */
   CWWidth | CWHeight | CWX | CWY,   11,   11,  198,   17, 0,0,0, /* Items */
   CWWidth | CWHeight | CWX | CWY,   11,   28,  198,  135, 0,0,0, /* ItemsListSW */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  198,  135, 0,0,0, /* ItemsList */
   CWWidth | CWHeight | CWX | CWY,   11,  173,  198,   17, 0,0,0, /* Selection */
   CWWidth | CWHeight | CWX | CWY,   11,  190,  198,   31, 0,0,0, /* Text */
   CWWidth | CWHeight | CWX | CWY,    0,  231,  220,    2, 0,0,0, /* Separator */
   CWWidth | CWHeight | CWX | CWY,   11,  243,   66,   43, 0,0,0, /* OK */
   CWWidth | CWHeight | CWX | CWY,   77,  243,   66,   43, 0,0,0, /* Cancel */
   CWWidth | CWHeight | CWX | CWY,  143,  243,   66,   43, 0,0,0, /* Help */ 
    };
    PrintDetails(toplevel,Expected);
};
  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 17
0
	int main(int argc, char *argv[])
	{
		int n;
		Arg args[10];
		XtAppContext app;
		Widget toplevel, button;
		XmString label, label1, label2;

		setlocale(LC_ALL, "");

		//建立顶级窗口
		toplevel = XtVaAppInitialize(&app, "FontList1", NULL, 0,
			&argc, argv, NULL, NULL);

		//建立按钮上标签的字符串
		label1 = XmStringCreate("复合字符串Testing", "small");
		label2 = XmStringCreate("大字体Testing", "large");
		label = XmStringConcat(label1, label2);

		n = 0;
		XtSetArg(args[n], XmNlabelString, label); 	n++;
		button = XmCreatePushButton(toplevel, "pushbutton", args, n);
		XtManageChild(button);

		//显示窗口
		XtRealizeWidget(toplevel);

		//进入事件循环
		XtAppMainLoop(app);

	}
Ejemplo n.º 18
0
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel, drawingArea, button, m;

  toplevel = XtVaAppInitialize(&theApp, "drawingArea", NULL, 0,
			       &argc, argv, NULL, NULL);

  drawingArea= XtVaCreateManagedWidget("drawingArea", xmDrawingAreaWidgetClass, toplevel,
	NULL);

  m = XmCreatePopupMenu(drawingArea, "popup", NULL, 0);
  
  button = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, m,
	NULL);

  XtAddCallback(drawingArea, XmNinputCallback, incb, (XtPointer)m);
  XtAddCallback(button, XmNactivateCallback, print, NULL);

  XtRealizeWidget(toplevel);
  
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,  506,  322,    1,    1, 0,0,0, /* drawingArea */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}

  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 19
0
int
main(int argc, char **argv)
{
  XtAppContext theApp;
  Widget toplevel;
  Widget butt1;
  Widget two;
  int id;
  int nid=0;
  int orientation;

  toplevel = XtVaAppInitialize(&theApp, "separator", NULL, 0,
			       &argc, argv, NULL, NULL);

  if (argc < 2){
	printf("Usage SeparTest <style> [orientation]\n\
		Where style = 0-6 \n\
		0 = XmNO_LINE \n\
		1 = XmSINGLE_LINE \n\
		2 = XmDOUBLE_LINE \n\
		3 = XmSINGLE_DASHED_LINE \n\
		4 = XmDOUBLE_DASHED_LINE \n\
		5 = XmSHADOW_ETCHED_IN \n\
		6 = XmSHADOW_ETCHED_OUT \n\
		7 = XmSHADOW_ETCHED_IN_DASH \n\
		8 = XmSHADOW_ETCHED_OUT_DASH \n\
		Where orientation = 0-1 \n\
		0 = XmHORIZONTAL \n\
		1 = XmVERTICAL \n");

  }
Ejemplo n.º 20
0
int
main(int argc, char **argv)
{
    Widget toplevel, one;
    XtAppContext app;
    Boolean brc=True;

    XtSetLanguageProc(NULL, NULL, NULL);

    toplevel = XtVaAppInitialize(&app, "Label",
                                 NULL, 0,
                                 &argc, argv, NULL,
                                 NULL);

#ifdef LESSTIF_VERSION
    /* This test has to be in front of any further "activities */
    brc=_LtCheckClassOfVendorShell(toplevel);
#endif

    one = XtVaCreateManagedWidget("One", xmLabelWidgetClass,
                                  toplevel, NULL);

    XtRealizeWidget(toplevel);

    exit( (int)!brc);

}
Ejemplo n.º 21
0
int
main(int argc, char *argv[])
{
  Widget toplevel, one;
  XtAppContext app;
  int value;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "Scale", NULL, 0, &argc, argv, NULL, NULL);

  one = XtVaCreateManagedWidget("sb", xmScaleWidgetClass, toplevel, 
                                XmNorientation, XmHORIZONTAL, 
                                XmNscaleWidth, 100, NULL);

  XtAddCallback(one, XmNdragCallback, dragCallback, NULL);
  XtAddCallback(one, XmNvalueChangedCallback, valueChangedCallback, NULL);

  XtRealizeWidget(toplevel);
  XtVaSetValues(one, XmNscaleMultiple, 2, NULL);
  LessTifTestWaitForIt(toplevel);

  LessTifTestKeyPress(one, XK_Right, ControlMask);
  XtVaGetValues(one, XmNvalue, &value, NULL);

  exit((value == 2) ? 0 : 1);
}
Ejemplo n.º 22
0
int
main(int argc, char **argv)
{
	Widget toplevel, one, d;
	XtAppContext app;
	XmFontList fontlist;

	XmString xmstr1 = XmStringCreateLtoR("\n\nHere is a\n\n", "MY_FONT1");
	XmString xmstr2 = XmStringCreate("different font", "MY_FONT");
	XmString xmstr3 = XmStringCreate("accelerator", "MY_FONT");
	XmStringContext context;
	char *text;
	XmStringCharSet tag;
	XmStringDirection dir;
	Boolean sep;

	XmString xmstr = XmStringConcat(xmstr1, xmstr2);

	XtSetLanguageProc(NULL, NULL, NULL);

	toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL);

	d = XmGetXmDisplay(XtDisplay(toplevel));
	XtAddCallback(d, XmNnoFontCallback, NoFontCB, NULL);
	XtAddCallback(d, XmNnoRenditionCallback, NoRenditionCB, NULL);

	fontlist = XmFontListAppendEntry(NULL,
		XmFontListEntryCreate("MY_FONT",
			XmFONT_IS_FONT,
			XLoadQueryFont(XtDisplay(toplevel),
			"-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));
	fontlist = XmFontListAppendEntry(fontlist,
		XmFontListEntryCreate("MY_FONT1",
			XmFONT_IS_FONT,
			XLoadQueryFont(XtDisplay(toplevel),
			"-adobe-helvetica-bold-r-normal--17-0-75-75-p-*-iso8859-1")));

	one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel,
		XmNfontList, fontlist,
		XmNlabelString, xmstr,
		XmNacceleratorText, xmstr3,
		NULL);

	XtRealizeWidget(toplevel);

/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   {CWWidth | CWHeight            ,    0,    0,  112,   58, 0,0,0}, /* One */
};
/* toplevel should be replaced with to correct applicationShell */
	PrintDetails(toplevel, Expected);
}

	LessTifTestMainLoop(toplevel);
	exit(0);
}
Ejemplo n.º 23
0
int
main(int argc, char **argv)
{
  Widget toplevel, one;
  XtAppContext app;
  XmFontList fontlist;
  XmString xmstr1 = XmStringCreateLtoR("Here is a\n", "MY_FONT1");
  XmString xmstr2 = XmStringCreate("different font", "MY_FONT");
  XmString xmstr3 = XmStringCreate("accelerator", "MY_FONT");
  XmStringContext context;
  char *text;
  XmStringCharSet tag;
  XmStringDirection dir;
  Boolean sep;

  XmString xmstr = XmStringConcat(xmstr1, xmstr2);

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, FallBack, NULL);

  XmStringInitContext(&context, xmstr);
  while (XmStringGetNextSegment(context, &text, &tag, &dir, &sep)) {
	printf("Text: %s Tag: %s Dir: %d Sep: %d\n", text, tag, dir, sep);
	fflush(stdout);
  }

  fontlist = XmFontListAppendEntry(NULL,
			   XmFontListEntryCreate("MY_FONT",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

  fontlist = XmFontListAppendEntry(fontlist,
			   XmFontListEntryCreate("MY_FONT1",
						 XmFONT_IS_FONT,
						 XLoadQueryFont(XtDisplay(toplevel), 
 	                                         "-adobe-helvetica-bold-o-normal--30-*-*-*-*-*-iso8859-1")));

  one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel, XmNfontList, fontlist, 
				XmNlabelString, xmstr,
				XmNacceleratorText, xmstr3, NULL);

  printf("xmstr: %p %p\n", xmstr, ((XmLabelRec*)one)->label._label);
  XtRealizeWidget(toplevel);
  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	128,	55,	0,0,0,	/* Form */
};

  PrintDetails(toplevel, Expected);
  }
  LessTifTestMainLoop(toplevel);
  /*
  XtAppMainLoop(app);
  */

  exit(0);
}
Ejemplo n.º 24
0
int
main(int argc, char **argv)
{
  int i;
  Widget toplevel, bb, label, pressme, pb;
  XtAppContext app;
  XmString item;
  Arg args[5];

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "GrabShell", NULL, 0, &argc, argv, NULL, NULL);

  bb = XmCreateBulletinBoard(toplevel, "bb", NULL, 0);
  
  pressme = XmCreatePushButton(bb,"Press me and let's see what the grab shell does.",NULL,0);
  
  XtManageChild(pressme);

  XtManageChild(bb);

  i = 0;
  XtSetArg(args[i], XmNownerEvents, True); i++;
  XtSetArg(args[i], XmNgrabStyle, GrabModeSync); i++;
  grabshell = XmCreateGrabShell(bb, "grab", args, i);
  label = XmCreateLabel(grabshell, "Hello World", NULL, 0);

  XtManageChild(label);

  i = 0;
  XtSetArg(args[i], XmNy, 100); i++;
  XtSetArg(args[i], XmNx, 0); i++;
  pb = XmCreatePushButton(grabshell,"hello", args, i);
  XtManageChild(pb);

  /* setup callback for an activate action */
  XtAddCallback(pressme, 
                XmNactivateCallback,
                (XtCallbackProc) onActivate, 
                (XtPointer) grabshell);

  XtAddCallback(grabshell,
                XmNpopupCallback,
                (XtCallbackProc) onPopup,
                (XtPointer) grabshell);

  XtRealizeWidget(toplevel);

#if 1
  GrabShellResources(grabshell);
#endif

  check_geometry();

  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 25
0
int
main(int argc, char **argv)
{
	Widget		toplevel, one, d;
	XtAppContext	app;
	XmFontList	fontlist;
	XmString	xms;
	Arg           args[10];
	XmTab         tabs[MAX_COLUMNS];
	XmTabList     tablist;
	XmRendition   renditions[MAX_COLUMNS];
	XmRenderTable rendertable;
	XmStringTable xmstring_table;
	int           xmstring_count;
	Pixel         pixels[MAX_COLUMNS];
	int           n, i;

	XtSetLanguageProc(NULL, NULL, NULL);
	toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv,
		fallback, NULL);

	d = XmGetXmDisplay(XtDisplay(toplevel));

	/* Create the multi-column data for the list */

	xmstring_table = CreateListData(&xmstring_count) ;

	xms = xmstring_table[0];
	for (i=1; i<xmstring_count; i++) {
		XmString	s, x;
		s = XmStringSeparatorCreate();
		x = XmStringConcat(xms, s);
		xms = XmStringConcat(x, xmstring_table[i]);
	}

	one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel,
		XmNalignment,	XmALIGNMENT_BEGINNING,
		XmNlabelString, xms,
		NULL);

	XtRealizeWidget(toplevel);

#if 0
/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   {CWWidth | CWHeight            ,    0,    0,  112,   58, 0,0,0}, /* One */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
#endif

	LessTifTestMainLoop(toplevel);
	exit(0);
}
Ejemplo n.º 26
0
	int main(int argc, char *argv[])
	{
		int i, n;
		Arg args[10];
		XtAppContext app;
		Widget toplevel, rowcol, sep, button;
		XmString str_months[12];

		setlocale(LC_ALL, "");

		//建立顶级窗口
		toplevel = XtVaAppInitialize(&app, "Text", NULL, 0,
			&argc, argv, NULL, NULL);

		//建立rowcolumn 布局
		n = 0;
		XtSetArg(args[n], XmNpacking, XmPACK_TIGHT);   n++;
		rowcol = XmCreateRowColumn(toplevel, "rowcol", args, n);
		XtManageChild(rowcol);

		//建立输入条
		n = 0;
		XtSetArg(args[n], XmNvalue, "输入条");	n++;
		textf = XmCreateTextField(rowcol, "textf", args, n);
		XtManageChild(textf);
		//建立回调
		XtAddCallback(textf, XmNactivateCallback, 
			(XtCallbackProc)checkit, NULL);

		//建立输入区
		n = 0;
		XtSetArg(args[n], XmNrows, 10);				n++;
		XtSetArg(args[n], XmNcolumns, 40);			n++;
		XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT);	n++;
		XtSetArg(args[n], XmNvalue, "输入区域\n请测试");	n++;
		text = XmCreateScrolledText(rowcol, "text", args, n);
		//text = XmCreateText(rowcol, "text", args, n);
		XtManageChild(text);
		
		//建立分隔符
		sep = XmCreateSeparator(rowcol, "separator", NULL, 0);
		XtManageChild(sep);

		//建立一个普通按钮
		button = XmCreatePushButton(rowcol, 
			"打印输入条和文本区内容", NULL, 0);
		XtManageChild(button);
		XtAddCallback(button, XmNactivateCallback,
			(XtCallbackProc)checkit, NULL);

		//显示窗口
		XtRealizeWidget(toplevel);

		//进入事件循环
		XtAppMainLoop(app);

	}
Ejemplo n.º 27
0
int
main(int argc, char **argv)
{
  Widget toplevel, one, two;
  XtAppContext app;
  unsigned int maximum;
  XmString str;

  XtSetLanguageProc(NULL, NULL, NULL);

  toplevel = XtVaAppInitialize(&app, "Scale", NULL, 0, &argc, argv, NULL, NULL);

  one = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel,
                                NULL);

  str = XmStringCreateLtoR("Test Scale", XmFONTLIST_DEFAULT_TAG);

  two = XtVaCreateManagedWidget("sb", xmScaleWidgetClass, one, 
                                XmNtopAttachment,  XmATTACH_FORM,
                                XmNleftAttachment,  XmATTACH_FORM,
                                XmNrightAttachment,  XmATTACH_FORM,
                                XmNbottomAttachment,  XmATTACH_FORM,
                                XmNorientation, XmHORIZONTAL, 
				XmNshowValue, True,
#if 0
                                XmNscaleWidth, 40,
#endif
				XmNminimum, 100,
				XmNmaximum, 300,
				XmNtitleString, str,
				XmNprocessingDirection, XmMAX_ON_LEFT,
				NULL);

  XtAddCallback(two, XmNdragCallback, dragCallback, NULL);
  XtAddCallback(two, XmNvalueChangedCallback, valueChangedCallback, NULL);

  XtRealizeWidget(toplevel);

  XtVaGetValues(two, XmNmaximum, &maximum, NULL);

  printf ("one.maximum = %u\n", maximum);

  
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   50,   50,  104,   56, 0,0,0, /* form */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  104,   56, 0,0,0, /* sb */
   CWWidth | CWHeight | CWX | CWY,    0,   35,   64,   17, 0,0,0, /* Title */
   CWWidth | CWHeight | CWX | CWY,    0,   16,  104,   19, 0,0,0, /* Scrollbar */ 
    };
    PrintDetails(toplevel,Expected);
};
  LessTifTestMainLoop(toplevel);

  exit(0);
}
Ejemplo n.º 28
0
void InitGraphics(int argc, char *argv[])
{
    Dimension width, height;
    XEvent event;
    static String fallback_resources[] = {
        "*xcheck*background: #e0e0e0",
        "*xcheck*fontList: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*font: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*",
        "*xcheck*XmText.background:  #b0e0c0",
        NULL,
    };

    XtSetLanguageProc(NULL,NULL,NULL);
    toplevel = XtVaAppInitialize(
        &app,"App-Class",
        NULL,0,
        &argc,argv,
        fallback_resources,
        NULL);
    mainWidget = XtVaCreateManagedWidget("mw", xmMainWindowWidgetClass, toplevel, NULL);
    dpy = XtDisplay(mainWidget);
    gc = XCreateGC(dpy,DefaultRootWindow(dpy),(int)NULL,NULL);
    XSetLineAttributes(dpy,gc,2,LineSolid,CapButt,JoinMiter);
    colormap = CreateColorMap(mainWidget);
    menubar = CreateMenuBar(mainWidget);
    workwin = CreateWorkWin(mainWidget);
    message = CreateMessage(mainWidget);
    XtVaSetValues(mainWidget,
        XmNcolormap,colormap,
        XmNmenuBar,menubar,
        XmNworkWindow,workwin,
        XmNmessageWindow,message,
        NULL);
    XtRealizeWidget(toplevel);
    do {
        XtAppNextEvent(app,&event);
        XtDispatchEvent(&event);
    }
    while(event.type != Expose);

    XtVaGetValues(toplevel,XmNheight,&height,XmNwidth,&width,NULL);
    XtVaSetValues(toplevel,
        XmNwidth, width,
        XmNheight, height,
        XmNmaxWidth, width,
        XmNmaxHeight, height,
        XmNminWidth, width,
        XmNminHeight, height,
        XmNallowShellResize, False,
        NULL);
    HandleEvents();

    strcpy(xval[0],"human");
    strcpy(xval[1],"computer");
    strcpy(xval[2],"10.0");
}
Ejemplo n.º 29
0
int
main(int argc, char *argv[]) {
    Widget rc, frame1, label;

    XtSetLanguageProc(NULL, NULL, NULL);

    top = XtVaAppInitialize(&app_context,
                            "Test-prog",
                            NULL, 0,
                            &argc, argv,
                            NULL,
                            NULL);

    main_window =
        XtVaCreateManagedWidget("mainwin", xmMainWindowWidgetClass, top, NULL);

    XmRepTypeInstallTearOffModelConverter();

    menubar = XmCreateMenuBar(main_window, "menubar", NULL, 0);
    XtManageChild(menubar);

    XmMainWindowSetAreas(main_window,menubar,NULL,NULL,NULL,NULL);

    rc = XtVaCreateWidget("rc", xmRowColumnWidgetClass, main_window, NULL);

    XtVaSetValues(main_window, XmNworkWindow, rc, NULL);
    XtManageChild(rc);

    frame1 = XtVaCreateWidget("frame1",
                              xmFrameWidgetClass,
                              rc,
                              NULL);
    XtManageChild(frame1);

    XtRealizeWidget(top);

    label = XtVaCreateManagedWidget("Rampaging Bulldozers",
                                    xmLabelWidgetClass,
                                    frame1,
                                    NULL);

    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,   56,   72,   16,   32, 0,0,0, /* mainwin */
            CWWidth | CWHeight | CWX | CWY,    0,    0,   16,   16, 0,0,0, /* menubar */
            CWWidth | CWHeight | CWX | CWY,    0,   16,   16,   16, 0,0,0, /* rc */
            CWWidth | CWHeight | CWX | CWY,    3,    3,   10,    4, 0,0,0, /* frame1 */
            CWWidth | CWHeight | CWX | CWY,    2,    2,    6,    1, 0,0,0, /* Rampaging Bulldozers */
        };
        /* toplevel should be replaced with to correct applicationShell */
        PrintDetails(top, Expected);
    }
    LessTifTestMainLoop(top);

    exit(0);
}
Ejemplo n.º 30
0
int
main(
  int argc,
  char ** argv )
{

  XtAppContext app_context;
  Widget TheWindow = XtVaAppInitialize( &app_context,
				        "Full Screen Test",
				        NULL, 0,
				        &argc, argv,
				        NULL,
				        NULL );

  if (TheWindow == NULL) exit(1);

  Display *display=XOpenDisplay(NULL);

  int screen = DefaultScreen(display);

  // Destroy the window asociated to the widget
  XtUnrealizeWidget( TheWindow );

  // Put some values in the size, otherwise the window creation will complain
  XtConfigureWidget( TheWindow, 0, 0, 10, 10, 0 );

  // Now set the attributes for the new window
  XSetWindowAttributes attr;

  // We'll handle it; make the Window manager leave us alone
  attr.override_redirect = true;

  Visual *visual =  DefaultVisual(display,screen);

  // Create a window with our attributes
  XtCreateWindow( TheWindow, InputOutput, visual, CWOverrideRedirect, &attr );

  SoXt::init( TheWindow );

  SoXtExaminerViewer *Viewer =
    new SoXtExaminerViewer(TheWindow, "My Examiner Viewer");

  Viewer->setDecoration(FALSE);
  Viewer->setBorder(FALSE);

  SoXt::show(TheWindow);

  // Set size and position; no border
  XtConfigureWidget( TheWindow, 0, 0,
		     DisplayWidth( display, DefaultScreen( display ) ),
		     DisplayHeight( display, DefaultScreen( display ) ), 0 );


  SoXt::mainLoop();

}