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 /** \class TGMdiFrame.
35 \ingroup guiwidgets
36 
37 This file contains the TGMdiFrame class.
38 
39 */
40 
41 
42 #include "TGMdiFrame.h"
43 #include "TGMdiMainFrame.h"
44 #include "TGMdiDecorFrame.h"
45 
46 #include <iostream>
47 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// TGMdiFrame constructor.
52 
54  Pixel_t back) :
55  TGCompositeFrame(main->GetContainer(), w, h,
56  options | kOwnBackground | kMdiFrame, back)
57 {
58  fMain = main;
59  fMain->AddMdiFrame(this); // this reparents the window
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// TGMdiFrame destructor.
65 
67 {
68  Cleanup();
69  fMain->RemoveMdiFrame(this);
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Close MDI frame window.
74 
76 {
77  DeleteWindow();
78  return kTRUE;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Typically call this method in the slot connected to the CloseWindow()
83 /// signal to prevent the calling of the default or any derived CloseWindow()
84 /// methods to prevent premature or double deletion of this window.
85 
87 {
89 }
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// Set MDI hints, also used to identify titlebar buttons.
93 
95 {
96  fMdiHints = mdihints;
97  ((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
98 }
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Set MDI window name (set titlebar title).
102 
104 {
105  ((TGMdiDecorFrame *)fParent)->SetWindowName(name);
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 /// Set MDI window icon (titlebar icon).
111 
113 {
114  ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Return MDI window name.
120 
122 {
123  return ((TGMdiDecorFrame *)fParent)->GetWindowName();
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Return pointer to picture used as MDI window icon (on titlebar).
128 
130 {
131  return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
132 }
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// Move MDI window at position x, y.
136 
138 {
139  ((TGMdiDecorFrame *)fParent)->Move(x, y);
140  fX = x; fY = y;
141 }
142 
143 ////////////////////////////////////////////////////////////////////////////////
144 /// Returns a MDI option string - used in SavePrimitive().
145 
147 {
148  TString hints;
150  hints = "kMdiDefaultHints";
151  else {
152  if (fMdiHints & kMdiClose) {
153  if (hints.Length() == 0) hints = "kMdiClose";
154  else hints += " | kMdiClose";
155  }
156  if (fMdiHints & kMdiRestore) {
157  if (hints.Length() == 0) hints = "kMdiRestore";
158  else hints += " | kMdiRestore";
159  }
160  if (fMdiHints & kMdiMove) {
161  if (hints.Length() == 0) hints = "kMdiMove";
162  else hints += " | kMdiMove";
163  }
164  if (fMdiHints & kMdiSize) {
165  if (hints.Length() == 0) hints = "kMdiSize";
166  else hints += " | kMdiSize";
167  }
168  if (fMdiHints & kMdiMinimize) {
169  if (hints.Length() == 0) hints = "kMdiMinimize";
170  else hints += " | kMdiMinimize";
171  }
172  if (fMdiHints & kMdiMaximize) {
173  if (hints.Length() == 0) hints = "kMdiMaximize";
174  else hints += " | kMdiMaximize";
175  }
176  if (fMdiHints & kMdiHelp) {
177  if (hints.Length() == 0) hints = "kMdiHelp";
178  else hints += " | kMdiHelp";
179  }
180  if (fMdiHints & kMdiMenu) {
181  if (hints.Length() == 0) hints = "kMdiMenu";
182  else hints += " | kMdiMenu";
183  }
184  }
185  return hints;
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Save a MDIframe as a C++ statement(s) on output stream out
190 
191 void TGMdiFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
192 {
193  char quote = '"';
194 
195  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
196 
198 
199  out << std::endl <<" // MDI frame "<< quote << GetWindowName() << quote << std::endl;
200  out << " TGMdiFrame *";
201  out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
202  << "," << GetWidth() + GetBorderWidth()*2
203  << "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;
204 
206  if (!GetOptions()) {
207  out << ");" << std::endl;
208  } else {
209  out << "," << GetOptionString() <<");" << std::endl;
210  }
211  } else {
212  out << "," << GetOptionString() << ",ucolor);" << std::endl;
213  }
214  if (option && strstr(option, "keep_names"))
215  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
216 
217  SavePrimitiveSubframes(out, option);
218 
219  out << " " << GetName() << "->SetWindowName(" << quote << GetWindowName()
220  << quote << ");" << std::endl;
221  out << " " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
222  << ");" << std::endl;
223  if ((GetX() != 5) && (GetY() != 23))
224  out << " " << GetName() << "->Move(" << GetX() << "," << GetY()
225  << ");" << std::endl;
226 
227  out << " " << GetName() << "->MapSubwindows();" << std::endl;
228  out << " " << GetName() << "->Layout();" << std::endl;
229 }
kMdiMinimize
@ kMdiMinimize
Definition: TGMdiMainFrame.h:55
TGMdiFrame::SetMdiHints
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
Definition: TGMdiFrame.cxx:94
TGFrame::fY
Int_t fY
Definition: TGFrame.h:86
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:225
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:95
TGMdiFrame::CloseWindow
virtual Bool_t CloseWindow()
Close MDI frame window.
Definition: TGMdiFrame.cxx:75
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
kMdiMaximize
@ kMdiMaximize
Definition: TGMdiMainFrame.h:56
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGMdiFrame.h
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGMdiFrame::fMdiHints
ULong_t fMdiHints
Definition: TGMdiFrame.h:53
TGMdiFrame::kDontCallClose
@ kDontCallClose
Definition: TGMdiFrame.h:50
TGMdiFrame::SetWindowName
void SetWindowName(const char *name)
Set MDI window name (set titlebar title).
Definition: TGMdiFrame.cxx:103
TGCompositeFrame::Cleanup
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:967
TGMdiFrame::TGMdiFrame
TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiFrame constructor.
Definition: TGMdiFrame.cxx:53
TGMdiMainFrame::UpdateWinListMenu
void UpdateWinListMenu()
Update MDI menu entries with current list of MDI child windows.
Definition: TGMdiMainFrame.cxx:524
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:86
TGMdiFrame::GetMdiHintsString
TString GetMdiHintsString() const
Returns a MDI option string - used in SavePrimitive().
Definition: TGMdiFrame.cxx:146
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:683
TString
Basic string class.
Definition: TString.h:136
TGMdiFrame::GetWindowIcon
const TGPicture * GetWindowIcon()
Return pointer to picture used as MDI window icon (on titlebar).
Definition: TGMdiFrame.cxx:129
kMdiHelp
@ kMdiHelp
Definition: TGMdiMainFrame.h:57
kOwnBackground
@ kOwnBackground
Definition: GuiTypes.h:391
TGMdiFrame::fMain
TGMdiMainFrame * fMain
Definition: TGMdiFrame.h:52
bool
TGCompositeFrame::SavePrimitiveSubframes
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxiliary protected method used to save subframes.
Definition: TGFrame.cxx:2641
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:224
TGFrame::GetOptionString
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2480
TGFrame::GetOptions
virtual UInt_t GetOptions() const
Definition: TGFrame.h:197
TGMdiMainFrame::RemoveMdiFrame
Bool_t RemoveMdiFrame(TGMdiFrame *f)
Remove MDI child window.
Definition: TGMdiMainFrame.cxx:235
TGFrame::DeleteWindow
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:276
TGMdiMainFrame.h
TGMdiFrame::GetWindowName
const char * GetWindowName()
Return MDI window name.
Definition: TGMdiFrame.cxx:121
h
#define h(i)
Definition: RSha256.hxx:106
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:336
TGMdiFrame
This file contains the TGMdiFrame class.
Definition: TGMdiFrame.h:44
TGMdiMainFrame
This file contains the TGMdiMainFrame class.
Definition: TGMdiMainFrame.h:131
TGFrame::SaveUserColor
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2453
TGMdiDecorFrame::GetTitleBar
TGMdiTitleBar * GetTitleBar() const
Definition: TGMdiDecorFrame.h:308
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:231
TGMdiFrame::~TGMdiFrame
virtual ~TGMdiFrame()
TGMdiFrame destructor.
Definition: TGMdiFrame.cxx:66
unsigned int
TGFrame::fX
Int_t fX
Definition: TGFrame.h:85
kMdiClose
@ kMdiClose
Definition: TGMdiMainFrame.h:51
kMdiSize
@ kMdiSize
Definition: TGMdiMainFrame.h:54
TGMdiMainFrame::AddMdiFrame
void AddMdiFrame(TGMdiFrame *f)
Add new MDI child window.
Definition: TGMdiMainFrame.cxx:194
TGFrame::GetBorderWidth
Int_t GetBorderWidth() const
Definition: TGFrame.h:233
TGMdiTitleBar
Definition: TGMdiDecorFrame.h:176
TGMdiFrameList::GetDecorFrame
TGMdiDecorFrame * GetDecorFrame() const
Definition: TGMdiMainFrame.h:100
kMdiRestore
@ kMdiRestore
Definition: TGMdiMainFrame.h:52
name
char name[80]
Definition: TGX11.cxx:110
TGFrame::GetY
Int_t GetY() const
Definition: TGFrame.h:232
kMdiFrame
@ kMdiFrame
Definition: GuiTypes.h:395
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:191
TGMdiFrame::Move
virtual void Move(Int_t x, Int_t y)
Move MDI window at position x, y.
Definition: TGMdiFrame.cxx:137
TGFrame::fBackground
Pixel_t fBackground
Definition: TGFrame.h:95
kMdiMenu
@ kMdiMenu
Definition: TGMdiMainFrame.h:58
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:28
TGMdiMainFrame::GetWindowList
TGMdiFrameList * GetWindowList(Int_t current=kFALSE) const
Definition: TGMdiMainFrame.h:204
TGMdiFrame::SetWindowIcon
void SetWindowIcon(const TGPicture *pic)
Set MDI window icon (titlebar icon).
Definition: TGMdiFrame.cxx:112
kMdiMove
@ kMdiMove
Definition: TGMdiMainFrame.h:53
kMdiDefaultHints
@ kMdiDefaultHints
Definition: TGMdiMainFrame.h:59
main
int main(int argc, char *argv[])
Definition: cef_main.cxx:54
int
TGMdiDecorFrame
This file contains all different MDI frame decoration classes.
Definition: TGMdiDecorFrame.h:229