Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

xutil.h File Reference

#include <X11/X.h>
#include <X11/Intrinsic.h>
#include <X11/IntrinsicP.h>
#include <X11/cursorfont.h>
#include <Xm/XmAll.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "machdep.h"
#include "mcw_malloc.h"
#include "afni_environ.h"

Go to the source code of this file.


Data Structures

struct  MCW_action_item
struct  MCW_textwin

Defines

#define MAX(a, b)   (((a)<(b)) ? (b) : (a))
#define MIN(a, b)   (((a)>(b)) ? (b) : (a))
#define SENSITIZE(w, sen)
#define SAVEUNDERIZE(w)   XtVaSetValues((w),XmNsaveUnder,True,NULL)
#define WAIT_for_window(w)
#define POPUP_cursorize(w)
#define NORMAL_cursorize(w)
#define WATCH_cursorize(w)
#define HAND_cursorize(w)
#define PENCIL_cursorize(w)
#define CROSSHAIR_cursorize(w)
#define MCW_CALLER_KILL   1
#define MCW_USER_KILL   2
#define MCW_TIMER_KILL   (1<<10)
#define MCW_nofile   0
#define MCW_readonly   1
#define MCW_readwrite   2
#define MCW_isitmwm(ww)   (!AFNI_noenv("AFNI_X11_REDECORATE"))
#define METER_TOP   1
#define METER_TOP_WIDE   2
#define METER_BOT   3
#define METER_BOT_WIDE   4
#define TEXT_READONLY   1
#define TEXT_EDITABLE   2
#define RWC_visibilize   RWC_visibilize_widget
#define VISIBILIZE_WHEN_MAPPED(w)   XtAddCallback(w,XmNmapCallback,RWC_visibilize_CB,NULL)
#define NULLIFY_ON_DESTROY(pp, ww)   RWC_destroy_nullify((ww),(void **)&(pp))
#define CANCEL_NULLIFY_ON_DESTROY(pp, ww)   RWC_destroy_nullify_cancel((ww),(void **)&(pp))
#define INVERT_manage(w)

Typedefs

typedef void void_func ()

Functions

void MCW_expose_widget (Widget)
void MCW_invert_widget (Widget)
void MCW_set_widget_bg (Widget, char *, Pixel)
Colormap MCW_get_colormap (Widget)
void MCW_set_colormap (Widget, Colormap)
int MCW_get_depth (Widget)
Visual * MCW_get_visual (Widget)
void MCW_set_widget_cursor (Widget, int)
void MCW_alter_widget_cursor (Widget, int, char *, char *)
void RWC_sleep (int)
void MCW_register_hint (Widget, char *)
void MCW_reghint_children (Widget, char *)
void MCW_hint_toggle (void)
void MCW_disable_help (void)
void MCW_enable_help (void)
void MCW_click_help_CB (Widget, XtPointer, XtPointer)
void MCW_register_help (Widget, char *)
void MCW_reghelp_children (Widget, char *)
void MCW_help_CB (Widget, XtPointer, XtPointer)
void MCW_unhelp_CB (Widget, XtPointer, XtPointer)
void MCW_unregister_help (Widget)
void MCW_unregister_hint (Widget)
void MCW_set_widget_label (Widget, char *)
void MCW_widget_geom (Widget, int *, int *, int *, int *)
void MCW_discard_events (Widget, int)
char * MCW_hotcolor (Widget w)
Widget MCW_action_area (Widget, MCW_action_item *, int)
Widget MCW_popup_message (Widget, char *, int)
void MCW_message_CB (Widget, XtPointer, XtPointer)
void MCW_message_timer_CB (XtPointer, XtIntervalId *)
void MCW_message_alter (Widget, char *)
int MCW_filetype (char *)
Widget MCW_popup_meter (Widget, int)
void MCW_popdown_meter (Widget)
void MCW_set_meter (Widget, int)
int MCW_widget_visible (Widget w)
char * RWC_getname (Display *, char *)
MCW_textwinnew_MCW_textwin (Widget, char *, int)
void MCW_textwin_CB (Widget, XtPointer, XtPointer)
void MCW_textwinkill_CB (Widget, XtPointer, XtPointer)
void MCW_textwin_alter (MCW_textwin *, char *)
MCW_textwinnew_MCW_textwin_2001 (Widget, char *, int, void_func *, XtPointer)
void RWC_visibilize_widget (Widget)
void RWC_xineramize (Display *, int, int, int, int, int *, int *)
void RWC_visibilize_CB (Widget, XtPointer, XtPointer)
void MCW_manage_widgets (Widget *, int)
void MCW_unmanage_widgets (Widget *, int)
void RWC_destroy_nullify (Widget, void **)
void RWC_destroy_nullify_cancel (Widget, void **)
void RWC_drag_rectangle (Widget, int, int, int *, int *)
void RWC_XtPopdown (Widget)
void AFNI_speak (char *string, int nofork)
void AFNI_speak_setvoice (char *vvv)

Define Documentation

#define CANCEL_NULLIFY_ON_DESTROY pp,
ww       RWC_destroy_nullify_cancel((ww),(void **)&(pp))
 

Definition at line 210 of file xutil.h.

#define CROSSHAIR_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
      MCW_set_widget_cursor( (w) , -XC_crosshair ) ;           \
 } while(0)

Definition at line 92 of file xutil.h.

Referenced by ISQ_set_cursor_state().

#define HAND_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
      MCW_set_widget_cursor( (w) , -XC_hand2 ) ;               \
 } while(0)

Definition at line 82 of file xutil.h.

Referenced by GRA_handle_keypress(), and ISQ_zoom_pb_CB().

#define INVERT_manage w   
 

Value:

do{ if( XtIsManaged(w) ) XtUnmanageChild(w);            \
     else                 XtManageChild(w); } while(0)

Definition at line 214 of file xutil.h.

Referenced by drive_MCW_imseq().

#define MAX a,
b       (((a)<(b)) ? (b) : (a))
 

Definition at line 26 of file xutil.h.

#define MCW_CALLER_KILL   1
 

Definition at line 132 of file xutil.h.

Referenced by AFNI_do_many_writes(), AFNI_write_dataset_CB(), ISQ_statify_all(), MCW_popup_message(), SUMA_PopUpMessage(), T3D_check_outliers(), and T3D_save_file_CB().

#define MCW_isitmwm ww       (!AFNI_noenv("AFNI_X11_REDECORATE"))
 

Definition at line 151 of file xutil.h.

Referenced by DRAW_make_widgets(), drive_MCW_imseq(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_montage_CB(), main(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), MCW_choose_string(), MCW_choose_timeseries(), MCW_choose_vector(), MCW_help_CB(), MCW_popup_message(), MCW_popup_meter(), NUD_make_widgets(), open_MCW_imseq(), PLUG_setup_widgets(), RCREND_make_widgets(), REND_make_widgets(), and TAG_make_widgets().

#define MCW_nofile   0
 

Definition at line 142 of file xutil.h.

Referenced by MCW_filetype().

#define MCW_readonly   1
 

Definition at line 143 of file xutil.h.

Referenced by MCW_filetype().

#define MCW_readwrite   2
 

Definition at line 144 of file xutil.h.

Referenced by MCW_filetype().

#define MCW_TIMER_KILL   (1<<10)
 

Definition at line 134 of file xutil.h.

Referenced by AFNI_crosshair_EV(), AFNI_do_many_writes(), AFNI_finalize_read_1D_CB(), AFNI_finalize_read_palette_CB(), AFNI_finalize_read_sess_CB(), AFNI_finalize_read_Web_CB(), AFNI_finalize_write_palette_CB(), AFNI_gra_send_CB(), AFNI_marks_action_CB(), AFNI_marks_quality_check(), AFNI_misc_CB(), AFNI_popup_sonnet(), AFNI_read_sess_CB(), AFNI_rescan_all_CB(), AFNI_rescan_CB(), AFNI_startup_timeout_CB(), AFNI_write_dataset_CB(), AFNI_write_many_dataset_CB(), DRAW_choose_CB(), DRAW_finalize_dset_CB(), DRAW_receiver(), DRAW_saveas_finalize_CB(), DSET2_dset_recv(), DSETN_dset_recv(), GRA_opt_CB(), ISQ_cropper(), MCW_choose_CB(), MCW_popup_message(), NOTES_add_CB(), NOTES_choose_CB(), NOTES_save_CB(), NUD_choose_CB(), NUD_nudge_CB(), PLUTO_popup_dset_chooser(), r_init_afni_vars(), RCREND_choose_CB(), RCREND_draw_CB(), RCREND_finalize_dset_CB(), RCREND_read_exec_CB(), RCREND_read_this_CB(), RCREND_save_many_CB(), RCREND_save_this_CB(), RCREND_script_CB(), RCREND_state_to_widgets(), RCREND_xhair_recv(), REND_choose_CB(), REND_draw_CB(), REND_finalize_dset_CB(), REND_read_exec_CB(), REND_read_this_CB(), REND_save_many_CB(), REND_save_this_CB(), REND_script_CB(), REND_state_to_widgets(), REND_xhair_recv(), SUMA_PopUpMessage(), T3D_check_outliers(), T3D_poperr(), T3D_save_file_CB(), and T3D_swap_CB().

#define MCW_USER_KILL   2
 

Definition at line 133 of file xutil.h.

Referenced by AFNI_crosshair_EV(), AFNI_do_many_writes(), AFNI_finalize_read_1D_CB(), AFNI_finalize_read_palette_CB(), AFNI_finalize_read_sess_CB(), AFNI_finalize_read_Web_CB(), AFNI_finalize_write_palette_CB(), AFNI_gra_send_CB(), AFNI_marks_action_CB(), AFNI_marks_quality_check(), AFNI_misc_CB(), AFNI_popup_sonnet(), AFNI_read_sess_CB(), AFNI_rescan_all_CB(), AFNI_rescan_CB(), AFNI_startup_timeout_CB(), AFNI_write_dataset_CB(), AFNI_write_many_dataset_CB(), DRAW_choose_CB(), DRAW_finalize_dset_CB(), DRAW_label_CB(), DRAW_receiver(), DRAW_saveas_finalize_CB(), drive_MCW_imseq(), DSET2_dset_recv(), DSETN_dset_recv(), GRA_opt_CB(), ISQ_butsave_EV(), ISQ_cropper(), ISQ_handle_keypress(), ISQ_saver_CB(), MCW_choose_CB(), MCW_popup_message(), NOTES_add_CB(), NOTES_choose_CB(), NOTES_save_CB(), NUD_choose_CB(), NUD_nudge_CB(), PLUG_action_CB(), PLUG_startup_plugin_CB(), PLUGIN_seq_send_CB(), PLUTO_popup_dset_chooser(), r_init_afni_vars(), RCREND_choose_CB(), RCREND_draw_CB(), RCREND_finalize_dset_CB(), RCREND_read_exec_CB(), RCREND_read_this_CB(), RCREND_save_many_CB(), RCREND_save_this_CB(), RCREND_script_CB(), RCREND_state_to_widgets(), RCREND_xhair_recv(), REND_choose_CB(), REND_draw_CB(), REND_finalize_dset_CB(), REND_read_exec_CB(), REND_read_this_CB(), REND_save_many_CB(), REND_save_this_CB(), REND_script_CB(), REND_state_to_widgets(), REND_xhair_recv(), SUMA_PopUpMessage(), T3D_check_outliers(), T3D_poperr(), T3D_save_file_CB(), and T3D_swap_CB().

#define METER_BOT   3
 

Definition at line 156 of file xutil.h.

Referenced by MCW_popup_meter().

#define METER_BOT_WIDE   4
 

Definition at line 157 of file xutil.h.

Referenced by MCW_popup_meter().

#define METER_TOP   1
 

Definition at line 154 of file xutil.h.

Referenced by MCW_popup_meter().

#define METER_TOP_WIDE   2
 

Definition at line 155 of file xutil.h.

Referenced by AFNI_fimmer_compute(), AFNI_refashion_dataset(), ISQ_saver_CB(), MCW_popup_meter(), NUD_doall_CB(), PLUTO_popup_meter(), RCREND_autocompute_CB(), RCREND_read_exec_CB(), REND_autocompute_CB(), and REND_read_exec_CB().

#define MIN a,
b       (((a)>(b)) ? (b) : (a))
 

Definition at line 27 of file xutil.h.

#define NORMAL_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )           \
   MCW_alter_widget_cursor( (w), -XC_top_left_arrow,"#ffb700","blue" ) ; \
 } while(0)

Definition at line 72 of file xutil.h.

