// Recalculate layout void FXStatusBar::layout(){ FXint left,right,top,bottom; FXint remain,extra_space,total_space,t; FXint x,y,w,h; FXint numc=0; FXint sumexpand=0; FXint numexpand=0; FXint e=0; FXuint hints; FXWindow* child; // Placement rectangle; right/bottom non-inclusive left=border+padleft; right=width-border-padright; top=border+padtop; bottom=height-border-padbottom; remain=right-left; // Find number of paddable children and total width for(child=corner->getNext(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); if(hints&LAYOUT_FIX_WIDTH) w=child->getWidth(); else w=child->getDefaultWidth(); FXASSERT(w>=0); if((hints&LAYOUT_CENTER_X) || ((hints&LAYOUT_FILL_X) && !(hints&LAYOUT_FIX_WIDTH))){ sumexpand+=w; numexpand+=1; } else{ remain-=w; } numc++; } } // Child spacing if(numc>1) remain-=hspacing*(numc-1); // Substract corner width if((options&STATUSBAR_WITH_DRAGCORNER) && (numc>1)){ right-=corner->getDefaultWidth(); remain-=corner->getDefaultWidth(); } // Do the layout for(child=corner->getNext(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); // Layout child in Y y=child->getY(); if(hints&LAYOUT_FIX_HEIGHT) h=child->getHeight(); else h=child->getDefaultHeight(); extra_space=0; if((hints&LAYOUT_FILL_Y) && !(hints&LAYOUT_FIX_HEIGHT)){ h=bottom-top; if(h<0) h=0; } else if(hints&LAYOUT_CENTER_Y){ if(h<(bottom-top)) extra_space=(bottom-top-h)/2; } if(hints&LAYOUT_BOTTOM) y=bottom-extra_space-h; else /*hints&LAYOUT_TOP*/ y=top+extra_space; // Layout child in X x=child->getX(); if(hints&LAYOUT_FIX_WIDTH) w=child->getWidth(); else w=child->getDefaultWidth(); extra_space=0; total_space=0; if((hints&LAYOUT_FILL_X) && !(hints&LAYOUT_FIX_WIDTH)){ if(sumexpand>0){ t=w*remain; FXASSERT(sumexpand>0); w=t/sumexpand; e+=t%sumexpand; if(e>=sumexpand){w++;e-=sumexpand;} } else{ FXASSERT(numexpand>0); w=remain/numexpand; e+=remain%numexpand; if(e>=numexpand){w++;e-=numexpand;} } } else if(hints&LAYOUT_CENTER_X){ if(sumexpand>0){ t=w*remain; FXASSERT(sumexpand>0); total_space=t/sumexpand-w; e+=t%sumexpand; if(e>=sumexpand){total_space++;e-=sumexpand;} } else{ FXASSERT(numexpand>0); total_space=remain/numexpand-w; e+=remain%numexpand; if(e>=numexpand){total_space++;e-=numexpand;} } extra_space=total_space/2; } if(hints&LAYOUT_RIGHT){ x=right-w-extra_space; right=right-w-hspacing-total_space; } else{/*hints&LAYOUT_LEFT*/ x=left+extra_space; left=left+w+hspacing+total_space; } child->position(x,y,w,h); } } // Just make sure corner grip's on top if((options&STATUSBAR_WITH_DRAGCORNER)){ if(numc>1) corner->position(width-border-corner->getDefaultWidth(),height-border-corner->getDefaultHeight(),corner->getDefaultWidth(),corner->getDefaultHeight()); else corner->position(width-padright-border-corner->getDefaultWidth(),height-border-padbottom-corner->getDefaultHeight(),corner->getDefaultWidth(),corner->getDefaultHeight()); corner->show(); corner->raise(); } else{ corner->hide(); } flags&=~FLAG_DIRTY; }