From: Andrew C. <ac...@us...> - 2005-06-02 02:40:35
|
Update of /cvsroot/planeshift/planeshift/src/common/paws In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4842/src/common/paws Modified Files: pawsmanager.cpp pawsmanager.h pawstextbox.cpp Log Message: Moved some event stuff out of EventHelper because it was messing the mouse up. So now handles the events directly. Some more fixes to the chat window for text behaviour when scrolling around and new text comes in. Index: pawsmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/paws/pawsmanager.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** pawsmanager.cpp 21 May 2005 22:18:26 -0000 1.61 --- pawsmanager.cpp 2 Jun 2005 02:40:26 -0000 1.62 *************** *** 307,314 **** bool PawsManager::HandleMouseDown( iEvent &ev ) { pawsWidget* widget = 0; ! csMouseEventData event; ! csMouseEventHelper::GetEventData(&ev,event); ! widget = mainWidget->WidgetAt( event.x, event.y ); if ( widget != NULL ) --- 307,320 ---- bool PawsManager::HandleMouseDown( iEvent &ev ) { + pawsWidget* widget = 0; ! csPoint event = MouseLocation(ev); ! ! int button; ! int modifiers; ! ev.Retrieve("mButton", button); ! ev.Retrieve("keyModifiers", modifiers); ! ! widget = mainWidget->WidgetAt( event.x, event.y ); if ( widget != NULL ) *************** *** 330,335 **** if ( widget != mainWidget ) widget->GetParent()->BringToTop(widget); ! bool returnResult = widget->OnMouseDown( event.Button, ! event.Modifiers, event.x, event.y ); --- 336,341 ---- if ( widget != mainWidget ) widget->GetParent()->BringToTop(widget); ! bool returnResult = widget->OnMouseDown( button, ! modifiers, event.x, event.y ); *************** *** 345,350 **** bool PawsManager::HandleMouseUp( iEvent &ev ) { ! csMouseEventData event; ! csMouseEventHelper::GetEventData(&ev,event); // Check to see if we are moving a widget. --- 351,361 ---- bool PawsManager::HandleMouseUp( iEvent &ev ) { ! csPoint event = MouseLocation(ev); ! ! int button; ! int modifiers; ! ev.Retrieve("mButton", button); ! ev.Retrieve("keyModifiers", modifiers); ! // Check to see if we are moving a widget. *************** *** 363,368 **** if ( currentFocusedWidget ) ! return currentFocusedWidget->OnMouseUp( event.Button, ! event.Modifiers, event.x, event.y ); --- 374,379 ---- if ( currentFocusedWidget ) ! return currentFocusedWidget->OnMouseUp( button, ! modifiers, event.x, event.y ); *************** *** 378,383 **** widget->GetParent()->BringToTop( widget ); ! return widget->OnMouseUp( event.Button, ! event.Modifiers, event.x, event.y ); --- 389,394 ---- widget->GetParent()->BringToTop( widget ); ! return widget->OnMouseUp( button, ! modifiers, event.x, event.y ); *************** *** 387,395 **** } bool PawsManager::HandleMouseMove( iEvent &ev ) { ! csMouseEventData event; ! csMouseEventHelper::GetEventData(&ev,event); mouse->SetPosition( event.x, event.y ); --- 398,430 ---- } + csPoint& PawsManager::MouseLocation( iEvent &ev ) + { + csMouseEventData event; + + const void *_ax = 0; size_t _ax_sz = 0; + csEventError ok = csEventErrNone; + ok = ev.Retrieve("mAxes", _ax, _ax_sz); + CS_ASSERT(ok == csEventErrNone); + ok = ev.Retrieve("mNumAxes", event.numAxes); + CS_ASSERT(ok == csEventErrNone); + for (int iter=0 ; iter<CS_MAX_MOUSE_AXES ; iter++) + { + if (iter<event.numAxes) + event.axes[iter] = ((int *)_ax)[iter]; + else + event.axes[iter] = 0; + } + + csPoint point; + point.x = event.axes[0]; + point.y = event.axes[1]; + return point; + } + + bool PawsManager::HandleMouseMove( iEvent &ev ) { ! csPoint event = MouseLocation(ev); mouse->SetPosition( event.x, event.y ); Index: pawsmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/paws/pawsmanager.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** pawsmanager.h 15 May 2005 18:43:56 -0000 1.28 --- pawsmanager.h 2 Jun 2005 02:40:26 -0000 1.29 *************** *** 330,334 **** protected: ! /** Sets position of the dragDropWidget (if there is one) to the position * of the mouse cursor. --- 330,336 ---- protected: ! ! csPoint& MouseLocation( iEvent &ev ); ! /** Sets position of the dragDropWidget (if there is one) to the position * of the mouse cursor. Index: pawstextbox.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/paws/pawstextbox.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pawstextbox.cpp 20 May 2005 20:32:13 -0000 1.60 --- pawstextbox.cpp 2 Jun 2005 02:40:26 -0000 1.61 *************** *** 384,387 **** --- 384,388 ---- scrollBar->PostSetup(); scrollBar->SetTickValue( 1.0 ); + scrollBar->SetMaxValue(0.0); AddChild( scrollBar ); *************** *** 472,477 **** } void pawsMessageTextBox::AddMessage( const char* data, int msgColour ) ! { // Add it to the main message buffer. MessageLine * msg = new MessageLine; --- 473,490 ---- } + void pawsMessageTextBox::AddMessage( const char* data, int msgColour ) ! { ! bool onBottom = false; ! int oldTopLine = topLine; ! ! if ( topLine == (int)scrollBar->GetMaxValue() ) ! onBottom = true; ! if ( (int)scrollBar->GetMaxValue() < maxLines ) ! onBottom = true; ! ! if ( topLine < 0 ) ! topLine = 0; ! // Add it to the main message buffer. MessageLine * msg = new MessageLine; *************** *** 500,519 **** scrollBar->SetMaxValue( (float)(adjusted.Length()-maxLines) ); - int oldTop = topLine; topLine = adjusted.Length() - maxLines; if ( topLine < 0 ) topLine = 0; ! ! if ( oldTop+1 == topLine ) { scrollBar->SetCurrentValue( (float)topLine ); } else { - topLine = oldTop; scrollBar->SetCurrentValue( float(topLine) ); ! } ! } --- 513,531 ---- scrollBar->SetMaxValue( (float)(adjusted.Length()-maxLines) ); topLine = adjusted.Length() - maxLines; if ( topLine < 0 ) topLine = 0; ! ! ! if ( !onBottom ) { + topLine = oldTopLine; scrollBar->SetCurrentValue( (float)topLine ); } else { scrollBar->SetCurrentValue( float(topLine) ); ! } } *************** *** 619,622 **** --- 631,636 ---- return pawsWidget::OnMouseDown( button, modifiers, x ,y); + + return false; } |