Browse Source

cmGrPlot.h/c Added default plot obj callback function to mgr.

master
kpl 12 years ago
parent
commit
9d4c82ae37
2 changed files with 27 additions and 7 deletions
  1. 16
    5
      cmGrPlot.c
  2. 11
    2
      cmGrPlot.h

+ 16
- 5
cmGrPlot.c View File

62
 
62
 
63
 typedef struct cmGrPl_str
63
 typedef struct cmGrPl_str
64
 {
64
 {
65
-  cmCtx_t*       ctx;  // 
66
-  cmErr_t        err;  //
67
-  cmGrPlotObj_t* list; // plot object linked list
68
-  cmGrPlotObj_t* fop;  // focused object ptr
65
+  cmCtx_t*         ctx;         // 
66
+  cmErr_t          err;         //
67
+  cmGrPlotObj_t*   list;        // plot object linked list
68
+  cmGrPlotObj_t*   fop;         // focused object ptr
69
+  cmGrPlotCbFunc_t cbFunc;      // dflt callback function
70
+  void*            cbArg;       // dflt callback function arg.
69
 } cmGrPl_t;
71
 } cmGrPl_t;
70
 
72
 
71
 cmGrPlH_t    cmGrPlNullHandle    = cmSTATIC_NULL_HANDLE;
73
 cmGrPlH_t    cmGrPlNullHandle    = cmSTATIC_NULL_HANDLE;
196
   {
198
   {
197
     cmGrPlotCbArg_t a;
199
     cmGrPlotCbArg_t a;
198
 
200
 
199
-    _cmGrPlotObjSetupCbArg(&a,op,kPreEventCbSelGrPlId);
201
+    _cmGrPlotObjSetupCbArg(&a,op,selId);
200
     a.deltaFlags = deltaFlags; 
202
     a.deltaFlags = deltaFlags; 
201
     return op->cbFunc(&a);
203
     return op->cbFunc(&a);
202
   }
204
   }
743
   op->fontId     = kHelveticaFfGrId;
745
   op->fontId     = kHelveticaFfGrId;
744
   op->fontSize   = 12;
746
   op->fontSize   = 12;
745
   op->fontStyle  = kNormalFsGrFl;
747
   op->fontStyle  = kNormalFsGrFl;
748
+  op->cbFunc     = p->cbFunc;
749
+  op->cbArg      = p->cbArg;
746
 
750
 
747
   if( cmIsFlag(op->cfgFlags,kSymbolGrPlFl) )
751
   if( cmIsFlag(op->cfgFlags,kSymbolGrPlFl) )
748
   {
752
   {
1232
     _cmGrPlotObjEvent(&a, eventFlags, keycode, 0, 0 );   
1236
     _cmGrPlotObjEvent(&a, eventFlags, keycode, 0, 0 );   
1233
   }   
1237
   }   
1234
 }
1238
 }
1239
+
1240
+void  cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg )
1241
+{
1242
+  cmGrPl_t*      p  = _cmGrPlHandleToPtr(h);
1243
+  p->cbFunc = func;
1244
+  p->cbArg  = arg;
1245
+}

+ 11
- 2
cmGrPlot.h View File

94
     cmGrKeyCodeId_t eventKey;     // Event keys (See the cmGrEvent() keys)
94
     cmGrKeyCodeId_t eventKey;     // Event keys (See the cmGrEvent() keys)
95
     int             eventX;       // Mouse X,Y location when event was generated (Same as cmGrEvent()) 
95
     int             eventX;       // Mouse X,Y location when event was generated (Same as cmGrEvent()) 
96
     int             eventY;       // 
96
     int             eventY;       // 
97
-    unsigned        deltaFlags;   // Event caused an object state change (See kXXXGrPlFl flags) 
97
+    unsigned        deltaFlags;   // Event which caused an object state change (See kXXXGrPlFl flags) 
98
   } cmGrPlotCbArg_t;
98
   } cmGrPlotCbArg_t;
99
 
99
 
100
 
100
 
104
   // the object has not yet been changed.  This may be confusing because if 
104
   // the object has not yet been changed.  This may be confusing because if 
105
   // the state of the object is queried inside the callback it will have the 
105
   // the state of the object is queried inside the callback it will have the 
106
   // pre-change state - but this state will be automatically toggled when the 
106
   // pre-change state - but this state will be automatically toggled when the 
107
-  // callback returns  'true'.  
107
+  // callback returns  'true'.  Examine the arg->deltaFlags to determine the
108
+  // state attribute which is changing.
108
   typedef bool (*cmGrPlotCbFunc_t)( cmGrPlotCbArg_t* arg );
109
   typedef bool (*cmGrPlotCbFunc_t)( cmGrPlotCbArg_t* arg );
109
 
110
 
110
   extern cmGrPlH_t    cmGrPlNullHandle;
111
   extern cmGrPlH_t    cmGrPlNullHandle;
201
   cmGrPlRC_t   cmGrPlotClear(   cmGrPlH_t h ); // destroy all objects
202
   cmGrPlRC_t   cmGrPlotClear(   cmGrPlH_t h ); // destroy all objects
202
   cmErr_t*     cmGrPlotErr(     cmGrPlH_t h );
203
   cmErr_t*     cmGrPlotErr(     cmGrPlH_t h );
203
   cmRpt_t*     cmGrPlotRpt(     cmGrPlH_t h );
204
   cmRpt_t*     cmGrPlotRpt(     cmGrPlH_t h );
205
+  
206
+  // Return the count of plot objects.
204
   unsigned     cmGrPlotObjectCount(   cmGrPlH_t h );
207
   unsigned     cmGrPlotObjectCount(   cmGrPlH_t h );
208
+
209
+  // Return the handle of the ith object (0<=index<cmGrPlotObjectCount())
205
   cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
210
   cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
211
+
212
+  // Given a plot object id return the associated object handle.
206
   cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
213
   cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
207
 
214
 
208
   // Pass a keyboard event to the plot system.
215
   // Pass a keyboard event to the plot system.
209
   void         cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
216
   void         cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
210
   
217
   
218
+  // Set the default object callback and arg.
219
+  void         cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg );
211
 
220
 
212
 
221
 
213
 #ifdef __cplusplus
222
 #ifdef __cplusplus

Loading…
Cancel
Save