42class TGMdiTestSubclass {
47 TGMdiFrame *fMdiFrame;
48 TGCanvas *fCanvasWindow;
49 TGCompositeFrame *fContainer;
52 TGMdiTestSubclass(TGMdiMainFrame *
main,
int w,
int h);
54 TGMdiFrame *GetMdiFrame()
const {
return fMdiFrame; }
55 virtual Bool_t CloseWindow();
63 TGMdiFrame *fMdiFrame;
65 TGCheckButton *fClose, *fMenu, *fMin, *fMax, *fSize, *fHelp;
68 TGMdiHintTest(TGMdiMainFrame *
main,
int w,
int h);
71 void HandleText(const
char *);
80 TGMdiMainFrame *fMainFrame;
81 TGMdiMenuBar *fMenuBar;
82 TGLayoutHints *fMenuBarItemLayout;
83 TGPopupMenu *fMenuFile, *fMenuWindow, *fMenuHelp;
89 TGAppMainFrame(const TGWindow *p,
int w,
int h);
91 void HandleMenu(
Int_t id);
96TGAppMainFrame::TGAppMainFrame(const TGWindow *p,
int w,
int h)
99 fMenuBar =
new TGMdiMenuBar(fMain, 10, 10);
102 fMainFrame =
new TGMdiMainFrame(fMain, fMenuBar, 300, 300);
105 const TGPicture *pbg =
gClient->GetPicture(
"mditestbg.xpm");
109 TGMdiFrame *mdiFrame;
113 TGMdiTestSubclass *t =
new TGMdiTestSubclass(fMainFrame, 320, 240);
114 mdiFrame = t->GetMdiFrame();
123 gClient->GetColorByName(
"red", ic);
124 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 200,
kOwnBackground, ic);
125 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"&Press me!"), 1),
131 mdiFrame->
Move(150, 200);
135 gClient->GetColorByName(
"green", ic);
136 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 200,
kOwnBackground, ic);
137 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"Button 1"), 11),
139 mdiFrame->
AddFrame(
new TGTextButton(mdiFrame,
new TGHotString(
"Button 2"), 12),
145 mdiFrame->
Move(180, 220);
149 gClient->GetColorByName(
"blue", ic);
150 mdiFrame =
new TGMdiFrame(fMainFrame, 200, 400,
kOwnBackground, ic);
152 TGListBox *fListBox =
new TGListBox(mdiFrame, 1);
162 fListBox->
Resize(100, 70);
167 mdiFrame->
Move(400, 300);
174 new TGMdiHintTest(fMainFrame, 200, 200);
178 fMain->SetWindowName(
"MDI test");
179 fMain->SetClassHints(
"mdi test",
"mdi test");
184 fMain->Resize(640, 400);
186 fMain->MapSubwindows();
191void TGAppMainFrame::HandleMenu(
Int_t id)
196 case M_FILE_NEW:
new TGMdiFrame(fMainFrame, 200, 100);
break;
200 case M_FILE_EXIT: CloseWindow();
break;
206 case M_WINDOW_CASCADE: fMainFrame->
Cascade();
break;
210 case M_WINDOW_OPAQUE:
224void TGAppMainFrame::InitMenu()
228 fMenuFile =
new TGPopupMenu(
gClient->GetRoot());
229 fMenuFile->
AddEntry(
new TGHotString(
"&New Window"), M_FILE_NEW);
230 fMenuFile->
AddEntry(
new TGHotString(
"&Close Window"), M_FILE_CLOSE);
232 fMenuFile->
AddEntry(
new TGHotString(
"E&xit"), M_FILE_EXIT);
234 fMenuWindow =
new TGPopupMenu(
gClient->GetRoot());
235 fMenuWindow->
AddEntry(
new TGHotString(
"Tile &Horizontally"), M_WINDOW_HOR);
236 fMenuWindow->
AddEntry(
new TGHotString(
"Tile &Vertically"), M_WINDOW_VERT);
237 fMenuWindow->
AddEntry(
new TGHotString(
"&Cascade"), M_WINDOW_CASCADE);
241 fMenuWindow->
AddEntry(
new TGHotString(
"&Arrange icons"), M_WINDOW_ARRANGE);
243 fMenuWindow->
AddEntry(
new TGHotString(
"&Opaque resize"), M_WINDOW_OPAQUE);
247 fMenuHelp =
new TGPopupMenu(
gClient->GetRoot());
248 fMenuHelp->
AddEntry(
new TGHotString(
"&Contents"), M_HELP_CONTENTS);
250 fMenuHelp->
AddEntry(
new TGHotString(
"&About"), M_HELP_ABOUT);
256 fMenuFile->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
257 fMenuWindow->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
258 fMenuHelp->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
260 fMenuBar->
AddPopup(
new TGHotString(
"&File"), fMenuFile, fMenuBarItemLayout);
261 fMenuBar->
AddPopup(
new TGHotString(
"&Windows"), fMenuWindow, fMenuBarItemLayout);
262 fMenuBar->
AddPopup(
new TGHotString(
"&Help"), fMenuHelp, fMenuBarItemLayout);
265void TGAppMainFrame::CloseWindow()
272TGMdiTestSubclass::TGMdiTestSubclass(TGMdiMainFrame *
main,
int w,
int h)
274 fMdiFrame =
new TGMdiFrame(
main, w,
h);
275 fMdiFrame->Connect(
"CloseWindow()",
"TGMdiTestSubclass",
this,
"CloseWindow()");
276 fMdiFrame->DontCallClose();
278 fCanvasWindow =
new TGCanvas(fMdiFrame, 400, 240);
280 fMdiFrame->GetWhitePixel());
281 fContainer->SetLayoutManager(
new TGTileLayout(fContainer, 8));
282 fCanvasWindow->SetContainer(fContainer);
284 for (
int i = 0; i < 256; ++i)
285 fCanvasWindow->AddFrame(
new TGFrame(fCanvasWindow->GetContainer(), 32, 32,
kOwnBackground, (i + 1) & 255),
290 fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"ofolder_t.xpm"));
293Bool_t TGMdiTestSubclass::CloseWindow()
297 new TGMsgBox(
gClient->GetRoot(), fMdiFrame, fMdiFrame->GetWindowName(),
"Really want to close the window?",
301 return fMdiFrame->CloseWindow();
308TGMdiHintTest::TGMdiHintTest(TGMdiMainFrame *
main,
int w,
int h)
310 fMdiFrame =
new TGMdiFrame(
main, w,
h);
312 fClose =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Close"), 11);
313 fMenu =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Menu (left icon)"), 12);
314 fMin =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Minimize"), 13);
315 fMax =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Maximize"), 14);
316 fSize =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Resize"), 15);
317 fHelp =
new TGCheckButton(fMdiFrame,
new TGHotString(
"Help"), 16);
321 fMdiFrame->AddFrame(fClose, lh);
322 fMdiFrame->AddFrame(fMenu, lh);
323 fMdiFrame->AddFrame(fMin, lh);
324 fMdiFrame->AddFrame(fMax, lh);
325 fMdiFrame->AddFrame(fSize, lh);
326 fMdiFrame->AddFrame(fHelp, lh);
334 fClose->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
335 fMenu->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
336 fMin->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
337 fMax->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
338 fSize->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
339 fHelp->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
341 fWName =
new TGTextEntry(fMdiFrame, (
const char *)
"", 20);
345 fWName->
Connect(
"TextChanged(char*)",
"TGMdiHintTest",
this,
"HandleText(char*)");
350 fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"app_t.xpm"));
352 fMdiFrame->MapSubwindows();
356void TGMdiHintTest::HandleButtons()
373 fMdiFrame->SetMdiHints(hints);
376void TGMdiHintTest::HandleText(
const char *)
383 new TGAppMainFrame(
gClient->GetRoot(), 640, 400);
389int main(
int argc,
char **argv)
391 TApplication theApp(
"MdiTest", &argc, argv);
#define RQ_OBJECT(sender_class)
int Int_t
Signed integer 4 bytes (int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
externTApplication * gApplication
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.