00001
00002
00003
00004 #include "TH1.h"
00005 #include "TClassMenuItem.h"
00006 #include "TList.h"
00007
00008 void poptest1(int a=5, int b = 56);
00009 void poptest2(int a, int b, TObject* c);
00010 void poptest2bis(TObject* c);
00011 int poptest3();
00012 void poptest4(char* ch);
00013
00014
00015 void customContextMenu()
00016 {
00017 TH1F *h;
00018 TH1F *h2;
00019 TClassMenuItem *n;
00020 TList *l;
00021
00022
00023 h = new TH1F("h","Schtroumpf",100,-4,4);
00024 h->FillRandom("gaus");
00025 h->Draw();
00026
00027 h2 = new TH1F("h2","h2",1000,-4,4);
00028 h2->FillRandom("gaus",30000);
00029
00030
00031 TClass *cl = h->IsA();
00032 l = cl->GetMenuList();
00033
00034
00035 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00036 "Test object, draw a second h","Draw",h2,"Option_t*");
00037 l->AddFirst(n);
00038 n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl);
00039 l->AddFirst(n);
00040
00041 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00042 "test no 4","poptest4",0,"const char*");
00043 l->AddFirst(n);
00044 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00045 "test no 3","poptest3",0,"");
00046 l->AddFirst(n);
00047 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00048 "test no 2 bis","poptest2bis",0,"TObject*",2);
00049 l->AddFirst(n);
00050 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00051 "test no 2","poptest2",0,"int,int,TObject*",2);
00052 l->AddFirst(n);
00053 n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,
00054 "test no 1","poptest1",0,"int,int");
00055 l->AddFirst(n);
00056 }
00057
00058 void poptest1(int a, int b)
00059 {
00060 printf("poptest1 %d %d\n",a,b);
00061 }
00062
00063 void poptest2(int a, int b, TObject *c)
00064 {
00065
00066 printf("poptest2 %d %d\n",a,b);
00067 printf("histo : %lx\n",(Long_t)c);
00068 printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
00069 }
00070
00071 void poptest2bis(TObject *c)
00072 {
00073
00074 printf("poptest2bis\n");
00075 printf("histo : %lx\n",(Long_t)c);
00076 printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
00077 }
00078
00079 int poptest3()
00080 {
00081 printf("poptest3\n");
00082 return 12;
00083 }
00084
00085 void poptest4(const char *ch)
00086 {
00087 printf("poptest4 %s\n",ch);
00088 }