Example #1
0
void ScrollView::adjustScrollbars(int x, int y, bool refresh)
{
    wxWindow* win = nativeWindow();
    if (!win)
        return;

    wxRect crect(win->GetClientRect()), vrect(win->GetVirtualSize());

    if (x == -1) x = m_data->viewStart.x;
    if (y == -1) y = m_data->viewStart.y;

    long style = win->GetWindowStyle();

    // by setting the wxALWAYS_SHOW_SB wxWindow flag before
    // each SetScrollbar call, we can control the scrollbars
    // visibility individually.

    // horizontal scrollbar
    switch (m_data->hScrollbarMode) {
        case ScrollbarAlwaysOff:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, 0, 0, 0, refresh);
            break;

        case ScrollbarAuto:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
            break;

        default: // ScrollbarAlwaysOn
            win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
            break;
    }

    // vertical scrollbar
    switch (m_data->vScrollbarMode) {
        case ScrollbarAlwaysOff:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, 0, 0, 0, refresh);
            break;

        case ScrollbarAlwaysOn:
            win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
            break;

        default: // case ScrollbarAuto:
            win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
            win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
    }
}
Example #2
0
std::vector<cv::Rect> transformRect(cv::Rect cur, cv::Rect seed, int width, int height)
{
    cv::Rect rect[]={cv::Rect(cur.x, cur.y, width, height),
                                    cv::Rect(cur.x-seed.width, cur.y-seed.height, width, height),
                                    cv::Rect(cur.x, cur.y-seed.height, width, height),
                                    cv::Rect(cur.x+seed.width, cur.y-seed.height, width, height),
                                    cv::Rect(cur.x+seed.width, cur.y, width, height),
                                    cv::Rect(cur.x+seed.width, cur.y+seed.height, width, height),
                                    cv::Rect(cur.x, cur.y+seed.height, width, height),
                                    cv::Rect(cur.x-seed.width, cur.y+seed.height, width, height),
                                    cv::Rect(cur.x-seed.width, cur.y, width, height)};
    std::vector<cv::Rect> vrect(rect, rect+sizeof(rect)/sizeof(rect[0]));
    return vrect;
}