KaliVeda
Toolkit for HIC analysis
KVLVContainer.cpp
1 /*
2 $Id: KVLVContainer.cpp,v 1.8 2009/04/28 09:11:29 franklan Exp $
3 $Revision: 1.8 $
4 $Date: 2009/04/28 09:11:29 $
5 */
6 
7 //Created by KVClassFactory on Wed Apr 9 13:54:31 2008
8 //Author: franklan
9 
10 #include "KVListView.h"
11 #include "KVLVContainer.h"
12 #include "KVLVEntry.h"
13 #include "TFunction.h"
14 #include "TRootContextMenu.h"
15 #include "TSystem.h"
16 #include <KVBase.h>
17 #include <TGMsgBox.h>
18 #include "TGClient.h"
19 #include "TEnv.h"
20 using namespace std;
21 
30 
32 public:
33  KVLVContainer* fContainer; // object container
34 
36  {
37  return kTRUE;
38  }
39  Int_t Compare(const TObject* obj) const;
40 };
41 
42 
43 
46 
48 {
49  // Method responsible for sorting the objects in the GUI list
50 
51  KVLVEntry* f1 = (KVLVEntry*) fFrame;
52  KVLVEntry* f2 = (KVLVEntry*)((TGFrameElement*) obj)->fFrame;
53  TObject* r1 = (TObject*)f1->GetUserData();
54  TObject* r2 = (TObject*)f2->GetUserData();
55  return fContainer->fSortType * fContainer->fSortData->Compare(r1, r2);
56 }
57 
58 
59 
62 // KVLVContainer and KVLVColumnData are utility classes used by KVListView
63 //
64 
65 
66 
67 
69 void KVLVColumnData::GetData(TObject* obj, Long_t& i)
70 {
71  fMethCall.Execute(obj, "", i);
72 }
73 
74 
75 
77 
79 {
80  fMethCall.Execute(obj, "", i);
81 }
82 
83 
84 
86 
88 {
89  if (fRetType == kTString) {
90  Long_t lret;
91  fMethCall.Execute(obj, "", lret);
92  i = ((TString*)lret)->Data();
93  return;
94  }
95  Char_t* cret;
96  fMethCall.Execute(obj, "", &cret);
97  i.Form("%s", cret);
98 }
99 
100 
101 
103 
105 {
106  Long_t lret;
107  fMethCall.Execute(obj, "", lret);
108  switch (fRetType) {
109  case kDatimeRef:
110  ((TDatime*)lret)->Copy(i);
111  break;
112 
113  case kDatimeInt:
114  i.Set((UInt_t)lret);
115  }
116 }
117 
118 
119 
122 
124 {
125 
126  // Format string with column data for object
127 
128  result = "";
129  Long_t lret;
130  Double_t dret;
131  KVDatime dtret;
132  switch (fRetType) {
133 
135  case (Int_t)kTString :
136  GetData(obj, result);
137  break;
138 
139  case (Int_t)TMethodCall::kLong :
140  GetData(obj, lret);
141  result.Form(fDataFormat, lret);
142  break;
143 
145  GetData(obj, dret);
146  result.Form(fDataFormat, dret);
147  break;
148 
149  case kDatimeRef:
150  case kDatimeInt:
151  GetData(obj, dtret);
152  result.Form("%s", dtret.String(fFmt));
153  break;
154 
155  default:
156  std::cout << "Error in <KVLVColumnData::GetDataString> : column " << fName << " : this type is not supported "
157  << (Int_t)fMethCall.ReturnType() << std::endl;
158  break;
159  }
160  return result.Data();
161 }
162 
163 
164 
178 
180 {
181  // If data in column is date & time info, use this method to
182  //
183  // - set the format for presenting the date & time. These are the formats
184  // available for KVDatime objects, i.e.
185  // KVDatime::kCTIME - ctime format (default) e.g. Thu Apr 10 10:48:34 2008
186  // KVDatime::kSQL - SQL format e.g. 1997-01-15 20:16:28
187  // KVDatime::kGANACQ - GANIL acquisition format e.g. 29-SEP-2005 09:42:17.00
188  //
189  // - define how the information is obtained from the object. The method
190  // given to the constructor must return either
191  // a reference/pointer to TDatime/KVDatime : with_reference=kTRUE (default)
192  // a UInt_t/time_t value (such as returned by TDatime::Convert) : with_reference=kFALSE
193 
194  fFmt = fmt;
195  if (with_reference) {
196  fRetType = kDatimeRef;
197  // determine class of returned pointer/reference
198  TString ptr_type = fMethCall.GetMethod()->GetReturnTypeName();
199  fIsKVDatime = ptr_type.Contains("KVDatime");
200  }
201  else {
202  fRetType = kDatimeInt;
203  }
204 }
205 
206 
207 
209 
211 {
212  KVDatime d1, d2;
213  GetData(o1, d1);
214  GetData(o2, d2);
215  return (d1 < d2 ? -1 : (d1 > d2 ? 1 : 0));
216 }
217 
218 
219 
221 
223 {
224  TString s1, s2;
225  GetData(o1, s1);
226  GetData(o2, s2);
227  return s2.CompareTo(s1);
228 }
229 
230 
231 
233 
235 {
236  Long_t l1, l2;
237  GetData(o1, l1);
238  GetData(o2, l2);
239  return (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0));
240 }
241 
242 
243 
245 
247 {
248  Double_t l1, l2;
249  GetData(o1, l1);
250  GetData(o2, l2);
251  return (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0));
252 }
253 
254 
255 
256 
264 
266 {
267  // Compare (for sorting) the two objects based on the type of data stored
268  // in this column. The sorting depends on the return type of the data.
269  // for integers: return 1 if ob1->data < ob2->data etc.
270  // for floats: return 1 if ob1->data < ob2->data etc.
271  // for strings: alphabetical sorting using TString::CompareTo
272  // for dates: chronological order (earliest first)
273 
274  switch (fRetType) {
275 
277  return Compare_string(ob1, ob2);
278  break;
279 
280  case (Int_t)TMethodCall::kLong :
281  return Compare_long(ob1, ob2);
282  break;
283 
285  return Compare_double(ob1, ob2);
286  break;
287 
288  case kDatimeRef:
289  case kDatimeInt:
290  return Compare_date(ob1, ob2);
291  break;
292 
293  default:
294  std::cout << "Error in <KVLVColumnData::Compare> : this type is not supported "
295  << (Int_t)fMethCall.ReturnType() << std::endl;
296  break;
297  }
298  return 0;
299 }
300 
301 
302 
303 
305 
307  : TGLVContainer(p, w, h, options, back)
308 {
309  default_init();
310 }
311 
312 
313 
315 
317  : TGLVContainer(p, options, back)
318 {
319  default_init();
320 }
321 
322 
323 
331 
333 {
334  // Default initialisation of list view container
335  // Multiple selection is enabled
336  // The parent list view widget handles messages generated by container.
337  // By default, we allow objects' context menu to be opened with right-click,
338  // and objects' Browse() method to be executed by double-clicking.
339  // This can be modified using AllowContextMenu(kFALSE) and AllowDoubleClick(kFALSE).
340 
342  fIsResized = kFALSE;
343  fSort = kFALSE;
344  fSortDir = 0;
345  fColData = 0;
347  fContextMenu = new TContextMenu("KVListViewContextMenu");
348  Connect("Clicked(TGFrame*,Int_t,Int_t,Int_t)",
349  "KVLVContainer", this, "OpenContextMenu(TGFrame*,Int_t,Int_t,Int_t)");
350  Connect("DoubleClicked(TGFrame*,Int_t,Int_t,Int_t)",
351  "KVLVContainer", this, "DoDoubleClick(TGFrame*,Int_t,Int_t,Int_t)");
352  fUserItems = new KVList;
355 
360 
363 
365  fObjClass = 0;
366 
368 }
369 
370 
371 
374 
376 {
377  // Destructor
378  if (fSortDir) delete [] fSortDir;
379  DeleteColData();
380  delete fContextMenu;
381  fUserItems->Clear();
382  delete fUserItems;
384  delete fPickOrderedObjects;
387 }
388 
389 
390 
391 
393 
395 {
396  if (fColData) {
397  for (int i = 0; i < fNcols; i++) {
398  if (fColData[i]) delete fColData[i];
399  }
400  delete [] fColData;
401  fColData = 0;
402  }
403 }
404 
405 
406 
407 
410 
411 void KVLVContainer::Sort(int column)
412 {
413  // Sort objects in container according to contents of given column.
414 
415  fSortData = fColData[column];
416  fSortType = fSortDir[column];
417  fSort = kTRUE;
418 
419  fList->Sort();
420  //invert sort direction for this column for next time
421  fSortDir[column] = -fSortDir[column];
422 
423  TGCanvas* canvas = (TGCanvas*) this->GetParent()->GetParent();
424  canvas->Layout();
425 
426  fSort = kFALSE;
427 }
428 
429 
430 
431 
434 
436 {
437  // Add an item to the list
438 
439  KVLVFrameElement* nw;
440 
441  nw = new KVLVFrameElement;
442  nw->fFrame = f;
443  nw->fLayout = l ? l : fgDefaultHints;
444  nw->fState = 1;
445  nw->fContainer = this;
446  fList->Add(nw);
447 }
448 
449 
450 
451 
457 
458 void KVLVContainer::Display(const TCollection* list_of_objects)
459 {
460  // Display the list of objects in the container.
461  // If the list is very long (> KVListView.MaxListLength)
462  // we pop up a dialog box to ask if all items should be displayed
463  // which can take quite a long time
464 
465  /* remove all items from display, but keep list in memory */
467  RemoveAll();
469 
470  Int_t max_entries = gEnv->GetValue("KVListView.MaxListLength", 1000);
471  if (list_of_objects->GetEntries() > max_entries) {
472  Int_t ret;
473  new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Long list",
474  Form("The list contains more than %d items. Do you want to display all items ?",
475  max_entries),
476  kMBIconQuestion, kMBYes | kMBNo, &ret);
477  if (ret & kMBNo) {
478  // display only the first KVListView.MaxListLength entries
479  TList list2;
480  Int_t N = 0;
481  TIter next(list_of_objects);
482  TObject* o;
483  while ((o = next()) && (N++) < max_entries) list2.Add(o);
484  FillList(&list2);
485  }
486  else
487  FillList(list_of_objects);
488  }
489  else
490  FillList(list_of_objects);
491  if (!fIsResized) {
493  fIsResized = kTRUE;
494  }
495  TGCanvas* canvas = (TGCanvas*) this->GetParent()->GetParent();
496  canvas->Layout();
497 
498  MapSubwindows();
499 }
500 
501 
502 
503 
507 
509 {
510  // Redisplay the list of objects in the container.
511  // This can be used to refresh the contents of the window.
512 
513  Display();
514 }
515 
516 
517 
518 
522 
524 {
525  // When the graphical list is emptied we need to empty the list
526  // of user objects also.
527 
530 }
531 
532 
533 
534 
538 
540 {
541  // Fill list from list
542  // Pointers to objects are stored in internal list fUserItems for Refresh()
543 
544  if (l) {
545  fUserItems->Clear();
546  }
547 
548  if (l && !l->GetSize()) return;
549 
550  TCollection* theList = (TCollection*)(l ? l : fUserItems);
551  TIter nxt(theList);
552  TObject* obj = 0;
553  while ((obj = nxt())) {
554  if (l) fUserItems->Add(obj);
555  KVLVEntry* ent;
557  ent = new KVLVEntry(obj, dynamic_cast<KVBase*>(obj)->GetLabel(), this, fNcols, fColData);
558  else
559  ent = new KVLVEntry(obj, this, fNcols, fColData);
560  AddItem(ent);
561  }
562 }
563 
564 
565 
566 
568 
570 {
571  DeleteColData();
572  if (fSortDir) delete [] fSortDir;
573  fNcols = ncols;
574  fSortDir = new int [ncols];
575  fColData = new KVLVColumnData* [ncols];
576  for (int i = 0; i < ncols; i++) {
577  fSortDir[i] = 1;
578  fColData[i] = 0;
579  }
580 }
581 
582 
583 
584 
586 
587 void KVLVContainer::SetDataColumn(Int_t index, TClass* cl, const Char_t* name, const Char_t* method)
588 {
589  fColData[index] = new KVLVColumnData(cl, name, method);
590 }
591 
592 
593 
594 
597 
599 {
600  // Find item with fUserData == userData in container.
601 
602  TGFrameElement* el;
603  TIter next(fList);
604  TGLVEntry* f = 0;
605  while ((el = (TGFrameElement*) next())) {
606  f = (TGLVEntry*) el->fFrame;
607  if (f->GetUserData() == userData) {
608  return f;
609  }
610  }
611  return 0;
612 }
613 
614 
615 
616 
620 
621 void KVLVContainer::ActivateItemWithData(void* userData, Bool_t activate)
622 {
623  // Find item with fUserData == userData in container and make it active
624  // (inactive if activate=kFALSE).
625 
626  TGFrameElement* el;
627  TIter next(fList);
628  while ((el = (TGFrameElement*) next())) {
629  TGLVEntry* f = (TGLVEntry*) el->fFrame;
630  if (f->GetUserData() == userData) {
631  if (activate) ActivateItem(el);
632  else DeActivateItem(el);
633  break;
634  }
635  }
636  fClient->NeedRedraw(this);
637 }
638 
639 
640 
641 
643 
645 {
646  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
647  TString val;
648  TGFrameElement* el;
649  TIter next(fList);
650  TGLVEntry* f = 0;
651  while ((el = (TGFrameElement*) next())) {
652  f = (TGLVEntry*) el->fFrame;
653  CD->GetData((TObject*)f->GetUserData(), val);
654  if (val == data) return f;
655  }
656  return 0;
657 }
658 
659 
660 
661 
663 
665 {
666  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
667  Long_t val;
668  TGFrameElement* el;
669  TIter next(fList);
670  TGLVEntry* f = 0;
671  while ((el = (TGFrameElement*) next())) {
672  f = (TGLVEntry*) el->fFrame;
673  CD->GetData((TObject*)f->GetUserData(), val);
674  if (val == data) return f;
675  }
676  return 0;
677 }
678 
679 
680 
681 
683 
685 {
686  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
687  Double_t val;
688  TGFrameElement* el;
689  TIter next(fList);
690  TGLVEntry* f = 0;
691  while ((el = (TGFrameElement*) next())) {
692  f = (TGLVEntry*) el->fFrame;
693  CD->GetData((TObject*)f->GetUserData(), val);
694  if (val == data) return f;
695  }
696  return 0;
697 }
698 
699 
700 
701 
703 
704 void KVLVContainer::ActivateItemWithColumnData(const Char_t* colname, const Char_t* data, Bool_t activ)
705 {
706  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
707  TString val;
708  TGFrameElement* el;
709  TIter next(fList);
710  TGLVEntry* f = 0;
711  while ((el = (TGFrameElement*) next())) {
712  f = (TGLVEntry*) el->fFrame;
713  CD->GetData((TObject*)f->GetUserData(), val);
714  if (val == data) {
715  if (activ) ActivateItem(el);
716  else DeActivateItem(el);
717  break;
718  }
719  }
720  fClient->NeedRedraw(this);
721 }
722 
723 
724 
725 
727 
729 {
730  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
731  Long_t val;
732  TGFrameElement* el;
733  TIter next(fList);
734  TGLVEntry* f = 0;
735  while ((el = (TGFrameElement*) next())) {
736  f = (TGLVEntry*) el->fFrame;
737  CD->GetData((TObject*)f->GetUserData(), val);
738  if (val == data) {
739  printf("%ld\n", data);
740  if (activ) ActivateItemFromSelectAll(el);
741  else DeActivateItem(el);
742  break;
743  }
744  }
745  //fClient->NeedRedraw(this);
746 }
747 
748 
749 
754 
756 {
757  // Activate items in the list whose column 'colname' contains the integer values in 'data'
758  //
759  // If several items have the same value of 'colname', only the first will be activated.
760  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
761  TGFrameElement* el;
762  TIter next(fList);
763  TGLVEntry* f = 0;
764  Long_t val;
765  data.Begin();
766  while (!data.End()) {
767  Int_t nd = data.Next();
768  //printf("nd=%d\n",nd);
769  next.Reset();
770  Bool_t find = kFALSE;
771  while ((el = (TGFrameElement*) next()) && !find) {
772  f = (TGLVEntry*) el->fFrame;
773  CD->GetData((TObject*)f->GetUserData(), val);
774  if (val == nd) {
775  find = kTRUE;
776  if (activ) ActivateItemFromSelectAll(el);
777  else DeActivateItem(el);
778  }
779  }
780  }
781  fClient->NeedRedraw(this);
782 }
783 
784 
785 
792 
793 void KVLVContainer::ActivateItemsWithColumnData(const Char_t* colname, const run_index_list& data, Bool_t activate)
794 {
795  // Activate items in the list whose column 'colname' contains the run_index_t values in 'data'
796  //
797  // \note the column must contain strings, i.e. the result of calling run_index_t::as_string()
798  //
799  // If several items have the same value of 'colname', only the first will be activated.
800  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
801  TGFrameElement* el;
802  TIter next(fList);
803  TGLVEntry* f = 0;
804  TString val;
805 
806  for(auto& r_ind : data)
807  {
808  next.Reset();
809  Bool_t find = kFALSE;
810  while ((el = (TGFrameElement*) next()) && !find) {
811  f = (TGLVEntry*) el->fFrame;
812  CD->GetData((TObject*)f->GetUserData(), val);
813  if (run_index_t{val} == r_ind) {
814  find = kTRUE;
815  if (activate) ActivateItemFromSelectAll(el);
816  else DeActivateItem(el);
817  }
818  }
819  }
820  fClient->NeedRedraw(this);
821 }
822 
823 
824 
825 
827 
829 {
830  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
831  Double_t val;
832  TGFrameElement* el;
833  TIter next(fList);
834  TGLVEntry* f = 0;
835  while ((el = (TGFrameElement*) next())) {
836  f = (TGLVEntry*) el->fFrame;
837  CD->GetData((TObject*)f->GetUserData(), val);
838  if (val == data) {
839  if (activ) ActivateItem(el);
840  else DeActivateItem(el);
841  break;
842  }
843  }
844  fClient->NeedRedraw(this);
845 }
846 
847 
848 
849 
860 
862 {
863  // Open context menu when user right-clicks an object in the list.
864  // Calling AllowContextMenu(kFALSE) will disable this.
865  // We also fill the list fPickOrderedObjects with the selected objects
866  // in the order of clicking
867  //
868  // if fUseObjLabelAsRealClass=kTRUE (and if objects inherit from KVBase)
869  // then the context menu opened will be that of the class given by
870  // KVBase::GetLabel. The object's KVBase::GetObject() method must
871  // return the real object to use.
872 
873  if (but == kButton1) {
874  TGLVEntry* el = (TGLVEntry*)f;
875  TObject* ob = (TObject*)el->GetUserData();
877  if (ob) {
878  Bool_t in_list = fPickOrderedObjects->FindObject(ob);
879  if (in_list) fPickOrderedObjects->Remove(ob);
880  else fPickOrderedObjects->AddLast(ob);
881  }
882  return;
883  }
884 
885  // context menus globally disabled and no exceptions defined
887 
888  if (but == kButton3) {
889  // Error("OpenContextMenu","x=%d y=%d",x,y);
890  // fContextMenu->Popup(x,y,this); return;
891 
892  TGLVEntry* el = (TGLVEntry*)f;
893  TObject* ob = (TObject*)el->GetUserData();
894  if (ob) {
895 
896  TObject* CMob = ob;
897  TString CMobClass = ob->ClassName();
898 
900  KVBase* bob = dynamic_cast<KVBase*>(ob);
901  CMobClass = bob->GetLabel();
902  CMob = bob->GetObject();
903  }
904  // check class context menu status
908  fContextMenu->Popup(x, y, CMob);
909  }
910  else if (fAllowContextMenu) fContextMenu->Popup(x, y, CMob);
911  }
912  }
913 }
914 
915 
916 
917 
918 
926 
928 {
929  // Perform 'default' action when user double-left-clicks an object in the list.
930  // By default, this calls the Browse(TBrowser*) method of the object (defined for TObject,
931  // overridden in child classes).
932  // If SetDoubleClickAction() was called, the DoubleClickAction(TObject*) signal
933  // will be emitted with the address of the selected object.
934  // Calling AllowDoubleClick(kFALSE) will disable this.
935 
936  if (!fAllowDoubleClick) return;
937 
938  if (but == kButton1) {
939  TGLVEntry* el = (TGLVEntry*)f;
940  TObject* ob = (TObject*)el->GetUserData();
941  if (ob) {
943  else ob->Browse(0);
944  }
945  }
946 }
947 
948 
949 
950 
953 
955 {
956  // Returns first object in currently displayed list
957 
959  if (f) {
960  KVLVEntry* l = (KVLVEntry*)f->fFrame;
961  if (l) {
962  return (TObject*)l->GetUserData();
963  }
964  }
965  return 0;
966 }
967 
968 
969 
970 
973 
975 {
976  // Returns last object in currently displayed list
977 
979  if (f) {
980  KVLVEntry* l = (KVLVEntry*)f->fFrame;
981  if (l) {
982  return (TObject*)l->GetUserData();
983  }
984  }
985  return 0;
986 }
987 
988 
989 
990 
994 
996 {
997  // Create and fill list with all currently selected items (KVLVEntry objects)
998  // USER MUST DELETE TLIST AFTER USE!!!
999 
1000  TGFrameElement* el;
1001  TIter next(fList);
1002  TList* ret = new TList();
1003 
1004  while ((el = (TGFrameElement*) next())) {
1005  if (el->fFrame->IsActive()) {
1006  ret->Add(el->fFrame);
1007  }
1008  }
1009  return ret;
1010 }
1011 
1012 
1013 
1014 
1015 
1019 
1021 {
1022  // Create and fill list with all currently selected objects (derived from TObject)
1023  // USER MUST DELETE TLIST AFTER USE!!!
1024 
1025  TGFrameElement* el;
1026  TIter next(fList);
1027  TList* ret = new TList();
1028 
1029  while ((el = (TGFrameElement*) next())) {
1030  if (el->fFrame->IsActive()) {
1031  ret->Add((TObject*)((KVLVEntry*)el->fFrame)->GetUserData());
1032  }
1033  }
1034  return ret;
1035 }
1036 
1037 
1038 
1047 
1049 {
1050  // The global context menu status (allowed or not allowed) is set by AllowContextMenu().
1051  // If required, this can be overridden for specific classes by calling this
1052  // method for each required class.
1053  // In this case, any objects in the list of precisely this class (not derived classes)
1054  // will have the opposite behaviour to that defined by AllowContextMenu(),
1055  // i.e. if context menus are globally disabled, this method defines the classes for
1056  // which a context menu is authorised, and vice-versa.
1057 
1060 }
1061 
1062 
1063 
1064 
1074 
1075 void KVLVContainer::SetDoubleClickAction(const char* receiver_class, void* receiver, const char* slot)
1076 {
1077  // Overrides the default 'double-click' action.
1078  // By default, double-clicking on an object in the list will call the Browse(TBrowser*)
1079  // method of the selected object.
1080  // Use this method to override this behaviour.
1081  // When an object is double-clicked the method 'slot' of the object 'receiver' of class
1082  // 'receiver_class' will be called. The method in question must have the signature
1083  // receiver_class::slot(TObject*)
1084  // The address of the selected (T)object is passed as argument.
1085 
1086  Connect("DoubleClickAction(TObject*)", receiver_class, receiver, slot);
1088 }
1089 
1090 
1091 
1093 
1095 {
1096  Emit("DoubleClickAction(TObject*)", (Long_t)obj);
1097 }
1098 
1099 
1100 
1103 
1105 {
1106  // Override TGContainer method in order to set fControlClick flag
1108  if (event->fCode == kButton1 && (event->fState & kKeyControlMask)) fControlClick = kTRUE;
1109 
1110  if (event->fCode == kButton3) {
1111  TList* list = GetSelectedItems();
1112  if (list->GetSize() == 0) {
1113  fContextMenu->Popup(event->fXRoot, event->fYRoot, this);
1114  delete list;
1115  return kTRUE;
1116  }
1117  else if (list->GetSize() == 1) {
1119  }
1120  delete list;
1121  }
1123 }
1124 
1125 
1126 
1128 
1129 void KVLVContainer::AddDataColumn(const char* columnName)
1130 {
1131  if (!fObjClass) return;
1132 
1133  SetDataColumn(fNcols + 1, fObjClass, columnName, "GetName");
1134 }
1135 
1136 
1137 
1141 
1143 {
1144  // Override method in TGContainer
1145  // If multiple selection is not enabled, do nothing
1146 
1147  if (!GetMultipleSelection()) return;
1148 
1149  // Select all items in the container.
1150  // SelectAll() signal emitted.
1151 
1152  TIter next(fList);
1153  TGFrameElement* el;
1154  TGFrame* fr;
1155  TGPosition pos = GetPagePosition();
1156 
1157  while ((el = (TGFrameElement*) next())) {
1158  fr = el->fFrame;
1159  if (!fr->IsActive()) {
1161  }
1162  }
1163  fSelected = fTotal;
1164 
1166  fTotal, fSelected);
1167  Emit("SelectAll()");
1168 
1169 }
1170 
1171 
1174 
1176 {
1177  // Activate item.
1178  TGFrame* fr = el->fFrame;
1179  fr->Activate(kTRUE);
1180 
1181  if (fLastActiveEl != el) {
1182  fLastActiveEl = el;
1185  fSelected++;
1186  }
1187 
1188  if (!fSelected) fSelected = 1;
1189  TGPosition pos = GetPagePosition();
1190  DrawRegion(fr->GetX() - pos.fX, fr->GetY() - pos.fY, fr->GetWidth(), fr->GetHeight());
1191 }
1192 
1193 
int Int_t
unsigned int UInt_t
long Long_t
std::string fRetType
const Mask_t kKeyControlMask
ULong_t Pixel_t
kButton3
kButton1
#define SafeDelete(p)
#define f(i)
#define s1(x)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
#define gClient
#define N
Int_t Compare(const void *item1, const void *item2)
kMBNo
kMBYes
kMBIconQuestion
winID w
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
char * Form(const char *fmt,...)
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
kCT_SELCHANGED
kC_CONTAINER
Base class for KaliVeda framework.
Definition: KVBase.h:139
const Char_t * GetLabel() const
Definition: KVBase.h:198
@ kIsKaliVedaObject
Definition: KVBase.h:159
virtual TObject * GetObject() const
Definition: KVBase.cpp:1528
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
EKVDateFormat
Definition: KVDatime.h:41
const Char_t * String(EKVDateFormat fmt=kCTIME)
Definition: KVDatime.cpp:401
Utility class describing the data used to fill each column of the list view container.
Definition: KVLVContainer.h:33
Int_t Compare_double(TObject *o1, TObject *o2)
const Char_t * GetDataString(TObject *)
Format string with column data for object.
Int_t Compare_date(TObject *o1, TObject *o2)
Int_t Compare(TObject *ob1, TObject *ob2)
Int_t Compare_long(TObject *o1, TObject *o2)
Int_t Compare_string(TObject *o1, TObject *o2)
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
void GetData(TObject *, Long_t &)
Extension of TGLVContainer for KVListView widget.
void ActivateItemWithData(void *userData, Bool_t activate=kTRUE)
KVLVColumnData * fSortData
name of column (i.e. type of data) currently used to sort objects
virtual void FillList(const TCollection *=0)
void AddDataColumn(const char *columnName)
virtual void Display(const TCollection *=0)
void DoubleClickAction(TObject *)
void SelectAll() override
void SetNewColumnName(const char* columnName);
TObject * GetFirstInList()
Returns first object in currently displayed list.
Bool_t HandleButton(Event_t *event) override
Override TGContainer method in order to set fControlClick flag.
TContextMenu * fContextMenu
used to display popup context menu for items
virtual ~KVLVContainer()
Destructor.
virtual void Refresh()
void OpenContextMenu(TGFrame *, Int_t, Int_t, Int_t)
Bool_t fUserDoubleClickAction
user-defined double-click action instead of Browse() method
void ActivateItemWithColumnData(const Char_t *colname, const Char_t *data, Bool_t activate=kTRUE)
Bool_t fAllowContextMenu
can objects' context menu be opened with right-click ?
Int_t fNcols
number of data columns
void DoDoubleClick(TGFrame *, Int_t, Int_t, Int_t)
Bool_t fUseObjLabelAsRealClass
if kTRUE, object's classname read from KVBase::GetLabel() (objects must be KVBase-derived!...
Bool_t fControlClick
set to kTRUE when user ctrl-clicks an item
void RemoveAll() override
TGLVEntry * FindItemWithColumnData(const Char_t *colname, const Char_t *data)
friend class KVLVEntry
Bool_t fAllowDoubleClick
do something when object double-clicked ?
friend class KVLVFrameElement
void ActivateItemsWithColumnData(const Char_t *colname, const KVNumberList &data, Bool_t activate=kTRUE)
TList * GetSelectedItems()
Bool_t fKeepUserItems
internal use only, do not clear list of user items in RemoveAll()
KVLVColumnData ** fColData
description of column data
KVList * fUserItems
list of currently displayed items, used by Refresh()
KVLVContainer(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kSunkenFrame, Pixel_t back=GetDefaultFrameBackground())
TObject * GetLastInList()
Returns last object in currently displayed list.
TList * GetSelectedObjects()
virtual void SetDataColumns(Int_t ncols)
void AddContextMenuClassException(TClass *)
Int_t fSortType
current sorting mode of contents (ascending or descending)
virtual void SetDataColumn(Int_t index, TClass *cl, const Char_t *name, const Char_t *method="")
void AddFrame(TGFrame *f, TGLayoutHints *l=0) override
Add an item to the list.
void Sort(int column)
Sort objects in container according to contents of given column.
virtual void ActivateItemFromSelectAll(TGFrameElement *el)
Activate item.
TList * fContextMenuClassExceptions
list of classes for which we override value of fAllowContextMenu
void SetDoubleClickAction(const char *receiver_class, void *receiver, const char *slot)
TGLVEntry * FindItemWithData(void *userData)
Find item with fUserData == userData in container.
Int_t * fSortDir
direction of sorting for each column
KVList * fPickOrderedObjects
list of currently selected objects, in order of selection
TClass * fObjClass
Bool_t fIsResized
used to resize columns exactly once
One item/line in a KVListView window.
Definition: KVLVEntry.h:65
Extension of TGFrameElement used by KVLVContainer.
Bool_t IsSortable() const
KVLVContainer * fContainer
Int_t Compare(const TObject *obj) const
Method responsible for sorting the objects in the GUI list.
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:146
Extended TList class which owns its objects by default.
Definition: KVList.h:28
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
void Clear(Option_t *option="") override
virtual void SetCleanup(Bool_t enable=kTRUE)
void SetOwner(Bool_t enable=kTRUE) override
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b)
void Set()
virtual const char * GetValue(const char *name, const char *dflt) const
void Layout() override
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
void MapSubwindows() override
static TGLayoutHints * fgDefaultHints
virtual void Associate(const TGWindow *w)
const TGWindow * fMsgWindow
Int_t fSelected
virtual void CurrentChanged(Int_t x, Int_t y)
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
void RemoveAll() override
virtual TGPosition GetPagePosition() const
TGFrameElement * fLastActiveEl
TGLayoutHints * fLayout
TGFrame * fFrame
virtual Bool_t IsActive() const
virtual void Activate(Bool_t)
Int_t GetX() const
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
UInt_t GetHeight() const
Int_t GetY() const
UInt_t GetWidth() const
TGListView * fListView
Bool_t HandleButton(Event_t *event) override
void SetMultipleSelection(Bool_t multi=kTRUE)
virtual void AddItem(TGLVEntry *item)
void DeActivateItem(TGFrameElement *el) override
void ActivateItem(TGFrameElement *el) override
TGListView * GetListView() const
Bool_t GetMultipleSelection() const
void * GetUserData() const
virtual void ResizeColumns()
TGClient * fClient
virtual const TGWindow * GetMainFrame() const
const TGWindow * GetParent() const
void Reset()
void Clear(Option_t *option="") override
TObject * FindObject(const char *name) const override
void Add(TObject *obj) override
TObject * Last() const override
TObject * First() const override
virtual void Sort(Bool_t order=kSortAscending)
static const EReturnType kLong
static const EReturnType kString
static const EReturnType kDouble
virtual void Browse(TBrowser *b)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
void Emit(const char *signal)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
const char * Data() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:31
Double_t y[n]
Double_t x[n]
TF1 * f1
TH1 * h
TLine l
ClassImp(TPyArg)