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;
/* 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. */
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)
{
/*********************************************************
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
***********************************************************/
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
***************************************************************/
/* 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;
}
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();
}