Skip to content
Snippets Groups Projects
Commit 7091a8ab authored by Matevz Tadel's avatar Matevz Tadel
Browse files

Add class TEveContext menu that insures context menus are on top of their

"parent" widgets (like buttons used to invoke them).


git-svn-id: http://root.cern.ch/svn/root/trunk@46702 27541ba8-7e3a-0410-8455-c3a389f83636
parent f97a4b27
Branches
Tags
No related merge requests found
......@@ -164,6 +164,7 @@
#pragma link C++ class TEveListTreeItem+;
#pragma link C++ class TEveGListTreeEditorFrame+;
#pragma link C++ class TEveBrowser+;
#pragma link C++ class TEveContextMenu+;
#pragma link C++ class TEveCompositeFrame+;
#pragma link C++ class TEveCompositeFrameInMainFrame+;
#pragma link C++ class TEveCompositeFrameInPack+;
......
......@@ -15,6 +15,7 @@
#include "TEveElement.h"
#include "TGFrame.h"
#include "TContextMenu.h"
class TEveWindow;
class TEveWindowSlot;
......@@ -22,8 +23,7 @@ class TEveWindowFrame;
class TEveWindowMainFrame;
class TEveWindowPack;
class TEveWindowTab;
class TContextMenu;
class TEveContextMenu;
class TGButton;
class TGSplitButton;
......@@ -67,10 +67,10 @@ protected:
Bool_t fShowInSync;
static TContextMenu *fgCtxMenu;
static const TString fgkEmptyFrameName;
static TEveContextMenu *fgCtxMenu;
static const TString fgkEmptyFrameName;
static TList *fgFrameList;
static TList *fgFrameList;
public:
TEveCompositeFrame(TGCompositeFrame* gui_parent, TEveWindow* eve_parent);
......@@ -415,4 +415,26 @@ public:
ClassDef(TEveWindowTab, 0); // Eve-window containing a TGTab.
};
//==============================================================================
//==============================================================================
// Helper classes
//==============================================================================
//==============================================================================
//==============================================================================
// TEveContextMenu
//==============================================================================
class TEveContextMenu : public TContextMenu
{
public:
TEveContextMenu(const char *name, const char *title = "Eve context menu");
void SetupAndPopup(TGWindow* button, TObject* obj);
ClassDef(TEveContextMenu, 0) // Specialization of TContextMenu for Eve.
};
#endif
......@@ -15,13 +15,12 @@
#include "TEveSelection.h"
#include "THashList.h"
#include "TContextMenu.h"
#include "TGButton.h"
#include "TContextMenu.h"
#include "TGMenu.h"
#include "TGPack.h"
#include "TGTab.h"
#include "TRootContextMenu.h"
#include <cassert>
......@@ -65,7 +64,7 @@
ClassImp(TEveCompositeFrame);
TContextMenu* TEveCompositeFrame::fgCtxMenu = 0;
TEveContextMenu* TEveCompositeFrame::fgCtxMenu = 0;
const TString TEveCompositeFrame::fgkEmptyFrameName("<relinquished>");
TList* TEveCompositeFrame::fgFrameList = new THashList;
......@@ -337,18 +336,10 @@ void TEveCompositeFrame::ActionPressed()
// This opens context menu of the eve-window.
if (fgCtxMenu == 0) {
fgCtxMenu = new TContextMenu("", "");
fgCtxMenu = new TEveContextMenu("", "");
}
Int_t x, y;
UInt_t w, h;
Window_t childdum;
gVirtualX->GetWindowSize(fIconBar->GetId(), x, y, w, h);
gVirtualX->TranslateCoordinates(fIconBar->GetId(),
gClient->GetDefaultRoot()->GetId(),
0, 0, x, y, childdum);
fgCtxMenu->Popup(x - 2, y + h - 2, fEveWindow);
fgCtxMenu->SetupAndPopup(fIconBar, fEveWindow);
}
//______________________________________________________________________________
......@@ -1528,3 +1519,51 @@ TEveWindowSlot* TEveWindowTab::NewSlot()
return TEveWindow::CreateWindowInTab(fTab, this);
}
//==============================================================================
//==============================================================================
// Helper classes
//==============================================================================
//==============================================================================
//==============================================================================
// TEveContextMenu
//==============================================================================
//______________________________________________________________________________
//
// Specialization of TContext menu.
// Provide a window manager hint that ensures proper placement of popup on Cocoa.
ClassImp(TEveContextMenu);
//______________________________________________________________________________
TEveContextMenu::TEveContextMenu(const char *name, const char *title) :
TContextMenu(name, title)
{
// Constructor.
}
//______________________________________________________________________________
void TEveContextMenu::SetupAndPopup(TGWindow* button, TObject* obj)
{
// Position the popup below given button and show context menu for object obj.
Int_t x, y;
UInt_t w, h;
Window_t childdum;
gVirtualX->GetWindowSize(button->GetId(), x, y, w, h);
gVirtualX->TranslateCoordinates(button->GetId(),
gClient->GetDefaultRoot()->GetId(),
0, 0, x, y, childdum);
TRootContextMenu *rcm = dynamic_cast<TRootContextMenu*>(fContextMenuImp);
if (rcm != 0)
{
gVirtualX->SetWMTransientHint (rcm->GetId(), button->GetId());
}
Popup(x - 2, y + h - 2, obj);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment