Exemplo n.º 1
0
void EclRender ()
{

    bool maximiseRender = false;

    //
    // Render any maximised Window?

    if( strcmp( maximisedWindow, "None" ) != 0 )
    {
        EclWindow *maximised = EclGetWindow( maximisedWindow );
        if( maximised )
        {
            maximised->Render( true );
            maximiseRender = true;
        }
        else
        {
            EclUnMaximise();
        }
    }

    if( !maximiseRender )
    {
        for ( int i = windows.Size() - 1; i >= 0; --i )
        {
            EclWindow *window = windows.GetData(i);
            bool hasFocus = ( strcmp ( window->m_name, windowFocus ) == 0 );
            
            START_PROFILE( window->m_name );
            window->Render( hasFocus );
            END_PROFILE( window->m_name );
        }
    }


    //
    // Render the tooltip

    if( tooltipTimer > 0.0f && tooltipCallback )
    {
        EclWindow *window = EclGetWindow();
        if( window )
        {
            EclButton *button = window->GetButton( EclGetCurrentButton() );
            {
                if( button )
                {
                    float timer = GetHighResTime() - tooltipTimer;
                    tooltipCallback( window, button, timer );
                }
            }
        }
    }
}
void EclUpdateMouse ( int _mouseX, int _mouseY, bool _lmb, bool _rmb )
{

    int oldMouseX = mouseX;
    int oldMouseY = mouseY;

    mouseX = _mouseX;
    mouseY = _mouseY;

    EclWindow *currentHighlightedWindow = EclGetWindow( mouseX, mouseY );
    if( currentHighlightedWindow )
    {
        EclDirtyWindow( currentHighlightedWindow );
    }

    if ( !_lmb && !lmb && !_rmb && !rmb )                        // No buttons changed, mouse move only
    {
        EclWindow *currentWindow = EclGetWindow( windowFocus );
        if ( currentWindow )
        {
            EclButton *button = currentWindow->GetButton ( mouseX - currentWindow->m_x, mouseY - currentWindow->m_y );
            if ( button )
            {
                if ( strcmp ( currentButton, button->m_name ) != 0 ) 
                {
                    strcpy ( currentButton, button->m_name );
                    EclDirtyWindow ( currentWindow );
                    tooltipTimer = EclGetAccurateTime() + 1000;
                }
                else
                {
                    if( EclGetAccurateTime() > tooltipTimer )
                    {
                        if( tooltipCallback ) tooltipCallback( currentWindow, button );                    
                    }
                }
            }
            else
            {
                if ( strcmp ( currentButton, "None" ) != 0 )
                {
                    strcpy ( currentButton, "None" );
                    EclDirtyWindow ( currentWindow );
                    if( tooltipCallback ) tooltipCallback( NULL, NULL );
                }
            }
        }
        else
        {
            if ( strcmp ( currentButton, "None" ) != 0 )
            {
                strcpy ( currentButton, "None" );
                if( tooltipCallback ) tooltipCallback( NULL, NULL );
            }
        }
    }
    else if ( _lmb && !lmb )                                     // Left button down
    {
		buttonDownMouseX = mouseX;
		buttonDownMouseY = mouseY;

        EclWindow *currentWindow = EclGetWindow( mouseX, mouseY );
        if ( currentWindow )
        {            
            if ( strcmp ( windowFocus, "None" ) != 0 ) EclDirtyWindow ( windowFocus );
            strcpy ( windowFocus, currentWindow->m_name );
            EclBringWindowToFront( currentWindow->m_name );
            strcpy ( mouseDownWindow, currentWindow->m_name );
           
            EclButton *button = currentWindow->GetButton ( mouseX - currentWindow->m_x, mouseY - currentWindow->m_y );
            if ( button )
            {
                strcpy ( currentButton, button->m_name );
                button->MouseDown();
            }
            else
            {
                strcpy( currentButton, "None" );
                currentWindow->MouseEvent( true, false, false, true );
                if( currentWindow->m_movable ) 
                {
                    mouseDownWindowX = mouseX - currentWindow->m_x;
                    mouseDownWindowY = mouseY - currentWindow->m_y;
                }
            }
        
        }
        else
        {
            if ( strcmp ( windowFocus, "None" ) != 0 ) 
            {
                EclDirtyWindow ( windowFocus );
                strcpy ( windowFocus, "None" );
            }
        }

        lmb = true;
    }
    else if ( _lmb && lmb )                                 // Left button dragged
    {
		buttonDownMouseX = mouseX;
		buttonDownMouseY = mouseY;

        if ( strcmp ( mouseDownWindow, "None" ) != 0 ) {

            EclWindow *window = EclGetWindow( mouseDownWindow );
            if( window )
            {
                EclButton *button = window->GetButton( mouseX - window->m_x, mouseY - window->m_y );
            
                if( button )
                {
                    button->MouseDown();
                }
                else
                {
                    if( strcmp( currentButton, "None" ) == 0 )
                    {
                        int newWidth = window->m_w;
                        int newHeight = window->m_h;
                        bool sizeChanged = false;

                        if( oldMouseY > window->m_y + window->m_h - 4 &&
                            oldMouseY < window->m_y + window->m_h + 4 )
                        {                
                            newHeight = mouseY - window->m_y;
                            sizeChanged = true;
                        }
                
                        if( oldMouseX > window->m_x + window->m_w - 4 &&
                            oldMouseX < window->m_x + window->m_w + 4 )
                        {
                            newWidth = mouseX - window->m_x;
                            sizeChanged = true;
                        }

                        if( sizeChanged )
                        {
                            if( window->m_resizable )
                            {
                                if( newWidth < 60 ) newWidth = 60;
                                if( newHeight < 40 ) newHeight = 40;  
                                EclSetWindowSize( mouseDownWindow, newWidth, newHeight );
                            }
                        }
                        else 
                        {
                            if( window->m_movable )
                            {
                                EclSetWindowPosition ( mouseDownWindow, 
                                                       mouseX - mouseDownWindowX, 
                                                       mouseY - mouseDownWindowY );
                            }
                        }
                    }
                }
            }
        }
    }
    else if ( !_lmb && lmb )                                // Left button up
    {
        strcpy ( mouseDownWindow, "None" );
        lmb = false;

        EclWindow *currentWindow = EclGetWindow( buttonDownMouseX, buttonDownMouseY );
        if ( currentWindow )
        {
            EclButton *button = currentWindow->GetButton( buttonDownMouseX - currentWindow->m_x, buttonDownMouseY - currentWindow->m_y );
            if ( button ) {
                EclDirtyWindow ( currentWindow );
                button->MouseUp ();
            }
            else
            {
                currentWindow->MouseEvent( true, false, true, false );
                EclRemovePopup();
            }
        }
        else
        {
            EclRemovePopup();
        }
    }

    if ( _rmb && !rmb )
    {
        // Right button down
    }
    else if ( _rmb && rmb )
    {
        // Right button dragged
    }
    else if ( !_rmb && rmb )
    {
        // Right button up
    }

}