void AddButton(string name, ButtonCallbackBase *callback) { buttonT button; button.name = name; button.x = ComputeNextButtonX(); button.y = WINDOW_HEIGHT + (CONTROL_STRIP_HEIGHT - BUTTON_HEIGHT) / 2; button.width = ComputeButtonWidth(name); button.height = BUTTON_HEIGHT; button.highlighted = false; button.callback = callback; buttons.add(button); DrawButton(button); UpdateDisplay(); }
void CButtonBarDisplay::ComputeButtonRects (void) // ComputeButtonRects // // Compute the rects of all buttons (based on our total size) { int iCount = m_pButtons->GetCount(); // Same as CVisualPalette::GetWidescreenRect int cxCenter = Min(RectWidth(m_rcRect) - (2 * 10), 1280); RECT rcCenter = m_rcRect; rcCenter.left = m_rcRect.left + (RectWidth(m_rcRect) - cxCenter) / 2; rcCenter.right = rcCenter.left + cxCenter; // Align centered buttons int cxTotalWidth = ComputeButtonWidth(CButtonBarData::alignCenter); int x = rcCenter.left + (RectWidth(rcCenter) - cxTotalWidth) / 2; int y = rcCenter.top; ComputeButtonRects(CButtonBarData::alignCenter, x, y); // Align left buttons // (We need extra space because the labels extend beyond the size of the // buttons). x = rcCenter.left + EXTRA_SPACING_X; y = rcCenter.top; ComputeButtonRects(CButtonBarData::alignLeft, x, y); // Align right buttons cxTotalWidth = ComputeButtonWidth(CButtonBarData::alignRight); x = rcCenter.right - (cxTotalWidth + EXTRA_SPACING_X); y = rcCenter.top; ComputeButtonRects(CButtonBarData::alignRight, x, y); }