TestMainFrame Class Reference

Collaboration diagram for TestMainFrame:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TestMainFrame (const TGWindow *p, UInt_t w, UInt_t h)
virtual ~TestMainFrame ()
void CloseWindow ()
void DoButton ()
void HandleMenu (Int_t id)
void HandlePopup ()
void HandlePopdown ()
void Created ()
void Welcome ()

Private Attributes

TGMainFramefMain
TGDockableFrame * fMenuDock
TGCompositeFrame * fStatusFrame
TGCanvas * fCanvasWindow
TileFramefContainer
TGTextEntry * fTestText
TGButton * fTestButton
TGColorSelect * fColorSel
TGMenuBar * fMenuBar
TGPopupMenu * fMenuFile
TGPopupMenu * fMenuTest
TGPopupMenu * fMenuView
TGPopupMenu * fMenuHelp
TGPopupMenu * fCascadeMenu
TGPopupMenu * fCascade1Menu
TGPopupMenu * fCascade2Menu
TGPopupMenu * fMenuNew1
TGPopupMenu * fMenuNew2
TGLayoutHints * fMenuBarLayout
TGLayoutHints * fMenuBarItemLayout
TGLayoutHints * fMenuBarHelpLayout

Detailed Description

Definition at line 232 of file guitest.C.


Constructor & Destructor Documentation

TestMainFrame::TestMainFrame ( const TGWindow *  p,
UInt_t  w,
UInt_t  h 
)

Definition at line 583 of file guitest.C.

00584 {
00585    // Create test main frame. A TGMainFrame is a top level window.
00586 
00587    fMain = new TGMainFrame(p, w, h);
00588 
00589    // use hierarchical cleaning
00590    fMain->SetCleanup(kDeepCleanup);
00591 
00592    fMain->Connect("CloseWindow()", "TestMainFrame", this, "CloseWindow()");
00593 
00594    // Create menubar and popup menus. The hint objects are used to place
00595    // and group the different menu widgets with respect to eachother.
00596    fMenuDock = new TGDockableFrame(fMain);
00597    fMain->AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
00598    fMenuDock->SetWindowName("GuiTest Menu");
00599 
00600    fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
00601    fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
00602    fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
00603 
00604    fMenuFile = new TGPopupMenu(gClient->GetRoot());
00605    fMenuFile->AddEntry("&Open...", M_FILE_OPEN);
00606    fMenuFile->AddEntry("&Save", M_FILE_SAVE);
00607    fMenuFile->AddEntry("S&ave as...", M_FILE_SAVEAS);
00608    fMenuFile->AddEntry("&Close", -1);
00609    fMenuFile->AddSeparator();
00610    fMenuFile->AddEntry("&Print", M_FILE_PRINT);
00611    fMenuFile->AddEntry("P&rint setup...", M_FILE_PRINTSETUP);
00612    fMenuFile->AddSeparator();
00613    fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
00614 
00615    fMenuFile->DisableEntry(M_FILE_SAVEAS);
00616    fMenuFile->HideEntry(M_FILE_PRINT);
00617 
00618    fCascade2Menu = new TGPopupMenu(gClient->GetRoot());
00619    fCascade2Menu->AddEntry("ID = 2&3", M_CASCADE_1);
00620    fCascade2Menu->AddEntry("ID = 2&4", M_CASCADE_2);
00621    fCascade2Menu->AddEntry("ID = 2&5", M_CASCADE_3);
00622 
00623    fCascade1Menu = new TGPopupMenu(gClient->GetRoot());
00624    fCascade1Menu->AddEntry("ID = 4&1", 41);
00625    fCascade1Menu->AddEntry("ID = 4&2", 42);
00626    fCascade1Menu->AddEntry("ID = 4&3", 43);
00627    fCascade1Menu->AddSeparator();
00628    fCascade1Menu->AddPopup("Cascade&d 2", fCascade2Menu);
00629 
00630    fCascadeMenu = new TGPopupMenu(gClient->GetRoot());
00631    fCascadeMenu->AddEntry("ID = 5&1", 51);
00632    fCascadeMenu->AddEntry("ID = 5&2", 52);
00633    fCascadeMenu->AddEntry("ID = 5&3", 53);
00634    fCascadeMenu->AddSeparator();
00635    fCascadeMenu->AddPopup("&Cascaded 1", fCascade1Menu);
00636 
00637    fMenuTest = new TGPopupMenu(gClient->GetRoot());
00638    fMenuTest->AddLabel("Test different features...");
00639    fMenuTest->AddSeparator();
00640    fMenuTest->AddEntry("&Dialog...", M_TEST_DLG);
00641    fMenuTest->AddEntry("&Message Box...", M_TEST_MSGBOX);
00642    fMenuTest->AddEntry("&Sliders...", M_TEST_SLIDER);
00643    fMenuTest->AddEntry("Sh&utter...", M_TEST_SHUTTER);
00644    fMenuTest->AddEntry("&List Directory...", M_TEST_DIRLIST);
00645    fMenuTest->AddEntry("&File List...", M_TEST_FILELIST);
00646    fMenuTest->AddEntry("&Progress...", M_TEST_PROGRESS);
00647    fMenuTest->AddEntry("&Number Entry...", M_TEST_NUMBERENTRY);
00648    fMenuTest->AddEntry("F&ont Dialog...", M_TEST_FONTDIALOG);
00649    fMenuTest->AddSeparator();
00650    fMenuTest->AddEntry("Add New Menus", M_TEST_NEWMENU);
00651    fMenuTest->AddSeparator();
00652    fMenuTest->AddPopup("&Cascaded menus", fCascadeMenu);
00653 
00654    fMenuView = new TGPopupMenu(gClient->GetRoot());
00655    fMenuView->AddEntry("&Dock", M_VIEW_DOCK);
00656    fMenuView->AddEntry("&Undock", M_VIEW_UNDOCK);
00657    fMenuView->AddSeparator();
00658    fMenuView->AddEntry("Enable U&ndock", M_VIEW_ENBL_DOCK);
00659    fMenuView->AddEntry("Enable &Hide", M_VIEW_ENBL_HIDE);
00660    fMenuView->DisableEntry(M_VIEW_DOCK);
00661 
00662    fMenuDock->EnableUndock(kTRUE);
00663    fMenuDock->EnableHide(kTRUE);
00664    fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
00665    fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
00666 
00667    // When using the DockButton of the MenuDock,
00668    // the states 'enable' and 'disable' of menus have to be updated.
00669    fMenuDock->Connect("Undocked()", "TestMainFrame", this, "HandleMenu(=M_VIEW_UNDOCK)");
00670 
00671    fMenuHelp = new TGPopupMenu(gClient->GetRoot());
00672    fMenuHelp->AddEntry("&Contents", M_HELP_CONTENTS);
00673    fMenuHelp->AddEntry("&Search...", M_HELP_SEARCH);
00674    fMenuHelp->AddSeparator();
00675    fMenuHelp->AddEntry("&About", M_HELP_ABOUT);
00676 
00677    fMenuNew1 = new TGPopupMenu();
00678    fMenuNew1->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
00679 
00680    fMenuNew2 = new TGPopupMenu();
00681    fMenuNew2->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
00682 
00683    // Menu button messages are handled by the main frame (i.e. "this")
00684    // HandleMenu() method.
00685    fMenuFile->Connect("Activated(Int_t)", "TestMainFrame", this,
00686                       "HandleMenu(Int_t)");
00687    fMenuFile->Connect("PoppedUp()", "TestMainFrame", this, "HandlePopup()");
00688    fMenuFile->Connect("PoppedDown()", "TestMainFrame", this, "HandlePopdown()");
00689    fMenuTest->Connect("Activated(Int_t)", "TestMainFrame", this,
00690                       "HandleMenu(Int_t)");
00691    fMenuView->Connect("Activated(Int_t)", "TestMainFrame", this,
00692                       "HandleMenu(Int_t)");
00693    fMenuHelp->Connect("Activated(Int_t)", "TestMainFrame", this,
00694                       "HandleMenu(Int_t)");
00695    fCascadeMenu->Connect("Activated(Int_t)", "TestMainFrame", this,
00696                          "HandleMenu(Int_t)");
00697    fCascade1Menu->Connect("Activated(Int_t)", "TestMainFrame", this,
00698                           "HandleMenu(Int_t)");
00699    fCascade2Menu->Connect("Activated(Int_t)", "TestMainFrame", this,
00700                           "HandleMenu(Int_t)");
00701    fMenuNew1->Connect("Activated(Int_t)", "TestMainFrame", this,
00702                       "HandleMenu(Int_t)");
00703    fMenuNew2->Connect("Activated(Int_t)", "TestMainFrame", this,
00704                       "HandleMenu(Int_t)");
00705 
00706    fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame);
00707    fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
00708    fMenuBar->AddPopup("&Test", fMenuTest, fMenuBarItemLayout);
00709    fMenuBar->AddPopup("&View", fMenuView, fMenuBarItemLayout);
00710    fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
00711 
00712    fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
00713 
00714    // Create TGCanvas and a canvas container which uses a tile layout manager
00715    fCanvasWindow = new TGCanvas(fMain, 400, 240);
00716    fContainer = new TileFrame(fCanvasWindow->GetViewPort());
00717    fContainer->SetCanvas(fCanvasWindow);
00718    fCanvasWindow->SetContainer(fContainer->GetFrame());
00719 
00720    // use hierarchical cleaning for container
00721    fContainer->GetFrame()->SetCleanup(kDeepCleanup);
00722 
00723    // Fill canvas with 256 colored frames
00724    for (int i=0; i < 256; ++i)
00725       fCanvasWindow->AddFrame(new TGFrame(fCanvasWindow->GetContainer(),
00726                               32, 32, 0, TColor::RGB2Pixel(0,0,(i+1)&255)),
00727                               new TGLayoutHints(kLHintsExpandY | kLHintsRight));
00728 
00729    fMain->AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
00730                                                     0, 0, 2, 2));
00731 
00732    // Create status frame containing a button and a text entry widget
00733    fStatusFrame = new TGCompositeFrame(fMain, 60, 20, kHorizontalFrame |
00734                                                       kSunkenFrame);
00735 
00736    fTestButton = new TGTextButton(fStatusFrame, "&Open editor...", 150);
00737    fTestButton->Connect("Clicked()", "TestMainFrame", this, "DoButton()");
00738    fTestButton->SetToolTipText("Pops up\ntext editor");
00739    fStatusFrame->AddFrame(fTestButton, new TGLayoutHints(kLHintsTop |
00740                           kLHintsLeft, 2, 0, 2, 2));
00741    fTestText = new TGTextEntry(fStatusFrame, new TGTextBuffer(100));
00742    fTestText->SetToolTipText("This is a text entry widget");
00743    fTestText->Resize(300, fTestText->GetDefaultHeight());
00744    fStatusFrame->AddFrame(fTestText, new TGLayoutHints(kLHintsTop | kLHintsLeft,
00745                                                        10, 2, 2, 2));
00746    Pixel_t yellow;
00747    gClient->GetColorByName("yellow", yellow);
00748    fColorSel = new TGColorSelect(fStatusFrame, yellow, 0);
00749    fStatusFrame->AddFrame(fColorSel, new TGLayoutHints(kLHintsTop |
00750                           kLHintsLeft, 2, 0, 2, 2));
00751 
00752    fMain->AddFrame(fStatusFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
00753                    0, 0, 1, 0));
00754 
00755    fMain->SetWindowName("GuiTest Signal/Slots");
00756 
00757    fMain->MapSubwindows();
00758 
00759    // we need to use GetDefault...() to initialize the layout algorithm...
00760    fMain->Resize();
00761    fMain->MapWindow();
00762    fMain->Print();
00763    Connect("Created()", "TestMainFrame", this, "Welcome()");
00764    Created();
00765 }

