[ROOT] Limit to vertical size of viewpad for TGCanvas?

From: Corey Reed (cjreed@mit.edu)
Date: Sat Jun 16 2001 - 03:02:13 MEST


In the hopes of making something like TControlBar except with a (vertical)
scroll bar, I tried using a TGCanvas with a TGVerticalFrame as the
container for TGTextButtons.

This works fine as long as the number of buttons is small. Small in this
case being less than about 1500. If too many buttons are added, scrolling
to the bottom of the canvas results in an empty (white) display in the
viewport.

TGCanvas appears to calculate the correct vertical size when figuring out
how far to allow scrolling, however, not all buttons are shown. A very
strange behavior is exhibited when scrolling too far down. Namely,
everything appears fine until you scroll one pixel too far down, at which
point the entire pad becomes white.

Below is a macro to reproduce these results.

for nButtons =< 1500, no strange behavior is seen

for nButtons > about 1520, the viewport does not display correctly when
scrolled to the bottom

void test_buttons (Int_t nButtons) {
  TGMainFrame* wind = new TGMainFrame(gClient->GetRoot(),160,600);
  wind->SetWindowName("Test TGCanvas");
  TGCanvas* gc = new TGCanvas(wind,160,600);
  TGVerticalFrame* gf = new TGVerticalFrame(gc,130,600);
  gc->SetContainer(gf);
  TGLayoutHints* lhint = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
  TGLayoutHints* chint = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY);
  for (Int_t i = 0;i<nButtons;i++)
    {
      char cc[20];
      sprintf(&cc,"Button %d",i);
      tbutton = new TGTextButton(gf,cc);
      gc->AddFrame(tbutton,lhint);
    }
  wind->AddFrame(gc,chint);
  wind->MapSubwindows();
  wind->Layout();
  wind->MapWindow();
}



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET