CMS 3D CMS Logo

IgQtPixButton.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/Studio/interface/IgQtPixButton.h"
00004 #include <qevent.h>
00005 #include <qpopupmenu.h>
00006 #include <qwhatsthis.h>
00007 #include <qcursor.h>
00008 
00009 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00010 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00011 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00012 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00013 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00014 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00015 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00016 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00017 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00018 
00019 IgQtPixButton::IgQtPixButton (QWidget *parent, const char *name)
00020     : QToolButton (parent, name)
00021 { initialise (QPixmap ()); }
00022 
00023 IgQtPixButton::IgQtPixButton (QPixmap pixmap, QWidget *parent,const char *name)
00024     : QToolButton (parent, name)
00025 { initialise (pixmap); }
00026 
00027 void
00028 IgQtPixButton::initialise (QPixmap pixmap)
00029 {
00030     setAutoRepeat (true);
00031     setAutoRaise (true);
00032     if (!pixmap.isNull ())
00033       setPixmap (pixmap);
00034 }
00035 
00036 void
00037 IgQtPixButton::mousePressEvent (QMouseEvent * event)
00038 {
00039     QPopupMenu *menu = popup ();
00040     if (event->button () == Qt::RightButton && menu)
00041     {
00042       QString text (QWhatsThis::textFor(this, QPoint (), true));
00043       unsigned int count = menu->count ();
00044       if(!text.isNull())
00045       {
00046         menu->insertSeparator ();
00047         menu->insertItem ("&What's This?", this, SLOT (showWhatsThisHelp (void)));
00048       }
00049       popup ()->exec (QCursor::pos ());
00050       event->accept ();
00051       while (menu->count () > count)
00052         menu->removeItemAt (count);
00053     }
00054     else    
00055      QToolButton::mousePressEvent (event);
00056 }
00057 
00058 void
00059 IgQtPixButton::showWhatsThisHelp (void)
00060 { QWhatsThis::display (QWhatsThis::textFor(this, QPoint (), true)); }

Generated on Tue Jun 9 17:38:49 2009 for CMSSW by  doxygen 1.5.4