void C4Menu::InitSize() { C4GUI::Element *pLast = pClientWindow->GetLast(); // Size calculation int Width, Height; Width=Columns*ItemWidth; Height=Lines*ItemHeight; VisibleCount = Columns*Lines; bool fBarNeeded; if (HasPortrait()) Width += C4MN_DlgPortraitWdt + C4MN_DlgPortraitIndent; // dialogs have auto-enlarge vertically if (pLast && Style == C4MN_Style_Dialog) { Height = std::max<int>(Height, pLast->GetBounds().y + pLast->GetBounds().Hgt + C4MN_DlgLineMargin); fBarNeeded = false; } else fBarNeeded = pLast && pLast->GetBounds().y + pLast->GetBounds().Hgt > pClientWindow->GetBounds().Hgt; // add dlg margins Width += GetMarginLeft() + GetMarginRight() + pClientWindow->GetMarginLeft() + pClientWindow->GetMarginRight(); Height += GetMarginTop() + GetMarginBottom() + pClientWindow->GetMarginTop() + pClientWindow->GetMarginBottom(); if (fBarNeeded) Width += C4GUI_ScrollBarWdt; SetBounds(C4Rect(rcBounds.x, rcBounds.y, Width, Height)); pClientWindow->SetScrollBarEnabled(fBarNeeded); UpdateOwnPos(); }
void C4ScoreboardDlg::Update() { // counts int32_t iRowCount = pBrd->iRows; int32_t iColCount = pBrd->iCols; delete [] piColWidths; piColWidths = nullptr; // invalid board - scipters can create those, but there's no reason why the engine // should display something pretty then; just keep dialog defaults if (!iRowCount || !iColCount) return; // calc sizes as max col widths plus some indent pixels piColWidths = new int32_t[iColCount]; int32_t iWdt=XMargin*2, iHgt=YMargin*2; for (int32_t iCol = 0; iCol < iColCount; ++iCol) { piColWidths[iCol] = XIndent; for (int32_t iRow = 0; iRow < iRowCount; ++iRow) { C4Scoreboard::Entry *pCell = pBrd->GetCell(iCol, iRow); if ((iRow || iCol) && !pCell->Text.isNull()) piColWidths[iCol] = std::max<int32_t>(piColWidths[iCol], ::GraphicsResource.FontRegular.GetTextWidth(pCell->Text.getData()) + XIndent); } iWdt += piColWidths[iCol]; } iHgt += iRowCount * (::GraphicsResource.FontRegular.GetLineHeight() + YIndent); const char *szTitle = pBrd->GetCell(0,0)->Text.getData(); if (szTitle) iWdt = std::max<int32_t>(iWdt, ::GraphicsResource.FontRegular.GetTextWidth(szTitle) + 40); if (!pTitle != !szTitle) SetTitle(szTitle); // needed for title margin... iWdt += GetMarginLeft() + GetMarginRight(); iHgt += GetMarginTop() + GetMarginBottom(); // update dialog SetBounds(C4Rect(rcBounds.x, rcBounds.y, iWdt, iHgt)); SetTitle(szTitle); if (szTitle && pTitle) pTitle->SetIcon(C4GUI::Icon::GetIconFacet(C4GUI::Ico_Player)); // realign C4GUI::Screen *pScr = GetScreen(); if (pScr) DoPlacement(pScr, pScr->GetPreferredDlgRect()); }
void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable ) { TRACE* t = GetTrace( aName ); if( t == nullptr || t->HasCursor() == aEnable ) return; if( aEnable ) { CURSOR* c = new CURSOR( t ); int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2; c->SetX( plotCenter ); t->SetCursor( c ); AddLayer( c ); } else { CURSOR* c = t->GetCursor(); t->SetCursor( NULL ); DelLayer( c, true ); } // Notify the parent window about the changes wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) ); }
void Window::UpdateOwnPos() { Container::UpdateOwnPos(); // set client rect int32_t iMarginL=GetMarginLeft(), iMarginT=GetMarginTop(); rcClientRect.Set(rcBounds.x + iMarginL, rcBounds.y + iMarginT, std::max<int32_t>(rcBounds.Wdt - iMarginL - GetMarginRight(), 0), std::max<int32_t>(rcBounds.Hgt - iMarginT - GetMarginBottom(), 0)); }