Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGMdiMenu.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 TGMdiMenu.
35 \ingroup guiwidgets
36
37This file contains the TGMdiMenuBar class.
38
39*/
40
41
42#include "TGMdi.h"
43#include "TGMdiMenu.h"
44#include "TList.h"
45
46#include <iostream>
47
48
50
51////////////////////////////////////////////////////////////////////////////////
52/// TGMdiMenuBar constructor.
53
56{
61
62 fLeft = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
63 fBar = new TGMenuBar(this, 1, 20, kHorizontalFrame);
64 fRight = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
65
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// TGMdiMenuBar destructor.
73
75{
76 if (!MustCleanup()) {
77 delete fLHint;
78 delete fLeftHint;
79 delete fRightHint;
80 delete fBarHint;
81 }
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Add popup menu to the MDI menu bar with layout hints l.
86
88{
89 fBar->AddPopup(s, menu, l);
90 // Layout();
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// This is called from TGMdiMainFrame on Maximize().
95
97{
98 // Hide all frames first
100 TIter nextl(fLeft->GetList());
101 while ((el = (TGFrameElement *) nextl())) {
102 fLeft->HideFrame(el->fFrame);
103 }
104 TIter nextr(fRight->GetList());
105 while ((el = (TGFrameElement *) nextr())) {
106 fRight->HideFrame(el->fFrame);
107 }
108 // Then add specified frames
109 icon->ReparentWindow(fLeft);
110 buttons->ReparentWindow(fRight);
111 fLeft->AddFrame(icon, fLHint);
112 fRight->AddFrame(buttons, fLHint);
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// This is called from TGMdiMainFrame on Restore()
117
119{
120 // Remove specified frames
121 fLeft->RemoveFrame(icon);
122 fRight->RemoveFrame(buttons);
123 // Then show (restore) last frames
124 TGFrameElement *el;
125 el = (TGFrameElement *)fLeft->GetList()->Last();
126 if (el)
127 fLeft->ShowFrame(el->fFrame);
128 el = (TGFrameElement *)fRight->GetList()->Last();
129 if (el)
130 fRight->ShowFrame(el->fFrame);
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// This is called from TGMdiMainFrame on Maximize().
135
137{
138 // Hide all frames first
139 TGFrameElement *el;
140 TIter nextl(fLeft->GetList());
141 while ((el = (TGFrameElement *) nextl())) {
142 fLeft->HideFrame(el->fFrame);
143 }
144 TIter nextr(fRight->GetList());
145 while ((el = (TGFrameElement *) nextr())) {
146 fRight->HideFrame(el->fFrame);
147 }
148 // Then show specified frames
149 fLeft->ShowFrame(icon);
150 fRight->ShowFrame(buttons);
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Used to hide specific frames from menu bar
155
157{
158 // Hide specified frames
159 fLeft->HideFrame(icon);
160 fRight->HideFrame(buttons);
161
162 // Then show (restore) last frames
163 TGFrameElement *el;
164 el = (TGFrameElement *)fLeft->GetList()->Last();
165 if (el)
166 fLeft->ShowFrame(el->fFrame);
167 el = (TGFrameElement *)fRight->GetList()->Last();
168 if (el)
169 fRight->ShowFrame(el->fFrame);
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Save a MDI menu as a C++ statement(s) on output stream out
174
175void TGMdiMenuBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
176{
177 out << std::endl;
178 out << " // MDI menu bar" << std::endl;
179
180 out << " TGMdiMenuBar *";
181 out << GetName() << " = new TGMdiMenuBar(" << fParent->GetName()
182 << "," << GetWidth() << "," << GetHeight() << ");" << std::endl;
183 if (option && strstr(option, "keep_names"))
184 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
185
186 if (!fList) return;
187
188 out << " TGMenuBar *" << fBar->GetName() << " = " << GetName()
189 << "->GetMenuBar();" << std::endl;
190
191 TGFrameElement *el;
192 TIter next(fBar->GetList());
193
194 while ((el = (TGFrameElement *)next())) {
195 el->fFrame->SavePrimitive(out, option);
196 el->fLayout->SavePrimitive(out, option);
197 out << ");" << std::endl;
198 }
199}
@ kHorizontalFrame
Definition GuiTypes.h:382
#define h(i)
Definition RSha256.hxx:106
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
Int_t MustCleanup() const override
Definition TGFrame.h:360
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
TList * fList
container of frame elements
Definition TGFrame.h:292
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
TGLayoutHints * fLayout
Definition TGLayout.h:114
TGFrame * fFrame
Definition TGLayout.h:112
void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0) override
Reparent window, make p the new parent and position the window at position (x,y) in new parent.
Definition TGFrame.h:202
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3233
UInt_t GetHeight() const
Definition TGFrame.h:225
UInt_t GetWidth() const
Definition TGFrame.h:224
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save layout hints as a C++ statement(s) on output stream out.
Definition TGLayout.cxx:975
void HideFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
Used to hide specific frames from menu bar.
TGMenuBar * fBar
standard menu bar
Definition TGMdiMenu.h:52
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a MDI menu as a C++ statement(s) on output stream out.
TGCompositeFrame * fLeft
Definition TGMdiMenu.h:51
void ShowFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Maximize().
void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Maximize().
Definition TGMdiMenu.cxx:96
TGLayoutHints * fLHint
Definition TGMdiMenu.h:53
TGLayoutHints * fRightHint
Definition TGMdiMenu.h:54
TGLayoutHints * fBarHint
right layout hints
Definition TGMdiMenu.h:54
void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l)
Add popup menu to the MDI menu bar with layout hints l.
Definition TGMdiMenu.cxx:87
TGLayoutHints * fLeftHint
left layout hints
Definition TGMdiMenu.h:53
TGMdiMenuBar(const TGWindow *p, Int_t w=1, Int_t h=20)
TGMdiMenuBar constructor.
Definition TGMdiMenu.cxx:54
TGCompositeFrame * fRight
left and right parts of MDI menu bar
Definition TGMdiMenu.h:51
~TGMdiMenuBar() override
TGMdiMenuBar destructor.
Definition TGMdiMenu.cxx:74
void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Restore()
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:418
This class creates a popup menu object.
Definition TGMenu.h:110
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:691
TLine l
Definition textangle.C:4