void WindowTestCase::Positioning()
{
    //Some basic tests for consistency
    int x, y;
    m_window->GetPosition(&x, &y);

    CPPUNIT_ASSERT_EQUAL(x, m_window->GetPosition().x);
    CPPUNIT_ASSERT_EQUAL(y, m_window->GetPosition().y);
    CPPUNIT_ASSERT_EQUAL(m_window->GetPosition(),
                         m_window->GetRect().GetTopLeft());

    m_window->GetScreenPosition(&x, &y);
    CPPUNIT_ASSERT_EQUAL(x, m_window->GetScreenPosition().x);
    CPPUNIT_ASSERT_EQUAL(y, m_window->GetScreenPosition().y);
    CPPUNIT_ASSERT_EQUAL(m_window->GetScreenPosition(),
                         m_window->GetScreenRect().GetTopLeft());
}
Beispiel #2
0
void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event))
{
    int nx = -m_hscroll->GetThumbPosition();
    int ny = -m_vscroll->GetThumbPosition();

    if (m_child)
    {
        wxPoint pos = m_child->GetPosition();

        m_viewport->ScrollWindow(nx - pos.x, ny - pos.y);
    }
}
Beispiel #3
0
void wxDynamicSashWindowLeaf::ResizeChild(const wxSize& size)
{
    if (m_child)
    {
        if (m_impl->m_window->HasFlag(wxDS_MANAGE_SCROLLBARS))
        {
            wxSize best_size = m_child->GetBestSize();
            if (best_size.GetWidth() < size.GetWidth())
                best_size.SetWidth(size.GetWidth());
            if (best_size.GetHeight() < size.GetHeight())
                best_size.SetHeight(size.GetHeight());
            m_child->SetSize(best_size);

            int hpos = m_hscroll->GetThumbPosition();
            int vpos = m_vscroll->GetThumbPosition();

            if (hpos < 0)
                hpos = 0;
            if (vpos < 0)
                vpos = 0;
            if (hpos > best_size.GetWidth() - size.GetWidth())
                hpos = best_size.GetWidth() - size.GetWidth();
            if (vpos > best_size.GetHeight() - size.GetHeight())
                vpos = best_size.GetHeight() - size.GetHeight();

            m_hscroll->SetScrollbar(hpos, size.GetWidth(),
                                    best_size.GetWidth(), size.GetWidth());
            m_vscroll->SetScrollbar(vpos, size.GetHeight(),
                                    best_size.GetHeight(), size.GetHeight());

            //  Umm, the scrollbars are doing something insane under GTK+ and subtracting
            //  one from the position I pass in.  This works around that.
            m_hscroll->SetThumbPosition(hpos + hpos - m_hscroll->GetThumbPosition());
            m_vscroll->SetThumbPosition(vpos + vpos - m_vscroll->GetThumbPosition());

            wxPoint pos = m_child->GetPosition();
            m_viewport->ScrollWindow(-hpos - pos.x, -vpos - pos.y);
        }
        else // !wxDS_MANAGE_SCROLLBARS
        {
            m_child->SetSize(size);
        }
    }
}