43class TGMdiTestSubclass {
48 TGMdiFrame *fMdiFrame;
49 TGCanvas *fCanvasWindow;
50 TGCompositeFrame *fContainer;
53 TGMdiTestSubclass(TGMdiMainFrame *
main,
int w,
int h);
55 TGMdiFrame *GetMdiFrame()
const {
return fMdiFrame; }
56 virtual Bool_t CloseWindow();
64 TGMdiFrame *fMdiFrame;
66 TGCheckButton *fClose, *fMenu, *fMin, *fMax, *fSize, *fHelp;
69 TGMdiHintTest(TGMdiMainFrame *
main,
int w,
int h);
72 void HandleText(const
char *);
81 TGMdiMainFrame *fMainFrame;
82 TGMdiMenuBar *fMenuBar;
83 TGLayoutHints *fMenuBarItemLayout;
84 TGPopupMenu *fMenuFile, *fMenuWindow, *fMenuHelp;
90 TGAppMainFrame(const TGWindow *p,
int w,
int h);
92 void HandleMenu(
Int_t id);
97TGAppMainFrame::TGAppMainFrame(const TGWindow *p,
int w,
int h)
100 fMenuBar =
new TGMdiMenuBar(fMain, 10, 10);
103 fMainFrame =
new TGMdiMainFrame(fMain, fMenuBar, 300, 300);
106 const TGPicture *pbg =
gClient->GetPicture(
"mditestbg.xpm");
110 TGMdiFrame *mdiFrame;
114 TGMdiTestSubclass *t =
new TGMdiTestSubclass(fMainFrame, 320, 240);
115 mdiFrame = t->GetMdiFrame();
124 gClient->GetColorByName(
"red", ic);
125 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 200,
127 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"&Press me!"), 1),
133 mdiFrame->
Move(150, 200);
137 gClient->GetColorByName(
"green", ic);
138 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 200,
kOwnBackground, ic);
139 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"Button 1"), 11),
141 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"Button 2"), 12),
147 mdiFrame->
Move(180, 220);
151 gClient->GetColorByName(
"blue", ic);
152 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 400,
kOwnBackground, ic);
154 TGListBox *fListBox =
new TGListBox(mdiFrame,1);
171 mdiFrame->
Move(400, 300);
178 new TGMdiHintTest(fMainFrame, 200, 200);
182 fMain->SetWindowName(
"MDI test");
183 fMain->SetClassHints(
"mdi test",
"mdi test");
188 fMain->Resize(640, 400);
190 fMain->MapSubwindows();
195void TGAppMainFrame::HandleMenu(
Int_t id)
201 new TGMdiFrame(fMainFrame, 200, 100);
220 case M_WINDOW_CASCADE:
224 case M_WINDOW_ARRANGE:
228 case M_WINDOW_OPAQUE:
244void TGAppMainFrame::InitMenu()
248 fMenuFile =
new TGPopupMenu(
gClient->GetRoot());
249 fMenuFile->
AddEntry(
new TGHotString(
"&New Window"), M_FILE_NEW);
250 fMenuFile->
AddEntry(
new TGHotString(
"&Close Window"), M_FILE_CLOSE);
252 fMenuFile->
AddEntry(
new TGHotString(
"E&xit"), M_FILE_EXIT);
254 fMenuWindow =
new TGPopupMenu(
gClient->GetRoot());
255 fMenuWindow->
AddEntry(
new TGHotString(
"Tile &Horizontally"), M_WINDOW_HOR);
256 fMenuWindow->
AddEntry(
new TGHotString(
"Tile &Vertically"), M_WINDOW_VERT);
257 fMenuWindow->
AddEntry(
new TGHotString(
"&Cascade"), M_WINDOW_CASCADE);
261 fMenuWindow->
AddEntry(
new TGHotString(
"&Arrange icons"), M_WINDOW_ARRANGE);
263 fMenuWindow->
AddEntry(
new TGHotString(
"&Opaque resize"), M_WINDOW_OPAQUE);
267 fMenuHelp =
new TGPopupMenu(
gClient->GetRoot());
268 fMenuHelp->
AddEntry(
new TGHotString(
"&Contents"), M_HELP_CONTENTS);
270 fMenuHelp->
AddEntry(
new TGHotString(
"&About"), M_HELP_ABOUT);
276 fMenuFile->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
277 "HandleMenu(Int_t)");
278 fMenuWindow->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
279 "HandleMenu(Int_t)");
280 fMenuHelp->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
281 "HandleMenu(Int_t)");
283 fMenuBar->
AddPopup(
new TGHotString(
"&File"), fMenuFile, fMenuBarItemLayout);
284 fMenuBar->
AddPopup(
new TGHotString(
"&Windows"),fMenuWindow,fMenuBarItemLayout);
285 fMenuBar->
AddPopup(
new TGHotString(
"&Help"), fMenuHelp, fMenuBarItemLayout);
288void TGAppMainFrame::CloseWindow()
295TGMdiTestSubclass::TGMdiTestSubclass(TGMdiMainFrame *
main,
int w,
int h)
297 fMdiFrame =
new TGMdiFrame(
main,
w,
h);
298 fMdiFrame->Connect(
"CloseWindow()",
"TGMdiTestSubclass",
this,
"CloseWindow()");
299 fMdiFrame->DontCallClose();
301 fCanvasWindow =
new TGCanvas(fMdiFrame, 400, 240);
302 fContainer =
new TGCompositeFrame(fCanvasWindow->GetViewPort(), 10, 10,
304 fMdiFrame->GetWhitePixel());
305 fContainer->SetLayoutManager(
new TGTileLayout(fContainer, 8));
306 fCanvasWindow->SetContainer(fContainer);
308 for (
int i = 0;
i < 256; ++
i)
309 fCanvasWindow->AddFrame(
new TGFrame(fCanvasWindow->GetContainer(),
315 fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"ofolder_t.xpm"));
318Bool_t TGMdiTestSubclass::CloseWindow()
322 new TGMsgBox(
gClient->GetRoot(), fMdiFrame,
323 fMdiFrame->GetWindowName(),
"Really want to close the window?",
326 if (ret ==
kMBYes)
return fMdiFrame->CloseWindow();
334TGMdiHintTest::TGMdiHintTest(TGMdiMainFrame *
main,
int w,
int h)
336 fMdiFrame =
new TGMdiFrame(
main,
w,
h);
338 fClose =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Close"), 11);
339 fMenu =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Menu (left icon)"), 12);
340 fMin =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Minimize"), 13);
341 fMax =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Maximize"), 14);
342 fSize =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Resize"), 15);
343 fHelp =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Help"), 16);
347 fMdiFrame->AddFrame(fClose, lh);
348 fMdiFrame->AddFrame(fMenu, lh);
349 fMdiFrame->AddFrame(fMin, lh);
350 fMdiFrame->AddFrame(fMax, lh);
351 fMdiFrame->AddFrame(fSize, lh);
352 fMdiFrame->AddFrame(fHelp, lh);
360 fClose->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
361 fMenu->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
362 fMin->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
363 fMax->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
364 fSize->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
365 fHelp->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
367 fWName =
new TGTextEntry(fMdiFrame, (
const char *)
"", 20);
372 fWName->
Connect(
"TextChanged(char*)",
"TGMdiHintTest",
this,
"HandleText(char*)");
377 fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"app_t.xpm"));
379 fMdiFrame->MapSubwindows();
383void TGMdiHintTest::HandleButtons()
394 fMdiFrame->SetMdiHints(hints);
397void TGMdiHintTest::HandleText(
const char *)
404 new TGAppMainFrame(
gClient->GetRoot(), 640, 400);
410int main(
int argc,
char **argv)
412 TApplication theApp(
"MdiTest", &argc, argv);
#define RQ_OBJECT(sender_class)
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void Layout() override
Layout the elements of the composite frame.
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
virtual void SetMultipleSelections(Bool_t multi=kTRUE)
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.
Bool_t SetCurrent(TGMdiFrameList *newcurrent)
Set current (active) MDI child window (by frame list).
void SetResizeMode(Int_t mode=kMdiDefaultResizeMode)
Set MDI windows resize mode (opaque or transparent).
TGMdiFrame * GetCurrent() const
Return pointer on current (active) MDI child window.
virtual void ArrangeMinimized()
This is an attempt to an "smart" minimized window re-arrangement.
TGPopupMenu * GetWinListMenu() const
virtual void TileHorizontal()
virtual void TileVertical()
virtual Int_t Close(TGMdiFrame *frame)
Close MDI child window mdiframe.
TGFrame * GetContainer() const
Pixmap_t GetPicture() const
void AddText(Int_t pos, const char *text)
const char * GetString() const
TGTextBuffer * GetBuffer() const
virtual void SetBackgroundPixmap(Pixmap_t pixmap)
set background pixmap
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.