iCAx开思工具箱

标题: 【求助】UG open的一个问题 [打印本页]

作者: pinkwall    时间: 2003-5-14 14:17
标题: 【求助】UG open的一个问题
include <Xm/XmAll.h>
  
在一个例子中看到这样一个头文件
  
然后下面函数体里面用到了这些函数
  
XtSetArg(args, XmNcancelLabelString, canstr);   
  
canstr  = XmStringCreate(" Back ", XmSTRING_DEFAULT_CHARSET);
  
这是ugopen的函数?? 还是什么c或c++的api?
作者: zzz    时间: 2003-5-14 15:13
早过时了,这是XWindows里面的东西,Unix里面开发时用的 。
作者: pinkwall    时间: 2003-5-14 15:23
应该用什么api替代呢??
  
msdn里面差不到
作者: zzz    时间: 2003-5-14 20:32
不知道啊,应该可以直接删掉吧。要不把代码贴上来看看。
这是清华的书里面的东西吧。
作者: pinkwall    时间: 2003-5-14 23:01
是ug自带的一个例子
  
The following example illustrates the sequence and the use of UF_UI_lock_ug_access, plus various other UF_UI functions.  
  
#include <Xm/XmAll.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_ui_xt.h>
  
/*  Local Function Declaration */
static void ok_cb( Widget w, XtPointer client_data,
                   XtPointer call_data);
static void back_cb( Widget w, XtPointer client_data,
                     XtPointer call_data);
static void cancel_cb( Widget w, XtPointer client_data,
                       XtPointer call_data);
static void launch_lock_cb( Widget w, XtPointer button_state,
                            XtPointer client_data);
static UF_UI_change_state_fn_t lock_change_state(int new_state);
static int initialize_uf( void );
static void call_end_dialog_xt ( XtPointer call_data,
                                 XtIntervalId *id );
static void call_end_dialog ( void );
static void clean_up( void );
  
static void create_custom_dialog(Position x, Position y,
                                 Widget parent);
/*  Local variables used within this file */
static Widget custom_dialog;
static Widget pushb1_w;
  
/*  Defines */
#define UFUN_INITIALIZED (0)
#define UFUN_NOT_INITIALIZED (1)
  
extern void
ufusr(char *param, int *retcod, int param_len)
{
  int        rcode;
  Widget     ug_parent;
 &nbsposition   x, y;
  
  /*  Check to see if Ufun is initialized and if it isn't then */
  /*  initialize it                                            */
  
  if (initialize_uf() == UFUN_NOT_INITIALIZED)
      return;
  
  /* Use UG parent and standard area 1 for primary menu. */
  ug_parent = (Widget)UF_UI_get_default_parent();
  UF_UI_get_DA2_coords([$x, &y)]
  
  create_custom_dialog(x,y,ug_parent);
  
  /*  Instantiate the change state function. This is called  */
  /*  whenever UG goes from a lock to an unlock state. This  */
  /*  does not mean that this is called whenever a new DA2 is */
  /*  brought up.                                            */
  
  rcode = UF_UI_register_change_state_fn(
         (UF_UI_change_state_fn_t)lock_change_state,
         "locktest_change_state");
  
  if (rcode == UF_UI_FAILURE)
    UF_UI_set_status("Could not set a change state function");
  
  XtManageChild (custom_dialog);
  
  UF_terminate();
}
  
/*  The function to create the custom dialog */
  
static void create_custom_dialog(Position x, Position y,
                                 Widget parent)
{
  
  int        i;
  Arg        args[20];
  Widget     form_w;
  XmString   canstr, helpstr, okstr;
  
  canstr  = XmStringCreate(" Back ", XmSTRING_DEFAULT_CHARSET);
  helpstr = XmStringCreate("Cancel", XmSTRING_DEFAULT_CHARSET);
  okstr   = XmStringCreate("  OK  ", XmSTRING_DEFAULT_CHARSET);
  
  /* Create the specified dialog. */
  i = 0;
  XtSetArg(args, XmNcancelLabelString, canstr);   i++;
  XtSetArg(args, XmNhelpLabelString, helpstr);   i++;
  XtSetArg(args, XmNokLabelString, okstr);   i++;
  XtSetArg(args, XmNx, x+200);   i++;
  XtSetArg(args, XmNy, y);   i++;
  XtSetArg(args, XmNdefaultPosition, False);   i++;
  XtSetArg(args, XmNautoUnmanage, False);  i++;
  XtSetArg(args, XmNdeleteResponse, XmDO_NOTHING);  i++;
  XtSetArg(args, XmNmarginHeight, 10);  i++;
  XtSetArg(args, XmNmarginWidth, 0);  i++;
  XtSetArg(args, XmNdialogType, XmDIALOG_WORKING);  i++;
  
  custom_dialog = XmCreateMessageDialog (parent,
                                         "Lock Example",
                                         args, i);
  
  XtUnmanageChild( XmMessageBoxGetChild(custom_dialog,
                                        XmDIALOG_MESSAGE_LABEL) );
  
  XtAddCallback (custom_dialog, XmNcancelCallback, back_cb, NULL);
  XtAddCallback (custom_dialog, XmNokCallback, ok_cb, NULL);
  XtAddCallback (custom_dialog, XmNhelpCallback, cancel_cb, NULL);
  
  /* Turn the default button off. */
  XtVaSetValues(custom_dialog, XmNdefaultButton, NULL, NULL);
  
  form_w = XtVaCreateManagedWidget("grp",
                                   xmFormWidgetClass,
                                   custom_dialog,
                                   NULL);
  
  pushb1_w =  XtVaCreateManagedWidget( "Launch Lock Test",
                  xmPushButtonWidgetClass, form_w,
                  XmNleftAttachment, XmATTACH_FORM,
                  XmNrightAttachment, XmATTACH_FORM,
                  XmNtopAttachment, XmATTACH_FORM,
                  NULL );
  
  XtAddCallback(pushb1_w,
                XmNactivateCallback,
                (XtCallbackProc) launch_lock_cb,
                NULL);
}
  
/*********************************************************
    Function:    lock_change_state
    Description: Called whenever UG locks and unlocks its menubar.
                 This is not quite as evident as it used to be
                 since UG's menubar doesn't grey out as much as it
                 used to, but the state changes are still the same.
    Input:       new_state - this is the new lock state of UG.
    Output:      N/A
    Return:      N/A
***********************************************************/
  
static UF_UI_change_state_fn_t lock_change_state(int new_state)
{
   if (custom_dialog != NULL)
   {
      if (new_state == UF_UI_LOCK)
         XtSetSensitive(pushb1_w, FALSE);
  
      else if (new_state == UF_UI_UNLOCK)
         XtSetSensitive(pushb1_w, TRUE);
  
      else if (new_state == UF_UI_ERROR)
       /*  Do any necessary clean up. This is called when */
       /*  UF_UI_set_force_unlock is called.              */
           printf("ERROR clean up time \n");
   }
  
   return(NULL);
  
} /* end locktest_change_state */
  
/**************************************************************
    Function:    launch_lock_cb
    Description: Called whenever the user presses the push
                 button in the custom dialog. This
                 launches a standard Ufun dialog (Point
                 Subfunction). It is demonstrating the use of
                 the lock and unlock  mechanism.
    Input:       w            - the widget with the action
                 button_state - call data
                 client_data  - any data the user wants to
                                pass on.
    Output:      N/A
    Return:      N/A
***************************************************************/
  
static void
launch_lock_cb( Widget w,
                XtPointer button_state,
                XtPointer client_data)
{
    int    rcode;
    int    def[2];
    double point1[3];
    if (initialize_uf() == UFUN_NOT_INITIALIZED)
         return;
  
   /*  Call the lock protocol to provide for the correct */
   /*  handshaking.                                     */
    rcode = UF_UI_lock_ug_access (UF_UI_FROM_CUSTOM);
    if (rcode != UF_UI_LOCK_SET)
    {
        UF_UI_set_status("Could not lock Unigraphics");
        return;
    }
  
    def[0] = 0;
    rcode = uc1616("Create Point", def, 0, point1);
  
    rcode = UF_UI_unlock_ug_access (UF_UI_FROM_CUSTOM);
    if (rcode != UF_UI_UNLOCK_SET)
        UF_UI_set_status("Could not unlock Unigraphics");
  
    UF_terminate();
}
  