Referenced by AFNI_add_interruptable(), AFNI_drive_set_pbar_all(), AFNI_drive_set_pbar_number(), AFNI_gra_send_CB(), AFNI_inten_av_CB(), AFNI_read_sess_CB(), AFNI_seq_send_CB(), AFNI_set_cursor(), AFNI_set_pbar_top_CB(), AFNI_splashup(), drive_MCW_grapher(), drive_MCW_imseq(), GRA_handle_keypress(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_montage_CB(), ISQ_record_open(), ISQ_statify_all(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), MCW_choose_string(), MCW_choose_timeseries(), MCW_choose_vector(), MCW_help_CB(), MCW_popup_message(), new_MCW_grapher(), new_MCW_textwin_2001(), open_MCW_imseq(), RCREND_color_bbox_CB(), RCREND_colornum_av_CB(), RCREND_open_func_CB(), RCREND_open_imseq(), REND_open_imseq(), and T3D_open_view_CB().

#define NULLIFY_ON_DESTROY pp,
ww       RWC_destroy_nullify((ww),(void **)&(pp))
 

Definition at line 209 of file xutil.h.

Referenced by AFNI_imag_pop_CB().

#define PENCIL_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
      MCW_set_widget_cursor( (w) , -XC_pencil ) ;              \
 } while(0)

Definition at line 87 of file xutil.h.

Referenced by ISQ_set_cursor_state().

#define POPUP_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )      \
      MCW_alter_widget_cursor( (w), -XC_left_ptr,"yellow","blue" ); \
 } while(0)

Definition at line 67 of file xutil.h.

Referenced by AFNI_drive_set_pbar_all(), AFNI_drive_set_pbar_number(), AFNI_inten_av_CB(), AFNI_set_pbar_top_CB(), AFNI_startup_3dview(), AFNI_view_xyz_CB(), DRAW_make_widgets(), drive_MCW_grapher(), drive_MCW_imseq(), GRA_handle_keypress(), ISQ_crop_pb_CB(), ISQ_drawing_EV(), ISQ_set_cursor_state(), ISQ_zoom_av_CB(), ISQ_zoom_pb_CB(), RCREND_color_bbox_CB(), RCREND_colornum_av_CB(), RCREND_make_widgets(), RCREND_open_func_CB(), REND_make_widgets(), and REND_open_func_CB().

#define RWC_visibilize   RWC_visibilize_widget
 

Definition at line 193 of file xutil.h.

Referenced by MCW_help_CB(), and MCW_popup_message().

#define SAVEUNDERIZE w       XtVaSetValues((w),XmNsaveUnder,True,NULL)
 

Definition at line 45 of file xutil.h.

Referenced by ISQ_but_disp_CB(), ISQ_montage_CB(), MCW_popup_message(), new_MCW_grapher(), new_MCW_pbar(), open_MCW_imseq(), RCREND_func_widgets(), and REND_func_widgets().

#define SENSITIZE w,
sen   
 

Value:

do{ Boolean fred = (Boolean) sen ;            \
       if(w != NULL){                            \
          int exp = (XtIsSensitive(w) != fred) ; \
          XtSetSensitive(w,fred) ;               \
          if(exp) MCW_expose_widget(w) ; break ; } } while(0)

Definition at line 38 of file xutil.h.

Referenced by AFNI_define_CB(), AFNI_initialize_view(), AFNI_marks_action_CB(), AFNI_marks_edits_CB(), AFNI_marks_transform_CB(), AFNI_setup_viewing(), AFNI_update_surface_widgets(), DRAW_fillin_CB(), DRAW_finalize_dset_CB(), DRAW_into_dataset(), DRAW_main(), DRAW_save_CB(), DRAW_saveas_finalize_CB(), DRAW_ttatlas_CB(), DRAW_undo_butlab(), ISQ_but_disp_CB(), ISQ_disp_act_CB(), ISQ_montage_action_CB(), ISQ_montage_CB(), ISQ_zoom_av_CB(), NUD_doall_CB(), NUD_finalize_dset_CB(), NUD_main(), NUD_nudge_CB(), NUD_redo_CB(), NUD_undo_CB(), NUD_undopush(), open_MCW_imseq(), T3D_type_av_CB(), TAG_beep_CB(), TAG_main(), and TAG_onoff().

#define TEXT_EDITABLE   2
 

Definition at line 170 of file xutil.h.

Referenced by new_MCW_textwin_2001().

#define TEXT_READONLY   1
 

Definition at line 169 of file xutil.h.

Referenced by AFNI_imag_pop_CB(), AFNI_misc_CB(), AFNI_pbar_CB(), DRAW_help_CB(), GRA_drawing_EV(), NOTES_help_CB(), NUD_help_CB(), PLUG_action_CB(), PLUTO_popup_worker(), r_main_cb_help(), RCREND_help_CB(), REND_help_CB(), TAG_help_CB(), and TTRR_action_CB().

#define VISIBILIZE_WHEN_MAPPED w       XtAddCallback(w,XmNmapCallback,RWC_visibilize_CB,NULL)
 

Definition at line 200 of file xutil.h.

Referenced by AFNI_new_fim_menu(), AFNI_plugin_button(), ISQ_record_button(), new_MCW_grapher(), new_MCW_optmenu(), new_MCW_pbar(), open_MCW_imseq(), r_main_mk_save_as_fr(), RCREND_func_widgets(), RCREND_script_menu(), REND_func_widgets(), and REND_script_menu().

#define WAIT_for_window w   
 

Value:

do{ XSync( XtDisplay(w) , False ) ;                         \
     while( XtWindow(w) == (Window) NULL ) ;         \
     RWC_sleep(1) ;                                            \
 } while(0)

Definition at line 61 of file xutil.h.

Referenced by AFNI_choose_surface_CB(), drive_MCW_grapher(), drive_MCW_imseq(), MCW_popup_message(), new_MCW_grapher(), RCREND_make_widgets(), REND_make_widgets(), and T3D_create_widgets().

#define WATCH_cursorize w   
 

Value:

do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
      MCW_set_widget_cursor( (w) , -XC_watch ) ;               \
 } while(0)

Definition at line 77 of file xutil.h.

Referenced by AFNI_set_cursor(), ISQ_statify_all(), T3D_save_file_CB(), and TTRR_setup_widgets().


Typedef Documentation

typedef void void_func()
 

Definition at line 174 of file xutil.h.


Function Documentation

void AFNI_speak char *    string,
int    nofork
 

Definition at line 2017 of file xutil.c.

Referenced by AFNI_do_many_writes(), AFNI_quit_CB(), ISQ_handle_keypress(), MAIN_workprocess(), PLUGIN_seq_send_CB(), T3D_quit_CB(), and T3D_save_file_CB().

02017 { return; }  /* dummy function */

void AFNI_speak_setvoice char *    vvv
 

Definition at line 2018 of file xutil.c.

02018 { return; }

Widget MCW_action_area Widget   ,
MCW_action_item  ,
int   
 

Definition at line 273 of file xutil.c.

References MCW_action_item::data, MCW_action_item::help_text, MCW_action_item::hint_text, MCW_action_item::make_red, MCW_hotcolor(), MCW_register_help(), MCW_register_hint(), MCW_set_widget_bg(), and TIG.

Referenced by DRAW_make_widgets(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_montage_CB(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), MCW_choose_string(), MCW_choose_timeseries(), MCW_choose_vector(), new_MCW_textwin_2001(), NOTES_make_widgets(), NUD_make_widgets(), PLUG_setup_widgets(), RCREND_make_widgets(), REND_make_widgets(), TAG_make_widgets(), and TTRR_setup_widgets().

00274 {
00275    Widget act_area , ww ;
00276    int ii ;
00277 
00278    act_area = XtVaCreateWidget( "action_area" , xmFormWidgetClass , parent ,
00279                                     XmNfractionBase , TIG*num_act - 1,
00280 
00281                                     XmNinitialResourcesPersistent , False ,
00282                                 NULL ) ;
00283 
00284    for( ii=0 ; ii < num_act ; ii++ ){
00285 
00286       ww = XtVaCreateManagedWidget(
00287                action[ii].label , xmPushButtonWidgetClass , act_area ,
00288 
00289                   XmNleftAttachment   ,
00290                        (ii) ? XmATTACH_POSITION : XmATTACH_FORM ,
00291                   XmNleftPosition     , ii*TIG ,
00292                   XmNtopAttachment    , XmATTACH_FORM ,
00293                   XmNbottomAttachment , XmATTACH_FORM ,
00294                   XmNrightAttachment  ,
00295                      (ii==num_act-1) ? XmATTACH_FORM : XmATTACH_POSITION ,
00296 
00297                   XmNrightPosition    , ii*TIG + (TIG-1) ,
00298 
00299                   XmNrecomputeSize , False ,
00300                   XmNtraversalOn   , False ,
00301                   XmNinitialResourcesPersistent , False ,
00302                NULL ) ;
00303 
00304       XtAddCallback( ww , XmNactivateCallback ,
00305                      action[ii].func_CB , action[ii].data ) ;
00306 
00307       action[ii].data = (XtPointer) ww ;  /* Feb 1998: save widget */
00308 
00309       if( action[ii].help_text != NULL )
00310          MCW_register_help( ww , action[ii].help_text ) ;
00311 
00312       if( action[ii].hint_text != NULL )
00313          MCW_register_hint( ww , action[ii].hint_text ) ;
00314 
00315       if( action[ii].make_red > 0 )                  /* for some fun */
00316          MCW_set_widget_bg( ww , MCW_hotcolor(ww) , 0 ) ;
00317       else if( action[ii].make_red < 0 )             /* for no fun at all */
00318          XtSetSensitive( ww , False ) ;
00319 
00320    }
00321 
00322    XtManageChild( act_area ) ;
00323    return act_area ;
00324 }

void MCW_alter_widget_cursor Widget   ,
int   ,
char *   ,
char *   
 

Definition at line 536 of file xutil.c.

References AFNI_yesenv(), cmap, and cur.

Referenced by drive_MCW_grapher(), drive_MCW_imseq(), and MCW_set_widget_cursor().

00537 {
00538    XColor fg , bg ;
00539    Cursor ccc ;
00540    Colormap cmap ;
00541    Display  * dis ;
00542    Boolean  good ;
00543    int ii ;
00544 
00545    static Cursor  cur_font[XC_num_glyphs] ;
00546    static Boolean first = True ;
00547 
00548    if( AFNI_yesenv("AFNI_DISABLE_CURSORS") ) return ; /* 21 Mar 2004 */
00549 
00550    if( first ){
00551       for( ii=0 ; ii < XC_num_glyphs ; ii++ ) cur_font[ii] = None ;
00552       first = False ;
00553    }
00554 
00555    if( !XtIsRealized(w) || XtWindow(w) == (Window) NULL ) return ;
00556 
00557    dis = XtDisplay(w) ;
00558 
00559    if( cur == 0 || cur <= -XC_num_glyphs ){    /* define cursor */
00560       ccc = None ;
00561    } else if( cur > 0 ){
00562       ccc = cur ;
00563    } else {
00564       ii = -cur ;
00565       if( cur_font[ii] == None ) cur_font[ii] = XCreateFontCursor( dis , ii ) ;
00566       ccc = cur_font[ii] ;
00567    }
00568 
00569    XDefineCursor( dis , XtWindow(w) , ccc ) ;
00570 
00571    if( fgname != NULL && bgname != NULL ){
00572 
00573       cmap = DefaultColormap( dis , DefaultScreen(dis) ) ;
00574 
00575       good =    XParseColor( dis , cmap , fgname , &fg )
00576              && XParseColor( dis , cmap , bgname , &bg ) ;
00577 
00578       if( good ) XRecolorCursor( dis , ccc , &fg , &bg ) ;
00579    }
00580    return ;
00581 }

void MCW_click_help_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 587 of file xutil.c.

References client_data, cur, and ev.

00588 {
00589    Widget whelp ;
00590    XmAnyCallbackStruct cbs ;
00591    XEvent ev ;
00592    static Cursor cur = 0 ;
00593    Display * dis = XtDisplay(w) ;
00594 
00595    if( cur == 0 ){
00596       cur = XCreateFontCursor( dis , XC_hand2 ) ;
00597    }
00598 
00599 #ifdef USE_LOCATE  /* old version */
00600    whelp = XmTrackingLocate( w , cur , False ) ; /* wait for user to click */
00601 #else
00602    cbs.event = &ev ;
00603    whelp = XmTrackingEvent( w , cur , False , cbs.event ) ;
00604 #endif
00605 
00606    if( whelp != NULL &&
00607        XtHasCallbacks(whelp,XmNhelpCallback) == XtCallbackHasSome ){
00608 
00609       cbs.reason = XmCR_HELP ;
00610       XtCallCallbacks( whelp , XmNhelpCallback , &cbs ) ;  /* call for help */
00611    } else {
00612       XBell( dis , 100 ) ;
00613    }
00614    return ;
00615 }

void MCW_disable_help void   
 

Definition at line 621 of file xutil.c.

References disable_helps.

Referenced by main().

00621 { disable_helps = 1 ; }

void MCW_discard_events Widget   ,
int   
 

Definition at line 222 of file xutil.c.

Referenced by GRA_drawing_EV(), GRA_handle_keypress(), ISQ_drawing_EV(), ISQ_show_bar(), ISQ_show_image(), and ISQ_show_zoom().

00223 {
00224    XEvent evjunk ;
00225 
00226    if( w == NULL || XtWindow(w) == (Window) NULL ) return ;
00227 
00228    XSync( XtDisplay(w) , False ) ;
00229    while( XCheckWindowEvent( XtDisplay(w), XtWindow(w) , ev_mask , &evjunk ) ) ;
00230    return ;
00231 }

void MCW_enable_help void   
 

Definition at line 622 of file xutil.c.

References disable_helps.

Referenced by MAIN_workprocess().

00622 { disable_helps = 0 ; }

void MCW_expose_widget Widget   
 

Definition at line 25 of file xutil.c.

Referenced by AFNI_crosshair_relabel(), AFNI_reset_func_range(), GRAF_drawing_EV(), and MCW_set_widget_label().

00026 {
00027    XExposeEvent xev;
00028    Dimension ww , hh ;
00029 
00030                                if( ! XtIsRealized(w)           ) return ;
00031                                if( ! XtIsManaged(w)            ) return ;
00032    xev.window  = XtWindow(w) ; if( xev.window == (Window) NULL ) return ;
00033    xev.type    = Expose ;
00034    xev.display = XtDisplay(w) ;
00035    xev.x       = xev.y = 0 ;
00036    XtVaGetValues( w, XmNwidth, &ww, XmNheight, &hh, NULL ) ;
00037    if( ww <= 0 || hh <= 0 ) return ;
00038    xev.width   = ww ; xev.height  = hh ;
00039    (XtClass (w))->core_class.expose( w, (XEvent *)&xev, NULL ) ;
00040    XFlush( XtDisplay(w) ) ;
00041    return ;
00042 }

int MCW_filetype char *   
 

Definition at line 900 of file xutil.c.

References MCW_nofile, MCW_readonly, and MCW_readwrite.

00901 {
00902    FILE * fff ;
00903 
00904    if( fname == NULL || strlen(fname) == 0 ) return MCW_nofile ;
00905 
00906    fff = fopen( fname , "r+" ) ;  /* open for read-update */
00907    fclose( fff ) ;
00908 
00909    if( fff != NULL ) return MCW_readwrite ;
00910 
00911    fff = fopen( fname , "r" ) ;   /* open for read-only */
00912    fclose(fff) ;
00913 
00914    if( fff != NULL ) return MCW_readonly ;
00915 
00916    return MCW_nofile ;
00917 }

Colormap MCW_get_colormap Widget   
 

Definition at line 48 of file xutil.c.

References cmap.

00049 {
00050    Colormap cmap = (Colormap) 0 ;
00051 
00052    if( w == NULL || ! XtIsWidget(w) ) return (Colormap) 0 ;
00053 
00054    XtVaGetValues( w , XmNcolormap  , &cmap , NULL ) ;
00055    return cmap ;
00056 }

int MCW_get_depth Widget   
 

Definition at line 60 of file xutil.c.

00061 {
00062    int depth = 0 ;
00063 
00064    if( w == NULL || ! XtIsWidget(w) ) return 0 ;
00065    XtVaGetValues( w , XmNdepth  , &depth , NULL ) ;
00066    return depth  ;
00067 }

Visual* MCW_get_visual Widget   
 

Definition at line 71 of file xutil.c.

00072 {
00073    Visual * visual = NULL ;
00074    Widget wpar = w ;
00075 
00076    if( w == NULL || ! XtIsWidget(w) ) return NULL ;
00077 
00078    while( XtParent(wpar) != NULL ) wpar = XtParent(wpar) ;  /* find top */
00079 
00080    XtVaGetValues( wpar , XmNvisual , &visual , NULL ) ;
00081    return visual ;
00082 }

void MCW_help_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 791 of file xutil.c.

References client_data, MCW_isitmwm, MCW_unhelp_CB(), MCW_widget_geom(), NORMAL_cursorize, RWC_getname(), RWC_visibilize, and RWC_XtPopdown().

Referenced by AFNI_startup_timeout_CB(), main(), MAIN_workprocess(), MCW_reghelp_children(), and MCW_register_help().

00792 {
00793    char * msg         = (char *) client_data ;
00794    static Widget wpop = NULL , wbut ;
00795    Position xx,yy ;
00796    XmString xstr ;
00797    int ww,hh , sw,sh ;
00798    char * def ;
00799 
00800 #ifndef USE_LOCATE
00801    XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct *) call_data ;
00802 #endif
00803 
00804    if( w == NULL ){
00805       if( wpop != NULL ) XtUnmapWidget(wpop) ;
00806       return ;
00807    }
00808 
00809    if( wpop == NULL || ! XtIsWidget(wpop) ){
00810 
00811       Widget wpar = w ;
00812 
00813       while( XtParent(wpar) != NULL ) wpar = XtParent(wpar) ;  /* find top */
00814 
00815       wpop = XtVaCreatePopupShell(
00816               "help" , xmDialogShellWidgetClass , wpar ,
00817                  XmNmappedWhenManaged , False ,
00818                  XmNallowShellResize , True ,
00819                  XmNdeleteResponse , XmDO_NOTHING ,
00820                  XmNinitialResourcesPersistent , False ,
00821               NULL ) ;
00822 
00823 #if 0
00824       def = XGetDefault(XtDisplay(wpar),"AFNI","helpborder") ;
00825 #else
00826       def = RWC_getname(XtDisplay(wpar),"helpborder") ;
00827 #endif
00828       if( def != NULL && strcmp(def,"False") == 0 ){
00829          XtVaSetValues( wpop ,
00830                            XmNoverrideRedirect , True ,
00831                         NULL ) ;
00832       } else if( MCW_isitmwm(wpar) ){
00833          XtVaSetValues( wpop ,
00834                            XmNmwmDecorations , MWM_DECOR_BORDER ,
00835                            XmNmwmFunctions   , MWM_FUNC_MOVE ,
00836                         NULL ) ;
00837       }
00838 
00839       wbut = XtVaCreateManagedWidget(
00840                 "help" , xmPushButtonWidgetClass , wpop ,
00841                    XmNalignment , XmALIGNMENT_BEGINNING ,
00842                    XmNinitialResourcesPersistent , False ,
00843                 NULL ) ;
00844 
00845       XtAddCallback( wbut , XmNactivateCallback , MCW_unhelp_CB , wpop ) ;
00846 
00847       XmUpdateDisplay( wpar ) ;
00848       RWC_XtPopdown( wpop ) ;
00849 
00850       XmAddWMProtocolCallback(
00851            wpop ,
00852            XmInternAtom( XtDisplay(wpop) , "WM_DELETE_WINDOW" , False ) ,
00853            MCW_unhelp_CB , wpop ) ;
00854 
00855       if( ! XtIsRealized(wpar) ) return ;
00856    }
00857 
00858    if( msg == NULL || strlen(msg) == 0 ) return ; /* no popup if no message */
00859 
00860    xstr = XmStringCreateLtoR( msg , XmFONTLIST_DEFAULT_TAG ) ;
00861    XtVaSetValues( wbut , XmNlabelString , xstr , NULL ) ;
00862    XmStringFree( xstr ) ;
00863 
00864 #ifndef USE_LOCATE
00865    if( cbs != NULL && cbs->event != NULL
00866                    && cbs->event->type == ButtonRelease ){
00867       XButtonEvent * xev = (XButtonEvent *) cbs->event ;
00868       xx = xev->x_root ;
00869       yy = xev->y_root ;
00870    } else
00871 #endif
00872    XtTranslateCoords( w , 15,15 , &xx , &yy ) ;    /* coordinates on root */
00873 
00874    MCW_widget_geom( wpop , &ww,&hh , NULL,NULL ) ; /* widget width and height */
00875    sw = WidthOfScreen (XtScreen(wpop)) ;           /* screen width and height */
00876    sh = HeightOfScreen(XtScreen(wpop)) ;
00877 
00878    if( xx+ww+3 >= sw && ww <= sw ) xx = sw-ww ;    /* make sure is on screen */
00879    if( yy+hh+3 >= sh && hh <= sh ) yy = sh-hh ;
00880 
00881    XtVaSetValues( wpop , XmNx , (int) xx , XmNy , (int) yy , NULL ) ;
00882    XtPopup( wpop , XtGrabNone ) ;
00883    RWC_visibilize(wpop) ;  /* 27 Sep 2000 */
00884    NORMAL_cursorize(wpop) ;
00885    return ;
00886 }

void MCW_hint_toggle void   
 

Definition at line 636 of file xutil.c.

References liteClue, RWC_getname(), and XgcNwaitPeriod.

Referenced by AFNI_misc_CB(), main(), and MAIN_workprocess().

00637 {
00638 #define PBIG 999999
00639    int period ;
00640    char * pdef ;
00641 
00642    if( liteClue == NULL ) return ;
00643 
00644    XtVaGetValues( liteClue , XgcNwaitPeriod , &period , NULL ) ;
00645    if( period < PBIG ){
00646       period = PBIG ;
00647    } else {
00648 #if 0
00649       pdef = XGetDefault(XtDisplay(liteClue),"AFNI","waitperiod") ;
00650 #else
00651       pdef = RWC_getname(XtDisplay(liteClue),"waitperiod") ;
00652 #endif
00653       if( pdef == NULL ){
00654          period = 1066 ;
00655       } else {
00656          period = strtol( pdef , NULL , 10 ) ;
00657          if( period < 100 ) period = 1066 ;
00658       }
00659    }
00660    XtVaSetValues( liteClue , XgcNwaitPeriod , period , NULL ) ;
00661    return ;
00662 }

char* MCW_hotcolor Widget    w
 

Definition at line 235 of file xutil.c.

References RWC_getname().

Referenced by AFNI_make_file_dialog(), MCW_action_area(), MCW_choose_multi_editable_strlist(), and PLUTO_set_butcolor().

00236 {
00237    static char *redcolor = NULL ;
00238 
00239    if( redcolor == NULL ){
00240      char *xdef = RWC_getname( (w!=NULL) ? XtDisplay(w) : NULL, "hotcolor" ) ;
00241 
00242      redcolor = (xdef != NULL) ? (xdef) : ("red4") ;
00243    }
00244    return redcolor ;
00245 }

void MCW_invert_widget Widget   
 

Definition at line 101 of file xutil.c.

References cmap.

Referenced by AFNI_controller_panel_CB(), AFNI_finalize_dataset_CB(), AFNI_gra_send_CB(), AFNI_initialize_view(), AFNI_marks_action_CB(), AFNI_seq_send_CB(), AFNI_set_cursor(), AFNI_view_xyz_CB(), AV_textact_CB(), DRAW_done_CB(), DRAW_quit_CB(), DRAW_save_CB(), DRAW_saveas_finalize_CB(), ISQ_crop_pb_CB(), ISQ_cropper(), ISQ_disp_act_CB(), ISQ_drawing_EV(), ISQ_getimage(), ISQ_montage_action_CB(), ISQ_record_CB(), ISQ_record_send_CB(), ISQ_redisplay(), ISQ_show_zoom(), ISQ_zoom_av_CB(), ISQ_zoom_pb_CB(), MCW_choose_CB(), NOTES_save_CB(), NUD_doall_CB(), NUD_quit_CB(), NUD_update_base(), PLUG_optional_toggle_CB(), PLUG_setup_widgets(), r_save_dataset_as(), RCREND_draw_CB(), RCREND_open_func_CB(), RCREND_reload_dataset(), RCREND_textact_CB(), REND_draw_CB(), REND_open_func_CB(), REND_reload_dataset(), REND_textact_CB(), SUMA_set_cmap_options(), SUMA_SetRangeTableTit_EV(), SUMA_SurfInfo_destroyed(), SUMA_SurfInfo_open(), SUMA_ViewerInfo_destroyed(), SUMA_ViewerInfo_open(), T3D_imseq_CB(), T3D_open_view_CB(), TAG_clear_CB(), TAG_clearall_CB(), TAG_reset_widgets(), TAG_set_CB(), TTRR_action_CB(), and TTRR_av_CB().

00102 {
00103    Pixel bg_pix , topsh_pix , botsh_pix , fg_pix , sel_pix ;
00104    Colormap cmap ;
00105 
00106    if( ! XtIsWidget(w) ) return ;
00107 
00108    XtVaGetValues( w , XmNforeground , &bg_pix ,  /* foreground -> bg */
00109                       XmNbackground , &fg_pix ,  /* background -> fg */
00110                       XmNcolormap   , &cmap ,
00111                   NULL ) ;
00112 
00113    XmGetColors( XtScreen(w) , cmap , bg_pix ,
00114                 NULL , &topsh_pix , &botsh_pix , &sel_pix ) ;
00115 
00116    XtVaSetValues( w ,
00117                     XmNtopShadowColor    , topsh_pix ,
00118                     XmNbottomShadowColor , botsh_pix ,
00119                     XmNselectColor       , sel_pix   ,
00120                     XmNarmColor          , sel_pix   ,
00121                     XmNborderColor       , fg_pix    ,
00122                     XmNforeground        , fg_pix    ,
00123                     XmNbackground        , bg_pix    ,
00124                   NULL ) ;
00125 
00126    XSync( XtDisplay(w) , False ) ;  /* make it happen NOW */
00127    XmUpdateDisplay( w ) ;
00128    return ;
00129 }

void MCW_manage_widgets Widget *   ,
int   
 

Definition at line 251 of file xutil.c.

Referenced by drive_MCW_imseq().

00252 {
00253    int ii ;
00254    if( war == NULL ) return ;
00255    for( ii=0 ; ii < nar ; ii++ )
00256       if( war[ii] != (Widget) 0 ) XtManageChild( war[ii] ) ;
00257    return ;
00258 }

void MCW_message_alter Widget   ,
char *   
 

Definition at line 474 of file xutil.c.

References ENTRY, and MCW_set_widget_label().

00475 {
00476    Widget wlab ;
00477    Widget *children=NULL ;
00478    int  num_children=0 ;
00479    XmString xstr ;
00480 
00481 ENTRY("MCW_message_alter") ;
00482 
00483    if( wmsg == NULL || msg == NULL || msg[0] == '\0' ) EXRETURN ;
00484 
00485    XtVaGetValues( wmsg , XmNchildren    , &children ,
00486                          XmNnumChildren , &num_children , NULL ) ;
00487    if( num_children < 1 ) EXRETURN ;
00488 
00489    MCW_set_widget_label( children[0] , msg ) ;
00490    EXRETURN ;
00491 }

void MCW_message_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 498 of file xutil.c.

Referenced by MCW_popup_message().

00499 {
00500 #ifdef ALLOW_TIMER_KILL
00501    XtIntervalId tid ;
00502 
00503    XtVaGetValues( w , XmNuserData , &tid , NULL ) ;  /* get timer id */
00504    XtDestroyWidget( XtParent(w) ) ;
00505 
00506    if( tid > 0 ) XtRemoveTimeOut( tid ) ;  /* if a timer exists, kill it */
00507 #else
00508    XtDestroyWidget( XtParent(w) ) ;
00509 #endif
00510 }

void MCW_message_timer_CB XtPointer   ,
XtIntervalId *   
 

Definition at line 516 of file xutil.c.

References client_data.

Referenced by MCW_popup_message().

00517 {
00518    XtDestroyWidget( (Widget) client_data ) ;
00519 }

void MCW_popdown_meter Widget   
 

Definition at line 1048 of file xutil.c.

Referenced by AFNI_fimmer_compute(), AFNI_refashion_dataset(), ISQ_saver_CB(), NUD_doall_CB(), PLUTO_popdown_meter(), RCREND_autocompute_CB(), RCREND_read_exec_CB(), REND_autocompute_CB(), and REND_read_exec_CB().

01049 {
01050    if( wscal == NULL ) return ;
01051    XtDestroyWidget( XtParent(wscal) ) ;
01052    return ;
01053 }

Widget MCW_popup_message Widget   ,
char *   ,
int   
 

Definition at line 339 of file xutil.c.

References AFNI_noenv(), ENTRY, ev, free, malloc, MCW_CALLER_KILL, MCW_isitmwm, MCW_message_CB(), MCW_message_timer_CB(), MCW_TIMER_KILL, MCW_USER_KILL, MCW_widget_geom(), NORMAL_cursorize, RETURN, RWC_visibilize, SAVEUNDERIZE, and WAIT_for_window.

Referenced by AFNI_crosshair_EV(), AFNI_do_many_writes(), AFNI_finalize_read_1D_CB(), AFNI_finalize_read_palette_CB(), AFNI_finalize_read_sess_CB(), AFNI_finalize_read_Web_CB(), AFNI_finalize_write_palette_CB(), AFNI_gra_send_CB(), AFNI_marks_action_CB(), AFNI_marks_quality_check(), AFNI_misc_CB(), AFNI_popup_sonnet(), AFNI_read_sess_CB(), AFNI_rescan_all_CB(), AFNI_rescan_CB(), AFNI_startup_timeout_CB(), AFNI_write_dataset_CB(), AFNI_write_many_dataset_CB(), DRAW_choose_CB(), DRAW_finalize_dset_CB(), DRAW_label_CB(), DRAW_receiver(), DRAW_saveas_finalize_CB(), drive_MCW_imseq(), GRA_opt_CB(), ISQ_butsave_EV(), ISQ_cropper(), ISQ_handle_keypress(), ISQ_saver_CB(), ISQ_statify_all(), MCW_choose_CB(), NOTES_add_CB(), NOTES_choose_CB(), NOTES_save_CB(), NUD_choose_CB(), NUD_nudge_CB(), PLUG_action_CB(), PLUG_startup_plugin_CB(), PLUGIN_seq_send_CB(), PLUTO_popup_dset_chooser(), PLUTO_popup_worker(), r_init_afni_vars(), RCREND_choose_CB(), RCREND_draw_CB(), RCREND_finalize_dset_CB(), RCREND_read_exec_CB(), RCREND_read_this_CB(), RCREND_save_many_CB(), RCREND_save_this_CB(), RCREND_script_CB(), RCREND_state_to_widgets(), RCREND_xhair_recv(), REND_choose_CB(), REND_draw_CB(), REND_finalize_dset_CB(), REND_read_exec_CB(), REND_read_this_CB(), REND_save_many_CB(), REND_save_this_CB(), REND_script_CB(), REND_state_to_widgets(), REND_xhair_recv(), SUMA_PopUpMessage(), T3D_check_outliers(), T3D_poperr(), T3D_save_file_CB(), and T3D_swap_CB().

00340 {
00341    Widget wmsg , wlab ;
00342    int wx,hy,xx,yy , xp,yp , scr_width,scr_height , xr,yr , xpr,ypr ;
00343    Screen *scr ;
00344    XEvent ev ;
00345 
00346 ENTRY("MCW_popup_message") ;
00347 
00348    if( ! XtIsRealized( wparent ) ||
00349        msg == NULL               || strlen(msg) == 0 ) RETURN(NULL) ;
00350 
00351    /* set position for message box based on parent and screen geometry */
00352 
00353    MCW_widget_geom( wparent , &wx,&hy,&xx,&yy ) ;  /* geometry of parent */
00354 
00355 #if 1
00356    { Position xroot , yroot ;
00357      XtTranslateCoords( wparent, 0,0, &xroot,&yroot ) ; /* root coords */
00358      xr = (int) xroot ; yr = (int) yroot ;
00359    }
00360 #else
00361      xr = xx ; yr = yy ;  /* the old code, essentially */
00362 #endif
00363 
00364    scr        = XtScreen( wparent ) ;
00365    scr_width  = WidthOfScreen( scr ) ;
00366    scr_height = HeightOfScreen( scr ) ;
00367 
00368    xp = xx+8 ;  xpr = xr+8 ;
00369         if( xpr+50 > scr_width ){ xp -= 100 ; xpr -= 100 ; } /* too right */
00370    else if( xpr+10 < 0 )        { xpr = xp = 1 ; }           /* too left  */
00371 
00372    yp = yy+hy+8 ;  ypr = yr+hy+8 ;
00373         if( ypr+50 > scr_height ){ yp = yy-8 ; ypr = yr-100 ;} /* too down */
00374    else if( ypr+10 < 0 )         { ypr = yp = 1 ;            } /* too up   */
00375 
00376    /* create a popup shell with a label */
00377 
00378    wmsg = XtVaCreatePopupShell(
00379              "help" , xmDialogShellWidgetClass , wparent ,
00380                 XmNx , xpr ,
00381                 XmNy , ypr ,
00382                 XmNinitialResourcesPersistent , False ,
00383              NULL ) ;
00384 
00385    if( MCW_isitmwm( wparent ) ){
00386       XtVaSetValues( wmsg ,
00387                         XmNmwmDecorations , MWM_DECOR_BORDER ,
00388                         XmNmwmFunctions   , MWM_FUNC_MOVE ,
00389                      NULL ) ;
00390    }
00391 
00392    switch( msg_type & (MCW_CALLER_KILL | MCW_USER_KILL) ){
00393 
00394       case MCW_CALLER_KILL:
00395 
00396          wlab = XtVaCreateManagedWidget(
00397                   "help" , xmLabelWidgetClass , wmsg ,
00398                      XtVaTypedArg,XmNlabelString,XmRString,msg,strlen(msg)+1,
00399                      XmNalignment , XmALIGNMENT_BEGINNING ,
00400                      XmNinitialResourcesPersistent , False ,
00401                   NULL ) ;
00402       break ;
00403 
00404       default:
00405       case MCW_USER_KILL:{
00406          static int first=1 ; char *mmsg = msg ;     /* 'first' stuff  */
00407          if( first ){                                /* on 06 Apr 2004 */
00408            if( !AFNI_noenv("AFNI_CLICK_MESSAGE") ){
00409              mmsg = (char *) malloc(strlen(msg)+99) ;
00410              strcpy(mmsg,msg) ;
00411              strcat(mmsg,"\n [---------------] "
00412                          "\n [ Click in Text ] "
00413                          "\n [ to Pop Down!! ]\n" ) ;
00414            }
00415          }
00416 
00417          wlab = XtVaCreateManagedWidget(
00418                   "help" , xmPushButtonWidgetClass , wmsg ,
00419                      XtVaTypedArg,XmNlabelString,XmRString,mmsg,strlen(msg)+1,
00420                      XmNalignment , XmALIGNMENT_BEGINNING ,
00421                      XmNinitialResourcesPersistent , False ,
00422                   NULL ) ;
00423 
00424          if( mmsg != msg ){ free((void *)mmsg); first = 0; }
00425 
00426          XtAddCallback( wlab , XmNactivateCallback , MCW_message_CB , NULL ) ;
00427       }
00428       break ;
00429    }
00430 
00431    SAVEUNDERIZE(wmsg) ;           /* 27 Feb 2001 */
00432    XtPopup( wmsg , XtGrabNone ) ;
00433 
00434    /* now wait until the label is exposed, and make sure it appears;
00435       the reason for this stuff is that this routine is likely to be
00436       called by a long computation that won't return control to Xt   */
00437 
00438    WAIT_for_window(wlab) ;
00439    XSync( XtDisplay(wlab) , False ) ;
00440 #if 0
00441    XMaskEvent( XtDisplay(wlab) , ExposureMask , &ev ) ;/* wait for expose  */
00442 #else
00443    XWindowEvent( XtDisplay(wlab) , XtWindow(wlab) , ExposureMask , &ev ) ;
00444 #endif
00445    XPutBackEvent( XtDisplay(wlab) , &ev ) ;            /* put expose back  */
00446    XSync( XtDisplay(wlab) , False ) ;
00447    XmUpdateDisplay( wlab ) ;                           /* show it for sure */
00448 
00449    /* now add the timer kill, if wanted */
00450 
00451 #define ALLOW_TIMER_KILL
00452 #ifdef ALLOW_TIMER_KILL
00453    if( (msg_type & MCW_TIMER_KILL) != 0 ){
00454       XtIntervalId tid ;
00455 
00456       tid = XtAppAddTimeOut( XtWidgetToApplicationContext( wmsg ) ,
00457                              33333 , MCW_message_timer_CB , wmsg   ) ;
00458 
00459       XtVaSetValues( wlab , XmNuserData ,  tid , NULL );/* put tid on wlab; */
00460    } else {                                             /* shells don't */
00461       XtVaSetValues( wlab , XmNuserData , 0 , NULL ) ;  /* have XmNuserData */
00462    }
00463 #endif
00464 
00465    RWC_visibilize(wmsg) ;  /* 27 Sep 2000 */
00466    NORMAL_cursorize(wmsg) ;
00467    RETURN(wmsg) ;
00468 }

Widget MCW_popup_meter Widget   ,
int   
 

Definition at line 963 of file xutil.c.

References ENTRY, ev, MCW_isitmwm, MCW_widget_geom(), METER_BOT, METER_BOT_WIDE, METER_HEIGHT, METER_TOP, METER_TOP_WIDE, METER_WIDTH, position, and RETURN.

Referenced by AFNI_fimmer_compute(), AFNI_refashion_dataset(), ISQ_saver_CB(), NUD_doall_CB(), PLUTO_popup_meter(), RCREND_autocompute_CB(), RCREND_read_exec_CB(), REND_autocompute_CB(), and REND_read_exec_CB().

