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// //
35// TGMdiMenu. //
36// //
37// This file contains the TGMdiMenuBar class. //
38// //
39//////////////////////////////////////////////////////////////////////////
40
41#include "TGMdi.h"
42#include "TGMdiMenu.h"
43#include "TList.h"
44
45#include <iostream>
46
47
49
50////////////////////////////////////////////////////////////////////////////////
51/// TGMdiMenuBar constructor.
52
53TGMdiMenuBar::TGMdiMenuBar(const TGWindow *p, int w, int h) :
55{
60
61 fLeft = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
62 fBar = new TGMenuBar(this, 1, 20, kHorizontalFrame);
63 fRight = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
64
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// TGMdiMenuBar destructor.
72
74{
75 if (!MustCleanup()) {
76 delete fLHint;
77 delete fLeftHint;
78 delete fRightHint;
79 delete fBarHint;
80 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Add popup menu to the MDI menu bar with layout hints l.
85
87{
88 fBar->AddPopup(s, menu, l);
89 // Layout();
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// This is called from TGMdiMainFrame on Maximize().
94
96{
97 // Hide all frames first
99 TIter nextl(fLeft->GetList());
100 while ((el = (TGFrameElement *) nextl())) {
101 fLeft->HideFrame(el->fFrame);
102 }
103 TIter nextr(fRight->GetList());
104 while ((el = (TGFrameElement *) nextr())) {
105 fRight->HideFrame(el->fFrame);
106 }
107 // Then add specified frames
108 icon->ReparentWindow(fLeft);
109 buttons->ReparentWindow(fRight);
110 fLeft->AddFrame(icon, fLHint);
111 fRight->AddFrame(buttons, fLHint);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// This is called from TGMdiMainFrame on Restore()
116
118{
119 // Remove specified frames
120 fLeft->RemoveFrame(icon);
121 fRight->RemoveFrame(buttons);
122 // Then show (restore) last frames
123 TGFrameElement *el;
124 el = (TGFrameElement *)fLeft->GetList()->Last();
125 if (el)
126 fLeft->ShowFrame(el->fFrame);
127 el = (TGFrameElement *)fRight->GetList()->Last();
128 if (el)
129 fRight->ShowFrame(el->fFrame);
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// This is called from TGMdiMainFrame on Maximize().
134
136{
137 // Hide all frames first
138 TGFrameElement *el;
139 TIter nextl(fLeft->GetList());
140 while ((el = (TGFrameElement *) nextl())) {
141 fLeft->HideFrame(el->fFrame);
142 }
143 TIter nextr(fRight->GetList());
144 while ((el = (TGFrameElement *) nextr())) {
145 fRight->HideFrame(el->fFrame);
146 }
147 // Then show specified frames
148 fLeft->ShowFrame(icon);
149 fRight->ShowFrame(buttons);
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Used to hide specific frames from menu bar
154
156{
157 // Hide specified frames
158 fLeft->HideFrame(icon);
159 fRight->HideFrame(buttons);
160
161 // Then show (restore) last frames
162 TGFrameElement *el;
163 el = (TGFrameElement *)fLeft->GetList()->Last();
164 if (el)
165 fLeft->ShowFrame(el->fFrame);
166 el = (TGFrameElement *)fRight->GetList()->Last();
167 if (el)
168 fRight->ShowFrame(el->fFrame);
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Save a MDI menu as a C++ statement(s) on output stream out
173
174void TGMdiMenuBar::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
175{
176 out << std::endl;
177 out << " // MDI menu bar" << std::endl;
178
179 out << " TGMdiMenuBar *";
180 out << GetName() << " = new TGMdiMenuBar(" << fParent->GetName()
181 << "," << GetWidth() << "," << GetHeight() << ");" << std::endl;
182 if (option && strstr(option, "keep_names"))
183 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
184
185 if (!fList) return;
186
187 out << " TGMenuBar *" << fBar->GetName() << " = " << GetName()
188 << "->GetMenuBar();" << std::endl;
189
190 TGFrameElement *el;
191 TIter next(fBar->GetList());
192
193 while ((el = (TGFrameElement *)next())) {
194 el->fFrame->SavePrimitive(out, option);
195 el->fLayout->SavePrimitive(out, option);
196 out << ");" << std::endl;
197 }
198}
@ 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:364
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsCenterY
Definition TGLayout.h:35
@ kLHintsNormal
Definition TGLayout.h:39
@ kLHintsExpandX
Definition TGLayout.h:37
virtual TList * GetList() const
Definition TGFrame.h:346
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual Int_t MustCleanup() const
Definition TGFrame.h:397
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1189
TList * fList
Definition TGFrame.h:328
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1134
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1175
TGLayoutHints * fLayout
Definition TGLayout.h:121
TGFrame * fFrame
Definition TGLayout.h:119
virtual void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0)
Reparent window, make p the new parent and position the window at position (x,y) in new parent.
Definition TGFrame.h:226
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a frame widget as a C++ statement(s) on output stream out.
Definition TGFrame.cxx:3192
UInt_t GetHeight() const
Definition TGFrame.h:249
UInt_t GetWidth() const
Definition TGFrame.h:248
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
void HideFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
Used to hide specific frames from menu bar.
TGMenuBar * fBar
Definition TGMdiMenu.h:59
TGCompositeFrame * fLeft
Definition TGMdiMenu.h:58
virtual ~TGMdiMenuBar()
TGMdiMenuBar destructor.
Definition TGMdiMenu.cxx:73
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:95
TGLayoutHints * fLHint
Definition TGMdiMenu.h:60
TGLayoutHints * fRightHint
Definition TGMdiMenu.h:61
TGLayoutHints * fBarHint
Definition TGMdiMenu.h:61
void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l)
Add popup menu to the MDI menu bar with layout hints l.
Definition TGMdiMenu.cxx:86
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a MDI menu as a C++ statement(s) on output stream out.
TGLayoutHints * fLeftHint
Definition TGMdiMenu.h:60
TGMdiMenuBar(const TGWindow *p, Int_t w=1, Int_t h=20)
TGMdiMenuBar constructor.
Definition TGMdiMenu.cxx:53
TGCompositeFrame * fRight
Definition TGMdiMenu.h:58
void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Restore()
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition TGMenu.cxx:417
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:335
const TGWindow * fParent
Definition TGWindow.h:36
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:693
auto * l
Definition textangle.C:4