/********************************************************
  
    Function:    ok_cb
    Description: This is called whenever the OK button is
                 pressed on the custom dialog.
    Input:       w            - the widget with the action
                 client_data  - any data the user wants to
                                pass on.
    Output:      N/A
    Return:      N/A
*********************************************************/
static void
ok_cb( Widget w, XtPointer client_data, XtPointer call_data)
{
  
  /*  Do any processing at this point in time and then do */
  /*  the necessary clean up.                            */
  
  clean_up( );
}
  
/******************************************************
    Function:    back_cb
    Description: This is called whenever the Back button
  
                 is pressed on the custom dialog.
    Input:       w            - the widget with the action
                 client_data  - any data the user wants to
                                pass on.
    Output:      N/A
    Return:      N/A
*******************************************************/
static void
back_cb( Widget w, XtPointer client_data, XtPointer call_data)
{
  /*  Do any necessary clean up to go back to the previous */
  /*  state */
  clean_up( );
}
  
/*******************************************************
    Function:    cancel_cb
    Description: This is called whenever the Cancel button
                 is pressed on the custom dialog.
    Input:       w            - the widget with the action
                 client_data  - any data the user wants to
                                pass on.
    Output:      N/A
  
   Return:      N/A
*************************************************************/
static void
cancel_cb( Widget w, XtPointer client_data,
           XtPointer call_data)
{
  /*  Do any necessary clean up to go back to the previous */
  /*  state */
  clean_up( );
}
  
/**************************************************************
    Function:    clean_up
    Description: This function does the necessary clean up when
                 leaving your custom dialog.
    Input:       N/A
    Output:      N/A
    Return:      N/A
***************************************************************/
static void clean_up( void )
{
  int rcode;
  if (initialize_uf() == UFUN_NOT_INITIALIZED)
      return;
  
  if (UF_UI_ask_lock_status() == UF_UI_LOCK)
  {
      if (rcode == UF_UI_FAILURE)
          UF_UI_set_status("Could not call set the change state to  
NULL");
  
      rcode = UF_UI_cancel_uf_dialog(UF_UI_FROM_CUSTOM);
      if (rcode == UF_UI_FAILURE)
      {
        /*  Even with a failure you want to destroy your custom */
        /*  dialog.                                            */
        UF_UI_set_status("Could not Cancel the dialog");
        call_end_dialog();
      }
      else
           
XtAppAddTimeOut(XtWidgetToApplicationContext(custom_dialog),
                 10,
                 (XtTimerCallbackProc) call_end_dialog_xt,
                 (XtPointer) NULL);
   }
   else
      call_end_dialog();
}
  
/*  This is called in the XtAppAddTimeOut function in the cancel */
/*  callback.                                                   */
static void call_end_dialog_xt ( XtPointer call_data,
                                 XtIntervalId *id )
{
    call_end_dialog();
}
  
static void call_end_dialog ( void )
{
  /*  Destroy your custom dialog */
      XtDestroyWidget(custom_dialog);
  
  /*  Be sure to unregister your change state function. By  */
  /*  passing in a NULL this unregisters the function.  */
  
      UF_UI_register_change_state_fn( NULL,
                                      "locktest_change_state");
  
      UF_terminate();
}
  
/*  This is used to initialize User Function */
  
static int initialize_uf( void )
{
  int        uf_is_initialized;
  int        initialize_rcode;
  
  /*  Check to see if Ufun is initialized and if it isn't then */
  /*  initialize it                                            */
  
  uf_is_initialized = UF_is_initialized();
  if( uf_is_initialized == 0 )
  {
      initialize_rcode = UF_initialize();
      if( initialize_rcode != 0 )
      {
          printf("Could not initialize User Function\n");
          return (UFUN_NOT_INITIALIZED);
      }
  }
  
  return(UFUN_INITIALIZED);
}
  
int ufusr_ask_unload(void)
{
   return ( UF_UNLOAD_SEL_DIALOG );
}
作者: spline    时间: 2003-5-15 08:25
放弃这些XWindow的吧,不然就装个XWindow的仿真器,估计里面是由XWindow的开发包的。
MSDN中估计没有功能完全相同的函数,只有自己是着自己组合那些API了,可以达到相同的效果。不然就试试MFC了。
作者: pinkwall    时间: 2003-5-15 16:16
问题是不知道这些函数都是干什么的
  
也没有帮助什么的可以查,这可咋办?




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3