OpenClonk
C4GUI::ComponentAligner Class Reference

#include <C4Gui.h>

Collaboration diagram for C4GUI::ComponentAligner:
[legend]

Public Member Functions

 ComponentAligner (const C4Rect &rcArea, int32_t iMarginX, int32_t iMarginY, bool fZeroAreaXY=false)
 
bool GetFromTop (int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
 
bool GetFromLeft (int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
 
bool GetFromRight (int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
 
bool GetFromBottom (int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
 
void GetAll (C4Rect &rcOut)
 
bool GetCentered (int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
 
C4RectGetFromTop (int32_t iHgt, int32_t iWdt=-1)
 
C4RectGetFromLeft (int32_t iWdt, int32_t iHgt=-1)
 
C4RectGetFromRight (int32_t iWdt, int32_t iHgt=-1)
 
C4RectGetFromBottom (int32_t iHgt, int32_t iWdt=-1)
 
C4RectGetAll ()
 
C4RectGetCentered (int32_t iWdt, int32_t iHgt)
 
C4RectGetGridCell (int32_t iSectX, int32_t iSectXMax, int32_t iSectY, int32_t iSectYMax, int32_t iSectSizeX=-1, int32_t iSectSizeY=-1, bool fCenterPos=false, int32_t iSectNumX=1, int32_t iSectNumY=1)
 
int32_t GetWidth () const
 
int32_t GetHeight () const
 
int32_t GetHMargin () const
 
int32_t GetVMargin () const
 
int32_t GetInnerWidth () const
 
int32_t GetInnerHeight () const
 
void ExpandTop (int32_t iByHgt)
 
void ExpandLeft (int32_t iByWdt)
 
void ExpandRight (int32_t iByWdt)
 
void ExpandBottom (int32_t iByHgt)
 
void LogIt (const char *szName)
 

Protected Attributes

C4Rect rcClientArea
 
int32_t iMarginX
 
int32_t iMarginY
 

Static Protected Attributes

static C4Rect rcTemp
 

Detailed Description

Definition at line 2774 of file C4Gui.h.

Constructor & Destructor Documentation

◆ ComponentAligner()

C4GUI::ComponentAligner::ComponentAligner ( const C4Rect rcArea,
int32_t  iMarginX,
int32_t  iMarginY,
bool  fZeroAreaXY = false 
)
inline

Definition at line 2783 of file C4Gui.h.

2785  { if (fZeroAreaXY) rcClientArea.x=rcClientArea.y=0; }
int32_t y
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30

References rcClientArea, C4Rect::x, and C4Rect::y.

Member Function Documentation

◆ ExpandBottom()

void C4GUI::ComponentAligner::ExpandBottom ( int32_t  iByHgt)
inline

Definition at line 2814 of file C4Gui.h.

2814 { rcClientArea.Hgt+=iByHgt; } // enlarge client rect
int32_t Hgt
Definition: C4Rect.h:30

References C4Rect::Hgt, and rcClientArea.

Referenced by C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg().

Here is the caller graph for this function:

◆ ExpandLeft()

void C4GUI::ComponentAligner::ExpandLeft ( int32_t  iByWdt)
inline

Definition at line 2812 of file C4Gui.h.

2812 { rcClientArea.x-=iByWdt; rcClientArea.Wdt+=iByWdt; } // enlarge client rect
int32_t Wdt
Definition: C4Rect.h:30

References rcClientArea, C4Rect::Wdt, and C4Rect::x.

Referenced by C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), C4GUI::LabeledEdit::LabeledEdit(), and C4GUI::MessageDialog::MessageDialog().

Here is the caller graph for this function:

◆ ExpandRight()

void C4GUI::ComponentAligner::ExpandRight ( int32_t  iByWdt)
inline

Definition at line 2813 of file C4Gui.h.

2813 { rcClientArea.Wdt+=iByWdt; } // enlarge client rect

References rcClientArea, and C4Rect::Wdt.

◆ ExpandTop()

void C4GUI::ComponentAligner::ExpandTop ( int32_t  iByHgt)
inline

Definition at line 2811 of file C4Gui.h.

2811 { rcClientArea.y-=iByHgt; rcClientArea.Hgt+=iByHgt; } // enlarge client rect

References C4Rect::Hgt, rcClientArea, and C4Rect::y.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), and C4ChatControl::UpdateSize().

Here is the caller graph for this function:

◆ GetAll() [1/2]

C4Rect& C4GUI::ComponentAligner::GetAll ( )
inline

Definition at line 2798 of file C4Gui.h.

2798 { GetAll(rcTemp); return rcTemp; } // get remaining client are
static C4Rect rcTemp
Definition: C4Gui.h:2780
C4Rect & GetAll()
Definition: C4Gui.h:2798

References GetAll(), and rcTemp.

Referenced by GetAll().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAll() [2/2]

◆ GetCentered() [1/2]

C4Rect& C4GUI::ComponentAligner::GetCentered ( int32_t  iWdt,
int32_t  iHgt 
)
inline

Definition at line 2799 of file C4Gui.h.

2799 { GetCentered(iWdt, iHgt, rcTemp); return rcTemp; } // get centered subregion within area (w/o size checks)
bool GetCentered(int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
Definition: C4Gui.cpp:1133

References GetCentered(), and rcTemp.

Referenced by GetCentered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCentered() [2/2]

bool C4GUI::ComponentAligner::GetCentered ( int32_t  iWdt,
int32_t  iHgt,
C4Rect rcOut 
)

Definition at line 1133 of file C4Gui.cpp.

1134  {
1135  rcOut.x = rcClientArea.GetMiddleX() - iWdt/2;
1136  rcOut.y = rcClientArea.GetMiddleY() - iHgt/2;
1137  rcOut.Wdt = iWdt;
1138  rcOut.Hgt = iHgt;
1139  // range check
1140  return rcOut.Wdt+iMarginX*2 <= rcClientArea.Wdt && rcOut.Hgt+iMarginY*2 <= rcClientArea.Hgt;
1141  }
int32_t GetMiddleX() const
Definition: C4Rect.h:56
int32_t GetMiddleY() const
Definition: C4Rect.h:57

References C4Rect::GetMiddleX(), C4Rect::GetMiddleY(), C4Rect::Hgt, iMarginX, iMarginY, rcClientArea, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GameOptionButtons::C4GameOptionButtons(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::InfoDialog::CreateSubComponents(), C4GUI::InputDialog::InputDialog(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4GUI::ProgressDialog::ProgressDialog(), and C4ChatControl::UpdateSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFromBottom() [1/2]

bool C4GUI::ComponentAligner::GetFromBottom ( int32_t  iHgt,
int32_t  iWdt,
C4Rect rcOut 
)

◆ GetFromBottom() [2/2]

C4Rect& C4GUI::ComponentAligner::GetFromBottom ( int32_t  iHgt,
int32_t  iWdt = -1 
)
inline

Definition at line 2797 of file C4Gui.h.

2797 { GetFromBottom(iHgt, iWdt, rcTemp); return rcTemp; } // get a portion from the bottom
bool GetFromBottom(int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
Definition: C4Gui.cpp:1109

References GetFromBottom(), and rcTemp.

Referenced by GetFromBottom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFromLeft() [1/2]

bool C4GUI::ComponentAligner::GetFromLeft ( int32_t  iWdt,
int32_t  iHgt,
C4Rect rcOut 
)

◆ GetFromLeft() [2/2]

C4Rect& C4GUI::ComponentAligner::GetFromLeft ( int32_t  iWdt,
int32_t  iHgt = -1 
)
inline

Definition at line 2795 of file C4Gui.h.

2795 { GetFromLeft(iWdt, iHgt, rcTemp); return rcTemp; } // get a portion from the left
bool GetFromLeft(int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
Definition: C4Gui.cpp:1076

References GetFromLeft(), and rcTemp.

Referenced by GetFromLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFromRight() [1/2]

bool C4GUI::ComponentAligner::GetFromRight ( int32_t  iWdt,
int32_t  iHgt,
C4Rect rcOut 
)

Definition at line 1093 of file C4Gui.cpp.

1094  {
1095  rcOut.x = rcClientArea.x + rcClientArea.Wdt - iWdt - iMarginX;
1096  rcOut.y = rcClientArea.y + iMarginY;
1097  rcOut.Wdt = iWdt;
1098  rcOut.Hgt = rcClientArea.Hgt - iMarginY * 2;
1099  rcClientArea.Wdt -= iWdt + iMarginX * 2;
1100  // get centered in height as specified
1101  if (iHgt >= 0)
1102  {
1103  rcOut.y += (rcOut.Hgt - iHgt) / 2;
1104  rcOut.Hgt = iHgt;
1105  }
1106  return rcClientArea.Wdt >= 0;
1107  }

References C4Rect::Hgt, iMarginX, iMarginY, rcClientArea, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4LeagueSignupDialog::C4LeagueSignupDialog(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4FileSelDlg::InitElements(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), and C4StartupScenSelDlg::ScenListItem::UpdateOwnPos().

Here is the caller graph for this function:

◆ GetFromRight() [2/2]

C4Rect& C4GUI::ComponentAligner::GetFromRight ( int32_t  iWdt,
int32_t  iHgt = -1 
)
inline

Definition at line 2796 of file C4Gui.h.

2796 { GetFromRight(iWdt, iHgt, rcTemp); return rcTemp; } // get a portion from the right
bool GetFromRight(int32_t iWdt, int32_t iHgt, C4Rect &rcOut)
Definition: C4Gui.cpp:1093

References GetFromRight(), and rcTemp.

Referenced by GetFromRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFromTop() [1/2]

bool C4GUI::ComponentAligner::GetFromTop ( int32_t  iHgt,
int32_t  iWdt,
C4Rect rcOut 
)

Definition at line 1059 of file C4Gui.cpp.

1060  {
1061  rcOut.x = rcClientArea.x + iMarginX;
1062  rcOut.y = rcClientArea.y + iMarginY;
1063  rcOut.Wdt = rcClientArea.Wdt - iMarginX * 2;
1064  rcOut.Hgt = iHgt;
1065  int32_t d = iHgt + iMarginY * 2;
1066  rcClientArea.y += d; rcClientArea.Hgt -= d;
1067  // get centered in width as specified
1068  if (iWdt >= 0)
1069  {
1070  rcOut.x += (rcOut.Wdt - iWdt) / 2;
1071  rcOut.Wdt = iWdt;
1072  }
1073  return rcClientArea.Hgt >= 0;
1074  }

References C4Rect::Hgt, iMarginX, iMarginY, rcClientArea, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupLegalDlg::C4StartupLegalDlg(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4FileSelDlg::InitElements(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4GoalDisplay::SetGoals(), and C4ChatControl::UpdateSize().

Here is the caller graph for this function:

◆ GetFromTop() [2/2]

C4Rect& C4GUI::ComponentAligner::GetFromTop ( int32_t  iHgt,
int32_t  iWdt = -1 
)
inline

Definition at line 2794 of file C4Gui.h.

2794 { GetFromTop(iHgt, iWdt, rcTemp); return rcTemp; } // get a portion from the top
bool GetFromTop(int32_t iHgt, int32_t iWdt, C4Rect &rcOut)
Definition: C4Gui.cpp:1059

References GetFromTop(), and rcTemp.

Referenced by GetFromTop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGridCell()

C4Rect & C4GUI::ComponentAligner::GetGridCell ( int32_t  iSectX,
int32_t  iSectXMax,
int32_t  iSectY,
int32_t  iSectYMax,
int32_t  iSectSizeX = -1,
int32_t  iSectSizeY = -1,
bool  fCenterPos = false,
int32_t  iSectNumX = 1,
int32_t  iSectNumY = 1 
)

Definition at line 1148 of file C4Gui.cpp.

1149  {
1150  int32_t iSectSizeXO = iSectSizeX, iSectSizeYO = iSectSizeY;
1151  int32_t iSectSizeXMax = (rcClientArea.Wdt-iMarginX) / iSectXMax - iMarginX;
1152  int32_t iSectSizeYMax = (rcClientArea.Hgt-iMarginY) / iSectYMax - iMarginY;
1153  if (iSectSizeX<0 || fCenterPos) iSectSizeX=iSectSizeXMax; else iSectSizeX=std::min<int32_t>(iSectSizeX, iSectSizeXMax);
1154  if (iSectSizeY<0 || fCenterPos) iSectSizeY=iSectSizeYMax; else iSectSizeY=std::min<int32_t>(iSectSizeY, iSectSizeYMax);
1155  rcTemp.x = iSectX * (iSectSizeX+iMarginX) + iMarginX + rcClientArea.x;
1156  rcTemp.y = iSectY * (iSectSizeY+iMarginY) + iMarginY + rcClientArea.y;
1157  rcTemp.Wdt = iSectSizeX * iSectNumX + iMarginX*(iSectNumX-1); rcTemp.Hgt = iSectSizeY * iSectNumY + iMarginY*(iSectNumY-1);
1158  if (iSectSizeXO>=0 && fCenterPos)
1159  {
1160  rcTemp.x += (iSectSizeX - iSectSizeXO)/2;
1161  rcTemp.Wdt = iSectSizeXO;
1162  }
1163  if (iSectSizeYO>=0 && fCenterPos)
1164  {
1165  rcTemp.y += (iSectSizeY - iSectSizeYO)/2;
1166  rcTemp.Hgt = iSectSizeYO;
1167  }
1168  return rcTemp;
1169  }

References C4Rect::Hgt, iMarginX, iMarginY, rcClientArea, rcTemp, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupLegalDlg::C4StartupLegalDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), and C4GoalDisplay::SetGoals().

Here is the caller graph for this function:

◆ GetHeight()

◆ GetHMargin()

int32_t C4GUI::ComponentAligner::GetHMargin ( ) const
inline

Definition at line 2805 of file C4Gui.h.

2805 { return iMarginX; }

References iMarginX.

◆ GetInnerHeight()

int32_t C4GUI::ComponentAligner::GetInnerHeight ( ) const
inline

Definition at line 2809 of file C4Gui.h.

2809 { return rcClientArea.Hgt-2*iMarginY; }

References C4Rect::Hgt, iMarginY, and rcClientArea.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4ChatControl::ChatSheet::NickItem::UpdateOwnPos(), C4FileSelDlg::DefaultListItem::UpdateOwnPos(), and C4ChatControl::UpdateSize().

Here is the caller graph for this function:

◆ GetInnerWidth()

int32_t C4GUI::ComponentAligner::GetInnerWidth ( ) const
inline

Definition at line 2808 of file C4Gui.h.

2808 { return rcClientArea.Wdt-2*iMarginX; }

References iMarginX, rcClientArea, and C4Rect::Wdt.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupLegalDlg::C4StartupLegalDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), and C4ChatControl::UpdateSize().

Here is the caller graph for this function:

◆ GetVMargin()

int32_t C4GUI::ComponentAligner::GetVMargin ( ) const
inline

Definition at line 2806 of file C4Gui.h.

2806 { return iMarginY; }

References iMarginY.

◆ GetWidth()

int32_t C4GUI::ComponentAligner::GetWidth ( ) const
inline

Definition at line 2803 of file C4Gui.h.

2803 { return rcClientArea.Wdt; }

References rcClientArea, and C4Rect::Wdt.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4StartupModsDlg::C4StartupModsDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), and C4FileSelDlg::InitElements().

Here is the caller graph for this function:

◆ LogIt()

void C4GUI::ComponentAligner::LogIt ( const char *  szName)

Definition at line 1143 of file C4Gui.cpp.

1144  {
1145  LogF("ComponentAligner %s: (%d,%d)+(%d,%d), Margin (%d,%d)", szName, rcClientArea.x, rcClientArea.y, rcClientArea.Wdt, rcClientArea.Hgt, iMarginX, iMarginY);
1146  }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262

References C4Rect::Hgt, iMarginX, iMarginY, LogF(), rcClientArea, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Here is the call graph for this function:

Member Data Documentation

◆ iMarginX

int32_t C4GUI::ComponentAligner::iMarginX
protected

◆ iMarginY

int32_t C4GUI::ComponentAligner::iMarginY
protected

◆ rcClientArea

◆ rcTemp

C4Rect C4GUI::ComponentAligner::rcTemp
staticprotected

The documentation for this class was generated from the following files: