예제 #1
0
void WarningMsg( Widget parent, char *msg, char *title)
{
    static Widget dialog = 0;
    XmString text, ok_str, cancel_str;

    if ( !dialog) {
        dialog  = XmCreateWarningDialog( parent, "Warning", NULL, 0);

        XtAddCallback( dialog, XmNokCallback, ok_pushed, NULL);
        XtAddCallback( dialog, XmNcancelCallback, cancel_pushed, NULL);
    }
    text = XmStringCreateLtoR( msg, XmFONTLIST_DEFAULT_TAG);
    ok_str = XmStringCreateLocalized( "Yes");
    cancel_str = XmStringCreateLocalized( "No");
    XtVaSetValues( dialog,
                   XmNmessageString, text,
                   XmNokLabelString, ok_str,
                   XmNcancelLabelString, cancel_str,
                   XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON,
                   NULL);
    XtVaSetValues( XtParent( dialog),
                   XmNtitle, title, NULL);
    XmStringFree( text);
    XmStringFree( ok_str);
    XmStringFree( cancel_str);

    XtManageChild( dialog);
    XtPopup( XtParent(dialog), XtGrabNone);

}
예제 #2
0
파일: p_avert.c 프로젝트: armnlib/xrec
Widget CreateWarningDialogWithCancelBox(Widget widgetParent)
{
   int i, lng;
   Widget warning, bouton;
   XmString label1, label2;
   Arg args[8];
   
   lng = c_getulng();

   i = 0;
   label1 = XmStringCreateLtoR(labelNon[lng], XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[i], XmNcancelLabelString, label1); i++;

   label2 = XmStringCreateLtoR(labelOui[lng], XmSTRING_DEFAULT_CHARSET);
   XtSetArg(args[i], XmNokLabelString, label2); i++;
   XtSetArg(args[i], XmNinitialResourcesPersistent, False); i++;

   warning = (Widget)XmCreateWarningDialog(widgetParent, "popup", args, i);
   CheckColormap(warning);

   XmStringFree(label1);
   XmStringFree(label2);

   bouton = (Widget)XmMessageBoxGetChild(warning, XmDIALOG_HELP_BUTTON);
   XtUnmanageChild(bouton);

   XtAddCallback(warning, XmNcancelCallback, (XtCallbackProc) AvrtOk, BTN_CANCEL);
   XtAddCallback(warning, XmNokCallback, (XtCallbackProc) AvrtOk, (XtPointer) BTN_OK);

   return warning;
   }
예제 #3
0
파일: error.c 프로젝트: douglandau/Color
void createMessage (Widget parent) {
    XmString okString;

    if (!dialog) {
      dialog = XmCreateWarningDialog (parent, "message", NULL, 0);
      okString = XmStringCreateLtoR ( "Ok", XmSTRING_DEFAULT_CHARSET);

      XtVaSetValues (dialog, XmNokLabelString, okString,
                             XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL,
                             XmNdefaultPosition, False,
                             NULL);
      XtVaSetValues (XtParent(dialog), XmNdeleteResponse, XmDO_NOTHING, NULL);
      XtVaSetValues (XtParent(dialog), XmNtitle, "Message", NULL);
      XtAddEventHandler( XtParent(dialog), VisibilityChangeMask, False,
						(XtEventHandler) keepOnTop,NULL);
      XtAddCallback (dialog, XmNmapCallback, (XtCallbackProc) centerMe, NULL);
      XtAddCallback (dialog, XmNokCallback, 
                     (XtCallbackProc) choiceCB, (XtPointer) ERROR_OK);
      XmStringFree (okString);
      XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON));
      XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
  }
}
예제 #4
0
파일: p_avert.c 프로젝트: armnlib/xrec
Widget CreateWarningDialog(Widget widgetParent)
{
   int i, lng;
   Widget warning, bouton;
   Arg args[8];

   lng = c_getulng();

   i = 0;
   warning = (Widget)XmCreateWarningDialog(widgetParent, "popup", args, i);
   XtSetArg(args[i], XmNinitialResourcesPersistent, False); i++;
   CheckColormap(warning);

   bouton = (Widget)XmMessageBoxGetChild(warning, XmDIALOG_CANCEL_BUTTON);
   XtUnmanageChild(bouton);

   bouton = (Widget)XmMessageBoxGetChild(warning, XmDIALOG_HELP_BUTTON);
   XtUnmanageChild(bouton);

   XtAddCallback(warning, XmNokCallback, (XtCallbackProc) AvrtOk, NULL);

   return warning;

   }
예제 #5
0
/*-------------------------
 *
 *  display_cancel_warning
 *
 *------------------------*/
void
display_cancel_warning(Widget parent)

{
   XmString  msg, dialogTitle, cancelMsg, resumeMsg;
   int       n;
   Arg       args[20];
   Widget    dialog;

   String   copyWarnMessage = "This will stop the copy process. Any files that have\n\
already been copied will remain in the destination folder.";
   String   moveWarnMessage = "This will stop the move process. Any files that have\n\
already been moved will remain in the destination folder.";



   if (G_move)
   {
      dialogTitle = XmStringCreateLocalized (GETMESSAGE(3, 12, "Folder Move - Warning"));
      msg         = XmStringCreateLocalized (GETMESSAGE(3, 10, moveWarnMessage));
      cancelMsg   = XmStringCreateLocalized (GETMESSAGE(3, 15, "Cancel Move"));
      resumeMsg   = XmStringCreateLocalized (GETMESSAGE(3, 16, "Continue Move"));
   }
   else
   {
      dialogTitle = XmStringCreateLocalized (GETMESSAGE(3, 11, "Folder Copy - Warning"));
      msg         = XmStringCreateLocalized (GETMESSAGE(3,  7, copyWarnMessage));
      cancelMsg   = XmStringCreateLocalized (GETMESSAGE(3, 13, "Cancel Copy"));
      resumeMsg   = XmStringCreateLocalized (GETMESSAGE(3, 14, "Continue Copy"));
   }


   n = 0;
   XtSetArg(args[n], XmNmessageString, msg); n++;
   XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
   XtSetArg(args[n], XmNdialogTitle, dialogTitle); n++;
   dialog = (Widget) XmCreateWarningDialog(parent, "warnDialog", args, n);

   XmStringFree(msg);
   XmStringFree(dialogTitle);

   n = 0;
   XtSetArg(args[n], XmNlabelString, cancelMsg); n++;
   XtSetValues((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON), args, n);
   XmStringFree(cancelMsg);

   n = 0;
   XtSetArg(args[n], XmNlabelString, resumeMsg); n++;
   XtSetValues((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON), args, n);
   XmStringFree(resumeMsg);

   XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON),
                 XmNactivateCallback,
   		 warning_yes_callback,
   		 dialog);
   XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON),
                 XmNactivateCallback,
   		 warning_no_callback,
   		 dialog);
   XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON),
                 XmNactivateCallback,
   		 help_callback,
   		 (XtPointer) STOPW_HELP_DIALOG);
   		
   XtManageChild(dialog);

}  /* end display_cancel_warning */
예제 #6
0
void pcpmessage (CHAR *pcpmsg)

/***********************************************************************
*
*_Title	pcpmessage - Used to report warnings to the user	
*
*_DESC	When this routine is called it will pop up a dialog which
*	contains the error message in the global variable pcpmsg
*

*_HIST	Jan 1 1996 Jeff Anderson, Original version
*       Nov 21 1996 Tracie Sucharski, Check for newline character.
*       Apr 30 2002 Janet Barrett, Renamed to pcpmessage and added
*                   modifications so that it will work with the
*                   pc2d program.
*_END
************************************************************************/

