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  

xvisual.c File Reference

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <stdio.h>
#include <Xm/XmAll.h>
#include "mrilib.h"
#include "logo.h"
#include "machdep.h"
#include <locale.h>

Go to the source code of this file.


Defines

#define MAIN
#define USE_PIXMAP
#define WANT_LOGO_BITMAP
#define LABEL_ARG(str)   XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
#define ICON_bg   bg_pix
#define ICON_fg   fg_pix

Functions

XImage * rgb_to_XImage (Display *dis, XVisualInfo *vin, MRI_IMAGE *im)
void fred_CB (Widget w, XtPointer cd, XtPointer cb)
void elvis_CB (Widget w, XtPointer cd, XtPointer cb)
int main (int argc, char *argv[])
char * _Xsetlocale (int category, const char *locale)

Variables

char * vcl []
XImage * xim = NULL
int xim_ww = 0
int xim_hh = 0

Define Documentation

#define ICON_bg   bg_pix
 

#define ICON_fg   fg_pix
 

#define LABEL_ARG str       XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
 

#define MAIN
 

Definition at line 7 of file xvisual.c.

#define USE_PIXMAP
 

Definition at line 26 of file xvisual.c.

#define WANT_LOGO_BITMAP
 

Definition at line 28 of file xvisual.c.


Function Documentation

char* _Xsetlocale int    category,
const char *    locale
 

Definition at line 356 of file xvisual.c.

00357 { return setlocale(category,locale) ; }

void elvis_CB Widget    w,
XtPointer    cd,
XtPointer    cb
 

Definition at line 36 of file xvisual.c.

References ev, logo_pixmap, xim, xim_hh, and xim_ww.

Referenced by main().

00037 {
00038    static int needGC = 1 ;
00039    static  GC myGC ;
00040    XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *) cb ;
00041    XExposeEvent * ev = (XExposeEvent *) cbs->event ;
00042    Dimension nx , ny ;
00043    int ii , jj ;
00044 
00045    if( cbs->reason != XmCR_EXPOSE || ev->count > 0 ) return ;
00046 
00047    if( needGC ){
00048      XGCValues  gcv;
00049      gcv.function = GXcopy ;
00050      myGC  = XCreateGC( XtDisplay(w) , XtWindow(w) , GCFunction , &gcv ) ;
00051      needGC = 0 ;
00052    }
00053 
00054    XtVaGetValues( w , XmNwidth  , &nx , XmNheight , &ny , NULL ) ;
00055 
00056 #ifdef USE_TRUECOLOR
00057    ii = 0 ;
00058    do{
00059       jj = 0 ;
00060       do{
00061          XPutImage( XtDisplay(w),XtWindow(w),myGC,xim,0,0,ii,jj,xim_ww,xim_hh) ;
00062          jj += xim_hh + 4 ;
00063       } while( jj < ny ) ;
00064       ii += xim_ww ;
00065    } while( ii < nx ) ;
00066 #else
00067 # ifdef USE_PIXMAP
00068    ii = 0 ;
00069    do{ jj = 0 ;
00070        do{
00071           XCopyArea( XtDisplay(w),logo_pixmap , XtWindow(w),myGC ,
00072                      0,0,logo_width,logo_height , ii,jj ) ;
00073          jj += logo_height + 4 ;
00074       } while( jj < ny ) ;
00075       ii += logo_width ;
00076    } while( ii < nx ) ;
00077 # endif /* USE_PIXMAP */
00078 #endif /* USE_TRUECOLOR */
00079 
00080    return ;
00081 }

void fred_CB Widget    w,
XtPointer    cd,
XtPointer    cb
 

Definition at line 34 of file xvisual.c.

Referenced by main().

00034 { exit(0); }

int main int    argc,
char *    argv[]
 

Definition at line 83 of file xvisual.c.

References argc, dpy, elvis_CB(), fred_CB(), LABEL_ARG, logo_pixmap, mri_free(), mri_read_ppm(), MRI_IMAGE::nx, MRI_IMAGE::ny, rgb_to_XImage(), top, xim, xim_hh, and xim_ww.

00084 {
00085         XtAppContext    app;            /* the application context */
00086         Widget          top;            /* toplevel widget */
00087         Display         *dpy;           /* display */
00088         Colormap        colormap;       /* created colormap */
00089         XVisualInfo     vinfo;          /* template for find visual */
00090         Visual          *vis ;          /* the Visual itself */
00091         XVisualInfo     *vinfo_list;    /* returned list of visuals */
00092         int             count;          /* number of matchs (only 1?) */
00093         int             vid , stat ;
00094         Widget          fred , fff ;
00095 
00096         top = XtVaAppInitialize( &app , "test" , NULL , 0 , &argc , argv , NULL , NULL ) ;
00097         dpy = XtDisplay (top);
00098 
00099 #ifndef USE_TRUECOLOR
00100         stat = XMatchVisualInfo( dpy,XScreenNumberOfScreen(XtScreen(top)),
00101                                  8,PseudoColor,&vinfo ) ;
00102         if( stat == 0 ){ printf("no 8 bit visual\n") ; exit(1) ; }
00103 #else
00104         vid = strtol( argv[1] , NULL , 0 ) ;
00105         vinfo.visualid = (VisualID) vid ;
00106         vinfo_list = XGetVisualInfo (dpy, VisualIDMask, &vinfo, &count);
00107         if( count == 0 || vinfo_list == NULL ){fprintf(stderr,"no match\n");exit(1);}
00108         vinfo = vinfo_list[0] ;
00109 #endif
00110         vid = vinfo.visualid ;
00111         vis = vinfo.visual ;
00112 
00113         colormap = XCreateColormap( dpy, RootWindowOfScreen(XtScreen(top)) ,
00114                                     vis , AllocNone ) ;
00115 
00116         XtVaSetValues( top ,
00117                           XtNborderColor , 0 ,
00118                           XtNbackground  , 0 ,
00119                           XtNdepth       , vinfo.depth ,
00120                           XtNcolormap    , colormap ,
00121                           XtNvisual      , vis ,
00122                        NULL ) ;
00123 
00124         fff = XtVaCreateWidget( "dialog" , xmFormWidgetClass , top ,
00125                                    XmNborderWidth , 0 ,
00126                                 NULL ) ;
00127 
00128 #ifndef LABEL_ARG
00129 #define LABEL_ARG(str) \
00130   XtVaTypedArg , XmNlabelString , XmRString , (str) , strlen(str)+1
00131 #endif
00132 
00133         fred = XtVaCreateManagedWidget( "dialog" , xmPushButtonWidgetClass , fff ,
00134                                           LABEL_ARG("Jumpback") ,
00135                                           XmNtopAttachment    , XmATTACH_FORM ,
00136                                           XmNleftAttachment   , XmATTACH_FORM ,
00137                                           XmNrightAttachment  , XmATTACH_FORM ,
00138                                          NULL ) ;
00139         XtAddCallback( fred , XmNactivateCallback , fred_CB , NULL ) ;
00140 
00141         fred = XtVaCreateManagedWidget( "dialog" , xmDrawingAreaWidgetClass , fff ,
00142                                           XmNtopAttachment    , XmATTACH_WIDGET ,
00143                                           XmNtopWidget        , fred ,
00144                                           XmNleftAttachment   , XmATTACH_FORM ,
00145                                           XmNrightAttachment  , XmATTACH_FORM ,
00146                                           XmNbottomAttachment , XmATTACH_FORM ,
00147                                         NULL ) ;
00148 
00149         XtAddCallback( fred , XmNexposeCallback , elvis_CB , NULL ) ;
00150 
00151 #ifdef USE_TRUECOLOR
00152         { MRI_IMAGE * im ;
00153           im = mri_read_ppm( "bob.ppm" ) ;
00154           xim = rgb_to_XImage( XtDisplay(top) , &vinfo , im ) ;
00155           xim_ww = im->nx ; xim_hh = im->ny ;
00156           mri_free(im) ;
00157         }
00158 #else
00159         xim_ww = xim_hh = 77 ;
00160 #endif
00161 
00162         XtVaSetValues( top ,
00163                          XmNwidth , xim_ww ,
00164                          XmNheight , xim_hh+40 ,
00165                        NULL ) ;
00166 
00167 #ifdef USE_PIXMAP
00168    {  Pixel bg_pix  , fg_pix  ;
00169 # define ICON_bg bg_pix
00170 # define ICON_fg fg_pix
00171 
00172       XtVaGetValues( fred ,
00173                        XmNforeground , &bg_pix ,  /* note reversal of roles here! */
00174                        XmNbackground , &fg_pix ,
00175                      NULL ) ;
00176 
00177       logo_pixmap = XCreatePixmapFromBitmapData(
00178                         XtDisplay(top) ,
00179                         RootWindowOfScreen(XtScreen(top)) ,
00180                         logo_bits , logo_width , logo_height ,
00181                         fg_pix , bg_pix ,
00182                         DefaultDepthOfScreen(XtScreen(top)) ) ;
00183 
00184       XtVaSetValues( top , XmNiconPixmap , logo_pixmap , NULL ) ;
00185    }
00186 #endif
00187 
00188 
00189         XtManageChild(fff) ;
00190         XtRealizeWidget(top);
00191         XtAppMainLoop(app);
00192 
00193         exit(0); /* never reached */
00194 }

XImage* rgb_to_XImage Display *    dis,
XVisualInfo *    vin,
MRI_IMAGE   im
 

Referenced by AFNI_make_widgets(), main(), and mri_to_XImage().


Variable Documentation

char* vcl[] [static]
 

Initial value:

  { "StaticGray"  , "GrayScale" , "StaticColor" ,
                         "PseudoColor" , "TrueColor" , "DirectColor"  }

Definition at line 17 of file xvisual.c.

XImage* xim = NULL [static]
 

Definition at line 20 of file xvisual.c.

Referenced by elvis_CB(), and main().

int xim_hh = 0 [static]
 

Definition at line 22 of file xvisual.c.

Referenced by elvis_CB(), and main().

int xim_ww = 0 [static]
 

Definition at line 21 of file xvisual.c.

Referenced by elvis_CB(), and main().

 

Powered by Plone

This site conforms to the following standards: