TGMdiFrame.cxx

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGMdiFrame.cxx 35582 2010-09-22 13:38:27Z bellenot $
00002 // Author: Bertrand Bellenot   20/08/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 /**************************************************************************
00013 
00014     This file is part of TGMdi an extension to the xclass toolkit.
00015     Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.
00016 
00017     This application is free software; you can redistribute it and/or
00018     modify it under the terms of the GNU Library General Public
00019     License as published by the Free Software Foundation; either
00020     version 2 of the License, or (at your option) any later version.
00021 
00022     This application is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025     Library General Public License for more details.
00026 
00027     You should have received a copy of the GNU Library General Public
00028     License along with this library; if not, write to the Free
00029     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00030 
00031 **************************************************************************/
00032 
00033 //////////////////////////////////////////////////////////////////////////
00034 //                                                                      //
00035 // TGMdiFrame.                                                          //
00036 //                                                                      //
00037 // This file contains the TGMdiFrame class.                             //
00038 //                                                                      //
00039 //////////////////////////////////////////////////////////////////////////
00040 
00041 #include "TGFrame.h"
00042 #include "TGMdiFrame.h"
00043 #include "TGMdiMainFrame.h"
00044 #include "TGMdiDecorFrame.h"
00045 #include "Riostream.h"
00046 
00047 ClassImp(TGMdiFrame)
00048 
00049 //______________________________________________________________________________
00050 TGMdiFrame::TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options,
00051                        Pixel_t back) :
00052    TGCompositeFrame(main->GetContainer(), w, h,
00053                     options | kOwnBackground | kMdiFrame, back)
00054 {
00055    // TGMdiFrame constructor.
00056 
00057    fMain = main;
00058    fMain->AddMdiFrame(this);  // this reparents the window
00059    fMdiHints = kMdiDefaultHints;
00060 }
00061 
00062 //______________________________________________________________________________
00063 TGMdiFrame::~TGMdiFrame()
00064 {
00065    // TGMdiFrame destructor.
00066 
00067    Cleanup();
00068    fMain->RemoveMdiFrame(this);
00069 }
00070 
00071 //______________________________________________________________________________
00072 Bool_t TGMdiFrame::CloseWindow()
00073 {
00074    // Close MDI frame window.
00075 
00076    DeleteWindow();
00077    return kTRUE;
00078 }
00079 
00080 //______________________________________________________________________________
00081 void TGMdiFrame::DontCallClose()
00082 {
00083    // Typically call this method in the slot connected to the CloseWindow()
00084    // signal to prevent the calling of the default or any derived CloseWindow()
00085    // methods to prevent premature or double deletion of this window.
00086 
00087    SetBit(kDontCallClose);
00088 }
00089 
00090 //______________________________________________________________________________
00091 void TGMdiFrame::SetMdiHints(ULong_t mdihints)
00092 {
00093    // Set MDI hints, also used to identify titlebar buttons.
00094 
00095    fMdiHints = mdihints;
00096    ((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
00097 }
00098 
00099 //______________________________________________________________________________
00100 void TGMdiFrame::SetWindowName(const char *name)
00101 {
00102    // Set MDI window name (set titlebar title).
00103 
00104    ((TGMdiDecorFrame *)fParent)->SetWindowName(name);
00105    fMain->UpdateWinListMenu();
00106 }
00107 
00108 //______________________________________________________________________________
00109 void TGMdiFrame::SetWindowIcon(const TGPicture *pic)
00110 {
00111    // Set MDI window icon (titlebar icon).
00112 
00113    ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
00114    fMain->UpdateWinListMenu();
00115 }
00116 
00117 //______________________________________________________________________________
00118 const char *TGMdiFrame::GetWindowName()
00119 {
00120    // Return MDI window name.
00121 
00122    return ((TGMdiDecorFrame *)fParent)->GetWindowName();
00123 }
00124 
00125 //______________________________________________________________________________
00126 const TGPicture *TGMdiFrame::GetWindowIcon()
00127 {
00128    // Return pointer to picture used as MDI window icon (on titlebar).
00129 
00130    return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
00131 }
00132 
00133 //______________________________________________________________________________
00134 void TGMdiFrame::Move(Int_t x, Int_t y)
00135 {
00136    // Move MDI window at position x, y.
00137 
00138    ((TGMdiDecorFrame *)fParent)->Move(x, y);
00139    fX = x; fY = y;
00140 }
00141 
00142 //______________________________________________________________________________
00143 TString TGMdiFrame::GetMdiHintsString() const
00144 {
00145    // Returns a MDI option string - used in SavePrimitive().
00146 
00147    TString hints;
00148    if (fMdiHints == kMdiDefaultHints)
00149       hints = "kMdiDefaultHints";
00150    else {
00151       if (fMdiHints & kMdiClose) {
00152          if (hints.Length() == 0) hints = "kMdiClose";
00153          else                     hints += " | kMdiClose";
00154       }
00155       if (fMdiHints & kMdiRestore) {
00156          if (hints.Length() == 0) hints = "kMdiRestore";
00157          else                     hints += " | kMdiRestore";
00158       }
00159       if (fMdiHints & kMdiMove) {
00160          if (hints.Length() == 0) hints = "kMdiMove";
00161          else                     hints += " | kMdiMove";
00162       }
00163       if (fMdiHints & kMdiSize) {
00164          if (hints.Length() == 0) hints = "kMdiSize";
00165          else                     hints += " | kMdiSize";
00166       }
00167       if (fMdiHints & kMdiMinimize) {
00168          if (hints.Length() == 0) hints = "kMdiMinimize";
00169          else                     hints += " | kMdiMinimize";
00170       }
00171       if (fMdiHints & kMdiMaximize) {
00172          if (hints.Length() == 0) hints = "kMdiMaximize";
00173          else                     hints += " | kMdiMaximize";
00174       }
00175       if (fMdiHints & kMdiHelp) {
00176          if (hints.Length() == 0) hints = "kMdiHelp";
00177          else                     hints += " | kMdiHelp";
00178       }
00179       if (fMdiHints & kMdiMenu) {
00180          if (hints.Length() == 0) hints = "kMdiMenu";
00181          else                     hints += " | kMdiMenu";
00182       }
00183    }
00184    return hints;
00185 }
00186 
00187 //______________________________________________________________________________
00188 void TGMdiFrame::SavePrimitive(ostream &out, Option_t *option /*= ""*/)
00189 {
00190    // Save a MDIframe as a C++ statement(s) on output stream out
00191 
00192    char quote = '"';
00193    
00194    if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
00195    
00196    TGMdiTitleBar *tb = fMain->GetWindowList()->GetDecorFrame()->GetTitleBar();
00197    
00198    out << endl <<"   // MDI frame "<< quote << GetWindowName() << quote << endl;
00199    out << "   TGMdiFrame *";
00200    out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
00201        << "," << GetWidth() + GetBorderWidth()*2 
00202        << "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;
00203 
00204    if (fBackground == GetDefaultFrameBackground()) {
00205       if (!GetOptions()) {
00206          out << ");" << endl;
00207       } else {
00208          out << "," << GetOptionString() <<");" << endl;
00209       }
00210    } else {
00211       out << "," << GetOptionString() << ",ucolor);" << endl;
00212    }
00213    if (option && strstr(option, "keep_names"))
00214       out << "   " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00215 
00216    SavePrimitiveSubframes(out, option);
00217    
00218    out << "   " << GetName() << "->SetWindowName(" << quote << GetWindowName()
00219        << quote << ");" << endl;
00220    out << "   " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
00221        << ");" << endl;
00222    if ((GetX() != 5) && (GetY() != 23))
00223       out << "   " << GetName() << "->Move(" << GetX() << "," << GetY() 
00224           << ");" << endl;
00225           
00226    out << "   " << GetName() << "->MapSubwindows();" << endl;
00227    out << "   " << GetName() << "->Layout();" << endl;
00228 }

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