/************************************************************************* Processing for drag-sizing the segment *************************************************************************/ void ListHeaderSegment::doDragSizing(const Point& local_mouse) { float delta = local_mouse.d_x - d_dragPoint.d_x; // store this so we can work out how much size actually changed float orgWidth = d_pixelSize.d_width; // ensure that we only size to the set constraints. // // NB: We are required to do this here due to our virtually unique sizing nature; the // normal system for limiting the window size is unable to supply the information we // require for updating our internal state used to manage the dragging, etc. float maxWidth(d_maxSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getDisplaySize().d_width)); float minWidth(d_minSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getDisplaySize().d_width)); float newWidth = orgWidth + delta; if (newWidth > maxWidth) delta = maxWidth - orgWidth; else if (newWidth < minWidth) delta = minWidth - orgWidth; // update segment area rect URect area(d_area.d_min.d_x, d_area.d_min.d_y, d_area.d_max.d_x + UDim(0,PixelAligned(delta)), d_area.d_max.d_y); setArea_impl(area.d_min, area.getSize()); // move the dragging point so mouse remains 'attached' to edge of segment d_dragPoint.d_x += d_pixelSize.d_width - orgWidth; WindowEventArgs args(this); onSegmentSized(args); }
/************************************************************************* Handler method for when a segment is sized. *************************************************************************/ bool ListHeader::segmentSizedHandler(const EventArgs& e) { layoutSegments(); // Fire segment sized event. WindowEventArgs args(((WindowEventArgs&)e).window); onSegmentSized(args); return true; }
/************************************************************************* Set the width of the specified column. *************************************************************************/ void ListHeader::setColumnWidth(uint column, const UDim& width) { if (column >= getColumnCount()) { CEGUI_THROW(InvalidRequestException( "specified column index is out of range for this ListHeader.")); } else { d_segments[column]->setSize(USize(width, d_segments[column]->getSize().d_height)); layoutSegments(); // Fire segment sized event. WindowEventArgs args(d_segments[column]); onSegmentSized(args); } }