TestMsgBox Class Reference

Collaboration diagram for TestMsgBox:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TestMsgBox (const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options=kVerticalFrame)
virtual ~TestMsgBox ()
void TryToClose ()
void CloseWindow ()
void DoClose ()
void DoRadio ()
void DoTest ()

Private Attributes

TGTransientFrame * fMain
TGCompositeFrame * f1
TGCompositeFrame * f2
TGCompositeFrame * f3
TGCompositeFrame * f4
TGCompositeFrame * f5
TGButton * fTestButton
TGButton * fCloseButton
TGPictureButton * fPictButton
TGRadioButton * fR [4]
TGCheckButton * fC [13]
TGGroupFrame * fG1
TGGroupFrame * fG2
TGLayoutHints * fL1
TGLayoutHints * fL2
TGLayoutHints * fL3
TGLayoutHints * fL4
TGLayoutHints * fL5
TGLayoutHints * fL6
TGLayoutHints * fL21
TGTextEntry * fTitle
TGTextEntry * fMsg
TGTextBuffer * fTbtitle
TGTextBuffer * fTbmsg
TGLabel * fLtitle
TGLabel * fLmsg
TGGC fRedTextGC

Detailed Description

Definition at line 309 of file guitest.C.


Constructor & Destructor Documentation

TestMsgBox::TestMsgBox ( const TGWindow *  p,
const TGWindow *  main,
UInt_t  w,
UInt_t  h,
UInt_t  options = kVerticalFrame 
)

Definition at line 1372 of file guitest.C.

01373                                                            :
01374      fRedTextGC(TGButton::GetDefaultGC())
01375 {
01376    // Create message box test dialog. Use this dialog to select the different
01377    // message dialog box styles and show the message dialog by clicking the
01378    // "Test" button.
01379 
01380    fMain = new TGTransientFrame(p, main, w, h, options);
01381    fMain->Connect("CloseWindow()", "TestMsgBox", this, "CloseWindow()");
01382    fMain->DontCallClose(); // to avoid double deletions.
01383 
01384    // use hierarchical cleaning
01385    fMain->SetCleanup(kDeepCleanup);
01386 
01387    //------------------------------
01388    // Set foreground color in graphics context for drawing of
01389    // TGlabel and TGButtons with text in red.
01390 
01391    Pixel_t red;
01392    gClient->GetColorByName("red", red);
01393    fRedTextGC.SetForeground(red);
01394    //---------------------------------
01395 
01396    int i;
01397 
01398    fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
01399 
01400    f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame | kFixedWidth);
01401    f2 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
01402    f3 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01403    f4 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01404    f5 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01405 
01406    fTestButton = new TGTextButton(f1, "&Test", 1, fRedTextGC());
01407    fTestButton->Connect("Clicked()", "TestMsgBox", this, "DoTest()");
01408 
01409    // Change background of fTestButton to green
01410    Pixel_t green;
01411    gClient->GetColorByName("green", green);
01412    fTestButton->ChangeBackground(green);
01413 
01414    fCloseButton = new TGTextButton(f1, "&Close", 2);
01415    fCloseButton->Connect("Clicked()", "TestMsgBox", this, "DoClose()");
01416 
01417    fPictButton = new TGPictureButton(f1, gClient->GetPicture("mb_stop_s.xpm"));
01418 
01419    f1->Resize(fTestButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
01420 
01421    fL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandX,
01422                            2, 2, 3, 0);
01423    fL2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX,
01424                            2, 5, 0, 2);
01425    fL21 = new TGLayoutHints(kLHintsTop | kLHintsRight,
01426                             2, 5, 10, 0);
01427 
01428    f1->AddFrame(fTestButton, fL1);
01429    f1->AddFrame(fCloseButton, fL1);
01430    f1->AddFrame(fPictButton, fL1);
01431    fMain->AddFrame(f1, fL21);
01432 
01433    //--------- create check and radio buttons groups
01434 
01435    fG1 = new TGGroupFrame(f3, new TGString("Buttons"),kVerticalFrame|kRaisedFrame);
01436    fG2 = new TGGroupFrame(f3, new TGString("Icons"),kVerticalFrame|kRaisedFrame);
01437 
01438    fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft |
01439                            kLHintsExpandX | kLHintsExpandY,
01440                            2, 2, 2, 2);
01441    fL4 = new TGLayoutHints(kLHintsTop | kLHintsLeft,
01442                            0, 0, 5, 0);
01443 
01444    fC[0]  = new TGCheckButton(fG1, new TGHotString("Yes"),        -1);
01445    fC[1]  = new TGCheckButton(fG1, new TGHotString("No"),         -1);
01446    fC[2]  = new TGCheckButton(fG1, new TGHotString("OK"),         -1);
01447    fC[3]  = new TGCheckButton(fG1, new TGHotString("Apply"),      -1);
01448    fC[4]  = new TGCheckButton(fG1, new TGHotString("Retry"),      -1);
01449    fC[5]  = new TGCheckButton(fG1, new TGHotString("Ignore"),     -1);
01450    fC[6]  = new TGCheckButton(fG1, new TGHotString("Cancel"),     -1);
01451    fC[7]  = new TGCheckButton(fG1, new TGHotString("Close"),      -1);
01452    fC[8]  = new TGCheckButton(fG1, new TGHotString("Yes to All"), -1);
01453    fC[9]  = new TGCheckButton(fG1, new TGHotString("No to All"),  -1);
01454    fC[10] = new TGCheckButton(fG1, new TGHotString("Newer Only"), -1);
01455    fC[11] = new TGCheckButton(fG1, new TGHotString("Append"),     -1);
01456    fC[12] = new TGCheckButton(fG1, new TGHotString("Dismiss"),    -1);
01457 
01458    for (i=0; i<13; ++i) fG1->AddFrame(fC[i], fL4);
01459 
01460    fR[0] = new TGRadioButton(fG2, new TGHotString("Stop"),        21);
01461    fR[1] = new TGRadioButton(fG2, new TGHotString("Question"),    22);
01462    fR[2] = new TGRadioButton(fG2, new TGHotString("Exclamation"), 23);
01463    fR[3] = new TGRadioButton(fG2, new TGHotString("Asterisk"),    24);
01464 
01465    for (i = 0; i < 4; ++i) {
01466       fG2->AddFrame(fR[i], fL4);
01467       fR[i]->Connect("Clicked()", "TestMsgBox", this, "DoRadio()");
01468    }
01469 
01470    fC[2]->SetState(kButtonDown);
01471    fR[0]->SetState(kButtonDown);
01472 
01473    f3->AddFrame(fG1, fL3);
01474    f3->AddFrame(fG2, fL3);
01475 
01476    fLtitle = new TGLabel(f4, new TGString("Title:"), fRedTextGC());
01477    fLmsg   = new TGLabel(f5, new TGString("Message:"));
01478 
01479    fTitle = new TGTextEntry(f4, fTbtitle = new TGTextBuffer(100));
01480    fMsg   = new TGTextEntry(f5, fTbmsg = new TGTextBuffer(100));
01481 
01482    fTbtitle->AddText(0, "MsgBox");
01483    fTbmsg->AddText(0, "This is a test message box.");
01484 
01485    fTitle->Resize(300, fTitle->GetDefaultHeight());
01486    fMsg->Resize(300, fMsg->GetDefaultHeight());
01487 
01488    fL5 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
01489                            3, 5, 0, 0);
01490    fL6 = new TGLayoutHints(kLHintsRight | kLHintsCenterY,
01491                            0, 2, 0, 0);
01492 
01493    f4->AddFrame(fLtitle, fL5);
01494    f4->AddFrame(fTitle, fL6);
01495    f5->AddFrame(fLmsg, fL5);
01496    f5->AddFrame(fMsg, fL6);
01497 
01498    f2->AddFrame(f3, fL1);
01499    f2->AddFrame(f4, fL1);
01500    f2->AddFrame(f5, fL1);
01501 
01502    fMain->AddFrame(f2, fL2);
01503 
01504    fMain->MapSubwindows();
01505    fMain->Resize();
01506 
01507    // position relative to the parent's window
01508    fMain->CenterOnParent();
01509 
01510    fMain->SetWindowName("Message Box Test");
01511 
01512    fMain->MapWindow();
01513    gClient->WaitFor(fMain);
01514 }

TestMsgBox::~TestMsgBox (  )  [virtual]

Definition at line 1519 of file guitest.C.

01520 {
01521    // Delete widgets created by dialog.
01522 
01523    fMain->DeleteWindow();  // deletes fMain
01524 }


Member Function Documentation

void TestMsgBox::TryToClose (  ) 

Definition at line 1571 of file guitest.C.

01572 {
01573    // The user try to close the main window,
01574    //  while a message dialog box is still open.
01575    printf("Can't close the window '%s' : a message box is still open\n", fMain->GetWindowName());
01576 }

void TestMsgBox::CloseWindow (  ) 

Definition at line 1526 of file guitest.C.

Referenced by DoClose().

01527 {
01528    // Close dialog in response to window manager close.
01529 
01530    delete this;
01531 }

void TestMsgBox::DoClose (  ) 

Definition at line 1533 of file guitest.C.

01534 {
01535    // Handle Close button.
01536 
01537    CloseWindow();
01538 }

void TestMsgBox::DoRadio (  ) 

Definition at line 1578 of file guitest.C.

01579 {
01580    // Handle radio buttons.
01581 
01582    TGButton *btn = (TGButton *) gTQSender;
01583    Int_t id = btn->WidgetId();
01584 
01585    if (id >= 21 && id <= 24) {
01586       for (int i = 0; i < 4; i++)
01587          if (fR[i]->WidgetId() != id)
01588             fR[i]->SetState(kButtonUp);
01589    }
01590 }

void TestMsgBox::DoTest (  ) 

Definition at line 1540 of file guitest.C.

01541 {
01542    // Handle test button.
01543 
01544    int i, buttons, retval;
01545    EMsgBoxIcon icontype = kMBIconStop;
01546 
01547    buttons = 0;
01548    for (i = 0; i < 13; i++)
01549       if (fC[i]->GetState() == kButtonDown)
01550          buttons |= mb_button_id[i];
01551 
01552    for (i = 0; i < 4; i++)
01553       if (fR[i]->GetState() == kButtonDown) {
01554          icontype = mb_icon[i];
01555          break;
01556       }
01557 
01558    // Since the message dialog box is created, we disable the
01559    // signal/slot communication mechanism, in order to ensure we
01560    // can't close the fMain window while the message box is open.
01561    fMain->Disconnect("CloseWindow()");
01562    fMain->Connect("CloseWindow()", "TestMsgBox", this, "TryToClose()");
01563    new TGMsgBox(gClient->GetRoot(), fMain,
01564                 fTbtitle->GetString(), fTbmsg->GetString(),
01565                 icontype, buttons, &retval);
01566    fMain->Disconnect("CloseWindow()");
01567    fMain->Connect("CloseWindow()", "TestMsgBox", this, "CloseWindow()");
01568 
01569 }


Member Data Documentation

TGTransientFrame* TestMsgBox::fMain [private]

Definition at line 314 of file guitest.C.

Referenced by DoTest(), TestMsgBox(), TryToClose(), and ~TestMsgBox().

TGCompositeFrame* TestMsgBox::f1 [private]

Definition at line 315 of file guitest.C.

Referenced by TestMsgBox().

TGCompositeFrame * TestMsgBox::f2 [private]

Definition at line 315 of file guitest.C.

Referenced by TestMsgBox().

TGCompositeFrame * TestMsgBox::f3 [private]

Definition at line 315 of file guitest.C.

Referenced by TestMsgBox().

TGCompositeFrame * TestMsgBox::f4 [private]

Definition at line 315 of file guitest.C.

Referenced by TestMsgBox().

TGCompositeFrame * TestMsgBox::f5 [private]

Definition at line 315 of file guitest.C.

Referenced by TestMsgBox().

TGButton* TestMsgBox::fTestButton [private]

Definition at line 316 of file guitest.C.

Referenced by TestMsgBox().

TGButton * TestMsgBox::fCloseButton [private]

Definition at line 316 of file guitest.C.

Referenced by TestMsgBox().

TGPictureButton* TestMsgBox::fPictButton [private]

Definition at line 317 of file guitest.C.

Referenced by TestMsgBox().

TGRadioButton* TestMsgBox::fR[4] [private]

Definition at line 318 of file guitest.C.

Referenced by DoRadio(), DoTest(), and TestMsgBox().

TGCheckButton* TestMsgBox::fC[13] [private]

Definition at line 319 of file guitest.C.

Referenced by DoTest(), and TestMsgBox().

TGGroupFrame* TestMsgBox::fG1 [private]

Definition at line 320 of file guitest.C.

Referenced by TestMsgBox().

TGGroupFrame * TestMsgBox::fG2 [private]

Definition at line 320 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints* TestMsgBox::fL1 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL2 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL3 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL4 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL5 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL6 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGLayoutHints * TestMsgBox::fL21 [private]

Definition at line 321 of file guitest.C.

Referenced by TestMsgBox().

TGTextEntry* TestMsgBox::fTitle [private]

Definition at line 322 of file guitest.C.

Referenced by TestMsgBox().

TGTextEntry * TestMsgBox::fMsg [private]

Definition at line 322 of file guitest.C.

Referenced by TestMsgBox().

TGTextBuffer* TestMsgBox::fTbtitle [private]

Definition at line 323 of file guitest.C.

Referenced by DoTest(), and TestMsgBox().

TGTextBuffer * TestMsgBox::fTbmsg [private]

Definition at line 323 of file guitest.C.

Referenced by DoTest(), and TestMsgBox().

TGLabel* TestMsgBox::fLtitle [private]

Definition at line 324 of file guitest.C.

Referenced by TestMsgBox().

TGLabel * TestMsgBox::fLmsg [private]

Definition at line 324 of file guitest.C.

Referenced by TestMsgBox().

TGGC TestMsgBox::fRedTextGC [private]

Definition at line 325 of file guitest.C.

Referenced by TestMsgBox().


The documentation for this class was generated from the following file:
Generated on Mon Jan 7 13:19:05 2013 for MicromegasFramework by  doxygen 1.4.7