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