{
  int pos;
  int comma,colon,brace,slash,newline;
  char *errstring,newstring[512],save[4];
  Widget shell;
  XmString xstring;
  static Widget DB = NULL;

  shell = xinfo.topShell;

/****************************************************************************
* Create the dialog if it has not already been done
*****************************************************************************/

  if (DB == NULL) {
    DB = XmCreateWarningDialog (shell,"warningDB",NULL,0);

    xstring = XmStringCreateSimple ("Warning");
    XtVaSetValues (DB,XmNdialogStyle,XmDIALOG_FULL_APPLICATION_MODAL,
                      XmNdialogTitle,xstring,
                      XmNnoResize,True,
                      NULL); 
    XmStringFree (xstring);
  }

/****************************************************************************
* Load the message into the error dialog 
*****************************************************************************/

  strcpy (newstring,"");
  errstring = pcpmsg;

  while ((int) strlen(errstring) > 35) {
    pos = 35;
    comma = 0;
    colon = 0;
    brace = 0;
    slash = 0;
    newline = 0;

    while ((errstring[pos] != ' ') && (pos > 0)) {
      if ((errstring[pos] == ',') && (!comma)) comma = pos;
      if ((errstring[pos] == ':') && (!colon)) colon = pos;
      if ((errstring[pos] == ']') && (!brace)) brace = pos;
      if ((errstring[pos] == '/') && (!slash)) slash = pos;
      if ((errstring[pos] == '\n') && (!newline)) newline = pos;
      pos--;
    }

    if (comma > pos) pos = comma;
    if (colon > pos) pos = colon;
    if (brace > pos) pos = brace;
    if (slash > pos) pos = slash;
    if (newline) pos = newline;
    if (pos == 0) pos = 35;

    if (pos - comma < 5) pos = comma;
    while (errstring[pos+1] == ' ') pos++;

    save[0] = errstring[pos];
    save[1] = 0;
    errstring[pos] = 0;

    strcat (newstring,errstring);
    strcat (newstring,save);
    if (save[0]!='\n') strcat (newstring,"\n");
    strcpy (errstring,&errstring[pos+1]);
  }

  if ((int) strlen (errstring) > 0) strcat (newstring,errstring);
 
  xstring = XmStringCreateLtoR (newstring, XmSTRING_DEFAULT_CHARSET);
  XtVaSetValues (DB,XmNmessageString,xstring,NULL);
  XmStringFree (xstring);

/****************************************************************************
* Pop up the error message 
*****************************************************************************/

  if (XtIsManaged (DB)) {
    XtUnmanageChild (DB);
    XtManageChild (DB);
  }
  else {
    XtManageChild (DB);
  }

  return;
}
예제 #7
0
Widget XmCreateWarningDialog_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreateWarningDialog(parent, name, arglist, argcount);}
예제 #8
0
파일: dialog.c 프로젝트: epicsdeb/alh
/******************************************************
  Error message popup
******************************************************/
void errMsg(const char *fmt, ...)
{
	XmString cstring,cstringOld,cstringNew;
	va_list vargs;
	static char lstring[1024];  /* DANGER: Fixed buffer size */
	static int warningboxMessages = 0;
	int nargs=10;
	Arg args[10];
    size_t len;
    struct tm * tms;
    time_t timeofday;

    timeofday = time(0L);
    tms = localtime(&timeofday);
    len = strftime(lstring,TIME_SIZE,"%Y/%m/%d %H:%M ",tms);
	va_start(vargs,fmt);
	vsprintf(&lstring[TIME_SIZE-1],fmt,vargs);
	va_end(vargs);

	if(lstring[TIME_SIZE-1] == '\0') return;

	alLogOpModMessage(0,0,&lstring[TIME_SIZE-1]);

	if (_no_error_popup) {
		return;
	}

	if (warningbox) {

		if (warningboxMessages > 30) return;

		cstring=XmStringCreateLtoR(lstring,XmSTRING_DEFAULT_CHARSET);
		XtVaGetValues(warningbox, XmNmessageString, &cstringOld, NULL);
		cstringNew = XmStringConcat(cstringOld,cstring);
		XmStringFree(cstring);
		XmStringFree(cstringOld);
		if (warningboxMessages == 30){
			cstring=XmStringCreateLtoR(
				"\nOnly first 30 messages are displayed and logged\n",
				XmSTRING_DEFAULT_CHARSET);
			cstringOld = cstringNew;
			cstringNew = XmStringConcat(cstringOld,cstring);
			XmStringFree(cstring);
			XmStringFree(cstringOld);
		}
		XtVaSetValues(warningbox, XmNmessageString, cstringNew, NULL);
		XmStringFree(cstringNew);
		warningboxMessages += 1;
		XtManageChild(warningbox);
	} else {
		XBell(display,50); 
		XBell(display,50); 
		XBell(display,50);
		cstring=XmStringCreateLtoR(lstring,XmSTRING_DEFAULT_CHARSET);
		nargs=0;
		XtSetArg(args[nargs],XmNtitle,"ALH Warning"); 
		nargs++;
		XtSetArg(args[nargs],XmNmessageString,cstring); 
		nargs++;
		warningbox=XmCreateWarningDialog(topLevelShell,"warningMessage",
		    args,nargs);
		XmStringFree(cstring);
		XtDestroyWidget(XmMessageBoxGetChild(warningbox,XmDIALOG_CANCEL_BUTTON));
		XtDestroyWidget(XmMessageBoxGetChild(warningbox,XmDIALOG_HELP_BUTTON));
		/*XtAddCallback(warningbox,XmNokCallback,logMessageString,NULL);*/
		XtAddCallback(warningbox,XmNokCallback,killWidget,NULL);
		warningboxMessages = 1;
		XtManageChild(warningbox);
	}
}
예제 #9
0
XSilChessWindow::XSilChessWindow(XtAppContext app, Widget toplevel,
                                 Visual * vsl, int vsldepth, Colormap cmap)
{
	char tmp[512];
	Arg al[10];
	int i;
	XmString xms;

	// Initialize member variables
	App=app;
	TopLevel=toplevel;
	Disp=XtDisplay(TopLevel);
	Vsl=vsl;
	VslDepth=vsldepth;
	CMap=cmap;
	DlgVsl=DefaultVisual(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	DlgVslDepth=DefaultDepth(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	DlgCMap=DefaultColormap(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	PixelSize=(VslDepth<=8 ? 1 : (VslDepth<=16 ? 2 : 4));
	RedMask=Vsl->red_mask;
	GreenMask=Vsl->green_mask;
	BlueMask=Vsl->blue_mask;
	SelX=SelY-1;
	IsSearching=false;
	AbortSearching=false;
	NeedPainting=false;
	IsPainting=false;
	HintWanted=false;
	HintValid=false;

	// Create main window
	MainWin=XtVaCreateManagedWidget(
		"mainWin",xmMainWindowWidgetClass,TopLevel,
		(char*)NULL
	);

	// Create main menu bar
	MainMenu=XmCreateMenuBar(MainWin,(char*)"mainMenu",NULL,0);
	XtManageChild(MainMenu);

	// Create menu item: file
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	FileMenu=XmCreatePulldownMenu(MainMenu,(char*)"fileMenu",al,3);
	BFile=XtVaCreateManagedWidget(
		"file",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,FileMenu,
		(char*)NULL
	);

	// Create menu item: file/load
	BFileLoad=XtVaCreateManagedWidget(
		"load",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileLoad,XmNactivateCallback,HandleCallback,this);

	// Create menu item: file/save
	BFileSave=XtVaCreateManagedWidget(
		"save",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileSave,XmNactivateCallback,HandleCallback,this);

	// Create menu item: file/exit
	XtVaCreateManagedWidget(
		"separator",xmSeparatorWidgetClass,FileMenu,
		(char*)NULL
	);
	BFileExit=XtVaCreateManagedWidget(
		"exit",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileExit,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	GameMenu=XmCreatePulldownMenu(MainMenu,(char*)"gameMenu",al,3);
	BGame=XtVaCreateManagedWidget(
		"game",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,GameMenu,
		(char*)NULL
	);

	// Create menu item: game/new
	BGameNew=XtVaCreateManagedWidget(
		"new",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameNew,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/flip
	BGameFlip=XtVaCreateManagedWidget(
		"flip",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameFlip,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/undo
	BGameUndo=XtVaCreateManagedWidget(
		"undo",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameUndo,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/list
	BGameList=XtVaCreateManagedWidget(
		"list",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameList,XmNactivateCallback,HandleCallback,this);

	// Create menu item: computer
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	CompMenu=XmCreatePulldownMenu(MainMenu,(char*)"compMenu",al,3);
	BComp=XtVaCreateManagedWidget(
		"comp",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,CompMenu,
		(char*)NULL
	);

	// Create menu item: computer/hint
	BCompHint=XtVaCreateManagedWidget(
		"hint",xmPushButtonWidgetClass,CompMenu,
		(char*)NULL
	);
	XtAddCallback(BCompHint,XmNactivateCallback,HandleCallback,this);

	// Create menu item: computer/depth
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	XtSetArg(al[3],XmNradioBehavior,True);
	DepthMenu=XmCreatePulldownMenu(CompMenu,(char*)"depthMenu",al,4);
	BCompDepth=XtVaCreateManagedWidget(
		"depth",xmCascadeButtonWidgetClass,CompMenu,
		XmNsubMenuId,DepthMenu,
		(char*)NULL
	);

	// Create menu items: computer/depth/1...
	for (i=0; i<=SilChessMachine::MAX_SEARCH_DEPTH; i++) {
		sprintf(tmp,"%d",i);
		BDepth[i]=XtVaCreateManagedWidget(
			tmp,xmToggleButtonWidgetClass,DepthMenu,
			(char*)NULL
		);
		XtAddCallback(BDepth[i],XmNvalueChangedCallback,HandleCallback,this);
	}

	// Create menu item: help
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	HelpMenu=XmCreatePulldownMenu(MainMenu,(char*)"helpMenu",al,3);
	BHelp=XtVaCreateManagedWidget(
		"help",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,HelpMenu,
		(char*)NULL
	);
	XtVaSetValues(MainMenu,XmNmenuHelpWidget,BHelp,(char*)NULL);

	// Create menu item: help/about
	BHelpAbout=XtVaCreateManagedWidget(
		"about",xmPushButtonWidgetClass,HelpMenu,
		(char*)NULL
	);
	XtAddCallback(BHelpAbout,XmNactivateCallback,HandleCallback,this);

	// Create a parent for status bar and view
	MainForm=XtVaCreateManagedWidget(
		"mainForm",xmFormWidgetClass,MainWin,
		(char*)NULL
	);

	// Create status line
	StatusFrame=XtVaCreateManagedWidget(
		"statusFrame",xmFrameWidgetClass,MainForm,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNtopAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	StatusLabel=XtVaCreateManagedWidget(
		"statusLabel",xmLabelWidgetClass,StatusFrame,
		XmNalignment, XmALIGNMENT_BEGINNING,
		(char*)NULL
	);

	// Create the chess board view
	ViewFrame=XtVaCreateManagedWidget(
		"viewFrame",xmFrameWidgetClass,MainForm,
		XmNtopAttachment,XmATTACH_WIDGET,
		XmNtopWidget,StatusFrame,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	ViewArea=XtVaCreateManagedWidget(
		"viewArea",xmDrawingAreaWidgetClass,ViewFrame,
		XmNtopAttachment,XmATTACH_FORM,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	XtAddCallback(ViewArea,XmNexposeCallback,HandleCallback,this);
	XtAddCallback(ViewArea,XmNresizeCallback,HandleCallback,this);
	XtAddEventHandler(
		ViewArea,ButtonPressMask|ButtonMotionMask|ButtonReleaseMask|
		StructureNotifyMask,False,HandleEvent,this
	);
	XtVaGetValues(ViewArea,XmNwidth,&ViewWidth,(char*)NULL);
	XtVaGetValues(ViewArea,XmNheight,&ViewHeight,(char*)NULL);
	ViewWin=0;
	ViewGC=NULL;

	// Create dialog: load game
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage,True);
	LoadDialog=XmCreateFileSelectionDialog(TopLevel,(char*)"loadDialog",al,4);
	XtAddCallback(LoadDialog,XmNokCallback,HandleCallback,this);
	XtUnmanageChild(XmFileSelectionBoxGetChild(LoadDialog,XmDIALOG_HELP_BUTTON));

	// Create dialog: save game
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	SaveDialog=XmCreateFileSelectionDialog(TopLevel,(char*)"saveDialog",al,4);
	XtAddCallback(SaveDialog,XmNokCallback,HandleCallback,this);
	XtUnmanageChild(XmFileSelectionBoxGetChild(SaveDialog,XmDIALOG_HELP_BUTTON));

	// Create dialog: file exists, overwrite?
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	OverwriteDialog=XmCreateWarningDialog(TopLevel,(char*)"overwriteDialog",al,4);
	XtUnmanageChild(XmMessageBoxGetChild(OverwriteDialog,XmDIALOG_HELP_BUTTON));
	XtAddCallback(OverwriteDialog,XmNokCallback,HandleCallback,this);

	// Create dialog: error message
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	ErrorBox=XmCreateWarningDialog(TopLevel,(char*)"errorBox",al,4);
	XtUnmanageChild(XmMessageBoxGetChild(ErrorBox,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(ErrorBox,XmDIALOG_HELP_BUTTON));

	// Create dialog: list of moves
	ListDialogPopup=XtVaCreateWidget(
		"listDialog_popup",xmDialogShellWidgetClass,TopLevel,
		XmNvisual,DlgVsl,
		XmNdepth,DlgVslDepth,
		XmNcolormap,DlgCMap,
		(char*)NULL
	);
	ListDialog=XtVaCreateWidget(
		"listDialog",xmFormWidgetClass,ListDialogPopup,
		(char*)NULL
	);
	LDClose=XtVaCreateManagedWidget(
		"close",xmPushButtonWidgetClass,ListDialog,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	XtAddCallback(LDClose,XmNactivateCallback,HandleCallback,this);
	LDScroll=XtVaCreateManagedWidget(
		"scroll",xmScrolledWindowWidgetClass,ListDialog,
		XmNscrollingPolicy,XmAUTOMATIC,
		XmNscrollBarDisplayPolicy,XmAS_NEEDED,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNtopAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_WIDGET,
		XmNbottomWidget,LDClose,
		(char*)NULL
	);
	LDList=XtVaCreateManagedWidget(
		"list",xmLabelGadgetClass,LDScroll,
		XmNalignment,XmALIGNMENT_BEGINNING,
		(char*)NULL
	);

	// Create dialog: about
	xms=XmStringCreateLtoR((char*)AboutText,XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage,True);
	XtSetArg(al[4],XmNmessageString,xms);
	XtSetArg(al[5],XmNmessageAlignment,XmALIGNMENT_CENTER);
	AboutDialog=XmCreateMessageDialog(TopLevel,(char*)"aboutDialog",al,6);
	XmStringFree(xms);
	XtUnmanageChild(XmMessageBoxGetChild(AboutDialog,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(AboutDialog,XmDIALOG_HELP_BUTTON));

	// Set main window areas
	XmMainWindowSetAreas(MainWin,MainMenu,NULL,NULL,NULL,MainForm);

	// Create chess machine
	Machine = new SilChessMachine();

	// Setup ray tracer
	RT.SetViewSize(ViewWidth,ViewHeight);
	RT.SetWorld(Machine);

	// Update all
	UpdateStatusBar();
	UpdateMovesList();
	UpdateView();
	UpdateDepthMenu();
}
예제 #10
0
파일: dtchooser.c 프로젝트: juddy/edcde
void 
MakeDialog( DialogType dtype )
{
    register int i, j;

    int		width;
    
    FILE	*fp, *fopen();
    char	buffer[128];
    char	*str;

    Widget	w, text;
    Dimension	txt_width, txt_height;
    XmString	ok, cancel, nw, sv;

    Widget      tlev;

    /*
     *  do things common to all dialogs...
     */

    ok     = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
    cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);

    i = InitArg(MessageBox);
    XtSetArg(argt[i], XmNmarginHeight,		MBOX_MARGIN_HEIGHT	); i++;
    XtSetArg(argt[i], XmNmarginWidth,		MBOX_MARGIN_WIDTH	); i++;
    XtSetArg(argt[i], XmNshadowThickness,	SHADOW_THICKNESS	); i++;
    XtSetArg(argt[i], XmNokLabelString,		ok			); i++;
    XtSetArg(argt[i], XmNcancelLabelString,	cancel			); i++;
    XtSetArg(argt[i], XmNnoResize,		False			); i++;
    XtSetArg(argt[i], XmNresizePolicy,		XmRESIZE_ANY		); i++;

    /*
     *  create the various dialogs...
     */

    /* JET - check the matte widget, and if non-null, well use that as
     * the parent for dialogs.  Otherwise use table (the original
     * toplevel widget for this func).  This is useful for Xinerama so
     * that child dialogs are centered on the matte, and not the whole
     * SLS screen.
     */
    if (matte != (Widget)NULL)
      tlev = matte;
    else
      tlev = table;


    switch (dtype) {

    case error:
	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateErrorDialog(tlev, "error_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	error_message = w;
	break;


    case help:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
	str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
	break;


    case copyright:
	if ((fp = fopen(COPYRIGHT,"r")) == NULL)
#if defined( __hp_osf )
	    xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#else
	    xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#endif
	else {
	    xmstr = (XmString) NULL;
	
	    while (fgets(buffer, 128, fp) != NULL) {
		j = strlen(buffer);
		if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
	    
		if ( xmstr != NULL )
		    xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());

		xmstr = XmStringConcat(xmstr,
	    			       XmStringCreate(buffer,
				       XmFONTLIST_DEFAULT_TAG));
	    }	    
	}

	fclose(fp);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
	
	XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);    

	copyright_msg = w;
	break;
    

    case hostname:
	    
	nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL,  MC_DEF_NW_LABEL);
	sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);

	xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	XtSetArg(argt[i], XmNokLabelString,		nw		); i++;
	XtSetArg(argt[i], XmNcancelLabelString,		sv		); i++;

	w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	XmStringFree(nw);
	XmStringFree(sv);

	hostname_message = w;
	break;


    case expassword:

	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED, 
			    MC_DEF_PASSWD_EXPIRED);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	passwd_message = w;
	break;


    case help_chooser:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);

	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
        str = (char*)
	      ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
        break;
    }
예제 #11
0
파일: infopop.c 프로젝트: mjames-upc/garp
void
InfoPop ( Widget parent,	int type,
	  char *message,	Boolean help,
	  Boolean cancel,	void (*HelpCB)(),
	  void (*CancelCB)() )
{
	Widget		dialog;
	XmString	xmstr;
	char		buf[4096];

	if ( message == NULL ) return;
/*
 *  Create an information dialog of the type requested in function call.
 */
	switch ( type ) {
	case ERROR:
	  dialog = XmCreateErrorDialog ( parent, "ERROR", NULL, 0 );
	  strcpy ( buf, "ERROR:\n" );
	break;
	  
	case INFORMATION:
	  dialog = XmCreateInformationDialog ( parent, "INFORMATION", NULL, 0 );
	  strcpy ( buf, "INFORMATION:\n" );
	break;

	case QUESTION:
	  dialog = XmCreateQuestionDialog ( parent, "QUESTION", NULL, 0 );
	  strcpy ( buf, "QUESTION:\n" );
	break;

	case WARNING:
	  dialog = XmCreateWarningDialog ( parent, "WARNING", NULL, 0 );
	  strcpy ( buf, "WARNING:\n" );
	break;

	case WORKING:
	  dialog = XmCreateWorkingDialog ( parent, "WORKING", NULL, 0 );
	  strcpy ( buf, "WORKING:\n" );
	break;

	default:
	break;
	}

/*
 *	Write message to dialog.
 */
	strcat ( buf, message );
	xmstr = XmStringCreateLtoR ( buf, XmFONTLIST_DEFAULT_TAG);
	XtVaSetValues ( dialog,
		XmNmessageString,	xmstr,
		NULL );

	XmStringFree ( xmstr );

/*
 *	Add callbacks to buttons or, alternatively, delete the buttons.
 */
	if ( !help ) XtUnmanageChild ( 
	    XmMessageBoxGetChild ( dialog, XmDIALOG_HELP_BUTTON ) );
	else
	    XtAddCallback ( dialog, XmNhelpCallback, HelpCB, NULL );

	if ( !cancel ) XtUnmanageChild (
	    XmMessageBoxGetChild ( dialog, XmDIALOG_CANCEL_BUTTON ) );
	else
	    XtAddCallback ( dialog, XmNcancelCallback, CancelCB, NULL );

/*
 *	Manage popup.
 */
	XtManageChild ( dialog );
	XtPopup ( XtParent ( dialog ), XtGrabNone );
}
예제 #12
0
void 
HelpRequestCB(
        Widget w,
        XtPointer clientData,
        XtPointer callData )

{
   XtPointer recordStruct;
   DialogData * dialogData;
   Arg args[8];
   int n;
   String topicTitle = NULL;
   int helpType;
   Boolean freeClientData;
   String fileType;
   String strVal;
   char *vol;
   char *locId;

   /* Refresh the display */
   /* printf ("in HelpRequestCB: clientdata=\"%s\"\n",(char *)clientData); */
   XmUpdateDisplay(w);

   if (recordStruct = LocateRecordStructure(w))
   {
      if (dialogData = _DtGetInstanceData(recordStruct))
      {
         if (IsMainWinDialog(dialogData))
         {
            FileMgrData * fileMgrData = (FileMgrData *)dialogData->data;
            FileMgrRec * fileMgrRec = (FileMgrRec *)recordStruct;

            /* Check for item help */
            if (clientData && strcmp(clientData, HELP_HELP_MODE_STR) == 0)
            {
              if( !ProcessItemHelp( fileMgrRec->shell ) )
              {
                char *tmpStr, *title, *msg;

                tmpStr = GetSharedMessage(ITEM_HELP_ERROR_TITLE);
                title = XtNewString(tmpStr);

                if( fileMgrData->toolbox )
                {
                  tmpStr = GetSharedMessage( AMITEM_HELP_ERROR );
                  msg = XtNewString(tmpStr);
                }
                else
                {
                  tmpStr = GetSharedMessage( ITEM_HELP_ERROR ),
                  msg = XtNewString(tmpStr);
                }

                _DtMessage(fileMgrRec->shell, title, msg, NULL,
                           HelpRequestCB);
                XtFree(title);
                XtFree(msg);
              }
              return;
            }
            /* Item help comes in with a NULL client data */
            if (clientData)
            {
               fileType = NULL;
               topicTitle = NULL;
               helpType = DtHELP_TYPE_TOPIC;
               freeClientData = False;
            }
            else
            {
               if(fileMgrData->selected_file_count > 1)
               {
                 Widget warn;
                 String s;
                 XmString xmstr;

                 n=0;
                 XtSetArg(args[n], XmNokLabelString, okXmString);                        n++;
                 XtSetArg(args[n], XmNcancelLabelString, cancelXmString);                n++;
                 s = GETMESSAGE(29,10, "Help is not available for multiple selected objects.");
                 xmstr = XmStringCreateLocalized(s);

                 XtSetArg(args[n], XmNmessageString, xmstr);                             n++;
                 XtSetArg(args[n], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));   n++;

                 warn = XmCreateWarningDialog(fileMgrRec->shell, "warn_msg", args, n);

                 XtUnmanageChild(XmMessageBoxGetChild(warn,XmDIALOG_HELP_BUTTON));
                 XtManageChild(warn);
                 XmStringFree(xmstr);

                 return;
               }

               /* Action/Filetype Help */
               topicTitle = GetSharedMessage(ACTION_FT_HELP_TITLE);
               helpType = DtHELP_TYPE_DYNAMIC_STRING;
               fileType = NULL;

               /* Determine string, and set clientData accordingly */
               if ((clientData =
                      MapIconWidgetToFileType(w, fileMgrData)) == NULL)
               {
                  /* Not a file icon; is it an action menu item? */
                  if (!IsMenuWidget(w, fileMgrRec, fileMgrData, &strVal, 
                                    &fileType))
                  {
                     if (! IsFilterIcon(w, fileMgrData, &strVal))
                        return;
                  }
                  clientData = (XtPointer)strVal;
               }
               freeClientData = True;
            }

            /* printf ("topic = %s\n", clientData); */

            /* Special check for 'Using Help'; required different volume */
            locId = (char *)clientData;
            if ((w == *usingHelp) && (strcmp(locId, HELP_HOME_TOPIC) == 0))
               vol = "Help4Help";
            else
               vol = fileMgrData->helpVol;

            if (fileMgrData->primaryHelpDialog)
            {
               ReusePrimaryHelpWindow( fileMgrData->primaryHelpDialog, 
                                       clientData, vol, topicTitle,
                                       fileType, helpType);
            }
            else
            {
               /* Create the main help window for this view */
               ShowHelpDialog(fileMgrRec->shell, (XtPointer)fileMgrRec,
			      MAIN_HELP_DIALOG, 
                              NULL, clientData, vol,
                              topicTitle, fileType, helpType);
            }

            if (freeClientData)
            {
               XtFree(fileType);
               XtFree(clientData);
            }
         }
      }
   }
      else if (clientData)
      {
         Widget mainHelpDialog=NULL;
         Arg args[10];
         int i=0;

         XtSetArg(args[0],XmNuserData,&mainHelpDialog);
         XtGetValues(w,args,1);

         XtSetArg(args[i], DtNhelpType,(unsigned char) DtHELP_TYPE_TOPIC); i++;
         XtSetArg(args[i], DtNhelpVolume, DTFILE_HELP_NAME); i++;
         XtSetArg(args[i], DtNlocationId, clientData); i++;
         XtSetArg(args[i], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));i++;
         if(!mainHelpDialog || ( mainHelpDialog && !XtIsManaged(mainHelpDialog)) )
	 {

             mainHelpDialog = DtCreateHelpDialog(w, "mainHelpDialog", args, i);
             XtAddCallback(mainHelpDialog, DtNcloseCallback,
                       closeCB_mainHelpDialog,
                       (XtPointer)NULL);
             XtManageChild(mainHelpDialog);
	     XtSetArg(args[0],XmNuserData,mainHelpDialog);
	     XtSetValues(w,args,1);
	 }
	 else
           XtSetValues(mainHelpDialog, args, i);
      }
}