/****************************************************************************** * File: lbtext.C * * Description: macro file to test diferent font settings for a list box * * widgets * * Author: Ilka Antcheva (CERN/EP/SFT) * *Site Contact: roottalk@cern.ch * *ROOT Version: 5.05/01 * * Last Change: 05/10/2005 * ******************************************************************************/ #include #include #include #include #include #include class MyMainFrame : public TGMainFrame { private: TGListBox *fListBox; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); ClassDef(MyMainFrame, 0) }; MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h, kHorizontalFrame) { fListBox = new TGListBox(this, 89); AddFrame(fListBox, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); const TGFont *ufont; // will reflect user font changes ufont = gClient->GetFont("-adobe-courier-medium-r-*-*-18-*-*-*-*-*-iso8859-1"); if (!ufont) ufont = fClient->GetResourcePool()->GetDefaultFont(); TGGC *uGC; // will reflect user GC changes // graphics context changes GCValues_t val; val.fMask = kGCFont; val.fFont = ufont->GetFontHandle(); uGC = gClient->GetGC(&val, kTRUE); TGTextLBEntry *entry; char tmp[20]; for (int i = 0; i < 10; ++i) { sprintf(tmp, "Entry %i", i+1); entry = new TGTextLBEntry(fListBox->GetContainer(), new TGString(tmp), i*10, uGC->GetGC(), ufont->GetFontStruct()); fListBox->AddEntry((TGLBEntry *)entry, new TGLayoutHints(kLHintsTop | kLHintsLeft)); } fListBox->Resize(150, 150); // Create a horizontal frame containing button(s) TGTextButton *exit = new TGTextButton(this, "&Exit ", "gApplication->Terminate()"); AddFrame(exit, new TGLayoutHints(kLHintsBottom | kLHintsRight, 15, 15, 3, 5)); // Set a name to the main frame SetWindowName("List Box Example"); MapSubwindows(); // Initialize the layout algorithm via Resize() Resize(GetDefaultSize()); // Map main frame MapWindow(); } MyMainFrame::~MyMainFrame() { // Clean up main frame... Cleanup(); } void lbtext() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 200, 200); }