Logo ROOT  
Reference Guide
TGMdiFrame.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 20/08/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /**************************************************************************
13 
14  This file is part of TGMdi an extension to the xclass toolkit.
15  Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.
16 
17  This application is free software; you can redistribute it and/or
18  modify it under the terms of the GNU Library General Public
19  License as published by the Free Software Foundation; either
20  version 2 of the License, or (at your option) any later version.
21 
22  This application is distributed in the hope that it will be useful,
23  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25  Library General Public License for more details.
26 
27  You should have received a copy of the GNU Library General Public
28  License along with this library; if not, write to the Free
29  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 
31 **************************************************************************/
32 
33 //////////////////////////////////////////////////////////////////////////
34 // //
35 // TGMdiFrame. //
36 // //
37 // This file contains the TGMdiFrame class. //
38 // //
39 //////////////////////////////////////////////////////////////////////////
40 
41 #include "TGMdiFrame.h"
42 #include "TGMdiMainFrame.h"
43 #include "TGMdiDecorFrame.h"
44 
45 #include <iostream>
46 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// TGMdiFrame constructor.
51 
53  Pixel_t back) :
54  TGCompositeFrame(main->GetContainer(), w, h,
55  options | kOwnBackground | kMdiFrame, back)
56 {
57  fMain = main;
58  fMain->AddMdiFrame(this); // this reparents the window
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// TGMdiFrame destructor.
64 
66 {
67  Cleanup();
68  fMain->RemoveMdiFrame(this);
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// Close MDI frame window.
73 
75 {
76  DeleteWindow();
77  return kTRUE;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Typically call this method in the slot connected to the CloseWindow()
82 /// signal to prevent the calling of the default or any derived CloseWindow()
83 /// methods to prevent premature or double deletion of this window.
84 
86 {
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Set MDI hints, also used to identify titlebar buttons.
92 
94 {
95  fMdiHints = mdihints;
96  ((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Set MDI window name (set titlebar title).
101 
103 {
104  ((TGMdiDecorFrame *)fParent)->SetWindowName(name);
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Set MDI window icon (titlebar icon).
110 
112 {
113  ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Return MDI window name.
119 
121 {
122  return ((TGMdiDecorFrame *)fParent)->GetWindowName();
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 /// Return pointer to picture used as MDI window icon (on titlebar).
127 
129 {
130  return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 /// Move MDI window at position x, y.
135 
137 {
138  ((TGMdiDecorFrame *)fParent)->Move(x, y);
139  fX = x; fY = y;
140 }
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 /// Returns a MDI option string - used in SavePrimitive().
144 
146 {
147  TString hints;
149  hints = "kMdiDefaultHints";
150  else {
151  if (fMdiHints & kMdiClose) {
152  if (hints.Length() == 0) hints = "kMdiClose";
153  else hints += " | kMdiClose";
154  }
155  if (fMdiHints & kMdiRestore) {
156  if (hints.Length() == 0) hints = "kMdiRestore";
157  else hints += " | kMdiRestore";
158  }
159  if (fMdiHints & kMdiMove) {
160  if (hints.Length() == 0) hints = "kMdiMove";
161  else hints += " | kMdiMove";
162  }
163  if (fMdiHints & kMdiSize) {
164  if (hints.Length() == 0) hints = "kMdiSize";
165  else hints += " | kMdiSize";
166  }
167  if (fMdiHints & kMdiMinimize) {
168  if (hints.Length() == 0) hints = "kMdiMinimize";
169  else hints += " | kMdiMinimize";
170  }
171  if (fMdiHints & kMdiMaximize) {
172  if (hints.Length() == 0) hints = "kMdiMaximize";
173  else hints += " | kMdiMaximize";
174  }
175  if (fMdiHints & kMdiHelp) {
176  if (hints.Length() == 0) hints = "kMdiHelp";
177  else hints += " | kMdiHelp";
178  }
179  if (fMdiHints & kMdiMenu) {
180  if (hints.Length() == 0) hints = "kMdiMenu";
181  else hints += " | kMdiMenu";
182  }
183  }
184  return hints;
185 }
186 
187 ////////////////////////////////////////////////////////////////////////////////
188 /// Save a MDIframe as a C++ statement(s) on output stream out
189 
190 void TGMdiFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
191 {
192  char quote = '"';
193 
194  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
195 
197 
198  out << std::endl <<" // MDI frame "<< quote << GetWindowName() << quote << std::endl;
199  out << " TGMdiFrame *";
200  out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
201  << "," << GetWidth() + GetBorderWidth()*2
202  << "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;
203 
205  if (!GetOptions()) {
206  out << ");" << std::endl;
207  } else {
208  out << "," << GetOptionString() <<");" << std::endl;
209  }
210  } else {
211  out << "," << GetOptionString() << ",ucolor);" << std::endl;
212  }
213  if (option && strstr(option, "keep_names"))
214  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
215 
216  SavePrimitiveSubframes(out, option);
217 
218  out << " " << GetName() << "->SetWindowName(" << quote << GetWindowName()
219  << quote << ");" << std::endl;
220  out << " " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
221  << ");" << std::endl;
222  if ((GetX() != 5) && (GetY() != 23))
223  out << " " << GetName() << "->Move(" << GetX() << "," << GetY()
224  << ");" << std::endl;
225 
226  out << " " << GetName() << "->MapSubwindows();" << std::endl;
227  out << " " << GetName() << "->Layout();" << std::endl;
228 }
kMdiMinimize
@ kMdiMinimize
Definition: TGMdiMainFrame.h:62
TGMdiFrame::SetMdiHints
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
Definition: TGMdiFrame.cxx:93
TGFrame::fY
Int_t fY
Definition: TGFrame.h:111
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:250
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGMdiFrame::CloseWindow
virtual Bool_t CloseWindow()
Close MDI frame window.
Definition: TGMdiFrame.cxx:74
TGPicture
Definition: TGPicture.h:36
kMdiMaximize
@ kMdiMaximize
Definition: TGMdiMainFrame.h:63
TGMdiFrame.h
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGMdiFrame::fMdiHints
ULong_t fMdiHints
Definition: TGMdiFrame.h:60
TGMdiFrame::SetWindowName
void SetWindowName(const char *name)
Set MDI window name (set titlebar title).
Definition: TGMdiFrame.cxx:102
TGCompositeFrame::Cleanup
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:952
TGMdiFrame::TGMdiFrame
TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiFrame constructor.
Definition: TGMdiFrame.cxx:52
TGMdiMainFrame::UpdateWinListMenu
void UpdateWinListMenu()
Update MDI menu entries with current list of MDI child windows.
Definition: TGMdiMainFrame.cxx:523
TGMdiDecorFrame.h
TGMdiFrame::DontCallClose
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
Definition: TGMdiFrame.cxx:85
TGMdiFrame::GetMdiHintsString
TString GetMdiHintsString() const
Returns a MDI option string - used in SavePrimitive().
Definition: TGMdiFrame.cxx:145
x
Double_t x[n]
Definition: legend1.C:17
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TString
Definition: TString.h:136
TGMdiFrame::GetWindowIcon
const TGPicture * GetWindowIcon()
Return pointer to picture used as MDI window icon (on titlebar).
Definition: TGMdiFrame.cxx:128
kMdiHelp
@ kMdiHelp
Definition: TGMdiMainFrame.h:64
kOwnBackground
@ kOwnBackground
Definition: GuiTypes.h:391
TGMdiFrame::fMain
TGMdiMainFrame * fMain
Definition: TGMdiFrame.h:59
bool
TGCompositeFrame::SavePrimitiveSubframes
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxilary protected method used to save subframes.
Definition: TGFrame.cxx:2626
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
TGFrame::GetOptionString
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2465
TGFrame::GetOptions
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
TGMdiMainFrame::RemoveMdiFrame
Bool_t RemoveMdiFrame(TGMdiFrame *f)
Remove MDI child window.
Definition: TGMdiMainFrame.cxx:234
TGFrame::DeleteWindow
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:261
TGMdiMainFrame.h
TGMdiFrame::GetWindowName
const char * GetWindowName()
Return MDI window name.
Definition: TGMdiFrame.cxx:120
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
h
#define h(i)
Definition: RSha256.hxx:124
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:317
TGMdiFrame
Definition: TGMdiFrame.h:51
TGMdiMainFrame
Definition: TGMdiMainFrame.h:138
main
int main(int argc, char **argv)
Definition: histspeedtest.cxx:751
TGFrame::SaveUserColor
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2438
TGMdiDecorFrame::GetTitleBar
TGMdiTitleBar * GetTitleBar() const
Definition: TGMdiDecorFrame.h:317
y
Double_t y[n]
Definition: legend1.C:17
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGFrame::GetX
Int_t GetX() const
Definition: TGFrame.h:256
TGMdiFrame::~TGMdiFrame
virtual ~TGMdiFrame()
TGMdiFrame destructor.
Definition: TGMdiFrame.cxx:65
unsigned int
TGFrame::fX
Int_t fX
Definition: TGFrame.h:110
kMdiClose
@ kMdiClose
Definition: TGMdiMainFrame.h:58
kMdiSize
@ kMdiSize
Definition: TGMdiMainFrame.h:61
TGMdiMainFrame::AddMdiFrame
void AddMdiFrame(TGMdiFrame *f)
Add new MDI child window.
Definition: TGMdiMainFrame.cxx:193
TGFrame::GetBorderWidth
Int_t GetBorderWidth() const
Definition: TGFrame.h:258
TGMdiTitleBar
Definition: TGMdiDecorFrame.h:185
TGMdiFrameList::GetDecorFrame
TGMdiDecorFrame * GetDecorFrame() const
Definition: TGMdiMainFrame.h:107
kMdiRestore
@ kMdiRestore
Definition: TGMdiMainFrame.h:59
name
char name[80]
Definition: TGX11.cxx:110
TGFrame::GetY
Int_t GetY() const
Definition: TGFrame.h:257
kMdiFrame
@ kMdiFrame
Definition: GuiTypes.h:395
TGMdiFrame::kDontCallClose
@ kDontCallClose
Definition: TGMdiFrame.h:57
TGMdiFrame::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a MDIframe as a C++ statement(s) on output stream out.
Definition: TGMdiFrame.cxx:190
TGMdiFrame::Move
virtual void Move(Int_t x, Int_t y)
Move MDI window at position x, y.
Definition: TGMdiFrame.cxx:136
TGFrame::fBackground
Pixel_t fBackground
Definition: TGFrame.h:120
kMdiMenu
@ kMdiMenu
Definition: TGMdiMainFrame.h:65
TGCompositeFrame
Definition: TGFrame.h:324
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:36
TGMdiMainFrame::GetWindowList
TGMdiFrameList * GetWindowList(Int_t current=kFALSE) const
Definition: TGMdiMainFrame.h:211
TGMdiFrame::SetWindowIcon
void SetWindowIcon(const TGPicture *pic)
Set MDI window icon (titlebar icon).
Definition: TGMdiFrame.cxx:111
kMdiMove
@ kMdiMove
Definition: TGMdiMainFrame.h:60
kMdiDefaultHints
@ kMdiDefaultHints
Definition: TGMdiMainFrame.h:66
int
TGMdiDecorFrame
Definition: TGMdiDecorFrame.h:238