RE: Canvas: mouse action (close) disable/detect

From: Faine, Valeri <fine_at_bnl.gov>
Date: Fri, 25 Feb 2005 19:43:03 -0500


You can try to play a little bit with Qt-layer (http://root.bnl.gov ) . That provides several ways to do that.

Very likely, the "eventFilter approach does fit your needs. See: http://doc.trolltech.com/3.3/qobject.html#installEventFilter You should introduce the "eventFilter" to watch for Hide/Show/Resize Qt events:

http://doc.trolltech.com/3.3/qhideevent.html 
http://doc.trolltech.com/3.3/qshowevent.html
http://doc.trolltech.com/3.3/qresizeevent.html

 

void installMyEventFilter(TCanvas *c, QObject *myFilter) {

   Int_t id = c->GetCanvasID();
   // Convert Canvas id to the real QWidget pointer    QWidget *canvasQtWidget = dynamic_cast<QWidget *>(TGQt::iwid(id));    if (canvasQtWidget) {

     // Get the top level widget ( parent widget )
     // see: http://doc.trolltech.com/3.3/qwidget.html#topLevelWidget 
     QWidget *topWidget = canvasQtWidget->topLevelWidget();
     // Install the custom filter
     topWidget->installEventFilter(myFilter);
   }
}

This should work on Mac / Windows / X11 whatsoever and for any event you may have wanted the custom action for.
Hope this helps.



Best regards
                   Valeri


> -----Original Message-----
> From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On
> Behalf Of Diego Faso
> Sent: Friday, February 25, 2005 11:45 AM
> To: Valeriy Onuchin
> Cc: roottalk_at_pcroot.cern.ch
> Subject: Re: [ROOT] Canvas: mouse action (close) disable/detect
>
> Thanks a lot: I tried a combination of the "disable/detect" close action:
> I disabled the mouse-action as you suggested, and it worked without any
> problem, hence, since I had some problem while trying to connect to
> TGMainFrame::CloseWindow() , I connected a new method to
> TRootCanvas::CloseWindow(), where the TRootCanvas is "i" in your example:
> in this way the mouse-action "close" is redirected to the method defined
> in my class.
> Thank you again, cheers
> Diego
>
> On Fri, 25 Feb 2005, Valeriy Onuchin wrote:
>
> > Hi Diego,
> > 1. to disable "Close" button
> > root [0] c = new TCanvas()
> > root [1] i = (TRootCanvas*)c->GetCanvasImp()
> > root [2] i->DontCallClose()
> >
> > but it will still possible minimize/iconify canvas.
> > Under x11 minimzimg/iconifying windows is a "job" of windows manager
> >
> > You can try the following (no 100% guarantee that will work
> > and depends on windows manager)
> >
> > /* MWM decorations values */
> > #define MWM_DECOR_NONE 0
> > #define MWM_DECOR_ALL (1L << 0)
> > #define MWM_DECOR_BORDER (1L << 1)
> > #define MWM_DECOR_RESIZEH (1L << 2)
> > #define MWM_DECOR_TITLE (1L << 3)
> > #define MWM_DECOR_MENU (1L << 4)
> > #define MWM_DECOR_MINIMIZE (1L << 5)
> > #define MWM_DECOR_MAXIMIZE (1L << 6)
> >
> >
> > i->UnmapWindow()
> > gVirtualX->SetMWMHints(i->GetId(), MWM_DECOR_BORDER, 0, 0)
> > i->MapWindow();
> >
> > 2. to detect "minimize/iconify" action
> > connect to TGFrame::ProcessedEvent signal and check for
> > event->fType == kStructureNotify event
> >
> > 3. to detect "close/delete window" action
> > connect to TGMainFrame::CloseWindow() signal
> >
> > HTH. Regards. Valeriy
> >
> > Diego Faso wrote:
> >
> > > Hello, I need to disable the possibility of closing/minimizing a
canvas
> > > (TCanvas) by using the "minimize/close" standard buttons, or at least
to
> > > detect the "minimize/close mouse-action".
> > > Is there a way to do it?
> > > I thought to connect the "close-mouse-action" to a method of my class,
but
> > > I don't know which method of TCanvas is called when I close the
canvas.
> > >
> > > Tahnk you, cheers
> > > Diego
> >
Received on Sat Feb 26 2005 - 01:43:24 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET