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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/toolx/Xt/ImageArea (Version 11.3.0) and /externals/g4tools/include/toolx/Xt/ImageArea (Version 11.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef toolx_Xt_ImageArea                          4 #ifndef toolx_Xt_ImageArea
  5 #define toolx_Xt_ImageArea                          5 #define toolx_Xt_ImageArea
  6                                                     6 
  7 #include <X11/IntrinsicP.h>                         7 #include <X11/IntrinsicP.h>
  8 #include <X11/CoreP.h>                              8 #include <X11/CoreP.h>
  9 #include <X11/CompositeP.h>                         9 #include <X11/CompositeP.h>
 10 #include <X11/StringDefs.h>                        10 #include <X11/StringDefs.h>
 11                                                    11 
 12 //#define TOOLX_XT_IMAGEAREA_DEBUG                 12 //#define TOOLX_XT_IMAGEAREA_DEBUG
 13                                                    13 
 14 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                    14 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
 15 #include <stdio.h>                                 15 #include <stdio.h>
 16 #endif                                             16 #endif
 17                                                    17 
 18 namespace toolx {                                  18 namespace toolx {
 19 namespace Xt {                                     19 namespace Xt {
 20                                                    20 
 21 //////////////////////////////////////////////     21 ///////////////////////////////////////////////////////////
 22 //////////////////////////////////////////////     22 ///////////////////////////////////////////////////////////
 23 //////////////////////////////////////////////     23 ///////////////////////////////////////////////////////////
 24                                                    24 
 25 typedef struct _ImageAreaClassRec* ImageAreaWi     25 typedef struct _ImageAreaClassRec* ImageAreaWidgetClass;
 26 typedef struct _ImageAreaRec* ImageAreaWidget;     26 typedef struct _ImageAreaRec* ImageAreaWidget;
 27                                                    27 
 28 //////////////////////////////////////////////     28 ///////////////////////////////////////////////////////////
 29 //////////////////////////////////////////////     29 ///////////////////////////////////////////////////////////
 30 //////////////////////////////////////////////     30 ///////////////////////////////////////////////////////////
 31                                                    31 
 32 typedef struct {                                   32 typedef struct {
 33   void* extension;                                 33   void* extension;
 34 } ImageAreaClassPart;                              34 } ImageAreaClassPart;
 35                                                    35 
 36 typedef struct _ImageAreaClassRec {                36 typedef struct _ImageAreaClassRec {
 37   CoreClassPart core_class;                        37   CoreClassPart core_class;
 38   CompositeClassPart composite_class;              38   CompositeClassPart composite_class;
 39   ImageAreaClassPart imageArea_class;              39   ImageAreaClassPart imageArea_class;
 40 } ImageAreaClassRec;                               40 } ImageAreaClassRec;
 41                                                    41 
 42 typedef struct {                                   42 typedef struct {
 43   XtCallbackList resizeCallback;                   43   XtCallbackList resizeCallback;
 44   XtCallbackList paintCallback;                    44   XtCallbackList paintCallback;
 45   XtCallbackList eventCallback;                    45   XtCallbackList eventCallback;
 46 } ImageAreaPart;                                   46 } ImageAreaPart;
 47                                                    47 
 48 typedef struct _ImageAreaRec {                     48 typedef struct _ImageAreaRec {
 49   CorePart core;                                   49   CorePart core;
 50   CompositePart composite;                         50   CompositePart composite;
 51   ImageAreaPart imageArea;                         51   ImageAreaPart imageArea;
 52 } ImageAreaRec;                                    52 } ImageAreaRec;
 53                                                    53 
 54 //////////////////////////////////////////////     54 ///////////////////////////////////////////////////////////
 55 //////////////////////////////////////////////     55 ///////////////////////////////////////////////////////////
 56 //////////////////////////////////////////////     56 ///////////////////////////////////////////////////////////
 57                                                    57 
 58 class ImageArea {                                  58 class ImageArea {
 59 protected:                                         59 protected:
 60   static const char* class_name() {static cons     60   static const char* class_name() {static const char* s_s = "ImageArea";return s_s;}
 61 public:                                            61 public:
 62   typedef struct {                                 62   typedef struct {
 63     int reason;                                    63     int reason;
 64     XEvent* event;                                 64     XEvent* event;
 65   } XoAnyCallbackStruct;                           65   } XoAnyCallbackStruct;
 66                                                    66 
 67   static int XoCR_RESIZE() {return 1;}             67   static int XoCR_RESIZE() {return 1;}
 68   static int XoCR_PAINT()  {return 2;}             68   static int XoCR_PAINT()  {return 2;}
 69   static int XoCR_EVENT()  {return 3;}             69   static int XoCR_EVENT()  {return 3;}
 70                                                    70   
 71   static const char* XoN_resizeCallback() {sta     71   static const char* XoN_resizeCallback() {static const char* s_s = "resizeCallback";return s_s;}
 72   static const char* XoN_paintCallback()  {sta     72   static const char* XoN_paintCallback()  {static const char* s_s = "paintCallback";return s_s;}
 73   static const char* XoN_eventCallback()  {sta     73   static const char* XoN_eventCallback()  {static const char* s_s = "eventCallback";return s_s;}
 74 public:                                            74 public:
 75   static void paint(Widget a_this) {               75   static void paint(Widget a_this) {
 76     if(!XtIsRealized(a_this)) return;              76     if(!XtIsRealized(a_this)) return;
 77     XoAnyCallbackStruct value;                     77     XoAnyCallbackStruct value;
 78     value.reason = XoCR_PAINT();                   78     value.reason = XoCR_PAINT();
 79     value.event = 0;                               79     value.event = 0;
 80     ::XtCallCallbacks(a_this,XoN_paintCallback     80     ::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
 81   }                                                81   }
 82 protected:                                         82 protected:
 83   static void initialize_class(void) {             83   static void initialize_class(void) {
 84 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                    84 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
 85     ::printf("debug: toolx::Xt::ImageArea: ini     85     ::printf("debug: toolx::Xt::ImageArea: initialize_class.\n");
 86 #endif                                             86 #endif
 87   }                                                87   }
 88                                                    88 
 89   static void initialize_widget(Widget a_reque     89   static void initialize_widget(Widget a_request,Widget a_this,ArgList,Cardinal*) {
 90     if(a_request->core.width<=0)  a_this->core     90     if(a_request->core.width<=0)  a_this->core.width  = 100;
 91     if(a_request->core.height<=0) a_this->core     91     if(a_request->core.height<=0) a_this->core.height = 100;
 92                                                    92 
 93 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                    93 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
 94     ::printf("debug: toolx::Xt::ImageArea: ini     94     ::printf("debug: toolx::Xt::ImageArea: initialize_widget: %s\n",::XtName(a_this));
 95 #endif                                             95 #endif
 96                                                    96 
 97     ::XtAddEventHandler                            97     ::XtAddEventHandler
 98        (a_this,ButtonPressMask|ButtonReleaseMa     98        (a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
 99                                                    99 
100 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   100 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
101     ::printf("debug: toolx::Xt::ImageArea: ini    101     ::printf("debug: toolx::Xt::ImageArea: initialize_widget: end\n");
102 #endif                                            102 #endif
103   }                                               103   }
104                                                   104 
105   static void destroy_widget(Widget) {            105   static void destroy_widget(Widget) {
106 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   106 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
107     ::printf("debug: toolx::Xt::ImageArea: des    107     ::printf("debug: toolx::Xt::ImageArea: destroy_widget.\n");
108 #endif                                            108 #endif
109   }                                               109   }
110                                                   110 
111   static void change_widget_size(Widget a_this    111   static void change_widget_size(Widget a_this) {
112 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   112 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
113     ::printf("debug: toolx::Xt::ImageArea: cha    113     ::printf("debug: toolx::Xt::ImageArea: change_widget_size: %s\n",XtName(a_this));
114 #endif                                            114 #endif
115                                                   115 
116     if(widget_class()->core_class.superclass->    116     if(widget_class()->core_class.superclass->core_class.resize!=NULL)
117       (widget_class()->core_class.superclass->    117       (widget_class()->core_class.superclass->core_class.resize)(a_this);
118                                                   118 
119     XoAnyCallbackStruct value;                    119     XoAnyCallbackStruct value;
120     value.reason = XoCR_RESIZE();                 120     value.reason = XoCR_RESIZE();
121     value.event = 0;                              121     value.event = 0;
122     ::XtCallCallbacks(a_this,XoN_resizeCallbac    122     ::XtCallCallbacks(a_this,XoN_resizeCallback(),(XtPointer)&value);
123                                                   123 
124 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   124 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
125     ::printf("debug: toolx::Xt::ImageArea: cha    125     ::printf("debug: toolx::Xt::ImageArea: change_widget_size: end\n");
126 #endif                                            126 #endif
127 }                                                 127 }
128                                                   128 
129   static void draw_widget(Widget  a_this,XEven    129   static void draw_widget(Widget  a_this,XEvent* a_event,Region a_region) {
130 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   130 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
131     ::printf("debug: toolx::Xt::ImageArea: dra    131     ::printf("debug: toolx::Xt::ImageArea: draw_widget: %s\n",XtName(a_this));
132 #endif                                            132 #endif
133                                                   133 
134     if(widget_class()->core_class.superclass->    134     if(widget_class()->core_class.superclass->core_class.expose!=NULL)
135       (widget_class()->core_class.superclass->    135       (widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
136                                                   136 
137     XoAnyCallbackStruct value;                    137     XoAnyCallbackStruct value;
138     value.reason = XoCR_PAINT();                  138     value.reason = XoCR_PAINT();
139     value.event = a_event;                        139     value.event = a_event;
140     ::XtCallCallbacks(a_this,XoN_paintCallback    140     ::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
141                                                   141   
142 #ifdef TOOLX_XT_IMAGEAREA_DEBUG                   142 #ifdef TOOLX_XT_IMAGEAREA_DEBUG
143     ::printf("debug: toolx::Xt::ImageArea: dra    143     ::printf("debug: toolx::Xt::ImageArea: draw_widget: end\n");
144 #endif                                            144 #endif
145   }                                               145   }
146                                                   146 
147 protected:                                        147 protected:
148   static void event_handler(Widget a_this,XtPo    148   static void event_handler(Widget a_this,XtPointer,XEvent* a_event ,Boolean*) {
149     XoAnyCallbackStruct value;                    149     XoAnyCallbackStruct value;
150     value.reason = XoCR_EVENT();                  150     value.reason = XoCR_EVENT();
151     value.event = a_event;                        151     value.event = a_event;
152     ::XtCallCallbacks(a_this,XoN_eventCallback    152     ::XtCallCallbacks(a_this,XoN_eventCallback(),(XtPointer)&value);
153   }                                               153   }
154                                                   154 
155 public:                                           155 public:
156   static WidgetClass widget_class() {             156   static WidgetClass widget_class() {
157     static XtResource s_resources[] = {           157     static XtResource s_resources[] = {
158       {(String)XoN_resizeCallback(),XtCCallbac    158       {(String)XoN_resizeCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
159        XtOffset(ImageAreaWidget,imageArea.resi    159        XtOffset(ImageAreaWidget,imageArea.resizeCallback),XtRImmediate,(XtPointer)NULL},
160       {(String)XoN_paintCallback(),XtCCallback    160       {(String)XoN_paintCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
161        XtOffset(ImageAreaWidget,imageArea.pain    161        XtOffset(ImageAreaWidget,imageArea.paintCallback),XtRImmediate,(XtPointer)NULL},
162       {(String)XoN_eventCallback(),XtCCallback    162       {(String)XoN_eventCallback(),XtCCallback,XtRCallback,sizeof(XtCallbackList),
163        XtOffset(ImageAreaWidget,imageArea.even    163        XtOffset(ImageAreaWidget,imageArea.eventCallback),XtRImmediate,(XtPointer)NULL}
164     };                                            164     };
165                                                   165 
166     static ImageAreaClassRec s_imageAreaClassR    166     static ImageAreaClassRec s_imageAreaClassRec = {
167       // Core Class Part :                        167       // Core Class Part :
168       {                                           168       {
169         (WidgetClass) &compositeClassRec, // p    169         (WidgetClass) &compositeClassRec, // pointer to superclass ClassRec   
170         (String)class_name(),             // w    170         (String)class_name(),             // widget resource class name
171         sizeof(ImageAreaRec),            // si    171         sizeof(ImageAreaRec),            // size in bytes of widget record
172         initialize_class,                // cl    172         initialize_class,                // class_initialize                 
173         NULL,                            // dy    173         NULL,                            // dynamic initialization           
174         FALSE,                           // ha    174         FALSE,                           // has class been initialized?      
175         initialize_widget,               // in    175         initialize_widget,               // initialize                       
176         NULL,                            // no    176         NULL,                            // notify that initialize called    
177         XtInheritRealize,                // XC    177         XtInheritRealize,                // XCreateWindow for widget
178         NULL,                            // wi    178         NULL,                            // widget semantics name to proc mapWidget
179         0,                               // nu    179         0,                               // number of entries in actions     
180         s_resources,                     // re    180         s_resources,                     // resources for subclass fields    
181         XtNumber(s_resources),           // nu    181         XtNumber(s_resources),           // number of entries in resources   
182         NULLQUARK,                       // re    182         NULLQUARK,                       // resource class quarkified        
183         TRUE,                            // co    183         TRUE,                            // compress MotionNotify for widget 
184         TRUE,                            // co    184         TRUE,                            // compress Expose events for widget
185         TRUE,                            // co    185         TRUE,                            // compress enter and leave events  
186         TRUE,                            // se    186         TRUE,                            // select for VisibilityNotify      
187         destroy_widget,                  // fr    187         destroy_widget,                  // free data for subclass pointers  
188         change_widget_size,              // ge    188         change_widget_size,              // geom manager changed widget size 
189         draw_widget,                     // re    189         draw_widget,                     // rediplay window                  
190         NULL,                            // se    190         NULL,                            // set subclass resource values
191         NULL,                            // no    191         NULL,                            // notify that SetValues called    
192         XtInheritSetValuesAlmost,        // Se    192         XtInheritSetValuesAlmost,        // SetValues got "Almost" geo reply
193         NULL,                            // no    193         NULL,                            // notify that get_values called    
194         XtInheritAcceptFocus,            // as    194         XtInheritAcceptFocus,            // assign input focus to widget     
195         XtVersion,                       // ve    195         XtVersion,                       // version of intrinsics used       
196         NULL,                            // li    196         NULL,                            // list of callback offsets         
197         XtInheritTranslations,           // tr    197         XtInheritTranslations,           // translations                     
198         XtInheritQueryGeometry,          // re    198         XtInheritQueryGeometry,          // return preferred geometry        
199         XtInheritDisplayAccelerator,     // di    199         XtInheritDisplayAccelerator,     // display your accelerator         
200         NULL                             // po    200         NULL                             // pointer to extension record      
201       },                                          201       },
202       // Composite Class Part :                   202       // Composite Class Part :
203       {                                           203       {
204         XtInheritGeometryManager,   // geometr    204         XtInheritGeometryManager,   // geometry manager for children   
205         XtInheritChangeManaged,     // change     205         XtInheritChangeManaged,     // change managed state of child   
206         XtInheritInsertChild,       // physica    206         XtInheritInsertChild,       // physically add child to parent  
207         XtInheritDeleteChild,       // physica    207         XtInheritDeleteChild,       // physically remove child             
208         NULL                        // pointer    208         NULL                        // pointer to extension record     
209       },                                          209       },
210       // ImageArea :                              210       // ImageArea :
211       {                                           211       {
212         NULL                                      212         NULL
213       }                                           213       }
214     };                                            214     };
215     return (WidgetClass)&s_imageAreaClassRec;     215     return (WidgetClass)&s_imageAreaClassRec;
216   }                                               216   }
217 };                                                217 };
218                                                   218 
219 }}                                                219 }}
220                                                   220 
221                                                   221 
222 #endif                                            222 #endif