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

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #ifndef _MCW_XUTIL_HEADER_
00008 #define _MCW_XUTIL_HEADER_
00009 
00010 #include <X11/X.h>
00011 #include <X11/Intrinsic.h>
00012 #include <X11/IntrinsicP.h>
00013 #include <X11/cursorfont.h>
00014 #include <Xm/XmAll.h>
00015 
00016 #include <stdio.h>
00017 #include <string.h>
00018 #include <math.h>
00019 #include <stdlib.h>
00020 #include "machdep.h"
00021 
00022 #include "mcw_malloc.h"
00023 #include "afni_environ.h"
00024 
00025 #ifndef MAX
00026 #   define MAX(a,b) (((a)<(b)) ? (b) : (a))
00027 #   define MIN(a,b) (((a)>(b)) ? (b) : (a))
00028 #endif
00029 
00030 #ifndef myXtFree
00031 #define myXtFree(xp) (XtFree((char *)(xp)) , (xp)=NULL)
00032 #endif
00033 
00034 #ifndef myXtNew
00035 #define myXtNew(type) ((type *) XtCalloc(1,(unsigned) sizeof(type)))
00036 #endif
00037 
00038 #define SENSITIZE(w,sen)                         \
00039    do{ Boolean fred = (Boolean) sen ;            \
00040        if(w != NULL){                            \
00041           int exp = (XtIsSensitive(w) != fred) ; \
00042           XtSetSensitive(w,fred) ;               \
00043           if(exp) MCW_expose_widget(w) ; break ; } } while(0)
00044 
00045 #define SAVEUNDERIZE(w) XtVaSetValues((w),XmNsaveUnder,True,NULL) /* 27 Feb 2001 */
00046 
00047 extern void MCW_expose_widget( Widget ) ;
00048 extern void MCW_invert_widget( Widget ) ;
00049 extern void MCW_set_widget_bg( Widget , char * , Pixel ) ;
00050 
00051 extern Colormap MCW_get_colormap( Widget ) ;            /* 01 Sep 1998 */
00052 extern void     MCW_set_colormap( Widget , Colormap ) ; /* 14 Sep 1998 */
00053 extern int      MCW_get_depth( Widget ) ;
00054 extern Visual * MCW_get_visual( Widget ) ;
00055 
00056 extern void MCW_set_widget_cursor( Widget,int ) ;
00057 extern void MCW_alter_widget_cursor( Widget,int , char * , char * ) ;
00058 
00059 extern void RWC_sleep( int ) ;  /* 16 Aug 2002 */
00060 
00061 #define WAIT_for_window(w)                                  \
00062  do{ XSync( XtDisplay(w) , False ) ;                         \
00063      while( XtWindow(w) == (Window) NULL ) ; /* spin */       \
00064      RWC_sleep(1) ;                                            \
00065  } while(0)
00066 
00067 #define POPUP_cursorize(w)                                        \
00068  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )      \
00069       MCW_alter_widget_cursor( (w), -XC_left_ptr,"yellow","blue" ); \
00070  } while(0)
00071 
00072 #define NORMAL_cursorize(w)                                            \
00073  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )           \
00074    MCW_alter_widget_cursor( (w), -XC_top_left_arrow,"#ffb700","blue" ) ; \
00075  } while(0)
00076 
00077 #define WATCH_cursorize(w)                                     \
00078  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
00079       MCW_set_widget_cursor( (w) , -XC_watch ) ;               \
00080  } while(0)
00081 
00082 #define HAND_cursorize(w)                                      \
00083  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
00084       MCW_set_widget_cursor( (w) , -XC_hand2 ) ;               \
00085  } while(0)
00086 
00087 #define PENCIL_cursorize(w)                                    \
00088  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
00089       MCW_set_widget_cursor( (w) , -XC_pencil ) ;              \
00090  } while(0)
00091 
00092 #define CROSSHAIR_cursorize(w)                                 \
00093  do{ if( (w) != (Widget)NULL && XtWindow(w) != (Window)NULL )  \
00094       MCW_set_widget_cursor( (w) , -XC_crosshair ) ;           \
00095  } while(0)
00096 
00097 extern void MCW_register_hint( Widget , char * ) ;
00098 extern void MCW_reghint_children( Widget , char * ) ;
00099 extern void MCW_hint_toggle(void) ;
00100 
00101 extern void MCW_disable_help(void) ; /* 02 Aug 1999 */
00102 extern void MCW_enable_help (void) ;
00103 
00104 extern void MCW_click_help_CB( Widget , XtPointer , XtPointer ) ;
00105 extern void MCW_register_help( Widget , char * ) ;
00106 extern void MCW_reghelp_children( Widget , char * ) ;
00107 extern void MCW_help_CB( Widget , XtPointer , XtPointer ) ;
00108 extern void MCW_unhelp_CB( Widget , XtPointer , XtPointer ) ;
00109 
00110 extern void MCW_unregister_help( Widget ) ;        /* 24 Apr 2001 */
00111 extern void MCW_unregister_hint( Widget ) ;        /* 11 Jul 2001 */
00112 
00113 extern void MCW_set_widget_label( Widget , char * ) ;
00114 extern void MCW_widget_geom( Widget , int * , int * , int * , int * ) ;
00115 extern void MCW_discard_events( Widget , int ) ;
00116 
00117 typedef struct {
00118       char         * label ;        /* label for button       */
00119       XtCallbackProc func_CB ;      /* callback procedure     */
00120       XtPointer      data ;         /* data for func_CB       */
00121       char         * help_text ;    /* for MCW_register_help  */
00122       char         * hint_text ;    /* for MCW_register_hint  */
00123       int            make_red ;     /* nonzero for red button */
00124 
00125       XtPointer parent , aux ;
00126 } MCW_action_item ;
00127 
00128 extern char * MCW_hotcolor(Widget w) ; /* 01 Nov 1999 */
00129 
00130 extern Widget MCW_action_area( Widget , MCW_action_item * , int ) ;
00131 
00132 #define MCW_CALLER_KILL 1
00133 #define MCW_USER_KILL   2
00134 #define MCW_TIMER_KILL  (1<<10)
00135 
00136 extern Widget MCW_popup_message( Widget , char * , int ) ;
00137 extern void MCW_message_CB( Widget , XtPointer , XtPointer ) ;
00138 extern void MCW_message_timer_CB( XtPointer , XtIntervalId * ) ;
00139 
00140 extern void MCW_message_alter( Widget , char * ) ;  /* 10 Jul 2001 */
00141 
00142 #define MCW_nofile    0
00143 #define MCW_readonly  1
00144 #define MCW_readwrite 2
00145 
00146 extern int MCW_filetype( char * ) ;
00147 
00148 #if 0
00149 extern Boolean MCW_isitmwm( Widget ) ;
00150 #else
00151 #define MCW_isitmwm(ww) (!AFNI_noenv("AFNI_X11_REDECORATE"))
00152 #endif
00153 
00154 #define METER_TOP       1
00155 #define METER_TOP_WIDE  2
00156 #define METER_BOT       3
00157 #define METER_BOT_WIDE  4
00158 
00159 extern Widget MCW_popup_meter( Widget , int ) ;
00160 extern void MCW_popdown_meter( Widget ) ;
00161 extern void MCW_set_meter( Widget , int ) ;
00162 
00163 extern int MCW_widget_visible( Widget w ) ;  /* 03 Jan 1999 */
00164 
00165 extern char * RWC_getname( Display * , char * ) ; /* 04 Jun 1999 */
00166 
00167 /*------------------------------------------------------------------------*/
00168 
00169 #define TEXT_READONLY  1
00170 #define TEXT_EDITABLE  2
00171 
00172 #ifndef VOID_FUNC
00173 #define VOID_FUNC
00174 typedef void void_func() ;
00175 #endif
00176 
00177 typedef struct {
00178    Widget wshell , wtop , wactar , wscroll , wtext ;
00179    void_func *kill_func ;
00180    XtPointer  kill_data ;
00181    int shell_width , shell_height ;
00182 } MCW_textwin ;
00183 
00184 extern MCW_textwin * new_MCW_textwin( Widget, char *, int ) ;
00185 extern void MCW_textwin_CB( Widget , XtPointer , XtPointer ) ;
00186 extern void MCW_textwinkill_CB( Widget , XtPointer , XtPointer ) ;
00187 
00188 extern void MCW_textwin_alter( MCW_textwin * , char * ) ; /* 10 Jul 2001 */
00189 extern MCW_textwin * new_MCW_textwin_2001(Widget,char *,int,void_func *,XtPointer);
00190 
00191 extern void RWC_visibilize_widget( Widget ) ;  /* 09 Nov 1999 */
00192 
00193 #define RWC_visibilize RWC_visibilize_widget   /* 27 Sep 2000: sometimes I forget */
00194 
00195 extern void RWC_xineramize( Display *,         /* 27 Sep 2000 */
00196                             int,int,int,int, int *, int * ) ;
00197 
00198 extern void RWC_visibilize_CB( Widget , XtPointer , XtPointer ) ; /* 27 Sep 2000 */
00199 
00200 #define VISIBILIZE_WHEN_MAPPED(w) \
00201   XtAddCallback(w,XmNmapCallback,RWC_visibilize_CB,NULL)
00202 
00203 extern void MCW_manage_widgets  ( Widget * , int ) ; /* 24 Apr 2001 */
00204 extern void MCW_unmanage_widgets( Widget * , int ) ;
00205 
00206 void RWC_destroy_nullify       ( Widget, void ** ) ; /* 31 Jul 2001 */
00207 void RWC_destroy_nullify_cancel( Widget, void ** ) ;
00208 
00209 #define NULLIFY_ON_DESTROY(pp,ww)        RWC_destroy_nullify((ww),(void **)&(pp))
00210 #define CANCEL_NULLIFY_ON_DESTROY(pp,ww) RWC_destroy_nullify_cancel((ww),(void **)&(pp))
00211 
00212 /* invert the managed status of a widget */
00213 
00214 #define INVERT_manage(w)                                 \
00215  do{ if( XtIsManaged(w) ) XtUnmanageChild(w);            \
00216      else                 XtManageChild(w); } while(0) /* 21 Sep 2001 */
00217 
00218 extern void RWC_drag_rectangle( Widget, int,int, int *,int * ) ; /* 12 Jun 2002 */
00219 
00220 extern void RWC_XtPopdown( Widget ) ; /* 30 Jun 2003 */
00221 
00222 extern void AFNI_speak( char *string , int nofork ) ;   /* 24 Nov 2003 */
00223 extern void AFNI_speak_setvoice( char *vvv ) ;
00224 
00225 
00226 #endif /* _MCW_XUTIL_HEADER_ */
 

Powered by Plone

This site conforms to the following standards: