TGLabel text is cut-off/not shown

I’m adding a TGLabel to a class GTMsgDlg : public TGTransientFrame derived class.

I am have difficulty displaying my TGLabel text without being cutoff. Here is a snippet of the code.

pfLabelFrame = new TGHorizontalFrame(this, GetWidth(), GetHeight());

// Layout hint for adding the pfLabel onto the TGVerticalFrame,  pfLabelFrame
// Vertical Frame.
pfL4 = new TGLayoutHints(kLHintsCenterX | kLHintsLeft | kLHintsExpandX, 5, 5, 10, 0);

// Label to add to the the pfLabelFrame
pfLabel = new TGLabel(pfLabelFrame, msg);

pfLabelFrame->AddFrame(pfLabel, pfL4);

// Add the pfLabelFrame to the Dialog

When this section of the code is called, msg = #define ANIMALCODE_TEXT_LABEL “Bull Change cycle is now complete and machine is ready to be drop delayed.\nPlease enter Animal Code to continue.”

I have not found a easily documented way to make sure my text fits in my dialog. Right now, my text looks like this when printed:

Bull Change cycle is now complete and machine
Please enter Animal Code to continue."

Some missing text.

How can I solve my problem?

Thank you,

Here is a simple example:

[code]#include <TGFrame.h>
#include <TGLabel.h>
#include <TGButton.h>

#define ANIMALCODE_TEXT_LABEL “Bull Change cycle is now complete and machine is ready to be drop delayed.\nPlease enter Animal Code to continue.”

class MyMainFrame : public TGMainFrame {
TGLabel *m_TextLabel;
TGTextButton *m_ChangeButton;
TGTextButton *m_ExitButton;

MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();

void DoChangeLabel();

MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
m_TextLabel = new TGLabel(this, new TGString(“Label”));
AddFrame(m_TextLabel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));

m_ChangeButton = new TGTextButton(this, “&Change Label”);
AddFrame(m_ChangeButton, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
m_ChangeButton->Connect(“Clicked()”, “MyMainFrame”, this, “DoChangeLabel()”);

m_ExitButton = new TGTextButton(this, “&Exit”, “gApplication->Terminate(0)”);
AddFrame(m_ExitButton, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));



void MyMainFrame::DoChangeLabel()

void test_label()
new MyMainFrame(gClient->GetDefaultRoot(), 300, 300);
Cheers, Bertrand.

Hi Bertrand,

Thank you for the response. Now I’m a bit more confused.

In a class MyMainFrame : public TGMainFrame you don’t seem to use a vertical or horizontal frame to put widgets into (e.g. TGLabel())

In my class GTMsgDlg : public TGTransientFrame I seem to need a vertical and horizontal frame to put my text and buttons.

When is a are vertical or horizontal frames needed to put widgets into, and when are they not needed?

Please help me get it clear in my mind.


Use a TGHorizontalFrame to horizontally arrange the widgets or sub-frames, a TGVerticalFrame to vertically arrange the widgets or sub-frames. The TGMainFrame has a kVerticalFrame flag by default:

TGMainFrame(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kVerticalFrame) (but you can use a kHorizontalFrame if you prefer…)

Cheers, Bertrand.


You are AWESOME!

Thank you.