TestMainFrame::~TestMainFrame (  )  [virtual]

Definition at line 767 of file guitest.C.

00768 {
00769    // Delete all created widgets.
00770 
00771    delete fMenuFile;
00772    delete fMenuTest;
00773    delete fMenuView;
00774    delete fMenuHelp;
00775    delete fCascadeMenu;
00776    delete fCascade1Menu;
00777    delete fCascade2Menu;
00778    delete fMenuNew1;
00779    delete fMenuNew2;
00780 
00781    delete fContainer;
00782    delete fMain;
00783 }


Member Function Documentation

void TestMainFrame::CloseWindow (  ) 

Definition at line 785 of file guitest.C.

Referenced by HandleMenu().

00786 {
00787    // Got close message for this MainFrame. Terminates the application.
00788 
00789    gApplication->Terminate();
00790 }

void TestMainFrame::DoButton (  ) 

Definition at line 792 of file guitest.C.

00793 {
00794    // Handle button click.
00795 
00796    Editor *ed = new Editor(fMain, 600, 400);
00797    ed->LoadBuffer(editortxt1);
00798    ed->AddBuffer(editortxt2);
00799    ed->AddBuffer(editortxt3);
00800    ed->AddBuffer(editortxt4);
00801    ed->AddBuffer(editortxt5);
00802    ed->AddBuffer(editortxt6);
00803    ed->Popup();
00804 }

void TestMainFrame::HandleMenu ( Int_t  id  ) 

Definition at line 806 of file guitest.C.

00807 {
00808    // Handle menu items.
00809 
00810    switch (id) {
00811 
00812       case M_FILE_OPEN:
00813          {
00814             static TString dir(".");
00815             TGFileInfo fi;
00816             fi.fFileTypes = filetypes;
00817             fi.fIniDir    = StrDup(dir);
00818             printf("fIniDir = %s\n", fi.fIniDir);
00819             new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi);
00820             printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
00821             dir = fi.fIniDir;
00822          }
00823          break;
00824 
00825       case M_FILE_SAVE:
00826          printf("M_FILE_SAVE\n");
00827          break;
00828 
00829       case M_FILE_PRINT:
00830          printf("M_FILE_PRINT\n");
00831          printf("Hiding itself, select \"Print Setup...\" to enable again\n");
00832          fMenuFile->HideEntry(M_FILE_PRINT);
00833          break;
00834 
00835       case M_FILE_PRINTSETUP:
00836          printf("M_FILE_PRINTSETUP\n");
00837          printf("Enabling \"Print\"\n");
00838          fMenuFile->EnableEntry(M_FILE_PRINT);
00839          break;
00840 
00841       case M_FILE_EXIT:
00842          CloseWindow();   // terminate theApp no need to use SendCloseMessage()
00843          break;
00844 
00845       case M_TEST_DLG:
00846          new TestDialog(gClient->GetRoot(), fMain, 400, 200);
00847          break;
00848 
00849       case M_TEST_MSGBOX:
00850          new TestMsgBox(gClient->GetRoot(), fMain, 400, 200);
00851          break;
00852 
00853       case M_TEST_SLIDER:
00854          new TestSliders(gClient->GetRoot(), fMain, 400, 200);
00855          break;
00856 
00857       case M_TEST_SHUTTER:
00858          new TestShutter(gClient->GetRoot(), fMain, 400, 200);
00859          break;
00860 
00861       case M_TEST_DIRLIST:
00862          new TestDirList(gClient->GetRoot(), fMain, 400, 200);
00863          break;
00864 
00865      case M_TEST_FILELIST:
00866          new TestFileList(gClient->GetRoot(), fMain, 400, 200);
00867          break;
00868 
00869       case M_TEST_PROGRESS:
00870          new TestProgress(gClient->GetRoot(), fMain, 600, 300);
00871          break;
00872 
00873       case M_TEST_NUMBERENTRY:
00874          new EntryTestDlg(gClient->GetRoot(), fMain);
00875          break;
00876 
00877       case M_TEST_FONTDIALOG:
00878          {
00879             TGFontDialog::FontProp_t prop;
00880             new TGFontDialog(gClient->GetRoot(), fMain, &prop);
00881             if (prop.fName != "")
00882                printf("Selected font: %s, size %d, italic %s, bold %s, color 0x%lx, align %u\n",
00883                       prop.fName.Data(), prop.fSize, prop.fItalic ? "yes" : "no",
00884                       prop.fBold ? "yes" : "no", prop.fColor, prop.fAlign);
00885          }
00886          break;
00887 
00888       case M_TEST_NEWMENU:
00889          {
00890             if (fMenuTest->IsEntryChecked(M_TEST_NEWMENU)) {
00891                HandleMenu(M_NEW_REMOVEMENU);
00892                return;
00893             }
00894             fMenuTest->CheckEntry(M_TEST_NEWMENU);
00895             TGPopupMenu *p = fMenuBar->GetPopup("Test");
00896             fMenuBar->AddPopup("New 1", fMenuNew1, fMenuBarItemLayout, p);
00897             p = fMenuBar->GetPopup("Help");
00898             fMenuBar->AddPopup("New 2", fMenuNew2, fMenuBarItemLayout, p);
00899             fMenuBar->MapSubwindows();
00900             fMenuBar->Layout();
00901 
00902             TGMenuEntry *e = fMenuTest->GetEntry("Add New Menus");
00903             fMenuTest->AddEntry("Remove New Menus", M_NEW_REMOVEMENU, 0, 0, e);
00904          }
00905          break;
00906 
00907       case M_NEW_REMOVEMENU:
00908          {
00909             fMenuBar->RemovePopup("New 1");
00910             fMenuBar->RemovePopup("New 2");
00911             fMenuBar->Layout();
00912             fMenuTest->DeleteEntry(M_NEW_REMOVEMENU);
00913             fMenuTest->UnCheckEntry(M_TEST_NEWMENU);
00914          }
00915          break;
00916 
00917       case M_VIEW_ENBL_DOCK:
00918          fMenuDock->EnableUndock(!fMenuDock->EnableUndock());
00919          if (fMenuDock->EnableUndock()) {
00920             fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
00921             fMenuView->EnableEntry(M_VIEW_UNDOCK);
00922          } else {
00923             fMenuView->UnCheckEntry(M_VIEW_ENBL_DOCK);
00924             fMenuView->DisableEntry(M_VIEW_UNDOCK);
00925          }
00926          break;
00927 
00928       case M_VIEW_ENBL_HIDE:
00929          fMenuDock->EnableHide(!fMenuDock->EnableHide());
00930          if (fMenuDock->EnableHide()) {
00931             fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
00932          } else {
00933             fMenuView->UnCheckEntry(M_VIEW_ENBL_HIDE);
00934          }
00935          break;
00936 
00937        case M_VIEW_DOCK:
00938          fMenuDock->DockContainer();
00939          fMenuView->EnableEntry(M_VIEW_UNDOCK);
00940          fMenuView->DisableEntry(M_VIEW_DOCK);
00941          break;
00942 
00943        case M_VIEW_UNDOCK:
00944          fMenuDock->UndockContainer();
00945          fMenuView->EnableEntry(M_VIEW_DOCK);
00946          fMenuView->DisableEntry(M_VIEW_UNDOCK);
00947          break;
00948 
00949       default:
00950          printf("Menu item %d selected\n", id);
00951          break;
00952    }
00953 }

void TestMainFrame::HandlePopup (  )  [inline]

Definition at line 260 of file guitest.C.

00260 { printf("menu popped up\n"); }

void TestMainFrame::HandlePopdown (  )  [inline]

Definition at line 261 of file guitest.C.

00261 { printf("menu popped down\n"); }

void TestMainFrame::Created (  )  [inline]

Definition at line 263 of file guitest.C.

Referenced by TestMainFrame().

00263 { Emit("Created()"); } //*SIGNAL*

void TestMainFrame::Welcome (  )  [inline]

Definition at line 264 of file guitest.C.

00264 { printf("TestMainFrame has been created. Welcome!\n"); }


Member Data Documentation

TGMainFrame* TestMainFrame::fMain [private]

Definition at line 237 of file guitest.C.

Referenced by DoButton(), HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGDockableFrame* TestMainFrame::fMenuDock [private]

Definition at line 238 of file guitest.C.

Referenced by HandleMenu(), and TestMainFrame().

TGCompositeFrame* TestMainFrame::fStatusFrame [private]

Definition at line 239 of file guitest.C.

Referenced by TestMainFrame().

TGCanvas* TestMainFrame::fCanvasWindow [private]

Definition at line 240 of file guitest.C.

Referenced by TestMainFrame().

TileFrame* TestMainFrame::fContainer [private]

Definition at line 241 of file guitest.C.

Referenced by TestMainFrame(), and ~TestMainFrame().

TGTextEntry* TestMainFrame::fTestText [private]

Definition at line 242 of file guitest.C.

Referenced by TestMainFrame().

TGButton* TestMainFrame::fTestButton [private]

Definition at line 243 of file guitest.C.

Referenced by TestMainFrame().

TGColorSelect* TestMainFrame::fColorSel [private]

Definition at line 244 of file guitest.C.

Referenced by TestMainFrame().

TGMenuBar* TestMainFrame::fMenuBar [private]

Definition at line 246 of file guitest.C.

Referenced by HandleMenu(), and TestMainFrame().

TGPopupMenu* TestMainFrame::fMenuFile [private]

Definition at line 247 of file guitest.C.

Referenced by HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fMenuTest [private]

Definition at line 247 of file guitest.C.

Referenced by HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fMenuView [private]

Definition at line 247 of file guitest.C.

Referenced by HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fMenuHelp [private]

Definition at line 247 of file guitest.C.

Referenced by TestMainFrame(), and ~TestMainFrame().

TGPopupMenu* TestMainFrame::fCascadeMenu [private]

Definition at line 248 of file guitest.C.

Referenced by TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fCascade1Menu [private]

Definition at line 248 of file guitest.C.

Referenced by TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fCascade2Menu [private]

Definition at line 248 of file guitest.C.

Referenced by TestMainFrame(), and ~TestMainFrame().

TGPopupMenu* TestMainFrame::fMenuNew1 [private]

Definition at line 249 of file guitest.C.

Referenced by HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGPopupMenu * TestMainFrame::fMenuNew2 [private]

Definition at line 249 of file guitest.C.

Referenced by HandleMenu(), TestMainFrame(), and ~TestMainFrame().

TGLayoutHints* TestMainFrame::fMenuBarLayout [private]

Definition at line 250 of file guitest.C.

Referenced by TestMainFrame().

TGLayoutHints * TestMainFrame::fMenuBarItemLayout [private]

Definition at line 250 of file guitest.C.

Referenced by HandleMenu(), and TestMainFrame().

TGLayoutHints * TestMainFrame::fMenuBarHelpLayout [private]

Definition at line 250 of file guitest.C.

Referenced by TestMainFrame().


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