Пример #1
0
int
main(int argc, char **argv)
{
  XtAppContext	app;
  Widget Shell;
  Widget Form;
  Widget TopLabel;
  Widget BottomLabel;

  XtSetLanguageProc(NULL, NULL, NULL);

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

  Form = XmCreateForm(Shell,"Form",NULL,0);

  TopLabel = XmCreateLabel(Form,"TopLabel",NULL,0);
  XtVaSetValues(TopLabel,
  	XmNtopAttachment, XmATTACH_NONE,
  	NULL);
  XtManageChild(TopLabel);

  BottomLabel = XmCreateLabel(Form,"BottomLabel",NULL,0);
  XtVaSetValues(BottomLabel,
  	XmNtopAttachment, XmATTACH_WIDGET,
  	XmNtopWidget, TopLabel,
  	XmNtopOffset, 1,
  	XmNbottomAttachment, XmATTACH_POSITION,
  	XmNbottomOffset, 2,
  	XmNbottomPosition, 50,
  	NULL);
  XtManageChild(BottomLabel);

  XtManageChild(Form);

  XtRealizeWidget(Shell);
  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	72,	81,	0,0,0,	/* Form */
  	CWWidth | CWHeight | CWX | CWY,	0,	0,	52,	17,	0,0,0,	/* two */
  	CWWidth | CWHeight | CWX | CWY,	0,	20,	70,	17,	0,0,0,	/* two */

  	CWWidth | CWHeight,		0,	0,	144,	160,	0,0,0,	/* Form */
  	CWWidth | CWHeight | CWX | CWY,	0,	0,	52,	17,	0,0,0,	/* two */
  	CWWidth | CWHeight | CWX | CWY,	0,	20,	70,	56,	0,0,0,	/* two */
};

  PrintDetails(Shell, Expected);
      LessTifTestWaitForIt(Shell);
      LessTifTestResizeWidget(Shell, 144, 160);
  PrintDetails(Shell, Expected);
  }
      LessTifTestMainLoop(Shell);
  exit(0);
}
Пример #2
0
static XmToolTipConfigTrait
ToolTipGetData (Widget w)
{
    Widget top = w;
    XmToolTipConfigTrait ttp;

    while (XtParent (top))
    {
        top = XtParent (top);
    }

    ttp = (XmToolTipConfigTrait) XmeTraitGet (top, XmQTtoolTipConfig);

    if (ttp != NULL && ttp->label == NULL && !top->core.being_destroyed)
    {
        Widget shell;

        shell = XtVaCreateWidget ("TipShell",
                                  transientShellWidgetClass, top,
                                  XmNoverrideRedirect, True, NULL);

        ttp->label = XmCreateLabel (shell, "TipLabel", NULL, 0);
        XtManageChild (ttp->label);
#ifdef FIX_1388
        XtAddCallback(top, XmNdestroyCallback, (XtCallbackProc) ToolTipLabelDestroyCallback, (XtPointer) NULL);
#endif
    }
    return ttp;
}
Пример #3
0
void Resize(void)

{
    Arg            args[10];
    Cardinal      argcount;
    Widget Label;
    
    if( HelpBoard ) {
	XtDestroyWidget( HelpBoard );
	XmUpdateDisplay( mainbull );
	printf( "Resize! Helpboard destroyed!\n" );
    }

    argcount = 0;
    XtSetArg( args[argcount], XmNresizePolicy, XmRESIZE_ANY ); argcount++;
    XtSetArg( args[argcount], XmNunitType, XmPIXELS ); argcount++;

    HelpBoard = XmCreateBulletinBoard( mainbull, "Board2", args, argcount );
    XtRealizeWidget( HelpBoard );
    XtManageChild( HelpBoard );

    printf( "Resize! XtWidth: %d\n", XtWidth( pgHelpMainWindow ) );

    argcount = 0;
    XtSetArg( args[argcount], XmNx, XtWidth( pgHelpMainWindow ) -50 ); argcount++;
    XtSetArg( args[argcount], XmNy, 50 ); argcount++;
    Label = XmCreateLabel( mainbull, "xxx", args, argcount );
    XtManageChild( Label );
}
Пример #4
0
Файл: motif.c Проект: E-LLP/QuIP
void make_label(QSP_ARG_DECL  Screen_Obj *sop)
{
#ifdef HAVE_MOTIF
	Arg al[10];
	int ac = 0;
	int w;

	sop->so_frame = generic_frame( curr_panel->po_panel_obj, sop, XmSHADOW_IN);

	/* set alignment of label to be left-justified */
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;

	/* message boxes resize to fit text stuck in there... */
	/* XtSetArg(al[ac], XmNallowShellResize, FALSE); ac++; */	/* does this work? no, does nothing */
	/* XtSetArg(al[ac], XmCAllowShellResize, FALSE); ac++; */ /* does this work? nothing */
	XtSetArg(al[ac], XmCNoResize, TRUE); ac++; /* does this work? nothing */

	XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;

	/* Set widget width */

	/* Default behavior was to span the full width of the panel... */
	// w = PO_WIDTH(curr_panel)-30;
	/* Pick a width based on the length of the initial text - assume font width of 8 pixels? */
	w = strlen(sop->so_content_text)*8;
	XtSetArg(al[ac], XmNwidth, w ); ac++;

	/* should this be the action text? */
	sop->so_obj = XmCreateLabel(sop->so_frame, (char *)sop->so_content_text, al, ac);
	XtManageChild(sop->so_obj);
	return;
#endif /* HAVE_MOTIF */
}
Пример #5
0
//
// create a LABEL + Edit line + an apply button
//
void
InvAnnotationEditor::createEditLine(Widget parent)
{
    Arg args[5];
    int i(0);

    Widget rc = XmCreateRowColumn(parent, (char *)"rc", NULL, 0);
    //    XtSetArg(args[i], XmNlabelString, descStr); i++;

    i = 0;
    XmString descStr = XmStringCreateSimple((char *)"enter annotation text:");
    XtSetArg(args[i], XmNlabelString, descStr);
    i++;
    Widget description = XmCreateLabel(rc, (char *)"description", args, 1);

    mTextField_ = XmCreateTextField(rc, (char *)"tf", NULL, 0);

    Widget applyBut = XmCreatePushButton(rc, (char *)"Apply", NULL, 0);

    XtAddCallback(applyBut, XmNactivateCallback, editApplyCB, (XtPointer) this);

    // manage all
    XtManageChild(rc);
    XtManageChild(description);
    XtManageChild(mTextField_);
    XtManageChild(applyBut);
}
Пример #6
0
//
// Create the work area for this window.  
//
Widget DXAnchorWindow::createWorkArea (Widget parent)
{
int n;
Arg args[20];
XmString xmstr;

    n = 0;
    this->form = XmCreateForm (parent, "frame", args, n);
    XtManageChild (this->form);

    //const char *cp = theDXApplication->getCopyrightNotice();
    const char *cp = "";
    char buf[256];
    strcpy (buf, cp);
    xmstr = XmStringCreateLtoR (buf, "bold");

    n = 0;
    XtSetArg (args[n], XmNlabelString, xmstr); n++;
    this->label = XmCreateLabel (this->form, "copyright", args, n);
    XtManageChild (this->label);

    XmStringFree(xmstr);

    this->resetWindowTitle();

    return form;
}
Пример #7
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);
}
Пример #8
0
/* -------------------------------------------------------------------- */
static void CreatePreferences()
{
  int		i;
  Cardinal	n;
  Arg		args[2];
  Widget	frame, RC, plRC, label, b[3];

  PreferShell = XtCreatePopupShell("prefParmsShell",
                   topLevelShellWidgetClass, AppShell, NULL, 0);

  PreferWindow = XmCreateRowColumn(PreferShell, (char *)"prefRC", NULL, 0);

  n = 0;
  frame = XmCreateFrame(PreferWindow, (char *)"prefFrame", args, n);
  XtManageChild(frame);

  n = 0;
  RC = XmCreateRowColumn(frame, (char *)"prefRC", args, n);

  for (i = 0; i < TOTAL_PREFERS; ++i)
    {
    plRC = XmCreateRowColumn(RC, (char *)"plRC", args, n);
    XtManageChild(plRC);

    sprintf(buffer, "prefer%d", i);
    label = XmCreateLabel(plRC, buffer, args, n);
    XtManageChild(label);

    prefText[i] = XmCreateTextField(plRC, (char *)"prefText", args, n);
    XtManageChild(prefText[i]);
    XtAddCallback(prefText[i], XmNlosingFocusCallback, ApplyPreferences, NULL);
    }


  /* Command buttons.
   */
  n = 0;
  frame = XmCreateFrame(PreferWindow, (char *)"buttonFrame", args, 0);
  XtManageChild(frame);

  n = 0;
  plRC = XmCreateForm(frame, (char *)"buttonRC", args, n);

  n = 0;
  b[0] = XmCreatePushButton(plRC, (char *)"dismissButton", args, n);
  XtAddCallback(b[0], XmNactivateCallback, DismissWindow, PreferWindow);

  n = 0;
  b[1] = XmCreatePushButton(plRC, (char *)"saveButton", args, n);
  XtAddCallback(b[1], XmNactivateCallback, SavePreferences, NULL);

  XtManageChildren(b, 2);

  XtManageChild(plRC);
  XtManageChild(RC);

}	/* END CREATEPREFERENCES */
Пример #9
0
int
main (int argc, char **argv)
{
  XtAppContext theApp;
  Widget dialog, rc, label;
  XmString xmstr;

  toplevel = XtVaAppInitialize (&theApp, "drawingArea", NULL, 0,
				&argc, argv, NULL, NULL);
     XtVaSetValues(toplevel,
     	XmNallowShellResize, True,
     	NULL);
     dialog = XmCreateMessageBox(toplevel, "MyDialog", NULL, 0);
     xmstr = XmStringCreateLtoR("Hello World\n\nIf you hit OK on this dialog, another one"
				      "\nshould appear, positioned to the lower right of this one.",
				      XmFONTLIST_DEFAULT_TAG);
  
  
     XtVaSetValues(dialog, XmNmessageString, xmstr, NULL);
  
#if 1
     rc = XmCreateRowColumn(dialog, "rc", NULL, 0);
#else
     rc = XmCreateForm(dialog, "rc", NULL, 0);
#endif
     label = XmCreateLabel(rc, "label", NULL, 0);
     XtVaSetValues(label,
     	XmNborderWidth, 1,
     	NULL);
     XtManageChild(label);
     XtManageChild(rc);
  XtManageChild (dialog);


  XtRealizeWidget (toplevel);

{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   56,   72,  368,  176, 0,0,0, /* MyDialog */
   CWWidth | CWHeight | CWX | CWY,    0,    0,    4,    4, 0,0,0, /* Symbol */
   CWWidth | CWHeight | CWX | CWY,   11,   11,  346,   56, 0,0,0, /* Message */
   CWWidth | CWHeight | CWX | CWY,    0,  112,  368,    2, 0,0,0, /* Separator */
   CWWidth | CWHeight | CWX | CWY,   11,  124,   64,   41, 0,0,0, /* OK */
   CWWidth | CWHeight | CWX | CWY,  152,  124,   64,   41, 0,0,0, /* Cancel */
   CWWidth | CWHeight | CWX | CWY,  293,  124,   64,   41, 0,0,0, /* Help */
   CWWidth | CWHeight | CWX | CWY,   11,   77,  346,   25, 0,0,0, /* rc */
   CWWidth | CWHeight | CWX | CWY,    3,    3,  338,   17, 0,0,0, /* label */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
  LessTifTestMainLoop(toplevel);

  exit (0);
}
Пример #10
0
void CreateMainW(Widget w, String name)
{
    Widget Form, MenuBar, Label, FileCascade, FileMenu;
    Widget Cascade, CascadeMenu, wch;

    Form = XmCreateForm(w, name, NULL, 0);
    MenuBar = XmCreateMenuBar(Form, "menubar", NULL, 0);
    XtVaSetValues(MenuBar, 
		  XmNtopAttachment, XmATTACH_FORM,
		  XmNleftAttachment, XmATTACH_FORM,
		  XmNrightAttachment, XmATTACH_FORM,
		  NULL);
    Label = XmCreateLabel(Form, "ExtTest Test Application", NULL, 0);
    XtVaSetValues(Label,
		  XmNtopAttachment, XmATTACH_WIDGET,
		  XmNtopWidget, MenuBar,
		  XmNleftAttachment, XmATTACH_FORM,
		  XmNrightAttachment, XmATTACH_FORM,
		  XmNbottomAttachment, XmATTACH_FORM,
		  NULL);
    FileCascade = XmCreateCascadeButton(MenuBar, "File", NULL, 0);
    FileMenu    = XmCreatePulldownMenu(MenuBar, "filemenu", NULL, 0);
    XtVaSetValues(FileCascade, XmNsubMenuId, FileMenu, NULL);

    Cascade = XmCreateCascadeButton(FileMenu, "Cascade", NULL, 0);
    XtManageChild(Cascade);

    XtManageChild(wch = XmCreatePushButton(FileMenu, "Modeless Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_MODELESS);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 42);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs Cascaded", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 43);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Application Modal Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_APPLICATION_MODAL);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Application Modal Dialogs", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 44);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Full Application Modal Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_FULL_APPLICATION_MODAL);

    XtManageChild(XmCreatePushButton(FileMenu, "Quit", NULL, 0));

    CascadeMenu = XmCreatePulldownMenu(FileMenu, "cascademenu", NULL, 0);
    XtVaSetValues(Cascade, XmNsubMenuId, CascadeMenu, NULL);
    XtManageChild(XmCreatePushButton(CascadeMenu, "Test1", NULL, 0));
    XtManageChild(wch = XmCreatePushButton(CascadeMenu, "Test2", NULL, 0));
    XtAddCallback(wch, XmNarmCallback, DumpCB, (XtPointer) NULL);

    XtManageChild(FileCascade);
    XtManageChild(MenuBar);
    XtManageChild(Label);
    XtManageChild(Form);
} /* CreateMainW */
/*
 * Procedure to make a bubble help widget
 *   Note that background, borderColor, and borderWidth are specified elsewhere
 */
static void makeBubbleHelpWidget(Widget w, char *label)
{
    Window child;
    Widget wparent=XtParent(w);
    XmString xmString;
    Position x,y;
    Dimension width,height;
    Arg args[20];
    int nargs;
    int xroot,yroot;

  /* Destroy any old one */
    if(bubbleHelpWidget) XtDestroyWidget(bubbleHelpWidget);
  /* Get location of widget relative to its parent */
    nargs=0;
    XtSetArg(args[nargs],XmNx,&x); nargs++;
    XtSetArg(args[nargs],XmNy,&y); nargs++;
    XtSetArg(args[nargs],XmNwidth,&width); nargs++;
    XtSetArg(args[nargs],XmNheight,&height); nargs++;
    XtGetValues(w,args,nargs);
  /* Translate the coordinates to the root window
   *  XmNx and XmNy are supposed to be relative to the parent, but they are not.
   *  They are relative to the root window */
    if(XTranslateCoordinates(XtDisplay(w),XtWindow(XtParent(w)),
      RootWindowOfScreen(XtScreen(w)),(int)x,(int)y,&xroot,&yroot,&child)) {
	x=xroot;
	y=yroot;
    }
  /* Create dialog shell */
    nargs=0;
    XtSetArg(args[nargs],XmNmwmDecorations,0); nargs++;
    XtSetArg(args[nargs],XmNmwmFunctions,0); nargs++;
    XtSetArg(args[nargs],XmNx,x+width/2+BUBBLE_DELTAX); nargs++;
    XtSetArg(args[nargs],XmNy,y+height+BUBBLE_DELTAY); nargs++;
    bubbleHelpWidget=XmCreateDialogShell(wparent,"bubbleHelpD",args,nargs);
  /* Create label */
    xmString=XmStringCreateLocalized(label);
    nargs=0;
    XtSetArg(args[nargs],XmNlabelString,xmString); nargs++;
    bubbleHelpWidgetLabel=XmCreateLabel(bubbleHelpWidget,"bubbleHelpDL",
      args,nargs);
    XtManageChild(bubbleHelpWidgetLabel);
    XtManageChild(bubbleHelpWidget);
    XmStringFree(xmString);
  /* Get location of widget */
    nargs=0;
    XtSetArg(args[nargs],XmNx,&x); nargs++;
    XtSetArg(args[nargs],XmNy,&y); nargs++;
    XtSetArg(args[nargs],XmNwidth,&width); nargs++;
    XtSetArg(args[nargs],XmNheight,&height); nargs++;
    XtGetValues(bubbleHelpWidget,args,nargs);
}
Пример #12
0
main(int argc, char **argv) {
   Widget   top_level, label;
   XmString motif_string;
   Arg      arg[1];
   top_level = XtInitialize(argv[0], "test", NULL, 0, &argc, argv);
   motif_string =
     XmStringCreateSimple("Yes! we are testing the Motif Label Widget!");
   XtSetArg(arg[0], XmNlabelString, motif_string);
   label = XmCreateLabel(top_level, "label", arg, 1);
   XtManageChild(label);
   XtRealizeWidget(top_level);
   XtMainLoop();
}
Пример #13
0
int
main(int argc, char **argv)
{
  XtAppContext	app;
  Widget Shell;
  Widget Form;
  Widget BottomLabel;
  Widget TopLabel;

  XtSetLanguageProc(NULL, NULL, NULL);

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

  Form = XmCreateRowColumn(Shell,"RowColumn",NULL,0);

  TopLabel = XmCreateLabel(Form,"TopLabel",NULL,0);
  XtManageChild(TopLabel);
  BottomLabel = XmCreateLabel(Form,"BottomLabel",NULL,0);
  XtManageChild(BottomLabel);

  {
  Arg args[10];
  int n = 0;

      XtSetArg(args[n], XmNdropProc, (XtCallbackProc)DropProc); n++;
      /*
      XtSetArg(args[n], XmNdragProc, (XtCallbackProc)DragProc); n++;
      */
      XmDropSiteRegister(BottomLabel, args, n);
  }

  XtManageChild(Form);

  XtRealizeWidget(Shell);

  LessTifTestMainLoop(Shell);
  exit(0);
}
Пример #14
0
static void
initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args)
{
#ifdef DEBUG
    printf("%s:initialize(%d) - %s %ix%i\n", __FILE__, __LINE__, 
    	XtName(new_w),
    	XtWidth(new_w), XtHeight(new_w));
#endif

    FilePicker_Label(new_w) = XmCreateLabel(new_w, XtName(new_w), args, *num_args);
    FilePicker_TextField(new_w) = XmCreateTextField(new_w, "TextField", args, *num_args);
    FilePicker_Button(new_w) = XltCreateBubbleButton(new_w, "Browse", args, *num_args);
    if (XtHeight(new_w) == 0)
    {
    	XtHeight(new_w) = XtHeight(FilePicker_Label(new_w)) > XtHeight(FilePicker_TextField(new_w)) ? XtHeight(FilePicker_Label(new_w)) : XtHeight(FilePicker_TextField(new_w));
    	XtHeight(new_w) = XtHeight(new_w) > XtHeight(FilePicker_Button(new_w)) ? XtHeight(new_w) : XtHeight(FilePicker_Button(new_w));
    }
    XtVaSetValues(FilePicker_Label(new_w),
    	XmNalignment, XmALIGNMENT_BEGINNING,
    	XmNtopAttachment, XmATTACH_FORM,
    	XmNleftAttachment, XmATTACH_FORM,
    	XmNrightAttachment, XmATTACH_WIDGET,
    	XmNrightWidget, FilePicker_TextField(new_w),
    	XmNbottomAttachment, XmATTACH_FORM,
    	NULL);
    XtVaSetValues(FilePicker_Button(new_w),
    	XmNtopAttachment, XmATTACH_FORM,
    	XmNtopOffset, (int)((XtHeight(new_w) - XtHeight(FilePicker_Button(new_w))) / 2),
    	XmNrightAttachment, XmATTACH_FORM,
    	NULL);
    XtVaSetValues(FilePicker_TextField(new_w),
    	XmNtopAttachment, XmATTACH_FORM,
    	XmNtopOffset, (int)((XtHeight(new_w) - XtHeight(FilePicker_TextField(new_w))) / 2),
    	XmNrightAttachment, XmATTACH_WIDGET,
    	XmNrightWidget, FilePicker_Button(new_w),
    	NULL);
    if (FilePicker_Value(new_w))
    {
    	XmTextFieldSetString(FilePicker_TextField(new_w), FilePicker_Value(new_w));
	XmTextFieldSetInsertionPosition(FilePicker_TextField(new_w), XmTextFieldGetLastPosition(FilePicker_TextField(new_w)));
    }
    XtManageChild(FilePicker_Label(new_w));
    XtManageChild(FilePicker_Button(new_w));
    XtManageChild(FilePicker_TextField(new_w));
    XtAddCallback(FilePicker_Button(new_w), XmNactivateCallback, (XtCallbackProc)BrowseCallback, NULL);
    /*
    XtAddCallback(new_w, XmNhelpCallback, (XtCallbackProc)Help, NULL);
    */
}
Пример #15
0
static Widget CreateLabel(char *label, Widget parent)
{
  Widget widget;
  register int n;
  Arg args[MAX_ARGS];
  XmString tcs;

  n = 0;
  tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET);
  XtSetArg(args[n], XmNlabelString, tcs);  n++;
  widget = XmCreateLabel(parent, label, args, n);
  XtManageChild(widget);
  XmStringFree(tcs);
  return(widget);
}
Пример #16
0
	int main(int argc, char *argv[])
	{
		int i, n;
		Arg args[10];
		char buf[80];
		XtAppContext app;
		Widget toplevel, notebook, page[6], label[6], frame[6], text[6];

		setlocale(LC_ALL, "");

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

		//建立Notebook
		n = 0;
		XtSetArg(args[n], XmNwidth, 600 ); 			n++;
		XtSetArg(args[n], XmNheight, 400 ); 			n++;
		XtSetArg(args[n], XmNfirstPageNumber, 1); 		n++;
		XtSetArg(args[n], XmNlastPageNumber, 6); 		n++;

		notebook  = XmCreateNotebook(toplevel, "notebook", args, n);
		XtManageChild(notebook);

		//建立页面
		for(i=0; i<6; i++){
			n = 0;
			sprintf(buf, "页面 %d", i + 1);
			label[i] = XmCreateLabel(notebook, buf, args, n);
			page[i] = XmCreatePushButton(notebook, buf, args, n);
		}
		XtManageChildren(label, 6);
		XtManageChildren(page, 6);

		for(i=0; i<6; i++){
			XtSetArg(args[n], XmNpageNumber, i + 1); n++;
			text[i] = XmCreateScrolledText(notebook, buf, args, n);
			XtManageChild(text[i]);
		}


		//显示窗口
		XtRealizeWidget(toplevel);

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

	}
Пример #17
0
int
main(int argc, char **argv)
{
  Widget toplevel;
  Widget Form;
  Widget Label;
  XtAppContext app;
  Arg args[10];
  int n;

  XtSetLanguageProc(NULL, NULL, NULL);

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

  printf("\nCreate a Label\n");
  n = 0;
  XtSetArg(args[n], XmNwidth, 80); n++;
  XtSetArg(args[n], XmNheight, 30); n++;
  XtSetArg(args[n], XmNrecomputeSize, False); n++;
  Label = XmCreateLabel(toplevel, "TestWidget", args, n);
  DoTests(Label);

  printf("\nManage the Label\n");
  XtManageChild(Label);
  DoTests(Label);

  printf("\nRealize the Shell\n");
  XtRealizeWidget(toplevel);
  DoTests(Label);

  printf("%s\n",GlobalResult ? "All Passed" : "One or more Failed");
  GlobalErrors = GlobalResult ? 0 : 1;

  {
  static XtWidgetGeometry Expected[] = {
  	CWWidth | CWHeight,		0,	0,	80,	30,	0,0,0,	/* Form */
};

  PrintDetails(toplevel, Expected);
  }
  LessTifTestMainLoop(toplevel);

  exit(GlobalResult ? 0 : 1);
}
Пример #18
0
static Widget
style_value (int i)
{
  Widget w, l;
  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_POSITION);
  stdarg (XmNtopPosition, i);
  stdarg (XmNbottomAttachment, XmATTACH_POSITION);
  stdarg (XmNbottomPosition, i + 1);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  stdarg (XmNrightAttachment, XmATTACH_FORM);
  stdarg (XmNalignment, XmALIGNMENT_END);
  l = XmCreateLabel (value_labels, value_names[i], args, n);
  XtManageChild (l);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_POSITION);
  stdarg (XmNtopPosition, i);
  stdarg (XmNbottomAttachment, XmATTACH_POSITION);
  stdarg (XmNbottomPosition, i + 1);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  stdarg (XmNrightAttachment, XmATTACH_FORM);
  stdarg (XmNcolumns, 8);
  w = XmCreateTextField (value_texts, value_names[i], args, n);
  XtAddCallback (w, XmNvalueChangedCallback,
		 (XtCallbackProc) style_value_cb, (XtPointer) (size_t) i);
  XtManageChild (w);

  n = 0;
  stdarg (XmNtopAttachment, XmATTACH_POSITION);
  stdarg (XmNtopPosition, i);
  stdarg (XmNbottomAttachment, XmATTACH_POSITION);
  stdarg (XmNbottomPosition, i + 1);
  stdarg (XmNleftAttachment, XmATTACH_FORM);
  stdarg (XmNrightAttachment, XmATTACH_FORM);
  stdarg (XmNlabelString, ustr);
  units_pb[i] = XmCreatePushButton (units_form, value_names[i], args, n);
  XtAddCallback (units_pb[i], XmNactivateCallback,
		 (XtCallbackProc) units_cb, (XtPointer) (size_t) i);
  XtManageChild (units_pb[i]);

  return w;
}
Пример #19
0
Widget CreateLabelWidget ( Widget parent, char name[], char message[], 
							Arg *args, int n )
/************************************************************************
 * CreateLabelWidget							*
 *									*
 * Widget CreateLabelWidget(parent, name, message, args, n)		*
 *									*
 * Input parameters:							*
 *	parent		Widget						*
 *	name[]		char						*
 *	message[]	char						*
 *	*args		Arg						*
 *	n		int						*
 **									*
 ***********************************************************************/
{
  Widget label_widget;
  XmString label_text;
/*---------------------------------------------------------------------*/
/*
 * Convert message to XmString
 */
    label_text = XmStringCreateLocalized( message );

/*
 * Set label_text         
 */
    XtSetArg( args[n], XmNlabelString, label_text ); n++;

/*
 * Create label widget
 */
    label_widget = XmCreateLabel( parent, name, args, n );

/*
 * Free the string
 */
    XmStringFree( label_text);

    return( label_widget);

}
Пример #20
0
Файл: motif.c Проект: E-LLP/QuIP
static Widget generic_frame(Widget parent, Screen_Obj *sop, int shadow_type)
{
	Arg al[10];
	int ac = 0;
	Widget frame, label;

	/* set orientation */
	XtSetArg(al[ac], XmNorientation, XmVERTICAL); ac++;
	/* set shadow type */
	// How can we specify NO shadow???
	XtSetArg(al[ac], XmNshadowType, shadow_type); ac++;
	XtSetArg(al[ac], XmNshadowThickness, 2); ac++;
	/* set geometry and placement */
//fprintf(stderr,"generic_frame:  top offset = %d\n",curr_panel->po_curry);
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, curr_panel->po_curry); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, curr_panel->po_currx); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;

	frame = XmCreateFrame(parent, (char *)SOB_NAME(sop), al, ac);
	XtManageChild(frame);

	/* Save object position */
	// BUG with nav_panels, this is messed up...
	if( curr_panel != NULL ){
		sop->so_x = curr_panel->po_currx;
		sop->so_y = curr_panel->po_curry;
	} else {
		NWARN("CAUTIOUS:  generic_frame:  current_panel is NULL!?");
	}

	ac = 0;
	XtSetArg(al[ac], XmNchildType, XmFRAME_TITLE_CHILD); ac++;

	//label = XmCreateLabelGadget(frame,sop->so_name, al, ac);
	label = XmCreateLabel(frame, (char *)sop->so_name, al, ac);
	XtManageChild(label);

	return(frame);
}
Пример #21
0
Widget XmdsCreateDisplay(Widget parent, String name, ArgList args, Cardinal argcount)
{
  XmdsDisplayPart info = {-1,0};
  Widget w;
  Arg lab_args[] = {{XmNlabelString, 0}, {XmNuserData, DisplayUserData}};
  Arg *merged_args;
  int nid;

  XmdsSetSubvalues(&info, resources, XtNumber(resources), args, argcount);
  if (info.nid == -1)
    info.nid = XmdsGetDeviceNid();
  if (info.nid != -1)
    nid = info.nid + info.nid_offset;
  else
    nid = -1;
  if (nid != -1) {
    static struct descriptor_d display_dsc = {0, DTYPE_T, CLASS_D, 0};
    static struct descriptor_xd xd = {0, DTYPE_DSC, CLASS_XD, 0, 0};
    struct descriptor nid_dsc = {sizeof(int), DTYPE_NID, CLASS_S, (char *)0};
    int status;
    nid_dsc.pointer = (char *)&nid;
    status = TdiEvaluate(&nid_dsc, &xd MDS_END_ARG);
    if (status&1) {
      status = TdiDecompile(&xd, &display_dsc MDS_END_ARG);
      if (status&1) {
        static DESCRIPTOR(zero_dsc, "\0");
        StrConcat((struct descriptor *)&display_dsc, (struct descriptor *)&display_dsc, &zero_dsc MDS_END_ARG);
        lab_args[0].value = (long)XmStringCreateSimple(display_dsc.pointer);
      }
      else
        lab_args[0].value = (long)XmStringCreateSimple("Error - Decomp");
    }
    else
      lab_args[0].value = (long)XmStringCreateSimple("Error - Eval");
  }
  merged_args = XtMergeArgLists(args, argcount, lab_args, XtNumber(lab_args));
  w = XmCreateLabel(parent, name, merged_args, XtNumber(lab_args) + argcount);
  XtFree((char *)lab_args[0].value);
  XtFree((char *)merged_args);
  return w;
}
Пример #22
0
void InvPartEditor::createRegFrame(Widget parent)
{
    Widget regFrame = XtVaCreateManagedWidget(
                          "RegFrame",
                          xmFrameWidgetClass, parent,
                          XmNleftAttachment, XmATTACH_FORM,
                          XmNrightAttachment, XmATTACH_FORM,
                          XmNleftOffset, 5,
                          XmNrightOffset, 5,
                          XmNbottomOffset, 5,
                          XmNtopOffset, 5,
                          XmNtopAttachment, XmATTACH_FORM,
                          XmNbottomAttachment, XmATTACH_WIDGET,
                          //XmNbottomWidget,      push_button,
                          NULL);
    Arg args[5];
    //Now the togglebutton and textfield for the reference part
    XtSetArg(args[0], XmNorientation, XmVERTICAL);
    Widget regCol = XtCreateManagedWidget("parent", xmRowColumnWidgetClass, regFrame, args, 1);

    XmString descStr = XmStringCreateSimple((char *)"Enter regular expression to specify parts");
    XtSetArg(args[0], XmNlabelString, descStr);
    Widget description = XmCreateLabel(regCol, (char *)"description", args, 1);
    Widget visible = XmCreatePushButton(regCol, (char *)"visible", NULL, 0);
    Widget invisible = XmCreatePushButton(regCol, (char *)"invisible", NULL, 0);
    Widget invert = XmCreatePushButton(regCol, (char *)"invert", NULL, 0);
    XtManageChild(description);
    XtManageChild(visible);
    XtManageChild(invisible);
    XtManageChild(invert);
    //A text field to specify  part-ids by a given regular expression
    //since this widget is referenced by several callback
    //it is no local variable but a member of the class.
    partname_ = XmCreateTextField(regCol, (char *)"partname_", NULL, 0);
    XtManageChild(partname_);
    XtAddCallback(invert, XmNactivateCallback, invertByNameCB, (XtPointer) this);
    XtAddCallback(invisible, XmNactivateCallback, unselectByNameCB, (XtPointer) this);
    XtAddCallback(visible, XmNactivateCallback, selectByNameCB, (XtPointer) this);
}
Пример #23
0
static Widget create_status_history(Widget parent)
{
    static Widget history_shell = 0;

    if (history_shell != 0)
	return history_shell;

    Arg args[10];
    int arg;

    arg = 0;
    XtSetArg(args[arg], XmNallowShellResize, True); arg++;
    XtSetArg(args[arg], XmNwidth,            10);   arg++;
    XtSetArg(args[arg], XmNheight,           10);   arg++;
    history_shell = verify(XmCreateMenuShell(parent, XMST("status_history"), 
					     args, arg));

    arg = 0;
    XtSetArg(args[arg], XmNmarginWidth, 0);     arg++;
    XtSetArg(args[arg], XmNmarginHeight, 0);    arg++;
    XtSetArg(args[arg], XmNresizeWidth, True);  arg++;
    XtSetArg(args[arg], XmNresizeHeight, True); arg++;
    XtSetArg(args[arg], XmNborderWidth, 0);     arg++;
    XtSetArg(args[arg], XmNshadowThickness, 0); arg++;
    history_row = verify(XmCreateRowColumn(history_shell, XMST("row"), 
					   args, arg));
    XtManageChild(history_row);

    arg = 0;
    XtSetArg(args[arg], XmNresizable, True); arg++;
    XtSetArg(args[arg], XmNalignment, XmALIGNMENT_BEGINNING); arg++;
    history_label = verify(XmCreateLabel(history_row, XMST("label"), 
					 args, arg));
    XtManageChild(history_label);

    return history_shell;
}
Пример #24
0
void pglpfw_create ( Widget parent )
/************************************************************************
 * pglpfw_create							*
 *									*
 * This function creates a file selection dialog box.			*
 *									*
 * void pglpfw_create ( parent )					*
 *									*
 * Input parameters:							*
 *	parent		Widget		Parent widget			*
 *									*
 * Output parameters:							*
 * Return parameters:							*
 *			NONE						*
 *									*
 **									*
 *									* 
 * T. Lee/SAIC		04/02	Created					*
 * T. Piper/SAIC	10/05	declared ii & nn long			*
 ***********************************************************************/
{
    int		toff = 5, ier;
    long	ii, nn;
    char	*open_btnstr[] = {"Open", "Cancel"};
    char	*sort_str[] = {"Name", "Date"};
    Widget	pane, label, frame, sort_label;
    Arg         args[10];
    Cardinal    argcnt;
    XmString    xmpattern; 
    XmStringTable	xmfils;
/*---------------------------------------------------------------------*/

    _fileSelW = XmCreateFormDialog( parent, "Open product", NULL, 0 );
    XtVaSetValues(_fileSelW,
		XmNdialogStyle,		XmDIALOG_APPLICATION_MODAL,
		NULL);

    /*
     * create a parent pane widget
     */
    pane = XtVaCreateWidget("pglpfw_pane",
                    xmPanedWindowWidgetClass, _fileSelW,
                    XmNsashWidth,             1,
                    XmNsashHeight,            1,
                    NULL);

    /*
     * ******** SORT PANE ********
     * create a form widget to hold the sort by toggles
     */
    _sortPaneW = XtVaCreateWidget("pglpfw_form",
                    xmFormWidgetClass, 	      pane,
		    XmNnoResize,     	      TRUE,
		    XmNautoUnmanage, 	      FALSE,
		    XmNfractionBase,          110,
		    NULL );

    sort_label = XmCreateLabel( _sortPaneW, 
    		    "Display Files In Order By:", NULL, 0 );
    XtVaSetValues( sort_label,
		    XmNtopAttachment,         XmATTACH_POSITION,
		    XmNtopPosition,           2,
		    XmNleftAttachment,        XmATTACH_POSITION,
		    XmNleftPosition,          1,
		    XmNrightAttachment,       XmATTACH_POSITION,
		    XmNrightPosition,         60,
		    NULL );
    XtManageChild( sort_label );


    _sortRadioW = XtVaCreateManagedWidget ("sort_radio",
		    xmRowColumnWidgetClass,   _sortPaneW,
		    XmNorientation,           XmVERTICAL,
		    XmNradioBehavior,         True,
		    XmNtopAttachment,         XmATTACH_WIDGET,
		    XmNtopWidget,             sort_label,
		    XmNrightAttachment,       XmATTACH_FORM,
		    XmNleftAttachment,        XmATTACH_FORM,
                    NULL);

    nn = XtNumber (sort_str);
    _sortBy = SORT_BY_NAME;
    _sortBtn = (WidgetList)XtMalloc(nn*sizeof(Widget));

    for (ii = 0; ii < nn; ii++) {
        _sortBtn[ii] = XtVaCreateManagedWidget (sort_str[ii],
		    xmToggleButtonWidgetClass,      _sortRadioW,
                    XmNtraversalOn,                 FALSE,
		    NULL);
	XtAddCallback(_sortBtn[ii], XmNdisarmCallback,
	            pglpfw_sortByCb, (XtPointer) ii);

	XmToggleButtonSetState (_sortBtn[ii], (_sortBy == ii), FALSE);
    }

    XtManageChild(_sortPaneW); 


    /*
     * ******** SELECT PANE ********
     * create a form widget to hold the directory and file lists
     */
    _selectPaneW = XtVaCreateWidget("pglpfw_selectform",
                    xmFormWidgetClass, 	pane,
                    NULL);
    XtVaSetValues( _selectPaneW,
		    XmNnoResize,     TRUE,
		    XmNautoUnmanage, FALSE,
		    NULL );


    /*
     * create the directory list
     */
    label = XmCreateLabel( _selectPaneW, "Select directory:", NULL, 0 );
    XtManageChild( label );
    XtVaSetValues( label,
		    XmNtopAttachment,   XmATTACH_POSITION,
		    XmNtopPosition,     2,
		    XmNleftAttachment,  XmATTACH_POSITION,
		    XmNleftPosition,    1,
		    XmNrightAttachment, XmATTACH_POSITION,
		    XmNrightPosition,   60,
		    NULL );

    frame = XmCreateFrame( _selectPaneW, "_DirSel_frameW", NULL, 0 );
    XtVaSetValues( frame,
		    XmNtopAttachment,    XmATTACH_WIDGET,
		    XmNtopWidget,        label,
		    XmNrightAttachment,  XmATTACH_FORM,
		    XmNleftAttachment,   XmATTACH_FORM,
		    NULL );

    _dirSel_listW = XmCreateScrolledList( frame,
					  "_DirSel_lstW", NULL, 0 );
    XtVaSetValues( _dirSel_listW,
                    XmNvisibleItemCount, VISIBLE_ITEM,
		    NULL );
    XtAddCallback( _dirSel_listW, XmNbrowseSelectionCallback,
 		   pglpfw_selectDirCb, NULL );

    pglpfw_readUsrTbl("lpf.nmap", &_lpfUsrTbl, &ier);

    if (_lpfUsrTbl.nitems > 0) {

        xmfils = (XmStringTable) XtMalloc 
	    (_lpfUsrTbl.nitems * sizeof (XmString *));

        for (ii = 0; ii < _lpfUsrTbl.nitems; ii++) {
	    xmfils[ii] = XmStringCreateLocalized (_lpfUsrTbl.items[ii].title);
        }

        XtVaSetValues (_dirSel_listW,
		       XmNitems,	xmfils,
		       XmNitemCount,	_lpfUsrTbl.nitems,
		       NULL);

        for (ii = 0; ii < _lpfUsrTbl.nitems; ii++) {
	    XmStringFree (xmfils[ii]);
        }
	XtFree ((XtPointer) xmfils);

	/*
	 * hi-light the local directory
	 */
	_dirPos = _lpfUsrTbl.nitems;
    }

    XtManageChild( _dirSel_listW );
    XtManageChild( frame );

    /*
     * create the file list
     */
    label = XmCreateLabel( _selectPaneW, "Select layer product file:", NULL, 0 );
    XtManageChild (label );
    XtVaSetValues (label,
		   XmNtopAttachment,	XmATTACH_WIDGET,
		   XmNtopWidget,	frame,
		   XmNtopOffset,	toff,
		   XmNleftAttachment,	XmATTACH_POSITION,
		   XmNleftPosition,	1,
		   XmNrightAttachment,	XmATTACH_POSITION,
		   XmNrightPosition,	60,
		   NULL );

    frame = XmCreateFrame( _selectPaneW, "_FileSel_frameW", NULL, 0 );
    XtVaSetValues (frame,
		   XmNtopAttachment,	XmATTACH_WIDGET,
		   XmNtopWidget,	label,
		   XmNrightAttachment,	XmATTACH_FORM,
		   XmNleftAttachment,	XmATTACH_FORM,
		   NULL);

    _fileSel_listW = XmCreateScrolledList (frame, "_FileSel_lstW", NULL, 0);

    XtVaSetValues (_fileSel_listW,
		   XmNvisibleItemCount, VISIBLE_ITEM,
		   NULL);

    XtAddCallback (_fileSel_listW, XmNbrowseSelectionCallback,
		   pglpfw_selectCb, NULL);


    XtManageChild (_fileSel_listW);
    XtManageChild (frame);

    XtManageChild(_selectPaneW);

    /*
     * ******** BROWSE PANE ********
     */
    _browseBtnPane = 
	XtVaCreateManagedWidget ("Browse",
				 xmPushButtonWidgetClass,	pane,
				 NULL);
    XtAddCallback(_browseBtnPane, XmNarmCallback,
		  pglpfw_browseBtnCb, (XtPointer) NULL); 



    /*
     * ******** OPEN CONTROL PANE ********
     */
    _openPaneW = 
	(Widget) NxmCtlBtn_create (pane, 1, "pglpfw_open", 
				   XtNumber(open_btnstr), open_btnstr, 
				   (XtCallbackProc)pglpfw_openCtlBtnCb, NULL); 


    XtManageChild(pane);


    /*
     * browse popup
     */

    argcnt = 0;

    xmpattern  = XmStringCreateLocalized(FILE_PATTERN);

    XtSetArg (args[argcnt], XmNpattern, xmpattern); 
    argcnt++;

    XtSetArg (args[argcnt], XmNtitle, "Browse"); 
    argcnt++;

    _browsePopup = XmCreateFileSelectionDialog(parent, "browseBox", 
					       args, argcnt);
    XmStringFree(xmpattern);

    XtAddCallback(_browsePopup, XmNcancelCallback,
		  pglpfw_browseDoneCb, (XtPointer) 0);
    XtAddCallback(_browsePopup, XmNokCallback,
		  pglpfw_browseDoneCb, (XtPointer) 1);

    XtUnmanageChild(XmFileSelectionBoxGetChild(_browsePopup, 
					       XmDIALOG_HELP_BUTTON));

}
Пример #25
0
int
main(int argc, char **argv)
{
  XtAppContext	app;
  Widget Shell;
  Widget Form;
  Widget BottomLabel;
  Widget TopLabel;
  Widget Sep;

  XtSetLanguageProc(NULL, NULL, NULL);

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

  Form = XmCreateRowColumn(Shell,"RC",NULL,0);
  XtVaSetValues(Form,
  	NULL);

  BottomLabel = XmCreateLabel(Form,"TopLabel",NULL,0);
  XtVaSetValues(BottomLabel,
  	XmNalignment, XmALIGNMENT_CENTER,
  	XmNwidth, 52,
  	XmNheight, 17,
  	XmNrecomputeSize, False,
  	NULL);
  XtManageChild(BottomLabel);

  Sep = XmCreateSeparator(Form, "Sep", NULL, 0);
  XtManageChild(Sep);

  BottomLabel = XmCreateLabel(Form,"BottomLabel",NULL,0);
  XtVaSetValues(BottomLabel,
  	XmNalignment, XmALIGNMENT_CENTER,
  	XmNwidth, 70,
  	XmNheight, 30,
  	XmNrecomputeSize, False,
  	NULL);
  XtManageChild(BottomLabel);

  XtManageChild(Form);

  XtRealizeWidget(Shell);

/* Note: the following values are the result of
 * querying the current geometry.
 */
{
XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,  673,  241,   76,   61, 0,0,0, /* RC */
   CWWidth | CWHeight | CWX | CWY,    3,    3,   70,   17, 0,0,0, /* TopLabel */
   CWWidth | CWHeight | CWX | CWY,    3,   23,   70,    2, 0,0,0, /* Sep */
   CWWidth | CWHeight | CWX | CWY,    3,   28,   70,   30, 0,0,0, /* BottomLabel */

   CWWidth | CWHeight            ,  673,  241,  144,   61, 0,0,0, /* RC */
   CWWidth | CWHeight | CWX | CWY,    3,    3,  138,   17, 0,0,0, /* TopLabel */
   CWWidth | CWHeight | CWX | CWY,    3,   23,  138,    2, 0,0,0, /* Sep */
   CWWidth | CWHeight | CWX | CWY,    3,   28,  138,   30, 0,0,0, /* BottomLabel */

   CWWidth | CWHeight            ,  673,  241,   80,   61, 0,0,0, /* RC */
   CWWidth | CWHeight | CWX | CWY,    3,    3,   74,   17, 0,0,0, /* TopLabel */
   CWWidth | CWHeight | CWX | CWY,    3,   23,   74,    2, 0,0,0, /* Sep */
   CWWidth | CWHeight | CWX | CWY,    3,   28,   74,   30, 0,0,0, /* BottomLabel */
};

  PrintDetails(Shell, Expected);
  LessTifTestWaitForIt(Shell);
  LessTifTestResizeWidget(Shell, 144, 61);
  PrintDetails(Shell, Expected);
  LessTifTestWaitForIt(Shell);
  LessTifTestResizeWidget(Shell, 80, 61);
  PrintDetails(Shell, Expected);
}

      LessTifTestMainLoop(Shell);
  exit(0);
}
Пример #26
0
main(int argc, char **argv)
{
	Widget shell, rowcolumn, scale, pushbutton, label1, label2, text;
	Widget paned, text2;
	int n, i;
	Widget widlist[100];
	Widget emacscli[100];
	Arg args[100];
	int no_ews = 1;
	char buf[100];

	if (argc > 1)
		no_ews = atoi(argv[1]);

	shell = XtAppInitialize(&xt_app_con, "Testmotif", NULL, 0,
				&argc, argv, NULL, NULL, 0);

	rowcolumn = XmCreateRowColumn(shell, "rowcolumn", NULL, 0);
	XtManageChild(rowcolumn);

	n = 0;
	XtSetArg(args[n], XmNtraversalOn, TRUE);
	n++;
#if 0
	label1 = XmCreateLabel(rowcolumn, "label1", args, n);
#endif
	label1 = XtVaCreateWidget("label1", xmLabelWidgetClass, rowcolumn,
				  XmNwidth, 50, XmNheight, 30,
				  XmNtraversalOn, TRUE, NULL);
	label2 = XmCreateLabel(rowcolumn, "label2", NULL, 0);
	scale = XmCreateScale(rowcolumn, "scale", NULL, 0);
	XtAddCallback(scale, XmNvalueChangedCallback, ScaleValueChangedCB,
		      label1);
	paned = XmCreatePanedWindow(rowcolumn, "paned", NULL, 0);
	n = 0;
	widlist[n++] = label1;
	widlist[n++] = label2;
	widlist[n++] = scale;
	widlist[n++] = paned;
	XtManageChildren(widlist, n);

	pushbutton = XmCreatePushButton(paned, "pushbutton", NULL, 0);
	text = XmCreateText(paned, "text", NULL, 0);
	for (i = 0; i < no_ews; i++) {
		int sz = snprintf(buf, sizeof(buf), "extcli%d", i);
		assert(sz>=0 && sz < sizeof(buf));
		emacscli[i] =
		    XtVaCreateWidget(buf, externalClientWidgetClass, paned,
				     XmNwidth, 500, XmNheight, 200,
				     XmNtraversalOn, TRUE,
				     NULL);
	}
	text2 = XmCreateText(paned, "text2", NULL, 0);
	n = 0;
	widlist[n++] = pushbutton;
	widlist[n++] = text;
	for (i = 0; i < no_ews; i++)
		widlist[n++] = emacscli[i];
	widlist[n++] = text2;
	XtManageChildren(widlist, n);

	XtRealizeWidget(shell);

	{
		XmString lab;
		char labarr[1000];
		char tmpbuf[50];

		strcpy(labarr, "window:");
		for (i = 0; i < no_ews; i++) {
			int sz = snprintf(tmpbuf, sizeof(tmpbuf),
					  " %d", XtWindow(emacscli[i]));
			assert(sz>=0 && sz<sizeof(tmpbuf));
			strcat(labarr, tmpbuf);
		}
		lab = XmStringCreateLocalized(labarr);
		XtVaSetValues(label2, XmNlabelString, lab, NULL);
		XmStringFree(lab);
	}

	XtAppMainLoop(xt_app_con);
}
Пример #27
0
void create_emfpr_dr_shell (Widget parent)
{
	Widget children[6];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */

	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNminWidth, 492); ac++;
	XtSetArg(al[ac], XmNminHeight, 182); ac++;
	XtSetArg(al[ac], XmNmaxWidth, 492); ac++;
	XtSetArg(al[ac], XmNmaxHeight, 182); ac++;
	emfpr_dr_shell = XmCreateDialogShell ( parent, "emfpr_dr_shell", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	emfpr_dr_main_form = XmCreateForm ( emfpr_dr_shell, "emfpr_dr_main_form", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNshadowThickness, 2); ac++;
	XtSetArg(al[ac], XmNshadowType, XmSHADOW_IN); ac++;
	emfpr_dr_inner_form = XmCreateForm ( emfpr_dr_main_form, "emfpr_dr_inner_form", al, ac );
	ac = 0;
	emfpr_dr_resume_lbl = XmCreateLabel ( emfpr_dr_inner_form, "emfpr_dr_resume_lbl", al, ac );
	emfpr_dr_product_lbl = XmCreateLabel ( emfpr_dr_inner_form, "emfpr_dr_product_lbl", al, ac );
	XtSetArg(al[ac], XmNmaxLength, 80); ac++;
	XtSetArg(al[ac], XmNcolumns, 40); ac++;
	emfpr_dr_product_txt = XmCreateText ( emfpr_dr_inner_form, "emfpr_dr_product_txt", al, ac );
	ac = 0;
	emfpr_dr_disc_reason_lbl = XmCreateLabel ( emfpr_dr_inner_form, "emfpr_dr_disc_reason_lbl", al, ac );
	XtSetArg(al[ac], XmNmaxLength, 80); ac++;
	XtSetArg(al[ac], XmNcolumns, 40); ac++;
	emfpr_dr_disc_reason_txt = XmCreateText ( emfpr_dr_inner_form, "emfpr_dr_disc_reason_txt", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNseparatorType, XmNO_LINE); ac++;
	emfpr_dr_sep1 = XmCreateSeparator ( emfpr_dr_inner_form, "emfpr_dr_sep1", al, ac );
	ac = 0;
	emfpr_dr_btn_form = XmCreateForm ( emfpr_dr_main_form, "emfpr_dr_btn_form", al, ac );
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNpacking, XmPACK_COLUMN); ac++;
	XtSetArg(al[ac], XmNentryAlignment, XmALIGNMENT_CENTER); ac++;
	emfpr_dr_btn_rc = XmCreateRowColumn ( emfpr_dr_btn_form, "emfpr_dr_btn_rc", al, ac );
	ac = 0;
	emfpr_dr_resume_btn = XmCreatePushButton ( emfpr_dr_btn_rc, "emfpr_dr_resume_btn", al, ac );
	emfpr_dr_close_btn = XmCreatePushButton ( emfpr_dr_btn_rc, "emfpr_dr_close_btn", al, ac );
	emfpr_dr_help_btn = XmCreatePushButton ( emfpr_dr_btn_rc, "emfpr_dr_help_btn", al, ac );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 10); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 10); ac++;
	XtSetArg(al[ac], XmNbottomWidget, emfpr_dr_btn_form); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 10); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 10); ac++;
	XtSetValues ( emfpr_dr_inner_form,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 10); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 100); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( emfpr_dr_btn_form,al, ac );
	ac = 0;
	XtAddCallback (emfpr_dr_main_form,XmNhelpCallback, XDhelp_link, (XtPointer) &_xd_help_pairs[0] );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 10); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 10); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( emfpr_dr_resume_lbl,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, emfpr_dr_product_txt); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, emfpr_dr_product_txt); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightWidget, emfpr_dr_product_txt); ac++;
	XtSetValues ( emfpr_dr_product_lbl,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 10); ac++;
	XtSetArg(al[ac], XmNtopWidget, emfpr_dr_resume_lbl); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 166); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( emfpr_dr_product_txt,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, emfpr_dr_disc_reason_txt); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, emfpr_dr_disc_reason_txt); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightWidget, emfpr_dr_disc_reason_txt); ac++;
	XtSetValues ( emfpr_dr_disc_reason_lbl,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, emfpr_dr_product_txt); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNleftWidget, emfpr_dr_product_txt); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( emfpr_dr_disc_reason_txt,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 10); ac++;
	XtSetArg(al[ac], XmNtopWidget, emfpr_dr_disc_reason_txt); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 10); ac++;
	XtSetArg(al[ac], XmNleftWidget, emfpr_dr_disc_reason_txt); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( emfpr_dr_sep1,al, ac );
	ac = 0;
	children[ac++] = emfpr_dr_resume_lbl;
	children[ac++] = emfpr_dr_product_lbl;
	children[ac++] = emfpr_dr_product_txt;
	children[ac++] = emfpr_dr_disc_reason_lbl;
	children[ac++] = emfpr_dr_disc_reason_txt;
	children[ac++] = emfpr_dr_sep1;
	XtManageChildren(children, ac);
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( emfpr_dr_btn_rc,al, ac );
	ac = 0;
	XtAddCallback (emfpr_dr_resume_btn, XmNactivateCallback, undo_disc_product_cb,NULL);
	XtAddCallback (emfpr_dr_close_btn, XmNactivateCallback, emfpr_dr_close_cb,NULL);
	XtAddCallback (emfpr_dr_help_btn,XmNactivateCallback, XDhelp_link, (XtPointer) &_xd_help_pairs[1] );
	children[ac++] = emfpr_dr_resume_btn;
	children[ac++] = emfpr_dr_close_btn;
	children[ac++] = emfpr_dr_help_btn;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = emfpr_dr_btn_rc;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = emfpr_dr_inner_form;
	children[ac++] = emfpr_dr_btn_form;
	XtManageChildren(children, ac);
	ac = 0;
}
Пример #28
0
/*
 * Function:  _DtPrintCreateMarginFrame
 *
 * Creates a frame for specifying margins.  The frame contains four text
 * fields, one for each _DtPrintMarginEnum.
 *
 *	parent -	specifies the parent of the frame.
 *
 * Returns the widget id of the frame.
 */
Widget
_DtPrintCreateMarginFrame(
	Widget			parent
	)
{
    DtpoMarginFrame
		*info;
    Arg		args[16];
    int		n;
    XmString	xms;

    info = (DtpoMarginFrame *) XtMalloc( sizeof(DtpoMarginFrame) );

    n = 0;
    XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    info->frame = XmCreateFrame(parent, "MarginFrame", args, n);
    XtAddCallback(
		info->frame,
		XmNdestroyCallback,
		_DtPrintDestroyMarginFrameCB,
		(XtPointer) info
		);

    xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_LABEL);
    n = 0;
    XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
    XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    info->label = XmCreateLabel(info->frame, "MarginLabel", args, n);
    XtManageChild(info->label);
    XmStringFree(xms);

    n = 0;
    XtSetArg(args[n], XmNallowOverlap, False); n++;
    XtSetArg(args[n], XmNfractionBase, 2); n++;
    info->form = XmCreateForm(info->frame, "MarginForm", args, n);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNrightPosition, 1); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;
    info->top = XmCreateTextField(info->form, "MarginTopText", args, n);
    XtManageChild(info->top);

    xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_TOP_MARGIN_LABEL);

    n = 0;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->top); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->top); n++;
    XtSetArg(args[n], XmNrightOffset, 3); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, info->top); n++;
    XtSetArg(args[n], XmNbottomOffset, 0); n++;
    info->top_label =
      XmCreateLabelGadget(info->form, "MarginTopLabel", args, n);
    XmStringFree(xms);
    XtManageChild(info->top_label);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->top); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
    info->right = XmCreateTextField(info->form, "MarginRightText", args, n);
    XtManageChild(info->right);

    xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_RIGHT_MARGIN_LABEL);
    n = 0;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->right); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->right); n++;
    XtSetArg(args[n], XmNrightOffset, 3); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, info->right); n++;
    XtSetArg(args[n], XmNbottomOffset, 0); n++;
    info->right_label =
      XmCreateLabelGadget(info->form, "MarginRightLabel", args, n);
    XmStringFree(xms);
    XtManageChild(info->right_label);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->top); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->top); n++;
    XtSetArg(args[n], XmNrightOffset, 0); n++;
    info->bottom = XmCreateTextField(info->form, "MarginBottomText", args, n);
    XtManageChild(info->bottom);

    xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_BOTTOM_MARGIN_LABEL);
    n = 0;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->bottom); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->bottom); n++;
    XtSetArg(args[n], XmNrightOffset, 3); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, info->bottom); n++;
    XtSetArg(args[n], XmNbottomOffset, 0); n++;
    info->bottom_label =
      XmCreateLabelGadget(info->form, "MarginBottomLabel", args, n);
    XmStringFree(xms);
    XtManageChild(info->bottom_label);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->bottom); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->right); n++;
    XtSetArg(args[n], XmNrightOffset, 0); n++;
    info->left = XmCreateTextField(info->form, "MarginLeftText", args, n);
    XtManageChild(info->left);

    xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_LEFT_MARGIN_LABEL);
    n = 0;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->left); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->left); n++;
    XtSetArg(args[n], XmNrightOffset, 3); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, info->left); n++;
    XtSetArg(args[n], XmNbottomOffset, 0); n++;
    info->left_label =
      XmCreateLabelGadget(info->form, "MarginLeftLabel", args, n);
    XmStringFree(xms);
    XtManageChild(info->left_label);

    XtManageChild(info->form);
    return info->frame;
}
Пример #29
0
/*
 * Function:  _DtPrintCreateHdrFtrFrame
 *
 * Creates a frame for specifying the contents of page headers and footers.
 * The frame contains four option menus, one for each _DtPrintHdrFtrEnum.
 * The pulldown menus for the option menu are constructed from the .string
 * field in the array of _DtPrintHdrFtrSpec in "specs".
 * 
 * _DtPrintCreateHdrFtrFrame copies the pointer to the array of
 * _DtPrintHdrFtrSpec.  IT DOES NOT COPY THE ELEMENTS OF THE ARRAY.
 *
 *	parent -	specifies the parent of the frame.
 *	nspecs -	specifies the number of entries in the specs array.
 *	specs -		array of header/footer specifiers.  The .string
 *			field is used to construct labels in the GUI.
 *			The .data field is returned in calls to
 *			_DtPrintGetHdrFtrSpec.
 *
 * Returns the widget id for the frame.
 */
