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
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
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
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);
105 fMain->UpdateWinListMenu();
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Set MDI window icon (titlebar icon).
110
112{
113 ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
114 fMain->UpdateWinListMenu();
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 // save options and custom color if not default
193 auto extra_args = SaveCtorArgs(out);
194
195 TGMdiTitleBar *tb = fMain->GetWindowList()->GetDecorFrame()->GetTitleBar();
196
197 out << "\n // MDI frame \"" << GetWindowName() << "\"\n";
198 out << " TGMdiFrame *" << GetName() << " = new TGMdiFrame(" << fMain->GetName() << ","
199 << GetWidth() + GetBorderWidth() * 2 << "," << GetHeight() + tb->GetHeight() + GetBorderWidth() * 2 << extra_args
200 << ");\n";
201
202 if (option && strstr(option, "keep_names"))
203 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
204
205 SavePrimitiveSubframes(out, option);
206
207 out << " " << GetName() << "->SetWindowName(\"" << TString(GetWindowName()).ReplaceSpecialCppChars() << "\");\n";
208 out << " " << GetName() << "->SetMdiHints(" << GetMdiHintsString() << ");\n";
209 if ((GetX() != 5) && (GetY() != 23))
210 out << " " << GetName() << "->Move(" << GetX() << "," << GetY() << ");\n";
211
212 out << " " << GetName() << "->MapSubwindows();\n";
213 out << " " << GetName() << "->Layout();\n";
214}
@ kMdiFrame
Definition GuiTypes.h:396
@ kOwnBackground
Definition GuiTypes.h:392
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
@ kMdiMinimize
@ kMdiMove
@ kMdiHelp
@ kMdiMenu
@ kMdiSize
@ kMdiRestore
@ kMdiMaximize
@ kMdiClose
@ kMdiDefaultHints
char name[80]
Definition TGX11.cxx:148
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxiliary protected method used to save subframes.
Definition TGFrame.cxx:2641
TGCompositeFrame(const TGCompositeFrame &)=delete
Int_t fX
frame x position
Definition TGFrame.h:85
Int_t GetBorderWidth() const
Definition TGFrame.h:235
Int_t GetX() const
Definition TGFrame.h:233
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
Int_t fY
frame y position
Definition TGFrame.h:86
UInt_t GetHeight() const
Definition TGFrame.h:227
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
Int_t GetY() const
Definition TGFrame.h:234
UInt_t GetWidth() const
Definition TGFrame.h:226
TGMdiMainFrame * fMain
pointer to the MDI main frame
Definition TGMdiFrame.h:50
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:51
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a MDIframe as a C++ statement(s) on output stream out.
TString GetMdiHintsString() const
Returns a MDI option string - used in SavePrimitive().
friend class TGMdiMainFrame
Definition TGMdiFrame.h:44
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
void SetWindowName(const char *name) override
Set MDI window name (set titlebar title).
void Move(Int_t x, Int_t y) override
Move MDI window at position x, y.
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.
friend class TGMdiDecorFrame
Definition TGMdiFrame.h:45
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.
~TGMdiFrame() override
TGMdiFrame destructor.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
int main(int argc, char **argv)
Definition hadd.cxx:631
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17