Example #1
0
void CMainFrame::AlignControlsOnBottom()
{
	if (CWndControl::s_selection.GetSize() <= 1)
		return;
	if (CWndControl::s_selection[0]->GetType() == WTYPE_GUI_EDITOR_WND)
		return;

	const int align = CWndControl::s_selection[0]->GetWindowRect(true).bottom();

	WindowData* wnd = m_dataMng->GetWindow(CWndControl::s_selection[0]->GetParent()->GetID());

	CWndControl* ctrl = null;
	QPoint pt;
	for (int i = 0; i < CWndControl::s_selection.GetSize(); i++)
	{
		ctrl = CWndControl::s_selection[i];
		pt = ctrl->GetWindowRect(true).topLeft();
		pt.setY(align - ctrl->GetWindowRect(true).height() + 1);
		ctrl->Move(pt);

		if (wnd)
		{
			ControlData* data = wnd->GetControl(ctrl->GetID());
			if (data)
			{
				const QSize size = data->rect.size();
				data->rect.setTop(align - data->rect.height() + 1);
				data->rect.setSize(size);
			}
		}
	}

	SetControlOnTop();
	m_editor->RenderEnvironment();
}
Example #2
0
void CWndControl::MouseButtonDown(Qt::MouseButton button, const QPoint& pos)
{
    m_mouseButtonsDown |= button;

    if (m_controls.GetSize() > 0)
    {
        CWndControl* ctrl = null, *setOnTop = null;
        QPoint pt;
        for (int i = m_controls.GetSize() - 1; i >= 0; i--)
        {
            ctrl = m_controls[i];
            if (ctrl->HasFlag(WBS_DOCKING))
                pt = pos;
            else
                pt = pos - (m_clientRect.topLeft() - m_windowRect.topLeft());
            if (ctrl->GetWindowRect(true).contains(pt) && ctrl->IsEnabled())
            {
                ctrl->MouseButtonDown(button, pt - ctrl->GetWindowRect(true).topLeft());
                if (IsRoot() && m_controls.GetSize() >= 2 && !setOnTop)
                    setOnTop = ctrl;
            }
        }

        if (setOnTop && m_controls[m_controls.GetSize() - 1] != setOnTop)
            SetControlOnTop(setOnTop);
    }

    if (GetType() != WTYPE_STATIC || !HasFlag(WSS_GROUPBOX))
    {
        if ((button == Qt::LeftButton || button == Qt::RightButton) && !s_focus)
        {
            s_focus = m_mustFocus;
            m_push = true;
        }
    }
}