Преглед изворни кода

Corrected useage of pre-event vs state change

master
kevin пре 12 година
родитељ
комит
00e2219a42
1 измењених фајлова са 22 додато и 6 уклоњено
  1. 22
    6
      cmGrPlot.c

+ 22
- 6
cmGrPlot.c Прегледај датотеку

@@ -217,22 +217,32 @@ void _cmGrPlotObjSetFocus( cmGrPlotObj_t* op )
217 217
     if( cmIsNotFlag(op->cfgFlags,kNoFocusGrPlFl) && cmIsNotFlag(op->cfgFlags,kNoDrawGrPlFl) )
218 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 223
     if( op->p->fop != NULL )
223 224
     {
224 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 227
         return;
227 228
 
229
+      cmGrPlotObj_t* fop = op->p->fop;
230
+
228 231
       op->p->fop = NULL;
232
+
233
+      // notify focus loser
234
+      _cmGrPlotObjCb(fop, kStateChangeGrPlId, kFocusGrPlFl );
229 235
     }
230 236
 
231 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 239
       return;
234 240
 
235 241
     op->p->fop = op;
242
+
243
+    // notify focus winner
244
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kFocusGrPlFl );
245
+        
236 246
   }
237 247
 
238 248
 }
@@ -246,7 +256,7 @@ void _cmGrPlotObjSetSelect( cmGrPlotObj_t* op, bool clearFl )
246 256
   unsigned stateFlags = op->stateFlags;
247 257
 
248 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 260
     return;
251 261
 
252 262
   if( clearFl )
@@ -262,6 +272,8 @@ void _cmGrPlotObjSetSelect( cmGrPlotObj_t* op, bool clearFl )
262 272
          
263 273
   op->stateFlags = cmTogFlag(stateFlags,kSelectGrPlFl);
264 274
 
275
+  // notify state change
276
+  _cmGrPlotObjCb(op, kStateChangeGrPlId, kSelectGrPlFl );
265 277
 }
266 278
 
267 279
 
@@ -914,18 +926,22 @@ void       cmGrPlotObjSetStateFlags( cmGrPlObjH_t oh, unsigned flags )
914 926
 
915 927
   if( cmIsFlag(flags,kVisibleGrPlFl) != _cmGrPlotObjIsVisible(op) )
916 928
   {
917
-    if( _cmGrPlotObjCb(op, kStateChangeGrPlId, kVisibleGrPlFl ) == false )
929
+    if( _cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kVisibleGrPlFl ) == false )
918 930
       return;
919 931
 
920 932
     op->cfgFlags = cmTogFlag(op->cfgFlags,kNoDrawGrPlFl);
933
+
934
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kVisibleGrPlFl );
921 935
   }
922 936
 
923 937
   if( cmIsFlag(flags,kEnabledGrPlFl) != _cmGrPlotObjIsEnabled(op) )
924 938
   {
925
-    if( _cmGrPlotObjCb(op, kStateChangeGrPlId, kEnabledGrPlFl ) == false )
939
+    if( _cmGrPlotObjCb(op, kPreEventCbSelGrPlId, kEnabledGrPlFl ) == false )
926 940
       return;
927 941
 
928 942
     op->stateFlags = cmTogFlag(op->cfgFlags,kEnabledGrPlFl);
943
+
944
+    _cmGrPlotObjCb(op, kStateChangeGrPlId, kEnabledGrPlFl );        
929 945
   }
930 946
 
931 947
   bool fl;

Loading…
Откажи
Сачувај