Ejemplo n.º 1
0
void TableHeader::updateColumnHeadersComponents(void)
{
    if(getColumnModel() == NULL) return;

    std::vector<UInt32> SelectedColumns = getColumnModel()->getSelectedColumns();
    std::vector<UInt32>::iterator SearchItor;
    bool isSelected(false);
        clearColumnHeaders();
        for(UInt32 i(0) ; i<getColumnModel()->getColumnCount(); ++i)
        {
            SearchItor = std::find(SelectedColumns.begin(), SelectedColumns.end(), i);
            
            isSelected = (SearchItor != SelectedColumns.end());

            //TODO: Add Column Focusing
            ComponentUnrecPtr NewComp(_DefaultTableHeaderRenderer->getTableCellRendererComponent(getTable(), getColumnModel()->getColumn(i)->getHeaderValue(), isSelected, false, 0, i));
            pushToColumnHeaders(NewComp);
        }

    
        clearChildren();

        //Add all of the Header Components
        for(UInt32 i(0); i<getMFColumnHeaders()->size() ; ++i)
        {
            pushToChildren(getColumnHeaders(i));
        }

        //TODO: Add all of the Margin Components
        
}
Ejemplo n.º 2
0
void TableHeader::onDestroy()
{
    if(getColumnModel() != NULL)
    {
        getColumnModel()->removeColumnModelListener(&_ColumnModelListener);
    }
}
Ejemplo n.º 3
0
void TableHeader::onCreate(const TableHeader * Id)
{
	Inherited::onCreate(Id);

    if(getColumnModel() != NULL)
    {
        getColumnModel()->addColumnModelListener(&_ColumnModelListener);
    }
}
Ejemplo n.º 4
0
TableColumn* TableHeader::columnAtPoint(const Pnt2f& point) const
{
    Int32 ColumnIndex = getColumnModel()->getColumnIndexAtX(point.x());
    if(ColumnIndex == -1)
    {
        return NULL;
    }
    else
    {
        return getColumnModel()->getColumn(ColumnIndex);
    }
}
Ejemplo n.º 5
0
void TableHeader::setColumnModel(TableColumnModel * const value)
{
    //if(_ColumnModel.get() != NULL)
    //{
    //    getColumnModel()->removeColumnModelListener(&_ColumnModelListener);
    //}
    //_ColumnModel = columnModel;
    updateColumnHeadersComponents();
    if(getColumnModel() != NULL)
    {
        getColumnModel()->addColumnModelListener(&_ColumnModelListener);
    }
}
Ejemplo n.º 6
0
void TableHeader::handleColBorderMouseDragged(MouseEventDetails* const e)
{
	if(e->getButton() == MouseEventDetails::BUTTON1)
	{
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());


        TableColumnRefPtr TheColumn(getColumnModel()->getColumn(_ResizingColumn));
        Real32 NewWidth(MousePosInComponent.x() - getColumnHeaders(_ResizingColumn)->getPosition().x());

        if(NewWidth <= 0 || NewWidth < TheColumn->getMinWidth())
        {
            NewWidth = TheColumn->getMinWidth();
        }

        if(NewWidth > TheColumn->getMaxWidth())
        {
            NewWidth = TheColumn->getMaxWidth();
        }
        
		//Get the new desired center for this margin
	    TheColumn->setWidth(NewWidth);
        updateLayout();
	}
}
Ejemplo n.º 7
0
void TableHeader::checkMouseMargins(MouseEventDetails* const e)
{
    if(isContainedClipBounds(e->getLocation(), this))
    {
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());
        UInt32 CumulativeHeaderWidth(0);
        for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
        {
            CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x();
            if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() &&
               MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance())
            {
                getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_RESIZE_W_TO_E);
                return;
            }
            CumulativeHeaderWidth += getColumnModel()->getColumnMargin();
        }
    }
    getParentWindow()->getParentDrawingSurface()->getEventProducer()->setCursorType(WindowEventProducer::CURSOR_POINTER);
}
Ejemplo n.º 8
0
void TableHeader::mousePressed(MouseEventDetails* const e)
{
    if(getResizingAllowed())
    {
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), this, e->getViewport());
        UInt32 CumulativeHeaderWidth(0);
        for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
        {
            CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x();
            if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() &&
               MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance())
            {
                _ColBorderMouseDraggedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&TableHeader::handleColBorderMouseDragged, this, _1));
                _ColBorderMouseReleasedConnection = getParentWindow()->getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&TableHeader::mouseColBorderMouseReleased, this, _1));
                _ResizingColumn = i;
                return;
            }
            CumulativeHeaderWidth += getColumnModel()->getColumnMargin();
        }
    }
    Inherited::mousePressed(e);
}
Ejemplo n.º 9
0
void TableHeader::mousePressed(const MouseEventUnrecPtr e)
{
    if(getResizingAllowed())
    {
		Pnt2f MousePosInComponent = ViewportToComponent(e->getLocation(), TableHeaderRefPtr(this), e->getViewport());
        UInt32 CumulativeHeaderWidth(0);
        for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
        {
            CumulativeHeaderWidth += getColumnHeaders(i)->getSize().x();
            if(MousePosInComponent.x() >= CumulativeHeaderWidth - getResizingCursorDriftAllowance() &&
               MousePosInComponent.x() <= CumulativeHeaderWidth + getColumnModel()->getColumnMargin() + getResizingCursorDriftAllowance())
            {
                getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseMotionListener(&(_MarginDraggedListener));
                getParentWindow()->getDrawingSurface()->getEventProducer()->addMouseListener(&(_MarginDraggedListener));
                _ResizingColumn = i;
                return;
            }
            CumulativeHeaderWidth += getColumnModel()->getColumnMargin();
        }
    }
    Inherited::mousePressed(e);
}
Ejemplo n.º 10
0
void TableHeader::updateLayout(void)
{
	Pnt2f BorderTopLeft, BorderBottomRight;
	getInsideInsetsBounds(BorderTopLeft, BorderBottomRight);
	
    UInt32 CumulativeWidth(0);
    UInt32 Height(0);
    
    //Use the Model to update the position and sizes of the Headers
    for(UInt32 i(0) ; i<getMFColumnHeaders()->size() ; ++i)
    {
        getColumnHeaders(i)->setPosition( Pnt2f(BorderTopLeft.x() + CumulativeWidth, BorderTopLeft.y()) );
        getColumnHeaders(i)->setSize( Vec2f(getColumnModel()->getColumn(i)->getWidth(), getColumnHeaders(i)->getPreferredSize().y()) );

        Height = osgMax<UInt32>(Height, getColumnHeaders(i)->getSize().y());
        CumulativeWidth += getColumnHeaders(i)->getSize().x();

        //Add on the Margin
        if(i != getMFColumnHeaders()->size()-1)
        {
            CumulativeWidth += getColumnModel()->getColumnMargin();
        }
    }
    
    //Use the Model to update the position and sizes of the Margins
    //Update My Preferred Size
	Pnt2f TopLeft, BottomRight;
	getBounds(TopLeft, BottomRight);

    Vec2f NewPreferredSize(CumulativeWidth + (BottomRight.x() - TopLeft.x() - BorderBottomRight.x() + BorderTopLeft.x()),
                               Height + (BottomRight.y() - TopLeft.y() - BorderBottomRight.y() + BorderTopLeft.y()));
    if(NewPreferredSize != getPreferredSize())
    {
            setPreferredSize(NewPreferredSize);
    }
}
Ejemplo n.º 11
0
void TableHeader::onCreate(const TableHeader * Id)
{
	Inherited::onCreate(Id);

    if(getColumnModel() != NULL)
    {
        _ColumnAddedConnection = getColumnModel()->connectColumnAdded(boost::bind(&TableHeader::handleColumnAdded, this, _1));
        _ColumnMarginChangedConnection = getColumnModel()->connectColumnMarginChanged(boost::bind(&TableHeader::handleColumnMarginChanged, this, _1));
        _ColumnMovedConnection = getColumnModel()->connectColumnMoved(boost::bind(&TableHeader::handleColumnMoved, this, _1));
        _ColumnRemovedConnection = getColumnModel()->connectColumnRemoved(boost::bind(&TableHeader::handleColumnRemoved, this, _1));
        _ColumnSelectionChangedConnection = getColumnModel()->connectColumnSelectionChanged(boost::bind(&TableHeader::handleColumnSelectionChanged, this, _1));
    }
}
Ejemplo n.º 12
0
void TableHeader::setColumnModel(TableColumnModel * const value)
{
    _ColumnAddedConnection.disconnect();
    _ColumnMarginChangedConnection.disconnect();
    _ColumnMovedConnection.disconnect();
    _ColumnRemovedConnection.disconnect();
    _ColumnSelectionChangedConnection.disconnect();

    updateColumnHeadersComponents();
    if(getColumnModel() != NULL)
    {
        _ColumnAddedConnection = getColumnModel()->connectColumnAdded(boost::bind(&TableHeader::handleColumnAdded, this, _1));
        _ColumnMarginChangedConnection = getColumnModel()->connectColumnMarginChanged(boost::bind(&TableHeader::handleColumnMarginChanged, this, _1));
        _ColumnMovedConnection = getColumnModel()->connectColumnMoved(boost::bind(&TableHeader::handleColumnMoved, this, _1));
        _ColumnRemovedConnection = getColumnModel()->connectColumnRemoved(boost::bind(&TableHeader::handleColumnRemoved, this, _1));
        _ColumnSelectionChangedConnection = getColumnModel()->connectColumnSelectionChanged(boost::bind(&TableHeader::handleColumnSelectionChanged, this, _1));
    }
}