Vector Popup::calcNaturalSize(void) const { Vector result(2.0f*marginWidth,2.0f*marginWidth,0.0f); GLfloat maxWidth=0.0; if(title!=0) { /* Calculate the label's natural size: */ Vector titleSize=title->calcNaturalSize(); if(maxWidth<titleSize[0]) maxWidth=titleSize[0]; result[1]+=titleSize[1]+titleSpacing; } if(child!=0) { /* Calculate the first child's natural size: */ Vector childSize=child->calcNaturalSize(); if(maxWidth<childSize[0]) maxWidth=childSize[0]; result[1]+=childSize[1]; } result[0]+=maxWidth; return calcExteriorSize(result); }
void ScrolledImage::requestResize(Widget* child,const Vector& newExteriorSize) { if(isManaged) { /* Gather the old and new sizes of the child widgets: */ Vector iSize=child==image?newExteriorSize:image->getExterior().size; Vector hbSize=child==horizontalScrollBar?newExteriorSize:horizontalScrollBar->getExterior().size; Vector vbSize=child==verticalScrollBar?newExteriorSize:verticalScrollBar->getExterior().size; /* Assemble the new interior size: */ if(iSize[0]<hbSize[0]) iSize[0]=hbSize[0]; if(iSize[1]<vbSize[1]) iSize[1]=vbSize[1]; iSize[0]+=vbSize[0]; iSize[1]+=hbSize[1]; /* Resize the widget: */ parent->requestResize(this,calcExteriorSize(iSize)); } else { /* Just resize the child: */ child->resize(Box(child->getExterior().origin,newExteriorSize)); } }
void Pager::requestResize(Widget* child,const Vector& newExteriorSize) { /* Just grant the request if nothing really changed: */ if(!isManaged) { /* Just resize the child: */ child->resize(Box(child->getExterior().origin,newExteriorSize)); } else if(newExteriorSize[0]==child->getExterior().size[0]&&newExteriorSize[1]==child->getExterior().size[1]) { /* Resize the child in its previous box: */ child->resize(child->getExterior()); /* Invalidate the visual representation: */ update(); } else { /* Calculate the new natural grid size: */ /* Calculate the size of the page button box: */ Vector buttonSize(0.0f,0.0f,0.0f); for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt) { /* Get the button's size: */ Vector s=*pbIt!=child?(*pbIt)->calcNaturalSize():newExteriorSize; /* Increment the box width: */ buttonSize[0]+=s[0]; /* Adjust the box height: */ if(buttonSize[1]<s[1]) buttonSize[1]=s[1]; } /* Calculate the size of the child widget area: */ Vector childSize(0.0f,0.0f,0.0f); for(WidgetList::const_iterator cIt=children.begin();cIt!=children.end();++cIt) { /* Get the child's size: */ Vector s=*cIt!=child?(*cIt)->calcNaturalSize():newExteriorSize; /* Adjust the box width and height: */ for(int i=0;i<2;++i) if(childSize[i]<s[i]) childSize[i]=s[i]; } /* Calcuate the new overall size: */ Vector newSize=childSize; newSize[0]+=2.0f*marginWidth; newSize[1]+=2.0f*marginWidth; if(newSize[0]<buttonSize[0]) newSize[0]=buttonSize[0]; newSize[1]+=buttonSize[1]; /* Try to resize the widget: */ parent->requestResize(this,calcExteriorSize(newSize)); } }
void Popup::requestResize(Widget* child,const Vector&) { /* Calculate the new exterior size: */ Vector size(2.0f*marginWidth,2.0f*marginWidth,0.0f); GLfloat maxWidth=0.0; if(title!=0) { /* Calculate the label's natural size: */ Vector titleSize=title->calcNaturalSize(); if(maxWidth<titleSize[0]) maxWidth=titleSize[0]; size[1]+=titleSize[1]+titleSpacing; } if(child!=0) { /* Calculate the first child's natural size: */ Vector childSize=child->calcNaturalSize(); if(maxWidth<childSize[0]) maxWidth=childSize[0]; size[1]+=childSize[1]; } size[0]+=maxWidth; size=calcExteriorSize(size); /* Resize the widget: */ resize(Box(Vector(0.0f,0.0f,0.0f),size)); }
Vector ColorMap::calcNaturalSize(void) const { /* Return size of color map area plus margin: */ Vector result=preferredSize; result[0]+=2.0f*marginWidth; result[1]+=2.0f*marginWidth; return calcExteriorSize(result); }
void ScrolledListBox::showHorizontalScrollBar(bool enable) { if(enable&&horizontalScrollBar==0) { /* Create a horizontal scroll bar: */ horizontalScrollBar=new ScrollBar("HorizontalScrollBar",this,ScrollBar::HORIZONTAL,false); horizontalScrollBar->getValueChangedCallbacks().add(this,&ScrolledListBox::scrollBarCallback); /* Add it to the widget's layout: */ Vector lbSize=listBox->getExterior().size; Vector vbSize=verticalScrollBar->getExterior().size; Vector hbSize=horizontalScrollBar->calcNaturalSize(); if(lbSize[0]<hbSize[0]) lbSize[0]=hbSize[0]; if(lbSize[1]<vbSize[1]) lbSize[1]=vbSize[1]; lbSize[0]+=vbSize[0]; lbSize[1]+=hbSize[1]; /* Resize the widget: */ if(isManaged) parent->requestResize(this,calcExteriorSize(lbSize)); else resize(Box(Vector(0.0f,0.0f,0.0f),calcExteriorSize(lbSize))); } else if(!enable&&horizontalScrollBar!=0) { /* Destroy the horizontal scroll bar: */ delete horizontalScrollBar; /* Remove it from the widget's layout: */ Vector lbSize=listBox->getExterior().size; Vector vbSize=verticalScrollBar->getExterior().size; if(lbSize[1]<vbSize[1]) lbSize[1]=vbSize[1]; lbSize[0]+=vbSize[0]; /* Resize the widget: */ if(isManaged) parent->requestResize(this,calcExteriorSize(lbSize)); else resize(Box(Vector(0.0f,0.0f,0.0f),calcExteriorSize(lbSize))); } }
void TextFieldSlider::setSpacing(GLfloat newSpacing) { /* Set the spacing: */ spacing=newSpacing; /* Adjust the widget's layout: */ Vector size=textField->getExterior().size; size[0]+=spacing; Vector sSize=slider->getExterior().size; size[0]+=sSize[0]; if(size[0]<sSize[1]) size[0]=sSize[1]; /* Resize the widget: */ if(isManaged) parent->requestResize(this,calcExteriorSize(size)); else resize(Box(Vector(0.0f,0.0f,0.0f),calcExteriorSize(size))); }
Vector ColorMapEditor:: calcNaturalSize() const { //return size of color map area plus margin Vector result = preferredSize; result[0] += 2.0f * marginWidth; result[1] += 2.0f * marginWidth; return calcExteriorSize(result); }
Vector ColorHexagon:: calcNaturalSize() const { /* Return size of color hexagon area plus margin: */ Vector result = preferredSize; result[0] += 2.0 * marginWidth; result[1] += 2.0 * marginWidth; return calcExteriorSize(result); }
Vector ColorBar::calcNaturalSize(void) const { Vector result; /* Calculate the natural width of the widget: */ result[0]=GLfloat(numTickMarks)*font->getCharacterWidth()*GLfloat(tickMarkLabelPrecision+6)+GLfloat(numTickMarks-1)*tickMarkLabelSeparation+2.0f*marginWidth; result[1]=font->getTextHeight()+tickMarkHeight+colorBarHeight+2.0f*marginWidth; return calcExteriorSize(result); }
Vector Image::calcNaturalSize(void) const { /* Calculate the widget's natural interior size based on the image resolution and display region: */ Vector size; for(int i=0;i<2;++i) size[i]=(region[2+i]-region[i])/resolution[i]; size[2]=0.0f; /* Return the widget's exterior size: */ return calcExteriorSize(size); }
void PopupWindow::requestResize(Widget* requestChild,const Vector& newExteriorSize) { /* Just grant the request if nothing really changed: */ if(newExteriorSize[0]==requestChild->getExterior().size[0]&&newExteriorSize[1]==requestChild->getExterior().size[1]) requestChild->resize(requestChild->getExterior()); else { /* Calculate the title bar's size: */ Vector newSize=requestChild==titleBar?newExteriorSize:titleBar->calcNaturalSize(); if(hideButton!=0) { Vector hbSize=requestChild==hideButton?newExteriorSize:hideButton->calcNaturalSize(); if(hbSize[1]<hbSize[0]) hbSize[1]=hbSize[0]; if(newSize[1]<hbSize[1]) newSize[1]=hbSize[1]; } if(closeButton!=0) { Vector cbSize=requestChild==closeButton?newExteriorSize:closeButton->calcNaturalSize(); if(cbSize[1]<cbSize[0]) cbSize[1]=cbSize[0]; if(newSize[1]<cbSize[1]) newSize[1]=cbSize[1]; } if(hideButton!=0) newSize[0]+=newSize[1]; if(closeButton!=0) newSize[0]+=newSize[1]; if(child!=0) { /* Calculate the child's size: */ Vector childSize=requestChild==child?newExteriorSize:child->calcNaturalSize(); childSize[0]+=2.0f*childBorderWidth; childSize[1]+=2.0f*childBorderWidth; /* Merge the child's size with the new window size: */ if(newSize[0]<childSize[0]) newSize[0]=childSize[0]; newSize[1]+=childSize[1]; } /* Resize the widget: */ resize(Box(Vector(0.0f,0.0f,0.0f),calcExteriorSize(newSize))); } }
Vector ScrolledImage::calcNaturalSize(void) const { /* Start with the widget's preferred interior size: */ Vector result=preferredSize; /* Adjust for the horizontal and vertical scroll bars: */ Vector hBarSize=horizontalScrollBar->calcNaturalSize(); Vector vBarSize=verticalScrollBar->calcNaturalSize(); if(result[0]<hBarSize[0]) result[0]=hBarSize[0]; if(result[1]<vBarSize[1]) result[1]=vBarSize[1]; result[0]+=vBarSize[0]; result[1]+=hBarSize[1]; return calcExteriorSize(result); }
Vector TextFieldSlider::calcNaturalSize(void) const { /* Calculate the text field's natural size: */ Vector result=textField->calcNaturalSize(); /* Insert the spacer: */ result[0]+=spacing; /* Calculate the slider's natural size: */ Vector sliderSize=slider->calcNaturalSize(); /* Adjust the widget size: */ result[0]+=sliderSize[0]; if(result[1]<sliderSize[1]) result[1]=sliderSize[1]; return calcExteriorSize(result); }
void TextFieldSlider::requestResize(Widget* child,const Vector& newExteriorSize) { if(isManaged) { /* Adjust the widget's layout: */ Vector size=child==textField?newExteriorSize:textField->getExterior().size; size[0]+=spacing; Vector sSize=child==slider?newExteriorSize:slider->getExterior().size; size[0]+=sSize[0]; if(size[1]<sSize[1]) size[1]=sSize[1]; /* Resize the widget: */ parent->requestResize(this,calcExteriorSize(size)); } else { /* Just resize the child: */ child->resize(Box(child->getExterior().origin,newExteriorSize)); } }
Vector DropdownBox::calcNaturalSize(void) const { /* Calculate the maximum width of all items: */ Vector result(0.0f,label.getFont()->getTextHeight(),0.0f); if(items!=0) for(int i=0;i<numItems;++i) { Vector itemSize=static_cast<Button*>(items->getChild(i))->getLabel().calcNaturalSize(); for(int j=0;j<2;++j) if(result[j]<itemSize[j]) result[j]=itemSize[j]; } /* Return size of largest list item plus margin and dropdown arrow: */ if(result[1]<arrow.getPreferredBoxSize()) result[1]=arrow.getPreferredBoxSize(); result[0]+=2.0f*marginWidth+leftInset+rightInset; result[1]+=2.0f*marginWidth; return calcExteriorSize(result); }
Vector PopupWindow::calcNaturalSize(void) const { /* Calculate the title bar size: */ Vector result=titleBar->calcNaturalSize(); if(hideButton!=0) { Vector hbSize=hideButton->calcNaturalSize(); if(hbSize[1]<hbSize[0]) hbSize[1]=hbSize[0]; if(result[1]<hbSize[1]) result[1]=hbSize[1]; } if(closeButton!=0) { Vector cbSize=closeButton->calcNaturalSize(); if(cbSize[1]<cbSize[0]) cbSize[1]=cbSize[0]; if(result[1]<cbSize[1]) result[1]=cbSize[1]; } if(hideButton!=0) result[0]+=result[1]; if(closeButton!=0) result[0]+=result[1]; /* Calculate the child's size: */ if(child!=0) { Vector childSize=child->calcNaturalSize(); childSize[0]+=2.0f*childBorderWidth; childSize[1]+=2.0f*childBorderWidth; /* Combine the title bar and child sizes: */ if(result[0]<childSize[0]) result[0]=childSize[0]; result[1]+=childSize[1]; } return calcExteriorSize(result); }
Vector Pager::calcNaturalSize(void) const { /* Calculate the size of the page button box: */ Vector buttonSize(0.0f,0.0f,0.0f); for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt) { /* Get the button's size: */ Vector s=(*pbIt)->calcNaturalSize(); /* Increment the box width: */ buttonSize[0]+=s[0]; /* Adjust the box height: */ if(buttonSize[1]<s[1]) buttonSize[1]=s[1]; } /* Calculate the size of the child widget area: */ Vector childSize(0.0f,0.0f,0.0f); for(WidgetList::const_iterator cIt=children.begin();cIt!=children.end();++cIt) { /* Get the child's size: */ Vector s=(*cIt)->calcNaturalSize(); /* Adjust the box width and height: */ for(int i=0;i<2;++i) if(childSize[i]<s[i]) childSize[i]=s[i]; } /* Calcuate the total interior size: */ Vector result=childSize; result[0]+=2.0f*marginWidth; result[1]+=2.0f*marginWidth; if(result[0]<buttonSize[0]) result[0]=buttonSize[0]; result[1]+=buttonSize[1]; return calcExteriorSize(result); }
Vector ScrolledListBox::calcNaturalSize(void) const { /* Calculate the list box's natural size: */ Vector result=listBox->calcNaturalSize(); /* Adjust for the vertical scroll bar: */ Vector vBarSize=verticalScrollBar->calcNaturalSize(); result[0]+=vBarSize[0]; if(result[1]<vBarSize[1]) result[1]=vBarSize[1]; if(horizontalScrollBar!=0) { /* Adjust for the horizontal scroll bar: */ Vector hBarSize=horizontalScrollBar->calcNaturalSize(); if(result[0]<hBarSize[0]+vBarSize[0]) result[0]=hBarSize[0]+vBarSize[0]; result[1]+=hBarSize[1]; } return calcExteriorSize(result); }
GLMotif::Vector ScaleBar::calcNaturalSize(void) const { /* Get the scale bar's size: */ GLMotif::Vector result(float(currentPhysLength),getUiFont()->getTextHeight()*3.0f,0.0f); if(lengthLabel!=0) { /* Adjust for the label size: */ const GLLabel::Box::Vector& labelSize=lengthLabel->getLabelSize(); if(result[0]<labelSize[0]) result[0]=labelSize[0]; } if(scaleLabel!=0) { /* Adjust for the label size: */ const GLLabel::Box::Vector& labelSize=scaleLabel->getLabelSize(); if(result[0]<labelSize[0]) result[0]=labelSize[0]; } /* Calculate the scale bar's current size: */ return calcExteriorSize(result); }
/* * calcNaturalSize - Determine the natural size of the SliceWidget. A virtual function of GLMotif::Widget base. * * return - GLMotif::Vector */ GLMotif::Vector SliceWidget::calcNaturalSize(void) const { GLMotif::Vector result = preferredSize; result[0] += 2.0f * marginWidth; result[1] += 2.0f * marginWidth; return calcExteriorSize(result); } // end calcNaturalSize()