Commit a1023d7e authored by Claes Sjofors's avatar Claes Sjofors

Xtt script, ConfirmDialog() function added

parent bcf0b4cb
......@@ -2714,6 +2714,7 @@ verify() <LINK> verify()
<h2>Miscellaneous functions
CutObjectName() <LINK> cutobjectname()
ConfirmDialog() <LINK> confirmdialog()
MessageError() <LINK> messageerror()
MessageInfo() <LINK> messageinfo()
GetCurrentText() <LINK> getcurrenttext()
......@@ -3896,6 +3897,7 @@ Miscellaneous functions
<b>Function <t>Description
CutObjectName() <t>Cut off an object name. <LINK> cutobjectname()
ConfirmDialog() <t>Open a confirm dialog <LINK> confirmdialog()
MessageError() <t>Print error message. <LINK> messageerror()
MessageInfo() <t>Print info message. <LINK> messageinfo()
GetCurrentText() <t>Get selected text. <LINK> getcurrenttext()
......@@ -3931,6 +3933,31 @@ int <t>segments <t>Number of segments that should be left.
<c> object_name = CutObjectName( path_name, 1);
</TOPIC>
<TOPIC> confirmdialog() <style> function
ConfirmDialog()
int ConfirmDialog( string title, string text)
<b>Description
Display a confirm dialog box.
Returns 1 if the yes-button is pressed, 0 if the no-button i pressed.
<b>Arguments
string <t>title <t>Title.
string <t>text <t>Confirm text.
<b>Example
<c> if ( ! ConfirmDialog( "Confirm", "Do you really want to..."))
<c> printf( "Yes is pressed\n");
<c> else
<c> printf( "No is pressed\n");
<c> endif
</TOPIC>
<TOPIC> messageerror() <style> function
MessageError()
......
......@@ -2483,6 +2483,7 @@ verify() <LINK> verify()
<h2>Diverse funktioner
CutObjectName() <LINK> cutobjectname()
ConfirmDialog() <LINK> confirmdialog()
MessageError() <LINK> messageerror()
MessageInfo() <LINK> messageinfo()
GetCurrentText() <LINK> getcurrenttext()
......@@ -3655,6 +3656,7 @@ GetNextSibling().
<TOPIC> misc_functions <style> function
Diverse funktioner
CutObjectName() <t>Klipp av ett objektsnamn. <LINK> cutobjectname()
ConfirmDialog() <t>Öppna en konfirmerings-dialog <LINK> confirmdialog()
MessageError() <t>Skriv ett felmeddelande. <LINK> messageerror()
MessageInfo() <t>Skriv ett informationsmeddelande. <LINK> messageinfo()
GetCurrentText() <t>Hämta text för utvalt alternativ. <LINK> getcurrenttext()
......@@ -3691,6 +3693,31 @@ int <t>segments <t>Antalet namnsegment som ska returneras.
<c> object_name = CutObjectName( path_name, 1);
</TOPIC>
<TOPIC> confirmdialog() <style> function
ConfirmDialog()
int ConfirmDialog( string title, string text)
<b>Beskrivning
Öppna ett konfirmerings-fönster.
Returnerar 1 om Ja-kappen har aktiverats, annars 0.
<b>Argument
string <t>title <t>Titel.
string <t>text <t>Konfirmerings text.
<b>Exempel
<c> if ( ! ConfirmDialog( "Confirm", "Do you really want to..."))
<c> printf( "Yes is pressed\n");
<c> else
<c> printf( "No is pressed\n");
<c> endif
</TOPIC>
<TOPIC> messageerror() <style> function
MessageError()
......
......@@ -105,7 +105,7 @@ XNavGtk::XNavGtk( void *xn_parent_ctx,
int xn_op_close_button,
pwr_tStatus *status) :
XNav( xn_parent_ctx, xn_name, root_menu, xn_opplace_name, xn_op_close_button, status),
parent_wid(xn_parent_wid)
parent_wid(xn_parent_wid), clock_cursor(0)
{
form_widget = scrolledbrowwidgetgtk_new(
......@@ -192,6 +192,21 @@ void XNavGtk::pop()
gtk_window_present( GTK_WINDOW(top));
}
void XNavGtk::set_clock_cursor()
{
if ( !clock_cursor)
clock_cursor = gdk_cursor_new_for_display( gtk_widget_get_display( form_widget),
GDK_WATCH);
gdk_window_set_cursor( form_widget->window, clock_cursor);
gdk_display_flush( gtk_widget_get_display( form_widget));
}
void XNavGtk::reset_cursor()
{
gdk_window_set_cursor( form_widget->window, NULL);
}
void XNavGtk::set_transient( void *basewidget)
{
GtkWidget *parent, *top;
......@@ -467,3 +482,32 @@ void XNavGtk::popup_button_cb( GtkWidget *w, gpointer data)
//xnav->reset_cursor();
}
static void xnav_confirm_dialog_ok( void *ctx, void *data)
{
((XNav *)ctx)->dialog_ok = 1;
gtk_main_quit();
}
static void xnav_confirm_dialog_cancel( void *ctx, void *data)
{
((XNav *)ctx)->dialog_cancel = 1;
gtk_main_quit();
}
int XNavGtk::confirm_dialog( char *title, char *text)
{
dialog_ok = 0;
dialog_cancel = 0;
wow->DisplayQuestion( this, title, text, xnav_confirm_dialog_ok,
xnav_confirm_dialog_cancel, 0);
gtk_main();
if ( dialog_ok) {
return 1;
}
if ( dialog_cancel) {
return 0;
}
return 0;
}
......@@ -115,6 +115,9 @@ class XNavGtk : public XNav {
xmenu_eItemType item_type,
xmenu_mUtility caller,
unsigned int priv, char *arg, int x, int y);
void set_clock_cursor();
void reset_cursor();
int confirm_dialog( char *title, char *text);
static void menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data);
static GtkWidget *build_menu( GtkWidget *Parent,
......@@ -133,6 +136,7 @@ class XNavGtk : public XNav {
GtkWidget *toplevel;
int popupmenu_x;
int popupmenu_y;
GdkCursor *clock_cursor;
};
#endif
......
......@@ -330,6 +330,8 @@ class XNav {
void *current_cmd_ctx;
int elog_enabled;
int elog_checked;
int dialog_ok;
int dialog_cancel;
virtual void set_inputfocus() {}
virtual void pop() {}
......@@ -387,6 +389,9 @@ class XNav {
void (* wl_bc_cancel)( void *),
pwr_tStatus *status) { return 0;}
virtual void bell( int time) {}
virtual int confirm_dialog( char *title, char *text) { return 0; }
virtual void set_clock_cursor() {}
virtual void reset_cursor() {}
void start_trace( pwr_tObjid Objid, char *object_str);
void start_trace_selected();
......
......@@ -4235,6 +4235,7 @@ static int xnav_open_func( void *client_data,
strcpy( title_str, "History");
}
xnav->set_clock_cursor();
if ( plotgroup_found) {
hist = xnav->xttsevhist_new( title_str, oidv, anamev, onamev, sevhistobjectv,
xnav->scctx, 0, width, height, options, &sts);
......@@ -4259,6 +4260,7 @@ static int xnav_open_func( void *client_data,
hist->get_select_cb = xnav_sevhist_get_select_cb;
}
}
xnav->reset_cursor();
}
else if ( cdh_NoCaseStrncmp( arg1_str, "FAST", strlen( arg1_str)) == 0)
{
......@@ -7505,6 +7507,38 @@ static int xnav_messageinfo_func(
return 1;
}
static int xnav_confirmdialog_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
XNav *xnav;
ccm_sArg *arg_p2;
int sts;
if ( arg_count != 2)
return CCM__ARGMISM;
arg_p2 = arg_list->next;
if ( arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
if ( arg_p2->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
xnav_get_stored_xnav( &xnav);
sts = xnav->confirm_dialog( arg_list->value_string, arg_p2->value_string);
*return_int = sts;
*return_decl = CCM_DECL_INT;
return 1;
}
static int xnav_cutobjectname_func(
void *filectx,
ccm_sArg *arg_list,
......@@ -7674,6 +7708,8 @@ int XNav::readcmdfile( char *incommand)
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetAttribute", xnav_getattribute_func);
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "ConfirmDialog", xnav_confirmdialog_func);
if ( EVEN(sts)) return sts;
ccm_func_registred = 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment