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 "TGFrame.h"
42#include "TGMdiFrame.h"
43#include "TGMdiMainFrame.h"
44#include "TGMdiDecorFrame.h"
45#include "Riostream.h"
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{
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
190void TGMdiFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
191{
192 char quote = '"';
193
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}
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
unsigned long ULong_t
Definition: RtypesCore.h:51
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
@ kMdiFrame
Definition: TGFrame.h:73
@ kOwnBackground
Definition: TGFrame.h:69
@ kMdiMinimize
@ kMdiMove
@ kMdiHelp
@ kMdiMenu
@ kMdiSize
@ kMdiRestore
@ kMdiMaximize
@ kMdiClose
@ kMdiDefaultHints
char name[80]
Definition: TGX11.cxx:109
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxilary protected method used to save subframes.
Definition: TGFrame.cxx:2623
Int_t fX
Definition: TGFrame.h:132
Int_t GetBorderWidth() const
Definition: TGFrame.h:280
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Int_t GetX() const
Definition: TGFrame.h:278
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
virtual UInt_t GetOptions() const
Definition: TGFrame.h:244
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2462
Int_t fY
Definition: TGFrame.h:133
UInt_t GetHeight() const
Definition: TGFrame.h:272
Int_t GetY() const
Definition: TGFrame.h:279
UInt_t GetWidth() const
Definition: TGFrame.h:271
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2435
Pixel_t fBackground
Definition: TGFrame.h:142
TGMdiTitleBar * GetTitleBar() const
TGMdiDecorFrame * GetDecorFrame() const
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
TGMdiMainFrame * fMain
Definition: TGMdiFrame.h:59
const TGPicture * GetWindowIcon()
Return pointer to picture used as MDI window icon (on titlebar).
Definition: TGMdiFrame.cxx:128
ULong_t fMdiHints
Definition: TGMdiFrame.h:60
TString GetMdiHintsString() const
Returns a MDI option string - used in SavePrimitive().
Definition: TGMdiFrame.cxx:145
virtual void Move(Int_t x, Int_t y)
Move MDI window at position x, y.
Definition: TGMdiFrame.cxx:136
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
Definition: TGMdiFrame.cxx:93
virtual Bool_t CloseWindow()
Close MDI frame window.
Definition: TGMdiFrame.cxx:74
void SetWindowIcon(const TGPicture *pic)
Set MDI window icon (titlebar icon).
Definition: TGMdiFrame.cxx:111
const char * GetWindowName()
Return MDI window name.
Definition: TGMdiFrame.cxx:120
@ kDontCallClose
Definition: TGMdiFrame.h:57
virtual ~TGMdiFrame()
TGMdiFrame destructor.
Definition: TGMdiFrame.cxx:65
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
Definition: TGMdiFrame.cxx:85
TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiFrame constructor.
Definition: TGMdiFrame.cxx:52
void SetWindowName(const char *name)
Set MDI window name (set titlebar title).
Definition: TGMdiFrame.cxx:102
void AddMdiFrame(TGMdiFrame *f)
Add new MDI child window.
TGMdiFrameList * GetWindowList(Int_t current=kFALSE) const
Bool_t RemoveMdiFrame(TGMdiFrame *f)
Remove MDI child window.
void UpdateWinListMenu()
Update MDI menu entries with current list of MDI child windows.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
const TGWindow * fParent
Definition: TGWindow.h:37
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
int main(int argc, char **argv)
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17