Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/toolx/Xt/ImageArea is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef toolx_Xt_ImageArea
0005 #define toolx_Xt_ImageArea
0006 
0007 #include <X11/IntrinsicP.h>
0008 #include <X11/CoreP.h>
0009 #include <X11/CompositeP.h>
0010 #include <X11/StringDefs.h>
0011 
0012 //#define TOOLX_XT_IMAGEAREA_DEBUG
0013 
0014 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0015 #include <stdio.h>
0016 #endif
0017 
0018 namespace toolx {
0019 namespace Xt {
0020 
0021 ///////////////////////////////////////////////////////////
0022 ///////////////////////////////////////////////////////////
0023 ///////////////////////////////////////////////////////////
0024 
0025 typedef struct _ImageAreaClassRec* ImageAreaWidgetClass;
0026 typedef struct _ImageAreaRec* ImageAreaWidget;
0027 
0028 ///////////////////////////////////////////////////////////
0029 ///////////////////////////////////////////////////////////
0030 ///////////////////////////////////////////////////////////
0031 
0032 typedef struct {
0033   void* extension;
0034 } ImageAreaClassPart;
0035 
0036 typedef struct _ImageAreaClassRec {
0037   CoreClassPart core_class;
0038   CompositeClassPart composite_class;
0039   ImageAreaClassPart imageArea_class;
0040 } ImageAreaClassRec;
0041 
0042 typedef struct {
0043   XtCallbackList resizeCallback;
0044   XtCallbackList paintCallback;
0045   XtCallbackList eventCallback;
0046 } ImageAreaPart;
0047 
0048 typedef struct _ImageAreaRec {
0049   CorePart core;
0050   CompositePart composite;
0051   ImageAreaPart imageArea;
0052 } ImageAreaRec;
0053 
0054 ///////////////////////////////////////////////////////////
0055 ///////////////////////////////////////////////////////////
0056 ///////////////////////////////////////////////////////////
0057 
0058 class ImageArea {
0059 protected:
0060   static const char* class_name() {static const char* s_s = "ImageArea";return s_s;}
0061 public:
0062   typedef struct {
0063     int reason;
0064     XEvent* event;
0065   } XoAnyCallbackStruct;
0066 
0067   static int XoCR_RESIZE() {return 1;}
0068   static int XoCR_PAINT()  {return 2;}
0069   static int XoCR_EVENT()  {return 3;}
0070   
0071   static const char* XoN_resizeCallback() {static const char* s_s = "resizeCallback";return s_s;}
0072   static const char* XoN_paintCallback()  {static const char* s_s = "paintCallback";return s_s;}
0073   static const char* XoN_eventCallback()  {static const char* s_s = "eventCallback";return s_s;}
0074 public:
0075   static void paint(Widget a_this) {
0076     if(!XtIsRealized(a_this)) return;
0077     XoAnyCallbackStruct value;
0078     value.reason = XoCR_PAINT();
0079     value.event = 0;
0080     ::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
0081   }
0082 protected:
0083   static void initialize_class(void) {
0084 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0085     ::printf("debug: toolx::Xt::ImageArea: initialize_class.\n");
0086 #endif
0087   }
0088 
0089   static void initialize_widget(Widget a_request,Widget a_this,ArgList,Cardinal*) {
0090     if(a_request->core.width<=0)  a_this->core.width  = 100;
0091     if(a_request->core.height<=0) a_this->core.height = 100;
0092 
0093 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0094     ::printf("debug: toolx::Xt::ImageArea: initialize_widget: %s\n",::XtName(a_this));
0095 #endif
0096 
0097     ::XtAddEventHandler
0098        (a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
0099 
0100 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0101     ::printf("debug: toolx::Xt::ImageArea: initialize_widget: end\n");
0102 #endif
0103   }
0104 
0105   static void destroy_widget(Widget) {
0106 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0107     ::printf("debug: toolx::Xt::ImageArea: destroy_widget.\n");
0108 #endif
0109   }
0110 
0111   static void change_widget_size(Widget a_this) {
0112 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0113     ::printf("debug: toolx::Xt::ImageArea: change_widget_size: %s\n",XtName(a_this));
0114 #endif
0115 
0116     if(widget_class()->core_class.superclass->core_class.resize!=NULL)
0117       (widget_class()->core_class.superclass->core_class.resize)(a_this);
0118 
0119     XoAnyCallbackStruct value;
0120     value.reason = XoCR_RESIZE();
0121     value.event = 0;
0122     ::XtCallCallbacks(a_this,XoN_resizeCallback(),(XtPointer)&value);
0123 
0124 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0125     ::printf("debug: toolx::Xt::ImageArea: change_widget_size: end\n");
0126 #endif
0127 }
0128 
0129   static void draw_widget(Widget  a_this,XEvent* a_event,Region a_region) {
0130 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0131     ::printf("debug: toolx::Xt::ImageArea: draw_widget: %s\n",XtName(a_this));
0132 #endif
0133 
0134     if(widget_class()->core_class.superclass->core_class.expose!=NULL)
0135       (widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
0136 
0137     XoAnyCallbackStruct value;
0138     value.reason = XoCR_PAINT();
0139     value.event = a_event;
0140     ::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
0141   
0142 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
0143     ::printf("debug: toolx::Xt::ImageArea: draw_widget: end\n");
0144 #endif
0145   }
0146 
0147 protected:
0148   static void event_handler(Widget a_this,XtPointer,XEvent* a_event ,Boolean*) {
0149     XoAnyCallbackStruct value;
0150     value.reason = XoCR_EVENT();
0151     value.event = a_event;
0152     ::XtCallCallbacks(a_this,XoN_eventCallback(),(XtPointer)&value);
0153   }
0154 
0155 public:
0156   static WidgetClass widget_class() {
0157     static XtResource s_resources[] = {
0158       {(String)XoN_resizeCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
0159        XtOffset(ImageAreaWidget,imageArea.resizeCallback),XtRImmediate,(XtPointer)NULL},
0160       {(String)XoN_paintCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
0161        XtOffset(ImageAreaWidget,imageArea.paintCallback),XtRImmediate,(XtPointer)NULL},
0162       {(String)XoN_eventCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
0163        XtOffset(ImageAreaWidget,imageArea.eventCallback),XtRImmediate,(XtPointer)NULL}
0164     };
0165 
0166     static ImageAreaClassRec s_imageAreaClassRec = {
0167       // Core Class Part :
0168       {
0169         (WidgetClass) &compositeClassRec, // pointer to superclass ClassRec   
0170         (String)class_name(),             // widget resource class name
0171         sizeof(ImageAreaRec),            // size in bytes of widget record
0172         initialize_class,                // class_initialize                 
0173         NULL,                            // dynamic initialization           
0174         FALSE,                           // has class been initialized?      
0175         initialize_widget,               // initialize                       
0176         NULL,                            // notify that initialize called    
0177         XtInheritRealize,                // XCreateWindow for widget
0178         NULL,                            // widget semantics name to proc mapWidget
0179         0,                               // number of entries in actions     
0180         s_resources,                     // resources for subclass fields    
0181         XtNumber(s_resources),           // number of entries in resources   
0182         NULLQUARK,                       // resource class quarkified        
0183         TRUE,                            // compress MotionNotify for widget 
0184         TRUE,                            // compress Expose events for widget
0185         TRUE,                            // compress enter and leave events  
0186         TRUE,                            // select for VisibilityNotify      
0187         destroy_widget,                  // free data for subclass pointers  
0188         change_widget_size,              // geom manager changed widget size 
0189         draw_widget,                     // rediplay window                  
0190         NULL,                            // set subclass resource values
0191         NULL,                            // notify that SetValues called    
0192         XtInheritSetValuesAlmost,        // SetValues got "Almost" geo reply
0193         NULL,                            // notify that get_values called    
0194         XtInheritAcceptFocus,            // assign input focus to widget     
0195         XtVersion,                       // version of intrinsics used       
0196         NULL,                            // list of callback offsets         
0197         XtInheritTranslations,           // translations                     
0198         XtInheritQueryGeometry,          // return preferred geometry        
0199         XtInheritDisplayAccelerator,     // display your accelerator         
0200         NULL                             // pointer to extension record      
0201       },
0202       // Composite Class Part :
0203       {
0204         XtInheritGeometryManager,   // geometry manager for children   
0205         XtInheritChangeManaged,     // change managed state of child   
0206         XtInheritInsertChild,       // physically add child to parent  
0207         XtInheritDeleteChild,       // physically remove child             
0208         NULL                        // pointer to extension record     
0209       },
0210       // ImageArea :
0211       {
0212         NULL
0213       }
0214     };
0215     return (WidgetClass)&s_imageAreaClassRec;
0216   }
0217 };
0218 
0219 }}
0220 
0221 
0222 #endif