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(); } }
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 }
JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders() { if (!ATK_IS_TABLE(m_element.get())) return JSStringCreateWithCharacters(0, 0); Vector<RefPtr<AccessibilityUIElement> > columnHeaders = getColumnHeaders(ATK_TABLE(m_element.get())); return createStringWithAttributes(columnHeaders); }
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); } }
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); }
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); }
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); }