Quellcode durchsuchen

cmGrPlot.h : Make callbacks for deselected objects when a new object is selected.

Added cmPlotObjCb() function.
master
Kevin Larke vor 9 Jahren
Ursprung
Commit
4cd55db162
2 geänderte Dateien mit 35 neuen und 10 gelöschten Zeilen
  1. 31
    10
      cmGrPlot.c
  2. 4
    0
      cmGrPlot.h

+ 31
- 10
cmGrPlot.c Datei anzeigen

180
 { return _cmGrPlotObjIsEnabled(op) && op->p->fop==op; }
180
 { return _cmGrPlotObjIsEnabled(op) && op->p->fop==op; }
181
 
181
 
182
 bool _cmGrPlotObjIsSelected(cmGrPlotObj_t* op)
182
 bool _cmGrPlotObjIsSelected(cmGrPlotObj_t* op)
183
-{ return _cmGrPlotObjIsFocused(op) || cmIsFlag(op->stateFlags,kSelectGrPlFl); }
183
+{ return /*_cmGrPlotObjIsFocused(op) ||*/ cmIsFlag(op->stateFlags,kSelectGrPlFl); }
184
 
184
 
185
 void _cmGrPlotObjSetupCbArg( cmGrPlotCbArg_t* a, cmGrPlotObj_t* op, cmGrPlCbSelId_t selId )
185
 void _cmGrPlotObjSetupCbArg( cmGrPlotCbArg_t* a, cmGrPlotObj_t* op, cmGrPlCbSelId_t selId )
186
 {
186
 {
249
 
249
 
250
 }
250
 }
251
 
251
 
252
+// Set the clear flag to clear all other selected objects if this object is 
253
+// selected.
252
 void _cmGrPlotObjSetSelect( cmGrPlotObj_t* op, bool clearFl )
254
 void _cmGrPlotObjSetSelect( cmGrPlotObj_t* op, bool clearFl )
253
 {
255
 {
254
   // if the object is disabled or not selectable
256
   // if the object is disabled or not selectable
257
 
259
 
258
   unsigned stateFlags = op->stateFlags;
260
   unsigned stateFlags = op->stateFlags;
259
 
261
 
260
-  // if the application callback returns false then do change the select state of the object
262
+  // if the application callback returns false then do not change the select state of the object
261
   if(_cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kSelectGrPlFl ) == false )
263
   if(_cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kSelectGrPlFl ) == false )
262
     return;
264
     return;
263
 
265
 
268
 
270
 
269
     // clear the select flag on all objects that share op->parent
271
     // clear the select flag on all objects that share op->parent
270
     for(; cop!=NULL; cop=cop->next)
272
     for(; cop!=NULL; cop=cop->next)
271
-      if( cmHandlesAreEqual(cmGrObjParent(cop->grObjH),parentObjH) )
272
-        cop->stateFlags = cmClrFlag(cop->stateFlags,kSelectGrPlFl);
273
+      if( cop!=op && cmHandlesAreEqual(cmGrObjParent(cop->grObjH),parentObjH) )
274
+      {
275
+        if( cmIsFlag(cop->stateFlags,kSelectGrPlFl) )
276
+        {  
277
+          cop->stateFlags = cmClrFlag(cop->stateFlags,kSelectGrPlFl);
278
+          
279
+          _cmGrPlotObjCb(cop, kStateChangeGrPlId, kSelectGrPlFl );
280
+        }
281
+      }
273
   }
282
   }
274
          
283
          
275
   op->stateFlags = cmTogFlag(stateFlags,kSelectGrPlFl);
284
   op->stateFlags = cmTogFlag(stateFlags,kSelectGrPlFl);
603
   {
612
   {
604
     cmGrPlotObj_t* cb_op = op;
613
     cmGrPlotObj_t* cb_op = op;
605
 
614
 
606
-    // if this is a key up/dn event and 'op' is not the 'focused op' then callback
615
+    // if this is a key up/dn event and 'op' is not the 'focused op' then 
607
     // callback on the 'focused op' instead of this 'op'.
616
     // callback on the 'focused op' instead of this 'op'.
608
     if( (cmIsFlag(flags,kKeyDnGrFl) || cmIsFlag(flags,kKeyUpGrFl)) && op->p->fop != op )
617
     if( (cmIsFlag(flags,kKeyDnGrFl) || cmIsFlag(flags,kKeyUpGrFl)) && op->p->fop != op )
609
       cb_op = op->p->fop;
618
       cb_op = op->p->fop;
834
 
843
 
835
 
844
 
836
   // set the default colors
845
   // set the default colors
837
-  op->drawColors[kSelectPlGrId] =   0xcd853f;
838
-  op->fillColors[kSelectPlGrId] =   0xdeb887; 
846
+  op->drawColors[kSelectPlGrId] =   kPeruGrId;
847
+  op->fillColors[kSelectPlGrId] =   kBurlyWoodGrId;
839
 
848
 
840
-  op->drawColors[kFocusPlGrId] =  0x483d8b;
849
+  op->drawColors[kFocusPlGrId] =  kDarkSlateBlueGrId;
841
   op->fillColors[kFocusPlGrId] =  0x8470ff; 
850
   op->fillColors[kFocusPlGrId] =  0x8470ff; 
842
 
851
 
843
-  op->drawColors[kEnablePlGrId] =  0x000000;
852
+  op->drawColors[kEnablePlGrId] =  kBlackGrId;
844
   op->fillColors[kEnablePlGrId] =  0x009ff7; 
853
   op->fillColors[kEnablePlGrId] =  0x009ff7; 
845
 
854
 
846
   op->drawColors[kDisablePlGrId] = 0xbebebe;
855
   op->drawColors[kDisablePlGrId] = 0xbebebe;
847
-  op->fillColors[kDisablePlGrId] = 0xd3d3de; 
856
+  op->fillColors[kDisablePlGrId] = kLightGrayGrId; 
848
 
857
 
849
   unsigned   grObjCfgFlags = 0;
858
   unsigned   grObjCfgFlags = 0;
850
   cmGrObjH_t parentGrH     = op->parent == NULL ? cmGrObjNullHandle : op->parent->grObjH;
859
   cmGrObjH_t parentGrH     = op->parent == NULL ? cmGrObjNullHandle : op->parent->grObjH;
1345
   return oh;
1354
   return oh;
1346
 }
1355
 }
1347
 
1356
 
1357
+void         cmGrPlotObjCb( cmGrPlH_t h, cmGrPlotObjCbFunc_t func, void* arg  )
1358
+{
1359
+  cmGrPl_t*       p = _cmGrPlHandleToPtr(h);
1360
+  cmGrPlotObj_t* op = p->list;
1361
+  cmGrPlObjH_t   oh = cmGrPlObjNullHandle;
1362
+
1363
+  for(; op!=NULL; op=op->next)
1364
+  {
1365
+    oh.h = op;
1366
+    func(arg,oh);
1367
+  }
1368
+}
1348
 
1369
 
1349
 void  cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode )
1370
 void  cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode )
1350
 {
1371
 {

+ 4
- 0
cmGrPlot.h Datei anzeigen

219
   // Given a plot object id return the associated object handle.
219
   // Given a plot object id return the associated object handle.
220
   cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
220
   cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
221
 
221
 
222
+  // Callback func(arg,objH) for every object. 
223
+  typedef void (*cmGrPlotObjCbFunc_t)( void* arg, cmGrPlObjH_t oh );
224
+  void         cmGrPlotObjCb( cmGrPlH_t h, cmGrPlotObjCbFunc_t func, void* arg );
225
+
222
   // Pass a keyboard event to the plot system.
226
   // Pass a keyboard event to the plot system.
223
   void         cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
227
   void         cmGrPlotKeyEvent(   cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
224
   
228
   

Laden…
Abbrechen
Speichern