static int AllocateEventWidget(Display* dpy, XID* pxid)
{
  Arg args[40];
  int argc;
  Widget w;
  
  if (!dpy || !pxid) return 0;
  argc = 0;
  XtSetArg(args[argc], XmNallowShellResize, True); argc++;
  XtSetArg(args[argc], XmNwidth, 100); argc++;
  XtSetArg(args[argc], XmNheight, 100); argc++;
  XtSetArg(args[argc], XmNmappedWhenManaged, False); argc++;
  w  = NULL;
  w  = XtAppCreateShell("WF","XApplication",
						vendorShellWidgetClass,
						dpy,
						args,
						argc);
  if (w == NULL) return 0;
  XtRealizeWidget(w);
  XtAddEventHandler(w, PropertyChangeMask, FALSE,
					request_handler, NULL);
  g_request_handler_atom = 
	XInternAtom(dpy, "WF atom", FALSE);
  *pxid = XtWindow(w);
  XFlush(dpy);
  return 1;
}
示例#2
0
void Application::initialize(std::string name, int argc, char* argv[])
{
  String fallbacks[fallbackResources.size() + 1];
  XtToolkitInitialize();
  context = XtCreateApplicationContext();

  for(unsigned int resourceIndex = 0; resourceIndex < fallbackResources.size(); resourceIndex++)
  {
    fallbacks[resourceIndex] = (char*)fallbackResources.at(resourceIndex).c_str();
  }

  fallbacks[fallbackResources.size()] = NULL;

  XtAppSetFallbackResources(context, fallbacks);
  Application::name = name;

  display = XtOpenDisplay(context, NULL, name.c_str(), name.c_str(), NULL, 0, &argc, argv);

  if(display == NULL)
  {
    throw MotifException("Failed to open display");
  }

  initialized = true;

  widget = XtAppCreateShell(Application::getName().c_str(), Application::getName().c_str(), applicationShellWidgetClass, Application::getDisplay(), NULL, 0);

}
示例#3
0
void imagesc(void *data, int x, int y, const char* type,
             double (*transf)(double), const char **colormap, char *title)
{
  static XtAppContext context;
  Widget drawing_area;
  Widget toplevel;
  Atom wm_delete;
  XEvent event;
  XpmImage *xpmImage;
  Boolean exitFlag = False;
  static Display *display = NULL;
  Arg al[10];
  int ac;
  int argc = 0;

  xpmImage = CreateXpmImage(data, x, y, type, transf, colormap);

  /* create the toplevel shell */
  XtToolkitInitialize();
  if (display == NULL) {
    context = XtCreateApplicationContext();
    display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL);
  }
  toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0);

  /* set window size. */
  ac=0;
  XtSetArg(al[ac],XmNmaxWidth,  x); ac++;
  XtSetArg(al[ac],XmNmaxHeight, y); ac++;
  XtSetArg(al[ac],XmNminWidth,  x); ac++;
  XtSetArg(al[ac],XmNminHeight, y); ac++;
  XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++;
  XtSetValues(toplevel,al,ac);

  ac=0;
  drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac);
  XtManageChild(drawing_area);
  XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage);
  XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag);
  XtRealizeWidget(toplevel);
  wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag);
  XmActivateWMProtocol(toplevel, wm_delete);

  while (!exitFlag) {
    XtAppNextEvent(context, &event);
    XtDispatchEvent(&event);
  }

  XtDestroyWidget(drawing_area);
  XtDestroyWidget(toplevel);
  free(xpmImage);
}
/*!
    \internal
    Initializes QtMotifDialog by creating the QtMotifDialogPrivate data
    and the Shell widget.
*/
void QtMotifDialog::init( const char *name, Widget parent, ArgList args, Cardinal argcount )
{
    d = new QtMotifDialogPrivate;

    Arg *realargs = new Arg[ argcount + 3 ];
    memcpy( realargs, args, argcount * sizeof(Arg) );
    int screen = x11Info().screen();
    if ( !QX11Info::appDefaultVisual(screen)) {
	// make Motif use the same visual/colormap/depth as Qt (if Qt
	// is not using the default)
	XtSetArg(realargs[argcount], XtNvisual, QX11Info::appVisual(screen));
	++argcount;
	XtSetArg(realargs[argcount], XtNcolormap, QX11Info::appColormap(screen));
	++argcount;
	XtSetArg(realargs[argcount], XtNdepth, QX11Info::appDepth(screen));
	++argcount;
    }

    // create the dialog shell
    if ( parent ) {
        if (!name)
            d->shell = XtCreatePopupShell( "QtMotifDialog", qmotifDialogWidgetClass, parent,
				       realargs, argcount );
        else
            d->shell = XtCreatePopupShell( name, qmotifDialogWidgetClass, parent,
				       realargs, argcount );
    } else {
        if (!name)
            d->shell = XtAppCreateShell( "QtMotifDialog", "QtMotifDialog", qmotifDialogWidgetClass,
                                         QtMotif::display(), realargs, argcount );
        else
            d->shell = XtAppCreateShell( name, name, qmotifDialogWidgetClass,
                                         QtMotif::display(), realargs, argcount );
    }

    ( (QtMotifDialogWidget) d->shell )->qmotifdialog.dialog = this;

    delete [] realargs;
    realargs = 0;
}
示例#5
0
int main(int argc, char *argv[])
{
  KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KXSConfig"), description, version);

  KCmdLineArgs::addCmdLineOptions(options);

  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  if(args->count()==0)
    exit(1);

  /* We must read exactly the same resources as xscreensaver.
     That means we must have both the same progclass *and* progname,
     at least as far as the resource database is concerned.  So,
     put "xscreensaver" in argv[0] while initializing Xt.
   */
  const char *dummyargs[] = { "xscreensaver" };
  int dummyargc = 1;
  progname = dummyargs[0];

  // Teach Xt to use the Display that TQt has already opened.
  XtToolkitInitialize ();
  XtAppContext xtApp = XtCreateApplicationContext ();
  Display *dpy = qt_xdisplay();
  XtAppSetFallbackResources (xtApp, const_cast<char**>(defaults));
  XtDisplayInitialize (xtApp, dpy, progname, progclass, 0, 0,
                       &dummyargc,
                       const_cast<char**>(dummyargs));
  Widget toplevel_shell = XtAppCreateShell (progname, progclass,
	  applicationShellWidgetClass,
	  dpy, 0, 0);
  dpy = XtDisplay (toplevel_shell);
  db = XtDatabase (dpy);
  XtGetApplicationNameAndClass (dpy, const_cast<char**>(&progname),
                                const_cast<char**>(&progclass));

  TQString name = TQString::fromLocal8Bit(args->arg(args->count() - 1));
  KXSConfigDialog *dialog=new KXSConfigDialog(args->arg(0), name);
  if ( dialog->create() ) {
      dialog->show();
      app.setMainWidget(dialog);
      app.exec();
  } else {
      KMessageBox::sorry(0,
	      i18n("No configuration available for %1").tqarg(name),
	      name );
  }

  delete dialog;
}
示例#6
0
int
main (int    argc,
      char **argv)
{
  Widget app_shell;

  /* Add Xt support for i18n: locale */
  XtSetLanguageProc(NULL, NULL, NULL);

  XtToolkitInitialize ();
  app_context = XtCreateApplicationContext ();
  display = XtOpenDisplay (app_context, NULL, argv[0], "ArborSplash",
			   NULL, 0, &argc, argv);
  if (!display)
  {
    printf("%s: can't open display, exiting...\n", argv[0]);
    exit (-1);
  }

  /*
   * Create a dummy application shell, and then hide it again so that the
   * splash screen can be a top-level screen for all applications.
   */
  app_shell = XtAppCreateShell(".splash",
                               "ArborSplash",
                               applicationShellWidgetClass,
                               display,
                               NULL, 0);

  create_splash_shell(app_shell);
  XtUnmanageChild(splash_form);

  /*
   * Unmanage the OK button -- the window will pop itself down after
   * 5 seconds.
   */
  XtUnmanageChild(splash_ok_btn);
  
  show_window(splash_shell, splash_form);

  XtAddEventHandler(splash_shell, 
		    VisibilityChangeMask,
		    False,
		    popup_splash,
		    NULL);
  XtAppAddTimeOut(app_context, 5000, exit_splash, NULL);
  XtAppMainLoop(app_context);

  return(0);
}
示例#7
0
void KXtWidget::init(const char* name, WidgetClass widget_class,
                    Widget parent, QWidget* qparent,
                    ArgList args, Cardinal num_args,
                    bool managed)
{
    need_reroot=FALSE;
    xtparent = 0;
    if (parent ) {
        Q_ASSERT(!qparent);
        xtw = XtCreateWidget(name, widget_class, parent, args, num_args);
        if ( widget_class == qWidgetClass )
            ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
        xtparent = parent;
        if (managed)
            XtManageChild(xtw);
    } else {
        Q_ASSERT(!managed);

        String n, c;
        XtGetApplicationNameAndClass(qt_xdisplay(), &n, &c);
        xtw = XtAppCreateShell(n, c, widget_class, qt_xdisplay(),
                               args, num_args);
        if ( widget_class == qWidgetClass )
            ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
    }

    if ( qparent ) {
        XtResizeWidget( xtw, 100, 100, 0 );
        XtSetMappedWhenManaged(xtw, False);
        XtRealizeWidget(xtw);
        XSync(qt_xdisplay(), False);    // I want all windows to be created now
        XReparentWindow(qt_xdisplay(), XtWindow(xtw), qparent->winId(), x(), y());
        XtSetMappedWhenManaged(xtw, True);
        need_reroot=TRUE;
    }

    Arg reqargs[20];
    Cardinal nargs=0;
    XtSetArg(reqargs[nargs], XtNx, x());        nargs++;
    XtSetArg(reqargs[nargs], XtNy, y());        nargs++;
    XtSetArg(reqargs[nargs], XtNwidth, width());        nargs++;
    XtSetArg(reqargs[nargs], XtNheight, height());      nargs++;
    //XtSetArg(reqargs[nargs], "mappedWhenManaged", False);     nargs++;
    XtSetValues(xtw, reqargs, nargs);

    //#### destroy();   MLK

    if (!parent || XtIsRealized(parent))
        XtRealizeWidget(xtw);
}
示例#8
0
Window::Window(std::string name) : Container(name)
{
  Arg args[1];

  XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
  widget = XtAppCreateShell(Application::getName().c_str(), Application::getName().c_str(), applicationShellWidgetClass, Application::getDisplay(), args, 1);

  deleteWindowAtom = XmInternAtom(XtDisplay(widget), (char*)"WM_DELETE_WINDOW", False);
  XmAddWMProtocolCallback(widget, deleteWindowAtom, closeCallback, (void*)this);
  XtAddEventHandler(widget, StructureNotifyMask, False, eventCallback, (void*)this);
  XtAddEventHandler(widget, FocusChangeMask, False, eventCallback, (void*)this);

  contentPanel.reset(new Panel(name, this));
}
示例#9
0
文件: Display.c 项目: att/uwin
/*
 * This is the real place, where we try to find the XmDisplay widget of
 * a display. If we can't get our hands on the widget, we create one.
 *
 * NOTICE:
 * We now support for user-defined XmDisplay subclasses. Such user-defined
 * replacements can be activated by calling _XmSetXmDisplayClass with a
 * pointer to an appropiate class record.
 */
static Widget 
GetXmDisplay(Display *Dsp)
{
    Widget DisplayWidget = NULL;
    Arg Args[5];
    Cardinal ArgCount;
    String AppName, AppClass;

    /*
     * If we haven't yet a XmDisplay widget for that particular display,
     * we're creating it on the fly.
     */
    if ((PerDisplayWidgetContext == PDWC_None) ||
	(XFindContext(Dsp, PDWC_RID_DisplayWidget, PerDisplayWidgetContext,
		      (XPointer *)&DisplayWidget) != XCSUCCESS))
    {
	/*
	 * Because we need to realize that display widget in the next step,
	 * we have to set the widget's initial size -- otherwise we will
	 * crash with that nasty error message saying, that the shell has
	 * zero with/height...
	 */
	ArgCount = 0;

	XtSetArg(Args[ArgCount], XmNwidth, 1); ArgCount++;
	XtSetArg(Args[ArgCount], XmNheight, 1); ArgCount++;
	XtSetArg(Args[ArgCount], XmNmappedWhenManaged, False); ArgCount++;

	XtGetApplicationNameAndClass(Dsp, &AppName, &AppClass);

	DisplayWidget = XtAppCreateShell(AppName, AppClass, __XmDisplayClass,
					 Dsp, Args, ArgCount);
	/*
	 * The XmDisplay widget is now already registered as the display
	 * object (this is done in DisplayInitialize()).
	 */
    }

    /*
     * Make sure we have a window.
     */
    if (!XtIsRealized(DisplayWidget))
    {
	XtRealizeWidget(DisplayWidget);
    }

    return DisplayWidget;
}
示例#10
0
WXWidget wxCreateTopLevelWidget( WXDisplay* display )
{
    Widget tlw = XtAppCreateShell( (String)NULL,
                                   wxTheApp->GetClassName().c_str(),
                                   applicationShellWidgetClass,
                                   (Display*)display,
                                   NULL, 0 );
    XtVaSetValues( tlw,
                   XmNoverrideRedirect, True,
                   NULL );

    XtAddCallback( tlw, XmNdestroyCallback,
                   (XtCallbackProc)wxTLWidgetDestroyCallback,
                   (XtPointer)NULL );

    return (WXWidget)tlw;
}
示例#11
0
文件: test2.c 项目: melanj/lesstif
static void
create_shell(Display *display,
             char *app_name,
             int app_argc,
             char **app_argv)
{
	Arg al[12];                 /* Arg List */
	int ac;       		    /* Arg Count */
	/* XmFontList f1; */

	ac = 0;
	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	shell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac );

	initialise_objects ( shell );
}
示例#12
0
文件: test2.c 项目: melanj/lesstif
int main(int argc, char **argv)
{
    XtAppContext    AppCtx;
    Widget          TopLevel, TopLevel2;
    XmBaseClassExt *bce;

    TopLevel = XtAppInitialize(&AppCtx, "Exttest", NULL, 0,
                               &argc, argv, NULL, NULL, 0);
    CreateMainW(TopLevel, "main_first");
    
    bce = _XmGetBaseClassExtPtr(XtClass(TopLevel), XmQmotif);
    printf("bce: %08X (sec obj create = %08X)\n\n",
           (int) (*bce),
           (int) ((*bce)->secondaryObjectCreate)
           );

    TopLevel2 = XtAppCreateShell("exttest2", "Exttest", 
				 applicationShellWidgetClass, 
				 XtDisplay(TopLevel),
				 NULL, 0);
    XtVaSetValues(TopLevel, XmNx, 500, NULL);
    CreateMainW(TopLevel2, "main_second");

    XtRealizeWidget(TopLevel); XtRealizeWidget(TopLevel2);
    DumpWidgetTree(TopLevel);
    DumpDisplayTree(TopLevel);
    DumpGrabList(TopLevel);
    
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   56,   72,  148,   48, 0,0,0, /* main_first */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  148,   31, 0,0,0, /* menubar */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* File */
   CWWidth | CWHeight | CWX | CWY,    0,   31,  148,   17, 0,0,0, /* ExtTest Test Application */ 
    };
    PrintDetails(    TopLevel ,Expected);
};
   LessTifTestMainLoop(    TopLevel );
   
   exit(0);
} /* main */
示例#13
0
文件: file.c 项目: idunham/dtextra
/*
 * file->open->ok
 */
static void
file_open_ok(Widget w, XtPointer closure, XtPointer call)
{
	XmFSS	*cbs = (XmFSS *)call;
	MGV	*m   = (MGV *)closure;
	char	*file;
	Widget	top;
	int	status;
	USEUP(w);
	assert(MgvOK(m));

	if(!XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &file))
		return;
	if(XmToggleButtonGetState(wl_find1(w, "*openNew"))) {
		top = XtAppCreateShell(NULL, "MGv", wlAppShellWidgetClass,
							XtDisplay(w), NULL, 0);
		if(top == NULL) {
			XtFree((XtPointer)file);
			return;
		}
		if((m = mgv_create(top, file)) == NULL) {
			XtFree((XtPointer)file);
			XtDestroyWidget(top);
			return;
		}
	}
	else if((status = mgv_open(m, file)) != 0) {
		wl_error(w, "%s: %s", file, strerror(status));
		XtFree((XtPointer)file);
		return;
	}
	XtFree((XtPointer)file);
	if(!XmToggleButtonGetState(wl_find1(w, "*openBrowse")))
		XtUnmanageChild(w);
	if(m->docinfo != NULL)
		XtUnmanageChild(m->docinfo);
	mgv_pgstack_goto(m->pgstack, 0);
}
示例#14
0
/**************************************************************
 * DaCreateGui:
 **************************************************************/
Widget DaCreateGui(char    * name,
		   char    * aclass,
		   int       argc,
		   char   ** argv,
		   Display * display)
{
  Arg args[15];
  Widget widget_array[10];
  int n;

  /***************** object of type : ApplicationShell *****************/
  n = 0;
  /* Setup argc & argv attribute */
  XtSetArg(args[n], XtNargc, argc); n++;
  XtSetArg(args[n], XtNargv, argv); n++;

  widget_array[WI_DAINPUT] = 
    XtAppCreateShell(name, aclass, applicationShellWidgetClass,
		     display, args, n);

  /***************** mainWindow : XmMainWindow *****************/
  widget_array[WI_MAINWINDOW] =
    XmCreateMainWindow(widget_array[WI_DAINPUT], "mainWindow", NULL, 0);

  /***************** menuBar : XmMenuBar *****************/
  widget_array[WI_MENUBAR] =
    XmCreateMenuBar(widget_array[WI_MAINWINDOW], "menuBar", NULL, 0);

  /***************** File : XmCascadeButton *****************/
  widget_array[WI_FILE] =
    XmCreateCascadeButton(widget_array[WI_MENUBAR], "File", NULL, 0);

  /***************** fileMenu : XmPulldownMenu *****************/
  widget_array[WI_FILEMENU] =
    XmCreatePulldownMenu(widget_array[WI_MENUBAR], "fileMenu", NULL, 0);
  {
    Arg args[1];
    XtSetArg(args[0], XmNsubMenuId, widget_array[WI_FILEMENU]);
    XtSetValues(widget_array[WI_FILE], args, 1);
  }

  /***************** Exit : XmPushButton *****************/
  widget_array[WI_EXIT] =
    XmCreatePushButton(widget_array[WI_FILEMENU], "Exit", NULL, 0);

  XtAddCallback(widget_array[WI_EXIT], 
		XmNactivateCallback, DaExit, NULL);

  /***************** Help : XmCascadeButton *****************/
  widget_array[WI_HELP] =
    XmCreateCascadeButton(widget_array[WI_MENUBAR], "Help", NULL, 0);

  /***************** helpMenu : XmPulldownMenu *****************/
  widget_array[WI_HELPMENU] =
    XmCreatePulldownMenu(widget_array[WI_MENUBAR], "helpMenu", NULL, 0);
  {
    Arg args[1];
    XtSetArg(args[0], XmNsubMenuId, widget_array[WI_HELPMENU]);
    XtSetValues(widget_array[WI_HELP], args, 1);
  }

  /***************** Overview : XmPushButton *****************/
  widget_array[WI_OVERVIEW] =
    XmCreatePushButton(widget_array[WI_HELPMENU], "Overview", NULL, 0);

  XtAddCallback(widget_array[WI_OVERVIEW], 
		XmNactivateCallback, DaOverView, NULL);

  /***************** workArea : XmDrawingArea *****************/
  n = 0;
  XtSetArg(args[n], XmNwidth, 300); n++;
  XtSetArg(args[n], XmNheight, 35); n++;
  widget_array[WI_WORKAREA] =
    XmCreateDrawingArea(widget_array[WI_MAINWINDOW], "workArea", args, n);

  /* 
   * Register drawing area for input method support and set input 
   * context values.
   */
  XmImRegister(widget_array[WI_WORKAREA], 0);
  {
    Pixel bg, fg;
    Pixmap bg_pixmap;
    n = 0;
    XtSetArg(args[n], XmNbackground, &bg); n++;
    XtSetArg(args[n], XmNforeground, &fg); n++;
    XtSetArg(args[n], XmNbackgroundPixmap, &bg_pixmap);n++;
    XtGetValues(widget_array[WI_WORKAREA], args, n);
    n = 0;
    XtSetArg(args[n], XmNbackground, bg); n++;
    XtSetArg(args[n], XmNforeground, fg); n++;
    XtSetArg(args[n], XmNbackgroundPixmap, bg_pixmap);n++;
    XmImSetValues(widget_array[WI_WORKAREA], args, n);
  }

  /* 
   * Add event handler for focus events. This is needed for the
   * input method to correctly display the input area.
   */
  XtAddEventHandler(widget_array[WI_WORKAREA], 
		    EnterWindowMask|LeaveWindowMask|FocusChangeMask, 
		    False, DaFocusHandler, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNexposeCallback, DaRedrawText, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNinputCallback, DaInputText, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNresizeCallback, DaResizedText, NULL);


  /***************** menuBar : XmMenuBar *****************/
  n = 0;
  XtSetArg(args[n], XmNmenuHelpWidget, widget_array[WI_HELP]); n++;
  XtSetValues(widget_array[WI_MENUBAR], args, n);


  XtManageChild(widget_array[WI_EXIT]);
  XtManageChild(widget_array[WI_FILE]);
  XtManageChild(widget_array[WI_OVERVIEW]);
  XtManageChild(widget_array[WI_HELP]);
  XtManageChild(widget_array[WI_MENUBAR]);
  XtManageChild(widget_array[WI_WORKAREA]);
  XtManageChild(widget_array[WI_MAINWINDOW]);

  /*
   *   Return the first created widget.
   */
  return widget_array[WI_DAINPUT];
}
示例#15
0
文件: Main.c 项目: juddy/edcde
int
main( 
     int argc,
     char **argv ) 
{
    Display *display;
    Arg args[20];
    int n=0;
    char *actionName;
    int numArgs = 0;
    DtActionArg *ap = NULL;
  
    XtSetLanguageProc(NULL, NULL, NULL);
    _DtEnvControl(DT_ENV_SET);
    (void) signal(SIGCHLD, (void (*)())SIG_IGN);

    /*  Initialize the toolkit and open the display  */
    XtToolkitInitialize() ;
    appContext = XtCreateApplicationContext() ;
    if ( !(display = XtOpenDisplay( appContext, NULL, argv[0], "Dtaction", 
                             option_list, 
			     sizeof(option_list)/sizeof(XrmOptionDescRec),
			     &argc, argv)) )
    {
	setlocale(LC_ALL, "");
        fprintf(stderr, "%s", GETMESSAGE(1,11,"Can't open display.\n"));
	exit(-1);
    }
  
    XtSetArg(args[n], XmNallowShellResize, True); n++;
    XtSetArg(args[n], XmNmappedWhenManaged, False); n++;
    XtSetArg(args[n], XmNheight, 1); n++;
    XtSetArg(args[n], XmNwidth, 1); n++;
    toplevel = XtAppCreateShell( argv[0], "Dtaction", 
            topLevelShellWidgetClass, display, args, n) ;

    XtRealizeWidget(toplevel);

    display = XtDisplay (toplevel);
    XtGetApplicationResources(toplevel, &appArgs, 
	resources, XtNumber(resources), NULL, 0);

    password = XtMalloc(1);
    password[0] = '\0';
    stars = XtMalloc(1);
    stars[0] = '\0';

   /*  Get Dt initialized  */
   if (DtInitialize (display, toplevel, argv[0], "Dtaction") == False)
   {
      /* Fatal Error: could not connect to the messaging system. */
      /* DtInitialize() has already logged an appropriate error msg */
      exit(-1);
   }

   /*
    * If the request specified that it wanted to run as a different
    * user, then take care of prompting for a password, and doing any
    * necessary verification and logging.
    */
   CheckUserRequest();
   
   /* Load the filetype/action dbs; DtInvokeAction() requires this */
   DtDbLoad();

   /*
    * Get the requested action name
    */
    if ( (actionName = argv[1]) == NULL)
    {
	fprintf(stderr, "%s", GETMESSAGE(1,10,"No action name specified.\n"));
	exit(-1);
    }

    if ( argc > 2 ) 
    {
	/*
	 * create an action arg array for the file objects for
	 * this action.  This number of objects should be one
	 * less than the argument count. The returned vector will
	 * be terminated by a null pointer.
	 */
	numArgs= argc - 2;
	ap = (DtActionArg *) XtCalloc(numArgs,sizeof(DtActionArg)); 
    }

	/*
	 * This client is restricted to FILE arguments.
	 * for the time being.
	 */
    for ( n = 0; n < numArgs; n++) {
        ap[n].argClass    = DtACTION_FILE;
	ap[n].u.file.name = argv[n+2];
    }

    actionId = DtActionInvoke(toplevel, actionName, ap, numArgs,
        appArgs.termOpts,
        appArgs.execHost,
        appArgs.contextDir,
        True,			/* use indicator */
        (DtActionCallbackProc) actionStatusCallback,
        NULL);

    /*
     * Set up a timer if we didn't get a valid procId -- since there will
     * be no invocation update in that case.
     * We must invoke XtMainLoop() at least once, to force any prompt or
     * error dialogs to get posted.
     */
    if ( !actionId)
	    XtAppAddTimeOut(appContext,
		10, (XtTimerCallbackProc)CheckForDone,
			   NULL);

    XtAppMainLoop(appContext);

    return EXIT_SUCCESS;
}
示例#16
0
void
main(unsigned int argc, char **argv)
{
    Cardinal n;
    Arg      args[MAX_ARGS];
    Boolean async_in;  
    Boolean wfw_in;    
    int     wTo_in;
  

    CommonTestInit(argc, argv);
      
    /*
     * test case for PIR 3058 
     * Create a Shell with TWO children - only one is managed.  The
     * SubstructureNotify eventhandler on the shell confuses it when
     * the UNmanaged child is getting resized.  See report for details.
     */
    XtAddEventHandler(Shell1, SubstructureNotifyMask, True, Junk, NULL);

    BBoard1 = XmCreateBulletinBoard(Shell1, "BBoard1", NULL, 0);

    PushButton1 = XmCreatePushButton(Shell1, "PushButton1", NULL, 0);
    XtManageChild(PushButton1);
    
    XtAddCallback(PushButton1, XmNactivateCallback, activatePB, NULL);
    /* end of test case for PIR 3058 */

    XtRealizeWidget(Shell1);


    CommonPause();

    /*
     * This case shows that it works as expected when there isn't
     * an event handler registered for SubstructureNotify (PIR 3058)
     */
    XtRemoveEventHandler(Shell1, SubstructureNotifyMask, True, Junk, NULL);
    XtDestroyWidget(PushButton1);
    XtDestroyWidget(BBoard1);

    BBoard1 = XmCreateBulletinBoard(Shell1, "BBoard1", NULL, 0);

    PushButton1 = XmCreatePushButton(Shell1, "PushButton1", NULL, 0);
    XtManageChild(PushButton1);
    
    XtAddCallback(PushButton1, XmNactivateCallback, activatePB, NULL);

    CommonPause();

/*
 * Text for CR 2940 - Check for changes in BulletinBoard noResize resource.
 */
    XtDestroyWidget(PushButton1);
    XtDestroyWidget(BBoard1);

    n = 0;
    toplevelShell = XtAppCreateShell("topLevelShell", "TopLevelShell",
                                     topLevelShellWidgetClass, display,
                                     args, n);

    BBoard1 = XmCreateBulletinBoard(toplevelShell, "BBoard1", NULL, 0);
    PushButton1 = XmCreatePushButton(BBoard1, "PushButton1", NULL, 0);
    XtManageChild(PushButton1);
    XtAddCallback(PushButton1, XmNactivateCallback, ChangeNoResize, NULL);

    XtManageChild(BBoard1);
    XtRealizeWidget(toplevelShell);

    CommonPause();

    XtDestroyWidget (toplevelShell);
    /* make output on term window look nicer */
    printf ("\n");
    printf ("\n");
    printf ("\n");

    CommonPause();

   /* begin test for CR 1684 */

    bool_str[0] = "False";
    bool_str[1] = "True";
    result_str[0] = "Failed";
    result_str[1] = "Passed";


    /* Test 1 - Initialization */
  async_in = True;
  wfw_in = False;
  wTo_in = 0;
  
  n=0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues (Shell1, args, n);
  
  n=0;
  BBoard1 = XmCreateBulletinBoard(Shell1, "BBoard1", args, n);

  n=0;
  PushButton1 = XmCreatePushButton(BBoard1, "PushButton1", args, n);

  printf("Test1: Initialize UseAsyncGeo to True\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 2 - Using SetValues, return UseAsyncGeo to False */
  async_in = False;
  wfw_in = True;
  wTo_in = 5000;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 2: Change UseAsyncGeo to False using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 3 - Using SetValues, return UseAsyncGeo to True */
  async_in = True;
  wfw_in = False;
  wTo_in = 0;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues(Shell1, args, n);
 
  printf("\nTest 3: Change UseAsyncGeo to True using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 4 - Using SetValues, change UseAsyncGeo to True and WaitForWm
            to False and WmTimeout to 1000 */
  async_in = False;
  wfw_in = False;
  wTo_in = 1000;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, False); n++;
  XtSetArg(args[n], XmNwaitForWm, False); n++;
  XtSetArg(args[n], XmNwmTimeout, 1000); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 4: Change UseAsyncGeo to False, WaitForWm to False and WmTimeout to 1000 using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

   CommonPause();

/* Test 5 - Using SetValues, change UseAsyncGeo to True, WaitForWm to Ture,
            and WmTimeout to 2000. */
  async_in = True;
  wfw_in = False;
  wTo_in = 0;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetArg(args[n], XmNwaitForWm, True); n++;
  XtSetArg(args[n], XmNwmTimeout, 2000); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 5: Change UseAsyncGeo to True, WaitForWm to True, and WmTimeout to 2000 using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 6 - Using SetValues, change UseAsyncGeo to False to check the
            results of Test 5 */
  async_in = False;
  wfw_in = True;
  wTo_in = 2000;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 6: Change UseAsyncGeo to False to verify values loaded in Test 5 using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 7 - Using SetValues, change UseAsyncGeo to True. Then change WaitForWm 
            to False and WmTimeout to 1000. */
  async_in = True;
  wfw_in = False;
  wTo_in = 0;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues(Shell1, args, n);

  n = 0;
  XtSetArg(args[n], XmNwaitForWm, False); n++;
  XtSetArg(args[n], XmNwmTimeout, 1000); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 7: Change UseAsyncGeo to True.  Then change WaitForWm to False, and WmTimeout to 1000 afterwards\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 8 - Using SetValues, change UseAsyncGeo to False to check the 
            previously loaded data */
  async_in = False;
  wfw_in = False;
  wTo_in = 1000;
  n = 0;
  XtSetArg(args[n], XmNuseAsyncGeometry, async_in); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 8: Change UseAsyncGeo to False to check the previously loaded data\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

/* Test 9 - Using SetValues, change WaitForWm to True, and WmTimeout to 2000. */
  async_in = False;
  wfw_in = True;
  wTo_in = 2000;
  n = 0;
  XtSetArg(args[n], XmNwaitForWm, True); n++;
  XtSetArg(args[n], XmNwmTimeout, 2000); n++;
  XtSetValues(Shell1, args, n);

  printf("\nTest 9: Change WaitForWm to True and WmTimeout to 2000 while UseAsyncGeo is False using SetValues\n");
  GetAndPrint(async_in, wfw_in, wTo_in);

  /* End test for CR 1684 */

  CommonPause();
  XtAppMainLoop(app_context);

}
示例#17
0
static int motDialogMapMethod(Ihandle* ih)
{
  Widget dialog_manager;
  InativeHandle* parent;
  int mwm_decor = 0;
  int num_args = 0;
  Arg args[20];

  if (iupAttribGetInt(ih, "DIALOGFRAME")) 
  {
    iupAttribSetStr(ih, "RESIZE", "NO");
    iupAttribSetStr(ih, "MAXBOX", "NO");
    iupAttribSetStr(ih, "MINBOX", "NO");
  }

  /****************************/
  /* Create the dialog shell  */
  /****************************/

  if (iupAttribGet(ih, "TITLE"))
      mwm_decor |= MWM_DECOR_TITLE;
  if (iupAttribGetInt(ih, "MENUBOX"))
      mwm_decor |= MWM_DECOR_MENU;
  if (iupAttribGetInt(ih, "MINBOX"))
      mwm_decor |= MWM_DECOR_MINIMIZE;
  if (iupAttribGetInt(ih, "MAXBOX"))
      mwm_decor |= MWM_DECOR_MAXIMIZE;
  if (iupAttribGetInt(ih, "RESIZE"))
      mwm_decor |= MWM_DECOR_RESIZEH;
  if (iupAttribGetInt(ih, "BORDER"))
      mwm_decor |= MWM_DECOR_BORDER;

  iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* so XtRealizeWidget will not show the dialog */
  iupmotSetArg(args, num_args, XmNdeleteResponse, XmDO_NOTHING);
  iupmotSetArg(args, num_args, XmNallowShellResize, True); /* Used so the BulletinBoard can control the shell size */
  iupmotSetArg(args, num_args, XmNtitle, "");
  iupmotSetArg(args, num_args, XmNvisual, iupmot_visual);
  
  if (iupmotColorMap()) 
    iupmotSetArg(args, num_args, XmNcolormap, iupmotColorMap());

  if (mwm_decor != 0x7E) 
    iupmotSetArg(args, num_args, XmNmwmDecorations, mwm_decor);

  if (iupAttribGetInt(ih, "SAVEUNDER"))
    iupmotSetArg(args, num_args, XmNsaveUnder, True);

  parent = iupDialogGetNativeParent(ih);
  if (parent)
    ih->handle = XtCreatePopupShell(NULL, topLevelShellWidgetClass, (Widget)parent, args, num_args);
  else
    ih->handle = XtAppCreateShell(NULL, "dialog", topLevelShellWidgetClass, iupmot_display, args, num_args);

  if (!ih->handle)
    return IUP_ERROR;

  XmAddWMProtocolCallback(ih->handle, iupmot_wm_deletewindow, motDialogCBclose, (XtPointer)ih);

  XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent,      (XtPointer)ih);
  XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
  XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
  XtAddEventHandler(ih->handle, StructureNotifyMask, False, (XtEventHandler)motDialogCBStructureNotifyEvent, (XtPointer)ih);

  XtAddCallback(ih->handle, XmNdestroyCallback, (XtCallbackProc)motDialogDestroyCallback, (XtPointer)ih);

  /*****************************/
  /* Create the dialog manager */
  /*****************************/

  dialog_manager = XtVaCreateManagedWidget(
              "dialog_manager",
              xmBulletinBoardWidgetClass,
              ih->handle,
              XmNmarginWidth, 0,
              XmNmarginHeight, 0,
              XmNwidth, 100,     /* set this to avoid size calculation problems */
              XmNheight, 100,
              XmNborderWidth, 0,
              XmNshadowThickness, 0,
              XmNnoResize, iupAttribGetInt(ih, "RESIZE")? False: True,
              XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */
              XmNuserData, ih, /* used only in motDialogConfigureNotify                   */
              XmNnavigationType, XmTAB_GROUP,
              NULL);

  XtOverrideTranslations(dialog_manager, XtParseTranslationTable("<Configure>: iupDialogConfigure()"));
  XtAddCallback(dialog_manager, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih);
  XtAddEventHandler(dialog_manager, KeyPressMask, False,(XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);

  /* force the BGCOLOR to match the DLGBGCOLOR */
  motDialogSetBgColorAttrib(ih, IupGetGlobal("DLGBGCOLOR"));

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  /* child dialogs must be always on top of the parent */
  if (parent)
    XSetTransientForHint(iupmot_display, XtWindow(ih->handle), XtWindow(parent));

  if (mwm_decor != 0x7E)  /* some decoration was changed */
    motDialogSetWindowManagerStyle(ih);

  /* Ignore VISIBLE before mapping */
  iupAttribSetStr(ih, "VISIBLE", NULL);

  if (IupGetGlobal("_IUP_SET_DLGFGCOLOR"))
  {
    iupmotSetGlobalColorAttrib(dialog_manager, XmNforeground, "DLGFGCOLOR");
    IupSetGlobal("_IUP_SET_DLGFGCOLOR", NULL);
  }

  return IUP_NOERROR;
}
示例#18
0
/*
** Create a new event display window
*/
SpaceWindow *CreatePanelSp(Display *display, int setsEventNum,
    int canOpenFiles, int canExit, char *windowTitle, char *eventSelectorText)
{
    Widget appShell, main, menuBar, form;
    SpaceWindow *window;
    static Atom wmpAtom, dwAtom = NULL;
    Arg al[20];
    int type, ac;
    XGCValues values;

    /* Allocate some memory for the new window data structure */
    window = (SpaceWindow *)XtMalloc(sizeof(SpaceWindow));
    
    /* Create an toplevel shell to hold the window */
    ac = 0;
    XtSetArg(al[ac], XmNtitle, windowTitle); ac++;
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    XtSetArg(al[ac], XmNiconName, windowTitle); ac++;
    /* Keep the phase name here, to same valid XDefaults.. */
    appShell = XtAppCreateShell ("phase", "Space",
		applicationShellWidgetClass, display, al, ac);
    	    
    /*
    ** create a main window holding a menu bar and a form with the rest of
    ** the window contents.
    */
    main = XmCreateMainWindow(appShell, "main", NULL, 0);
    XtManageChild(main);
    type = STDHEP_SPACE;
    menuBar = CreateMenuBar(main, (StdHepWindow *) window,
                                   canOpenFiles, canExit, type);
    XtManageChild(menuBar);
    form = createContents(main, window, setsEventNum, eventSelectorText);
    XtManageChild(form);

    /* add the window to the global window list */
    AddToWindowList((StdHepWindow *) window);
    
    /* realize all of the widgets in the new window */
    XtRealizeWidget(appShell);

    /* set up closeCB to be called when the user selects close from the
       window menu.  The close menu item usually activates f.kill which
       sends a WM_DELETE_WINDOW protocol request for the window. */
    if (dwAtom == NULL) {
    	wmpAtom = XmInternAtom(display, "WM_PROTOCOLS", TRUE);
    	dwAtom = XmInternAtom(display, "WM_DELETE_WINDOW", TRUE);
    }
    XmAddProtocolCallback(appShell, wmpAtom, dwAtom, closeCB, window);

    /* initialize window structure, including a read-only graphics contexts
       for drawing in scale area and highlighting in spin widget */
    window->shell = appShell;
    window->selectedTrack = NO_TRACK;
    window->trackWindowShell = NULL;
    window->btnRotationPanel = NULL;
    window->absRotationPanel = NULL;
    window->buttonRotateDegrees = INITIAL_ROT_INCR;
    window->event.nParticles = 0;
    window->event.particles = NULL;
    window->colorcode.nParticles = 0;
    window->colorcode.particles = NULL;
    window->nDetectorSegments = 0;
    window->detectorSegments = NULL;
    ac = 0;
    XtSetArg(al[ac], XmNbackground, &values.background); ac++;
    XtSetArg(al[ac], XmNforeground, &values.foreground); ac++;
    XtGetValues(window->scaleArea, al, ac);
    window->scaleGC =
    	XtGetGC(window->scaleArea, GCForeground|GCBackground, &values);
    window->highlightGC = SpinCopyGC(window->spin);
    XSetLineAttributes(display, window->highlightGC, 5, LineSolid,
    		       CapRound, JoinMiter);
    return window;
}
示例#19
0
文件: alarm.c 项目: juddy/edcde
/*
**  Functions to build and popup the postup reminder
*/
extern void
postup_show_proc(Calendar *c, CSA_reminder_reference *r) {
        int			start_hr, stop_hr;
	char			text[BUFSIZ];
	time_t			st, sp = 0;
	Lines			*lines, *l = NULL;
	Props			*p = (Props *)c->properties;
	Widget			pu_frame, pu_base_form, 
				pu_text_form, separator, 
				pu_form, button_form, pu_date,
				pu_range, pu_image, pu_close, line, last_line;
	Boolean			start_am, stop_am;
	XmString		xmstr;
	CSA_return_code		stat;
	DisplayType		dis_t = get_int_prop(p, CP_DEFAULTDISP);
	OrderingType		ord_t = get_int_prop(p, CP_DATEORDERING);
	SeparatorType		sep_t = get_int_prop(p, CP_DATESEPARATOR);
	Dtcm_appointment	*appt;
	char			*title;

	if (!c->postup)
		c->postup = XtAppCreateShell("calendar_postup", "Dtcm",
			xmDialogShellWidgetClass, c->xcontext->display,
			NULL, 0);

	/*
	**  Create the Motif objects
	*/
	title = XtNewString(catgets(c->DT_catd, 1, 839, "Calendar : Reminder"));
	pu_frame = XtVaCreatePopupShell("pu_frame",
		topLevelShellWidgetClass, c->postup,
		XmNtitle, title,
		XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE,
		XmNdeleteResponse,      XmDESTROY,
		NULL);
	XtFree(title);

	pu_base_form = XtVaCreateWidget("pu_base_form",
		xmFormWidgetClass, pu_frame,
		NULL);

	pu_text_form = XtVaCreateWidget("pu_test_form",
		xmFormWidgetClass, pu_base_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNtopOffset, 1,
		NULL);

	pu_image = XtVaCreateWidget("pu_image",
		xmLabelGadgetClass, pu_text_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 5,
		XmNlabelType, XmPIXMAP,
		XmNlabelPixmap, ((Props_pu *)c->properties_pu)->postup_pixmap,
		NULL);

	button_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_base_form,
		XmNbottomAttachment, XmATTACH_FORM,
		XmNbottomOffset, 2,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNleftAttachment, XmATTACH_FORM,
		XmNrightAttachment, XmATTACH_FORM,
		XmNfractionBase, 3,
		NULL);

	xmstr = XmStringCreateLocalized(catgets(c->DT_catd, 1, 680, "Close"));
	pu_close = XtVaCreateManagedWidget("close", 
		xmPushButtonWidgetClass, button_form, 
                XmNtopAttachment, 	XmATTACH_FORM,
		XmNbottomAttachment, 	XmATTACH_FORM,
		XmNleftAttachment, 	XmATTACH_POSITION,
		XmNrightAttachment, 	XmATTACH_POSITION,
		XmNleftPosition,	1,
		XmNrightPosition,	2,
		XmNbottomOffset, 	1,
                XmNlabelString, 	xmstr,
                NULL);
	XmStringFree(xmstr);

	separator = XtVaCreateWidget("separator",
                xmSeparatorGadgetClass,
                pu_base_form,
                XmNleftAttachment,      XmATTACH_FORM,
                XmNrightAttachment,     XmATTACH_FORM,
                XmNbottomAttachment,   	XmATTACH_WIDGET,
                XmNbottomWidget,        button_form,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_text_form,
		XmNtopOffset, 1,
                NULL);


	pu_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_text_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 1,
		XmNleftAttachment, XmATTACH_WIDGET,
		XmNleftWidget, pu_image,
		XmNverticalSpacing, 10,
		NULL);

	pu_date = XtVaCreateWidget("pu_date",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		NULL);

	pu_range = XtVaCreateWidget("pu_range",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_date,
		XmNtopOffset, 8,
		NULL);

	XtAddCallback(pu_close, XmNactivateCallback, close_cb, pu_frame);

	appt = allocate_appt_struct(appt_read,
				    c->general->version,
				    CSA_ENTRY_ATTR_START_DATE_I,
				    CSA_ENTRY_ATTR_END_DATE_I,
				    CSA_ENTRY_ATTR_SUMMARY_I,
				    CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
				    NULL);
	stat = query_appt_struct(c->cal_handle, r->entry, appt);
	backend_err_msg(c->frame, c->calname, stat,
			((Props_pu *)c->properties_pu)->xm_error_pixmap);
	if (stat != CSA_SUCCESS) {
		free_appt_struct(&appt);
		return;
	}

	_csa_iso8601_to_tick(appt->time->value->item.date_time_value, &st);
	if (appt->end_time)
		_csa_iso8601_to_tick(appt->end_time->value->\
			item.date_time_value, &sp);
	l = lines = text_to_lines(appt->what->value->item.string_value, 5);
	last_line = 0;
	while (l) {
		xmstr = XmStringCreateLocalized(l->s);
		line = XtVaCreateWidget("text_line",
			xmLabelGadgetClass, pu_text_form,
			XmNlabelString, xmstr,
			XmNleftAttachment, XmATTACH_WIDGET,
			XmNleftWidget, pu_form,
			XmNleftOffset, 15,
			NULL);
		XmStringFree(xmstr);

		if (last_line)
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_WIDGET,
				XmNtopWidget, last_line,
				XmNtopOffset, 8,
				NULL);
		else
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_FORM,
				XmNtopOffset, 8,
				NULL);

		last_line = line;
		l = l->next;
	}
	if (lines)
		destroy_lines(lines);

	/*
	**  Now fill in the correct information
	*/
	set_date_in_widget(st, pu_date, ord_t, sep_t);

        if (!showtime_set(appt) || magic_time(st)) 
                text[0] = '\0';
	else {
		start_hr = hour(st);
		if (sp) stop_hr = hour(sp);
		if (dis_t == HOUR12) {
			start_am = adjust_hour(&start_hr);
			if (sp) {
				/* NL_COMMENT

				   Message 1087 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  In the C locale it would
				   look something like this:

				   ``From 11:00am to 1:00pm''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm
					$4	-> stop hour
					$5	-> stop minute
					$6	-> am or pm

				*/
			        char *am = XtNewString(catgets(c->DT_catd, 
							       1, 4, "am"));
			        char *pm = XtNewString(catgets(c->DT_catd, 
							       1, 3, "pm"));
				stop_am = adjust_hour(&stop_hr);
				sprintf(text, catgets(c->DT_catd, 1, 1087,
				   "From %1$2d:%2$02d%3$s to %4$2d:%5$02d%6$s"),
					start_hr, minute(st),
					(start_am) ? am : pm,
					stop_hr, minute(sp),
					(stop_am) ? am : pm
					);
				XtFree(am);
				XtFree(pm);
			} else {
				/* NL_COMMENT

				   Message 1088 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  It is used when an appt
				   does not have and ``end'' time.  In the 
				   C locale it would look something like this:

				   ``11:00am''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm

				*/
			        char *meridian = 
				  XtNewString ((start_am) ? 
					       catgets(c->DT_catd, 1, 4, "am"):
					       catgets(c->DT_catd, 1, 3, "pm"));
				
				sprintf(text, catgets(c->DT_catd, 1, 1088,
				   			"%1$2d:%2$02d%3$s"), 
					start_hr, minute(st), meridian
					);
				XtFree(meridian);
			}
		} else {
			if (sp) {
				/* NL_COMMENT

				   Message 1089 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   a user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``From 0100 to 1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> stop hour
					$4	-> stop minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1089,
				   "From %1$02d%2$02d to %3$02d%4$02d"),
					start_hr, minute(st), stop_hr, 
					minute(sp));
			} else {
				/* NL_COMMENT

				   Message 1090 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   an appt does not have an end time and the
				   user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1090,
							"%1$02d%2$02d"), 
					start_hr, minute(st));
			}
		}
	}

	free_appt_struct(&appt);
	xmstr = XmStringCreateLocalized(text);
	XtVaSetValues(pu_range, XmNlabelString, xmstr,
		NULL);
	XmStringFree(xmstr);

	ManageChildren(pu_form);
	ManageChildren(pu_base_form);
	ManageChildren(pu_text_form);
	XtManageChild(pu_base_form);
	XtVaSetValues(button_form, XmNdefaultButton, pu_close, NULL);
        XtVaSetValues(button_form, XmNcancelButton, pu_close, NULL);
	XtPopup(pu_frame, XtGrabNone);
	DtWsmOccupyAllWorkspaces(c->xcontext->display, XtWindow(pu_frame));
}
示例#20
0
void 
  create_appShell (Display *display, char *app_name, int app_argc, char **app_argv)
{
	Widget children[12];      /* Children to manage */
	Arg al[64];           /* Arg List */
	register int ac = 0;      /* Arg Count */
	char from_s [256];    /* For font list conversion */
	XrmValue from_value, to_value; /* ditto */
	int fg, bg;           /* colour values for pixmaps */ 
	XmString *list_items; /* For list items */
	int list_item;        /* Index for list_items */
	XmString xmstrings[15];    /* temporary storage for XmStrings */
	Widget widget1 = (Widget)NULL;
	Widget widget2 = (Widget)NULL;
	Widget widget3 = (Widget)NULL;
	Widget widget7 = (Widget)NULL;
	Widget widget8 = (Widget)NULL;
	Widget widget9 = (Widget)NULL;
	Widget widget10 = (Widget)NULL;
	Widget widget11 = (Widget)NULL;
	Widget widget12 = (Widget)NULL;
	Widget generateButton = (Widget)NULL;
	Widget deleteButton = (Widget)NULL;
	Widget browseButton = (Widget)NULL;
	Widget widget13 = (Widget)NULL;
	Widget widget14 = (Widget)NULL;
	Widget widget15 = (Widget)NULL;
	Widget widget16 = (Widget)NULL;
	Widget widget17 = (Widget)NULL;
	Widget nameLabel = (Widget)NULL;
	Widget textLabel = (Widget)NULL;
	Widget severityLabel = (Widget)NULL;
	Widget widget25 = (Widget)NULL;
	Widget widget27 = (Widget)NULL;
	Widget widget28 = (Widget)NULL;
	Widget widget29 = (Widget)NULL;
	Widget widget30 = (Widget)NULL;
	Widget widget31 = (Widget)NULL;
	Widget widget32 = (Widget)NULL;
	Widget widget33 = (Widget)NULL;
	Widget moduleLabel = (Widget)NULL;
	Widget widget37 = (Widget)NULL;
	Widget *modbutton;	/* replaces 38-49 */
	Widget categoryLabel = (Widget)NULL;
	Widget descriptionLabel = (Widget)NULL;
	Widget toolMenu = (Widget)NULL;
	Widget toolCascade = (Widget)NULL;
	Widget lockMenu = (Widget)NULL;
	Widget lockCascade = (Widget)NULL;
	Widget unlockButton = (Widget)NULL;
	Widget lockButton = (Widget)NULL;
	int imod;
	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	appShell = XtAppCreateShell ( app_name, "EditMessage", applicationShellWidgetClass, display, al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
	widget1 = XmCreateMainWindow ( appShell, "mainWindow", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNhorizontalScrollBar, &widget2 ); ac++;
	XtSetArg(al[ac], XmNverticalScrollBar, &widget3 ); ac++;
	XtGetValues(widget1, al, ac );
	ac = 0;
	widget7 = XmCreateMenuBar ( widget1, "widget7", al, ac );
	widget9 = XmCreatePulldownMenu ( widget7, "fileMenu", al, ac );
	/*
	XtAddCallback(widget9, XmNunmapCallback, grab_input, NULL);
	*/
	widget10 = XmCreatePushButton ( widget9, "openButton", al, ac );
	widget11 = XmCreatePushButton ( widget9, "newButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	widget12 = XmCreatePushButton ( widget9, "saveButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	deleteButton = XmCreatePushButton ( widget9, "deleteButton", al, ac );
	ac = 0;
	widget13 = XmCreateSeparator ( widget9, "widget13", al, ac );
	widget14 = XmCreatePushButton ( widget9, "exitButton", al, ac );
	XtSetArg(al[ac], XmNsubMenuId, widget9); ac++;
	widget8 = XmCreateCascadeButton ( widget7, "fileCascade", al, ac );
	ac = 0;
	toolMenu =  XmCreatePulldownMenu ( widget7, "toolMenu", al, ac );
	/*
	XtAddCallback(toolMenu, XmNunmapCallback, grab_input, NULL);
	*/
	generateButton = XmCreatePushButton ( toolMenu, "generateButton", al, ac );
	browseButton = XmCreatePushButton ( toolMenu, "browseButton", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, toolMenu); ac++;
	toolCascade = XmCreateCascadeButton ( widget7, "toolCascade", al, ac );

	lockMenu = XmCreatePulldownMenu ( widget7, "lockMenu", al, ac );
	/*
	XtAddCallback(widget9, XmNunmapCallback, grab_input, NULL);
	*/
	lockButton = XmCreatePushButton ( lockMenu, "lockButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	unlockButton = XmCreatePushButton ( lockMenu, "unlockButton", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, lockMenu); ac++;
	lockCascade = XmCreateCascadeButton ( widget7, "lockCascade", al, ac );

	ac = 0;
	widget16 = XmCreatePulldownMenu ( widget7, "widget16", al, ac );
	/*
	XtAddCallback(widget16, XmNunmapCallback, grab_input, NULL);
	*/
	XtSetArg(al[ac], XmNsubMenuId, widget16); ac++;
	widget15 = XmCreateCascadeButton ( widget7, "helpCascade", al, ac );

	/* Hand-added */
	XtVaSetValues(widget7, XmNmenuHelpWidget, widget15, NULL);

	ac = 0; 
	widget17 = XmCreateForm ( widget1, "editMsgForm", al, ac );
	XtSetArg(al[ac], XmNwidth, 100); ac++;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	nameLabel = XmCreateLabel ( widget17, "nameLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	textLabel = XmCreateLabel ( widget17, "textLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 20); ac++;
	nameTextField = XmCreateTextField( widget17, "nameTextField", al, ac );
	XtAddCallback(nameTextField, XmNvalueChangedCallback, message_modified,
		      NULL);
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 50); ac++;
	msgTextField = XmCreateTextField ( widget17, "msgTextField", al, ac );
	XtAddCallback(msgTextField, XmNvalueChangedCallback, message_modified,
		      NULL);
	ac = 0;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	severityLabel = XmCreateLabel ( widget17, "severityLabel", al, ac );
	ac = 0;
	severityMenu = XmCreatePulldownMenu ( widget17, "severityPulldown", al, ac );
	/*
	XtAddCallback(severityMenu, XmNunmapCallback, grab_input, NULL);
	*/
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_DEBUG);
	widget27 = XmCreatePushButton ( severityMenu, "debugButton", al, 1);
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_INFORM);
	widget28 = XmCreatePushButton ( severityMenu, "informButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_WARN);
	widget29 = XmCreatePushButton ( severityMenu, "warnButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_ERROR);
	widget30 = XmCreatePushButton ( severityMenu, "errorButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_ALARM);
	widget31 = XmCreatePushButton ( severityMenu, "alarmButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_FATAL);
	widget32 = XmCreatePushButton ( severityMenu, "fatalButton", al, 1 );
	ac = 0;
	XtSetArg(al[ac], XmNuserData, (caddr_t)SEV_UNKNOWN); ac++;
	/* "Unknown" is only allowed if it is found in the DB */
	XtSetArg(al[ac], XmNsensitive, FALSE); ac++;
	widget33 = XmCreatePushButton (severityMenu, "unknownButton", al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, severityMenu); ac++;
	severityOptionMenu = XmCreateOptionMenu ( widget17, "severityOptionMenu", al, ac );
	ac = 0;
	widget25 = XmOptionButtonGadget ( severityOptionMenu );
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	moduleLabel = XmCreateLabel ( widget17, "moduleLabel", al, ac );
	ac = 0;
	moduleMenu = XmCreatePulldownMenu ( widget17, "moduleMenu", al, ac );
	/*
	XtAddCallback(moduleMenu, XmNunmapCallback, grab_input, NULL);
	*/
	
	/* Create the button for the chosen module as the default.
	   */
	if (strcmp(module_names[0], g_module)) {
	  for (imod=0; imod<nmodule_names; imod++) 
	    if (!strcmp(module_names[imod], g_module)) break;
	  strcpy(module_names[imod], module_names[0]);
	  strcpy(module_names[0], g_module);
	}
	modbutton = (Widget *)XtMalloc(nmodule_names * sizeof(Widget));
	for (imod = 0; imod < nmodule_names; imod++) {
	  XtSetArg(al[0], XmNuserData, module_names[imod]);
	  modbutton[imod] = XmCreatePushButton(moduleMenu, module_names[imod], 
					       al, 1 );
	}
	XtSetArg(al[ac], XmNsubMenuId, moduleMenu); ac++;
	moduleOptionMenu = XmCreateOptionMenu ( widget17, "moduleOptionMenu", al, ac );
	ac = 0;
	widget37 = XmOptionButtonGadget ( moduleOptionMenu );
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	categoryLabel = XmCreateLabel ( widget17, "categoryLabel", al, ac );
	ac = 0;
	categoryTextField = XmCreateTextField ( widget17, "categoryTextField", al, ac );
	XtAddCallback(categoryTextField, XmNvalueChangedCallback, 
		      message_modified, NULL);
	XtSetArg(al[ac], XmNwidth, 101); ac++;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	descriptionLabel = XmCreateLabel ( widget17, "descriptionLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 255); ac++;
	descriptionText = XmCreateText ( widget17, "descriptionText", al, ac );
	XtAddCallback(descriptionText, XmNvalueChangedCallback, 
		      message_modified, NULL);
	ac = 0;
	children[ac++] = widget10;
	children[ac++] = widget11;
	children[ac++] = widget12;
	children[ac++] = deleteButton;
	children[ac++] = widget13;
	children[ac++] = widget14;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = generateButton;
	children[ac++] = browseButton;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = unlockButton;
	children[ac++] = lockButton;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = widget8;
	children[ac++] = widget15;
	children[ac++] = toolCascade;
	children[ac++] = lockCascade;
	XtManageChildren(children, ac);

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, nameTextField); ac++;
        XtSetValues ( nameLabel,al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, msgTextField); ac++;
        XtSetValues ( textLabel,al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;

        XtSetValues ( nameTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, nameTextField); ac++;
        XtSetValues ( msgTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, severityOptionMenu); ac++;
        XtSetValues ( severityLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetValues ( severityOptionMenu,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, moduleOptionMenu); ac++;
        XtSetValues ( moduleLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetValues ( moduleOptionMenu,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, categoryTextField); ac++;
        XtSetValues ( categoryLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, moduleOptionMenu); ac++;
        XtSetValues ( categoryTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, descriptionText); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, descriptionText); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, descriptionText); ac++;
        XtSetValues ( descriptionLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, categoryTextField); ac++;
        XtSetValues ( descriptionText,al, ac );

	XtAddCallback(widget10, XmNactivateCallback, open_message, NULL);
	XtAddCallback(browseButton, XmNactivateCallback, browse_messages, 
		      g_module);
	XtAddCallback(widget11, XmNactivateCallback, new_message, NULL);
	XtAddCallback(widget12, XmNactivateCallback, save_message, NULL);
	XtAddCallback(deleteButton, XmNactivateCallback, delete_message, NULL);
	XtAddCallback(generateButton, XmNactivateCallback, generate_header, NULL);
	XtAddCallback(lockButton, XmNactivateCallback, set_lock, widget9);
	XtAddCallback(unlockButton, XmNactivateCallback, unset_lock, widget9);
	XtAddCallback(widget14, XmNactivateCallback, exit_app, NULL);
	XtAddCallback(widget27, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget28, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget29, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget30, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget31, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget32, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget33, XmNactivateCallback, set_severity, NULL);
	for (imod = 0; imod < nmodule_names; imod++)
	  XtAddCallback(modbutton[imod], XmNactivateCallback, set_module, 
			NULL);
	ac = 0;
	children[ac++] = widget27;
	children[ac++] = widget28;
	children[ac++] = widget29;
	children[ac++] = widget30;
	children[ac++] = widget31;
	children[ac++] = widget32;
	children[ac++] = widget33;
	XtManageChildren(children, ac);
	XtManageChildren(modbutton, nmodule_names);
	ac = 0;
	children[ac++] = nameLabel;
	children[ac++] = textLabel;
	children[ac++] = nameTextField;
	children[ac++] = msgTextField;
	children[ac++] = severityLabel;
	children[ac++] = severityOptionMenu;
	children[ac++] = moduleLabel;
	children[ac++] = moduleOptionMenu;
	children[ac++] = categoryLabel;
	children[ac++] = categoryTextField;
	children[ac++] = descriptionLabel;
	children[ac++] = descriptionText;
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( widget7 );
	XtManageChild ( widget17 );
	XmMainWindowSetAreas(widget1, widget7, (Widget) NULL, widget2, widget3, widget17 );
	XtManageChild ( widget1);
}
示例#21
0
文件: test8.c 项目: melanj/lesstif
static void
create_shell(Display *display,
             char *app_name,
             int app_argc,
             char **app_argv)
{
	Arg al[12];                    /* Arg List */
	int ac;           /* Arg Count */
	XmString *list_items;          /* For list items */
	int list_item;                 /* Index for list_items */
	/* XmFontList f1; */

	ac = 0;
	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	shell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac );

	initialise_objects ( shell );
	
	ac = 0;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	XtSetArg(al[ac], XmNlabelFontList, f1); ac++;
	XtSetArg(al[ac], XmNheight, 400); ac++;
	form = XmCreateForm ( shell, "form", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNfontList, f1); ac++;
	XtSetArg(al[ac], XmNselectionPolicy, XmSINGLE_SELECT); ac++;
	XtSetArg(al[ac], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); ac++;
	XtSetArg(al[ac], XmNitemCount, 5); ac++;
	list_items = (XmString *) XtMalloc ( sizeof (XmString) * 5 );
	list_items[0] = XmStringCreateLtoR("The", "large_italic");
	list_items[1] = XmStringCreateLtoR("Quick", "small_bold");
	/*list_items[2] = XmStringCreateLtoR("\033$BF|\033(B\033$BK\\\033(B", "japanese" );*/
	list_items[2] = XmStringCreateLtoR("F|  K\\", "japanese" );
	list_items[3] = XmStringCreateLtoR("Brown", "small_italic");
	list_items[4] = XmStringCreateLtoR("Fox", "large_bold");
	XtSetArg(al[ac], XmNitems, list_items); ac++;
	list1 = XmCreateScrolledList ( form, "list1", al, ac );
	list1_sw = XtParent ( list1 );

	for (list_item = 0; list_item < 5; list_item++ )
		XmStringFree (list_items [list_item]);
	XtFree ( (char *) list_items ); 
	da = XmCreateDrawingArea ( form, "da", al, 0 );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION); ac++;
	XtSetArg(al[ac], XmNbottomPosition, 65); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;

	XtSetValues ( list1_sw,al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_POSITION); ac++;
	XtSetArg(al[ac], XmNtopPosition, 65); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( da,al, ac );

	XtManageChild(list1);
	XtAddCallback (da, XmNexposeCallback, da_expose, list1);
	XtManageChild(da);
	XtManageChild ( form);
}
示例#22
0
Widget mXtAppCreateShell(String n, String m, int x, Display *d, Arg *args, int nargs)
{
  return XtAppCreateShell(n, m, applicationShellWidgetClass, d, args, nargs);
}
示例#23
0
文件: p_edition.c 项目: armnlib/xrec
/*<----------------------------------------------------------------------------------------->*/
void InitPanneauEdition()
{
   Arg	args[10];
   XmString label;
   XmStringTable labelTable;
   register int n;	
   char nomShell[128];
   int lng = 0;
   
   Xinit("xrec");
   lng = c_getulng();
   
   memset(&champOriginal, '\000', sizeof(_Champ));

   n = 0;
   strcpy(nomShell, XtName(SuperWidget.topLevel));
   strcat(nomShell, nomPanneauEdition[lng]);
   peTopLevel = XtAppCreateShell(nomShell, nomShell, 
				 applicationShellWidgetClass,
				 XtDisplay(SuperWidget.topLevel), args, n);

   peForme = (Widget) XmCreateForm(peTopLevel, "form", NULL, 0);
   XtManageChild(peForme);

   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
   peFermer = (Widget)XmCreatePushButton(peForme, labelFermer[lng], args, n);
   XtAddCallback(peFermer, XmNactivateCallback, (XtCallbackProc)  PeFermer, NULL);
   XtManageChild(peFermer);

   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
   XtSetArg(args[n], XmNrightWidget, peFermer); n++;
   peAfficher = (Widget)XmCreatePushButton(peForme, labelAfficher[lng], args, n);
   XtAddCallback(peAfficher, XmNactivateCallback, (XtCallbackProc)  PeAfficher, NULL);
   XtManageChild(peAfficher);

   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
   XtSetArg(args[n], XmNtopWidget, peFermer); n++;
   XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
   peFrame = (Widget) XmCreateFrame(peForme, "form", args, n);
   XtManageChild(peFrame);

   n = 0;
   XtSetArg (args[n], XmNorientation, XmVERTICAL);  n++;
   XtSetArg (args[n], XmNnumColumns, 1);  n++;
   peRC = (Widget) XmCreateRowColumn(peFrame, "RC", args, n);
   XtManageChild(peRC);
   
   n=0;
   XtSetArg (args[n], XmNorientation, XmVERTICAL);  n++;
   XtSetArg (args[n], XmNpacking, XmPACK_COLUMN);  n++;
   XtSetArg (args[n], XmNnumColumns, 2);  n++;
   peRCBoutons = (Widget) XmCreateRowColumn(peRC, "RCBoutons", args, n);
   XtManageChild(peRCBoutons);
   
   label = XmStringCreateLtoR(EditerValeurs[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg (args[n], XmNsensitive, False);  n++;
   peEditerValeurs = (Widget) XmCreatePushButton(peRCBoutons, EditerValeurs[lng], args, n);
   XtAddCallback(peEditerValeurs, XmNactivateCallback, (XtCallbackProc)  PeEditerValeurs, MODIFIER);
   XtManageChild(peEditerValeurs);
   XmStringFree(label);
   
   label = XmStringCreateLtoR(AnnulerEdition[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg (args[n], XmNsensitive, False);  n++;
   peAnnulerEdition = (Widget) XmCreatePushButton(peRCBoutons, AnnulerEdition[lng], args, n);
   XtAddCallback(peAnnulerEdition, XmNactivateCallback, (XtCallbackProc)  PeAnnulerEdition, NULL);
   XtManageChild(peAnnulerEdition);
   XmStringFree(label);
   
   label = XmStringCreateLtoR(Enregistrer[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg (args[n], XmNsensitive, False);  n++;
   peEnregistrer = (Widget) XmCreatePushButton(peRCBoutons, Enregistrer[lng], args, n);
   XtAddCallback(peEnregistrer, XmNactivateCallback, (XtCallbackProc)  PeEnregistrer, NULL);
   XtManageChild(peEnregistrer);
   XmStringFree(label);
   
   label = XmStringCreateLtoR(RemettreValeurs[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg(args[n], XmNsensitive, False); n++;
   peRemettreValeurs = (Widget) XmCreatePushButton(peRCBoutons, RemettreValeurs[lng], args, n);
   XtAddCallback(peRemettreValeurs, XmNactivateCallback, (XtCallbackProc)  PeEditerValeurs, (XtPointer) REMETTRE);
   XtManageChild(peRemettreValeurs);
   XmStringFree(label);
   
   label = XmStringCreateLtoR(RefaireEdition[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg (args[n], XmNsensitive, False);  n++;
   peRefaireEdition = (Widget) XmCreatePushButton(peRCBoutons, RefaireEdition[lng], args, n);
   XtAddCallback(peRefaireEdition, XmNactivateCallback, (XtCallbackProc)  PeRefaireEdition, NULL);
   XtManageChild(peRefaireEdition);
   XmStringFree(label);
   
   label = XmStringCreateLtoR(AnnulerToutesModifs[lng], XmSTRING_DEFAULT_CHARSET);
   n = 0;
   XtSetArg(args[n], XmNlabelString, label); n++;
   XtSetArg (args[n], XmNsensitive, False);  n++;
   peAnnulerToutesModifs = (Widget) XmCreatePushButton(peRCBoutons, AnnulerToutesModifs[lng], args, n);
   XtAddCallback(peAnnulerToutesModifs, XmNactivateCallback, (XtCallbackProc)  PeAnnulerToutesModifs, NULL);
   XtManageChild(peAnnulerToutesModifs);
   XmStringFree(label);
   
   n = 0;
   peSeparateurs[0] =  (Widget) XmCreateSeparator(peRC, "sep 1", args, n);
   XtManageChild(peSeparateurs[0]);
   
   labelTable = (XmString *)calloc(1, sizeof(XmString *));
   labelTable[0] = label;
   
   n=0;
   XtSetArg (args[n], XmNorientation, XmVERTICAL);  n++;
   XtSetArg (args[n], XmNnumColumns, 1);  n++;
   peRCValRemplacement = (Widget) XmCreateRowColumn(peRC, "Val", args, n);
   XtManageChild(peRCValRemplacement);
   
   label = XmStringCreateLtoR(NouvelleValeur[lng], XmSTRING_DEFAULT_CHARSET);
   n=0;
   peLabelValRemplacement = (Widget) XmCreateLabel(peRCValRemplacement, NouvelleValeur[lng], args, n);
   XtManageChild(peLabelValRemplacement);
   XmStringFree(label);
   
   n = 0;
   XtSetArg (args[n], XmNvalue, "0.0000");  n++;
   XtSetArg (args[n], XmNblinkRate, 0);  n++;
   peTextValRemplacement = (Widget) XmCreateTextField(peRCValRemplacement, "text", args, n);
   XtManageChild(peTextValRemplacement);
   
   n = 0;
   peSeparateurs[2] =  (Widget) XmCreateSeparator(peRC, "sep 2", args, n);
   XtManageChild(peSeparateurs[2]);
   
   n=0;
   XtSetArg (args[n], XmNorientation, XmVERTICAL);  n++;
   XtSetArg (args[n], XmNnumColumns, 1);  n++;
   peRCEtikRemplacement = (Widget) XmCreateRowColumn(peRC, "Etik", args, n);
   XtManageChild(peRCEtikRemplacement);
   
   label = XmStringCreateLtoR(NouvelleEtiquette[lng], XmSTRING_DEFAULT_CHARSET);
   n=0;
   peLabelEtikRemplacement = (Widget) XmCreateLabel(peRCEtikRemplacement, NouvelleEtiquette[lng], args, n);
   XtManageChild(peLabelEtikRemplacement);
   XmStringFree(label);
   
   n = 0;
   XtSetArg (args[n], XmNmaxLength, 8);  n++;
   XtSetArg (args[n], XmNvalue, EtiquetteDefaut[lng]);  n++;
   XtSetArg (args[n], XmNblinkRate, 0);  n++;
   peTextEtikRemplacement = (Widget) XmCreateTextField(peRCEtikRemplacement, "text", args, n);
   XtManageChild(peTextEtikRemplacement);

   peInfo = (Widget) CreateInfoDialog(peTopLevel);
   peWarning = (Widget) CreateWarningDialog(peTopLevel);
   peWarningWithCancel = (Widget) CreateWarningDialogWithCancelBox(peTopLevel);

   }
示例#24
0
static int motMessageDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  Widget msgbox, dialog;
  int style = XmDIALOG_FULL_APPLICATION_MODAL;
  int type = XmDIALOG_MESSAGE;
  int num_but = 2;
  char *value;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

  if (parent)
  {
    msgbox = XmCreateMessageDialog(parent, "messagedialog", NULL, 0);
    dialog = XtParent(msgbox);
  }
  else
  {
    dialog = XtAppCreateShell(NULL, "messagedialog", topLevelShellWidgetClass, iupmot_display, NULL, 0);
    msgbox = XmCreateMessageBox(dialog, "messagebox", NULL, 0);
    style = XmDIALOG_MODELESS;
    XtVaSetValues(dialog,
      XmNmwmInputMode, MWM_INPUT_FULL_APPLICATION_MODAL,
      XmNmappedWhenManaged, False,
      XmNsaveUnder, True,
      NULL);
  }
  if (!msgbox)
    return IUP_NOERROR;

  value = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(value, "ERROR"))
    type = XmDIALOG_ERROR;
  else if (iupStrEqualNoCase(value, "WARNING"))
    type = XmDIALOG_WARNING;
  else if (iupStrEqualNoCase(value, "INFORMATION"))
    type = XmDIALOG_INFORMATION;
  else if (iupStrEqualNoCase(value, "QUESTION"))
    type = XmDIALOG_QUESTION;


  value = iupAttribGet(ih, "TITLE");
  if (value)
    iupmotSetString(msgbox, XmNdialogTitle, value);
  else
  {
    if (parent)
    {
      XmString title;
      XtVaGetValues(parent, XmNdialogTitle, &title, NULL);
      XtVaSetValues(msgbox, XmNdialogTitle, title, NULL);
    }
  }

  value = iupAttribGet(ih, "VALUE");
  if (value)
    iupmotSetString(msgbox, XmNmessageString, value);

  XtVaSetValues(msgbox,
                XmNdialogType, type,
                XmNdialogStyle, style,
                XmNautoUnmanage, False,
                XmNnoResize, True,
                NULL);

  value = iupAttribGetStr(ih, "BUTTONS");
  if (iupStrEqualNoCase(value, "OK"))
  {
    XtUnmanageChild(XmMessageBoxGetChild(msgbox, XmDIALOG_CANCEL_BUTTON));
    num_but = 1;
  }
  else if (iupStrEqualNoCase(value, "YESNO"))
  {
    iupmotSetString(msgbox, XmNokLabelString, iupStrMessageGet("IUP_YES"));
    iupmotSetString(msgbox, XmNcancelLabelString, iupStrMessageGet("IUP_NO"));
  }

  if (!IupGetCallback(ih, "HELP_CB"))
    XtUnmanageChild(XmMessageBoxGetChild(msgbox, XmDIALOG_HELP_BUTTON));

  if (num_but == 2 && iupAttribGetInt(ih, "BUTTONDEFAULT") == 2)
    XtVaSetValues(msgbox, XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON, NULL);
  else
    XtVaSetValues(msgbox, XmNdefaultButtonType, XmDIALOG_OK_BUTTON, NULL);

  XtAddCallback(msgbox, XmNokCallback, (XtCallbackProc)motMessageDlgCallback, (XtPointer)ih);
  XtAddCallback(msgbox, XmNcancelCallback, (XtCallbackProc)motMessageDlgCallback, (XtPointer)ih);
  XtAddCallback(msgbox, XmNhelpCallback, (XtCallbackProc)motMessageDlgHelpCallback, (XtPointer)ih);

  XmAddWMProtocolCallback(dialog, iupmot_wm_deletewindow, motMessageDlgDeleteWindowCallback, (XtPointer)ih);
  XtManageChild(msgbox);

  XtRealizeWidget(dialog);
  ih->handle = dialog;
  iupDialogUpdatePosition(ih);
  ih->handle = NULL;  /* reset handle */

  if (style == XmDIALOG_MODELESS)
    XtPopup(dialog, XtGrabExclusive);

  /* while the user hasn't provided an answer, simulate main loop.
  ** The answer changes as soon as the user selects one of the
  ** buttons and the callback routine changes its value. */
  iupAttribSetStr(ih, "BUTTONRESPONSE", NULL);
  while (iupAttribGet(ih, "BUTTONRESPONSE") == NULL)
    XtAppProcessEvent(iupmot_appcontext, XtIMAll);

  if (!iupAttribGet(ih, "_IUP_WM_DELETE"))
  {
    XtUnmanageChild(msgbox);

    if (style == XmDIALOG_MODELESS)
    {
      XtPopdown(dialog);
      XtDestroyWidget(dialog);
    }
  }

  return IUP_NOERROR;
}
示例#25
0
void
main(unsigned int argc, char **argv)
{

	Arg     args[10];
	int     n;
	int		i;

	XmString    message;
	XmString    cancel_label, ok_label, help_label;
	char    message_begin[120];


	n = 0;

    CommonTestInit(argc, argv);

    n = 0;
	XtSetArg(args[n], XmNwidth, 10); n++;
	XtSetArg(args[n], XmNheight, 10); n++;
	XtSetValues(Shell1, args, n);

	XtRealizeWidget(Shell1);

    CommonPause();
    
	XSetErrorHandler(ErrorHandle);
	/*
 	 * Initialize the PIInfo data values
  	 */
	for (i = 0; i < NUM_TESTS; i++)
		PIInfo[i].actual_return = False;

/*
 * Create top level shell widget as parent for test_button widgets
 */
	n = 0;
	XtSetArg(args[n], XtNallowShellResize, TRUE); n++;

	test_top = XtAppCreateShell("test_top",				/* application name */
		 						"Test_top",				/* application class */
		 						topLevelShellWidgetClass,	/* widget class */
		 						display,				/* display */
		 						args, n);				/* arguments */

/*
 * Create button1 widget
 */
	display = XtDisplay(test_top);
	screen = DefaultScreenOfDisplay(display);
	test1_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow,
								btn1_bits, btn1_width,
								btn1_height,
								CommonGetColor("red"),
								CommonGetColor("yellow"),
								DefaultDepth(display, DefaultScreen(display)));
	test2_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow,
								btn2_bits, btn2_width,
								btn2_height,
								CommonGetColor("yellow"),
								CommonGetColor("red"),
								DefaultDepth(display, DefaultScreen(display)));
	n = 0;
	XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
	XtSetArg(args[n], XmNlabelPixmap, test1_btn1_icon); n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
	test1_btn1 = XmCreatePushButton(test_top, "test1_btn1", args, n);
	XtManageChild(test1_btn1);
	XtRealizeWidget(test_top);

/*
 * Create top level shell widget as parent for test_button2 widget
 */
	n = 0;
	XtSetArg(args[n], XtNallowShellResize, TRUE); n++;

	test_top2 = XtAppCreateShell("test_top2",			/* application name */
		 						"Test_top2",			/* application class */
		 						topLevelShellWidgetClass,	/* widget class */
		 						display,				/* display */
		 						args, n);				/* arguments */

/*
 * Create button2 widget
 */
	n = 0;
	XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
	XtSetArg(args[n], XmNlabelPixmap, test2_btn1_icon); n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
	test2_btn1 = XmCreatePushButton(test_top2, "test2_btn1", args, n);
	XtManageChild(test2_btn1);
	XtRealizeWidget(test_top2);

	test_wdw = XtWindow(test_top);
	top_wdw = XtWindow(Shell1);
	test_wdw2 = XtWindow(test_top2);

	XtAddEventHandler(Shell1, NoEventMask, True, CMEventHandler, NULL);
	XtAddEventHandler(test_top, NoEventMask, True, CMEventHandler, NULL);
	XtAddEventHandler(test_top2, NoEventMask, True, CMEventHandler, NULL);

	/*
	 * Move the test_top shell window and the Shell1 window
	 */
	XMoveWindow(display, test_wdw, 100, 100);
	XMoveWindow(display, test_wdw2, 100, 300);

	/*
 	 * set protocols - WM_DELETE_WINDOW
  	 */
	proto_atom = XmInternAtom(display, "WM_PROTOCOLS", False);
	delwin_atom = XmInternAtom(display, "WM_DELETE_WINDOW", False);
	XmAddWMProtocols(test_top, &delwin_atom, 1);

#ifdef	DONT
/*
 * set protocols - WM_SAVE_YOURSELF
 */
		savylf_atom = XmInternAtom(display, "WM_SAVE_YOURSELF", False);
		XmAddWMProtocols(test_top2, &savylf_atom, 1);

/*
 * set protocols - WM_TAKE_FOCUS
 */
		takfoc_atom = XmInternAtom(display, "WM_TAKE_FOCUS", False);
		/* change it on test_wdw2 */
		XChangeProperty(display, test_wdw2,
			proto_atom, 
			proto_atom, 32, PropModeReplace,
			(unsigned char *)&takfoc_atom, 1);
#endif	/* DONT */

    CommonPause();
	iteration++;

	/*
 	 * Check if window is not deleted after f.kill WM_DELETE_WINDOW
  	 */
	ret_stat = XGetWindowAttributes(display, test_wdw, &win_attrs);
	/*
	 * Actual return is if the window is still mapped and
	 * recognizable.
	 */
	PIInfo[PIInfo_DW2].actual_return = ret_stat;

	/*
  	 * set protocols - _MOTIF_WM_MESSAGES
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item, send_msg1);
	menu_atom = XmInternAtom(display, "_MOTIF_WM_MENU", False);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeReplace, (unsigned char *)menu_item, 
					strlen(menu_item) + 1);
    /* add a message acceptance to widget */
	motif_msg_atom = XmInternAtom(display, "_MOTIF_WM_MESSAGES", False);
	XmAddWMProtocols(test_top2, &motif_msg_atom, 1);

	msg_num = MSG_NUMBER;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsgCB, NULL);

	PIUnmapWindow(test_wdw2);
	wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

#ifdef	DONT
/*
 * Iconify test_wdw2, see if save_yourself works
 */
	/*
	 * Unmap the window to change state
	 */
	PIUnmapWindow(test_wdw2);
	/* 
	 * Map the window into iconic state
	 */
	wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = IconicState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
#endif /* DONT */

	CommonPause();
#ifdef SHOW_P899

	iteration++;

	/*
 	 * set protocols - _MOTIF_WM_MENU
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item2, send_msg2);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeAppend, (unsigned char *)menu_item2, 
					strlen(menu_item2) + 1);
	/*
 	 * Turn on acceptance of send_message2
  	 */
	msg_num = MSG_NUMBER2;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsg2CB, NULL);
	PIUnmapWindow(test_wdw2);
    wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

	CommonPause();

#endif /* P899 */
	iteration++;

	/*
 	 * set protocols - _MOTIF_WM_MENU
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item2, send_msg3);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeReplace, (unsigned char *)menu_item2, 
					strlen(menu_item2) + 1);
#ifndef P899
	/*
 	 * Turn on acceptance of send_message2
  	 */
	msg_num = MSG_NUMBER2;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsg2CB, NULL);
#endif /* P899 */
	PIUnmapWindow(test_wdw2);
    wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

	CommonPause();
	iteration++;

/*
 * Put up a message box with the results of the test.
 */
	display_summary(NUM_TESTS, TEST_DESCRIP_LENGTH, PIInfo);

	CommonPause();

/*
 *  Loop and process events.
 */

	XtAppMainLoop(app_context);

}
示例#26
0
void xtbin::xtbin_realize() {
  Arg args[2];
  int n;
  Widget top_widget;
  Widget embedded;
  XSetWindowAttributes attr;
  unsigned long mask;

  attr.bit_gravity = NorthWestGravity;
  attr.event_mask = 
    ButtonMotionMask |
    ButtonPressMask |
    ButtonReleaseMask |
    EnterWindowMask |
    ExposureMask |
    KeyPressMask |
    KeyReleaseMask |
    LeaveWindowMask |
    PointerMotionMask |
    StructureNotifyMask |
    VisibilityChangeMask |
    FocusChangeMask;

  attr.colormap         = xxlib_rgb_get_cmap(mXlibRgbHandle);
  attr.background_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFFC0C0C0);
  attr.border_pixel     = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFF646464);

#ifdef DEBUG  
  printf("attr.background_pixel = %lx, attr.border_pixel = %lx, parent_window = %x\n", 
         (long)attr.background_pixel,
         (long)attr.border_pixel, (int)parent_window);
#endif /* DEBUG */
  
  mask = CWBitGravity | CWEventMask | CWBorderPixel | CWBackPixel;

  if (attr.colormap)
    mask |= CWColormap;

  window = XCreateWindow(xtdisplay, parent_window,
                         x, y, width, height, 0, 
                         xxlib_rgb_get_depth(mXlibRgbHandle),
                         InputOutput, xxlib_rgb_get_visual(mXlibRgbHandle),
                         mask, &attr);
  XSetWindowBackgroundPixmap(xtdisplay, window, None);
  XSelectInput(xtdisplay, window, ExposureMask);

  XMapWindow(xtdisplay, window);
  XFlush(xtdisplay);

  top_widget = XtAppCreateShell("drawingArea", "Wrapper",
                                applicationShellWidgetClass, xtdisplay,
                                NULL, 0);

  xtwidget = top_widget;

  n = 0;
  XtSetArg(args[n], XtNheight, height); n++;
  XtSetArg(args[n], XtNwidth,  width);  n++;
  XtSetValues(top_widget, args, n);

  embedded = XtVaCreateWidget("form", compositeWidgetClass, top_widget, NULL);

  n = 0;
  XtSetArg(args[n], XtNheight, height); n++;
  XtSetArg(args[n], XtNwidth,  width);  n++;
  XtSetValues(embedded, args, n);

  oldwindow = top_widget->core.window;
  top_widget->core.window = window;

  XtRegisterDrawable(xtdisplay, window, top_widget);

  XtRealizeWidget(embedded);
  XtRealizeWidget(top_widget);
  XtManageChild(embedded);

  /* Now fill out the xtbin info */
  xtwindow = XtWindow(embedded);

  /* Suppress background refresh flashing */
  XSetWindowBackgroundPixmap(xtdisplay, XtWindow(top_widget), None);
  XSetWindowBackgroundPixmap(xtdisplay, XtWindow(embedded),   None);

  /* Listen to all Xt events */
  XSelectInput(xtdisplay, XtWindow(top_widget), 0x0fffff);
  XSelectInput(xtdisplay, XtWindow(embedded),   0x0fffff);

  sync();
}
PRBool PlugletViewMotif::SetWindow(nsPluginWindow* win) {
    
    PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
	              ("PlugletViewMotif.SetWindow this=%p\n",this));
    JNIEnv *env = PlugletEngine::GetJNIEnv();
    if(!clazz) {
        Initialize();
        if(!clazz) {
            return PR_FALSE;
        }
    }
    if (!win 
        || !win->window) {
        if (win && !win->window) {
	    PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
               ("PlugletViewMotif.SetWindow  win->window = NULL. We have a bug in plugin module. this=%p\n",this));
        }
        if (frame) {
            env->DeleteGlobalRef(frame);
            if (env->ExceptionOccurred()) {
                env->ExceptionDescribe();
            }
            frame = NULL;
            return PR_TRUE;
        }
        return PR_FALSE;
    }
    AwtLock(env);
    int containerWindowID = (int) win->window;
    printf("containerWindowID=%d WindowID=%d\n",containerWindowID, WindowID);
#if 0
    if (WindowID == containerWindowID) {
        printf("about to return false\n");
        return PR_FALSE; 
    }
#endif
    WindowID = containerWindowID;
    Display *awt_display = getAwtDisplay();
    XSync(awt_display, FALSE);
    Arg args[40];
    int argc = 0;
    XtSetArg(args[argc], XmNsaveUnder, False); argc++;
    XtSetArg(args[argc], XmNallowShellResize, False); argc++;
    XtSetArg(args[argc], XmNwidth, win->width); argc++;
    XtSetArg(args[argc], XmNheight, win->height); argc++;
    XtSetArg(args[argc], XmNx, 0); argc++;
    XtSetArg(args[argc], XmNy, 0); argc++;
    XtSetArg(args[argc], XmNmappedWhenManaged,False); argc++;
    XtSetArg(args[argc], XmNvisual, awt_visual); argc++;
    XtSetArg(args[argc], XmNdepth, awt_depth); argc++;
    XtSetArg(args[argc], XmNcolormap, awt_cmap); argc++;
    Widget w = XtAppCreateShell("AWTapp", "XApplication", 
                                vendorShellWidgetClass,
                                awt_display,
                                args, argc);
    XtRealizeWidget(w);
    XFlush(awt_display);
    XSync(awt_display, True);
    Window child, parent;
    parent = (Window) containerWindowID;
    child = XtWindow(w);
    XReparentWindow(awt_display, child, parent, 0, 0);
    XFlush(awt_display);
    XSync(awt_display, True);
    
    if (frame) {
        env->DeleteGlobalRef(frame);
        if (env->ExceptionOccurred()) {
            env->ExceptionDescribe();
            return PR_FALSE;
        }
        
    }
    frame = env->NewObject(clazz,initMID,(jlong)w);
    if(frame) {
        frame = env->NewGlobalRef(frame);
        if (env->ExceptionOccurred()) {
            env->ExceptionDescribe();
            return PR_FALSE;
        }
        
    }
    AwtUnLock(env);
    return PR_TRUE;
}
示例#28
0
文件: main.c 项目: epronk/xtickertape
/* Parse args and go */
int
main(int argc, char *argv[])
{
    XtAppContext context;

#ifndef HAVE_XTVAOPENAPPLICATION
    Display *display;
#endif
    XTickertapeRec rc;
    elvin_handle_t handle;
    elvin_error_t error;
    const char *user;
    const char *domain;
    const char *ticker_dir;
    const char *config_file;
    const char *groups_file;
    const char *usenet_file;
    const char *keys_file;
    const char *keys_dir;
    Widget top;
    const char *names[AN_MAX + 1];
    int i;

    /* Determine the name of the executable. */
    progname = xbasename(argv[0]);

#ifdef HAVE_XTVAOPENAPPLICATION
    /* Create the toplevel widget */
    top = XtVaOpenApplication(
        &context, "XTickertape",
        NULL, 0,
        &argc, argv, NULL,
        applicationShellWidgetClass,
        XtNborderWidth, 0,
        NULL);
#else
    /* Initialize the X Toolkit */
    XtToolkitInitialize();

    /* Create an application context */
    context = XtCreateApplicationContext();

    /* Open the display */
    display = XtOpenDisplay(context, NULL, NULL, "XTickertape",
                            NULL, 0, &argc, argv);
    if (display == NULL) {
        fprintf(stderr, "Error: Can't open display\n");
        exit(1);
    }

    /* Create the toplevel widget */
    top = XtAppCreateShell(NULL, "XTickertape", applicationShellWidgetClass,
                           display, NULL, 0);
#endif

    /* Load the application shell resources */
    XtGetApplicationResources(top, &rc, resources, XtNumber(resources),
                              NULL, 0);

    /* Make sure our app-defaults file has a version number */
    if (rc.version_tag == NULL) {
        app_defaults_version_error("app-defaults file not found or "
                                   "out of date");
        exit(1);
    }

    /* Make sure that version number is the one we want */
    if (strcmp(rc.version_tag, PACKAGE "-" VERSION) != 0) {
        app_defaults_version_error("app-defaults file has the wrong "
                                   "version number");
        exit(1);
    }

    /* Add a calback for when it gets destroyed */
    XtAppAddActions(context, actions, XtNumber(actions));

#if !defined(ELVIN_VERSION_AT_LEAST)
    /* Initialize the elvin client library */
    error = elvin_xt_init(context);
    if (error == NULL) {
        fprintf(stderr, "*** elvin_xt_init(): failed\n");
        exit(1);
    }

    /* Double-check that the initialization worked */
    if (elvin_error_is_error(error)) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }

#elif ELVIN_VERSION_AT_LEAST(4, 1, -1)
    /* Allocate an error context */
    error = elvin_error_alloc(NULL, NULL);
    if (error == NULL) {
        fprintf(stderr, "%s: error: elvin_error_alloc failed\n", progname);
        exit(1);
    }

    /* Initialize the elvin client library */
    client = elvin_xt_init_default(context, error);
    if (client == NULL) {
        eeprintf(error, "elvin_xt_init failed\n");
        exit(1);
    }

    /* Create a new elvin connection handle */
    handle = elvin_handle_alloc(client, error);
    if (handle == NULL) {
        eeprintf(error, "elvin_handle_alloc failed\n");
        exit(1);
    }
#else /* ELVIN_VERSION_AT_LEAST */
# error "Unsupported Elvin library version"
#endif /* ELVIN_VERSION_AT_LEAST */

    /* Scan what's left of the arguments */
    parse_args(argc, argv, handle, &user, &domain,
               &ticker_dir, &config_file,
               &groups_file, &usenet_file,
               &keys_file, &keys_dir,
               error);

    /* Intern a bunch of atoms.  We jump through a few hoops in order
     * in order to do this in a single RPC to the X server. */
#ifdef USE_ASSERT
    memset(names, 0, sizeof(names));
#endif /* USE_ASSERT */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[atom_list[i].index] == NULL);
        names[atom_list[i].index] = atom_list[i].name;
    }

    /* Make sure we've specified a name for each atom. */
    for (i = 0; i <= AN_MAX; i++) {
        ASSERT(names[i] != NULL);
    }

    /* Intern the atoms. */
    if (!XInternAtoms(XtDisplay(top), (char **)names, AN_MAX + 1,
                      False, atoms)) {
        fprintf(stderr, "%s: error: XInternAtoms failed\n", progname);
        exit(1);
    }

    /* Create an Icon for the root shell */
    XtVaSetValues(top, XtNiconWindow, create_icon(top), NULL);

    /* Create a tickertape */
    tickertape = tickertape_alloc(
        &rc, handle,
        user, domain,
        ticker_dir, config_file,
        groups_file, usenet_file,
        keys_file, keys_dir,
        top,
        error);

    /* Set up SIGHUP to reload the subscriptions */
    signal(SIGHUP, reload_subs);

#ifdef USE_VALGRIND
    /* Set up SIGUSR1 to invoke valgrind. */
    signal(SIGUSR1, count_leaks);
#endif /* USE_VALGRIND */

#ifdef HAVE_LIBXMU
    /* Enable editres support */
    XtAddEventHandler(top, (EventMask)0, True, _XEditResCheckMessages, NULL);
#endif /* HAVE_LIBXMU */

    /* Let 'er rip! */
    XtAppMainLoop(context);

    /* Keep the compiler happy */
    return 0;
}
示例#29
0
/* Create the Xt client widgets
*  */
static void
xt_client_create ( XtClient* xtclient , 
                   Window embedderid, 
                   int height, 
                   int width ) 
{
  int           n;
  Arg           args[6];
  Widget        child_widget;
  Widget        top_widget;

#ifdef DEBUG_XTBIN
  printf("xt_client_create() \n");
#endif
  top_widget = XtAppCreateShell("drawingArea", "Wrapper", 
                                applicationShellWidgetClass, 
                                xtclient->xtdisplay, 
                                NULL, 0);
  xtclient->top_widget = top_widget;

  /* set size of Xt window */
  n = 0;
  XtSetArg(args[n], XtNheight,   height);n++;
  XtSetArg(args[n], XtNwidth,    width);n++;
  XtSetValues(top_widget, args, n);

  child_widget = XtVaCreateWidget("form", 
                                  compositeWidgetClass, 
                                  top_widget, NULL);

  n = 0;
  XtSetArg(args[n], XtNheight,   height);n++;
  XtSetArg(args[n], XtNwidth,    width);n++;
  XtSetArg(args[n], XtNvisual,   xtclient->xtvisual ); n++;
  XtSetArg(args[n], XtNdepth,    xtclient->xtdepth ); n++;
  XtSetArg(args[n], XtNcolormap, xtclient->xtcolormap ); n++;
  XtSetArg(args[n], XtNborderWidth, 0); n++;
  XtSetValues(child_widget, args, n);

  XSync(xtclient->xtdisplay, FALSE);
  xtclient->oldwindow = top_widget->core.window;
  top_widget->core.window = embedderid;

  /* this little trick seems to finish initializing the widget */
#if XlibSpecificationRelease >= 6
  XtRegisterDrawable(xtclient->xtdisplay, 
                     embedderid,
                     top_widget);
#else
  _XtRegisterWindow( embedderid,
                     top_widget);
#endif
  XtRealizeWidget(child_widget);

  /* listen to all Xt events */
  XSelectInput(xtclient->xtdisplay, 
               XtWindow(top_widget), 
               0x0FFFFF);
  xt_client_set_info (child_widget, 0);

  XtManageChild(child_widget);
  xtclient->child_widget = child_widget;

  /* set the event handler */
  XtAddEventHandler(child_widget,
                    0x0FFFFF & ~ResizeRedirectMask,
                    TRUE, 
                    (XtEventHandler)xt_client_event_handler, xtclient);
  XtAddEventHandler(child_widget, 
                    SubstructureNotifyMask | ButtonReleaseMask, 
                    TRUE, 
                    (XtEventHandler)xt_client_focus_listener, 
                    xtclient);
  XSync(xtclient->xtdisplay, FALSE);
}
示例#30
0
static int motFileDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  Widget filebox, dialog;
  int dialogtype, style = XmDIALOG_FULL_APPLICATION_MODAL;
  IFnss file_cb = NULL;
  Widget preview_canvas = NULL;
  char* value;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

  value = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(value, "SAVE"))
    dialogtype = IUP_DIALOGSAVE;
  else if (iupStrEqualNoCase(value, "DIR"))
    dialogtype = IUP_DIALOGDIR;
  else
    dialogtype = IUP_DIALOGOPEN;
  iupAttribSetInt(ih, "_IUPDLG_DIALOGTYPE", dialogtype);

  if (parent)
  {
    filebox = XmCreateFileSelectionDialog(parent, "filedialog", NULL, 0);
    dialog = XtParent(filebox);
  }
  else
  {
    dialog = XtAppCreateShell(NULL, "filedialog", topLevelShellWidgetClass, iupmot_display, NULL, 0);
    filebox = XmCreateFileSelectionBox(dialog, "filebox", NULL, 0);
    style = XmDIALOG_MODELESS;
    XtVaSetValues(dialog,
      XmNmwmInputMode, MWM_INPUT_FULL_APPLICATION_MODAL,
      XmNmappedWhenManaged, False,
      XmNsaveUnder, True,
      NULL);
  }
  if (!filebox)
    return IUP_NOERROR;

  if (!iupAttribGetBoolean(ih, "SHOWHIDDEN"))
    XtVaSetValues(filebox, XmNfileFilterStyle, XmFILTER_HIDDEN_FILES, NULL);

  value = iupAttribGet(ih, "TITLE");
  if (!value)
  {
    if (dialogtype == IUP_DIALOGSAVE)
      value = "IUP_SAVEAS";
    else if (dialogtype == IUP_DIALOGOPEN)
      value = "IUP_OPEN";
    else
      value = "IUP_SELECTDIR";
    iupAttribSetStr(ih, "TITLE", iupStrMessageGet(value));
  }
  iupmotSetString(filebox, XmNdialogTitle, value);

  XtVaSetValues(filebox,
                XmNdialogStyle, style,
                XmNautoUnmanage, False,
                XmNresizePolicy, XmRESIZE_GROW,
                NULL);

  if (dialogtype == IUP_DIALOGDIR)
    XtVaSetValues(filebox, XmNfileTypeMask, XmFILE_DIRECTORY, NULL);

  /* just check for the path inside FILE */
  value = iupAttribGet(ih, "FILE");
  if (value && value[0] == '/')
  {
    char* dir = iupStrFileGetPath(value);
    iupAttribStoreStr(ih, "DIRECTORY", dir);
    free(dir);
  }

  /* set XmNdirectory before XmNpattern and before XmNdirSpec */

  value = iupAttribGet(ih, "DIRECTORY");
  if (value)
    iupmotSetString(filebox, XmNdirectory, value);

  value = iupAttribGet(ih, "FILTER");
  if (value)
  {
    char *filter = value;
    char *p = strchr(value, ';');
    if (p) 
    {
      /* Use only the first filter */
      int size = p-value;
      filter = (char*)malloc(size+1);
      memcpy(filter, value, size);
      filter[size] = 0;
    }

    iupmotSetString(filebox, XmNpattern, filter);

    if (filter != value) 
      free(filter);
  }

  value = iupAttribGet(ih, "FILE");
  if (value)
  {
    char* file = value;

    if (value[0] != '/')  /* if does not contains a full path, then add the directory */
    {
      char* cur_dir = NULL;
      char* dir = iupAttribGet(ih, "DIRECTORY");
      if (!dir)
      {
        cur_dir = iupdrvGetCurrentDirectory();
        dir = cur_dir;
      }

      file = iupStrFileMakeFileName(dir, value);

      if (cur_dir)
        free(cur_dir);
    }

  /* clear value before setting. Do not know why we have to do this, 
     but if not cleared it will fail to set the XmNdirSpec value. */
    iupmotSetString(filebox, XmNdirSpec, "");
    iupmotSetString(filebox, XmNdirSpec, file);

    if (file != value)
      free(file);
  }

  if (!IupGetCallback(ih, "HELP_CB"))
    XtUnmanageChild(XmFileSelectionBoxGetChild(filebox, XmDIALOG_HELP_BUTTON));

  XtAddCallback(filebox, XmNokCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNcancelCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNhelpCallback, (XtCallbackProc)motFileDlgHelpCallback, (XtPointer)ih);

  if (dialogtype == IUP_DIALOGDIR)
  {
    Widget new_folder = XtVaCreateManagedWidget("new_folder", xmPushButtonWidgetClass, filebox, 
                                                XmNlabelType, XmSTRING, 
                                                NULL);
    iupmotSetString(new_folder, XmNlabelString, iupStrMessageGet("IUP_CREATEFOLDER"));
    XtAddCallback(new_folder, XmNactivateCallback, (XtCallbackProc)motFileDlgNewFolderCallback, (XtPointer)filebox);
  }
  else
  {
    file_cb = (IFnss)IupGetCallback(ih, "FILE_CB");
    if (file_cb)
    {
      Widget list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
      list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_DIR_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);

      if (iupAttribGetBoolean(ih, "SHOWPREVIEW"))
      {
        Widget frame = XtVaCreateManagedWidget("preview_canvas", xmFrameWidgetClass, filebox, 
                                                        XmNshadowType, XmSHADOW_ETCHED_IN,
                                                        NULL);

        preview_canvas = XtVaCreateManagedWidget("preview_canvas", xmDrawingAreaWidgetClass, frame, 
                                                        XmNwidth, 180, 
                                                        XmNheight, 150,
                                                        XmNresizePolicy, XmRESIZE_GROW,
                                                        NULL);

        XtAddCallback(preview_canvas, XmNexposeCallback, (XtCallbackProc)motFileDlgPreviewCanvasExposeCallback, (XtPointer)ih);
        XtAddCallback(preview_canvas, XmNresizeCallback, (XtCallbackProc)motFileDlgPreviewCanvasResizeCallback,  (XtPointer)ih);

        iupAttribSetStr(ih, "_IUPDLG_FILEBOX", (char*)filebox);
      }
    }

    if (iupAttribGetBoolean(ih, "MULTIPLEFILES"))
    {
      Widget wList = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtVaSetValues(wList, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);

      if (file_cb)
        XtAddCallback(wList, XmNextendedSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
    }
  }

  XmAddWMProtocolCallback(dialog, iupmot_wm_deletewindow, motFileDlgCBclose, (XtPointer)ih);
  XtManageChild(filebox);

  XtRealizeWidget(dialog);
  ih->handle = dialog;
  iupDialogUpdatePosition(ih);
  ih->handle = NULL;  /* reset handle */

  if (file_cb)
  {
    if (preview_canvas)
      motFileDlgPreviewCanvasInit(ih, preview_canvas);

    file_cb(ih, NULL, "INIT");
  }

  if (ih->userwidth && ih->userheight)
  {
    XtVaSetValues(dialog,
      XmNwidth, (XtArgVal)(ih->userwidth),
      XmNheight, (XtArgVal)(ih->userheight),
      NULL);
  }

  if (style == XmDIALOG_MODELESS)
    XtPopup(dialog, XtGrabExclusive);

  /* while the user hasn't provided an answer, simulate main loop.
  ** The answer changes as soon as the user selects one of the
  ** buttons and the callback routine changes its value. */
  iupAttribSetStr(ih, "STATUS", NULL);
  while (iupAttribGet(ih, "STATUS") == NULL)
    XtAppProcessEvent(iupmot_appcontext, XtIMAll);

  if (file_cb)
  {
    if (preview_canvas)
      XFreeGC(iupmot_display, (GC)iupAttribGet(ih, "PREVIEWDC"));

    file_cb(ih, NULL, "FINISH");
  }

  if (!iupAttribGet(ih, "_IUP_WM_DELETE"))
  {
    XtUnmanageChild(filebox);

    if (style == XmDIALOG_MODELESS)
    {
      XtPopdown(dialog);
      XtDestroyWidget(dialog);
    }
  }

  return IUP_NOERROR;
}