]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/TGClassBrowser.cxx
e631b374594515756fc11db3695ee36cf3fa9526
[u/mrichter/AliRoot.git] / EVE / Reve / TGClassBrowser.cxx
1
2 #include "TROOT.h"
3 #include "TSystem.h"
4 #include "TGClient.h"
5 #include "TGListTree.h"
6 #include "TGLayout.h"
7 #include "TSystemDirectory.h"
8 #include "TGMimeTypes.h"
9 #include "TFile.h"
10 #include "TKey.h"
11 #include "TInterpreter.h"
12 #include "TClass.h"
13 #include "TDataMember.h"
14 #include "TMethod.h"
15 #include "TMethodArg.h"
16
17 #include "TGClassBrowser.h"
18
19 ClassImp(TGClassBrowser)
20
21 //______________________________________________________________________________
22 TGClassBrowser::TGClassBrowser(const TGWindow *p, UInt_t w, UInt_t h) :
23       TGMainFrame(p, w, h)
24
25 {
26    SetCleanup(kDeepCleanup);
27    fCanvas = new TGCanvas(this, 100, 100);
28    fListTree = new TGListTree(fCanvas, kHorizontalFrame);
29    AddFrame(fCanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop | 
30                 kLHintsExpandX | kLHintsExpandY));
31    
32    TGListTreeItem *item = fListTree->AddItem(0,"Classes");
33    fListTree->Connect("DoubleClicked(TGListTreeItem *, Int_t)",
34       "TGClassBrowser", this, "DoubleClicked(TGListTreeItem *, Int_t)");
35    fClassIcon = gClient->GetPicture("class.png");
36    fMemberIcon = gClient->GetPicture("member.png");
37    fMethodIcon = gClient->GetPicture("method.png");
38
39    MapSubwindows();
40    Resize(GetDefaultSize());
41    MapWindow();
42    TClass *cl;
43    TIter nextcl(gROOT->GetListOfClasses());
44    while ((cl = (TClass *)nextcl())) {
45       TGListTreeItem *itm = fListTree->AddItem(item, cl->GetName(), 
46                                                fClassIcon, fClassIcon);
47       itm->SetTipText(Form("Decl: %s : %d\nImpl: %s : %d",
48                       cl->GetDeclFileName(), cl->GetDeclFileLine(),
49                       cl->GetImplFileName(), cl->GetImplFileLine()));
50    }
51 }
52
53 //______________________________________________________________________________
54 TGClassBrowser::~TGClassBrowser()
55 {
56    // Destructor.
57
58    delete fListTree;
59    Cleanup();
60 }
61
62 //______________________________________________________________________________
63 void TGClassBrowser::DisplayClass(TGListTreeItem *, const TString &)
64 {
65    // display details of ROOT class
66
67 }
68
69 //______________________________________________________________________________
70 void TGClassBrowser::DoubleClicked(TGListTreeItem *item, Int_t /*btn*/)
71 {
72    // Process double clicks in TGListTree.
73
74    TClass *cl;
75    TIter nextcl(gROOT->GetListOfClasses());
76    if (item == fListTree->GetFirstItem()) {   
77       while ((cl = (TClass *)nextcl())) {
78          if (!fListTree->FindChildByName(item, cl->GetName())) {
79             TGListTreeItem *itm = fListTree->AddItem(item, cl->GetName(), 
80                                                      fClassIcon, fClassIcon);
81             itm->SetTipText(Form("Decl: %s : %d\nImpl: %s : %d",
82                             cl->GetDeclFileName(), cl->GetDeclFileLine(),
83                             cl->GetImplFileName(), cl->GetImplFileLine()));
84          }
85       }
86       fListTree->ClearViewPort();
87       return;
88    }
89    cl = (TClass*)gROOT->GetListOfClasses()->FindObject(item->GetText());
90    if (cl) {
91       TClass *bc;
92       TDataMember *dm;
93       TMethod *m;
94       
95       TIter nextbc(cl->GetListOfBases());
96       while ((bc = (TClass *) nextbc())) {
97          fListTree->AddItem(item, bc->GetName(), fClassIcon, fClassIcon);
98       }
99      
100       TIter nextdm(cl->GetListOfDataMembers());
101       while ((dm = (TDataMember *) nextdm())) {
102          if (dm->IsEnum()) continue;
103          fListTree->AddItem(item, Form("%s %s",dm->GetFullTypeName(), dm->GetName()), 
104                             fMemberIcon, fMemberIcon);
105       }
106
107       TIter nextm(cl->GetListOfMethods());
108       while ((m = (TMethod *) nextm())) {
109          TString method = Form("%s %s(", m->GetReturnTypeName(), m->GetName());
110          TIter nextarg(m->GetListOfMethodArgs());
111          TMethodArg *a;
112          while ((a = (TMethodArg*) nextarg())) {
113             method += a->GetFullTypeName();
114             method += ", ";
115          }
116          method.Remove(TString::kTrailing,' ');
117          method.Remove(TString::kTrailing,',');
118          method += ")";
119          fListTree->AddItem(item, method.Data(), fMethodIcon, fMethodIcon);
120       }
121    }
122    fListTree->ClearViewPort();
123 }
124