long aListBox::InsertItem(aListItem* itemString, long where) { if ( itemCount >= MAX_LIST_ITEMS ) return -1; gosASSERT( itemString ); if ( where >= itemCount ) where = itemCount; for ( int i = itemCount - 1; i > where - 1; i-- ) { items[i+1] = items[i]; items[i+1]->move( 0, itemString->height() + skipAmount ); } float lastX = x() + itemString->x(); float lastY = y(); items[where] = itemString; if ( itemCount > 0 ) { if ( where - 1 > -1 ) lastY = items[where-1]->bottom() + skipAmount; else lastY = items[where+1]->top() - skipAmount - itemString->height(); } itemString->moveTo( lastX, lastY ); itemString->showGUIWindow( true ); if ( itemString->globalRight() > globalRight() ) // can't have it hanging over the edge { float shrink = globalRight() - itemString->globalRight(); itemString->resize( itemString->width() + shrink, itemString->height() ); } itemCount++; if ( scrollBar ) { int itemsTotalHeight = 0; if ( items ) itemsTotalHeight = items[itemCount-1]->bottom() - items[0]->top(); if ( itemsTotalHeight > scrollBar->height() ) scrollBar->SetScrollMax( itemsTotalHeight - scrollBar->height() ); else scrollBar->SetScrollMax( 0 ); } return where; }
RECT aRect::getGlobalGUI_RECT() { RECT rect; rect.left = globalLeft(); rect.right = globalRight(); rect.top = globalTop(); rect.bottom = globalBottom(); return rect; }
long aListBox::AddItem(aListItem* add) { if (itemCount >= MAX_LIST_ITEMS) return TOO_MANY_ITEMS; float lastX = globalX() + add->globalX(); float lastY = globalY() + topSkip; if ( itemCount ) { lastY = items[itemCount-1]->globalY() + items[itemCount-1]->height() + skipAmount; } items[itemCount++] = add; add->moveTo( lastX, lastY ); if ( add->globalRight() > globalRight() ) // can't have it hanging over the edge { float shrink = globalRight() - add->globalRight(); add->resize( add->width() + shrink, add->height() ); } if ( scrollBar ) { int itemsTotalHeight = 0; if ( items ) itemsTotalHeight = items[itemCount-1]->bottom() - items[0]->top() + skipAmount; if ( itemsTotalHeight > scrollBar->height() ) scrollBar->SetScrollMax( itemsTotalHeight - scrollBar->height() ); else { scrollBar->SetScroll( 0 ); scrollBar->SetScrollMax( 0 ); } } return itemCount - 1; }
void mcScrollButton::render() { if ( isShowing() && state != DISABLED ) { setColor( regularColor ); aButton::render(); GUI_RECT rect = { globalX(), globalY(), globalRight()-1, globalBottom()-1 }; drawEmptyRect( rect, lightEdge, darkEdge ); } }