Widget
_DtPrintCreateHdrFtrFrame(
	Widget		parent,
	int		nspecs,
	char		**spec_strings,
	void		**spec_data
	)
{
    DtpoHdrFtrFrame	*info;
    Arg		args[16];
    int		n;
    int		i;
    XmString	xms;

    info = (DtpoHdrFtrFrame *) XtMalloc( sizeof(DtpoHdrFtrFrame) );
    info->nspecs = nspecs;
    info->specs = (DtpoHdrFtrSpec *) XtMalloc(nspecs*sizeof(DtpoHdrFtrSpec));
    for (i=0; i<nspecs; i++)
    {
        info->specs[i].string = spec_strings[i];
	if (spec_data != (void*) NULL)
          info->specs[i].data = spec_data[i];
	else
	  info->specs[i].data = (void*) NULL;
	info->specs[i].button = (Widget) NULL;
    }


    /*
     * Create the frame and attach add a destroyCallback to clean up
     * memory allocated for this object.
     */
    n = 0;
    XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    info->frame = XmCreateFrame(parent, "HdrFtrFrame", args, n);
    XtAddCallback(
		info->frame,
		XmNdestroyCallback,
		_DtPrintDestroyHdrFtrFrameCB,
		(XtPointer) info
		);

    /*
     * Create a label child for the frame
     */
    xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_LABEL);
    n = 0;
    XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
    XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    info->label = XmCreateLabel(info->frame, "HdrFtrLabel", args, n);
    XtManageChild(info->label);
    XmStringFree(xms);

    /*
     * Create a form work area child which will be populated by the
     * OptionMenu's.
     */
    n = 0;
    XtSetArg(args[n], XmNallowOverlap, False); n++;
    XtSetArg(args[n], XmNfractionBase, 2); n++;
    info->form = XmCreateForm(info->frame, "HdrFtrForm", args, n);

    /*
     * Create the pulldown menu for the option menus.
     * Store the button index in the userData resource of each button.
     */
    info->menu = XmCreatePulldownMenu(parent, "HdrFtrMenu", NULL, 0);
    for (i=0; i<info->nspecs; i++)
    {
	static char	button_label[32];

	sprintf(button_label, "Button%d", i);
	xms = XmStringCreateLocalized(info->specs[i].string);
	n = 0;
	XtSetArg(args[n], XmNlabelString, xms); n++;
	XtSetArg(args[n], XmNuserData, i); n++;
	info->specs[i].button =
	    XmCreatePushButtonGadget(info->menu, button_label, args, n);
        XmStringFree(xms);
        XtManageChild(info->specs[i].button);
    }


    /*
     * Create the option menus using the menu created above.
     */
    xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_TOP_LEFT_LABEL);

    n=0;
    XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNrightPosition, 1); n++;
    XtSetArg(args[n], XmNrightOffset, 5); n++;

    info->top_left = XmCreateOptionMenu(
				info->form,
				"PageHeaderLeftOM",
				args, n
				);
    XmStringFree(xms);
    XtManageChild(info->top_left);

    xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_TOP_RIGHT_LABEL);

    n=0;
    XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->top_left); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;

    info->top_right = XmCreateOptionMenu(
				info->form,
				"PageHeaderRightOM",
				args, n
				);
    XmStringFree(xms);
    XtManageChild(info->top_right);

    xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_BOTTOM_LEFT_LABEL);

    n=0;
    XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->top_left); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->top_left); n++;
    XtSetArg(args[n], XmNrightOffset, 0); n++;

    info->bottom_left = XmCreateOptionMenu(
				info->form,
				"PageFooterLeftOM",
				args, n
				);
    XmStringFree(xms);
    XtManageChild(info->bottom_left);

    xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_BOTTOM_RIGHT_LABEL);

    n=0;
    XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
    XtSetArg(args[n], XmNlabelString, xms); n++;
    XtSetArg(args[n], XmNuserData, info); n++;
    XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, info->bottom_left); n++;
    XtSetArg(args[n], XmNtopOffset, 0); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, info->top_right); n++;
    XtSetArg(args[n], XmNrightOffset, 0); n++;

    info->bottom_right = XmCreateOptionMenu(
				info->form,
				"PageFooterRightOM",
				args, n
				);
    XmStringFree(xms);
    XtManageChild(info->bottom_right);

    XtManageChild(info->form);
    return info->frame;
}
Пример #30
0
void
CreateControlPanel()
{
	Widget	PopupShell, Form1, SBResLabel, SBStringResLabel,
                SBNumericResLabel;
	Widget  Manager1, Manager2, Manager3;
	Widget  ArrowSensLabel, ArrowSensPulldown, ArrowSensOptions,
	        ArrowSensPB[NUM_ARROW_SENS_BTNS];
	Widget  DecimalPtsLabel, DecimalPtsTF;
	Widget  IncrValueLabel, IncrValueTF;
	Widget  MaxValueLabel, MaxValueTF;
	Widget  MinValueLabel, MinValueTF;
	Widget  NumValuesLabel, NumValuesTF;
	Widget  PositionLabel, PositionTF;
	Widget  ChildTypeLabel, ChildTypePulldown, ChildTypeOptions,
                ChildTypePB[NUM_CHILD_TYPE_BTNS];
	Widget  ValuesLabel, ValuesComboBox;
	XmString	string;
	int	i;

        n = 0;
        XtSetArg( args[n], XmNx, 0 ); n++;
        XtSetArg( args[n], XmNy, 500 ); n++;
        XtSetArg( args[n], XmNwidth,  CONTROL_PANEL_WIDTH ); n++;
        XtSetArg( args[n], XmNheight,  CONTROL_PANEL_HEIGHT ); n++;
        PopupShell = XtCreatePopupShell("Resource Control Panel",
                                         topLevelShellWidgetClass,
                                         Shell1, args, n );
        XtManageChild( PopupShell );

        n = 0;
	Form1 = XmCreateForm( PopupShell, "Form1", args, n );
        XtManageChild( Form1 );



        string = XmStringCreateLtoR("SpinBox Resources",
				XmFONTLIST_DEFAULT_TAG );

        n = 0;
        XtSetArg( args[n], XmNtopAttachment, XmATTACH_FORM ); n++;
        XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++;
        XtSetArg( args[n], XmNlabelString, string ); n++;
        XtSetArg( args[n], XmNbackground, CommonGetColor("white")); n++;
        XtSetArg( args[n], XmNforeground, CommonGetColor("blue")); n++;
        SBResLabel = XmCreateLabel( Form1, "SBResLabel", args, n );
        XtManageChild( SBResLabel );

        XmStringFree( string );

        Manager1 = 
        CreateSpinBoxResourceControls( Form1, SBResLabel, Form1, Form1 );

      /*
       *  Create SpinBox Constraint Resource Panel for an XmSTRING child
       *  type.
       */
        Manager2 = CreateConstraintResourceControls( Form1, Form1, Form1, 
                          XmSTRING );

        string = XmStringCreateLtoR("SpinBox Constraint Resources - XmSTRING",
                     XmFONTLIST_DEFAULT_TAG );
        n = 0; 
        XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++;
        XtSetArg( args[n], XmNtopWidget, Manager1 ); n++;
        XtSetArg( args[n], XmNleftAttachment, XmATTACH_FORM ); n++;
        XtSetArg( args[n], XmNlabelString, string ); n++;
        XtSetArg( args[n], XmNbackground, CommonGetColor("white")); n++;
        XtSetArg( args[n], XmNforeground, CommonGetColor("blue")); n++;
        SBStringResLabel = XmCreateLabel( Form1, "SBStringResLabel",
                                          args, n );
        XtManageChild( SBStringResLabel );

        XmStringFree( string );

      /*
       *  Create SpinBox Constraint Resource Panel for an XmNUMERIC child
       *  type.
       */
        Manager3 = CreateConstraintResourceControls( Form1, Manager2,
                          Form1, XmNUMERIC );

        string = XmStringCreateLtoR("SpinBox Constraint Resources - XmNUMERIC",
                                XmFONTLIST_DEFAULT_TAG );

        n = 0;
        XtSetArg( args[n], XmNtopAttachment, XmATTACH_WIDGET ); n++;
        XtSetArg( args[n], XmNtopWidget, Manager1 ); n++;
        XtSetArg( args[n], XmNx, CONTROL_PANEL_WIDTH / 2 - MARGIN ); n++;
        XtSetArg( args[n], XmNlabelString, string ); n++;
        XtSetArg( args[n], XmNbackground, CommonGetColor("white")); n++;
        XtSetArg( args[n], XmNforeground, CommonGetColor("blue")); n++;
        SBNumericResLabel = XmCreateLabel( Form1, "SBStringResLabel",
                                          args, n );
        XtManageChild( SBNumericResLabel );

        XmStringFree( string );

   XtPopup( PopupShell, XtGrabNone );

}