Ejemplo n.º 1
0
Rect View::ConvertToWindow( Rect box )
{
   Rect sam = box;
 
   View *parent = this;	// I am my own parent.

   while ( parent != NULL )
   {
      sam.left   += parent->Frame().left; 
      sam.right  += parent->Frame().left; 
      sam.bottom += parent->Frame().top; 
      sam.top    += parent->Frame().top; 

      parent = parent->GetParent();
   }
 

   return sam;
}
Ejemplo n.º 2
0
void Window::MouseEvent( int what, int x, int y, unsigned int buttons )
{

    // Backwards, as added.
    lock();
    for ( int i = CountChildren() - 1; i >= 0; i-- )
    {
        View *view = ChildAt(i);

        if ( view->Frame().Contains( x,y ) )
        {
            int nx = x - view->Frame().left;
            int ny = y - view->Frame().top;

            SetActiveView( view );
            view->MouseEvent( what, nx, ny, buttons );
            break;
        }
    }
    unlock();

}
Ejemplo n.º 3
0
Point View::ConvertFromWindow( Point p )
{
   Point sam = p;
 
   View *parent = this;	// I am my own parent.

   while ( parent != NULL )
   {
      sam.x   -= parent->Frame().left; 
      sam.y   -= parent->Frame().top; 

      parent = parent->GetParent();
   }

   return sam;
}
Ejemplo n.º 4
0
View *Window::ChildAt( int x, int y )
{
    lock();
    for ( int i = CountChildren() - 1; i >= 0; i-- )
    {
        View *view = ChildAt(i);

        if ( view->Frame().Contains( x,y ) )
        {
            unlock();
            return view;
        }
    }
    unlock();

    return NULL;
}
Ejemplo n.º 5
0
void
View::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
{
    if (x == 0 && y == 0)
        return;

    fFrame.right += x;
    fFrame.bottom += y;

    if (fVisible && dirtyRegion) {
        IntRect oldBounds(Bounds());
        oldBounds.right -= x;
        oldBounds.bottom -= y;

        BRegion* dirty = fWindow->GetRegion();
        if (!dirty)
            return;

        dirty->Set((clipping_rect)Bounds());
        dirty->Include((clipping_rect)oldBounds);

        if (!(fFlags & B_FULL_UPDATE_ON_RESIZE)) {
            // the dirty region is just the difference of
            // old and new bounds
            dirty->Exclude((clipping_rect)(oldBounds & Bounds()));
        }

        InvalidateScreenClipping();

        if (dirty->CountRects() > 0) {
            if ((fFlags & B_DRAW_ON_CHILDREN) == 0) {
                // exclude children, they are expected to
                // include their own dirty regions in ParentResized()
                for (View* child = FirstChild(); child;
                        child = child->NextSibling()) {
                    if (!child->IsVisible())
                        continue;
                    IntRect previousChildVisible(
                        child->Frame() & oldBounds & Bounds());
                    if (dirty->Frame().Intersects(previousChildVisible)) {
                        dirty->Exclude((clipping_rect)previousChildVisible);
                    }
                }
            }

            ConvertToScreen(dirty);
            dirtyRegion->Include(dirty);
        }
        fWindow->RecycleRegion(dirty);
    }

    // layout the children
    for (View* child = FirstChild(); child; child = child->NextSibling())
        child->ParentResized(x, y, dirtyRegion);

    // view bitmap

    resize_frame(fBitmapDestination, fBitmapResizingMode, x, y);

    // at this point, children are at their new locations,
    // so we can rebuild the clipping
    // TODO: when the implementation of Hide() and Show() is
    // complete, see if this should be avoided
    RebuildClipping(false);
}
Ejemplo n.º 6
0
void View::MouseEvent( int what, int x, int y, unsigned int buttons )
{

			// Backwards, as added.
  lock();
  for ( int i = CountChildren() - 1; i >= 0; i-- )  
  {
     View *view = ChildAt(i);

        if ( view->Frame().Contains( x,y ) )
         {
		   int nx = x - view->Frame().left;
		   int ny = y - view->Frame().top;

		   if ( GetWindow() != NULL ) GetWindow()->SetActiveView( view );
		   
		   view->MouseEvent( what, nx, ny, buttons );
		   unlock();
		   return;
	  	 }
  }
  unlock();
 

	// Otherwise...
 
  	   switch( what )
	   {
	     case MOUSE_DOWN:
            MouseDown( x, y, buttons );
		    break;
	     case MOUSE_UP:
			if ( hasFlag( HAS_POPUPMENU ) == false )
			{
			   MouseUp( x, y, buttons );
			   break;
			}
			// Only the right mouse button.
			
			if ( m_buttons != RIGHT_MOUSE_BUTTON )
			{
				MouseUp( x, y, buttons );
				break;
			}

			if ( m_popupMenu == NULL ) m_popupMenu = Popup();
			if ( m_popupMenu == NULL ) return;
			
			m_popupMenu->MoveTo(  x - m_popupMenu->Frame().Width() / 2,
								  y - m_popupMenu->Frame().Height() / 2 );
			
			m_popupMenu->Show();
		    break;

	     case MOUSE_MOVED:
            MouseMoved( x, y, buttons );
		    break;
	   }

	m_buttons = buttons;
}