/** Compute the size of a tray. */ void ComputeTraySize(TrayType *tp) { TrayComponentType *cp; const ScreenType *sp; int x, y; /* Determine the first dimension. */ if(tp->layout == LAYOUT_HORIZONTAL) { if(tp->height == 0) { tp->height = ComputeMaxHeight(tp); } if(tp->height == 0) { tp->height = DEFAULT_TRAY_HEIGHT; } } else { if(tp->width == 0) { tp->width = ComputeMaxWidth(tp); } if(tp->width == 0) { tp->width = DEFAULT_TRAY_WIDTH; } } /* Now at least one size is known. Inform the components. */ for(cp = tp->components; cp; cp = cp->next) { if(cp->SetSize) { if(tp->layout == LAYOUT_HORIZONTAL) { (cp->SetSize)(cp, 0, tp->height); } else { (cp->SetSize)(cp, tp->width, 0); } } } /* Initialize the coordinates. */ tp->x = tp->requestedX; tp->y = tp->requestedY; /* Determine on which screen the tray will reside. */ switch(tp->valign) { case TALIGN_TOP: y = 0; break; case TALIGN_BOTTOM: y = rootHeight - 1; break; case TALIGN_CENTER: y = 1 + rootHeight / 2; break; default: if(tp->y < 0) { y = rootHeight + tp->y; } else { y = tp->y; } break; } switch(tp->halign) { case TALIGN_LEFT: x = 0; break; case TALIGN_RIGHT: x = rootWidth - 1; break; case TALIGN_CENTER: x = 1 + rootWidth / 2; break; default: if(tp->x < 0) { x = rootWidth + tp->x; } else { x = tp->x; } break; } sp = GetCurrentScreen(x, y); /* Determine the missing dimension. */ if(tp->layout == LAYOUT_HORIZONTAL) { if(tp->width == 0) { if(CheckHorizontalFill(tp)) { tp->width = sp->width; } else { tp->width = ComputeTotalWidth(tp); } if(tp->width == 0) { tp->width = DEFAULT_TRAY_WIDTH; } } } else { if(tp->height == 0) { if(CheckVerticalFill(tp)) { tp->height = sp->height; } else { tp->height = ComputeTotalHeight(tp); } if(tp->height == 0) { tp->height = DEFAULT_TRAY_HEIGHT; } } } /* Compute the tray location. */ switch(tp->valign) { case TALIGN_TOP: tp->y = sp->y - TRAY_BORDER_SIZE; break; case TALIGN_BOTTOM: tp->y = sp->y + sp->height - tp->height + TRAY_BORDER_SIZE; break; case TALIGN_CENTER: tp->y = sp->y + (sp->height - tp->height) / 2; break; default: if(tp->y < 0) { tp->y = sp->y + sp->height - tp->height + TRAY_BORDER_SIZE; } else { tp->y -= TRAY_BORDER_SIZE; } break; } switch(tp->halign) { case TALIGN_LEFT: tp->x = sp->x - TRAY_BORDER_SIZE; break; case TALIGN_RIGHT: tp->x = sp->x + sp->width - tp->width + TRAY_BORDER_SIZE; break; case TALIGN_CENTER: tp->x = sp->x + (sp->width - tp->width) / 2; break; default: if(tp->x < 0) { tp->x = sp->x + sp->width - tp->width + TRAY_BORDER_SIZE; } else { tp->x -= TRAY_BORDER_SIZE; } break; } }
/** Compute the size of a tray. */ void ComputeTraySize(TrayType *tp) { TrayComponentType *cp; /* Determine the first dimension. */ if(tp->layout == LAYOUT_HORIZONTAL) { if(tp->height == 0) { tp->height = ComputeMaxHeight(tp); } if(tp->height == 0) { tp->height = DEFAULT_TRAY_HEIGHT; } } else { if(tp->width == 0) { tp->width = ComputeMaxWidth(tp); } if(tp->width == 0) { tp->width = DEFAULT_TRAY_WIDTH; } } /* Now at least one size is known. Inform the components. */ for(cp = tp->components; cp; cp = cp->next) { if(cp->SetSize) { if(tp->layout == LAYOUT_HORIZONTAL) { (cp->SetSize)(cp, 0, tp->height - 2 * tp->border); } else { (cp->SetSize)(cp, tp->width - 2 * tp->border, 0); } } } /* Determine the missing dimension. */ if(tp->layout == LAYOUT_HORIZONTAL) { if(tp->width == 0) { if(CheckHorizontalFill(tp)) { tp->width = rootWidth; } else { tp->width = ComputeTotalWidth(tp); } if(tp->width == 0) { tp->width = DEFAULT_TRAY_WIDTH; } } } else { if(tp->height == 0) { if(CheckVerticalFill(tp)) { tp->height = rootHeight; } else { tp->height = ComputeTotalHeight(tp); } if(tp->height == 0) { tp->height = DEFAULT_TRAY_HEIGHT; } } } /* Compute the tray location. */ switch(tp->valign) { case TALIGN_TOP: tp->y = 0; break; case TALIGN_BOTTOM: tp->y = rootHeight - tp->height + 1; break; case TALIGN_CENTER: tp->y = rootHeight / 2 - tp->height / 2; break; default: if(tp->y < 0) { tp->y = rootHeight + tp->y - tp->height + 1; } break; } switch(tp->halign) { case TALIGN_LEFT: tp->x = 0; break; case TALIGN_RIGHT: tp->x = rootWidth - tp->width + 1; break; case TALIGN_CENTER: tp->x = rootWidth / 2 - tp->width / 2; break; default: if(tp->x < 0) { tp->x = rootWidth + tp->x - tp->width + 1; } break; } }