Root Dialog Box Obstructed Characters

Hi,

I am setting up a dialog box, which I attached a screenshot of. I also attached my code below. Notice that the text for the first column which should read “Plot Type” is cut off.
I tried following examples in the tutorials but to no avail. What do I need to do to get the letters not be cut off. I’m sure it relates to the hints but I can’t get it to work. Where is the best tutorial on how to do the hints correctly. I’ve read the GUI chapter in the ROOT manual but it’s spartan on this.

Thank you.

Best Regards,

Jon Lederman

TICoolPlotConfigureDialog::TICoolPlotConfigureDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
UInt_t h, UInt_t options)
: TGTransientFrame(p, main, w, h, options)
{
// Create a dialog window. A dialog window pops up with respect to its
// “main” window.

// use hierarchical cleani
SetCleanup(kDeepCleanup);


fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
TGHorizontalFrame *bottom_frame=new TGHorizontalFrame(this, 60, 20, kFixedWidth);

fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
fOkButton->Associate(this);
fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
fCancelButton->Associate(this);



fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
                        2, 2, 2, 2);
fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);

TGLayoutHints* fLChoose=new TGLayoutHints(kLHintsBottom | kLHintsCenterX| kLHintsExpandX, 0, 0, 0, 0);

fFrame1->AddFrame(fOkButton, fL1);
fFrame1->AddFrame(fCancelButton, fL1);
fFrame1->AddFrame(fOkButton, fL1);
fFrame1->AddFrame(fCancelButton, fL1);



fFrame1->Resize(150, fOkButton->GetDefaultHeight());
AddFrame(fFrame1, fL2);

//--------- create Tab widget and some composite frames for Tab testing

fTab = new TGTab(this, 300, 300);
TGCompositeFrame *tf = fTab->AddTab("ICool Plot Variables");

fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);


TGHorizontalFrame* th=new TGHorizontalFrame(tf, 400,400);
tf->AddFrame(th);

//From TestMsgBox
fL41 = new TGLayoutHints(kLHintsTop | kLHintsLeft,
                        0, 0, 5, 0);
fG1 = new TGGroupFrame(th, new TGString("X Variable"),kVerticalFrame|kRaisedFrame);
 fG2 = new TGGroupFrame(th, new TGString("Y Variable"),kVerticalFrame|kRaisedFrame);
fC[0]  = new TGCheckButton(fG1, new TGHotString("ePerp"),        -1);
fC[1]  = new TGCheckButton(fG1, new TGHotString("eLong"),         -1);
fC[2]  = new TGCheckButton(fG1, new TGHotString("OK"),         -1);
fC[3]  = new TGCheckButton(fG1, new TGHotString("Apply"),      -1);
fC[4]  = new TGCheckButton(fG1, new TGHotString("Retry"),      -1);
fC[5]  = new TGCheckButton(fG1, new TGHotString("Ignore"),     -1);
fC[6]  = new TGCheckButton(fG1, new TGHotString("Cancel"),     -1);
fC[7]  = new TGCheckButton(fG1, new TGHotString("Close"),      -1);
fC[8]  = new TGCheckButton(fG1, new TGHotString("Yes to All"), -1);
fC[9]  = new TGCheckButton(fG1, new TGHotString("No to All"),  -1);
fC[10] = new TGCheckButton(fG1, new TGHotString("Newer Only"), -1);
fC[11] = new TGCheckButton(fG1, new TGHotString("Append"),     -1);
fC[12] = new TGCheckButton(fG1, new TGHotString("Dismiss"),    -1);

for (int i=0; i<13; ++i) fG1->AddFrame(fC[i], fL3);

fR[0] = new TGRadioButton(fG2, new TGHotString("Stop"),        21);
fR[1] = new TGRadioButton(fG2, new TGHotString("Question"),    22);
fR[2] = new TGRadioButton(fG2, new TGHotString("Exclamation"), 23);
fR[3] = new TGRadioButton(fG2, new TGHotString("Asterisk"),    24);

for (int i = 0; i < 4; ++i) {
    fG2->AddFrame(fR[i], fL3);
    fR[i]->Associate(this);
}



fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
fF1->AddFrame(new TGTextButton(fF1, "&Test button", 0), fL3);
fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);

// tf->AddFrame(fF1, fL3);
fTxt1->Resize(150, fTxt1->GetDefaultHeight());
fTxt2->Resize(150, fTxt2->GetDefaultHeight());

tf = fTab->AddTab("ICool Plot Color");

TGLayoutHints *ct = new TGLayoutHints(kLHintsTop | kLHintsLeft, 1, 1, 1, 1);

    TGGroupFrame *choose_type = new TGGroupFrame(th, new TGString("Plot Type"),kVerticalFrame|kRaisedFrame);
TGCheckButton *ecalc9  = new TGCheckButton(choose_type, new TGHotString("ECalc9 Plot"),        -1);
TGCheckButton *for009  = new TGCheckButton(choose_type, new TGHotString("For009 Plot"),         -1);

choose_type->AddFrame(ecalc9, ct);
choose_type->AddFrame(for009, ct);


th->AddFrame(choose_type);
th->AddFrame(fG1);
th->AddFrame(fG2);




fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
                        200, 2, 2, 2);
fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
fF2->AddFrame(fBtn1 = new TGTextButton(fF2, "&Button 1", 0), fL1);
fF2->AddFrame(fBtn2 = new TGTextButton(fF2, "B&utton 2", 0), fL1);
fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "C&heck 1", 0), fL1);
fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Chec&k 2", 0), fL1);
fF2->AddFrame(fRad1 = new TGRadioButton(fF2, "&Radio 1", 81), fL1);
fF2->AddFrame(fRad2 = new TGRadioButton(fF2, "R&adio 2", 82), fL1);
fCombo = new TGComboBox(fF2, 88);
fF2->AddFrame(fCombo, fL3);



int i;
for (i = 0; i < 20; i++) {
    char tmp[20];
    
    sprintf(tmp, "Entry %i", i+1);
    fCombo->AddEntry(tmp, i+1);
}
 
fCombo->Resize(150, 20);

fBtn1->Associate(this);
fBtn2->Associate(this);
fChk1->Associate(this);
fChk2->Associate(this);
fRad1->Associate(this);
fRad2->Associate(this);

TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
kLHintsExpandY, 2, 2, 5, 1);
AddFrame(fTab, fL5);

MapSubwindows();
Resize();   // resize to default size

// position relative to the parent's window
CenterOnParent();

SetWindowName("Design ICool Plot");

MapWindow();
//fClient->WaitFor(this);    // otherwise canvas contextmenu does not work

Hi Jon,

Next time, try to add code using the “Code” form, that will ease our life… And providing a macro that we can run would be even better! :wink:
Anyway, there are several issues with your code:

  1. remove this line:TGHorizontalFrame *bottom_frame=new TGHorizontalFrame(this, 60, 20, kFixedWidth);This frame is not used, and stays on the top left corner of the main frame, covering part of the TGTab…

  2. When you add an element to a composite frame, don’t forget to call AddFrame()

  3. When using AddFrame(), use a proper TGLayoutHints (the default is null)

Take a look at your modified code below, I hope it will help:

[code]TICoolPlotConfigureDialog::TICoolPlotConfigureDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options)
: TGTransientFrame(p, main, w, h, options)
{
// Create a dialog window. A dialog window pops up with respect to its
// “main” window.

// use hierarchical cleani
SetCleanup(kDeepCleanup);

fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);

// Useless, and even polluting:
//TGHorizontalFrame *bottom_frame=new TGHorizontalFrame(this, 60, 20, kFixedWidth);

fOkButton = new TGTextButton(fFrame1, “&Ok”, 1);
fOkButton->Associate(this);
fCancelButton = new TGTextButton(fFrame1, “&Cancel”, 2);
fCancelButton->Associate(this);

fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);

TGLayoutHints* fLChoose=new TGLayoutHints(kLHintsBottom | kLHintsCenterX| kLHintsExpandX, 0, 0, 0, 0);

fFrame1->AddFrame(fOkButton, fL1);
fFrame1->AddFrame(fCancelButton, fL1);
fFrame1->AddFrame(fOkButton, fL1);
fFrame1->AddFrame(fCancelButton, fL1);

fFrame1->Resize(150, fOkButton->GetDefaultHeight());
AddFrame(fFrame1, fL2);

//--------- create Tab widget and some composite frames for Tab testing

fTab = new TGTab(this, 300, 300);
TGCompositeFrame *tf = fTab->AddTab(“ICool Plot Variables”);

fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);

TGHorizontalFrame* th=new TGHorizontalFrame(tf, 400,400);
tf->AddFrame(th);

//From TestMsgBox
fL41 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 0);
fG1 = new TGGroupFrame(th, new TGString(“X Variable”),kVerticalFrame|kRaisedFrame);
fG2 = new TGGroupFrame(th, new TGString(“Y Variable”),kVerticalFrame|kRaisedFrame);
fC[0] = new TGCheckButton(fG1, new TGHotString(“ePerp”), -1);
fC[1] = new TGCheckButton(fG1, new TGHotString(“eLong”), -1);
fC[2] = new TGCheckButton(fG1, new TGHotString(“OK”), -1);
fC[3] = new TGCheckButton(fG1, new TGHotString(“Apply”), -1);
fC[4] = new TGCheckButton(fG1, new TGHotString(“Retry”), -1);
fC[5] = new TGCheckButton(fG1, new TGHotString(“Ignore”), -1);
fC[6] = new TGCheckButton(fG1, new TGHotString(“Cancel”), -1);
fC[7] = new TGCheckButton(fG1, new TGHotString(“Close”), -1);
fC[8] = new TGCheckButton(fG1, new TGHotString(“Yes to All”), -1);
fC[9] = new TGCheckButton(fG1, new TGHotString(“No to All”), -1);
fC[10] = new TGCheckButton(fG1, new TGHotString(“Newer Only”), -1);
fC[11] = new TGCheckButton(fG1, new TGHotString(“Append”), -1);
fC[12] = new TGCheckButton(fG1, new TGHotString(“Dismiss”), -1);

for (int i=0; i<13; ++i) fG1->AddFrame(fC[i], fL3);

fR[0] = new TGRadioButton(fG2, new TGHotString(“Stop”), 21);
fR[1] = new TGRadioButton(fG2, new TGHotString(“Question”), 22);
fR[2] = new TGRadioButton(fG2, new TGHotString(“Exclamation”), 23);
fR[3] = new TGRadioButton(fG2, new TGHotString(“Asterisk”), 24);

for (int i = 0; i < 4; ++i) {
fG2->AddFrame(fR[i], fL3);
fR[i]->Associate(this);
}

fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
fF1->AddFrame(new TGTextButton(fF1, “&Test button”, 0), fL3);
fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
// tf->AddFrame(fF1, fL3);
fTxt1->Resize(150, fTxt1->GetDefaultHeight());
fTxt2->Resize(150, fTxt2->GetDefaultHeight());

// forgotten:
tf->AddFrame(fF1, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2, 2, 2, 2));

tf = fTab->AddTab(“ICool Plot Color”);

TGLayoutHints *ct = new TGLayoutHints(kLHintsTop | kLHintsLeft, 1, 1, 1, 1);

TGGroupFrame *choose_type = new TGGroupFrame(th, new TGString(“Plot Type”),kVerticalFrame|kRaisedFrame);
TGCheckButton *ecalc9 = new TGCheckButton(choose_type, new TGHotString(“ECalc9 Plot”), -1);
TGCheckButton *for009 = new TGCheckButton(choose_type, new TGHotString(“For009 Plot”), -1);

choose_type->AddFrame(ecalc9, ct);
choose_type->AddFrame(for009, ct);

// TGLayoutHints was forgotten:
th->AddFrame(choose_type, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
th->AddFrame(fG1, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2, 2, 2, 2));
th->AddFrame(fG2, new TGLayoutHints(kLHintsTop|kLHintsLeft, 2, 2, 2, 2));

fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 200, 2, 2, 2);
fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
fF2->AddFrame(fBtn1 = new TGTextButton(fF2, “&Button 1”, 0), fL1);
fF2->AddFrame(fBtn2 = new TGTextButton(fF2, “B&utton 2”, 0), fL1);
fF2->AddFrame(fChk1 = new TGCheckButton(fF2, “C&heck 1”, 0), fL1);
fF2->AddFrame(fChk2 = new TGCheckButton(fF2, “Chec&k 2”, 0), fL1);
fF2->AddFrame(fRad1 = new TGRadioButton(fF2, “&Radio 1”, 81), fL1);
fF2->AddFrame(fRad2 = new TGRadioButton(fF2, “R&adio 2”, 82), fL1);
fCombo = new TGComboBox(fF2, 88);
fF2->AddFrame(fCombo, fL3);

// forgotten:
tf->AddFrame(fF2, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2, 2, 2, 2));

int i;
for (i = 0; i < 20; i++) {
char tmp[20];

  sprintf(tmp, "Entry %i", i+1);
  fCombo->AddEntry(tmp, i+1);

}

fCombo->Resize(150, 20);

fBtn1->Associate(this);
fBtn2->Associate(this);
fChk1->Associate(this);
fChk2->Associate(this);
fRad1->Associate(this);
fRad2->Associate(this);

TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 2, 2, 5, 1);
AddFrame(fTab, fL5);

MapSubwindows();
Resize(); // resize to default size

// position relative to the parent’s window
CenterOnParent();

SetWindowName(“Design ICool Plot”);

MapWindow();
//fClient->WaitFor(this); // otherwise canvas contextmenu does not work[/code]Obviously, I used randomly selected layout hints, up to you to decide how to arrange the components…

Cheers, Bertrand.

P.S. BTW, you forgot to attach a screenshot…

Hi Bertrand,

Even with your changes, I still am getting characters obstructed. I don’t understand the problem or why the hints are not working. I have attached a screenshot. Please have a look and please let me know is going wrong.

Thanks for all the help.

Regards,

Jon
dialog.pdf (58.6 KB)

Hi Jon,

You most probably create an empty (and unused) frame. Without seeing the code, I can’t really tell what’s wrong in it…

Cheers, Bertrand.

Hi Bertrand,

That fixed it! I had created a frame but didn’t add it. I didn’t realize creating a frame alone impacts the layout even if you haven’t added it. Thanks. I was wondering whether you can help me with something else. Please look at the dialog box screenshot I sent. I am trying to set up things so that if I click on the Ecalc9 Plot under (plot type) it will display one set of variables under X Variable and Y Variable and if I click on For009 Plot it will display another. How is the best way to accomplish this - to change the selections on a dialog box on the fly depending on user clicking something else? Or is there another method you’d recommend. I anxiously await your reply.

Jon