Dear Fons In my GUI application I would like to select entries from a list containing 10,000 entries. Therefore, I have implemented a TGListBox in my GUI. Sorrowly, I realized that TGListBox is not able to display more than 2075 entries (see the attached macro gui.C below). Moreover, filling TGListBox with few thousand entries is pretty slow. Could you tell me how I could solve this problem? Could it be that the problem is due to the fact that class TGFrame has a size fWidth, fHeight which is defined as unsigned integer only? If this is the case is it possible that you change the size to longint values? Maybe the following could be of interest to you: In the early days of the Macintosh, Apple had a similar problem since the size of the BitMap was defined as integer values. Apple needed to change this without breaking application code. If I remember correctly, Apple changed the size of the BitMap to longint but left the corresponding scrollvalues for the ScrollBars as integer and somehow transformed the scrollvalues to longint. Thank you in advance for your help. Best regards Christian ---------------------------------- C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a, A.u.s.t.r.i.a //----------------------------------------------------------------------// #include <stdio.h> #include <stdlib.h> #include <iostream.h> #include <TROOT.h> #include <TApplication.h> #include <TVirtualX.h> #include <RQ_OBJECT.h> #include <TGFrame.h> #include <TGMenu.h> #include <TGTextEntry.h> #include <TGTextBuffer.h> #include <TGListBox.h> #include <TGFileDialog.h> #include <TSystem.h> #include <TEnv.h> //----------------------------------------------------------------------// class TMain { RQ_OBJECT() private: TGMainFrame *fMain; TGCompositeFrame *fFrame; TGCompositeFrame *fFV1; TGCompositeFrame *fFH1; TGTextEntry *fEntryNum; TGTextBuffer *fBufNum; TGButton *fOKBtn; TGCompositeFrame *fFH2; TGTextEntry *fEntryID; TGTextBuffer *fBufID; TGButton *fIDBtn; TGCompositeFrame *fFV2; TGListBox *fListBox; Int_t fNEntries; public: TMain(const TGWindow *vWindow, UInt_t vWidth, UInt_t vHeight, UInt_t vOptions = kVerticalFrame); virtual ~TMain(); // slots void FCloseWindow(); void FClickOK(); void FClickID(); }; //----------------------------------------------------------------------// TMain::TMain(const TGWindow *vWindow, UInt_t vWidth, UInt_t vHeight, UInt_t vOptions) { fNEntries = 0; fL1 = new TGLayoutHints(kLHintsLeft | kLHintsTop); fL2 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2); fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 15, 15); // Basic frame layout fMain = new TGMainFrame(vWindow, vWidth, vHeight, vOptions); fMain->Connect("CloseWindow()", "TMain", this, "FCloseWindow()"); fFrame = new TGCompositeFrame(fMain, 200, 20, kHorizontalFrame); fMain->AddFrame(fFrame, fL1); fFV1 = new TGCompositeFrame(fFrame, 200, 20, kVerticalFrame); fFrame->AddFrame(fFV1, fL3); fFV2 = new TGCompositeFrame(fFrame, 200, 20, kVerticalFrame); fFrame->AddFrame(fFV2, fL3); // Set number of entries fFH1 = new TGCompositeFrame(fFV1, 60, 20, kHorizontalFrame); fFV1->AddFrame(fFH1, fL1); fFH1->AddFrame(new TGLabel(fFH1,new TGString("Set # entries:")), fL2); fEntryNum = new TGTextEntry(fFH1, fBufNum = new TGTextBuffer(255), -1); fEntryNum->Resize(150,20); fFH1->AddFrame(fEntryNum, fL2); fOKBtn = new TGTextButton(fFH1, " OK ", 1); fOKBtn->Connect("Clicked()", "TMain", this, "FClickOK()"); fFH1->AddFrame(fOKBtn, fL2); // Get entry ID fFH2 = new TGCompositeFrame(fFV1, 60, 20, kHorizontalFrame); fFV1->AddFrame(fFH2, fL1); fFH2->AddFrame(new TGLabel(fFH2,new TGString("Get entry ID: ")), fL2); fEntryID = new TGTextEntry(fFH2, fBufID = new TGTextBuffer(255), -1); fEntryID->Resize(150,20); fFH2->AddFrame(fEntryID, fL2); fIDBtn = new TGTextButton(fFH2, " Go ", 1); fIDBtn->Connect("Clicked()", "TMain", this, "FClickID()"); fFH2->AddFrame(fIDBtn, fL2); // ListBox fListBox = new TGListBox(fFV2, 1); fFV2->AddFrame(fListBox, fL2); fListBox->Resize(150, 400); fMain->MapSubwindows(); fMain->Layout(); fMain->Resize(fMain->GetDefaultSize()); fMain->SetWMPosition(140,120); fMain->SetWindowName("ListBox Test"); fMain->MapWindow(); }//Constructor //----------------------------------------------------------------------// TMain::~TMain() { delete fIDBtn; delete fEntryID; delete fFH2; delete fOKBtn; delete fEntryNum; delete fFH1; delete fListBox; delete fFV1; delete fFV2; delete fFrame; delete fMain; }//Destructor //----------------------------------------------------------------------// void TMain::FCloseWindow() { delete this; }//FCloseWindow //----------------------------------------------------------------------// void TMain::FClickOK() { // Reset TGListBox fListBox->RemoveEntries(0, fNEntries); fNEntries = 0; const char *vText = ""; vText = fBufNum->GetString(); fNEntries = atoi(vText); // Int_t fNEntries = atoi((char*)vText); cout << "fNEntries =" << fNEntries << endl; for (Int_t id=0;id<fNEntries;id++) { TString vName = "Name_"; vName += id + 1; fListBox->AddEntry(vName, id); }//for_id fListBox->MapSubwindows(); fListBox->Layout(); }//FClickOK //----------------------------------------------------------------------// void TMain::FClickID() { const char *vText = ""; vText = fBufID->GetString(); Int_t vID = atoi(vText) - 1; // Int_t vID = atoi((char*)vText); cout << "vID = " << vID << endl; TString vName = "no selection"; TGLBEntry *vEntry =fListBox->Select(vID, kTRUE); if (vEntry) { if (vEntry->InheritsFrom(TGTextLBEntry::Class())) { vName = ((TGTextLBEntry*)vEntry)->GetText()->GetString(); }//if }//if cout << "Selected entry = " << vName << endl; }//FClickID //----------------------------------------------------------------------// void gui() { new TMain(gClient->GetRoot(), 400, 220); }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET