51 #include <QVBoxLayout> 56 #include <QMouseEvent> 58 #include "toolBoxElement.hh" 59 #include "parser/element.hh" 61 #define BACKGROUND_RED 0x00 62 #define BACKGROUND_GREEN 0x00 63 #define BACKGROUND_BLUE 0x00 64 #define BACKGROUND_ALPHA 0xff 80 QVBoxLayout *layout =
new QVBoxLayout ();
82 layout->setContentsMargins (2, 2, 2, 2);
86 label->setAlignment (Qt::AlignHCenter);
87 label->setWordWrap (
true);
89 QPalette p = label->palette ();
90 p.setBrush (QPalette::WindowText, Qt::white);
91 p.setBrush (QPalette::ButtonText, Qt::white);
92 label->setPalette (p);
94 layout->addWidget (label);
111 void ToolBoxElement::paintEvent(QPaintEvent * )
114 p.setRenderHint(QPainter::Antialiasing);
116 p.setBrush(QBrush(QColor(BACKGROUND_RED,
120 p.setPen(QColor(BACKGROUND_RED + 0x30,
121 BACKGROUND_GREEN + 0x30,
122 BACKGROUND_BLUE + 0x30,
124 p.drawRoundedRect(0, 0, width (), height (), 4, 4);
133 QMimeData *mimeData =
new QMimeData;
135 QPoint off = _event->pos() - QPoint (width () / 2, height () / 2);
137 QString data = QString::number (off.x ()) +
";";
138 data += QString::number (off.y ()) +
";" + element_->
name ();
141 mimeData->setData (
"application/x-openflipper.vsi",data.toLocal8Bit ());
143 QDrag *drag =
new QDrag(
this);
144 drag->setMimeData(mimeData);
146 QPixmap pixmap (size ());
147 pixmap.fill(Qt::transparent);
151 drag->setPixmap(pixmap);
152 drag->setHotSpot(_event->pos());
const QString & shortDescription() const
Short description.
void mousePressEvent(QMouseEvent *_event)
Starts drag on mouse press.
~ToolBoxElement()
Destructor.
const QString & longDescription() const
Long description.
ToolBoxElement(Element *_element, QWidget *_parent=NULL)
Constructor.
QString name() const
Element name.