GUI MDI features.
#include <stdio.h>
#include <stdlib.h>
enum EMenuIds {
M_FILE_NEW,
M_FILE_CLOSE,
M_WINDOW_HOR,
M_WINDOW_VERT,
M_WINDOW_CASCADE,
M_WINDOW_OPAQUE,
M_WINDOW_ARRANGE,
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;
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()
{
}
TGMdiTestSubclass::TGMdiTestSubclass(
TGMdiMainFrame *main,
int w,
int h)
{
fMdiFrame->Connect("CloseWindow()", "TGMdiTestSubclass", this, "CloseWindow()");
fMdiFrame->DontCallClose();
fCanvasWindow =
new TGCanvas(fMdiFrame, 400, 240);
fMdiFrame->GetWhitePixel());
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?",
}
{
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