27#include "formmanager.h"
28#include "resizehandle.h"
30#include "widgetfactory.h"
31#include "widgetlibrary.h"
33#define MINIMUM_WIDTH 10
34#define MINIMUM_HEIGHT 10
50 m_set->m_widget->installEventFilter(
this);
57ResizeHandle::~ResizeHandle()
61void ResizeHandle::setEditingMode(
bool editing)
64 setBackgroundColor(
blue);
66 setBackgroundColor(
black);
69void ResizeHandle::updatePos()
74 move(m_set->m_widget->x() - 3, m_set->m_widget->y() - 3);
78 move(m_set->m_widget->x() + m_set->m_widget->width()/2 - 3, m_set->m_widget->y() - 3);
82 move(m_set->m_widget->x() + m_set->m_widget->width() - 3, m_set->m_widget->y() - 3);
86 move(m_set->m_widget->x() - 3, m_set->m_widget->y() + m_set->m_widget->height()/2 - 3);
90 move(m_set->m_widget->x() + m_set->m_widget->width() - 3, m_set->m_widget->y() + m_set->m_widget->height()/2 - 3);
94 move(m_set->m_widget->x() - 3, m_set->m_widget->y() + m_set->m_widget->height() - 3);
98 move(m_set->m_widget->x() + m_set->m_widget->width()/2 - 3, m_set->m_widget->y() + m_set->m_widget->height() - 3);
102 move(m_set->m_widget->x() + m_set->m_widget->width() - 3, m_set->m_widget->y() + m_set->m_widget->height() - 3);
108bool ResizeHandle::eventFilter(TQObject *
o,
TQEvent *
ev)
110 if (((
ev->type() == TQEvent::Move) || (
ev->type() == TQEvent::Resize)) &&
o == m_set->m_widget)
134void ResizeHandle::mousePressEvent(TQMouseEvent *
ev)
142 WidgetFactory *
wfactory = m_set->m_form->library()->factoryForClassName(m_set->widget()->className());
148void ResizeHandle::mouseMoveEvent(TQMouseEvent *
ev)
150 int gridX = m_set->m_form->gridSize();
151 int gridY = m_set->m_form->gridSize();
153 if (!m_dragging)
return;
156 int tmpx = m_set->m_widget->x();
157 int tmpy = m_set->m_widget->y();
158 int tmpw = m_set->m_widget->width();
159 int tmph = m_set->m_widget->height();
164 if(
FormManager::self()->snapWidgetsToGrid() && (
ev->state() != (TQt::LeftButton|TQt::ControlButton|TQt::AltButton)))
211 if(
tmpx >= m_set->m_widget->x() + m_set->m_widget->width())
213 tmpx = m_set->m_widget->x() + m_set->m_widget->width() - MINIMUM_WIDTH;
214 tmpw = MINIMUM_WIDTH;
217 if(
tmpy >= m_set->m_widget->y() + m_set->m_widget->height())
219 tmpy = m_set->m_widget->y() + m_set->m_widget->height() - MINIMUM_HEIGHT;
220 tmph = MINIMUM_HEIGHT;
229 else if(
tmpx +
tmpw > m_set->m_widget->parentWidget()->width())
230 tmpw = m_set->m_widget->parentWidget()->width() -
tmpx;
237 else if(
tmpy +
tmph > m_set->m_widget->parentWidget()->height())
238 tmph = m_set->m_widget->parentWidget()->height() -
tmpy;
244 m_set->m_widget->hide();
260 m_set->m_widget->show();
263void ResizeHandle::mouseReleaseEvent(TQMouseEvent *)
297ResizeHandleSet::~ResizeHandleSet()
299 for (
int i = 0;
i < 8;
i++)
310 for(
int i = 0;
i < 8;
i++)
327ResizeHandleSet::raise()
329 for(
int i = 0;
i < 8;
i++)
330 m_handles[
i]->raise();
333void ResizeHandleSet::setEditingMode(
bool editing)
335 for(
int i = 0;
i < 8;
i++)
336 m_handles[
i]->setEditingMode(
editing);
339#include "resizehandle.moc"