Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
37This 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{
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
191void TGMdiFrame::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
192{
193 char quote = '"';
194
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}
@ kMdiFrame
Definition GuiTypes.h:395
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int main()
Definition Prototype.cxx:12
#define h(i)
Definition RSha256.hxx:106
unsigned long ULong_t
Definition RtypesCore.h:55
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
@ kMdiMinimize
@ kMdiMove
@ kMdiHelp
@ kMdiMenu
@ kMdiSize
@ kMdiRestore
@ kMdiMaximize
@ kMdiClose
@ kMdiDefaultHints
char name[80]
Definition TGX11.cxx:110
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxiliary protected method used to save subframes.
Definition TGFrame.cxx:2665
Int_t fX
frame x position
Definition TGFrame.h:85
Int_t GetBorderWidth() const
Definition TGFrame.h:233
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
Int_t GetX() const
Definition TGFrame.h:231
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2504
Int_t fY
frame y position
Definition TGFrame.h:86
UInt_t GetHeight() const
Definition TGFrame.h:225
Int_t GetY() const
Definition TGFrame.h:232
UInt_t GetWidth() const
Definition TGFrame.h:224
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2477
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
This file contains all different MDI frame decoration classes.
TGMdiTitleBar * GetTitleBar() const
TGMdiDecorFrame * GetDecorFrame() const
This file contains the TGMdiFrame class.
Definition TGMdiFrame.h:44
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a MDIframe as a C++ statement(s) on output stream out.
TGMdiMainFrame * fMain
pointer to the MDI main frame
Definition TGMdiFrame.h:52
const TGPicture * GetWindowIcon()
Return pointer to picture used as MDI window icon (on titlebar).
ULong_t fMdiHints
MDI hints, also used to identify titlebar buttons.
Definition TGMdiFrame.h:53
TString GetMdiHintsString() const
Returns a MDI option string - used in SavePrimitive().
virtual void Move(Int_t x, Int_t y)
Move MDI window at position x, y.
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
virtual Bool_t CloseWindow()
Close MDI frame window.
void SetWindowIcon(const TGPicture *pic)
Set MDI window icon (titlebar icon).
const char * GetWindowName()
Return MDI window name.
virtual ~TGMdiFrame()
TGMdiFrame destructor.
void DontCallClose()
Typically call this method in the slot connected to the CloseWindow() signal to prevent the calling o...
TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiFrame constructor.
void SetWindowName(const char *name)
Set MDI window name (set titlebar title).
This file contains the TGMdiMainFrame class.
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.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:766
Basic string class.
Definition TString.h:136
Ssiz_t Length() const
Definition TString.h:410
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17