00964 {
00965    Widget wmsg , wscal ;
00966    int wx,hy,xx,yy , xp,yp , scr_width,scr_height , xr,yr , xpr,ypr , wid ;
00967    Screen * scr ;
00968    XEvent ev ;
00969    Position xroot , yroot ;
00970 
00971 ENTRY("MCW_popup_meter") ;
00972 
00973    if( wparent == NULL || ! XtIsRealized( wparent ) ) RETURN(NULL) ;
00974 
00975    /* set position parent and screen geometry */
00976 
00977    MCW_widget_geom( wparent , &wx,&hy,&xx,&yy ) ;     /* geometry of parent */
00978    XtTranslateCoords( wparent, 0,0, &xroot,&yroot ) ; /* root coords of parent */
00979    xr = (int) xroot ; yr = (int) yroot ;
00980 
00981    scr        = XtScreen( wparent ) ;
00982    scr_width  = WidthOfScreen( scr ) ;
00983    scr_height = HeightOfScreen( scr ) ;
00984 
00985    switch( position ){
00986 
00987       default:
00988       case METER_TOP:
00989       case METER_TOP_WIDE:
00990          xpr = xr ;
00991          ypr = yr - METER_HEIGHT-2 ;
00992          wid = (position==METER_TOP_WIDE) ? wx : METER_WIDTH ;
00993          if( ypr < 0 ) ypr = yr+hy+1 ;
00994       break ;
00995 
00996       case METER_BOT:
00997       case METER_BOT_WIDE:
00998          xpr = xr ;
00999          ypr = yr+hy+1 ;
01000          wid = (position==METER_BOT_WIDE) ? wx : METER_WIDTH ;
01001          if( ypr+METER_HEIGHT > scr_height ) ypr = yr - METER_HEIGHT-2 ;
01002       break ;
01003    }
01004 
01005    /* create a popup shell with a scale */
01006 
01007    wmsg = XtVaCreatePopupShell(
01008              "menu" , xmDialogShellWidgetClass , wparent ,
01009                 XmNx , xpr ,
01010                 XmNy , ypr ,
01011                 XmNborderWidth , 0 ,
01012                 XmNoverrideRedirect , True ,
01013                 XmNinitialResourcesPersistent , False ,
01014              NULL ) ;
01015 
01016 #if 0
01017    if( MCW_isitmwm( wparent ) ){
01018       XtVaSetValues( wmsg ,
01019                         XmNmwmDecorations , MWM_DECOR_BORDER ,
01020                         XmNmwmFunctions   , MWM_FUNC_MOVE ,
01021                      NULL ) ;
01022    }
01023 #endif
01024 
01025    wscal = XtVaCreateManagedWidget(
01026             "menu" , xmScaleWidgetClass , wmsg ,
01027                XmNminimum , 0 ,
01028                XmNmaximum , 100 ,
01029                XmNshowValue , False ,
01030                XmNvalue , 0 ,
01031                XmNorientation , XmHORIZONTAL ,
01032                XmNscaleWidth , wid ,
01033                XmNscaleHeight , METER_HEIGHT ,
01034                XmNborderWidth , 0 ,
01035                XmNhighlightThickness , 0 ,
01036                XmNshadowThickness , 0 ,
01037                XmNtraversalOn , False ,
01038                XmNinitialResourcesPersistent , False ,
01039             NULL ) ;
01040 
01041    XtPopup( wmsg , XtGrabNone ) ;
01042 
01043    RETURN(wscal) ;
01044 }

void MCW_reghelp_children Widget   ,
char *   
 

Definition at line 771 of file xutil.c.

References MCW_help_CB().

Referenced by AFNI_make_surface_widgets(), DRAW_make_widgets(), drive_MCW_imseq(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_montage_CB(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), NUD_make_widgets(), open_MCW_imseq(), RCREND_func_widgets(), RCREND_make_cutout(), RCREND_make_widgets(), REND_make_cutout(), REND_make_widgets(), SUMA_BuildMenu(), SUMA_cb_createSumaCont(), T3D_create_widgets(), and TAG_make_widgets().

00772 {
00773    Widget * children ;
00774    int  num_children , ic ;
00775 
00776    if( disable_helps ) return ;
00777    if( w == NULL || msg == NULL ) return ;
00778 
00779    XtVaGetValues( w , XmNchildren    , &children ,
00780                       XmNnumChildren , &num_children , NULL ) ;
00781 
00782    XtAddCallback( w , XmNhelpCallback , MCW_help_CB , msg ) ;
00783 
00784    for( ic=0 ; ic < num_children ; ic++ )
00785       XtAddCallback( children[ic] , XmNhelpCallback , MCW_help_CB , msg ) ;
00786    return ;
00787 }

void MCW_reghint_children Widget   ,
char *   
 

Definition at line 726 of file xutil.c.

References clueless, and MCW_register_hint().

Referenced by AFNI_make_surface_widgets(), AFNI_new_fim_menu(), DRAW_make_widgets(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_montage_CB(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), new_MCW_grapher(), NUD_make_widgets(), open_MCW_imseq(), PLUG_setup_widgets(), RCREND_func_widgets(), RCREND_make_widgets(), RCREND_script_menu(), REND_make_widgets(), REND_script_menu(), T3D_create_widgets(), and TAG_make_widgets().

00727 {
00728    Widget * children=NULL ;
00729    int  num_children=0 , ic ;
00730 
00731    if( disable_helps ) return ;
00732    if( w == NULL || msg == NULL || clueless == 1 || !XtIsWidget(w) ) return ;
00733 
00734    XtVaGetValues( w , XmNchildren    , &children ,
00735                       XmNnumChildren , &num_children , NULL ) ;
00736 
00737    MCW_register_hint( w , msg ) ;
00738    if( children == NULL || num_children == 0 ) return ;
00739 
00740    for( ic=0 ; ic < num_children ; ic++ )
00741       MCW_register_hint( children[ic] , msg ) ;
00742 
00743    return ;
00744 }

void MCW_register_help Widget   ,
char *   
 

Definition at line 761 of file xutil.c.

References MCW_help_CB().

Referenced by AFNI_imag_pop_CB(), AFNI_make_widgets(), AFNI_new_fim_menu(), AFNI_plugin_button(), DRAW_make_widgets(), drive_MCW_imseq(), ISQ_but_disp_CB(), ISQ_record_button(), MCW_action_area(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_timeseries(), new_MCW_grapher(), NOTES_make_note(), NOTES_make_widgets(), NUD_make_widgets(), open_MCW_imseq(), PLUG_setup_widgets(), RCREND_make_cutout(), RCREND_make_widgets(), REND_make_cutout(), REND_make_widgets(), SUMA_cb_createSumaCont(), SUMA_cb_createSurfaceCont(), SUMA_cb_createViewerCont(), SUMA_CreateArrowField(), SUMA_CreateDrawROIWindow(), SUMA_CreateTable(), SUMA_CreateTextField(), SUMA_set_cmap_options(), T3D_create_widgets(), and TAG_make_widgets().

00762 {
00763    if( disable_helps ) return ;
00764    if( w == NULL || msg == NULL ) return ;
00765    XtAddCallback( w , XmNhelpCallback , MCW_help_CB , msg ) ;
00766    return ;
00767 }

void MCW_register_hint Widget   ,
char *   
 

Definition at line 678 of file xutil.c.

References clueless, liteClue, my_getenv(), RES_CONVERT, and XcgLiteClueAddWidget().

Referenced by AFNI_hintize_pbar(), AFNI_imag_pop_CB(), AFNI_make_surface_widgets(), AFNI_new_fim_menu(), AFNI_plugin_button(), AFNI_thr_scale_CB(), AFNI_update_surface_widgets(), DRAW_make_widgets(), drive_MCW_imseq(), ISQ_but_disp_CB(), ISQ_record_button(), ISQ_set_barhint(), MCW_action_area(), MCW_bbox_hints(), MCW_reghint_children(), new_MCW_grapher(), NOTES_make_note(), NOTES_make_widgets(), NUD_make_widgets(), open_MCW_imseq(), PLUG_setup_widgets(), r_gr_mk_fill_buttons(), r_INT_mk_app_buttons(), r_wt_mk_fill_buttons(), RCREND_func_widgets(), REND_func_widgets(), SUMA_BuildMenu(), SUMA_cb_createSumaCont(), SUMA_cb_createSurfaceCont(), SUMA_cb_createViewerCont(), SUMA_CreateArrowField(), SUMA_CreateDrawROIWindow(), SUMA_CreateTable(), SUMA_CreateTextField(), SUMA_set_cmap_options(), T3D_create_widgets(), and TAG_make_widgets().

00679 {
00680    if( disable_helps ) return ;
00681    if( w == NULL || msg == NULL || clueless == 1 || !XtIsWidget(w) ) return ;
00682 
00683    if( clueless == -1 ){
00684       char * hh = my_getenv("AFNI_HINTS") ;
00685       if( hh != NULL && ( strncmp(hh,"KILL",4)==0 ||
00686                           strncmp(hh,"kill",4)==0 ||
00687                           strncmp(hh,"Kill",4)==0 ) ){
00688          clueless = 1 ;
00689          return ;
00690       } else {
00691          clueless = 0 ;
00692       }
00693    }
00694 
00695    /*-- Do we have to make the hint-displaying widget? --*/
00696 
00697    if( liteClue == NULL ){
00698       Widget wpar = w ;
00699       char * cfont ;
00700 
00701       while( XtParent(wpar) != NULL ) wpar = XtParent(wpar) ;  /* find top */
00702 
00703       cfont = XGetDefault(XtDisplay(wpar),"AFNI","cluefont") ;
00704       if( cfont != NULL ){
00705          liteClue = XtVaCreatePopupShell( "help", xcgLiteClueWidgetClass, wpar,
00706                                              RES_CONVERT(XtNfontSet,cfont) ,
00707                                           NULL);
00708       } else {
00709          liteClue = XtVaCreatePopupShell( "help", xcgLiteClueWidgetClass, wpar,
00710                                           NULL);
00711       }
00712       if( liteClue == NULL ) return ;
00713 
00714       XtVaSetValues( liteClue , XmNsaveUnder , True , NULL ) ;  /* 22 Jan 1999 */
00715    }
00716 
00717    /*-- attach the hint to the widget, if it is a widget --*/
00718 
00719    if( XtIsWidget(w) ) XcgLiteClueAddWidget( liteClue, w, msg, 0,0 ) ;
00720 
00721    return ;
00722 }

void MCW_set_colormap Widget   ,
Colormap   
 

Definition at line 89 of file xutil.c.

References cmap.

00090 {
00091    if( w == NULL || ! XtIsWidget(w) ) return ;
00092    XtVaSetValues( w , XmNcolormap  , cmap , NULL ) ;
00093    return ;
00094 }

void MCW_set_meter Widget   ,
int   
 

Definition at line 1057 of file xutil.c.

Referenced by AFNI_fimmer_compute(), AFNI_refashion_dataset(), ISQ_saver_CB(), NUD_doall_CB(), PLUTO_set_meter(), RCREND_autocompute_CB(), RCREND_read_exec_CB(), REND_autocompute_CB(), and REND_read_exec_CB().

01058 {
01059    int val , old ;
01060 
01061 #undef  NCOL
01062 #define NCOL 30
01063 #ifdef NCOL
01064    static int icol=0 ;
01065    static char *cname[] = {
01066       "#0000ff", "#3300ff", "#6600ff", "#9900ff", "#cc00ff",
01067       "#ff00ff", "#ff00cc", "#ff0099", "#ff0066", "#ff0033",
01068       "#ff0000", "#ff3300", "#ff6600", "#ff9900", "#ffcc00",
01069       "#ffff00", "#ccff00", "#99ff00", "#66ff00", "#33ff00",
01070       "#00ff00", "#00ff33", "#00ff66", "#00ff99", "#00ffcc",
01071       "#00ffff", "#00ccff", "#0099ff", "#0066ff", "#0033ff"
01072     } ;
01073 #endif
01074 
01075    val = percent ;
01076    if( wscal == NULL || val < 0 || val > 100 ) return ;
01077 
01078    XmScaleGetValue( wscal , &old ) ; if( val == old ) return ;
01079 
01080    XtVaSetValues( wscal , XmNvalue , val , NULL ) ;
01081 
01082 #ifdef NCOL
01083    { Widget ws = XtNameToWidget(wscal,"Scrollbar") ;
01084      if( ws != NULL )
01085      XtVaSetValues( ws ,
01086                      XtVaTypedArg , XmNtroughColor , XmRString ,
01087                                     cname[icol] , strlen(cname[icol])+1 ,
01088                    NULL ) ;
01089      icol = (icol+1) % NCOL ;
01090    }
01091 #endif
01092 
01093    XmUpdateDisplay(wscal) ;
01094    return ;
01095 }

void MCW_set_widget_bg Widget   ,
char *   ,
Pixel   
 

Definition at line 138 of file xutil.c.

References cmap.

Referenced by AFNI_make_file_dialog(), AFNI_make_surface_widgets(), AFNI_new_fim_menu(), alter_MCW_pbar(), ISQ_surfgraph_draw(), MCW_action_area(), MCW_choose_multi_editable_strlist(), MCW_choose_ovcolor(), MCW_DC_ovcolor_text(), new_MCW_colormenu(), new_MCW_grapher(), new_MCW_pbar(), open_MCW_imseq(), PBAR_set_CB(), PBAR_set_panecolor(), rotate_MCW_pbar(), SUMA_cb_createSumaCont(), SUMA_CreateDrawROIWindow(), and T3D_create_widgets().

00139 {
00140    Pixel bg_pix , topsh_pix , botsh_pix , fg_pix , sel_pix ;
00141    Colormap cmap ;
00142 
00143 #if 1
00144    if( ! XtIsWidget(w) ) return ;
00145 #else
00146    if( ! XtIsObject(w) ) return ;
00147 #endif
00148 
00149 
00150    if( cname != NULL && strlen(cname) > 0 ){
00151       XtVaSetValues( w ,
00152                      XtVaTypedArg , XmNbackground , XmRString ,
00153                                     cname , strlen(cname)+1 ,
00154                      NULL ) ;
00155 
00156       XtVaGetValues( w , XmNbackground , &bg_pix , NULL ) ;
00157    } else {
00158       bg_pix = pix ;
00159    }
00160 
00161 #if 0
00162    XtVaGetValues( w , XmNcolormap , &cmap , NULL ) ;
00163    XmGetColors( XtScreen(w) , cmap , bg_pix ,
00164                 &fg_pix , &topsh_pix , &botsh_pix , &sel_pix ) ;
00165    XtVaSetValues( w ,
00166                     XmNtopShadowColor    , topsh_pix ,
00167                     XmNbottomShadowColor , botsh_pix ,
00168                     XmNselectColor       , sel_pix   ,
00169                     XmNarmColor          , sel_pix   ,
00170                     XmNborderColor       , fg_pix    ,
00171                     XmNforeground        , fg_pix    ,
00172                     XmNbackground        , bg_pix    ,
00173                   NULL ) ;
00174    XFlush( XtDisplay(w) ) ;
00175 #else
00176    XmChangeColor( w , bg_pix ) ;
00177 #endif
00178 
00179    return ;
00180 }

void MCW_set_widget_cursor Widget   ,
int   
 

Definition at line 528 of file xutil.c.

References cur, and MCW_alter_widget_cursor().

Referenced by AFNI_add_interruptable(), and SUMA_UpdateViewerCursor().

00529 {
00530    MCW_alter_widget_cursor( w , cur , NULL,NULL ) ;
00531    return ;
00532 }

void MCW_set_widget_label Widget   ,
char *   
 

Definition at line 184 of file xutil.c.

References MCW_expose_widget().

Referenced by AFNI_brick_to_mri(), AFNI_do_bkgd_lab(), AFNI_initialize_view(), AFNI_misc_CB(), AFNI_quit_CB(), AFNI_set_thr_pval(), AFNI_setup_viewing(), AFNI_update_surface_widgets(), drive_MCW_imseq(), GRAF_drawing_EV(), GRAF_pasdrawing_EV(), ISQ_but_done_CB(), ISQ_draw_winfo(), MCW_message_alter(), new_MCW_pbar(), PBAR_button_EV(), PBAR_resize_CB(), PBAR_show_bigmode(), RCREND_done_CB(), RCREND_done_timeout_CB(), RCREND_set_thr_pval(), REND_done_CB(), REND_done_timeout_CB(), REND_set_thr_pval(), SUMA_cb_doneSumaCont(), SUMA_cb_DrawROI_Delete(), T3D_quit_CB(), and T3D_setup_stat_aux().

00185 {
00186    XmString xstr ;
00187    xstr = XmStringCreateLtoR( str , XmFONTLIST_DEFAULT_TAG ) ;
00188    XtVaSetValues( w , XmNlabelString , xstr , NULL ) ;
00189    XmStringFree( xstr ) ;
00190    MCW_expose_widget( w ) ;
00191 }

void MCW_textwin_alter MCW_textwin  ,
char *   
 

Definition at line 1287 of file xutil.c.

References cbuf, ENTRY, MAX, MCW_widget_geom(), mmm, MCW_textwin::shell_height, MCW_textwin::shell_width, MCW_textwin::wshell, and MCW_textwin::wtext.

Referenced by AFNI_set_viewpoint().

01288 {
01289    int swid , shi ;
01290    char * msg = mmm ;
01291    int cmax = 20 , ll , nlin ;
01292    char * cpt , *cold , cbuf[128] ;
01293    XmString xstr ;
01294    XmFontList xflist ;
01295 
01296 ENTRY("MCW_textwin_alter") ;
01297 
01298    if( tw == NULL ) EXRETURN ;     /* bad */
01299 
01300    if( msg == NULL ) msg = " " ; /* don't let user be so stupid */
01301 
01302 #if 0
01303    /*-- compute size of text window with new message in it --*/
01304 
01305    XtVaGetValues( tw->wtext , XmNfontList , &xflist , NULL ) ;
01306 
01307    /* find longest line in msg */
01308 
01309    cmax = 20 ; nlin = 1 ;
01310    for( cpt=msg,cold=msg ; *cpt != '\0' ; cpt++ ){
01311       if( *cpt == '\n' ){
01312          ll = cpt - cold - 1 ; if( cmax < ll ) cmax = ll ;
01313          cold = cpt ; nlin++ ;
01314       }
01315    }
01316    ll = cpt - cold - 1 ; if( cmax < ll ) cmax = ll ;
01317    if( cmax > 100 ) cmax = 100 ;
01318 
01319    /* fill a dummy string of that length, plus a bit */
01320 
01321    cmax+=3 ;
01322    for( ll=0 ; ll < cmax ; ll++ ) cbuf[ll] = 'x' ;
01323    cbuf[cmax] = '\0' ;
01324 
01325    /* find width, height of the dummy string */
01326 
01327    xstr = XmStringCreateLtoR( cbuf , XmFONTLIST_DEFAULT_TAG ) ;
01328    swid = XmStringWidth ( xflist , xstr ) + 44 ;
01329    shi  = XmStringHeight( xflist , xstr ) * nlin + 66 ;
01330    XmStringFree( xstr ) ;
01331 
01332    /* find width, height of screen */
01333 
01334    cmax = WidthOfScreen(XtScreen(tw->wshell)) - 128 ;
01335    if( swid > cmax ) swid = cmax ;
01336 
01337    cmax = HeightOfScreen(XtScreen(tw->wshell)) - 128 ;
01338    if( shi > cmax ) shi = cmax ;
01339 #endif
01340 
01341    /*-- actually set new text --*/
01342 
01343    XtVaSetValues( tw->wtext , XmNvalue , msg , NULL ) ;
01344 
01345 #if 1
01346    MCW_widget_geom( tw->wtext , &swid , &shi , NULL,NULL ) ;
01347    XtVaSetValues( tw->wshell , XmNwidth,swid+29 , XmNheight,shi+59 , NULL ) ;
01348    tw->shell_width = swid+29 ; tw->shell_height = shi+59 ;
01349 #endif
01350 
01351 #if 0
01352    /*-- maybe set new window size --*/
01353 
01354    if( swid > tw->shell_width || shi > tw->shell_height ){
01355       tw->shell_width  = swid = MAX( swid , tw->shell_width ) ;
01356       tw->shell_height = shi  = MAX( shi  , tw->shell_height ) ;
01357       XtVaSetValues( tw->wshell , XmNwidth,swid , XmNheight,shi , NULL ) ;
01358    }
01359 #endif
01360 
01361    EXRETURN ;
01362 }

void MCW_textwin_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 1366 of file xutil.c.

References AFNI_CALL_VOID_1ARG, client_data, MCW_textwin::kill_data, MCW_textwin::kill_func, myXtFree, and MCW_textwin::wshell.

01367 {
01368    MCW_textwin * tw = (MCW_textwin *) client_data ;
01369    char * wname     = XtName(w) ;
01370 
01371    if( client_data == NULL ) return ;
01372 
01373    if( strcmp(wname,"Quit") == 0 ){
01374       if( tw->kill_func != NULL )
01375 #if 0
01376         tw->kill_func(tw->kill_data); /* 10 Jul 2001 */
01377 #else
01378         AFNI_CALL_VOID_1ARG( tw->kill_func , XtPointer , tw->kill_data ) ;
01379 #endif
01380       XtDestroyWidget( tw->wshell ) ;
01381       myXtFree( tw ) ;
01382       return ;
01383    }
01384 
01385    XBell( XtDisplay(w) , 100 ) ;
01386    return ;
01387 }

void MCW_textwinkill_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 1391 of file xutil.c.

References AFNI_CALL_VOID_1ARG, client_data, MCW_textwin::kill_data, MCW_textwin::kill_func, myXtFree, and MCW_textwin::wshell.

Referenced by AFNI_imag_pop_CB(), and new_MCW_textwin_2001().

01392 {
01393    MCW_textwin * tw = (MCW_textwin *) client_data ;
01394 
01395    if( tw->kill_func != NULL )
01396 #if 0
01397      tw->kill_func(tw->kill_data); /* 10 Jul 2001 */
01398 #else
01399      AFNI_CALL_VOID_1ARG( tw->kill_func , XtPointer , tw->kill_data ) ;
01400 #endif
01401    XtDestroyWidget( tw->wshell ) ;
01402    myXtFree( tw ) ;
01403    return ;
01404 }

void MCW_unhelp_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 890 of file xutil.c.

References client_data, and RWC_XtPopdown().

Referenced by MCW_help_CB().

00891 {
00892    Widget wpop = (Widget) client_data ;
00893 
00894    RWC_XtPopdown(wpop) ;
00895    return ;
00896 }

void MCW_unmanage_widgets Widget *   ,
int   
 

Definition at line 260 of file xutil.c.

Referenced by drive_MCW_imseq().

00261 {
00262    int ii ;
00263    if( war == NULL ) return ;
00264    for( ii=0 ; ii < nar ; ii++ )
00265       if( war[ii] != (Widget) 0 ) XtUnmanageChild( war[ii] ) ;
00266    return ;
00267 }

void MCW_unregister_help Widget   
 

Definition at line 749 of file xutil.c.

Referenced by AFNI_pop_whereami_kill(), and drive_MCW_imseq().

00750 {
00751    XtCallbackList hc=NULL ;
00752 
00753    XtVaGetValues( w , XmNhelpCallback , &hc , NULL ) ;
00754 
00755    if( hc != NULL )
00756       XtRemoveCallbacks( w , XmNhelpCallback , hc ) ;
00757 }

void MCW_unregister_hint Widget   
 

Definition at line 666 of file xutil.c.

References liteClue, and XcgLiteClueDeleteWidget().

Referenced by AFNI_pop_whereami_kill(), drive_MCW_imseq(), and ISQ_set_barhint().

00667 {
00668    if( liteClue != NULL && w != NULL )
00669       XcgLiteClueDeleteWidget( liteClue , w ) ;
00670    return ;
00671 }

void MCW_widget_geom Widget   ,
int *   ,
int *   ,
int *   ,
int *   
 

Definition at line 195 of file xutil.c.

Referenced by AFNI_finalsave_layout_CB(), AFNI_imag_pop_CB(), AFNI_misc_CB(), alter_MCW_pbar(), drive_MCW_grapher(), drive_MCW_imseq(), GRA_drawing_EV(), GRA_mapmenu_CB(), GRA_new_pixmap(), GRA_setshift_startup(), ISQ_but_disp_CB(), ISQ_drawing_EV(), ISQ_mapxy(), ISQ_place_widget(), ISQ_reset_dimen(), ISQ_show_bar(), ISQ_show_image(), ISQ_show_zoom(), MCW_help_CB(), MCW_popup_message(), MCW_popup_meter(), MCW_textwin_alter(), new_MCW_textwin_2001(), NOTES_add_CB(), NOTES_delete_CB(), NOTES_finalize_dset_CB(), NOTES_refit_CB(), PBAR_bigexpose_CB(), PBAR_button_EV(), PBAR_resize_CB(), PBAR_show_bigmode(), PLUG_setup_widgets(), PLUG_startup_plugin_CB(), RCREND_func_widgets(), REND_func_widgets(), RWC_visibilize_widget(), SNAP_store_image(), and TTRR_setup_widgets().

00196 {
00197    Dimension nx , ny ;  /* don't try to make these ints! */
00198    Position  xx , yy ;
00199 
00200    if( w == NULL ) return ;
00201 
00202    if( XtIsRealized(w) ){
00203       XtVaGetValues( w , XmNwidth  , &nx , XmNheight , &ny ,
00204                          XmNx      , &xx , XmNy      , &yy , NULL ) ;
00205    } else {
00206       XtWidgetGeometry wg ;
00207       (void) XtQueryGeometry( w , NULL , &wg ) ;   /* works! */
00208       nx = wg.width ; ny = wg.height ;
00209       xx = wg.x     ; yy = wg.y      ;
00210    }
00211 
00212 #define ASSIF(p,v) if( p!= NULL ) *p = v
00213 
00214    ASSIF(wout,nx) ; ASSIF(hout,ny) ;
00215    ASSIF(xout,xx) ; ASSIF(yout,yy) ;
00216 
00217    return ;
00218 }

int MCW_widget_visible Widget    w
 

Definition at line 1411 of file xutil.c.

Referenced by AFNI_finalsave_layout_CB(), fd_px_store(), GRA_redraw_overlay(), ISQ_show_bar(), ISQ_show_image(), and SNAP_grab_image().

01412 {
01413    Window ww ;
01414    XWindowAttributes wa ;
01415 
01416    if( w == (Widget) NULL ) return 0 ;
01417    ww = XtWindow(w) ;
01418    if( ww == (Window) NULL ) return 0 ;
01419 
01420    XGetWindowAttributes( XtDisplay(w) , ww , &wa ) ;
01421 
01422    return ( (wa.map_state == IsViewable) ? 1 : 0 ) ;
01423 }

MCW_textwin* new_MCW_textwin Widget   ,
char *   ,
int   
 

Definition at line 1107 of file xutil.c.

References new_MCW_textwin_2001().

Referenced by AFNI_misc_CB(), AFNI_pbar_CB(), DRAW_help_CB(), GRA_drawing_EV(), NOTES_help_CB(), NUD_help_CB(), PLUG_action_CB(), PLUTO_popup_worker(), r_main_cb_help(), RCREND_help_CB(), REND_help_CB(), TAG_help_CB(), and TTRR_action_CB().

01108 {
01109    return new_MCW_textwin_2001( wpar,msg,type , NULL,NULL ) ;
01110 }

MCW_textwin* new_MCW_textwin_2001 Widget   ,
char *   ,
int   ,
void_func  ,
XtPointer   
 

Definition at line 1116 of file xutil.c.

References cbuf, MCW_action_item::data, EDIT_NUM, ENTRY, MCW_textwin::kill_data, MCW_textwin::kill_func, MCW_action_item::make_red, MCW_action_area(), MCW_textwinkill_CB(), MCW_widget_geom(), myXtNew, NORMAL_cursorize, RETURN, RONLY_NUM, RWC_visibilize_widget(), RWC_xineramize(), MCW_textwin::shell_height, MCW_textwin::shell_width, TEXT_EDITABLE, MCW_textwin::wactar, MCW_textwin::wscroll, MCW_textwin::wshell, MCW_textwin::wtext, and MCW_textwin::wtop.

Referenced by AFNI_imag_pop_CB(), and new_MCW_textwin().

01118 {
01119    MCW_textwin * tw ;
01120    int wx,hy,xx,yy , xp,yp , scr_width,scr_height , xr,yr , xpr,ypr , ii,nact ;
01121    int swid , shi ;
01122    Position xroot , yroot ;
01123    Screen * scr ;
01124    Boolean editable ;
01125    Arg wa[64] ; int na ;
01126 
01127 ENTRY("new_MCW_textwin_2001") ;
01128 
01129    /*-- sanity check --*/
01130 
01131    if( ! XtIsRealized(wpar) ) RETURN(NULL) ;
01132 
01133    /* set position based on parent and screen geometry */
01134 
01135    MCW_widget_geom( wpar , &wx,&hy,&xx,&yy ) ;     /* geometry of parent */
01136    XtTranslateCoords( wpar, 0,0, &xroot,&yroot ) ; /* root coords */
01137    xr = (int) xroot ; yr = (int) yroot ;
01138 
01139    scr        = XtScreen(wpar) ;
01140    scr_width  = WidthOfScreen(scr) ;
01141    scr_height = HeightOfScreen(scr) ;
01142 
01143    xp = xx+8 ;  xpr = xr+8 ;
01144         if( xpr+50 > scr_width ){ xp -= 100 ; xpr -= 100 ; } /* too right */
01145    else if( xpr+10 < 0 )        { xpr = xp = 1 ; }           /* too left  */
01146 
01147    yp = yy+hy+8 ;  ypr = yr+hy+8 ;
01148         if( ypr+50 > scr_height ){ yp = yy-8 ; ypr = yr-100 ;} /* too down */
01149    else if( ypr+10 < 0 )         { ypr = yp = 1 ;            } /* too up   */
01150 
01151    /* create a popup shell */
01152 
01153    tw = myXtNew(MCW_textwin) ;
01154 
01155    tw->kill_func = kill_func ;  /* 10 Jul 2001 */
01156    tw->kill_data = kill_data ;
01157 
01158    tw->wshell = XtVaCreatePopupShell(
01159                  "menu" , xmDialogShellWidgetClass , wpar ,
01160                     XmNx , xpr ,
01161                     XmNy , ypr ,
01162                     XmNborderWidth , 0 ,
01163                     XmNborderColor , 0 ,
01164                     XmNinitialResourcesPersistent , False ,
01165                  NULL ) ;
01166 
01167    XmAddWMProtocolCallback(
01168         tw->wshell ,
01169         XmInternAtom( XtDisplay(tw->wshell) , "WM_DELETE_WINDOW" , False ) ,
01170         MCW_textwinkill_CB , (XtPointer) tw ) ;
01171 
01172    /* create a form to hold everything else */
01173 
01174    tw->wtop = XtVaCreateWidget(
01175                 "menu" , xmFormWidgetClass , tw->wshell ,
01176                   XmNborderWidth , 0 ,
01177                   XmNborderColor , 0 ,
01178                   XmNtraversalOn , False ,
01179                   XmNinitialResourcesPersistent , False ,
01180                 NULL ) ;
01181 
01182    /* create action area */
01183 
01184    editable = (Boolean) (type == TEXT_EDITABLE) ;
01185 
01186    nact = (editable) ? EDIT_NUM : RONLY_NUM ;
01187    for( ii=0 ; ii < nact ; ii++ ){
01188      TWIN_act[ii].data     = (XtPointer) tw ;
01189      TWIN_act[ii].make_red = 0 ;
01190    }
01191    TWIN_act[nact-1].make_red = 1 ;
01192 
01193    tw->wactar = MCW_action_area( tw->wtop , TWIN_act , nact ) ;
01194 
01195    /* create text area */
01196 
01197    tw->wscroll = XtVaCreateManagedWidget(
01198                     "menu" , xmScrolledWindowWidgetClass , tw->wtop ,
01199                        XmNscrollingPolicy        , XmAUTOMATIC ,
01200                        XmNvisualPolicy           , XmVARIABLE ,
01201                        XmNscrollBarDisplayPolicy , XmAS_NEEDED ,
01202 
01203                        XmNleftAttachment  , XmATTACH_FORM ,
01204                        XmNrightAttachment , XmATTACH_FORM ,
01205                        XmNbottomAttachment, XmATTACH_FORM ,
01206                        XmNtopAttachment   , XmATTACH_WIDGET ,
01207                        XmNtopWidget       , tw->wactar ,
01208                        XmNtopOffset       , 7 ,
01209 
01210                        XmNinitialResourcesPersistent , False ,
01211                     NULL ) ;
01212 
01213    XtVaSetValues( tw->wactar ,
01214                      XmNleftAttachment , XmATTACH_FORM ,
01215                      XmNrightAttachment, XmATTACH_FORM ,
01216                      XmNtopAttachment  , XmATTACH_FORM ,
01217                      XmNtopOffset      , 7 ,
01218                   NULL ) ;
01219 
01220    tw->wtext = XtVaCreateManagedWidget(
01221                     "menu" , xmTextWidgetClass , tw->wscroll ,
01222                        XmNeditMode               , XmMULTI_LINE_EDIT ,
01223                        XmNautoShowCursorPosition , editable ,
01224                        XmNeditable               , editable ,
01225                        XmNcursorPositionVisible  , editable ,
01226                     NULL ) ;
01227 
01228    if( msg == NULL ) msg = "\0" ;  /* 27 Sep 2000 */
01229 
01230    if( msg != NULL ){
01231       int cmax = 20 , ll , nlin ;
01232       char * cpt , *cold , cbuf[128] ;
01233       XmString xstr ;
01234       XmFontList xflist ;
01235 
01236       XtVaSetValues( tw->wtext , XmNvalue , msg , NULL ) ;
01237       XtVaGetValues( tw->wtext , XmNfontList , &xflist , NULL ) ;
01238 
01239       cmax = 20 ; nlin = 1 ;
01240       for( cpt=msg,cold=msg ; *cpt != '\0' ; cpt++ ){
01241          if( *cpt == '\n' ){
01242             ll = cpt - cold - 1 ; if( cmax < ll ) cmax = ll ;
01243             cold = cpt ; nlin++ ;
01244          }
01245       }
01246       ll = cpt - cold - 1 ; if( cmax < ll ) cmax = ll ;
01247       if( cmax > 100 ) cmax = 100 ;
01248       cmax+=3 ;
01249       for( ll=0 ; ll < cmax ; ll++ ) cbuf[ll] = 'x' ;
01250       cbuf[cmax] = '\0' ;
01251 
01252       xstr = XmStringCreateLtoR( cbuf , XmFONTLIST_DEFAULT_TAG ) ;
01253       swid = XmStringWidth ( xflist , xstr ) + 44 ;
01254       shi  = XmStringHeight( xflist , xstr ) * nlin + 66 ;
01255       XmStringFree( xstr ) ;
01256 
01257       cmax = WidthOfScreen(XtScreen(wpar)) - 128 ;
01258       if( swid > cmax ) swid = cmax ;
01259 
01260       cmax = HeightOfScreen(XtScreen(wpar)) - 128 ;
01261       if( shi > cmax ) shi = cmax ;
01262    } else {
01263       swid = shi = 100 ;
01264    }
01265 
01266    XtManageChild( tw->wtop ) ;
01267 
01268    XtVaSetValues( tw->wshell , XmNwidth,swid , XmNheight,shi , NULL ) ;
01269 
01270    XtPopup( tw->wshell , XtGrabNone ) ;
01271 
01272    RWC_visibilize_widget( tw->wshell ) ;  /* 09 Nov 1999 */
01273 
01274    RWC_xineramize( XtDisplay(tw->wshell) ,
01275                    xpr,ypr,swid,shi , &xpr,&ypr ); /* 27 Sep 2000 */
01276 
01277    XtVaSetValues( tw->wshell, XmNx,xpr , XmNy,ypr , NULL ) ;
01278 
01279    tw->shell_width = swid ; tw->shell_height = shi ; /* 10 Jul 2001 */
01280 
01281    NORMAL_cursorize( tw->wshell ) ;
01282    RETURN(tw) ;
01283 }

void RWC_destroy_nullify Widget   ,
void **   
 

Definition at line 1691 of file xutil.c.

References p, and RWC_destroy_nullify_CB().

01692 {
01693    if( p != NULL && w != NULL )
01694      XtAddCallback( w, XmNdestroyCallback, RWC_destroy_nullify_CB, p ) ;
01695    return ;
01696 }

void RWC_destroy_nullify_cancel Widget   ,
void **   
 

Definition at line 1698 of file xutil.c.

References p, and RWC_destroy_nullify_CB().

01699 {
01700    if( w != NULL )
01701      XtRemoveCallback( w, XmNdestroyCallback, RWC_destroy_nullify_CB, p ) ;
01702    return ;
01703 }

void RWC_drag_rectangle Widget   ,
int   ,
int   ,
int *   ,
int *   
 

Definition at line 1741 of file xutil.c.

References cur, ENTRY, RWC_drag_cursor(), RWC_draw_rect(), win, x2, and y1.

Referenced by ISQ_cropper().

01742 {
01743    Display *dis ;
01744    Window win , rW,cW ;
01745    int grab , xold,yold , x,y, rx,ry , first=1 ;
01746    unsigned int mask ;                                      /* which buttons */
01747    unsigned int bmask=Button1Mask|Button2Mask|Button3Mask ; /* all buttons  */
01748    XGCValues  gcv;
01749    GC         myGC ;
01750 
01751 
01752 ENTRY("RWC_drag_rectangle") ;
01753 
01754    /** make a GC for invert drawing **/
01755 
01756    gcv.function = GXinvert ;
01757    myGC         = XtGetGC( w , GCFunction , &gcv ) ;
01758 
01759    /** grab the pointer (so no one else gets events from it),
01760        and confine it to the window in question              **/
01761 
01762    dis = XtDisplay(w) ; win = XtWindow(w) ;
01763 
01764    RWC_drag_cursor(dis) ;
01765 
01766    grab = !XGrabPointer(dis, win, False, 0, GrabModeAsync,
01767                         GrabModeAsync, win, cur , (Time)CurrentTime);
01768 
01769    /* grab fails => exit */
01770 
01771    if( !grab ){ XBell(dis,100); *x2=x1; *y2=y1; EXRETURN; }
01772 
01773    xold = x1 ; yold = y1 ;  /* current location of pointer */
01774 
01775    /** loop and find out where the pointer is (while button is down) **/
01776 
01777    while( XQueryPointer(dis,win,&rW,&cW,&rx,&ry,&x,&y,&mask) ){
01778 
01779      /* check if all buttons are released */
01780 
01781      if( !(mask & bmask) ) break ;  /* no button down => done! */
01782 
01783      /* pointer now at (x,y) in the window */
01784 
01785      /* if it has moved, redraw rectangle */
01786 
01787      if( x != xold || y != yold ){
01788 
01789        if( !first )  /* undraw old rectangle */
01790          RWC_draw_rect( dis,win,myGC , x1,y1 , xold,yold ) ;
01791 
01792        /* draw new rectangle */
01793 
01794        xold = x ; yold = y ; first = 0 ;
01795        RWC_draw_rect( dis,win,myGC , x1,y1 , xold,yold ) ;
01796 
01797      } /* end of new (x,y) position */
01798 
01799    } /* end of loop while button is pressed */
01800 
01801    if( !first )  /* undraw old rectangle */
01802      RWC_draw_rect( dis,win,myGC , x1,y1 , xold,yold ) ;
01803 
01804    /* clean up */
01805 
01806    XtReleaseGC( w , myGC ) ;
01807    if (grab) XUngrabPointer(dis, (Time)CurrentTime) ;
01808 
01809    *x2 = xold ; *y2 = yold ;  /* output values */
01810    EXRETURN ;
01811 }

char* RWC_getname Display *   ,
char *   
 

Definition at line 1433 of file xutil.c.

References display, my_getenv(), and name.

Referenced by MCW_choose_CB(), MCW_help_CB(), MCW_hint_toggle(), MCW_hotcolor(), MCW_set_listmax(), and new_MCW_grapher().

01434 {
01435    char * cval , qqq[256] ;
01436    int nn , ii ;
01437 
01438    if( name == NULL || name[0] == '\0' ) return NULL ;
01439 
01440    /* try X11 */
01441 
01442    if( display != NULL ){
01443      cval = XGetDefault(display,"AFNI",name) ;
01444      if( cval != NULL ) return cval ;
01445    }
01446 
01447    /* try AFNI_name */
01448 
01449    strcpy(qqq,"AFNI_") ; strcat(qqq,name) ;
01450    cval = my_getenv(qqq) ;
01451    if( cval != NULL ) return cval ;
01452 
01453    /* try AFNI_NAME (uppercase it) */
01454 
01455    strcpy(qqq,"AFNI_") ; nn = strlen(name) ;
01456    for( ii=0 ; ii < nn && ii < 250 ; ii++ ) qqq[ii+5] = toupper(name[ii]) ;
01457    qqq[ii+5] = '\0' ;
01458    cval = my_getenv(qqq) ;
01459    return cval ;
01460 }

void RWC_sleep int    msec
 

Sleep a given # of milliseconds (uses the Unix select routine). ---------------------------------------------------------------------

Definition at line 1907 of file xutil.c.

Referenced by AFNI_drive_quit(), AFNI_sleeper(), ISQ_drawing_EV(), and SNAP_grab_image().

01908 {
01909    struct timeval tv ;
01910    if( msec <= 0 ) return ;             /* can't wait into the past */
01911    tv.tv_sec  = msec/1000 ;
01912    tv.tv_usec = (msec%1000)*1000 ;
01913    select( 1 , NULL,NULL,NULL , &tv ) ;
01914    return ;
01915 }

void RWC_visibilize_CB Widget   ,
XtPointer   ,
XtPointer   
 

Definition at line 1511 of file xutil.c.

References AFNI_yesenv(), ENTRY, and RWC_visibilize_timeout_CB().

01512 {
01513    Widget wpar = w ;
01514 ENTRY("RWC_visibilize_CB") ;
01515 
01516    if( AFNI_yesenv("AFNI_DONT_MOVE_MENUS") ) return ;  /* 08 Aug 2001 */
01517 
01518    while( !XtIsShell(wpar) ){ wpar = XtParent(w); } /* find 1st shell parent */
01519 
01520    /* must wait for the thing to actually appear, dammit */
01521 
01522    (void) XtAppAddTimeOut( XtWidgetToApplicationContext(wpar) ,
01523                            1 , RWC_visibilize_timeout_CB , wpar ) ;
01524    EXRETURN ;
01525 }

void RWC_visibilize_widget Widget   
 

Definition at line 1466 of file xutil.c.

References ENTRY, MCW_widget_geom(), and RWC_xineramize().

Referenced by AFNI_misc_CB(), AFNI_pbar_CB(), AFNI_read_1D_CB(), AFNI_read_sess_CB(), DRAW_main(), GRA_setshift_startup(), MCW_choose_integer(), MCW_choose_multi_editable_strlist(), MCW_choose_multi_strlist(), MCW_choose_ovcolor(), MCW_choose_string(), MCW_choose_timeseries(), MCW_choose_vector(), new_MCW_textwin_2001(), NOTES_main(), NUD_main(), PLUG_startup_plugin_CB(), RCREND_main(), REND_main(), RWC_visibilize_timeout_CB(), and TAG_main().

01467 {
01468    Position xroot , yroot ;
01469    int wx,hy,xx,yy , scr_width,scr_height , xo,yo ;
01470    Screen *scr ;
01471 
01472 ENTRY("RWC_visibilize_widget") ;
01473 
01474    if( w == NULL || !XtIsWidget(w) ) EXRETURN ;
01475 
01476    MCW_widget_geom( w , &wx,&hy,&xx,&yy ) ;     /* geometry of widget */
01477 
01478    scr        = XtScreen( w ) ;
01479    scr_width  = WidthOfScreen( scr ) ;
01480    scr_height = HeightOfScreen( scr ) ;
01481 
01482    xo = xx ; yo = yy ;                          /* save original position */
01483 
01484    if( xx+wx > scr_width ) xx = scr_width - wx ;
01485    if( xx    < 0         ) xx = 0              ;
01486 
01487    if( yy+hy > scr_height ) yy = scr_height - hy ;
01488    if( yy    < 0          ) yy = 0               ;
01489 
01490    RWC_xineramize( XtDisplay(w) , xx,yy,wx,hy , &xx,&yy ); /* 27 Sep 2000 */
01491 
01492    if( xx != xo || yy != yo )
01493       XtVaSetValues( w , XmNx , xx , XmNy , yy , NULL ) ;
01494 
01495    EXRETURN ;
01496 }

void RWC_xineramize Display *   ,
int   ,
int   ,
int   ,
int   ,
int *   ,
int *   
 

Definition at line 1537 of file xutil.c.

References abs, BUF, dpy, ENTRY, getenv(), malloc, STATUS, xn, and yn.

Referenced by GRA_mapmenu_CB(), ISQ_place_widget(), new_MCW_textwin_2001(), RWC_visibilize_widget(), and timeout_event().

01539 {
01540    static int first=1 ;
01541    static int nxsi=0 , *xbot,*ybot,*xtop,*ytop ;
01542    int ii , ss ;
01543 
01544 ENTRY("RWC_xineramize") ;
01545 
01546    if( dpy==NULL || xn==NULL || yn==NULL || ww<0 || hh<0 ) EXRETURN; /* ERROR */
01547 
01548    /*--- first time in: check AFNI.xinerama X resource
01549                         load boundaries of sub-screens from resource ---*/
01550 
01551    if( first ){
01552       char * xdef , * xp ;
01553       int nn,xorg,yorg,wide,high ;
01554 
01555       first = 0 ;                         /* never again */
01556       xdef  = getenv( "AFNI_XINERAMA" ) ;
01557 
01558       if( xdef != NULL && (xdef[0] == 'N' || xdef[0] == 'n') ){ /* skip Xinerama */
01559          nxsi = 0 ;
01560          STATUS("AFNI_XINERAMA is NO") ;
01561       } else {
01562          xdef = XGetDefault(dpy,"AFNI","xinerama") ; /* get resource */
01563          if( xdef == NULL ) xdef = getenv("AFNI_xinerama") ;  /* 27 Oct 2003 */
01564          if( xdef != NULL ){
01565             char *qdef = strdup(xdef) ;
01566             for( nn=0 ; qdef[nn] != '\0' ; nn++ )
01567               if( qdef[nn] == '_' || qdef[nn] == ':' ) qdef[nn] = ' ' ;
01568 
01569             nn = 0 ; sscanf(qdef,"%d%n",&nxsi,&nn) ;  /* number of sub-screens */
01570             if( nn <= 0 || nxsi <= 1 ){               /* ERROR */
01571                nxsi = 0 ;
01572             } else {
01573                xbot = (int *) malloc(sizeof(int)*nxsi) ; /* make arrays to */
01574                ybot = (int *) malloc(sizeof(int)*nxsi) ; /* store sub-screen */
01575                xtop = (int *) malloc(sizeof(int)*nxsi) ; /* coordinate ranges */
01576                ytop = (int *) malloc(sizeof(int)*nxsi) ;
01577                xp = qdef + nn ;
01578                for( ii=0 ; ii < nxsi ; ii++ ){    /* scan for sub-screen info */
01579                   nn = 0 ;
01580                   sscanf(xp,"%d%d%d%d%d%n",&ss,&xorg,&yorg,&wide,&high,&nn) ;
01581                   if( nn <= 0 ) break ;           /* ERROR */
01582                   xbot[ii] = xorg ; xtop[ii] = xorg+wide ;
01583                   ybot[ii] = yorg ; ytop[ii] = yorg+high ;
01584                   xp += nn ;
01585 
01586                   if(PRINT_TRACING){
01587                     char str[256] ;
01588                     sprintf(str," Screen %d: xbot=%4d ybot=%4d xtop=%4d ytop=%4d",
01589                                   ii,xbot[ii],ybot[ii],xtop[ii],ytop[ii] ) ;
01590                     STATUS(str) ;
01591                   }
01592                }
01593 
01594                nxsi = ii ;  /* in case the scan aborted */
01595             }
01596          }
01597       }
01598 
01599       /* if nothing found yet, use the display size */
01600 
01601       if( nxsi <= 0 ){
01602          nxsi = 1 ;
01603          xbot = (int *) malloc(sizeof(int)*nxsi) ;
01604          ybot = (int *) malloc(sizeof(int)*nxsi) ;
01605          xtop = (int *) malloc(sizeof(int)*nxsi) ;
01606          ytop = (int *) malloc(sizeof(int)*nxsi) ;
01607          xbot[0] = ybot[0] = 0 ;
01608          xtop[0] = WidthOfScreen(DefaultScreenOfDisplay(dpy)) ;
01609          ytop[0] = HeightOfScreen(DefaultScreenOfDisplay(dpy)) ;
01610       }
01611    }
01612 
01613 #if 0                                           /* doesn't occur anymore */
01614    if( nxsi == 0 ){ *xn=xx; *yn=yy; EXRETURN; } /* not setup? change nothing */
01615 #endif
01616 
01617    /*--- find the Xinerama sub-screen that (xx,yy) is on (if any) ---*/
01618 
01619    if( nxsi > 1 ){
01620       for( ss=0 ; ss < nxsi ; ss++ ){
01621          if( xx >= xbot[ss] && xx < xtop[ss] &&
01622              yy >= ybot[ss] && yy < ytop[ss]   ) break ;
01623       }
01624    } else {
01625       ss = 0 ;  /* must use #0 - what else is there? */
01626    }
01627 
01628    if(PRINT_TRACING){
01629       char str[256] ;
01630       sprintf(str,"Rect: xx=%d yy=%d ww=%d hh=%d; On ss=%d",xx,yy,ww,hh,ss); STATUS(str);
01631    }
01632 
01633    /*--- if not inside any screen, find one it is closest to ---*/
01634 
01635    if( ss >= nxsi ){
01636       int dleft,dright,dtop,dbot,dd , dmin , xdif,ydif ;
01637       dmin = 123456789 ; ss = 0 ;
01638       for( ii=0 ; ii < nxsi; ii++ ){
01639          xdif = (xx < xbot[ii]) ? (xbot[ii]-xx)       /* x dist to    */
01640                :(xx > xtop[ii]) ? (xx-xtop[ii]) : 0 ; /* [xbot..xtop] */
01641 
01642          ydif = (yy < ybot[ii]) ? (ybot[ii]-yy)
01643                :(yy > ytop[ii]) ? (yy-ytop[ii]) : 0 ;
01644 
01645          dleft  = abs(xx-xbot[ii]) + ydif ;  /* L1 dist to left edge */
01646          dright = abs(xx-xtop[ii]) + ydif ;
01647          dbot   = abs(yy-ybot[ii]) + xdif ;
01648          dtop   = abs(yy-ytop[ii]) + xdif ;
01649 
01650                            dd = dleft ;      /* find smallest dist */
01651          if( dright < dd ) dd = dright ;
01652          if( dbot   < dd ) dd = dbot ;
01653          if( dtop   < dd ) dd = dtop ;
01654 
01655          if( dd < dmin ){ dmin = dd; ss = ii; } /* smallest so far? */
01656       }
01657 
01658       if(PRINT_TRACING){
01659          char str[256] ; sprintf(str,"New ss=%d",ss) ; STATUS(str) ;
01660       }
01661    }
01662 
01663    /*--- now adjust position so all of rectangle
01664          (xx..xx+ww,yy..yy+hh) fits on that screen (if possible) ---*/
01665 
01666    if( xx+ww+BUF >= xtop[ss] ){ xx = xtop[ss]-ww-1-2*BUF; } /* move left */
01667    if( yy+hh+BUF >= ytop[ss] ){ yy = ytop[ss]-hh-1-2*BUF; } /* move up  */
01668    if( xx    < xbot[ss]+BUF  ){ xx = xbot[ss]+BUF; }        /* move right */
01669    if( yy    < ybot[ss]+BUF  ){ yy = ybot[ss]+BUF; }        /* move down */
01670 
01671 
01672    if(PRINT_TRACING){
01673       char str[256] ; sprintf(str,"New xx=%d yy=%d",xx,yy) ; STATUS(str) ;
01674    }
01675 
01676    *xn = xx ; *yn = yy ; EXRETURN ;
01677 }

void RWC_XtPopdown Widget    w
 

Popdown a widget that may not be a shell. [30 Jun 2003] -------------------------------------------------------------------

Definition at line 1921 of file xutil.c.

Referenced by AFNI_close_file_dialog_CB(), AFNI_finalize_read_1D_CB(), AFNI_finalize_read_palette_CB(), AFNI_finalize_read_sess_CB(), GRA_setshift_action_CB(), ISQ_montage_action_CB(), MCW_choose_CB(), MCW_help_CB(), MCW_unhelp_CB(), and refit_MCW_optmenu().

01922 {
01923    Widget wpar = w ;
01924 
01925    if( wpar == NULL ) return ;
01926    while( XtIsShell(wpar) == 0 && XtParent(wpar) != NULL ) wpar = XtParent(wpar);
01927    XtPopdown(wpar) ;
01928    return ;
01929 }
 

Powered by Plone

This site conforms to the following standards: