guitest.cxx

Go to the documentation of this file.
00001 // @(#)root/test:$Id: guitest.cxx 31772 2009-12-10 11:39:58Z bellenot $
00002 // Author: Fons Rademakers   07/03/98
00003 
00004 // guitest.cxx: test program for ROOT native GUI classes.
00005 // To run it do: make guitest; guitest
00006 // Another version with identical functionality but using the new signals
00007 // and slots communication mechanism can be found in $ROOTSYS/tutorials.
00008 // That version can be run entirely in the interpreter.
00009 
00010 #include <stdlib.h>
00011 
00012 #include <TROOT.h>
00013 #include <TApplication.h>
00014 #include <TVirtualX.h>
00015 #include <TVirtualPadEditor.h>
00016 #include <TGResourcePool.h>
00017 #include <TGListBox.h>
00018 #include <TGListTree.h>
00019 #include <TGFSContainer.h>
00020 #include <TGClient.h>
00021 #include <TGFrame.h>
00022 #include <TGIcon.h>
00023 #include <TGLabel.h>
00024 #include <TGButton.h>
00025 #include <TGTextEntry.h>
00026 #include <TGNumberEntry.h>
00027 #include <TGMsgBox.h>
00028 #include <TGMenu.h>
00029 #include <TGCanvas.h>
00030 #include <TGComboBox.h>
00031 #include <TGTab.h>
00032 #include <TGSlider.h>
00033 #include <TGDoubleSlider.h>
00034 #include <TGFileDialog.h>
00035 #include <TGTextEdit.h>
00036 #include <TGShutter.h>
00037 #include <TGProgressBar.h>
00038 #include <TGColorSelect.h>
00039 #include <TRootEmbeddedCanvas.h>
00040 #include <TCanvas.h>
00041 #include <TColor.h>
00042 #include <TH1.h>
00043 #include <TH2.h>
00044 #include <TRandom.h>
00045 #include <TSystem.h>
00046 #include <TSystemDirectory.h>
00047 #include <TEnv.h>
00048 #include <TFile.h>
00049 #include <TKey.h>
00050 #include <TGDockableFrame.h>
00051 #include <TGFontDialog.h>
00052 
00053 
00054 enum ETestCommandIdentifiers {
00055    M_FILE_OPEN,
00056    M_FILE_SAVE,
00057    M_FILE_SAVEAS,
00058    M_FILE_PRINT,
00059    M_FILE_PRINTSETUP,
00060    M_FILE_EXIT,
00061 
00062    M_TEST_DLG,
00063    M_TEST_MSGBOX,
00064    M_TEST_SLIDER,
00065    M_TEST_SHUTTER,
00066    M_TEST_DIRLIST,
00067    M_TEST_FILELIST,
00068    M_TEST_PROGRESS,
00069    M_TEST_NUMBERENTRY,
00070    M_TEST_FONTDIALOG,
00071    M_TEST_NEWMENU,
00072 
00073    M_VIEW_ENBL_DOCK,
00074    M_VIEW_ENBL_HIDE,
00075    M_VIEW_DOCK,
00076    M_VIEW_UNDOCK,
00077 
00078    M_HELP_CONTENTS,
00079    M_HELP_SEARCH,
00080    M_HELP_ABOUT,
00081 
00082    M_CASCADE_1,
00083    M_CASCADE_2,
00084    M_CASCADE_3,
00085 
00086    M_NEW_REMOVEMENU,
00087 
00088    VId1,
00089    HId1,
00090    VId2,
00091    HId2,
00092 
00093    VSId1,
00094    HSId1,
00095    VSId2,
00096    HSId2,
00097 
00098    ColorSel
00099 };
00100 
00101 
00102 Int_t mb_button_id[13] = { kMBYes, kMBNo, kMBOk, kMBApply,
00103                            kMBRetry, kMBIgnore, kMBCancel,
00104                            kMBClose, kMBYesAll, kMBNoAll, 
00105                            kMBNewer, kMBAppend, kMBDismiss};
00106 
00107 EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion,
00108                            kMBIconExclamation, kMBIconAsterisk };
00109 
00110 const char *filetypes[] = { "All files",     "*",
00111                             "ROOT files",    "*.root",
00112                             "ROOT macros",   "*.C",
00113                             0,               0 };
00114 
00115 struct shutterData_t {
00116    const char *pixmap_name;
00117    const char *tip_text;
00118    Int_t       id;
00119    TGButton   *button;
00120 };
00121 
00122 shutterData_t histo_data[] = {
00123    { "h1_s.xpm",        "TH1",      1001,  0 },
00124    { "h2_s.xpm",        "TH2",      1002,  0 },
00125    { "h3_s.xpm",        "TH3",      1003,  0 },
00126    { "profile_s.xpm",   "TProfile", 1004,  0 },
00127    { 0,                 0,          0,     0 }
00128 };
00129 
00130 shutterData_t function_data[] = {
00131    { "f1_s.xpm",        "TF1",      2001,  0 },
00132    { "f2_s.xpm",        "TF2",      2002,  0 },
00133    { 0,                 0,          0,     0 }
00134 };
00135 
00136 shutterData_t tree_data[] = {
00137    { "ntuple_s.xpm",    "TNtuple",  3001,  0 },
00138    { "tree_s.xpm",      "TTree",    3002,  0 },
00139    { "chain_s.xpm",     "TChain",   3003,  0 },
00140    { 0,                 0,          0,     0 }
00141 };
00142 
00143 
00144 const char *editortxt =
00145 "This is the ROOT text edit widget TGTextEdit. It is not intended as\n"
00146 "a full developers editor, but it is relatively complete and can ideally\n"
00147 "be used to edit scripts or to present users editable config files, etc.\n\n"
00148 "The text edit widget supports standard emacs style ctrl-key navigation\n"
00149 "in addition to the arrow keys. By default the widget has under the right\n"
00150 "mouse button a popup menu giving access to several built-in functions.\n\n"
00151 "Cut, copy and paste between different editor windows and any other\n"
00152 "standard text handling application is supported.\n\n"
00153 "Text can be selected with the mouse while holding the left button\n"
00154 "or with the arrow keys while holding the shift key pressed. Use the\n"
00155 "middle mouse button to paste text at the current mouse location.\n"
00156 "Mice with scroll-ball are properly supported.\n\n"
00157 "This are the currently defined key bindings:\n"
00158 "Left Arrow\n"
00159 "    Move the cursor one character leftwards.\n"
00160 "    Scroll when cursor is out of frame.\n"
00161 "Right Arrow\n"
00162 "    Move the cursor one character rightwards.\n"
00163 "    Scroll when cursor is out of frame.\n"
00164 "Backspace\n"
00165 "    Deletes the character on the left side of the text cursor and moves the\n"
00166 "    cursor one position to the left. If a text has been marked by the user\n"
00167 "    (e.g. by clicking and dragging) the cursor will be put at the beginning\n"
00168 "    of the marked text and the marked text will be removed.\n"
00169 "Home\n"
00170 "    Moves the text cursor to the left end of the line. If mark is TRUE text\n"
00171 "    will be marked towards the first position, if not any marked text will\n"
00172 "    be unmarked if the cursor is moved.\n"
00173 "End\n"
00174 "    Moves the text cursor to the right end of the line. If mark is TRUE text\n"
00175 "    will be marked towards the last position, if not any marked text will\n"
00176 "    be unmarked if the cursor is moved.\n"
00177 "Delete\n"
00178 "    Deletes the character on the right side of the text cursor. If a text\n"
00179 "    has been marked by the user (e.g. by clicking and dragging) the cursor\n"
00180 "    will be put at the beginning of the marked text and the marked text will\n"
00181 "    be removed.\n"
00182 "    Deletes the character on the right side of the text cursor. If a text\n"
00183 "    has been marked by the user (e.g. by clicking and dragging) the cursor\n"
00184 "    will be put at the beginning of the marked text and the marked text will\n"
00185 "    be removed.\n"
00186 "Shift - Left Arrow\n"
00187 "    Mark text one character leftwards.\n"
00188 "Shift - Right Arrow\n"
00189 "    Mark text one character rightwards.\n"
00190 "Control-A\n"
00191 "    Select the whole text.\n"
00192 "Control-B\n"
00193 "    Move the cursor one character leftwards."
00194 "Control-C\n"
00195 "    Copy the marked text to the clipboard.\n"
00196 "Control-D\n"
00197 "    Delete the character to the right of the cursor.\n"
00198 "Control-E\n"
00199 "    Move the cursor to the end of the line.\n"
00200 "Control-F\n"
00201 "    Start Search Dialog.\n"
00202 "Control-H\n"
00203 "    Delete the character to the left of the cursor.\n"
00204 "Control-K\n"
00205 "    Delete marked text if any or delete all\n"
00206 "    characters to the right of the cursor.\n"
00207 "Control-L\n"
00208 "    Start GoTo Line Dialog\n"
00209 "Control-U\n"
00210 "    Delete all characters on the line.\n"
00211 "Control-V\n"
00212 "    Paste the clipboard text into line edit.\n"
00213 "Control-X\n"
00214 "    Cut the marked text, copy to clipboard.\n"
00215 "Control-Y\n"
00216 "    Paste the clipboard text into line edit.\n"
00217 "Control-Z\n"
00218 "    Undo action.\n\n"
00219 "All other keys with valid ASCII codes insert themselves into the line.";
00220 
00221 class TileFrame;
00222 
00223 
00224 class TestMainFrame : public TGMainFrame {
00225 
00226 private:
00227    TGDockableFrame    *fMenuDock;
00228    TGCompositeFrame   *fStatusFrame;
00229    TGCanvas           *fCanvasWindow;
00230    TileFrame          *fContainer;
00231    TGTextEntry        *fTestText;
00232    TGButton           *fTestButton;
00233    TGColorSelect      *fColorSel;
00234 
00235    TGMenuBar          *fMenuBar;
00236    TGPopupMenu        *fMenuFile, *fMenuTest, *fMenuView, *fMenuHelp;
00237    TGPopupMenu        *fCascadeMenu, *fCascade1Menu, *fCascade2Menu;
00238    TGPopupMenu        *fMenuNew1, *fMenuNew2;
00239    TGLayoutHints      *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout;
00240 
00241 public:
00242    TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
00243    virtual ~TestMainFrame();
00244 
00245    virtual void CloseWindow();
00246    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t);
00247 };
00248 
00249 
00250 class TestDialog : public TGTransientFrame {
00251 
00252 private:
00253    TGCompositeFrame    *fFrame1, *fF1, *fF2, *fF3, *fF4, *fF5;
00254    TGGroupFrame        *fF6, *fF7;
00255    TGButton            *fOkButton, *fCancelButton, *fStartB, *fStopB;
00256    TGButton            *fBtn1, *fBtn2, *fChk1, *fChk2, *fRad1, *fRad2;
00257    TGPictureButton     *fPicBut1;
00258    TGCheckButton       *fCheck1;
00259    TGCheckButton       *fCheckMulti;
00260    TGListBox           *fListBox;
00261    TGComboBox          *fCombo;
00262    TGTab               *fTab;
00263    TGTextEntry         *fTxt1, *fTxt2;
00264    TGLayoutHints       *fL1, *fL2, *fL3, *fL4;
00265    TRootEmbeddedCanvas *fEc1, *fEc2;
00266    Int_t                fFirstEntry;
00267    Int_t                fLastEntry;
00268    Bool_t               fFillHistos;
00269    TH1F                *fHpx;
00270    TH2F                *fHpxpy;
00271 
00272    void FillHistos();
00273 
00274 public:
00275    TestDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h,
00276                UInt_t options = kVerticalFrame);
00277    virtual ~TestDialog();
00278 
00279    virtual void CloseWindow();
00280    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00281 };
00282 
00283 
00284 class TestMsgBox : public TGTransientFrame {
00285 
00286 private:
00287    TGCompositeFrame     *f1, *f2, *f3, *f4, *f5;
00288    TGButton             *fTestButton, *fCloseButton;
00289    TGPictureButton      *fPictButton;
00290    TGRadioButton        *fR[4];
00291    TGCheckButton        *fC[13];
00292    TGGroupFrame         *fG1, *fG2;
00293    TGLayoutHints        *fL1, *fL2, *fL3, *fL4, *fL5, *fL6, *fL21;
00294    TGTextEntry          *fTitle, *fMsg;
00295    TGTextBuffer         *fTbtitle, *fTbmsg;
00296    TGLabel              *fLtitle, *fLmsg;
00297    TGGC                  fRedTextGC;
00298 
00299 public:
00300    TestMsgBox(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h,
00301               UInt_t options = kVerticalFrame);
00302    virtual ~TestMsgBox();
00303 
00304    virtual void CloseWindow();
00305    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00306 };
00307 
00308 
00309 class TestSliders : public TGTransientFrame {
00310 
00311 private:
00312    TGVerticalFrame   *fVframe1, *fVframe2;
00313    TGLayoutHints     *fBly, *fBfly1;
00314    TGHSlider         *fHslider1, *fHslider2;
00315    TGVSlider         *fVslider1;
00316    TGDoubleVSlider   *fVslider2;
00317    TGTextEntry       *fTeh1, *fTev1, *fTeh2, *fTev2;
00318    TGTextBuffer      *fTbh1, *fTbv1, *fTbh2, *fTbv2;
00319 
00320 public:
00321    TestSliders(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
00322    virtual ~TestSliders();
00323 
00324    virtual void CloseWindow();
00325    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00326 };
00327 
00328 
00329 class TestShutter : public TGTransientFrame {
00330 
00331 private:
00332    TGShutter       *fShutter;
00333    TGLayoutHints   *fLayout;
00334    const TGPicture *fDefaultPic;
00335 
00336 public:
00337    TestShutter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
00338    ~TestShutter();
00339 
00340    void AddShutterItem(const char *name, shutterData_t data[]);
00341    virtual void CloseWindow();
00342    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00343 };
00344 
00345 
00346 class TestDirList  : public TGTransientFrame {
00347 
00348 protected:
00349    TGListTree  *fContents;
00350    TString DirName(TGListTreeItem* item);
00351    const TGPicture *fIcon;
00352 
00353 public:
00354    TestDirList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
00355    virtual ~TestDirList();
00356    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00357 };
00358 
00359 
00360 
00361 class TestFileList  : public TGTransientFrame {
00362 
00363 protected:
00364    TGFileContainer  *fContents;
00365    TGPopupMenu      *fMenu;
00366 
00367    virtual void DisplayFile(const TString &fname);
00368    virtual void DisplayDirectory(const TString &fname);
00369    virtual void DisplayObject(const TString& fname,const TString& name);
00370    virtual void OnDoubleClick(TGLVEntry*,Int_t);
00371    virtual void DoMenu(Int_t);
00372 
00373 public:
00374    TestFileList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
00375    virtual ~TestFileList();
00376 
00377    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00378 };
00379 
00380 
00381 class TestProgress : public TGTransientFrame {
00382 
00383 private:
00384    TGHorizontalFrame *fHframe1;
00385    TGVerticalFrame   *fVframe1;
00386    TGLayoutHints     *fHint1, *fHint2, *fHint3, *fHint4, *fHint5;
00387    TGHProgressBar    *fHProg1, *fHProg2, *fHProg3;
00388    TGVProgressBar    *fVProg1, *fVProg2;
00389    TGTextButton      *fGO;
00390 
00391 public:
00392    TestProgress(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
00393    virtual ~TestProgress();
00394 
00395    virtual void CloseWindow();
00396    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00397 };
00398 
00399 
00400 class EntryTestDlg : public TGTransientFrame {
00401 
00402 private:
00403    TGVerticalFrame      *fF1;
00404    TGVerticalFrame      *fF2;
00405    TGHorizontalFrame    *fF[13];
00406    TGLayoutHints        *fL1;
00407    TGLayoutHints        *fL2;
00408    TGLayoutHints        *fL3;
00409    TGLabel              *fLabel[13];
00410    TGNumberEntry        *fNumericEntries[13];
00411    TGCheckButton        *fLowerLimit;
00412    TGCheckButton        *fUpperLimit;
00413    TGNumberEntry        *fLimits[2];
00414    TGCheckButton        *fPositive;
00415    TGCheckButton        *fNonNegative;
00416    TGButton             *fSetButton;
00417    TGButton             *fExitButton;
00418 
00419    static const char *const numlabel[13];
00420    static const Double_t numinit[13];
00421 
00422 public:
00423    EntryTestDlg(const TGWindow *p, const TGWindow *main);
00424    virtual ~EntryTestDlg();
00425    virtual void CloseWindow();
00426 
00427    void SetLimits();
00428    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t);
00429 };
00430 
00431 
00432 class Editor : public TGTransientFrame {
00433 
00434 private:
00435    TGTextEdit       *fEdit;   // text edit widget
00436    TGTextButton     *fOK;     // OK button
00437    TGLayoutHints    *fL1;     // layout of TGTextEdit
00438    TGLayoutHints    *fL2;     // layout of OK button
00439 
00440 public:
00441    Editor(const TGWindow *main, UInt_t w, UInt_t h);
00442    virtual ~Editor();
00443 
00444    void   LoadBuffer(const char *buffer);
00445    void   LoadFile(const char *file);
00446 
00447    TGTextEdit *GetEditor() const { return fEdit; }
00448 
00449    void   SetTitle();
00450    void   Popup();
00451    void   CloseWindow();
00452    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00453 };
00454 
00455 
00456 class TileFrame : public TGCompositeFrame {
00457 
00458 private:
00459    TGCanvas *fCanvas;
00460 
00461 public:
00462    TileFrame(const TGWindow *p);
00463    virtual ~TileFrame() { }
00464 
00465    void SetCanvas(TGCanvas *canvas) { fCanvas = canvas; }
00466    Bool_t HandleButton(Event_t *event);
00467 };
00468 
00469 TileFrame::TileFrame(const TGWindow *p) :
00470    TGCompositeFrame(p, 10, 10, kHorizontalFrame, GetWhitePixel())
00471 {
00472    // Create tile view container. Used to show colormap.
00473 
00474    fCanvas = 0;
00475    SetLayoutManager(new TGTileLayout(this, 8));
00476 
00477    // Handle only buttons 4 and 5 used by the wheel mouse to scroll
00478    gVirtualX->GrabButton(fId, kButton4, kAnyModifier,
00479                          kButtonPressMask | kButtonReleaseMask,
00480                          kNone, kNone);
00481    gVirtualX->GrabButton(fId, kButton5, kAnyModifier,
00482                          kButtonPressMask | kButtonReleaseMask,
00483                          kNone, kNone);
00484 }
00485 
00486 Bool_t TileFrame::HandleButton(Event_t *event)
00487 {
00488    // Handle wheel mouse to scroll.
00489 
00490    Int_t page = 0;
00491    if (event->fCode == kButton4 || event->fCode == kButton5) {
00492       if (!fCanvas) return kTRUE;
00493       if (fCanvas->GetContainer()->GetHeight())
00494          page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() *
00495                               fCanvas->GetViewPort()->GetHeight()) /
00496                               fCanvas->GetContainer()->GetHeight());
00497    }
00498 
00499    if (event->fCode == kButton4) {
00500       //scroll up
00501       Int_t newpos = fCanvas->GetVsbPosition() - page;
00502       if (newpos < 0) newpos = 0;
00503       fCanvas->SetVsbPosition(newpos);
00504       return kTRUE;
00505    }
00506    if (event->fCode == kButton5) {
00507       // scroll down
00508       Int_t newpos = fCanvas->GetVsbPosition() + page;
00509       fCanvas->SetVsbPosition(newpos);
00510       return kTRUE;
00511    }
00512    return kTRUE;
00513 }
00514 
00515 
00516 TestMainFrame::TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
00517       : TGMainFrame(p, w, h)
00518 {
00519    // Create test main frame. A TGMainFrame is a top level window.
00520 
00521    // use hierarchical cleaning
00522    SetCleanup(kDeepCleanup);
00523 
00524    // Create menubar and popup menus. The hint objects are used to place
00525    // and group the different menu widgets with respect to eachother.
00526    fMenuDock = new TGDockableFrame(this);
00527    AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
00528    fMenuDock->SetWindowName("GuiTest Menu");
00529 
00530    fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
00531    fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
00532    fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
00533 
00534    fMenuFile = new TGPopupMenu(fClient->GetRoot());
00535    fMenuFile->AddEntry("&Open...", M_FILE_OPEN);
00536    fMenuFile->AddEntry("&Save", M_FILE_SAVE);
00537    fMenuFile->AddEntry("S&ave as...", M_FILE_SAVEAS);
00538    fMenuFile->AddEntry("&Close", -1);
00539    fMenuFile->AddSeparator();
00540    fMenuFile->AddEntry("&Print", M_FILE_PRINT);
00541    fMenuFile->AddEntry("P&rint setup...", M_FILE_PRINTSETUP);
00542    fMenuFile->AddSeparator();
00543    fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
00544 
00545    fMenuFile->DisableEntry(M_FILE_SAVEAS);
00546    fMenuFile->HideEntry(M_FILE_PRINT);
00547 
00548    fCascade2Menu = new TGPopupMenu(fClient->GetRoot());
00549    fCascade2Menu->AddEntry("ID = 2&3", M_CASCADE_1);
00550    fCascade2Menu->AddEntry("ID = 2&4", M_CASCADE_2);
00551    fCascade2Menu->AddEntry("ID = 2&5", M_CASCADE_3);
00552 
00553    fCascade1Menu = new TGPopupMenu(fClient->GetRoot());
00554    fCascade1Menu->AddEntry("ID = 4&1", 41);
00555    fCascade1Menu->AddEntry("ID = 4&2", 42);
00556    fCascade1Menu->AddEntry("ID = 4&3", 43);
00557    fCascade1Menu->AddSeparator();
00558    fCascade1Menu->AddPopup("Cascade&d 2", fCascade2Menu);
00559 
00560    fCascadeMenu = new TGPopupMenu(fClient->GetRoot());
00561    fCascadeMenu->AddEntry("ID = 5&1", 51);
00562    fCascadeMenu->AddEntry("ID = 5&2", 52);
00563    fCascadeMenu->AddEntry("ID = 5&3", 53);
00564    fCascadeMenu->AddSeparator();
00565    fCascadeMenu->AddPopup("&Cascaded 1", fCascade1Menu);
00566 
00567    fMenuTest = new TGPopupMenu(fClient->GetRoot());
00568    fMenuTest->AddLabel("Test different features...");
00569    fMenuTest->AddSeparator();
00570    fMenuTest->AddEntry("&Dialog...", M_TEST_DLG);
00571    fMenuTest->AddEntry("&Message Box...", M_TEST_MSGBOX);
00572    fMenuTest->AddEntry("&Sliders...", M_TEST_SLIDER);
00573    fMenuTest->AddEntry("Sh&utter...", M_TEST_SHUTTER);
00574    fMenuTest->AddEntry("&List Directory...", M_TEST_DIRLIST);
00575    fMenuTest->AddEntry("&File List...", M_TEST_FILELIST);
00576    fMenuTest->AddEntry("&Progress...", M_TEST_PROGRESS);
00577    fMenuTest->AddEntry("&Number Entry...", M_TEST_NUMBERENTRY);
00578    fMenuTest->AddEntry("F&ont Dialog...", M_TEST_FONTDIALOG);
00579    fMenuTest->AddSeparator();
00580    fMenuTest->AddEntry("Add New Menus", M_TEST_NEWMENU);
00581    fMenuTest->AddSeparator();
00582    fMenuTest->AddPopup("&Cascaded menus", fCascadeMenu);
00583 
00584    fMenuView = new TGPopupMenu(gClient->GetRoot());
00585    fMenuView->AddEntry("&Dock", M_VIEW_DOCK);
00586    fMenuView->AddEntry("&Undock", M_VIEW_UNDOCK);
00587    fMenuView->AddSeparator();
00588    fMenuView->AddEntry("Enable U&ndock", M_VIEW_ENBL_DOCK);
00589    fMenuView->AddEntry("Enable &Hide", M_VIEW_ENBL_HIDE);
00590    fMenuView->DisableEntry(M_VIEW_DOCK);
00591 
00592    fMenuDock->EnableUndock(kTRUE);
00593    fMenuDock->EnableHide(kTRUE);
00594    fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
00595    fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
00596 
00597    fMenuHelp = new TGPopupMenu(fClient->GetRoot());
00598    fMenuHelp->AddEntry("&Contents", M_HELP_CONTENTS);
00599    fMenuHelp->AddEntry("&Search...", M_HELP_SEARCH);
00600    fMenuHelp->AddSeparator();
00601    fMenuHelp->AddEntry("&About", M_HELP_ABOUT);
00602 
00603    fMenuNew1 = new TGPopupMenu();
00604    fMenuNew1->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
00605 
00606    fMenuNew2 = new TGPopupMenu();
00607    fMenuNew2->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
00608 
00609    // Menu button messages are handled by the main frame (i.e. "this")
00610    // ProcessMessage() method.
00611    fMenuFile->Associate(this);
00612    fMenuTest->Associate(this);
00613    fMenuView->Associate(this);
00614    fMenuHelp->Associate(this);
00615    fCascadeMenu->Associate(this);
00616    fCascade1Menu->Associate(this);
00617    fCascade2Menu->Associate(this);
00618    fMenuNew1->Associate(this);
00619    fMenuNew2->Associate(this);
00620 
00621    fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame);
00622    fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
00623    fMenuBar->AddPopup("&Test", fMenuTest, fMenuBarItemLayout);
00624    fMenuBar->AddPopup("&View", fMenuView, fMenuBarItemLayout);
00625    fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
00626 
00627    fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
00628 
00629    // Create TGCanvas and a canvas container which uses a tile layout manager
00630    fCanvasWindow = new TGCanvas(this, 400, 240);
00631    fContainer = new TileFrame(fCanvasWindow->GetViewPort());
00632    fContainer->SetCanvas(fCanvasWindow);
00633    fCanvasWindow->SetContainer(fContainer);
00634 
00635    // use hierarchical cleaning for container
00636    fContainer->SetCleanup(kDeepCleanup);
00637 
00638    // Fill canvas with 256 colored frames
00639    for (int i=0; i < 256; ++i)
00640       fCanvasWindow->AddFrame(new TGFrame(fCanvasWindow->GetContainer(),
00641                               32, 32, 0, TColor::RGB2Pixel(0,0,(i+1)&255)),
00642                               new TGLayoutHints(kLHintsExpandY | kLHintsRight));
00643 
00644    AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
00645                                              0, 0, 2, 2));
00646 
00647    // Create status frame containing a button and a text entry widget
00648    fStatusFrame = new TGCompositeFrame(this, 60, 20, kHorizontalFrame |
00649                                                      kSunkenFrame);
00650 
00651    fTestButton = new TGTextButton(fStatusFrame, "&Open editor...", 150);
00652    fTestButton->Associate(this);
00653    fTestButton->SetToolTipText("Pops up\ntext editor");
00654    fStatusFrame->AddFrame(fTestButton, new TGLayoutHints(kLHintsTop |
00655                           kLHintsLeft, 2, 0, 2, 2));
00656    fTestText = new TGTextEntry(fStatusFrame, new TGTextBuffer(100));
00657    fTestText->SetToolTipText("This is a text entry widget");
00658    fTestText->Resize(300, fTestText->GetDefaultHeight());
00659    fStatusFrame->AddFrame(fTestText, new TGLayoutHints(kLHintsTop | kLHintsLeft,
00660                                                        10, 2, 2, 2));
00661    Pixel_t yellow;
00662    fClient->GetColorByName("yellow", yellow);
00663    fColorSel = new TGColorSelect(fStatusFrame, yellow, ColorSel);
00664    fStatusFrame->AddFrame(fColorSel, new TGLayoutHints(kLHintsTop |
00665                           kLHintsLeft, 2, 0, 2, 2));
00666 
00667    AddFrame(fStatusFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
00668             0, 0, 1, 0));
00669 
00670    SetWindowName("GuiTest");
00671    MapSubwindows();
00672 
00673    // we need to use GetDefault...() to initialize the layout algorithm...
00674    Resize();   // resize to default size
00675    MapWindow();
00676    Print();
00677 }
00678 
00679 TestMainFrame::~TestMainFrame()
00680 {
00681    // Delete all created widgets.
00682 
00683    delete fMenuFile;
00684    delete fMenuTest;
00685    delete fMenuView;
00686    delete fMenuHelp;
00687    delete fCascadeMenu;
00688    delete fCascade1Menu;
00689    delete fCascade2Menu;
00690    delete fMenuNew1;
00691    delete fMenuNew2;
00692    delete fContainer;
00693 }
00694 
00695 void TestMainFrame::CloseWindow()
00696 {
00697    // Got close message for this MainFrame. Terminate the application
00698    // or returns from the TApplication event loop (depending on the
00699    // argument specified in TApplication::Run()).
00700 
00701    gApplication->Terminate(0);
00702 }
00703 
00704 Bool_t TestMainFrame::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
00705 {
00706    // Handle messages send to the TestMainFrame object. E.g. all menu button
00707    // messages.
00708 
00709    switch (GET_MSG(msg)) {
00710 
00711       case kC_COMMAND:
00712          switch (GET_SUBMSG(msg)) {
00713 
00714             case kCM_BUTTON:
00715                //printf("Button was pressed, id = %ld\n", parm1);
00716                if (parm1 == 150) {
00717                   Editor *ed = new Editor(this, 600, 400);
00718                   ed->LoadBuffer(editortxt);
00719                   ed->Popup();
00720                }
00721               break;
00722 
00723             case kCM_MENUSELECT:
00724                //printf("Pointer over menu entry, id=%ld\n", parm1);
00725                break;
00726 
00727             case kCM_MENU:
00728                switch (parm1) {
00729 
00730                   case M_FILE_OPEN:
00731                      {
00732                         static TString dir(".");
00733                         TGFileInfo fi;
00734                         fi.fFileTypes = filetypes;
00735                         fi.fIniDir    = StrDup(dir);
00736                         new TGFileDialog(fClient->GetRoot(), this, kFDOpen, &fi);
00737                         printf("Open file: %s (dir: %s)\n", fi.fFilename,
00738                                fi.fIniDir);
00739                         dir = fi.fIniDir;
00740                      }
00741                      break;
00742 
00743                   case M_FILE_SAVE:
00744                      printf("M_FILE_SAVE\n");
00745                      break;
00746 
00747                   case M_FILE_PRINT:
00748                      printf("M_FILE_PRINT\n");
00749                      printf("Hiding itself, select \"Print Setup...\" to enable again\n");
00750                      fMenuFile->HideEntry(M_FILE_PRINT);
00751                      break;
00752 
00753                   case M_FILE_PRINTSETUP:
00754                      printf("M_FILE_PRINTSETUP\n");
00755                      printf("Enabling \"Print\"\n");
00756                      fMenuFile->EnableEntry(M_FILE_PRINT);
00757                      break;
00758 
00759                   case M_FILE_EXIT:
00760                      CloseWindow();   // this also terminates theApp
00761                      break;
00762 
00763                   case M_TEST_DLG:
00764                      new TestDialog(fClient->GetRoot(), this, 400, 200);
00765                      break;
00766 
00767                   case M_TEST_MSGBOX:
00768                      new TestMsgBox(fClient->GetRoot(), this, 400, 200);
00769                      break;
00770 
00771                   case M_TEST_SLIDER:
00772                      new TestSliders(fClient->GetRoot(), this, 400, 200);
00773                      break;
00774 
00775                   case M_TEST_SHUTTER:
00776                      new TestShutter(fClient->GetRoot(), this, 400, 200);
00777                      break;
00778 
00779                   case M_TEST_DIRLIST:
00780                      new TestDirList(gClient->GetRoot(), this, 400, 200);
00781                      break;
00782 
00783                   case M_TEST_FILELIST:
00784                      new TestFileList(gClient->GetRoot(), this, 400, 200);
00785                      break;
00786 
00787                   case M_TEST_PROGRESS:
00788                      new TestProgress(fClient->GetRoot(), this, 600, 300);
00789                      break;
00790 
00791                   case M_TEST_NUMBERENTRY:
00792                      new EntryTestDlg(fClient->GetRoot(), this);
00793                      break;
00794 
00795                   case M_TEST_FONTDIALOG:
00796                      {
00797                         TGFontDialog::FontProp_t prop;
00798                         new TGFontDialog(fClient->GetRoot(), this, &prop);
00799                         if (prop.fName != "")
00800                            printf("Selected font: %s, size %d, italic %s, bold %s, color 0x%lx, align %u\n",
00801                                   prop.fName.Data(), prop.fSize, prop.fItalic ? "yes" : "no",
00802                                   prop.fBold ? "yes" : "no", prop.fColor, prop.fAlign);
00803                      }
00804                      break;
00805 
00806                   case M_TEST_NEWMENU:
00807                      {
00808                         if (fMenuTest->IsEntryChecked(M_TEST_NEWMENU)) {
00809                            ProcessMessage(MK_MSG(kC_COMMAND, kCM_MENU),
00810                                           M_NEW_REMOVEMENU, 0);
00811                            return kTRUE;
00812                         }
00813                         fMenuTest->CheckEntry(M_TEST_NEWMENU);
00814                         TGPopupMenu *p = fMenuBar->GetPopup("Test");
00815                         fMenuBar->AddPopup("New 1", fMenuNew1, fMenuBarItemLayout, p);
00816                         p = fMenuBar->GetPopup("Help");
00817                         fMenuBar->AddPopup("New 2", fMenuNew2, fMenuBarItemLayout, p);
00818                         fMenuBar->MapSubwindows();
00819                         fMenuBar->Layout();
00820 
00821                         TGMenuEntry *e = fMenuTest->GetEntry("Add New Menus");
00822                         fMenuTest->AddEntry("Remove New Menus", M_NEW_REMOVEMENU, 0, 0, e);
00823                      }
00824                      break;
00825 
00826                   case M_NEW_REMOVEMENU:
00827                      {
00828                         fMenuBar->RemovePopup("New 1");
00829                         fMenuBar->RemovePopup("New 2");
00830                         fMenuBar->Layout();
00831                         fMenuTest->DeleteEntry(M_NEW_REMOVEMENU);
00832                         fMenuTest->UnCheckEntry(M_TEST_NEWMENU);
00833                      }
00834                      break;
00835 
00836                   case M_VIEW_ENBL_DOCK:
00837                      fMenuDock->EnableUndock(!fMenuDock->EnableUndock());
00838                      if (fMenuDock->EnableUndock()) {
00839                         fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
00840                         fMenuView->EnableEntry(M_VIEW_UNDOCK);
00841                      } else {
00842                         fMenuView->UnCheckEntry(M_VIEW_ENBL_DOCK);
00843                         fMenuView->DisableEntry(M_VIEW_UNDOCK);
00844                      }
00845                      break;
00846 
00847                   case M_VIEW_ENBL_HIDE:
00848                      fMenuDock->EnableHide(!fMenuDock->EnableHide());
00849                      if (fMenuDock->EnableHide()) {
00850                         fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
00851                      } else {
00852                         fMenuView->UnCheckEntry(M_VIEW_ENBL_HIDE);
00853                      }
00854                      break;
00855 
00856                   case M_VIEW_DOCK:
00857                      fMenuDock->DockContainer();
00858                      fMenuView->EnableEntry(M_VIEW_UNDOCK);
00859                      fMenuView->DisableEntry(M_VIEW_DOCK);
00860                      break;
00861 
00862                   case M_VIEW_UNDOCK:
00863                      fMenuDock->UndockContainer();
00864                      fMenuView->EnableEntry(M_VIEW_DOCK);
00865                      fMenuView->DisableEntry(M_VIEW_UNDOCK);
00866                      break;
00867 
00868                   default:
00869                      break;
00870                }
00871             default:
00872                break;
00873          }
00874       default:
00875          break;
00876    }
00877 
00878    if (fMenuDock->IsUndocked()) {
00879       fMenuView->EnableEntry(M_VIEW_DOCK);
00880       fMenuView->DisableEntry(M_VIEW_UNDOCK);
00881    } else {
00882       fMenuView->EnableEntry(M_VIEW_UNDOCK);
00883       fMenuView->DisableEntry(M_VIEW_DOCK);
00884    }
00885 
00886    return kTRUE;
00887 }
00888 
00889 TestDialog::TestDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
00890                        UInt_t h, UInt_t options)
00891     : TGTransientFrame(p, main, w, h, options)
00892 {
00893    // Create a dialog window. A dialog window pops up with respect to its
00894    // "main" window.
00895 
00896    // use hierarchical cleani
00897    SetCleanup(kDeepCleanup);
00898 
00899    fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
00900 
00901    fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
00902    fOkButton->Associate(this);
00903    fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
00904    fCancelButton->Associate(this);
00905 
00906    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
00907                            2, 2, 2, 2);
00908    fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
00909 
00910    fFrame1->AddFrame(fOkButton, fL1);
00911    fFrame1->AddFrame(fCancelButton, fL1);
00912 
00913    fFrame1->Resize(150, fOkButton->GetDefaultHeight());
00914    AddFrame(fFrame1, fL2);
00915 
00916    //--------- create Tab widget and some composite frames for Tab testing
00917 
00918    fTab = new TGTab(this, 300, 300);
00919    fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
00920 
00921    TGCompositeFrame *tf = fTab->AddTab("Tab 1");
00922    fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
00923    fF1->AddFrame(new TGTextButton(fF1, "&Test button", 0), fL3);
00924    fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
00925    fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
00926    tf->AddFrame(fF1, fL3);
00927    fTxt1->Resize(150, fTxt1->GetDefaultHeight());
00928    fTxt2->Resize(150, fTxt2->GetDefaultHeight());
00929 
00930    tf = fTab->AddTab("Tab 2");
00931    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
00932                            200, 2, 2, 2);
00933    fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
00934    fF2->AddFrame(fBtn1 = new TGTextButton(fF2, "&Button 1", 0), fL1);
00935    fF2->AddFrame(fBtn2 = new TGTextButton(fF2, "B&utton 2", 0), fL1);
00936    fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "C&heck 1", 0), fL1);
00937    fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Chec&k 2", 0), fL1);
00938    fF2->AddFrame(fRad1 = new TGRadioButton(fF2, "&Radio 1", 81), fL1);
00939    fF2->AddFrame(fRad2 = new TGRadioButton(fF2, "R&adio 2", 82), fL1);
00940    fCombo = new TGComboBox(fF2, 88);
00941    fF2->AddFrame(fCombo, fL3);
00942 
00943    tf->AddFrame(fF2, fL3);
00944 
00945    int i;
00946    for (i = 0; i < 20; i++) {
00947       char tmp[20];
00948 
00949       sprintf(tmp, "Entry %i", i+1);
00950       fCombo->AddEntry(tmp, i+1);
00951    }
00952 
00953    fCombo->Resize(150, 20);
00954 
00955    fBtn1->Associate(this);
00956    fBtn2->Associate(this);
00957    fChk1->Associate(this);
00958    fChk2->Associate(this);
00959    fRad1->Associate(this);
00960    fRad2->Associate(this);
00961 
00962    //-------------- embedded canvas demo
00963    fFillHistos = kFALSE;
00964    fHpx   = 0;
00965    fHpxpy = 0;
00966 
00967    tf = fTab->AddTab("Tab 3");
00968    fF3 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
00969    fStartB = new TGTextButton(fF3, "Start &Filling Hists", 40);
00970    fStopB  = new TGTextButton(fF3, "&Stop Filling Hists", 41);
00971    fStartB->Associate(this);
00972    fStopB->Associate(this);
00973    fF3->AddFrame(fStartB, fL3);
00974    fF3->AddFrame(fStopB, fL3);
00975 
00976    fF5 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
00977 
00978    fL4 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
00979                            kLHintsExpandY, 5, 5, 5, 5);
00980    fEc1 = new TRootEmbeddedCanvas("ec1", fF5, 100, 100);
00981    fF5->AddFrame(fEc1, fL4);
00982    fEc2 = new TRootEmbeddedCanvas("ec2", fF5, 100, 100);
00983    fF5->AddFrame(fEc2, fL4);
00984 
00985    tf->AddFrame(fF3, fL3);
00986    tf->AddFrame(fF5, fL4);
00987 
00988    fEc1->GetCanvas()->SetBorderMode(0);
00989    fEc2->GetCanvas()->SetBorderMode(0);
00990 
00991    // make tab yellow
00992    Pixel_t yellow;
00993    fClient->GetColorByName("yellow", yellow);
00994    TGTabElement *tabel = fTab->GetTabTab("Tab 3");;
00995    tabel->ChangeBackground(yellow);
00996 
00997    //-------------- end embedded canvas demo
00998 
00999    TGTextButton *bt;
01000    tf = fTab->AddTab("Tab 4");
01001    fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
01002    fF4->AddFrame(bt = new TGTextButton(fF4, "A&dd Entry", 90), fL3);
01003    bt->Associate(this);
01004 
01005    fF4->AddFrame(bt = new TGTextButton(fF4, "Remove &Entry", 91), fL3);
01006    bt->Associate(this);
01007 
01008    fF4->AddFrame(fListBox = new TGListBox(fF4, 89), fL3);
01009    fF4->AddFrame(fCheckMulti = new TGCheckButton(fF4, "&Mutli Selectable", 92), fL3);
01010    fCheckMulti->Associate(this);
01011    tf->AddFrame(fF4, fL3);
01012 
01013    for (i=0; i < 20; ++i) {
01014       char tmp[20];
01015 
01016       sprintf(tmp, "Entry %i", i);
01017       fListBox->AddEntry(tmp, i);
01018    }
01019    fFirstEntry = 0;
01020    fLastEntry  = 20;
01021 
01022    fListBox->Resize(150, 80);
01023 
01024    //--- tab 5
01025    tf = fTab->AddTab("Tab 5");
01026    tf->SetLayoutManager(new TGHorizontalLayout(tf));
01027 
01028    fF6 = new TGGroupFrame(tf, "Options", kVerticalFrame);
01029    fF6->SetTitlePos(TGGroupFrame::kRight); // right aligned
01030    tf->AddFrame(fF6, fL3);
01031 
01032    // 2 column, n rows
01033    fF6->SetLayoutManager(new TGMatrixLayout(fF6, 0, 2, 10));
01034    char buff[100];
01035    int j;
01036    for (j = 0; j < 4; j++) {
01037       sprintf(buff, "Module %i", j+1);
01038       fF6->AddFrame(new TGLabel(fF6, new TGHotString(buff)));
01039 
01040       TGTextBuffer *tbuf = new TGTextBuffer(10);
01041       tbuf->AddText(0, "0.0");
01042 
01043       TGTextEntry  *tent = new TGTextEntry(fF6, tbuf);
01044       tent->Resize(50, tent->GetDefaultHeight());
01045       tent->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
01046 
01047       fF6->AddFrame(tent);
01048    }
01049    fF6->Resize(); // resize to default size
01050 
01051    // another matrix with text and buttons
01052    fF7 = new TGGroupFrame(tf, "Tab Handling", kVerticalFrame);
01053    tf->AddFrame(fF7, fL3);
01054 
01055    fF7->SetLayoutManager(new TGMatrixLayout(fF7, 0, 1, 10));
01056 
01057    fF7->AddFrame(bt = new TGTextButton(fF7, "Remove Tab", 101));
01058    bt->Associate(this);
01059    bt->Resize(90, bt->GetDefaultHeight());
01060 
01061    fF7->AddFrame(bt = new TGTextButton(fF7, "Add Tab", 103));
01062    bt->Associate(this);
01063    bt->Resize(90, bt->GetDefaultHeight());
01064 
01065    fF7->AddFrame(bt = new TGTextButton(fF7, "Remove Tab 5", 102));
01066    bt->Associate(this);
01067    bt->Resize(90, bt->GetDefaultHeight());
01068 
01069    fF7->Resize(fF6->GetDefaultSize());
01070 
01071    //--- end of last tab
01072 
01073    TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
01074                                           kLHintsExpandY, 2, 2, 5, 1);
01075    AddFrame(fTab, fL5);
01076 
01077    MapSubwindows();
01078    Resize();   // resize to default size
01079 
01080    // position relative to the parent's window
01081    CenterOnParent();
01082 
01083    SetWindowName("Dialog");
01084 
01085    MapWindow();
01086    //fClient->WaitFor(this);    // otherwise canvas contextmenu does not work
01087 }
01088 
01089 TestDialog::~TestDialog()
01090 {
01091    // Delete test dialog widgets.
01092 
01093 }
01094 
01095 void TestDialog::FillHistos()
01096 {
01097    // Fill histograms till user clicks "Stop Filling" button.
01098 
01099    static int cnt;
01100 
01101    if (!fHpx) {
01102       fHpx   = new TH1F("hpx","This is the px distribution",100,-4,4);
01103       fHpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
01104       fHpx->SetFillColor(kRed);
01105       cnt = 0;
01106    }
01107 
01108    const int kUPDATE = 1000;
01109    float px, py;
01110    TCanvas *c1 = fEc1->GetCanvas();
01111    TCanvas *c2 = fEc2->GetCanvas();
01112 
01113    while (fFillHistos) {
01114       gRandom->Rannor(px,py); //px and py will be two gaussian random numbers
01115       fHpx->Fill(px);
01116       fHpxpy->Fill(px,py);
01117       cnt++;
01118       if (!(cnt % kUPDATE)) {
01119          if (cnt == kUPDATE) {
01120             c1->cd();
01121             fHpx->Draw();
01122             c2->cd();
01123             fHpxpy->Draw("cont");
01124          }
01125          c1->Modified();
01126          c1->Update();
01127          c2->Modified();
01128          c2->Update();
01129          gSystem->ProcessEvents();  // handle GUI events
01130       }
01131    }
01132 }
01133 
01134 void TestDialog::CloseWindow()
01135 {
01136    // Called when window is closed (via the window manager or not).
01137    // Let's stop histogram filling...
01138    fFillHistos = kFALSE;
01139    // Add protection against double-clicks
01140    fOkButton->SetState(kButtonDisabled);
01141    fCancelButton->SetState(kButtonDisabled);
01142    // ... and close the Ged editor if it was activated.
01143    if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
01144       TVirtualPadEditor::Terminate();
01145    DeleteWindow();
01146 }
01147 
01148 Bool_t TestDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
01149 {
01150    // Process messages coming from widgets associated with the dialog.
01151 
01152    char tmp[20];
01153    static int newtab = 0;
01154 
01155    switch (GET_MSG(msg)) {
01156       case kC_COMMAND:
01157 
01158          switch (GET_SUBMSG(msg)) {
01159             case kCM_BUTTON:
01160                switch(parm1) {
01161                   case 1:
01162                   case 2:
01163                      printf("\nTerminating dialog: %s pressed\n",
01164                             (parm1 == 1) ? "OK" : "Cancel");
01165                      CloseWindow();
01166                      break;
01167                   case 40:  // start histogram filling
01168                      fFillHistos = kTRUE;
01169                      FillHistos();
01170                      break;
01171                   case 41:  // stop histogram filling
01172                      fFillHistos = kFALSE;
01173                      break;
01174                   case 90:  // add one entry in list box
01175                      fLastEntry++;
01176                      sprintf(tmp, "Entry %i", fLastEntry);
01177                      fListBox->AddEntry(tmp, fLastEntry);
01178                      fListBox->MapSubwindows();
01179                      fListBox->Layout();
01180                      break;
01181                   case 91:  // remove one entry in list box
01182                      if (fFirstEntry <= fLastEntry) {
01183                         fListBox->RemoveEntry(fFirstEntry);
01184                         fListBox->Layout();
01185                         fFirstEntry++;
01186                      }
01187                      break;
01188                   case 101:  // remove tabs
01189                      {
01190                         TString s = fTab->GetTabTab(0)->GetString();
01191                         if ((s == "Tab 3") && (fMain->MustCleanup() != kDeepCleanup)) {
01192                            // Need to delete the embedded canvases
01193                            // since RemoveTab() will Destroy the container
01194                            // window, which in turn will destroy the embedded
01195                            // canvas windows.
01196                            SafeDelete(fEc1);
01197                            SafeDelete(fEc2);
01198                         }
01199                         fTab->RemoveTab(0);
01200                         fTab->Layout();
01201                      }
01202                      break;
01203                   case 102:  // remove tab 5
01204                      {
01205                         int nt = fTab->GetNumberOfTabs();
01206                         for (int i = 0 ; i < nt; i++) {
01207                            TString s = fTab->GetTabTab(i)->GetString();
01208                            if (s == "Tab 5") {
01209                               fTab->RemoveTab(i);
01210                               fTab->Layout();
01211                               break;
01212                            }
01213                         }
01214                      }
01215                      break;
01216                   case 103:  // add tabs
01217                      sprintf(tmp, "New Tab %d", ++newtab);
01218                      fTab->AddTab(tmp);
01219                      fTab->MapSubwindows();
01220                      fTab->Layout();
01221                      break;
01222                   default:
01223                      break;
01224                }
01225                break;
01226             case kCM_RADIOBUTTON:
01227                switch (parm1) {
01228                   case 81:
01229                      fRad2->SetState(kButtonUp);
01230                      break;
01231                   case 82:
01232                      fRad1->SetState(kButtonUp);
01233                      break;
01234                }
01235                break;
01236             case kCM_CHECKBUTTON:
01237                switch (parm1) {
01238                   case 92:
01239                      fListBox->SetMultipleSelections(fCheckMulti->GetState());
01240                      break;
01241                   default:
01242                      break;
01243                }
01244                break;
01245             case kCM_TAB:
01246                printf("Tab item %ld activated\n", parm1);
01247                break;
01248             default:
01249                break;
01250          }
01251          break;
01252 
01253       default:
01254          break;
01255    }
01256    return kTRUE;
01257 }
01258 
01259 TestMsgBox::TestMsgBox(const TGWindow *p, const TGWindow *main,
01260                        UInt_t w, UInt_t h, UInt_t options) :
01261      TGTransientFrame(p, main, w, h, options),
01262      fRedTextGC(TGButton::GetDefaultGC())
01263 {
01264    // Create message box test dialog. Use this dialog to select the different
01265    // message dialog box styles and show the message dialog by clicking the
01266    // "Test" button.
01267 
01268    // use hierarchical cleani
01269    SetCleanup(kDeepCleanup);
01270 
01271    //------------------------------
01272    // Set foreground color in graphics context for drawing of
01273    // TGlabel and TGButtons with text in red.
01274 
01275    Pixel_t red;
01276    fClient->GetColorByName("red", red);
01277    fRedTextGC.SetForeground(red);
01278    //---------------------------------
01279 
01280    int i;
01281 
01282    ChangeOptions((GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
01283 
01284    f1 = new TGCompositeFrame(this, 60, 20, kVerticalFrame | kFixedWidth);
01285    f2 = new TGCompositeFrame(this, 60, 20, kVerticalFrame);
01286    f3 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01287    f4 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01288    f5 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
01289 
01290    fTestButton = new TGTextButton(f1, "&Test", 1, fRedTextGC());
01291 
01292    // Change background of fTestButton to green
01293    Pixel_t green;
01294    fClient->GetColorByName("green", green);
01295    fTestButton->ChangeBackground(green);
01296 
01297    fCloseButton = new TGTextButton(f1, "&Close", 2);
01298    fPictButton = new TGPictureButton(f1, fClient->GetPicture("mb_stop_s.xpm"));
01299 
01300    f1->Resize(fTestButton->GetDefaultWidth()+40, GetDefaultHeight());
01301 
01302    fTestButton->Associate(this);
01303    fCloseButton->Associate(this);
01304    fPictButton->Associate(this);
01305 
01306    fL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandX,
01307                            2, 2, 3, 0);
01308    fL2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX,
01309                            2, 5, 0, 2);
01310    fL21 = new TGLayoutHints(kLHintsTop | kLHintsRight,
01311                             2, 5, 10, 0);
01312 
01313    f1->AddFrame(fTestButton, fL1);
01314    f1->AddFrame(fCloseButton, fL1);
01315    f1->AddFrame(fPictButton, fL1);
01316    AddFrame(f1, fL21);
01317 
01318    //--------- create check and radio buttons groups
01319 
01320    fG1 = new TGGroupFrame(f3, new TGString("Buttons"),kVerticalFrame|kRaisedFrame);
01321    fG2 = new TGGroupFrame(f3, new TGString("Icons"),kVerticalFrame|kRaisedFrame);
01322 
01323    fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft |
01324                            kLHintsExpandX | kLHintsExpandY,
01325                            2, 2, 2, 2);
01326    fL4 = new TGLayoutHints(kLHintsTop | kLHintsLeft,
01327                            0, 0, 5, 0);
01328 
01329    fC[0]  = new TGCheckButton(fG1, new TGHotString("Yes"),        -1);
01330    fC[1]  = new TGCheckButton(fG1, new TGHotString("No"),         -1);
01331    fC[2]  = new TGCheckButton(fG1, new TGHotString("OK"),         -1);
01332    fC[3]  = new TGCheckButton(fG1, new TGHotString("Apply"),      -1);
01333    fC[4]  = new TGCheckButton(fG1, new TGHotString("Retry"),      -1);
01334    fC[5]  = new TGCheckButton(fG1, new TGHotString("Ignore"),     -1);
01335    fC[6]  = new TGCheckButton(fG1, new TGHotString("Cancel"),     -1);
01336    fC[7]  = new TGCheckButton(fG1, new TGHotString("Close"),      -1);
01337    fC[8]  = new TGCheckButton(fG1, new TGHotString("Yes to All"), -1);
01338    fC[9]  = new TGCheckButton(fG1, new TGHotString("No to All"),  -1);
01339    fC[10] = new TGCheckButton(fG1, new TGHotString("Newer Only"), -1);
01340    fC[11] = new TGCheckButton(fG1, new TGHotString("Append"),     -1);
01341    fC[12] = new TGCheckButton(fG1, new TGHotString("Dismiss"),    -1);
01342 
01343    for (i=0; i<13; ++i) fG1->AddFrame(fC[i], fL4);
01344 
01345    fR[0] = new TGRadioButton(fG2, new TGHotString("Stop"),        21);
01346    fR[1] = new TGRadioButton(fG2, new TGHotString("Question"),    22);
01347    fR[2] = new TGRadioButton(fG2, new TGHotString("Exclamation"), 23);
01348    fR[3] = new TGRadioButton(fG2, new TGHotString("Asterisk"),    24);
01349 
01350    for (i = 0; i < 4; ++i) {
01351       fG2->AddFrame(fR[i], fL4);
01352       fR[i]->Associate(this);
01353    }
01354 
01355    fC[2]->SetState(kButtonDown);
01356    fR[0]->SetState(kButtonDown);
01357 
01358    f3->AddFrame(fG1, fL3);
01359    f3->AddFrame(fG2, fL3);
01360 
01361    fLtitle = new TGLabel(f4, new TGString("Title:"), fRedTextGC());
01362    fLmsg   = new TGLabel(f5, new TGString("Message:"));
01363 
01364    fTitle = new TGTextEntry(f4, fTbtitle = new TGTextBuffer(100));
01365    fMsg   = new TGTextEntry(f5, fTbmsg = new TGTextBuffer(100));
01366 
01367    fTbtitle->AddText(0, "MsgBox");
01368    fTbmsg->AddText(0, "This is a test message box.");
01369 
01370    fTitle->Resize(300, fTitle->GetDefaultHeight());
01371    fMsg->Resize(300, fMsg->GetDefaultHeight());
01372 
01373    fL5 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
01374                            3, 5, 0, 0);
01375    fL6 = new TGLayoutHints(kLHintsRight | kLHintsCenterY,
01376                            0, 2, 0, 0);
01377 
01378    f4->AddFrame(fLtitle, fL5);
01379    f4->AddFrame(fTitle, fL6);
01380    f5->AddFrame(fLmsg, fL5);
01381    f5->AddFrame(fMsg, fL6);
01382 
01383    f2->AddFrame(f3, fL1);
01384    f2->AddFrame(f4, fL1);
01385    f2->AddFrame(f5, fL1);
01386 
01387    AddFrame(f2, fL2);
01388 
01389    MapSubwindows();
01390    Resize();   // resize to default size
01391 
01392    // position relative to the parent's window
01393    CenterOnParent();
01394 
01395    SetWindowName("Message Box Test");
01396 
01397    MapWindow();
01398    fClient->WaitFor(this);
01399 }
01400 
01401 // Order is important when deleting frames. Delete children first,
01402 // parents last.
01403 
01404 TestMsgBox::~TestMsgBox()
01405 {
01406    // Delete widgets created by dialog.
01407 
01408 }
01409 
01410 void TestMsgBox::CloseWindow()
01411 {
01412    // Close dialog in response to window manager close.
01413 
01414    DeleteWindow();
01415 }
01416 
01417 Bool_t TestMsgBox::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
01418 {
01419    // Process messages sent to this dialog.
01420 
01421    int i, buttons, retval;
01422    EMsgBoxIcon icontype = kMBIconStop;
01423 
01424    switch(GET_MSG(msg)) {
01425       case kC_COMMAND:
01426 
01427          switch(GET_SUBMSG(msg)) {
01428             case kCM_BUTTON:
01429                switch(parm1) {
01430                   case 1:
01431                      buttons = 0;
01432                      for (i=0; i<13; ++i)
01433                         if (fC[i]->GetState() == kButtonDown)
01434                            buttons |= mb_button_id[i];
01435 
01436                      for (i=0; i<4; ++i)
01437                         if (fR[i]->GetState() == kButtonDown)
01438                            { icontype = mb_icon[i]; break; }
01439 
01440                      // Since the message dialog box is created, we disable the
01441                      // window manager close mechanism, in order to ensure we
01442                      // can't close the fMain window while the MessageBox is open.
01443                      SetBit(kDontCallClose);
01444                      new TGMsgBox(fClient->GetRoot(), this,
01445                                   fTbtitle->GetString(), fTbmsg->GetString(),
01446                                   icontype, buttons, &retval);
01447                      ResetBit(kDontCallClose);
01448                      break;
01449 
01450                   case 2:
01451                      CloseWindow();
01452                      break;
01453 
01454                }
01455                break;
01456 
01457             case kCM_RADIOBUTTON:
01458             case kCM_CHECKBUTTON:
01459                if (parm1 >= 21 && parm1 <= 24) {
01460                   for (i=0; i<4; ++i)
01461                      if (fR[i]->WidgetId() != parm1)
01462                         fR[i]->SetState(kButtonUp);
01463                }
01464                break;
01465 
01466             default:
01467                break;
01468          }
01469          break;
01470 
01471       default:
01472          break;
01473    }
01474 
01475    return kTRUE;
01476 }
01477 
01478 TestSliders::TestSliders(const TGWindow *p, const TGWindow *main,
01479                          UInt_t w, UInt_t h) :
01480     TGTransientFrame(p, main, w, h)
01481 {
01482    // Dialog used to test the different supported sliders.
01483 
01484    // use hierarchical cleani
01485    SetCleanup(kDeepCleanup);
01486 
01487    ChangeOptions((GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
01488 
01489    fVframe1 = new TGVerticalFrame(this, 0, 0, 0);
01490 
01491    fTeh1 = new TGTextEntry(fVframe1, fTbh1 = new TGTextBuffer(10), HId1);
01492    fTev1 = new TGTextEntry(fVframe1, fTbv1 = new TGTextBuffer(10), VId1);
01493    fTbh1->AddText(0, "0");
01494    fTbv1->AddText(0, "0");
01495 
01496    fTeh1->Associate(this);
01497    fTev1->Associate(this);
01498 
01499    fHslider1 = new TGHSlider(fVframe1, 100, kSlider1 | kScaleBoth, HSId1);
01500    fHslider1->Associate(this);
01501    fHslider1->SetRange(0,50);
01502 
01503    fVslider1 = new TGVSlider(fVframe1, 100, kSlider2 | kScaleBoth, VSId1);
01504    fVslider1->Associate(this);
01505    fVslider1->SetRange(0,8);
01506 
01507    fVframe1->Resize(100, 100);
01508 
01509    fVframe2 = new TGVerticalFrame(this, 0, 0, 0);
01510    fTeh2 = new TGTextEntry(fVframe2, fTbh2 = new TGTextBuffer(10), HId2);
01511    fTev2 = new TGTextEntry(fVframe2, fTbv2 = new TGTextBuffer(10), VId2);
01512    fTbh2->AddText(0, "0");
01513    fTbv2->AddText(0, "0");
01514 
01515    fTeh2->Associate(this);
01516    fTev2->Associate(this);
01517 
01518    fHslider2 = new TGHSlider(fVframe2, 150, kSlider2 | kScaleBoth, HSId2);
01519    fHslider2->Associate(this);
01520    fHslider2->SetRange(0,3);
01521 
01522    fVslider2 = new TGDoubleVSlider(fVframe2, 100, kDoubleScaleBoth, VSId2);
01523    fVslider2->Associate(this);
01524    fVslider2->SetRange(-10,10);
01525 
01526    fVframe2->Resize(100, 100);
01527 
01528    //--- layout for buttons: top align, equally expand horizontally
01529    fBly = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 3, 0);
01530 
01531    //--- layout for the frame: place at bottom, right aligned
01532    fBfly1 = new TGLayoutHints(kLHintsTop | kLHintsRight, 20, 10, 15, 0);
01533 
01534    fVframe1->AddFrame(fHslider1, fBly);
01535    fVframe1->AddFrame(fVslider1, fBly);
01536    fVframe1->AddFrame(fTeh1, fBly);
01537    fVframe1->AddFrame(fTev1, fBly);
01538 
01539    fVframe2->AddFrame(fHslider2, fBly);
01540    fVframe2->AddFrame(fVslider2, fBly);
01541    fVframe2->AddFrame(fTeh2, fBly);
01542    fVframe2->AddFrame(fTev2, fBly);
01543 
01544    AddFrame(fVframe2, fBfly1);
01545    AddFrame(fVframe1, fBfly1);
01546 
01547    SetWindowName("Slider Test");
01548    TGDimension size = GetDefaultSize();
01549    Resize(size);
01550 
01551    SetWMSize(size.fWidth, size.fHeight);
01552    SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
01553    SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
01554                               kMWMDecorMinimize | kMWMDecorMenu,
01555                kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
01556                               kMWMFuncMinimize,
01557                kMWMInputModeless);
01558 
01559    // position relative to the parent's window
01560    CenterOnParent();
01561 
01562    MapSubwindows();
01563    MapWindow();
01564 
01565    fClient->WaitFor(this);
01566 }
01567 
01568 TestSliders::~TestSliders()
01569 {
01570    // Delete dialog.
01571 
01572 }
01573 
01574 void TestSliders::CloseWindow()
01575 {
01576    // Called when window is closed via the window manager.
01577 
01578    DeleteWindow();
01579 }
01580 
01581 Bool_t TestSliders::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
01582 {
01583    // Process slider messages.
01584 
01585    char buf[10];
01586 
01587    switch (GET_MSG(msg)) {
01588       case kC_TEXTENTRY:
01589          switch (GET_SUBMSG(msg)) {
01590             case kTE_TEXTCHANGED:
01591                switch (parm1) {
01592                   case HId1:
01593                      fHslider1->SetPosition(atoi(fTbh1->GetString()));
01594                      break;
01595                   case VId1:
01596                      fVslider1->SetPosition(atoi(fTbv1->GetString()));
01597                      break;
01598                   case HId2:
01599                      fHslider2->SetPosition(atoi(fTbh2->GetString()));
01600                      break;
01601                   case VId2:
01602                      fVslider2->SetPosition(atoi(fTbv2->GetString()),
01603                                             atoi(fTbv2->GetString())+2);
01604                      break;
01605                }
01606                break;
01607          }
01608          break;
01609       case kC_VSLIDER:
01610       case kC_HSLIDER:
01611          switch (GET_SUBMSG(msg)) {
01612             case kSL_POS:
01613                sprintf(buf, "%ld", parm2);
01614                switch (parm1) {
01615                   case HSId1:
01616                      fTbh1->Clear();
01617                      fTbh1->AddText(0, buf);
01618                      // Re-align the cursor with the characters.
01619                      fTeh1->SetCursorPosition(fTeh1->GetCursorPosition());
01620                      fTeh1->Deselect();
01621                      fClient->NeedRedraw(fTeh1);
01622                      break;
01623                   case VSId1:
01624                      fTbv1->Clear();
01625                      fTbv1->AddText(0, buf);
01626                      fTev1->SetCursorPosition(fTev1->GetCursorPosition());
01627                      fTev1->Deselect();
01628                      fClient->NeedRedraw(fTev1);
01629                      break;
01630                   case HSId2:
01631                      fTbh2->Clear();
01632                      fTbh2->AddText(0, buf);
01633                      fTeh2->SetCursorPosition(fTeh2->GetCursorPosition());
01634                      fTeh2->Deselect();
01635                      fClient->NeedRedraw(fTeh2);
01636                      break;
01637                   case VSId2:
01638                      sprintf(buf, "%f", fVslider2->GetMinPosition());
01639                      fTbv2->Clear();
01640                      fTbv2->AddText(0, buf);
01641                      fTev2->SetCursorPosition(fTev2->GetCursorPosition());
01642                      fTev2->Deselect();
01643                      fClient->NeedRedraw(fTev2);
01644                      break;
01645                }
01646                break;
01647          }
01648          break;
01649       default:
01650          break;
01651    }
01652    return kTRUE;
01653 }
01654 
01655 TestShutter::TestShutter(const TGWindow *p, const TGWindow *main,
01656                          UInt_t w, UInt_t h) :
01657    TGTransientFrame(p, main, w, h)
01658 {
01659    // Create transient frame containing a shutter widget.
01660 
01661    // use hierarchical cleani
01662    SetCleanup(kDeepCleanup);
01663 
01664    fDefaultPic = fClient->GetPicture("folder_s.xpm");
01665    fShutter = new TGShutter(this, kSunkenFrame);
01666 
01667    AddShutterItem("Histograms", histo_data);
01668    AddShutterItem("Functions", function_data);
01669    AddShutterItem("Trees", tree_data);
01670 
01671    fLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
01672    AddFrame(fShutter, fLayout);
01673 
01674    MapSubwindows();
01675    Resize(80, 300);
01676 
01677    // position relative to the parent's window
01678    CenterOnParent();
01679 
01680    SetWindowName("Shutter Test");
01681 
01682    MapWindow();
01683    //fClient->WaitFor(this);
01684 }
01685 
01686 void TestShutter::AddShutterItem(const char *name, shutterData_t *data)
01687 {
01688    TGShutterItem    *item;
01689    TGCompositeFrame *container;
01690    TGButton         *button;
01691    const TGPicture  *buttonpic;
01692    static int id = 5001;
01693 
01694    TGLayoutHints *l = new TGLayoutHints(kLHintsTop | kLHintsCenterX,
01695                                         5, 5, 5, 0);
01696 
01697    item = new TGShutterItem(fShutter, new TGHotString(name), id++);
01698    container = (TGCompositeFrame *) item->GetContainer();
01699 
01700    for (int i=0; data[i].pixmap_name != 0; i++) {
01701       buttonpic = fClient->GetPicture(data[i].pixmap_name);
01702       if (!buttonpic) {
01703          Warning("AddShutterItem", "missing pixmap \"%s\", using default",
01704                  data[i].pixmap_name);
01705          buttonpic = fDefaultPic;
01706       }
01707 
01708       button = new TGPictureButton(container, buttonpic, data[i].id);
01709 
01710       container->AddFrame(button, l);
01711       button->Associate(this);
01712       button->SetToolTipText(data[i].tip_text);
01713       data[i].button = button;
01714    }
01715 
01716    fShutter->AddItem(item);
01717 }
01718 
01719 TestShutter::~TestShutter()
01720 {
01721    // dtor
01722 }
01723 
01724 void TestShutter::CloseWindow()
01725 {
01726    DeleteWindow();
01727 }
01728 
01729 Bool_t TestShutter::ProcessMessage(Long_t, Long_t parm1, Long_t)
01730 {
01731    // Process messages sent to this dialog.
01732 
01733    printf("Shutter button %d\n", (Int_t)parm1);
01734    return kTRUE;
01735 }
01736 
01737 TestDirList::TestDirList(const TGWindow *p, const TGWindow *main,
01738                          UInt_t w, UInt_t h) : TGTransientFrame(p, main, w, h)
01739 {
01740    // Create transient frame containing a dirlist widget.
01741 
01742    // use hierarchical cleani
01743    SetCleanup(kDeepCleanup);
01744 
01745    TGLayoutHints *lo;
01746    fIcon = gClient->GetPicture("rootdb_t.xpm");
01747 
01748    TGCanvas* canvas = new TGCanvas(this, w, h);
01749    fContents = new TGListTree(canvas, kHorizontalFrame);
01750    fContents->Associate(this);
01751    lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsBottom);
01752    AddFrame(canvas,lo);
01753 
01754 #ifdef WIN32
01755    fContents->AddItem(0,"c:\\");  // browse the upper directory
01756 #else
01757    fContents->AddItem(0,"/");  // browse the upper directory
01758 #endif
01759 
01760    // position relative to the parent's window
01761    CenterOnParent();
01762 
01763    SetWindowName("List Dir Test");
01764    MapSubwindows();
01765    MapWindow();
01766    Resize();
01767 }
01768 
01769 TestDirList::~TestDirList()
01770 {
01771    // dtor.
01772 
01773 }
01774 
01775 TString TestDirList::DirName(TGListTreeItem* item)
01776 {
01777    // returns an absolute path
01778 
01779    TGListTreeItem* parent;
01780    TString dirname = item->GetText();
01781 
01782    while ((parent=item->GetParent())) {
01783       dirname = gSystem->ConcatFileName(parent->GetText(),dirname);
01784       item = parent;
01785    }
01786 
01787    return dirname;
01788 }
01789 
01790 Bool_t TestDirList::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/)
01791 {
01792    // process message sent to this widget.
01793 
01794    TGListTreeItem *item = fContents->GetSelected();
01795 
01796    if ( (GET_MSG(msg)!=kC_LISTTREE) || (parm1!=kButton1) ||
01797         !item || (Bool_t)item->GetUserData()) return kTRUE;
01798 
01799    if ( (GET_SUBMSG(msg)!=kCT_ITEMDBLCLICK) &&
01800         (GET_SUBMSG(msg)!=kCT_ITEMCLICK) ) return kTRUE;
01801 
01802    // use  UserData to indicate that item was already browsed
01803    item->SetUserData((void*)1);
01804 
01805    TSystemDirectory dir(item->GetText(),DirName(item));
01806 
01807    TList *files = dir.GetListOfFiles();
01808 
01809    if (files) {
01810       TIter next(files);
01811       TSystemFile *file;
01812       TString fname;
01813 
01814       while ((file=(TSystemFile*)next())) {
01815          fname = file->GetName();
01816          if (file->IsDirectory()) {
01817             if ((fname!="..") && (fname!=".")) { // skip it
01818                fContents->AddItem(item,fname);
01819             }
01820          } else if (fname.EndsWith(".root")) {   // add root files
01821             fContents->AddItem(item,fname,fIcon,fIcon);
01822          }
01823       }
01824       delete files;
01825    }
01826    return kTRUE;
01827 }
01828 
01829 
01830 
01831 TestFileList::TestFileList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h) :
01832               TGTransientFrame(p, main, w, h)
01833 {
01834    // Create transient frame containing a filelist widget.
01835 
01836    // use hierarchical cleani
01837    SetCleanup(kDeepCleanup);
01838 
01839    TGLayoutHints *lo;
01840 
01841    TGMenuBar* mb = new TGMenuBar(this);
01842    lo = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
01843    AddFrame(mb, lo);
01844 
01845    fMenu = mb->AddPopup("&View");
01846    fMenu->AddEntry("Lar&ge Icons",kLVLargeIcons);
01847    fMenu->AddEntry("S&mall Icons",kLVSmallIcons);
01848    fMenu->AddEntry("&List",       kLVList);
01849    fMenu->AddEntry("&Details",    kLVDetails);
01850    fMenu->AddSeparator();
01851    fMenu->AddEntry("&Close",      10);
01852    fMenu->Associate(this);
01853 
01854    TGListView* lv = new TGListView(this, w, h);
01855    lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
01856    AddFrame(lv,lo);
01857 
01858    Pixel_t white;
01859    gClient->GetColorByName("white",white);
01860    fContents = new TGFileContainer(lv,kSunkenFrame,white);
01861    fContents->Associate(this);
01862 
01863    // position relative to the parent's window
01864    CenterOnParent();
01865 
01866    SetWindowName("File List Test");
01867    MapSubwindows();
01868    MapWindow();
01869    fContents->SetDefaultHeaders();
01870    fContents->DisplayDirectory();
01871    fContents->AddFile("..");        // up level directory
01872    fContents->Resize();
01873    fContents->StopRefreshTimer();   // stop refreshing
01874    Resize();
01875 }
01876 
01877 TestFileList::~TestFileList()
01878 {
01879    // dtor.
01880 
01881    delete fContents;
01882 }
01883 
01884 void TestFileList::DisplayFile(const TString &fname)
01885 {
01886    // display content of ROOT file
01887 
01888    TFile file(fname);
01889    fContents->RemoveAll();
01890    fContents->AddFile(gSystem->WorkingDirectory());
01891    fContents->SetPagePosition(0,0);
01892    fContents->SetColHeaders("Name","Title");
01893 
01894    TIter next(file.GetListOfKeys());
01895    TKey *key;
01896 
01897    while ((key=(TKey*)next())) {
01898       TString cname = key->GetClassName();
01899       TString name = key->GetName();
01900       TGLVEntry *entry = new TGLVEntry(fContents,name,cname);
01901       entry->SetSubnames(key->GetTitle());
01902       fContents->AddItem(entry);
01903 
01904       // user data is a filename
01905       entry->SetUserData((void*)StrDup(fname));
01906    }
01907    Resize();
01908 }
01909 
01910 void TestFileList::DisplayDirectory(const TString &fname)
01911 {
01912    // display content of directory
01913 
01914    fContents->SetDefaultHeaders();
01915    gSystem->ChangeDirectory(fname);
01916    fContents->ChangeDirectory(fname);
01917    fContents->DisplayDirectory();
01918    fContents->AddFile("..");  // up level directory
01919    Resize();
01920 }
01921 
01922 void TestFileList::DisplayObject(const TString& fname,const TString& name)
01923 {
01924    // browse object located in file
01925 
01926    TDirectory *sav = gDirectory;
01927 
01928    static TFile *file = 0;
01929    if (file) delete file;     // close
01930    file = new TFile(fname);   // reopen
01931 
01932    TObject* obj = file->Get(name);
01933    if (obj) {
01934       if (!obj->IsFolder()) {
01935          obj->Browse(0);
01936       } else obj->Print();
01937    }
01938    gDirectory = sav;
01939 }
01940 
01941 
01942 void TestFileList::DoMenu(Int_t mode)
01943 {
01944    // switch view mode
01945 
01946    if (mode<10) {
01947       fContents->SetViewMode((EListViewMode)mode);
01948    } else {
01949       delete this;   // Close menu entry choosen
01950    }
01951 }
01952 
01953 void TestFileList::OnDoubleClick(TGLVEntry* f, Int_t btn)
01954 {
01955    // handle double click
01956 
01957    if (btn!=kButton1) return;
01958    gVirtualX->SetCursor(fContents->GetId(),gVirtualX->CreateCursor(kWatch));
01959 
01960    TString name(f->GetTitle());
01961    const char* fname = (const char*)f->GetUserData();
01962 
01963    if (fname) {
01964       DisplayObject(fname,name);
01965    } else if (name.EndsWith(".root")) {
01966       DisplayFile(name);
01967    } else {
01968       DisplayDirectory(name);
01969    }
01970    gVirtualX->SetCursor(fContents->GetId(),gVirtualX->CreateCursor(kPointer));
01971 }
01972 
01973 Bool_t TestFileList::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/)
01974 {
01975    // process message sent to this widget.
01976 
01977    switch (GET_MSG(msg)) {
01978 
01979       case kC_CONTAINER:
01980          switch (GET_SUBMSG(msg)) {
01981             case kCT_ITEMDBLCLICK:
01982                if (parm1==kButton1) OnDoubleClick((TGLVEntry*)fContents->GetLastActive(), parm1);
01983                break;
01984          }
01985          break;
01986       case kC_COMMAND:
01987          switch (GET_SUBMSG(msg)) {
01988             case kCM_MENU:
01989                DoMenu(parm1);
01990                break;
01991          }
01992          break;
01993    }
01994    return kTRUE;
01995 }
01996 
01997 
01998 TestProgress::TestProgress(const TGWindow *p, const TGWindow *main,
01999                            UInt_t w, UInt_t h) :
02000     TGTransientFrame(p, main, w, h)
02001 {
02002    // Dialog used to test the different supported progress bars.
02003 
02004    // use hierarchical cleani
02005    SetCleanup(kDeepCleanup);
02006 
02007    ChangeOptions((GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
02008 
02009    fHframe1 = new TGHorizontalFrame(this, 0, 0, 0);
02010 
02011    fVProg1 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
02012    fVProg1->SetBarColor("purple");
02013    fVProg2 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
02014    fVProg2->SetFillType(TGProgressBar::kBlockFill);
02015    fVProg2->SetBarColor("green");
02016 
02017    fHframe1->Resize(300, 300);
02018 
02019    fVframe1 = new TGVerticalFrame(this, 0, 0, 0);
02020 
02021    fHProg1 = new TGHProgressBar(fVframe1, 300);
02022    fHProg1->ShowPosition();
02023    fHProg2 = new TGHProgressBar(fVframe1, TGProgressBar::kFancy, 300);
02024    fHProg2->SetBarColor("lightblue");
02025    fHProg2->ShowPosition(kTRUE, kFALSE, "%.0f events");
02026    fHProg3 = new TGHProgressBar(fVframe1, TGProgressBar::kStandard, 300);
02027    fHProg3->SetFillType(TGProgressBar::kBlockFill);
02028 
02029    fGO = new TGTextButton(fVframe1, "Go", 10);
02030    fGO->Associate(this);
02031 
02032    fVframe1->Resize(300, 300);
02033 
02034    fHint1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 10, 5, 5);
02035    fHint2 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5,  5, 10);
02036    fHint3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 0, 50, 50, 0);
02037    fHint4 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0);
02038    fHint5 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0);
02039 
02040    fHframe1->AddFrame(fVProg1, fHint1);
02041    fHframe1->AddFrame(fVProg2, fHint1);
02042 
02043    fVframe1->AddFrame(fHProg1, fHint2);
02044    fVframe1->AddFrame(fHProg2, fHint2);
02045    fVframe1->AddFrame(fHProg3, fHint2);
02046    fVframe1->AddFrame(fGO,     fHint3);
02047 
02048    AddFrame(fHframe1, fHint4);
02049    AddFrame(fVframe1, fHint5);
02050 
02051    SetWindowName("Progress Test");
02052    Resize();
02053 
02054    // position relative to the parent's window
02055    CenterOnParent();
02056 
02057    MapSubwindows();
02058    MapWindow();
02059 
02060    fClient->WaitFor(this);
02061 }
02062 
02063 TestProgress::~TestProgress()
02064 {
02065    // Delete dialog.
02066 }
02067 
02068 void TestProgress::CloseWindow()
02069 {
02070    // Called when window is closed via the window manager.
02071 
02072    // Interrupt Progress bars increment.
02073    gROOT->SetInterrupt();
02074    DeleteWindow();
02075 }
02076 
02077 Bool_t TestProgress::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
02078 {
02079    // Process slider messages.
02080 
02081    switch (GET_MSG(msg)) {
02082       case kC_COMMAND:
02083          switch (GET_SUBMSG(msg)) {
02084             case kCM_BUTTON:
02085                switch (parm1) {
02086                   case 10:
02087                      {
02088                         fVProg1->Reset(); fVProg2->Reset();
02089                         fHProg1->Reset(); fHProg2->Reset(); fHProg3->Reset();
02090                         fVProg2->SetBarColor("green");
02091                         int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
02092                         int inc1 = 4, inc2 = 3, inc3 = 2, inc4 = 1;
02093                         while (cnt1 < 100 || cnt2 < 100 || cnt3 < 100 || cnt4 <100) {
02094                            if (cnt1 < 100) {
02095                               cnt1 += inc1;
02096                               fVProg1->Increment(inc1);
02097                            }
02098                            if (cnt2 < 100) {
02099                               cnt2 += inc2;
02100                               fVProg2->Increment(inc2);
02101                               if (cnt2 > 75)
02102                                  fVProg2->SetBarColor("red");
02103                            }
02104                            if (cnt3 < 100) {
02105                               cnt3 += inc3;
02106                               fHProg1->Increment(inc3);
02107                            }
02108                            if (cnt4 < 100) {
02109                               cnt4 += inc4;
02110                               fHProg2->Increment(inc4);
02111                               fHProg3->Increment(inc4);
02112                            }
02113                            gSystem->Sleep(100);
02114                            // if user closed window return
02115                            if (gSystem->ProcessEvents()) break;
02116                            if (!fGO) return kTRUE;
02117                         }
02118                      }
02119                      break;
02120                   default:
02121                      break;
02122                }
02123                break;
02124             default:
02125                break;
02126          }
02127          break;
02128       default:
02129          break;
02130    }
02131    return kTRUE;
02132 }
02133 
02134 
02135 // TGNumberEntry widget test dialog
02136 const char *const EntryTestDlg::numlabel[13] = {
02137    "Integer",
02138    "One digit real",
02139    "Two digit real",
02140    "Three digit real",
02141    "Four digit real",
02142    "Real",
02143    "Degree.min.sec",
02144    "Min:sec",
02145    "Hour:min",
02146    "Hour:min:sec",
02147    "Day/month/year",
02148    "Month/day/year",
02149    "Hex"
02150 };
02151 
02152 const Double_t EntryTestDlg::numinit[13] = {
02153    12345, 1.0, 1.00, 1.000, 1.0000, 1.2E-12,
02154    90 * 3600, 120 * 60, 12 * 60, 12 * 3600 + 15 * 60,
02155    19991121, 19991121, (Double_t) 0xDEADFACE
02156 };
02157 
02158 EntryTestDlg::EntryTestDlg(const TGWindow * p, const TGWindow * main)
02159  : TGTransientFrame(p, main, 10, 10, kHorizontalFrame)
02160 {
02161    // build widgets
02162 
02163    // use hierarchical cleani
02164    SetCleanup(kDeepCleanup);
02165 
02166    TGGC myGC = *fClient->GetResourcePool()->GetFrameGC();
02167    TGFont *myfont = fClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
02168    if (myfont) myGC.SetFont(myfont->GetFontHandle());
02169 
02170    fF1 = new TGVerticalFrame(this, 200, 300);
02171    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
02172    AddFrame(fF1, fL1);
02173    fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsRight, 2, 2, 2, 2);
02174    for (int i = 0; i < 13; i++) {
02175       fF[i] = new TGHorizontalFrame(fF1, 200, 30);
02176       fF1->AddFrame(fF[i], fL2);
02177       fNumericEntries[i] = new TGNumberEntry(fF[i], numinit[i], 12, i + 20,
02178                                              (TGNumberFormat::EStyle) i);
02179       fNumericEntries[i]->Associate(this);
02180       fF[i]->AddFrame(fNumericEntries[i], fL2);
02181       fLabel[i] = new TGLabel(fF[i], numlabel[i], myGC(), myfont->GetFontStruct());
02182       fF[i]->AddFrame(fLabel[i], fL2);
02183    }
02184    fF2 = new TGVerticalFrame(this, 200, 500);
02185    fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
02186    AddFrame(fF2, fL3);
02187    fLowerLimit = new TGCheckButton(fF2, "lower limit:", 4);
02188    fLowerLimit->Associate(this);
02189    fF2->AddFrame(fLowerLimit, fL3);
02190    fLimits[0] = new TGNumberEntry(fF2, 0, 12, 10);
02191    fLimits[0]->SetLogStep(kFALSE);
02192    fLimits[0]->Associate(this);
02193    fF2->AddFrame(fLimits[0], fL3);
02194    fUpperLimit = new TGCheckButton(fF2, "upper limit:", 5);
02195    fUpperLimit->Associate(this);
02196    fF2->AddFrame(fUpperLimit, fL3);
02197    fLimits[1] = new TGNumberEntry(fF2, 0, 12, 11);
02198    fLimits[1]->SetLogStep(kFALSE);
02199    fLimits[1]->Associate(this);
02200    fF2->AddFrame(fLimits[1], fL3);
02201    fPositive = new TGCheckButton(fF2, "Positive", 6);
02202    fPositive->Associate(this);
02203    fF2->AddFrame(fPositive, fL3);
02204    fNonNegative = new TGCheckButton(fF2, "Non negative", 7);
02205    fNonNegative->Associate(this);
02206    fF2->AddFrame(fNonNegative, fL3);
02207    fSetButton = new TGTextButton(fF2, " Set ", 2);
02208    fSetButton->Associate(this);
02209    fF2->AddFrame(fSetButton, fL3);
02210    fExitButton = new TGTextButton(fF2, " Close ", 1);
02211    fExitButton->Associate(this);
02212    fF2->AddFrame(fExitButton, fL3);
02213 
02214    // set dialog box title
02215    SetWindowName("Number Entry Test");
02216    SetIconName("Number Entry Test");
02217    SetClassHints("NumberEntryDlg", "NumberEntryDlg");
02218    // resize & move to center
02219    MapSubwindows();
02220    UInt_t width = GetDefaultWidth();
02221    UInt_t height = GetDefaultHeight();
02222    Resize(width, height);
02223 
02224    CenterOnParent();
02225 
02226    // make the message box non-resizable
02227    SetWMSize(width, height);
02228    SetWMSizeHints(width, height, width, height, 0, 0);
02229    SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
02230                kMWMDecorMinimize | kMWMDecorMenu,
02231                kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
02232                kMWMFuncMinimize, kMWMInputModeless);
02233 
02234    MapWindow();
02235    fClient->WaitFor(this);
02236 }
02237 
02238 EntryTestDlg::~EntryTestDlg()
02239 {
02240    // dtor
02241 }
02242 
02243 void EntryTestDlg::CloseWindow()
02244 {
02245    DeleteWindow();
02246 }
02247 
02248 void EntryTestDlg::SetLimits()
02249 {
02250    Double_t min = fLimits[0]->GetNumber();
02251    Bool_t low = (fLowerLimit->GetState() == kButtonDown);
02252    Double_t max = fLimits[1]->GetNumber();
02253    Bool_t high = (fUpperLimit->GetState() == kButtonDown);
02254    TGNumberFormat::ELimit lim;
02255    if (low && high) {
02256       lim = TGNumberFormat::kNELLimitMinMax;
02257    } else if (low) {
02258       lim = TGNumberFormat::kNELLimitMin;
02259    } else if (high) {
02260       lim = TGNumberFormat::kNELLimitMax;
02261    } else {
02262       lim = TGNumberFormat::kNELNoLimits;
02263    }
02264    Bool_t pos = (fPositive->GetState() == kButtonDown);
02265    Bool_t nneg = (fNonNegative->GetState() == kButtonDown);
02266    TGNumberFormat::EAttribute attr;
02267    if (pos) {
02268       attr = TGNumberFormat::kNEAPositive;
02269    } else if (nneg) {
02270       attr = TGNumberFormat::kNEANonNegative;
02271    } else {
02272       attr = TGNumberFormat::kNEAAnyNumber;
02273    }
02274    for (int i = 0; i < 13; i++) {
02275       fNumericEntries[i]->SetFormat(fNumericEntries[i]->GetNumStyle(), attr);
02276       fNumericEntries[i]->SetLimits(lim, min, max);
02277    }
02278 }
02279 
02280 Bool_t EntryTestDlg::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/)
02281 {
02282    switch (GET_MSG(msg)) {
02283    case kC_COMMAND:
02284       {
02285          switch (GET_SUBMSG(msg)) {
02286          case kCM_BUTTON:
02287             {
02288                switch (parm1) {
02289                   // exit button
02290                case 1:
02291                   {
02292                      CloseWindow();
02293                      break;
02294                   }
02295                   // set button
02296                case 2:
02297                   {
02298                      SetLimits();
02299                      break;
02300                   }
02301                }
02302                break;
02303             }
02304          }
02305          break;
02306       }
02307    }
02308    return kTRUE;
02309 }
02310 
02311 
02312 Editor::Editor(const TGWindow *main, UInt_t w, UInt_t h) :
02313     TGTransientFrame(gClient->GetRoot(), main, w, h)
02314 {
02315    // Create an editor in a dialog.
02316 
02317    // use hierarchical cleani
02318    SetCleanup(kDeepCleanup);
02319 
02320    fEdit = new TGTextEdit(this, w, h, kSunkenFrame | kDoubleBorder);
02321    fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
02322    AddFrame(fEdit, fL1);
02323 
02324    // set selected text colors 
02325    Pixel_t pxl;
02326    gClient->GetColorByName("#ccccff", pxl);
02327    fEdit->SetSelectBack(pxl);
02328    fEdit->SetSelectFore(TGFrame::GetBlackPixel());
02329 
02330    fOK = new TGTextButton(this, "  &OK  ");
02331    fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
02332    AddFrame(fOK, fL2);
02333 
02334    SetTitle();
02335 
02336    MapSubwindows();
02337    Resize();   // resize to default size
02338 
02339    // editor covers right half of parent window
02340    CenterOnParent(kTRUE, TGTransientFrame::kRight);
02341 }
02342 
02343 Editor::~Editor()
02344 {
02345    // Delete editor dialog.
02346 
02347 }
02348 
02349 void Editor::SetTitle()
02350 {
02351    // Set title in editor window.
02352 
02353    TGText *txt = GetEditor()->GetText();
02354    Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
02355 
02356    char title[256];
02357    if (untitled)
02358       sprintf(title, "ROOT Editor - Untitled");
02359    else
02360       sprintf(title, "ROOT Editor - %s", txt->GetFileName());
02361 
02362    SetWindowName(title);
02363    SetIconName(title);
02364 }
02365 
02366 void Editor::Popup()
02367 {
02368    // Show editor.
02369 
02370    MapWindow();
02371 }
02372 
02373 void Editor::LoadBuffer(const char *buffer)
02374 {
02375    // Load a text buffer in the editor.
02376 
02377    fEdit->LoadBuffer(buffer);
02378 }
02379 
02380 void Editor::LoadFile(const char *file)
02381 {
02382    // Load a file in the editor.
02383 
02384    fEdit->LoadFile(file);
02385 }
02386 
02387 void Editor::CloseWindow()
02388 {
02389    // Called when closed via window manager action.
02390 
02391    DeleteWindow();
02392 }
02393 
02394 Bool_t Editor::ProcessMessage(Long_t msg, Long_t, Long_t)
02395 {
02396    // Process OK button.
02397 
02398    switch (GET_MSG(msg)) {
02399       case kC_COMMAND:
02400          switch (GET_SUBMSG(msg)) {
02401             case kCM_BUTTON:
02402                // Only one button and one action...
02403                DeleteWindow();
02404                break;
02405             default:
02406                break;
02407          }
02408          break;
02409       case kC_TEXTVIEW:
02410          switch (GET_SUBMSG(msg)) {
02411             case kTXT_CLOSE:
02412                // close window
02413                DeleteWindow();
02414                break;
02415             case kTXT_OPEN:
02416                SetTitle();
02417                break;
02418             case kTXT_SAVE:
02419                SetTitle();
02420                break;
02421             default:
02422                break;
02423          }
02424       default:
02425          break;
02426    }
02427 
02428    return kTRUE;
02429 }
02430 
02431 
02432 //---- Main program ------------------------------------------------------------
02433 
02434 int main(int argc, char **argv)
02435 {
02436    TApplication theApp("App", &argc, argv);
02437 
02438    if (gROOT->IsBatch()) {
02439       fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]);
02440       return 1;
02441    }
02442 
02443    TestMainFrame mainWindow(gClient->GetRoot(), 400, 220);
02444 
02445    theApp.Run();
02446 
02447    return 0;
02448 }

Generated on Tue Jul 5 15:15:01 2011 for ROOT_528-00b_version by  doxygen 1.5.1