ROOT logo
// @(#)root/gui:$Id: TGMdiFrame.cxx 23115 2008-04-10 13:35:37Z rdm $
// Author: Bertrand Bellenot   20/08/2004

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

/**************************************************************************

    This file is part of TGMdi an extension to the xclass toolkit.
    Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.

    This application is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This application is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

**************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGMdiFrame.                                                          //
//                                                                      //
// This file contains the TGMdiFrame class.                             //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TGFrame.h"
#include "TGMdiFrame.h"
#include "TGMdiMainFrame.h"
#include "TGMdiDecorFrame.h"
#include "Riostream.h"

ClassImp(TGMdiFrame)

//______________________________________________________________________________
TGMdiFrame::TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options,
                       Pixel_t back) :
   TGCompositeFrame(main->GetContainer(), w, h,
                    options | kOwnBackground | kMdiFrame, back)
{
   // TGMdiFrame constructor.

   fMain = main;
   fMain->AddMdiFrame(this);  // this reparents the window
   fMdiHints = kMdiDefaultHints;
}

//______________________________________________________________________________
TGMdiFrame::~TGMdiFrame()
{
   // TGMdiFrame destructor.

   Cleanup();
   fMain->RemoveMdiFrame(this);
}

//______________________________________________________________________________
Bool_t TGMdiFrame::CloseWindow()
{
   // Close MDI frame window.

   DeleteWindow();
   return kTRUE;
}

//______________________________________________________________________________
void TGMdiFrame::DontCallClose()
{
   // Typically call this method in the slot connected to the CloseWindow()
   // signal to prevent the calling of the default or any derived CloseWindow()
   // methods to prevent premature or double deletion of this window.

   SetBit(kDontCallClose);
}

//______________________________________________________________________________
void TGMdiFrame::SetMdiHints(ULong_t mdihints)
{
   // Set MDI hints, also used to identify titlebar buttons.

   fMdiHints = mdihints;
   ((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
}

//______________________________________________________________________________
void TGMdiFrame::SetWindowName(const char *name)
{
   // Set MDI window name (set titlebar title).

   ((TGMdiDecorFrame *)fParent)->SetWindowName(name);
   fMain->UpdateWinListMenu();
}

//______________________________________________________________________________
void TGMdiFrame::SetWindowIcon(const TGPicture *pic)
{
   // Set MDI window icon (titlebar icon).

   ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
   fMain->UpdateWinListMenu();
}

//______________________________________________________________________________
const char *TGMdiFrame::GetWindowName()
{
   // Return MDI window name.

   return ((TGMdiDecorFrame *)fParent)->GetWindowName();
}

//______________________________________________________________________________
const TGPicture *TGMdiFrame::GetWindowIcon()
{
   // Return pointer to picture used as MDI window icon (on titlebar).

   return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
}

//______________________________________________________________________________
void TGMdiFrame::Move(Int_t x, Int_t y)
{
   // Move MDI window at position x, y.

   ((TGMdiDecorFrame *)fParent)->Move(x, y);
   fX = x; fY = y;
}

//______________________________________________________________________________
TString TGMdiFrame::GetMdiHintsString() const
{
   // Returns a MDI option string - used in SavePrimitive().

   TString hints;
   if (fMdiHints == kMdiDefaultHints)
      hints = "kMdiDefaultHints";
   else {
      if (fMdiHints & kMdiClose) {
         if (hints.Length() == 0) hints = "kMdiClose";
         else                     hints += " | kMdiClose";
      }
      if (fMdiHints & kMdiRestore) {
         if (hints.Length() == 0) hints = "kMdiRestore";
         else                     hints += " | kMdiRestore";
      }
      if (fMdiHints & kMdiMove) {
         if (hints.Length() == 0) hints = "kMdiMove";
         else                     hints += " | kMdiMove";
      }
      if (fMdiHints & kMdiSize) {
         if (hints.Length() == 0) hints = "kMdiSize";
         else                     hints += " | kMdiSize";
      }
      if (fMdiHints & kMdiMinimize) {
         if (hints.Length() == 0) hints = "kMdiMinimize";
         else                     hints += " | kMdiMinimize";
      }
      if (fMdiHints & kMdiMaximize) {
         if (hints.Length() == 0) hints = "kMdiMaximize";
         else                     hints += " | kMdiMaximize";
      }
      if (fMdiHints & kMdiHelp) {
         if (hints.Length() == 0) hints = "kMdiHelp";
         else                     hints += " | kMdiHelp";
      }
      if (fMdiHints & kMdiMenu) {
         if (hints.Length() == 0) hints = "kMdiMenu";
         else                     hints += " | kMdiMenu";
      }
   }
   return hints;
}

//______________________________________________________________________________
void TGMdiFrame::SavePrimitive(ostream &out, Option_t *option /*= ""*/)
{
   // Save a MDIframe as a C++ statement(s) on output stream out

   char quote = '"';
   
   if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
   
   TGMdiTitleBar *tb = fMain->GetWindowList()->GetDecorFrame()->GetTitleBar();
   
   out << endl <<"   // MDI frame "<< quote << GetWindowName() << quote << endl;
   out << "   TGMdiFrame *";
   out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
       << "," << GetWidth() + GetBorderWidth()*2 
       << "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;

   if (fBackground == GetDefaultFrameBackground()) {
      if (!GetOptions()) {
         out << ");" << endl;
      } else {
         out << "," << GetOptionString() <<");" << endl;
      }
   } else {
      out << "," << GetOptionString() << ",ucolor);" << endl;
   }

   SavePrimitiveSubframes(out, option);
   
   out << "   " << GetName() << "->SetWindowName(" << quote << GetWindowName()
       << quote << ");" << endl;
   out << "   " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
       << ");" << endl;
   if ((GetX() != 5) && (GetY() != 23))
      out << "   " << GetName() << "->Move(" << GetX() << "," << GetY() 
          << ");" << endl;
          
   out << "   " << GetName() << "->MapSubwindows();" << endl;
   out << "   " << GetName() << "->Layout();" << endl;
}
 TGMdiFrame.cxx:1
 TGMdiFrame.cxx:2
 TGMdiFrame.cxx:3
 TGMdiFrame.cxx:4
 TGMdiFrame.cxx:5
 TGMdiFrame.cxx:6
 TGMdiFrame.cxx:7
 TGMdiFrame.cxx:8
 TGMdiFrame.cxx:9
 TGMdiFrame.cxx:10
 TGMdiFrame.cxx:11
 TGMdiFrame.cxx:12
 TGMdiFrame.cxx:13
 TGMdiFrame.cxx:14
 TGMdiFrame.cxx:15
 TGMdiFrame.cxx:16
 TGMdiFrame.cxx:17
 TGMdiFrame.cxx:18
 TGMdiFrame.cxx:19
 TGMdiFrame.cxx:20
 TGMdiFrame.cxx:21
 TGMdiFrame.cxx:22
 TGMdiFrame.cxx:23
 TGMdiFrame.cxx:24
 TGMdiFrame.cxx:25
 TGMdiFrame.cxx:26
 TGMdiFrame.cxx:27
 TGMdiFrame.cxx:28
 TGMdiFrame.cxx:29
 TGMdiFrame.cxx:30
 TGMdiFrame.cxx:31
 TGMdiFrame.cxx:32
 TGMdiFrame.cxx:33
 TGMdiFrame.cxx:34
 TGMdiFrame.cxx:35
 TGMdiFrame.cxx:36
 TGMdiFrame.cxx:37
 TGMdiFrame.cxx:38
 TGMdiFrame.cxx:39
 TGMdiFrame.cxx:40
 TGMdiFrame.cxx:41
 TGMdiFrame.cxx:42
 TGMdiFrame.cxx:43
 TGMdiFrame.cxx:44
 TGMdiFrame.cxx:45
 TGMdiFrame.cxx:46
 TGMdiFrame.cxx:47
 TGMdiFrame.cxx:48
 TGMdiFrame.cxx:49
 TGMdiFrame.cxx:50
 TGMdiFrame.cxx:51
 TGMdiFrame.cxx:52
 TGMdiFrame.cxx:53
 TGMdiFrame.cxx:54
 TGMdiFrame.cxx:55
 TGMdiFrame.cxx:56
 TGMdiFrame.cxx:57
 TGMdiFrame.cxx:58
 TGMdiFrame.cxx:59
 TGMdiFrame.cxx:60
 TGMdiFrame.cxx:61
 TGMdiFrame.cxx:62
 TGMdiFrame.cxx:63
 TGMdiFrame.cxx:64
 TGMdiFrame.cxx:65
 TGMdiFrame.cxx:66
 TGMdiFrame.cxx:67
 TGMdiFrame.cxx:68
 TGMdiFrame.cxx:69
 TGMdiFrame.cxx:70
 TGMdiFrame.cxx:71
 TGMdiFrame.cxx:72
 TGMdiFrame.cxx:73
 TGMdiFrame.cxx:74
 TGMdiFrame.cxx:75
 TGMdiFrame.cxx:76
 TGMdiFrame.cxx:77
 TGMdiFrame.cxx:78
 TGMdiFrame.cxx:79
 TGMdiFrame.cxx:80
 TGMdiFrame.cxx:81
 TGMdiFrame.cxx:82
 TGMdiFrame.cxx:83
 TGMdiFrame.cxx:84
 TGMdiFrame.cxx:85
 TGMdiFrame.cxx:86
 TGMdiFrame.cxx:87
 TGMdiFrame.cxx:88
 TGMdiFrame.cxx:89
 TGMdiFrame.cxx:90
 TGMdiFrame.cxx:91
 TGMdiFrame.cxx:92
 TGMdiFrame.cxx:93
 TGMdiFrame.cxx:94
 TGMdiFrame.cxx:95
 TGMdiFrame.cxx:96
 TGMdiFrame.cxx:97
 TGMdiFrame.cxx:98
 TGMdiFrame.cxx:99
 TGMdiFrame.cxx:100
 TGMdiFrame.cxx:101
 TGMdiFrame.cxx:102
 TGMdiFrame.cxx:103
 TGMdiFrame.cxx:104
 TGMdiFrame.cxx:105
 TGMdiFrame.cxx:106
 TGMdiFrame.cxx:107
 TGMdiFrame.cxx:108
 TGMdiFrame.cxx:109
 TGMdiFrame.cxx:110
 TGMdiFrame.cxx:111
 TGMdiFrame.cxx:112
 TGMdiFrame.cxx:113
 TGMdiFrame.cxx:114
 TGMdiFrame.cxx:115
 TGMdiFrame.cxx:116
 TGMdiFrame.cxx:117
 TGMdiFrame.cxx:118
 TGMdiFrame.cxx:119
 TGMdiFrame.cxx:120
 TGMdiFrame.cxx:121
 TGMdiFrame.cxx:122
 TGMdiFrame.cxx:123
 TGMdiFrame.cxx:124
 TGMdiFrame.cxx:125
 TGMdiFrame.cxx:126
 TGMdiFrame.cxx:127
 TGMdiFrame.cxx:128
 TGMdiFrame.cxx:129
 TGMdiFrame.cxx:130
 TGMdiFrame.cxx:131
 TGMdiFrame.cxx:132
 TGMdiFrame.cxx:133
 TGMdiFrame.cxx:134
 TGMdiFrame.cxx:135
 TGMdiFrame.cxx:136
 TGMdiFrame.cxx:137
 TGMdiFrame.cxx:138
 TGMdiFrame.cxx:139
 TGMdiFrame.cxx:140
 TGMdiFrame.cxx:141
 TGMdiFrame.cxx:142
 TGMdiFrame.cxx:143
 TGMdiFrame.cxx:144
 TGMdiFrame.cxx:145
 TGMdiFrame.cxx:146
 TGMdiFrame.cxx:147
 TGMdiFrame.cxx:148
 TGMdiFrame.cxx:149
 TGMdiFrame.cxx:150
 TGMdiFrame.cxx:151
 TGMdiFrame.cxx:152
 TGMdiFrame.cxx:153
 TGMdiFrame.cxx:154
 TGMdiFrame.cxx:155
 TGMdiFrame.cxx:156
 TGMdiFrame.cxx:157
 TGMdiFrame.cxx:158
 TGMdiFrame.cxx:159
 TGMdiFrame.cxx:160
 TGMdiFrame.cxx:161
 TGMdiFrame.cxx:162
 TGMdiFrame.cxx:163
 TGMdiFrame.cxx:164
 TGMdiFrame.cxx:165
 TGMdiFrame.cxx:166
 TGMdiFrame.cxx:167
 TGMdiFrame.cxx:168
 TGMdiFrame.cxx:169
 TGMdiFrame.cxx:170
 TGMdiFrame.cxx:171
 TGMdiFrame.cxx:172
 TGMdiFrame.cxx:173
 TGMdiFrame.cxx:174
 TGMdiFrame.cxx:175
 TGMdiFrame.cxx:176
 TGMdiFrame.cxx:177
 TGMdiFrame.cxx:178
 TGMdiFrame.cxx:179
 TGMdiFrame.cxx:180
 TGMdiFrame.cxx:181
 TGMdiFrame.cxx:182
 TGMdiFrame.cxx:183
 TGMdiFrame.cxx:184
 TGMdiFrame.cxx:185
 TGMdiFrame.cxx:186
 TGMdiFrame.cxx:187
 TGMdiFrame.cxx:188
 TGMdiFrame.cxx:189
 TGMdiFrame.cxx:190
 TGMdiFrame.cxx:191
 TGMdiFrame.cxx:192
 TGMdiFrame.cxx:193
 TGMdiFrame.cxx:194
 TGMdiFrame.cxx:195
 TGMdiFrame.cxx:196
 TGMdiFrame.cxx:197
 TGMdiFrame.cxx:198
 TGMdiFrame.cxx:199
 TGMdiFrame.cxx:200
 TGMdiFrame.cxx:201
 TGMdiFrame.cxx:202
 TGMdiFrame.cxx:203
 TGMdiFrame.cxx:204
 TGMdiFrame.cxx:205
 TGMdiFrame.cxx:206
 TGMdiFrame.cxx:207
 TGMdiFrame.cxx:208
 TGMdiFrame.cxx:209
 TGMdiFrame.cxx:210
 TGMdiFrame.cxx:211
 TGMdiFrame.cxx:212
 TGMdiFrame.cxx:213
 TGMdiFrame.cxx:214
 TGMdiFrame.cxx:215
 TGMdiFrame.cxx:216
 TGMdiFrame.cxx:217
 TGMdiFrame.cxx:218
 TGMdiFrame.cxx:219
 TGMdiFrame.cxx:220
 TGMdiFrame.cxx:221
 TGMdiFrame.cxx:222
 TGMdiFrame.cxx:223
 TGMdiFrame.cxx:224
 TGMdiFrame.cxx:225
 TGMdiFrame.cxx:226