Example #1
0
void UserRectSel::mouseMoveEvent(QMouseEvent * e)
{
    PanelStrut nearest = current;
    int diff = -1;
    QPoint p = e->globalPos(); // + offset;
    for (RectList::const_iterator it = rectangles.constBegin();
         it != rectangles.constEnd();
         ++it)
    {
        PanelStrut r = *it;
        int ndiff = (r.m_rect.center() - p).manhattanLength();

        if (diff < 0 || ndiff < diff)
        {
            diff = ndiff;
            nearest = r;
        }
    }

    if (nearest != current)
    {
        paintCurrent();
        current = nearest;
        paintCurrent();
    }
}
Example #2
0
/*
 * CurrentWndProc - handle messages for the current color selection window
 */
WPI_MRESULT CALLBACK CurrentWndProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    switch ( msg ) {
    case WM_CREATE:
        SetCurrentNumColors( 16 );
        break;

    case WM_PAINT:
        paintCurrent( hwnd );
        break;

    case WM_DESTROY:
        if( lButton.bitmap != NULL ) {
            _wpi_deletebitmap( lButton.bitmap );
        }
        if( rButton.bitmap != NULL ) {
            _wpi_deletebitmap( rButton.bitmap );
        }
        break;

    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return 0;

} /* CurrentWndProc */