GUI MDI features.
#include <stdio.h>
#include <stdlib.h>
enum EMenuIds {
M_FILE_NEW,
M_FILE_CLOSE,
M_FILE_EXIT,
M_WINDOW_HOR,
M_WINDOW_VERT,
M_WINDOW_CASCADE,
M_WINDOW_OPAQUE,
M_WINDOW_ARRANGE,
M_HELP_CONTENTS,
M_HELP_ABOUT
};
class TGMdiTestSubclass {
protected:
public:
TGMdiFrame *GetMdiFrame()
const {
return fMdiFrame; }
};
class TGMdiHintTest {
protected:
public:
void HandleButtons();
void HandleText(const char *);
};
class TGAppMainFrame {
protected:
void InitMenu();
void CloseWindow();
public:
TGAppMainFrame(const
TGWindow *p,
int w,
int h);
void HandleMenu(
Int_t id);
};
TGAppMainFrame::TGAppMainFrame(const
TGWindow *p,
int w,
int h)
{
if (pbg)
TGMdiTestSubclass *t = new TGMdiTestSubclass(fMainFrame, 320, 240);
mdiFrame = t->GetMdiFrame();
gClient->GetColorByName(
"red", ic);
mdiFrame->
Move(150, 200);
gClient->GetColorByName(
"green", ic);
mdiFrame->
Move(180, 220);
gClient->GetColorByName(
"blue", ic);
mdiFrame->
Move(400, 300);
new TGMdiHintTest(fMainFrame, 200, 200);
InitMenu();
fMain->SetWindowName("MDI test");
fMain->SetClassHints("mdi test", "mdi test");
else
fMain->Resize(640, 400);
fMain->MapSubwindows();
fMain->MapWindow();
fMain->Layout();
}
void TGAppMainFrame::HandleMenu(
Int_t id)
{
switch (id) {
case M_FILE_NEW:
break;
case M_FILE_CLOSE:
break;
case M_FILE_EXIT:
CloseWindow();
break;
case M_WINDOW_HOR:
break;
case M_WINDOW_VERT:
break;
case M_WINDOW_CASCADE:
break;
case M_WINDOW_ARRANGE:
break;
case M_WINDOW_OPAQUE:
} else {
}
break;
default:
break;
}
}
void TGAppMainFrame::InitMenu()
{
fMenuFile->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
fMenuWindow->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
fMenuHelp->
Connect(
"Activated(Int_t)",
"TGAppMainFrame",
this,
"HandleMenu(Int_t)");
}
void TGAppMainFrame::CloseWindow()
{
}
{
fMdiFrame->Connect("CloseWindow()", "TGMdiTestSubclass", this, "CloseWindow()");
fMdiFrame->DontCallClose();
fCanvasWindow =
new TGCanvas(fMdiFrame, 400, 240);
fMdiFrame->GetWhitePixel());
fContainer->SetLayoutManager(
new TGTileLayout(fContainer, 8));
fCanvasWindow->SetContainer(fContainer);
for (int i = 0; i < 256; ++i)
fCanvasWindow->AddFrame(
new TGFrame(fCanvasWindow->GetContainer(),
fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"ofolder_t.xpm"));
}
Bool_t TGMdiTestSubclass::CloseWindow()
{
int ret = 0;
fMdiFrame->GetWindowName(), "Really want to close the window?",
if (ret ==
kMBYes)
return fMdiFrame->CloseWindow();
}
{
fMdiFrame->AddFrame(fClose, lh);
fMdiFrame->AddFrame(fMenu, lh);
fMdiFrame->AddFrame(fMin, lh);
fMdiFrame->AddFrame(fMax, lh);
fMdiFrame->AddFrame(
fSize, lh);
fMdiFrame->AddFrame(fHelp, lh);
fClose->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fMenu->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fMin->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fMax->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fSize->Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fHelp->
Connect(
"Clicked()",
"TGMdiHintTest",
this,
"HandleButtons()");
fWName =
new TGTextEntry(fMdiFrame, (
const char *)
"", 20);
5, 5, 5, 5));
fWName->
Connect(
"TextChanged(char*)",
"TGMdiHintTest",
this,
"HandleText(char*)");
fMdiFrame->SetWindowIcon(
gClient->GetPicture(
"app_t.xpm"));
fMdiFrame->MapSubwindows();
fMdiFrame->Layout();
}
void TGMdiHintTest::HandleButtons()
{
int hints = 0;
fMdiFrame->SetMdiHints(hints);
}
void TGMdiHintTest::HandleText(const char *)
{
}
void mditest()
{
new TGAppMainFrame(
gClient->GetRoot(), 640, 400);
}
#ifdef STANDALONE
int main(
int argc,
char **argv)
{
mditest();
theApp.Run();
return 0;
}
#endif
#define RQ_OBJECT(sender_class)
R__EXTERN TApplication * gApplication
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
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=0)
Add frame to the composite frame using the specified layout hints.
virtual void Layout()
Layout the elements of the composite frame.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
virtual void Resize(UInt_t w, UInt_t h)
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 Move(Int_t x, Int_t y)
Move MDI window at position x, y.
virtual void SetMdiHints(ULong_t mdihints)
Set MDI hints, also used to identify titlebar buttons.
void SetWindowName(const char *name)
Set MDI window name (set titlebar title).
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.
int main(int argc, char **argv)