void EclRemoveWindow ( char *name ) { int index = EclGetWindowIndex(name); if ( index != -1 ) { EclWindow *window = windows.GetData(index); if( strcmp( mouseDownWindow, name ) == 0 ) { strcpy( mouseDownWindow, "None" ); } if( strcmp( windowFocus, name ) == 0 ) { strcpy( windowFocus, "None" ); } window->Remove(); windows.RemoveData(index); delete window; } else { AppDebugOut( "EclRemoveWindow failed on window %s\n", name ); } }
void EclUpdateKeyboard ( int keyCode, bool shift, bool ctrl, bool alt, unsigned char ascii ) { EclWindow *currentWindow = EclGetWindow( windowFocus ); if ( currentWindow ) { currentWindow->Keypress( keyCode, shift, ctrl, alt, ascii ); } }
void EclUnMaximise () { EclWindow *w = EclGetWindow( maximisedWindow ); strcpy( maximisedWindow, "None" ); if( w ) { w->SetPosition( maximiseOldX, maximiseOldY ); w->SetSize( maximiseOldW, maximiseOldH ); } }
void EclRender () { bool maximiseRender = false; // // Render any maximised Window? if( strcmp( maximisedWindow, "None" ) != 0 ) { EclWindow *maximised = EclGetWindow( maximisedWindow ); if( maximised ) { clearDraw ( maximised->m_x, maximised->m_y, maximised->m_w, maximised->m_h ); maximised->Render( true ); maximiseRender = true; } else { EclUnMaximise(); } } if( !maximiseRender ) { // // Clear all dirty rectangle areas if ( clearDraw ) { for( int i = 0; i < dirtyrects.Size(); ++i ) { DirtyRect *dr = dirtyrects.GetData(i); clearDraw ( dr->m_x, dr->m_y, dr->m_width, dr->m_height ); } } // // Draw all dirty buttons for ( int i = windows.Size() - 1; i >= 0; --i ) { EclWindow *window = windows.GetData(i); if ( window->m_dirty ) { bool hasFocus = ( strcmp ( window->m_name, windowFocus ) == 0 ); window->Render( hasFocus ); //window->m_dirty = false; } } } }
void EclUpdate () { // // Update all windows for ( int i = 0; i < windows.Size(); ++i ) { EclWindow *window = windows.GetData(i); window->Update(); } }
void EclUnMaximise () { EclWindow *w = EclGetWindow( maximisedWindow ); strcpy( maximisedWindow, "None" ); if( w ) { w->SetPosition( maximiseOldX, maximiseOldY ); w->SetSize( maximiseOldW, maximiseOldH ); } EclDirtyRectangle( 0, 0, screenW, screenH ); }
void EclSetWindowSize ( char *name, int w, int h ) { EclWindow *window = EclGetWindow(name); if ( window ) { window->Remove(); window->m_w = w; window->m_h = h; window->Create(); } else { AppDebugOut( "EclSetWindowSize failed on window %s\n", name ); } }
void EclMaximiseWindow ( char *name ) { EclUnMaximise(); EclWindow *w = EclGetWindow( name ); if( w ) { strcpy( maximisedWindow, name ); strcpy( mouseDownWindow, name ); strcpy( windowFocus, name ); maximiseOldX = w->m_x; maximiseOldY = w->m_y; maximiseOldW = w->m_w; maximiseOldH = w->m_h; w->SetPosition( 0, 0 ); w->SetSize( screenW, screenH ); } }
void EclSetWindowSize ( char *name, int w, int h ) { EclWindow *window = EclGetWindow(name); if ( window ) { window->Remove(); EclDirtyWindow( window ); EclDirtyRectangle( window->m_x, window->m_y, window->m_w, window->m_h ); window->m_w = w; window->m_h = h; window->Create(); EclDirtyRectangle( window->m_x, window->m_y, window->m_w, window->m_h ); } else { } }
void ScrollBar::Remove() { EclWindow *parent = EclGetWindow( m_parentWindow ); if( parent ) { char barName[256]; char upName[256]; char downName[256]; sprintf( barName, "%s bar", m_name ); sprintf( upName, "%s up", m_name ); sprintf( downName, "%s down", m_name ); parent->RemoveButton( barName ); parent->RemoveButton( upName ); parent->RemoveButton( downName ); } }
int EclMouseStatus() { EclWindow *mouseWindow = EclGetWindow( mouseX, mouseY ); bool resizeH = false; bool resizeV = false; if( mouseWindow && mouseY > mouseWindow->m_y + mouseWindow->m_h - 6 ) { resizeV = true; } if( mouseWindow && mouseX > mouseWindow->m_x + mouseWindow->m_w - 6 ) { resizeH = true; } if( mouseDownBottom ) resizeV = true; if( mouseDownRight ) resizeH = true; if( resizeH && resizeV ) return EclMouseStatus_ResizeHV; if( resizeH ) return EclMouseStatus_ResizeH; if( resizeV ) return EclMouseStatus_ResizeV; if( mouseWindow ) { EclButton *button = mouseWindow->GetButton ( mouseX - mouseWindow->m_x, mouseY - mouseWindow->m_y ); if( button ) { return EclMouseStatus_InWindow; } else { return EclMouseStatus_Draggable; } } return EclMouseStatus_NoWindow; }
void ScrollBar::Create( char *name, int x, int y, int w, int h, int numRows, int winSize, int stepSize ) { strcpy( m_name, name ); m_x = x; m_y = y; m_w = w; m_h = h; m_numRows = numRows; m_winSize = winSize; EclWindow *parent = EclGetWindow( m_parentWindow ); AppDebugAssert( parent ); char barName[256]; char upName[256]; char downName[256]; sprintf( barName, "%s bar", name ); sprintf( upName, "%s up", name ); sprintf( downName, "%s down", name ); ScrollChangeButton *up = new ScrollChangeButton(this, stepSize*-1); up->SetProperties( upName, x, y, w, 18, UnicodeString(), UnicodeString(" ") ); parent->RegisterButton( up ); ScrollBarButton *bar = new ScrollBarButton(this); bar->SetProperties( barName, x, y+18, w, h-36, UnicodeString(" "), UnicodeString(" ") ); parent->RegisterButton( bar ); ScrollChangeButton *down = new ScrollChangeButton(this, stepSize); down->SetProperties( downName, x, y+h-18, w, 18, UnicodeString(), UnicodeString(" ") ); parent->RegisterButton( down ); }
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 *currentWindow = EclGetWindow( mouseX, mouseY ); if ( !_lmb && !lmb && !_rmb && !rmb ) // No buttons changed, mouse move only { 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 ); tooltipTimer = GetHighResTime(); } } else { if ( strcmp ( currentButton, "None" ) != 0 ) { strcpy ( currentButton, "None" ); tooltipTimer = 0.0f; } } } else { if ( strcmp ( currentButton, "None" ) != 0 ) { strcpy ( currentButton, "None" ); tooltipTimer = 0.0f; } } } else if ( _lmb && !lmb ) // Left button down { EclWindow *currentWindow = EclGetWindow( mouseX, mouseY ); if ( currentWindow ) { 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; if( mouseY > currentWindow->m_y + currentWindow->m_h - 6 ) { mouseDownBottom = true; } if( mouseX > currentWindow->m_x + currentWindow->m_w - 6 ) { mouseDownRight = true; } } } } else { if ( strcmp ( windowFocus, "None" ) != 0 ) { strcpy ( windowFocus, "None" ); } } lmb = true; } else if ( _lmb && lmb ) // Left button dragged { if ( strcmp ( mouseDownWindow, "None" ) != 0 ) { EclWindow *window = EclGetWindow( mouseDownWindow ); EclButton *button; if (grabbedButton) button = window->GetButton( EclGetCurrentButton() ); else button = window->GetButton( mouseX - window->m_x, mouseY - window->m_y ); if( button && mouseDownWindowX < 0.0f ) { button->MouseDown(); } else { if( strcmp( currentButton, "None" ) == 0 || mouseDownWindowX >= 0.0f ) { int newWidth = window->m_w; int newHeight = window->m_h; bool sizeChanged = false; if( mouseDownBottom ) { newHeight = mouseY - window->m_y; sizeChanged = true; } if( mouseDownRight ) { newWidth = mouseX - window->m_x; sizeChanged = true; } if( sizeChanged ) { if( newWidth < window->m_minW ) newWidth = window->m_minW; if( newHeight < window->m_minH ) newHeight = window->m_minH; EclSetWindowSize( mouseDownWindow, newWidth, newHeight ); } else { EclSetWindowPosition ( mouseDownWindow, mouseX - mouseDownWindowX, mouseY - mouseDownWindowY ); } } } } } else if ( !_lmb && lmb ) // Left button up { strcpy ( mouseDownWindow, "None" ); mouseDownWindowX = -1; mouseDownWindowY = -1; mouseDownBottom = false; mouseDownRight = false; grabbedButton = false; lmb = false; EclWindow *currentWindow = EclGetWindow( mouseX, mouseY ); if ( currentWindow ) { EclButton *button = currentWindow->GetButton( mouseX - currentWindow->m_x, mouseY - currentWindow->m_y ); if ( button ) { button->MouseUp (); } else { currentWindow->MouseEvent( true, false, true, false ); } } } if ( _rmb && !rmb ) { // Right button down } else if ( _rmb && rmb ) { // Right button dragged } else if ( !_rmb && rmb ) { // Right button up } }
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 } }