Procházet zdrojové kódy

Corrected useage of pre-event vs state change

master
kevin před 12 roky
rodič
revize
00e2219a42
1 změnil soubory, kde provedl 22 přidání a 6 odebrání
  1. 22
    6
      cmGrPlot.c

+ 22
- 6
cmGrPlot.c Zobrazit soubor

217
     if( cmIsNotFlag(op->cfgFlags,kNoFocusGrPlFl) && cmIsNotFlag(op->cfgFlags,kNoDrawGrPlFl) )
217
     if( cmIsNotFlag(op->cfgFlags,kNoFocusGrPlFl) && cmIsNotFlag(op->cfgFlags,kNoDrawGrPlFl) )
218
       break;
218
       break;
219
 
219
 
220
-  if( op != NULL )
220
+  // if the focus is changing to a new object
221
+  if( op != NULL  && op->p->fop != op )
221
   {  
222
   {  
222
     if( op->p->fop != NULL )
223
     if( op->p->fop != NULL )
223
     {
224
     {
224
       // if the application callback returns false then do no release focus from the current object
225
       // if the application callback returns false then do no release focus from the current object
225
-      if(_cmGrPlotObjCb(op->p->fop, kStateChangeGrPlId, kFocusGrPlFl ) == false )
226
+      if(_cmGrPlotObjCb(op->p->fop, kPreEventCbSelGrPlId, kFocusGrPlFl ) == false )
226
         return;
227
         return;
227
 
228
 
229
+      cmGrPlotObj_t* fop = op->p->fop;
230
+
228
       op->p->fop = NULL;
231
       op->p->fop = NULL;
232
+
233
+      // notify focus loser
234
+      _cmGrPlotObjCb(fop, kStateChangeGrPlId, kFocusGrPlFl );
229
     }
235
     }
230
 
236
 
231
     // if the application callback returns false then do not give focus to the selected object
237
     // if the application callback returns false then do not give focus to the selected object
232
-    if(_cmGrPlotObjCb(op, kStateChangeGrPlId, kFocusGrPlFl ) == false )
238
+    if(_cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kFocusGrPlFl ) == false )
233
       return;
239
       return;
234
 
240
 
235
     op->p->fop = op;
241
     op->p->fop = op;
242
+
243
+    // notify focus winner
244
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kFocusGrPlFl );
245
+        
236
   }
246
   }
237
 
247
 
238
 }
248
 }
246
   unsigned stateFlags = op->stateFlags;
256
   unsigned stateFlags = op->stateFlags;
247
 
257
 
248
   // if the application callback returns false then do change the select state of the object
258
   // if the application callback returns false then do change the select state of the object
249
-  if(_cmGrPlotObjCb(op, kStateChangeGrPlId, kSelectGrPlFl ) == false )
259
+  if(_cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kSelectGrPlFl ) == false )
250
     return;
260
     return;
251
 
261
 
252
   if( clearFl )
262
   if( clearFl )
262
          
272
          
263
   op->stateFlags = cmTogFlag(stateFlags,kSelectGrPlFl);
273
   op->stateFlags = cmTogFlag(stateFlags,kSelectGrPlFl);
264
 
274
 
275
+  // notify state change
276
+  _cmGrPlotObjCb(op, kStateChangeGrPlId, kSelectGrPlFl );
265
 }
277
 }
266
 
278
 
267
 
279
 
914
 
926
 
915
   if( cmIsFlag(flags,kVisibleGrPlFl) != _cmGrPlotObjIsVisible(op) )
927
   if( cmIsFlag(flags,kVisibleGrPlFl) != _cmGrPlotObjIsVisible(op) )
916
   {
928
   {
917
-    if( _cmGrPlotObjCb(op, kStateChangeGrPlId, kVisibleGrPlFl ) == false )
929
+    if( _cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kVisibleGrPlFl ) == false )
918
       return;
930
       return;
919
 
931
 
920
     op->cfgFlags = cmTogFlag(op->cfgFlags,kNoDrawGrPlFl);
932
     op->cfgFlags = cmTogFlag(op->cfgFlags,kNoDrawGrPlFl);
933
+
934
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kVisibleGrPlFl );
921
   }
935
   }
922
 
936
 
923
   if( cmIsFlag(flags,kEnabledGrPlFl) != _cmGrPlotObjIsEnabled(op) )
937
   if( cmIsFlag(flags,kEnabledGrPlFl) != _cmGrPlotObjIsEnabled(op) )
924
   {
938
   {
925
-    if( _cmGrPlotObjCb(op, kStateChangeGrPlId, kEnabledGrPlFl ) == false )
939
+    if( _cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kEnabledGrPlFl ) == false )
926
       return;
940
       return;
927
 
941
 
928
     op->stateFlags = cmTogFlag(op->cfgFlags,kEnabledGrPlFl);
942
     op->stateFlags = cmTogFlag(op->cfgFlags,kEnabledGrPlFl);
943
+
944
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kEnabledGrPlFl );        
929
   }
945
   }
930
 
946
 
931
   bool fl;
947
   bool fl;

Načítá se…
Zrušit
Uložit