Created
April 19, 2019 07:58
-
-
Save petrstepanov/551a286cf6d15d808d0105b6b161f4be to your computer and use it in GitHub Desktop.
TGListBox inside TGCanvas container not shrinks down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TGClient.h> | |
#include <TGCanvas.h> | |
#include <TGListBox.h> | |
#include <TGFrame.h> | |
class MyMainFrame : public TGMainFrame { | |
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) { | |
// Create canvas with white background | |
TGCanvas* canvas = new TGCanvas(this); | |
TGCompositeFrame* container = new TGCompositeFrame(canvas->GetViewPort(), 10, 10, kOwnBackground); | |
container->SetBackgroundColor(TColor::Number2Pixel(kGray+1)); | |
canvas->SetContainer(container); | |
AddFrame(canvas, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY, 10, 10, 10, 10)); | |
// Add child ListBox (breaks layout - scrollbars appear when decreasing window size) | |
TGListBox* listBox = new TGListBox(container); | |
container->AddFrame(listBox, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 20, 20, 20, 20)); | |
SetWindowName("TGCanvas issue"); | |
SetWMSizeHints(300, 300, 1000, 1000, 1, 1); | |
MapSubwindows(); | |
Resize(GetDefaultSize()); | |
MapWindow(); | |
} | |
MyMainFrame::~MyMainFrame(){ | |
Cleanup(); | |
} | |
void canvasResize(){ | |
new MyMainFrame(gClient->GetRoot(), 300, 300); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment