OpenClonk
C4ScriptGuiWindow Class Reference

#include <C4ScriptGuiWindow.h>

Inheritance diagram for C4ScriptGuiWindow:
[legend]
Collaboration diagram for C4ScriptGuiWindow:
[legend]

Public Types

enum  MouseState { None = 0, Focus = 1, MouseDown = 2 }
 

Public Member Functions

void SetTag (C4String *tag)
 
 C4ScriptGuiWindow ()
 
 ~C4ScriptGuiWindow () override
 
int32_t GetID ()
 
C4ScriptGuiWindowGetChildByID (int32_t child)
 
C4ScriptGuiWindowGetChildByName (C4String *childName)
 
C4ScriptGuiWindowGetSubWindow (int32_t childID, C4Object *childTarget)
 
bool CreateFromPropList (C4PropList *proplist, bool resetStdTag=false, bool isUpdate=false, bool isLoading=false)
 
const C4Value ToC4Value ()
 
void SetEnumeratedID (int enumID)
 
void Denumerate (C4ValueNumbers *numbers)
 
C4ScriptGuiWindowAddChild (C4ScriptGuiWindow *child)
 
C4ScriptGuiWindowAddChild ()
 
void ClearChildren (bool close=true)
 
void RemoveChild (C4ScriptGuiWindow *child, bool close=true, bool all=false)
 
void Close ()
 
void ClearPointers (C4Object *pObj)
 
float CalculateRelativeSize (float parentWidthOrHeight, C4ScriptGuiWindowPropertyName::type absoluteProperty, C4ScriptGuiWindowPropertyName::type relativeProperty)
 
void RequestLayoutUpdate ()
 
bool UpdateLayout (C4TargetFacet &cgo)
 
bool UpdateLayout (C4TargetFacet &cgo, float parentWidth, float parentHeight)
 
bool UpdateChildLayout (C4TargetFacet &cgo, float parentWidth, float parentHeight)
 
void UpdateLayoutGrid ()
 
void UpdateLayoutTightGrid ()
 
void UpdateLayoutVertical ()
 
void Draw (C4TargetFacet &cgo) override
 
bool DrawAll (C4TargetFacet &cgo, int32_t player)
 
bool Draw (C4TargetFacet &cgo, int32_t player, C4Rect *currentClippingRect)
 
bool GetClippingRect (int32_t &left, int32_t &top, int32_t &right, int32_t &bottom)
 
bool DrawChildren (C4TargetFacet &cgo, int32_t player, int32_t withMultipleFlag=-1, C4Rect *currentClippingRect=nullptr)
 
bool ExecuteCommand (int32_t actionID, int32_t player, int32_t subwindowID, int32_t actionType, C4Object *target)
 
virtual bool MouseInput (int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual bool ProcessMouseInput (int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, int32_t parentOffsetX, int32_t parentOffsetY)
 
void MouseEnter (C4GUI::CMouse &rMouse) override
 
void MouseLeave (C4GUI::CMouse &rMouse) override
 
void OnMouseOut (int32_t player)
 
void OnMouseIn (int32_t player, int32_t parentOffsetX, int32_t parentOffsetY)
 
bool HasMouseFocus ()
 
bool IsVisibleTo (int32_t player)
 
void MouseInput (CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
 
bool IsComponentOutsideClientArea () override
 
void Update ()
 
void UpdateOwnPos () override
 
void Freeze ()
 
void UnFreeze ()
 
bool IsFrozen () const
 
void SetClientHeight (int32_t iToHgt)
 
void SetDecoration (ScrollBarFacets *pToGfx, bool fAutoScroll)
 
void SetScroll (int32_t iToScroll)
 
void ScrollToBottom ()
 
void ScrollPages (int iPageCount)
 
void ScrollBy (int iAmount)
 
void ScrollRangeInView (int32_t iY, int32_t iHgt)
 
bool IsRangeInView (int32_t iY, int32_t iHgt)
 
int32_t GetScrollY ()
 
void SetScrollBarEnabled (bool fToVal, bool noAutomaticPositioning=false)
 
bool IsScrollBarEnabled ()
 
bool IsScrollingActive ()
 
bool IsScrollingNecessary ()
 
void SetPos (int32_t iXPos, int32_t iYPos)
 
C4RectGetClientRect () override
 
void ApplyElementOffset (int32_t &riX, int32_t &riY) override
 
void ApplyInvElementOffset (int32_t &riX, int32_t &riY) override
 
virtual int32_t GetMarginTop ()
 
virtual int32_t GetMarginLeft ()
 
virtual int32_t GetMarginRight ()
 
virtual int32_t GetMarginBottom ()
 
void Clear ()
 
void ClearChildren ()
 
void RemoveElement (Element *pChild) override
 
void MakeLastElement (Element *pChild)
 
void AddElement (Element *pChild)
 
void ReaddElement (Element *pChild)
 
void InsertElement (Element *pChild, Element *pInsertBefore)
 
ElementGetNextNestedElement (Element *pPrevElement, bool fBackwards)
 
ElementGetFirstContained () override
 
virtual ElementGetLastContained ()
 
ElementGetFirstNestedElement (bool fBackwards) override
 
Iterator begin ()
 
Iterator end ()
 
ReverseIterator rbegin ()
 
ReverseIterator rend ()
 
ElementGetFirst ()
 
ElementGetLast ()
 
ContainerGetContainer () override
 
ElementGetElementByIndex (int32_t i)
 
int32_t GetElementCount ()
 
void SetVisibility (bool fToValue) override
 
virtual bool IsFocused (Control *pCtrl)
 
virtual bool IsSelectedChild (Element *pChild)
 
bool IsParentOf (Element *pEl) override
 
virtual void StartDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual void DoDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual void StopDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
bool DoContext ()
 
ContainerGetParent ()
 
virtual class Dialog * GetDlg ()
 
virtual Screen * GetScreen ()
 
virtual ControlIsFocusElement ()
 
void ScreenPos2ClientPos (int32_t &riX, int32_t &riY)
 
void ClientPos2ScreenPos (int32_t &riX, int32_t &riY)
 
void SetToolTip (const char *szNewTooltip, bool is_immediate=false)
 
const char * GetToolTip ()
 
const char * GetOwnToolTip ()
 
bool IsImmediateToolTip () const
 
int32_t GetWidth ()
 
int32_t GetHeight ()
 
C4RectGetBounds ()
 
void SetBounds (const C4Rect &rcNewBound)
 
C4Rect GetContainedClientRect ()
 
ElementGetNext () const
 
ElementGetPrev () const
 
bool IsInActiveDlg (bool fForKeyboard)
 
C4Rect GetToprightCornerRect (int32_t iWidth=16, int32_t iHeight=16, int32_t iHIndent=4, int32_t iVIndent=4, int32_t iIndexX=0)
 
bool IsVisible ()
 
virtual int32_t GetListItemTopSpacing ()
 
virtual bool GetListItemTopSpacingBar ()
 
void SetDragTarget (Window *pToWindow)
 
void SetContextHandler (ContextHandler *pNewHd)
 
virtual ContextHandler * GetContextHandler ()
 

Public Attributes

int32_t currentMouseState
 
bool fVisible {true}
 

Static Public Attributes

static const float standardWidth = 50.0f
 
static const float standardHeight = 31.0f
 

Protected Member Functions

void ElementSizeChanged (Element *pOfElement) override
 
void ElementPosChanged (Element *pOfElement) override
 
virtual void AfterElementRemoval ()
 
bool OnHotkey (uint32_t cHotkey) override
 
virtual void DrawElement (C4TargetFacet &cgo)
 
virtual void UpdateSize ()
 
virtual void UpdatePos ()
 
void Draw3DFrame (C4TargetFacet &cgo, bool fUp=false, int32_t iIndent=1, BYTE byAlpha=C4GUI_BorderAlpha, bool fDrawTop=true, int32_t iTopOff=0, bool fDrawLeft=true, int32_t iLeftOff=0)
 
void DrawBar (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawVBar (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawHBarByVGfx (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawHVBar (C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
 
virtual bool IsOwnPtrElement ()
 
virtual bool IsExternalDrawDialog ()
 
virtual bool IsMenu ()
 
virtual class DialogWindow * GetDialogWindow ()
 
virtual bool CheckNameHotkey (const char *)
 

Protected Attributes

ScrollBarpScrollBar
 
int32_t iScrollY
 
int32_t iClientHeight
 
bool fHasBar
 
int32_t iFrozen
 
C4Rect rcClientRect
 
ElementpFirst
 
ElementpLast
 
ContainerpParent {nullptr}
 
ElementpPrev
 
ElementpNext
 
WindowpDragTarget {nullptr}
 
int32_t iDragX
 
int32_t iDragY
 
bool fDragging {false}
 
ContextHandler * pContextHandler {nullptr}
 
C4Rect rcBounds
 

Friends

class C4ScriptGuiWindowAction
 
class C4ScriptGuiWindowScrollBar
 

Detailed Description

Definition at line 179 of file C4ScriptGuiWindow.h.

Member Enumeration Documentation

◆ MouseState

Enumerator
None 
Focus 
MouseDown 

Definition at line 333 of file C4ScriptGuiWindow.h.

Constructor & Destructor Documentation

◆ C4ScriptGuiWindow()

C4ScriptGuiWindow::C4ScriptGuiWindow ( )

Definition at line 624 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowPropertyName::_lastProp, ANY_OWNER, C4ScriptGuiWindowPropertyName::backgroundColor, C4ScriptGuiWindowPropertyName::bottom, C4ScriptGuiWindowPropertyName::bottomMargin, currentMouseState, C4GUI::ScrollBar::fAutoHide, C4ScriptGuiWindowPropertyName::frameDecoration, C4Rect::Hgt, C4ScriptGuiWindowPropertyName::left, C4ScriptGuiWindowPropertyName::leftMargin, C4ScriptGuiWindowStyleFlag::None, C4ScriptGuiWindowPropertyName::onClickAction, C4ScriptGuiWindowPropertyName::onCloseAction, C4ScriptGuiWindowPropertyName::onMouseInAction, C4ScriptGuiWindowPropertyName::onMouseOutAction, C4ScriptGuiWindowPropertyName::player, C4ScriptGuiWindowPropertyName::priority, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4ScriptGuiWindowPropertyName::relBottom, C4ScriptGuiWindowPropertyName::relBottomMargin, C4ScriptGuiWindowPropertyName::relLeft, C4ScriptGuiWindowPropertyName::relLeftMargin, C4ScriptGuiWindowPropertyName::relRight, C4ScriptGuiWindowPropertyName::relRightMargin, C4ScriptGuiWindowPropertyName::relTop, C4ScriptGuiWindowPropertyName::relTopMargin, C4ScriptGuiWindowPropertyName::right, C4ScriptGuiWindowPropertyName::rightMargin, C4ScriptGuiWindowPropertyName::style, C4ScriptGuiWindowPropertyName::symbolDef, C4ScriptGuiWindowPropertyName::symbolGraphicsName, C4ScriptGuiWindowPropertyName::symbolObject, C4ScriptGuiWindowPropertyName::text, C4ScriptGuiWindowPropertyName::tooltip, C4ScriptGuiWindowPropertyName::top, C4ScriptGuiWindowPropertyName::topMargin, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by CreateFromPropList().

624  : C4GUI::ScrollWindow(this)
625 {
626  Init();
627 }
Here is the caller graph for this function:

◆ ~C4ScriptGuiWindow()

C4ScriptGuiWindow::~C4ScriptGuiWindow ( )
override

Definition at line 688 of file C4ScriptGuiWindow.cpp.

References C4PropList::begin(), C4ScriptGuiWindowPropertyName::bottomMargin, C4V_Array, C4V_Nil, C4V_PropList, C4V_String, C4GUI::Container::ClearChildren(), C4RefCnt::DecRef(), C4PropList::end(), StdStrBuf::Format(), C4String::GetCStr(), C4ValueArray::GetItem(), C4ValueArray::GetSize(), C4Value::getStr(), C4Value::GetType(), C4Value::GetTypeName(), C4ScriptGuiWindowPropertyName::leftMargin, LogF(), C4PropList::New(), C4GUI::ScrollWindow::pScrollBar, C4StringTable::RegString(), C4ScriptGuiWindowPropertyName::relBottomMargin, C4ScriptGuiWindowPropertyName::relLeftMargin, C4ScriptGuiWindowPropertyName::relRightMargin, C4ScriptGuiWindowPropertyName::relTopMargin, C4ScriptGuiWindowPropertyName::rightMargin, C4ValueArray::SetItem(), C4PropList::SetPropertyByS(), C4ValueArray::SetSize(), Strings, and C4ScriptGuiWindowPropertyName::topMargin.

689 {
690  ClearChildren(false);
691 
692  // delete certain properties that contain allocated elements or referenced strings
693  for (auto & prop : props)
694  prop.CleanUpAll();
695 
696  if (pScrollBar)
697  delete pScrollBar;
698  if (name)
699  name->DecRef();
700 }
ScrollBar * pScrollBar
Definition: C4Gui.h:942
void DecRef()
Definition: C4StringTable.h:28
Here is the call graph for this function:

Member Function Documentation

◆ AddChild() [1/2]

C4ScriptGuiWindow * C4ScriptGuiWindow::AddChild ( C4ScriptGuiWindow child)

Definition at line 1189 of file C4ScriptGuiWindow.cpp.

References GetID(), C4ScriptGuiWindowProperty::GetInt(), C4GUI::Element::GetParent(), C4GUI::Container::InsertElement(), MenuDebugLogF, and C4ScriptGuiWindowPropertyName::priority.

1190 {
1191  if (IsRoot())
1192  {
1193  child->SetID(GenerateMenuID());
1194  child->isMainWindow = true;
1195  // update all windows asap
1196  mainWindowNeedsLayoutUpdate = true;
1197  }
1198 
1199  // child's priority is ususally 0 here, so just insert it in front of other windows with a priority below 0
1200  // when the child's priority updates, the update function will be called and the child will be sorted to the correct position
1201  ChildChangedPriority(child);
1202 
1203  return child;
1204 }
Here is the call graph for this function:

◆ AddChild() [2/2]

C4ScriptGuiWindow* C4ScriptGuiWindow::AddChild ( )
inline

Definition at line 280 of file C4ScriptGuiWindow.h.

References AddChild().

Referenced by AddChild(), and CreateFromPropList().

280 { return AddChild(new C4ScriptGuiWindow()); }
C4ScriptGuiWindow * AddChild()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddElement()

void C4GUI::Container::AddElement ( Element pChild)
inherited

Definition at line 118 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, C4GUI::Element::pPrev, and C4GUI::Container::RemoveElement().

Referenced by C4Menu::Add(), C4GUI::Tabular::AddCustomSheet(), C4GUI::ListBox::AddElement(), C4ChartDialog::C4ChartDialog(), C4ChatControl::C4ChatControl(), C4ChatDlg::C4ChatDlg(), C4DownloadDlg::C4DownloadDlg(), C4GameOptionButtons::C4GameOptionButtons(), C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Menu::C4Menu(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextButton::ContextButton(), C4MapFolderData::CreateGUIElements(), C4GUI::InfoDialog::CreateSubComponents(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4GUI::FullscreenDialog::FullscreenDialog(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), C4GUI::Container::InsertElement(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4ChatControl::ChatSheet::NickItem::NickItem(), C4StartupPlrColorPickerDlg::OnClosed(), C4GUI::ProgressDialog::ProgressDialog(), C4GUI::ContextMenu::RemoveElement(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollWindow(), C4GUI::InputDialog::SetCustomEdit(), C4GUI::Dialog::SetTitle(), C4GUI::FullscreenDialog::SetTitle(), C4ChatControl::ChatSheet::NickItem::SortFunc(), C4GUI::TextWindow::TextWindow(), C4Network2ClientDlg::UpdateText(), and C4DownloadDlg::~C4DownloadDlg().

119  {
120  // safety
121  if (!pChild) return;
122  // remove from any previous container
123  if (pChild->pParent) pChild->pParent->RemoveElement(pChild);
124  // add to end of list
125  if (pLast) pLast->pNext = pChild; else pFirst = pChild;
126  pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
127  pChild->pParent = this;
128 
129  assert(pChild->pNext != pChild);
130  assert(pChild->pPrev != pChild);
131  assert(pChild->pParent != pChild);
132  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Container * pParent
Definition: C4Gui.h:376
Element * pNext
Definition: C4Gui.h:377
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AfterElementRemoval()

virtual void C4GUI::Container::AfterElementRemoval ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::ListBox.

Definition at line 756 of file C4Gui.h.

Referenced by C4GUI::ListBox::AfterElementRemoval(), and C4GUI::Container::RemoveElement().

757  { if (pParent) pParent->AfterElementRemoval(); } // called by ScrollWindow to parent after an element has been removed
virtual void AfterElementRemoval()
Definition: C4Gui.h:756
Container * pParent
Definition: C4Gui.h:376
Here is the caller graph for this function:

◆ ApplyElementOffset()

void C4GUI::Window::ApplyElementOffset ( int32_t &  riX,
int32_t &  riY 
)
inlineoverridevirtualinherited

Reimplemented from C4GUI::Container.

Reimplemented in C4GUI::Dialog.

Definition at line 866 of file C4Gui.h.

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

Referenced by C4GUI::Dialog::ApplyElementOffset().

867  { riX -= rcClientRect.x; riY -= rcClientRect.y; }
C4Rect rcClientRect
Definition: C4Gui.h:851
int32_t y
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ ApplyInvElementOffset()

void C4GUI::Window::ApplyInvElementOffset ( int32_t &  riX,
int32_t &  riY 
)
inlineoverridevirtualinherited

Reimplemented from C4GUI::Container.

Reimplemented in C4GUI::Dialog.

Definition at line 868 of file C4Gui.h.

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

Referenced by C4GUI::Dialog::ApplyInvElementOffset().

869  { riX += rcClientRect.x; riY += rcClientRect.y; }
C4Rect rcClientRect
Definition: C4Gui.h:851
int32_t y
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ begin()

Iterator C4GUI::Container::begin ( )
inlineinherited

Definition at line 824 of file C4Gui.h.

Referenced by ClearPointers().

824 { return Iterator(pFirst); }
Element * pFirst
Definition: C4Gui.h:750
Here is the caller graph for this function:

◆ CalculateRelativeSize()

float C4ScriptGuiWindow::CalculateRelativeSize ( float  parentWidthOrHeight,
C4ScriptGuiWindowPropertyName::type  absoluteProperty,
C4ScriptGuiWindowPropertyName::type  relativeProperty 
)

Definition at line 1382 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowProperty::GetFloat().

Referenced by UpdateLayoutGrid(), UpdateLayoutTightGrid(), and UpdateLayoutVertical().

1383 {
1384  const float widthOrHeight = Em2Pix(props[absoluteProperty].GetFloat())
1385  + float(parentWidthOrHeight) * props[relativeProperty].GetFloat();
1386  return widthOrHeight;
1387 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckNameHotkey()

virtual bool C4GUI::Element::CheckNameHotkey ( const char *  )
inlineprotectedvirtualinherited

Reimplemented in C4StartupScenSelDlg::ScenListItem.

Definition at line 407 of file C4Gui.h.

Referenced by C4GUI::ListBox::CharIn().

407 { return false; }
Here is the caller graph for this function:

◆ Clear()

void C4GUI::Container::Clear ( )
inherited

Definition at line 63 of file C4GuiContainers.cpp.

References C4GUI::Container::ClearChildren().

Referenced by C4GUI::Screen::Clear(), C4GUI::ComboBox_FillCB::ClearEntries(), C4StartupNetListEntry::ClearRef(), C4Scoreboard::CompileFunc(), C4ClientList::CompileFunc(), C4ClientList::Init(), C4MapFolderData::Load(), C4StartupNetListEntry::SetReference(), C4ClientList::~C4ClientList(), C4MapFolderData::~C4MapFolderData(), C4MessageInput::~C4MessageInput(), C4GUI::Container::~Container(), and C4GUI::ContextMenu::~ContextMenu().

64  {
65  ClearChildren();
66  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearChildren() [1/2]

void C4ScriptGuiWindow::ClearChildren ( bool  close = true)

Definition at line 1324 of file C4ScriptGuiWindow.cpp.

References RemoveChild().

1325 {
1326  RemoveChild(nullptr, close, true);
1327 }
void RemoveChild(C4ScriptGuiWindow *child, bool close=true, bool all=false)
Here is the call graph for this function:

◆ ClearChildren() [2/2]

void C4GUI::Container::ClearChildren ( )
inherited

Definition at line 68 of file C4GuiContainers.cpp.

References C4GUI::Element::IsOwnPtrElement(), C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::Container::Clear(), Close(), RemoveChild(), C4GoalDisplay::SetGoals(), and ~C4ScriptGuiWindow().

69  {
70  // delete all items; dtor will update list
71  while (pFirst)
72  {
73  if (pFirst->IsOwnPtrElement())
74  {
75  // unlink from list
76  Element *pANext = pFirst->pNext;
77  pFirst->pPrev = pFirst->pNext = nullptr;
78  pFirst->pParent = nullptr;
79  if ((pFirst = pANext))
80  pFirst->pPrev = nullptr;
81  else
82  pLast = nullptr;
83  }
84  else
85  delete pFirst;
86  }
87  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Container * pParent
Definition: C4Gui.h:376
virtual bool IsOwnPtrElement()
Definition: C4Gui.h:401
Element * pNext
Definition: C4Gui.h:377
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearPointers()

void C4ScriptGuiWindow::ClearPointers ( C4Object pObj)

Definition at line 1161 of file C4ScriptGuiWindow.cpp.

References C4GUI::Container::begin(), C4ScriptGuiWindowProperty::ClearPointers(), ClearPointers(), Close(), C4GUI::Container::end(), C4ScriptGuiWindowPropertyName::onClickAction, C4ScriptGuiWindowPropertyName::onCloseAction, C4ScriptGuiWindowPropertyName::onMouseInAction, C4ScriptGuiWindowPropertyName::onMouseOutAction, and C4ScriptGuiWindowPropertyName::symbolObject.

Referenced by C4ScriptGuiWindowAction::C4ScriptGuiWindowAction(), ClearPointers(), and C4ScriptGuiWindowProperty::GetCurrentTag().

1162 {
1163  // not removing or clearing anything twice
1164  // if this flag is set, the object will not be used after this frame (callbacks?) anyway
1165  if (wasRemoved) return;
1166 
1167  if (target == pObj)
1168  {
1169  Close();
1170  return;
1171  }
1172 
1173  // all properties which have anything to do with objects need to be called from here!
1179 
1180  for (auto iter = begin(); iter != end();)
1181  {
1182  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(*iter);
1183  // increment the iterator before (possibly) deleting the child
1184  ++iter;
1185  child->ClearPointers(pObj);
1186  }
1187 }
Iterator begin()
Definition: C4Gui.h:824
void ClearPointers(C4Object *pObj)
void ClearPointers(C4Object *pObj)
Iterator end()
Definition: C4Gui.h:825
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClientPos2ScreenPos()

void C4GUI::Element::ClientPos2ScreenPos ( int32_t &  riX,
int32_t &  riY 
)
inherited

Definition at line 231 of file C4Gui.cpp.

References C4GUI::Container::ApplyInvElementOffset(), and C4GUI::Element::GetParent().

Referenced by C4MapFolderData::CreateGUIElements(), C4GUI::Screen::DoContext(), and C4Menu::Draw().

232  {
233  // apply all parent offsets
234  Container *pCont = pParent;
235  while (pCont)
236  {
237  pCont->ApplyInvElementOffset(riX, riY);
238  pCont = pCont->GetParent();
239  }
240  // apply own offset
241  riX += rcBounds.x; riY += rcBounds.y;
242  }
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
Container * pParent
Definition: C4Gui.h:376
int32_t x
Definition: C4Rect.h:30
friend class Container
Definition: C4Gui.h:472
virtual void ApplyInvElementOffset(int32_t &riX, int32_t &riY)
Definition: C4Gui.h:841
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Close()

void C4ScriptGuiWindow::Close ( )

Definition at line 1329 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowPropertyName::bottom, C4ScriptGuiWindowPropertyName::bottomMargin, C4ScriptGuiWindowActionID::Call, C4GUI::Container::ClearChildren(), C4ScriptGuiWindowAction::ExecuteCommand(), C4ScriptGuiWindowStyleFlag::FitChildren, C4ScriptGuiWindowProperty::GetAction(), C4ScriptGuiWindowProperty::GetInt(), C4GUI::Element::GetParent(), C4Rect::Hgt, NO_OWNER, C4ScriptGuiWindowStyleFlag::NoCrop, C4ScriptGuiWindowPropertyName::onCloseAction, C4GUI::Element::rcBounds, RemoveChild(), RequestLayoutUpdate(), C4GUI::ScrollWindow::SetScrollBarEnabled(), C4ScriptGuiWindowPropertyName::style, and C4ScriptGuiWindowPropertyName::topMargin.

Referenced by ClearPointers(), and RemoveChild().

1330 {
1331  // first, close all children and dispose of them properly
1332  ClearChildren(true);
1333 
1334  if (!closeActionWasExecuted)
1335  {
1336  closeActionWasExecuted = true;
1337 
1338  // make call to target object if applicable
1340  // only calls are valid actions for OnClose
1341  if (action && action->action == C4ScriptGuiWindowActionID::Call)
1342  {
1343  // close is always syncronized (script call/object removal) and thus the action can be executed immediately
1344  // (otherwise the GUI&action would have been removed anyway..)
1345  action->ExecuteCommand(action->id, this, NO_OWNER);
1346  }
1347  }
1348 
1349  if (!wasRemoved)
1350  {
1351  assert(GetParent() && "Close()ing GUIWindow without parent");
1352  static_cast<C4ScriptGuiWindow*>(GetParent())->RemoveChild(this);
1353  }
1354 }
Container * GetParent()
Definition: C4Gui.h:429
void RemoveChild(C4ScriptGuiWindow *child, bool close=true, bool all=false)
const int NO_OWNER
Definition: C4Constants.h:137
C4ScriptGuiWindowAction * GetAction()
bool ExecuteCommand(int32_t actionID, C4ScriptGuiWindow *parent, int32_t player)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateFromPropList()

bool C4ScriptGuiWindow::CreateFromPropList ( C4PropList proplist,
bool  resetStdTag = false,
bool  isUpdate = false,
bool  isLoading = false 
)

Definition at line 990 of file C4ScriptGuiWindow.cpp.

References AddChild(), C4ScriptGuiWindowPropertyName::backgroundColor, C4ScriptGuiWindowPropertyName::bottom, C4ScriptGuiWindow(), CreateFromPropList(), currentMouseState, C4ScriptGuiWindowPropertyName::frameDecoration, GetChildByName(), C4String::GetCStr(), C4GUI::Element::GetParent(), C4PropList::GetProperties(), C4PropList::GetPropertyByS(), C4Value::getStr(), C4RefCnt::IncRef(), C4ScriptGuiWindowPropertyName::left, MenuDebugLogF, C4ScriptGuiWindowPropertyName::onClickAction, C4ScriptGuiWindowPropertyName::onCloseAction, C4ScriptGuiWindowPropertyName::onMouseInAction, C4ScriptGuiWindowPropertyName::onMouseOutAction, C4StringTable::P, P_BackgroundColor, P_Bottom, P_Decoration, P_GraphicsName, P_ID, P_Left, P_Margin, P_Mode, P_OnClick, P_OnClose, P_OnMouseIn, P_OnMouseOut, P_Player, P_Priority, P_Prototype, P_Right, P_Std, P_Style, P_Symbol, P_Target, P_Text, P_Tooltip, P_Top, C4ScriptGuiWindowPropertyName::player, C4ScriptGuiWindowPropertyName::priority, C4ScriptGuiWindowPropertyName::relBottom, C4ScriptGuiWindowPropertyName::relLeft, C4ScriptGuiWindowPropertyName::relRight, C4ScriptGuiWindowPropertyName::relTop, RemoveChild(), RequestLayoutUpdate(), C4ScriptGuiWindowPropertyName::right, C4ScriptGuiWindowProperty::Set(), SetTag(), Strings, C4ScriptGuiWindowPropertyName::style, C4ScriptGuiWindowPropertyName::symbolDef, C4ScriptGuiWindowPropertyName::symbolGraphicsName, C4ScriptGuiWindowPropertyName::symbolObject, C4ScriptGuiWindowPropertyName::text, C4ScriptGuiWindowPropertyName::tooltip, and C4ScriptGuiWindowPropertyName::top.

Referenced by CreateFromPropList(), and Denumerate().

991 {
992  if (!proplist) return false;
993  C4ScriptGuiWindow * parent = static_cast<C4ScriptGuiWindow*>(GetParent());
994  assert((parent || isLoading) && "GuiWindow created from proplist without parent (fails for ID tag)");
995 
996  bool layoutUpdateRequired = false; // needed for position changes etc
997 
998  // Get properties from proplist and check for those, that match an allowed property to set them;
999  // We take ownership here. Automatically destroy the object when we're done.
1000  std::unique_ptr<C4ValueArray> properties(proplist->GetProperties());
1001  properties->SortStrings();
1002  C4String *stdTag = &Strings.P[P_Std];
1003  const int32_t propertySize = properties->GetSize();
1004  for (int32_t i = 0; i < propertySize; ++i)
1005  {
1006  const C4Value &entry = properties->GetItem(i);
1007  C4String *key = entry.getStr();
1008  assert(key && "PropList returns non-string as key");
1009  MenuDebugLogF("--%s\t\t(I am %d)", key->GetCStr(), id);
1010  C4Value property;
1011  proplist->GetPropertyByS(key, &property);
1012 
1013  if(&Strings.P[P_Left] == key)
1014  {
1015  SetPositionStringProperties(property, C4ScriptGuiWindowPropertyName::relLeft, C4ScriptGuiWindowPropertyName::left, stdTag);
1016  layoutUpdateRequired = true;
1017  }
1018  else if(&Strings.P[P_Top] == key)
1019  {
1020  SetPositionStringProperties(property, C4ScriptGuiWindowPropertyName::relTop, C4ScriptGuiWindowPropertyName::top, stdTag);
1021  layoutUpdateRequired = true;
1022  }
1023  else if(&Strings.P[P_Right] == key)
1024  {
1025  SetPositionStringProperties(property, C4ScriptGuiWindowPropertyName::relRight, C4ScriptGuiWindowPropertyName::right, stdTag);
1026  layoutUpdateRequired = true;
1027  }
1028  else if(&Strings.P[P_Bottom] == key)
1029  {
1030  SetPositionStringProperties(property, C4ScriptGuiWindowPropertyName::relBottom, C4ScriptGuiWindowPropertyName::bottom, stdTag);
1031  layoutUpdateRequired = true;
1032  }
1033  else if (&Strings.P[P_Margin] == key)
1034  {
1035  SetMarginProperties(property, stdTag);
1036  layoutUpdateRequired = true;
1037  }
1038  else if(&Strings.P[P_BackgroundColor] == key)
1039  props[C4ScriptGuiWindowPropertyName::backgroundColor].Set(property, stdTag);
1040  else if(&Strings.P[P_Target] == key)
1041  target = property.getObj();
1042  else if(&Strings.P[P_Symbol] == key)
1043  {
1044  props[C4ScriptGuiWindowPropertyName::symbolDef].Set(property, stdTag);
1045  props[C4ScriptGuiWindowPropertyName::symbolObject].Set(property, stdTag);
1046  }
1047  else if(&Strings.P[P_Decoration] == key)
1048  {
1049  props[C4ScriptGuiWindowPropertyName::frameDecoration].Set(property, stdTag);
1050  }
1051  else if(&Strings.P[P_Text] == key)
1052  {
1053  props[C4ScriptGuiWindowPropertyName::text].Set(property, stdTag);
1054  layoutUpdateRequired = true;
1055  }
1056  else if (&Strings.P[P_GraphicsName] == key)
1057  {
1058  props[C4ScriptGuiWindowPropertyName::symbolGraphicsName].Set(property, stdTag);
1059  }
1060  else if (&Strings.P[P_Tooltip] == key)
1061  {
1062  props[C4ScriptGuiWindowPropertyName::tooltip].Set(property, stdTag);
1063  }
1064  else if(&Strings.P[P_Prototype] == key)
1065  ; // do nothing
1066  else if (&Strings.P[P_Mode] == key) // note that "Mode" is abused here for saving whether we have mouse focus
1067  {
1068  if (isLoading)
1069  currentMouseState = property.getInt();
1070  }
1071  else if(&Strings.P[P_ID] == key)
1072  {
1073  // setting IDs is only valid for subwindows or when loading savegames!
1074  if (parent && !isMainWindow)
1075  {
1076  if (id) // already have an ID? remove from parent
1077  parent->ChildWithIDRemoved(this);
1078  id = property.getInt();
1079  if (id != 0)
1080  parent->ChildGotID(this);
1081  }
1082  else
1083  if (isLoading)
1084  id = property.getInt();
1085  }
1086  else if (&Strings.P[P_OnClick] == key)
1087  {
1088  MenuDebugLogF("Adding new action, I am window %d with parent %d", id, static_cast<C4ScriptGuiWindow*>(parent)->id);
1089  props[C4ScriptGuiWindowPropertyName::onClickAction].Set(property, stdTag);
1090  }
1091  else if(&Strings.P[P_OnMouseIn] == key)
1092  props[C4ScriptGuiWindowPropertyName::onMouseInAction].Set(property, stdTag);
1093  else if(&Strings.P[P_OnMouseOut] == key)
1094  props[C4ScriptGuiWindowPropertyName::onMouseOutAction].Set(property, stdTag);
1095  else if(&Strings.P[P_OnClose] == key)
1096  props[C4ScriptGuiWindowPropertyName::onCloseAction].Set(property, stdTag);
1097  else if(&Strings.P[P_Style] == key)
1098  {
1099  props[C4ScriptGuiWindowPropertyName::style].Set(property, stdTag);
1100  layoutUpdateRequired = true;
1101  }
1102  else if(&Strings.P[P_Priority] == key)
1103  {
1104  props[C4ScriptGuiWindowPropertyName::priority].Set(property, stdTag);
1105  layoutUpdateRequired = true;
1106  // resort into parent's list
1107  if (parent)
1108  parent->ChildChangedPriority(this);
1109  }
1110  else if(&Strings.P[P_Player] == key)
1111  props[C4ScriptGuiWindowPropertyName::player].Set(property, stdTag);
1112  else
1113  {
1114  // possibly sub-window?
1115  C4PropList *subwindow = property.getPropList();
1116  if (subwindow)
1117  {
1118  // remember the name of the child; but ignore names starting with underscores
1119  C4String *childName = nullptr;
1120  if (key->GetCStr()[0] != '_')
1121  childName = key;
1122 
1123  // Do we already have a child with that name? That implies that we are updating here.
1124  C4ScriptGuiWindow *child = GetChildByName(childName);
1125  bool freshlyAdded = false;
1126 
1127  // first time referencing a child with that name? Create a new one!
1128  if (!child)
1129  {
1130  child = new C4ScriptGuiWindow();
1131  if (childName != nullptr)
1132  {
1133  child->name = childName;
1134  child->name->IncRef();
1135  }
1136  AddChild(child);
1137  freshlyAdded = true;
1138  }
1139 
1140  if (!child->CreateFromPropList(subwindow, isUpdate == true, false, isLoading))
1141  {
1142  // Remove the child again if we just added it. However, ignore when just updating an existing child.
1143  if (freshlyAdded)
1144  RemoveChild(child, false);
1145  }
1146  else
1147  layoutUpdateRequired = true;
1148  }
1149  }
1150  }
1151 
1152  if (!isLoading && layoutUpdateRequired)
1154 
1155  if (resetStdTag || isLoading)
1156  SetTag(stdTag);
1157 
1158  return true;
1159 }
C4String P[P_LAST]
#define MenuDebugLogF(...)
C4String * getStr() const
Definition: C4Value.h:117
void IncRef()
Definition: C4StringTable.h:27
void SetTag(C4String *tag)
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:914
const char * GetCStr() const
Definition: C4StringTable.h:49
C4StringTable Strings
Definition: C4Globals.cpp:42
Container * GetParent()
Definition: C4Gui.h:429
void RemoveChild(C4ScriptGuiWindow *child, bool close=true, bool all=false)
C4ScriptGuiWindow * GetChildByName(C4String *childName)
C4ScriptGuiWindow * AddChild()
bool CreateFromPropList(C4PropList *proplist, bool resetStdTag=false, bool isUpdate=false, bool isLoading=false)
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
void Set(const C4Value &value, C4String *tag)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Denumerate()

void C4ScriptGuiWindow::Denumerate ( C4ValueNumbers numbers)

Definition at line 867 of file C4ScriptGuiWindow.cpp.

References CreateFromPropList(), C4Value::getPropList(), C4ValueNumbers::GetValue(), and RequestLayoutUpdate().

868 {
869  assert(IsRoot());
870  if (id == 0)
871  {
872  // nothing to do, note that the id is abused for the id in the enumeration
873  return;
874  }
875  C4Value value = numbers->GetValue(id);
876  id = 0;
877  CreateFromPropList(value.getPropList(), false, false, true);
878 
879  for (C4GUI::Element * element : *this)
880  {
881  C4ScriptGuiWindow *mainWindow = static_cast<C4ScriptGuiWindow*>(element);
882  mainWindow->RequestLayoutUpdate();
883  }
884 }
C4PropList * getPropList() const
Definition: C4Value.h:116
bool CreateFromPropList(C4PropList *proplist, bool resetStdTag=false, bool isUpdate=false, bool isLoading=false)
const C4Value & GetValue(uint32_t)
Definition: C4Value.cpp:243
Here is the call graph for this function:

◆ DoContext()

bool C4GUI::Element::DoContext ( )
inherited

Definition at line 417 of file C4Gui.cpp.

Referenced by C4GUI::ContextButton::MouseInput(), C4GUI::ListBox::OnGetFocus(), and C4GUI::ContextButton::~ContextButton().

418  {
419  if (!pContextHandler) return false;
420  return pContextHandler->OnContext(this, rcBounds.Wdt/2, rcBounds.Hgt/2);
421  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
int32_t Wdt
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
virtual bool OnContext(Element *pOnElement, int32_t iX, int32_t iY)=0
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ DoDragging()

void C4GUI::Element::DoDragging ( CMouse rMouse,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
virtualinherited

Reimplemented in C4GUI::Edit, and C4GUI::ScrollBar.

Definition at line 269 of file C4Gui.cpp.

Referenced by C4GUI::Screen::MouseInput().

270  {
271  // check if anything moved
272  if (pDragTarget && (iX != iDragX || iY != iDragY))
273  {
274  // move position, then
275  pDragTarget->rcBounds.x += iX-iDragX;
276  pDragTarget->rcBounds.y += iY-iDragY;
277  // drag X/Y is up-to-date if this is a child element of the drag target
279  }
280  }
int32_t iDragY
Definition: C4Gui.h:379
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
Window * pDragTarget
Definition: C4Gui.h:378
virtual void UpdatePos()
Definition: C4Gui.cpp:193
int32_t iDragX
Definition: C4Gui.h:379
Here is the caller graph for this function:

◆ Draw() [1/2]

void C4ScriptGuiWindow::Draw ( C4TargetFacet cgo)
inlineoverridevirtual

Reimplemented from C4GUI::Window.

Definition at line 302 of file C4ScriptGuiWindow.h.

References C4ScriptGuiWindowPropertyName::bottom, C4ScriptGuiWindowPropertyName::left, C4GUI::ScrollWindow::MouseInput(), C4ScriptGuiWindowPropertyName::player, C4ScriptGuiWindowPropertyName::right, and C4ScriptGuiWindowPropertyName::top.

Referenced by DrawChildren().

302 {}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw() [2/2]

bool C4ScriptGuiWindow::Draw ( C4TargetFacet cgo,
int32_t  player,
C4Rect currentClippingRect 
)

Definition at line 1888 of file C4ScriptGuiWindow.cpp.

References ACenter, ALeft, ARight, C4ScriptGuiWindowPropertyName::backgroundColor, CStdFont::BreakMessage(), C4RGB, currentMouseState, C4Def::Draw(), C4GUI::FrameDecoration::Draw(), C4Draw::DrawBoxDw(), DrawChildren(), C4Draw::DrawFrameDw(), C4Object::DrawPicture(), C4GraphicsResource::FontCaption, C4GraphicsResource::FontRegular, FormatString(), C4ScriptGuiWindowPropertyName::frameDecoration, StdStrBuf::getData(), CStdFont::GetLineHeight(), C4GUI::Element::GetParent(), C4GUI::ScrollWindow::GetScrollY(), CStdFont::GetTextExtent(), GraphicsResource, GraphicsSystem, C4Rect::Hgt, C4GUI::FrameDecoration::iBorderBottom, C4GUI::FrameDecoration::iBorderLeft, C4GUI::FrameDecoration::iBorderRight, C4GUI::FrameDecoration::iBorderTop, C4GUI::Element::IsVisible(), IsVisibleTo(), C4ScriptGuiWindowStyleFlag::Multiple, C4ScriptGuiWindowStyleFlag::NoCrop, pDraw, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4GraphicsSystem::ShowMenuInfo, C4ScriptGuiWindowPropertyName::style, C4Facet::Surface, C4ScriptGuiWindowPropertyName::symbolDef, C4ScriptGuiWindowPropertyName::symbolGraphicsName, C4ScriptGuiWindowPropertyName::symbolObject, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4ScriptGuiWindowPropertyName::text, C4ScriptGuiWindowStyleFlag::TextBottom, C4ScriptGuiWindowStyleFlag::TextHCenter, C4Draw::TextOut(), C4ScriptGuiWindowStyleFlag::TextRight, C4ScriptGuiWindowStyleFlag::TextVCenter, UpdateLayout(), C4Rect::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, and C4Facet::Y.

1889 {
1890  assert(!IsRoot()); // not root, root needs to receive DrawAll
1891 
1892  // message hidden?
1893  if (!IsVisibleTo(player)) return false;
1894 
1895  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
1896 
1897  if (mainWindowNeedsLayoutUpdate)
1898  {
1899  assert(GetParent() && (static_cast<C4ScriptGuiWindow*>(GetParent())->IsRoot()));
1900  assert(isMainWindow);
1901  assert(!(style & C4ScriptGuiWindowStyleFlag::Multiple) && "\"Multiple\"-style window not updated by a full refresh of the root window.");
1902  C4ScriptGuiWindow * parent = static_cast<C4ScriptGuiWindow*>(GetParent());
1903  UpdateLayout(cgo, parent->rcBounds.Wdt, parent->rcBounds.Hgt);
1904  assert(!mainWindowNeedsLayoutUpdate);
1905  }
1906 
1907  const int32_t outDrawX = cgo.X + cgo.TargetX + rcBounds.x;
1908  const int32_t outDrawY = cgo.Y + cgo.TargetY + rcBounds.y;
1909  const int32_t outDrawWdt = rcBounds.Wdt;
1910  const int32_t outDrawHgt = rcBounds.Hgt;
1911  const int32_t outDrawRight = outDrawX + rcBounds.Wdt;
1912  const int32_t outDrawBottom = outDrawY + rcBounds.Hgt;
1913  // draw various properties
1914  C4Facet cgoOut(cgo.Surface, outDrawX, outDrawY, outDrawWdt, outDrawHgt);
1915 
1917  if (backgroundColor)
1918  pDraw->DrawBoxDw(cgo.Surface, outDrawX, outDrawY, outDrawRight - 1.0f, outDrawBottom - 1.0f, backgroundColor);
1919 
1921 
1922  if (frameDecoration)
1923  {
1924  // the frame decoration will adjust for cgo.TargetX/Y itself
1925  C4Rect rect(
1926  outDrawX - frameDecoration->iBorderLeft - cgo.TargetX,
1927  outDrawY - frameDecoration->iBorderTop - cgo.TargetY,
1928  outDrawWdt + frameDecoration->iBorderRight + frameDecoration->iBorderLeft,
1929  outDrawHgt + frameDecoration->iBorderBottom + frameDecoration->iBorderTop);
1930  frameDecoration->Draw(cgo, rect);
1931  }
1932 
1934  if (symbolObject)
1935  {
1936  symbolObject->DrawPicture(cgoOut, false, nullptr);
1937  }
1938  else
1939  {
1942  if (symbolDef)
1943  {
1944  symbolDef->Draw(cgoOut, false, 0UL, nullptr, 0, 0, nullptr, graphicsName ? graphicsName->getData() : nullptr);
1945  }
1946  }
1947 
1949 
1950  if (strBuf)
1951  {
1952  StdStrBuf sText;
1953  int alignment = ALeft;
1954  // If we are showing a scrollbar, we need to leave a bit of space for it so that it doesn't overlap the text.
1955  const int scrollbarXOffset = pScrollBar->IsVisible() ? pScrollBar->rcBounds.Wdt : 0;
1956  const int scrollbarScroll = pScrollBar->IsVisible() ? this->GetScrollY() : 0;
1957  const int actualDrawingWidth = outDrawWdt - scrollbarXOffset;
1958 
1959  // If we are set to NoCrop, the message will be split by string-defined line breaks only.
1960  int allowedTextWidth = actualDrawingWidth;
1961 
1963  allowedTextWidth = std::numeric_limits<int>::max();
1964  int32_t textHgt = ::GraphicsResource.FontRegular.BreakMessage(strBuf->getData(), allowedTextWidth, &sText, true);
1965  float textYOffset = static_cast<float>(-scrollbarScroll), textXOffset = 0.0f;
1967  textYOffset = float(outDrawHgt) / 2.0f - float(textHgt) / 2.0f;
1968  else if (style & C4ScriptGuiWindowStyleFlag::TextBottom)
1969  textYOffset = float(outDrawHgt) - float(textHgt);
1971  {
1972  int wdt, hgt;
1973  ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(), wdt, hgt, true);
1974  textXOffset = float(actualDrawingWidth) / 2.0f;
1975  alignment = ACenter;
1976  }
1977  else if (style & C4ScriptGuiWindowStyleFlag::TextRight)
1978  {
1979  alignment = ARight;
1980  int wdt, hgt;
1981  ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(), wdt, hgt, true);
1982  textXOffset = float(actualDrawingWidth);
1983  }
1984  pDraw->TextOut(sText.getData(), ::GraphicsResource.FontRegular, 1.0, cgo.Surface, outDrawX + textXOffset, outDrawY + textYOffset, 0xffffffff, alignment);
1985  }
1986 
1987 
1988  if (GraphicsSystem.ShowMenuInfo) // print helpful debug info
1989  {
1990  DWORD frameColor = C4RGB(100, 150, 100);
1991  if (currentMouseState & MouseState::Focus) frameColor = C4RGB(0, 255, 0);
1992 
1993  pDraw->DrawFrameDw(cgo.Surface, outDrawX, outDrawY, outDrawRight, outDrawBottom, frameColor);
1994  if (target || id)
1995  {
1996  StdStrBuf buf = FormatString("%s(%d)", target ? target->GetName() : "", id);
1997  pDraw->TextOut(buf.getData(), ::GraphicsResource.FontCaption, 1.0, cgo.Surface, cgo.X + outDrawRight, cgo.Y + outDrawBottom - ::GraphicsResource.FontCaption.GetLineHeight(), 0xffff00ff, ARight);
1998  }
1999  //StdStrBuf buf2 = FormatString("(%d, %d, %d, %d)", rcBounds.x, rcBounds.y, rcBounds.Wdt, rcBounds.Hgt);
2000  //pDraw->TextOut(buf2.getData(), ::GraphicsResource.FontCaption, 1.0, cgo.Surface, cgo.X + outDrawX + rcBounds.Wdt / 2, cgo.Y + outDrawY + +rcBounds.Hgt / 2, 0xff00ffff, ACenter);
2001  }
2002 
2003  DrawChildren(cgo, player, -1, currentClippingRect);
2004  return true;
2005 }
int32_t GetScrollY()
Definition: C4Gui.h:987
float Y
Definition: C4Facet.h:118
void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
Definition: C4Object.cpp:2340
bool IsVisible()
Definition: C4Gui.cpp:201
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:567
void Draw(C4TargetFacet &cgo, C4Rect &rcDrawArea)
const int ARight
Definition: C4Surface.h:41
Definition: C4Rect.h:27
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
C4GraphicsResource GraphicsResource
bool DrawChildren(C4TargetFacet &cgo, int32_t player, int32_t withMultipleFlag=-1, C4Rect *currentClippingRect=nullptr)
bool IsVisibleTo(int32_t player)
int32_t Wdt
Definition: C4Rect.h:30
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:641
C4GUI::FrameDecoration * GetFrameDecoration()
int32_t y
Definition: C4Rect.h:30
ScrollBar * pScrollBar
Definition: C4Gui.h:942
const int ACenter
Definition: C4Surface.h:41
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
void DrawBoxDw(C4Surface *sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr)
Definition: C4Draw.cpp:846
C4Rect rcBounds
Definition: C4Gui.h:385
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
Container * GetParent()
Definition: C4Gui.h:429
Definition: C4Def.h:98
C4Draw * pDraw
Definition: C4Draw.cpp:42
#define C4RGB(r, g, b)
Definition: StdColors.h:26
const char * getData() const
Definition: StdBuf.h:442
std::tuple< std::string, int > BreakMessage(const char *szMsg, int iWdt, bool fCheckMarkup, float fZoom=1.0f)
int32_t x
Definition: C4Rect.h:30
float TargetX
Definition: C4Facet.h:165
virtual const char * GetName() const
Definition: C4PropList.cpp:649
bool UpdateLayout(C4TargetFacet &cgo)
const int ALeft
Definition: C4Surface.h:41
int GetLineHeight() const
Definition: C4FontLoader.h:125
int32_t Hgt
Definition: C4Rect.h:30
C4Surface * Surface
Definition: C4Facet.h:117
float TargetY
Definition: C4Facet.h:165
uint32_t DWORD
float X
Definition: C4Facet.h:118
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:

◆ Draw3DFrame()

void C4GUI::Element::Draw3DFrame ( C4TargetFacet cgo,
bool  fUp = false,
int32_t  iIndent = 1,
BYTE  byAlpha = C4GUI_BorderAlpha,
bool  fDrawTop = true,
int32_t  iTopOff = 0,
bool  fDrawLeft = true,
int32_t  iLeftOff = 0 
)
protectedinherited

Definition at line 291 of file C4Gui.cpp.

References C4GUI_BorderColor1, C4GUI_BorderColor2, C4GUI_BorderColor3, C4Draw::DrawLineDw(), pDraw, C4Facet::Surface, C4TargetFacet::TargetX, and C4TargetFacet::TargetY.

Referenced by C4GUI::ProgressBar::DrawElement(), C4GUI::GroupBox::DrawElement(), C4GUI::Edit::DrawElement(), C4GUI::ListBox::DrawElement(), C4GUI::Tabular::DrawElement(), C4GUI::TextWindow::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::ComboBox::DrawElement(), and C4GUI::Dialog::DrawElement().

292  {
293  DWORD dwAlpha = byAlpha<<24;
294  int32_t x0 = cgo.TargetX + rcBounds.x + iLeftOff,
295  y0 = cgo.TargetY + rcBounds.y + iTopOff,
296  x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1,
297  y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1;
298  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x1,(float)y0, C4GUI_BorderColor1 | dwAlpha);
299  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x0,(float)y1, C4GUI_BorderColor1 | dwAlpha);
300  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x1-1),(float)(y0+1), C4GUI_BorderColor2 | dwAlpha);
301  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x0+1),(float)(y1-1), C4GUI_BorderColor2 | dwAlpha);
302  pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y1,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
303  pDraw->DrawLineDw(cgo.Surface, (float)x1,(float)y0,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
304  pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y1-1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
305  pDraw->DrawLineDw(cgo.Surface, (float)(x1-1),(float)(y0+1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
306  }
#define C4GUI_BorderColor2
Definition: C4Gui.h:86
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:614
int32_t Wdt
Definition: C4Rect.h:30
#define C4GUI_BorderColor1
Definition: C4Gui.h:85
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
C4Draw * pDraw
Definition: C4Draw.cpp:42
int32_t x
Definition: C4Rect.h:30
float TargetX
Definition: C4Facet.h:165
#define C4GUI_BorderColor3
Definition: C4Gui.h:87
int32_t Hgt
Definition: C4Rect.h:30
C4Surface * Surface
Definition: C4Facet.h:117
float TargetY
Definition: C4Facet.h:165
uint32_t DWORD
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawAll()

bool C4ScriptGuiWindow::DrawAll ( C4TargetFacet cgo,
int32_t  player 
)

Definition at line 1866 of file C4ScriptGuiWindow.cpp.

References DrawChildren(), C4GUI::Element::IsVisible(), C4TargetFacet::TargetX, C4TargetFacet::TargetY, UpdateLayout(), C4Facet::X, and C4Facet::Y.

1867 {
1868  assert(IsRoot()); // we are root
1869  if (!IsVisible()) return false;
1870  // if the viewport shows an upper-board, apply an offset to everything
1871  const int oldTargetX = cgo.TargetX;
1872  const int oldTargetY = cgo.TargetY;
1873  cgo.TargetX += cgo.X;
1874  cgo.TargetY += cgo.Y;
1875  // this will check whether the viewport resized and we need an update
1876  UpdateLayout(cgo);
1877  // step one: draw all multiple-tagged windows
1878  DrawChildren(cgo, player, 1);
1879  // TODO: adjust rectangle for main menu if multiple windows exist
1880  // step two: draw one "main" menu
1881  DrawChildren(cgo, player, 0);
1882  // ..and restore the offset
1883  cgo.TargetX = oldTargetX;
1884  cgo.TargetY = oldTargetY;
1885  return true;
1886 }
float Y
Definition: C4Facet.h:118
bool IsVisible()
Definition: C4Gui.cpp:201
bool DrawChildren(C4TargetFacet &cgo, int32_t player, int32_t withMultipleFlag=-1, C4Rect *currentClippingRect=nullptr)
float TargetX
Definition: C4Facet.h:165
bool UpdateLayout(C4TargetFacet &cgo)
float TargetY
Definition: C4Facet.h:165
float X
Definition: C4Facet.h:118
Here is the call graph for this function:

◆ DrawBar()

void C4GUI::Element::DrawBar ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 308 of file C4Gui.cpp.

References C4Facet::Draw(), C4Facet::DrawX(), C4GUI::DynBarFacet::fctBegin, C4GUI::DynBarFacet::fctEnd, C4GUI::DynBarFacet::fctMiddle, C4Surface::Hgt, C4Facet::Hgt, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Surface::Wdt, C4Facet::Wdt, and C4Facet::X.

Referenced by C4GUI::WoodenLabel::DrawElement(), and C4GUI::Button::DrawElement().

309  {
310  if (rcBounds.Hgt == rFacets.fctMiddle.Hgt)
311  {
312  // exact bar
313  int32_t x0=cgo.TargetX+rcBounds.x, y0=cgo.TargetY+rcBounds.y;
314  int32_t iX = rFacets.fctBegin.Wdt, w=rFacets.fctMiddle.Wdt, wLeft=rFacets.fctBegin.Wdt, wRight=rFacets.fctEnd.Wdt;
315  int32_t iRightShowLength = wRight/3;
316  bool fOverflow = (wLeft > rcBounds.Wdt);
317  if (fOverflow) rFacets.fctBegin.Wdt = rcBounds.Wdt;
318  rFacets.fctBegin.Draw(cgo.Surface, x0,y0);
319  if (fOverflow) rFacets.fctBegin.Wdt = wLeft;
320  while (iX < rcBounds.Wdt-iRightShowLength)
321  {
322  int32_t w2=std::min(w, rcBounds.Wdt-iRightShowLength-iX); rFacets.fctMiddle.Wdt=w2;
323  rFacets.fctMiddle.Draw(cgo.Surface, x0+iX, y0);
324  iX += w;
325  }
326  rFacets.fctMiddle.Wdt=w;
327  fOverflow = (wRight > rcBounds.Wdt);
328  if (fOverflow)
329  {
330  rFacets.fctEnd.X += wRight - rcBounds.Wdt;
331  rFacets.fctEnd.Wdt = rcBounds.Wdt;
332  }
333  rFacets.fctEnd.Draw(cgo.Surface, x0+rcBounds.Wdt-rFacets.fctEnd.Wdt, y0);
334  if (fOverflow)
335  {
336  rFacets.fctEnd.X -= wRight - rcBounds.Wdt;
337  rFacets.fctEnd.Wdt = wRight;
338  }
339  }
340  else
341  {
342  // zoomed bar
343  float fZoom = (float) rcBounds.Hgt / rFacets.fctMiddle.Hgt;
344  int32_t x0=cgo.TargetX+rcBounds.x, y0=cgo.TargetY+rcBounds.y;
345  int32_t iX = int32_t(fZoom*rFacets.fctBegin.Wdt), w=int32_t(fZoom*rFacets.fctMiddle.Wdt), wOld=rFacets.fctMiddle.Wdt;
346  int32_t iRightShowLength = rFacets.fctEnd.Wdt/3;
347  rFacets.fctBegin.DrawX(cgo.Surface, x0,y0,int32_t(fZoom*rFacets.fctBegin.Wdt),rcBounds.Hgt);
348  while (iX < rcBounds.Wdt-(fZoom*iRightShowLength))
349  {
350  int32_t w2=std::min<int32_t>(w, rcBounds.Wdt-int32_t(fZoom*iRightShowLength)-iX); rFacets.fctMiddle.Wdt=long(float(w2)/fZoom);
351  rFacets.fctMiddle.DrawX(cgo.Surface, x0+iX, y0, w2,rcBounds.Hgt);
352  iX += w;
353  }
354  rFacets.fctMiddle.Wdt=wOld;
355  rFacets.fctEnd.DrawX(cgo.Surface, x0+rcBounds.Wdt-int32_t(fZoom*rFacets.fctEnd.Wdt), y0,int32_t(fZoom*rFacets.fctEnd.Wdt),rcBounds.Hgt);
356  }
357  }
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
float TargetX
Definition: C4Facet.h:165
int32_t Hgt
Definition: C4Rect.h:30
C4Surface * Surface
Definition: C4Facet.h:117
float TargetY
Definition: C4Facet.h:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawChildren()

bool C4ScriptGuiWindow::DrawChildren ( C4TargetFacet cgo,
int32_t  player,
int32_t  withMultipleFlag = -1,
C4Rect currentClippingRect = nullptr 
)

Definition at line 1557 of file C4ScriptGuiWindow.cpp.

References Draw(), C4GUI::ScrollBar::DrawElement(), GetClippingRect(), C4ScriptGuiWindowProperty::GetInt(), C4Rect::Hgt, C4Facet::Hgt, C4GUI::ScrollWindow::iScrollY, C4GUI::Element::IsVisible(), C4ScriptGuiWindowStyleFlag::Multiple, pDraw, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4Draw::RestorePrimaryClipper(), C4Draw::SetPrimaryClipper(), C4Draw::StorePrimaryClipper(), C4ScriptGuiWindowPropertyName::style, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, C4Facet::Y, and C4TargetFacet::Zoom.

Referenced by Draw(), and DrawAll().

1558 {
1559  // remember old target rectangle and adjust
1560  float oldTargetX = cgo.TargetX;
1561  float oldTargetY = cgo.TargetY;
1562  C4Rect myClippingRect;
1563  if (IsRoot())
1564  {
1565  cgo.TargetX = 0;
1566  cgo.TargetY = 0;
1568  // default: full screen clipper
1569  myClippingRect = C4Rect(0, 0, cgo.Wdt * cgo.Zoom, cgo.Hgt * cgo.Zoom);
1570  currentClippingRect = &myClippingRect;
1571  }
1572 
1573  // if ANY PARENT has scroll bar, then adjust clipper
1574  int32_t clipX1(0), clipX2(0), clipY1(0), clipY2(0);
1575  bool clipping = GetClippingRect(clipX1, clipY1, clipX2, clipY2);
1576 
1577  const int32_t targetClipX1 = cgo.X + cgo.TargetX + clipX1;
1578  const int32_t targetClipY1 = cgo.Y + cgo.TargetY + clipY1;
1579  const int32_t targetClipX2 = cgo.X + cgo.TargetX + clipX2;
1580  const int32_t targetClipY2 = cgo.Y + cgo.TargetY + clipY2;
1581 
1582  if (clipping)
1583  {
1584  // Take either the parent rectangle or restrict it additionally by the child's geometry.
1585  myClippingRect = C4Rect(
1586  std::max(currentClippingRect->x, targetClipX1),
1587  std::max(currentClippingRect->y, targetClipY1),
1588  std::min(currentClippingRect->Wdt, targetClipX2),
1589  std::min(currentClippingRect->Hgt, targetClipY2));
1590  currentClippingRect = &myClippingRect;
1591  }
1592 
1593  if (withMultipleFlag != 1)
1594  {
1595  cgo.TargetX += rcBounds.x;
1596  cgo.TargetY += rcBounds.y - iScrollY;
1597  }
1598  else
1599  {
1600  assert(IsRoot());
1601  assert(withMultipleFlag == 1);
1602  }
1603 
1604 
1605  // note that withMultipleFlag only plays a roll for the root-menu
1606  bool oneDrawn = false; // was at least one child drawn?
1607  //for (auto iter = rbegin(); iter != rend(); ++iter)
1608  for (auto element : *this)
1609  {
1610  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(element);
1611 
1612  if (withMultipleFlag != -1)
1613  {
1614  const int32_t &style = child->props[C4ScriptGuiWindowPropertyName::style].GetInt();
1615  if ((withMultipleFlag == 0) && (style & C4ScriptGuiWindowStyleFlag::Multiple)) continue;
1616  if ((withMultipleFlag == 1) && !(style & C4ScriptGuiWindowStyleFlag::Multiple)) continue;
1617  }
1618 
1619  pDraw->SetPrimaryClipper(currentClippingRect->x, currentClippingRect->y, currentClippingRect->Wdt, currentClippingRect->Hgt);
1620 
1621  if (child->Draw(cgo, player, currentClippingRect))
1622  oneDrawn = true;
1623  // draw only one window when drawing non-Multiple windows
1624  if (oneDrawn && (withMultipleFlag == 0)) break;
1625  }
1626 
1627  // Scrolling obviously does not affect the scroll bar.
1628  cgo.TargetY += iScrollY;
1629  // The scroll bar does not correct for the cgo offset (i.e. the upper board).
1630  cgo.TargetX += cgo.X;
1631  cgo.TargetY += cgo.Y;
1632 
1633  if (pScrollBar->IsVisible())
1634  pScrollBar->DrawElement(cgo);
1635 
1636  if (IsRoot())
1637  {
1639  }
1640 
1641  // restore target rectangle
1642  cgo.TargetX = oldTargetX;
1643  cgo.TargetY = oldTargetY;
1644  return oneDrawn;
1645 }
bool RestorePrimaryClipper()
Definition: C4Draw.cpp:210
float Y
Definition: C4Facet.h:118
float Zoom
Definition: C4Facet.h:165
bool IsVisible()
Definition: C4Gui.cpp:201
Definition: C4Rect.h:27
int32_t iScrollY
Definition: C4Gui.h:943
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
void Draw(C4TargetFacet &cgo) override
ScrollBar * pScrollBar
Definition: C4Gui.h:942
C4Rect rcBounds
Definition: C4Gui.h:385
C4Draw * pDraw
Definition: C4Draw.cpp:42
bool SetPrimaryClipper(int iX1, int iY1, int iX2, int iY2)
Definition: C4Draw.cpp:217
int32_t x
Definition: C4Rect.h:30
bool GetClippingRect(int32_t &left, int32_t &top, int32_t &right, int32_t &bottom)
float TargetX
Definition: C4Facet.h:165
float Hgt
Definition: C4Facet.h:118
int32_t Hgt
Definition: C4Rect.h:30
float TargetY
Definition: C4Facet.h:165
float Wdt
Definition: C4Facet.h:118
void DrawElement(C4TargetFacet &cgo) override
float X
Definition: C4Facet.h:118
bool StorePrimaryClipper()
Definition: C4Draw.cpp:203
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawElement()

◆ DrawHBarByVGfx()

void C4GUI::Element::DrawHBarByVGfx ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 365 of file C4Gui.cpp.

References C4BltTransform::SetRotate(), C4TargetFacet::TargetX, and C4TargetFacet::TargetY.

Referenced by C4GUI::ScrollBar::DrawElement().

366  {
367  C4DrawTransform trf;
368  float fOffX = cgo.TargetX + rcBounds.x + rcBounds.Hgt/2;
369  float fOffY = cgo.TargetY + rcBounds.y + rcBounds.Hgt/2;
370  trf.SetRotate(-90.0f, fOffX, fOffY);
371 
372  DrawHVBar(cgo, rFacets, trf, rcBounds.Wdt);
373  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:375
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
float TargetX
Definition: C4Facet.h:165
void SetRotate(float iAngle, float fOffX, float fOffY)
int32_t Hgt
Definition: C4Rect.h:30
float TargetY
Definition: C4Facet.h:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawHVBar()

void C4GUI::Element::DrawHVBar ( C4TargetFacet cgo,
DynBarFacet rFacets,
C4DrawTransform trf,
int32_t  iMiddleLength 
)
protectedinherited

Definition at line 375 of file C4Gui.cpp.

References C4Facet::DrawT(), C4GUI::DynBarFacet::fctBegin, C4GUI::DynBarFacet::fctEnd, C4GUI::DynBarFacet::fctMiddle, C4Facet::Hgt, C4Facet::Surface, C4TargetFacet::TargetX, and C4TargetFacet::TargetY.

376  {
377  int32_t y0 = cgo.TargetY + rcBounds.y;
378  int32_t x0 = cgo.TargetX + rcBounds.x;
379 
380  // draw up arrow
381  rFacets.fctBegin.DrawT(cgo.Surface, x0, y0, 0, 0, &trf);
382 
383  // draw middle part
384  int32_t h = rFacets.fctMiddle.Hgt;
385  int32_t barHeight = iMiddleLength - (rFacets.fctBegin.Hgt + rFacets.fctEnd.Hgt);
386 
387  for (int32_t iY = 0; iY <= barHeight; iY += h)
388  {
389  int32_t h2 = std::min(h, barHeight - iY);
390  rFacets.fctMiddle.Hgt = h2;
391  rFacets.fctMiddle.DrawT(cgo.Surface, x0, y0 + rFacets.fctBegin.Hgt + iY, 0, 0, &trf);
392  }
393  rFacets.fctMiddle.Hgt = h;
394 
395  // draw lower arrow
396  rFacets.fctEnd.DrawT(cgo.Surface, x0, y0 + iMiddleLength - rFacets.fctEnd.Hgt, 0, 0, &trf);
397  }
int Hgt
Definition: C4Surface.h:65
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
float TargetX
Definition: C4Facet.h:165
C4Surface * Surface
Definition: C4Facet.h:117
float TargetY
Definition: C4Facet.h:165
Here is the call graph for this function:

◆ DrawVBar()

void C4GUI::Element::DrawVBar ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 359 of file C4Gui.cpp.

Referenced by C4GUI::ScrollBar::DrawElement().

360  {
361  C4DrawTransform trf(1);
362  DrawHVBar(cgo, rFacets, trf, rcBounds.Hgt);
363  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:375
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ ElementPosChanged()

void C4GUI::ScrollWindow::ElementPosChanged ( Element pOfElement)
inlineoverrideprotectedvirtualinherited

Reimplemented from C4GUI::Container.

Definition at line 954 of file C4Gui.h.

References C4GUI::Container::ElementPosChanged().

955  {
956  Window::ElementPosChanged(pOfElement);
957  if (pParent) pParent->ElementPosChanged(pOfElement);
958  }
Container * pParent
Definition: C4Gui.h:376
virtual void ElementPosChanged(Element *pOfElement)
Definition: C4Gui.h:754
Here is the call graph for this function:

◆ ElementSizeChanged()

void C4GUI::ScrollWindow::ElementSizeChanged ( Element pOfElement)
inlineoverrideprotectedvirtualinherited

Reimplemented from C4GUI::Container.

Definition at line 949 of file C4Gui.h.

References C4GUI::Container::ElementSizeChanged().

950  {
951  Window::ElementSizeChanged(pOfElement);
952  if (pParent) pParent->ElementSizeChanged(pOfElement);
953  }
virtual void ElementSizeChanged(Element *pOfElement)
Definition: C4Gui.h:753
Container * pParent
Definition: C4Gui.h:376
Here is the call graph for this function:

◆ end()

Iterator C4GUI::Container::end ( )
inlineinherited

Definition at line 825 of file C4Gui.h.

Referenced by ClearPointers().

825 { return Iterator(nullptr); }
Here is the caller graph for this function:

◆ ExecuteCommand()

bool C4ScriptGuiWindow::ExecuteCommand ( int32_t  actionID,
int32_t  player,
int32_t  subwindowID,
int32_t  actionType,
C4Object target 
)

Definition at line 2279 of file C4ScriptGuiWindow.cpp.

References ExecuteCommand(), Game, C4GUI::Container::GetElementCount(), MenuDebugLogF, and C4Game::ScriptGuiRoot.

Referenced by C4ControlMenuCommand::C4ControlMenuCommand(), C4ScriptGuiWindowAction::C4ScriptGuiWindowAction(), and ExecuteCommand().

2280 {
2281  if (isMainWindow && subwindowID) // we are a main window! try a shortcut through the ID?
2282  {
2283  MenuDebugLogF("passing command... instance:%d, plr:%d, subwin:%d, type:%d [I am %d, MW]", actionID, player, subwindowID, actionType, id);
2284  MenuDebugLogF("stats:");
2285  MenuDebugLogF("active menus:\t%d", GetElementCount());
2286  MenuDebugLogF("children ID map:\t%d", childrenIDMap.size());
2287  // the reasoning for that shortcut is that I assume that usually windows with actions will also have an ID assigned
2288  // this obviously doesn't have to be the case, but I believe it's worth the try
2289  std::pair<std::multimap<int32_t, C4ScriptGuiWindow*>::iterator, std::multimap<int32_t, C4ScriptGuiWindow*>::iterator> range;
2290  range = childrenIDMap.equal_range(subwindowID);
2291 
2292  for (std::multimap<int32_t, C4ScriptGuiWindow*>::iterator iter = range.first; iter != range.second; ++iter)
2293  {
2294  if (iter->second->ExecuteCommand(actionID, player, subwindowID, actionType, target))
2295  {
2296  MenuDebugLogF("shortcutting command sucessful!");
2297  return true;
2298  }
2299  }
2300  // it is not possible that another window would match the criteria. Abort later after self-check
2301  MenuDebugLogF("shortcutting command failed.. no appropriate window");
2302  }
2303 
2304  // are we elligible?
2305  if ((id == subwindowID) && (this->target == target))
2306  {
2307  MenuDebugLogF("stats: (I am %d)", id);
2308  MenuDebugLogF("children:\t%d", GetElementCount());
2309  MenuDebugLogF("all actions:\t%d", props[actionType].GetAllActions().size());
2310  std::list<C4ScriptGuiWindowAction*> allActions = props[actionType].GetAllActions();
2311  for (auto action : allActions)
2312  {
2313  assert(action && "C4ScriptGuiWindowProperty::GetAllActions returned list with null-pointer");
2314 
2315  if (action->ExecuteCommand(actionID, this, player))
2316  {
2317  MenuDebugLogF("executing command sucessful!");
2318  return true;
2319  }
2320  }
2321 
2322  // note that we should not simply return false here
2323  // there is no guarantee that only one window with that target&ID exists
2324  }
2325 
2326  // not caught, forward to children!
2327  // abort if main window, though. See above
2328  if (isMainWindow && subwindowID)
2329  {
2330  MenuDebugLogF("executing command failed!");
2331  return false;
2332  }
2333 
2334  // otherwise, just pass to children..
2335  for (C4GUI::Element *element : *this)
2336  {
2337  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(element);
2338  if (child->ExecuteCommand(actionID, player, subwindowID, actionType, target))
2339  {
2340  MenuDebugLogF("passing command sucessful! (I am %d - &p)", id, this->target);
2341  return true;
2342  }
2343  }
2344  return false;
2345 }
bool ExecuteCommand(int32_t actionID, int32_t player, int32_t subwindowID, int32_t actionType, C4Object *target)
#define MenuDebugLogF(...)
std::list< C4ScriptGuiWindowAction * > GetAllActions()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Freeze()

void C4GUI::ScrollWindow::Freeze ( )
inlineinherited

Definition at line 969 of file C4Gui.h.

Referenced by C4GUI::ListBox::FreezeScrolling(), and C4Menu::RefillInternal().

969 { ++iFrozen; }
int32_t iFrozen
Definition: C4Gui.h:946
Here is the caller graph for this function:

◆ GetBounds()

C4Rect& C4GUI::Element::GetBounds ( )
inlineinherited

Definition at line 445 of file C4Gui.h.

Referenced by C4GUI::ListBox::AddElement(), C4Menu::AdjustPosition(), C4GameOverDlg::C4GameOverDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextMenu::CheckOpenSubmenu(), C4GUI::ListBox::ContractToElementHeight(), C4MapFolderData::CreateGUIElements(), C4GUI::Screen::DoContext(), C4GUI::Window::Draw(), C4GUI::ListBox::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::TextWindow::ElementPosChanged(), C4GUI::TextWindow::ElementSizeChanged(), C4GUI::Dialog::GetMarginTop(), C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), C4Menu::InitSize(), C4GUI::ListBox::InsertElement(), C4GUI::ScrollWindow::IsRangeInView(), C4StartupPlrSelDlg::PlayerListItem::Load(), C4GUI::Window::MouseInput(), C4GUI::ScrollBar::MouseInput(), C4GUI::ListBox::MouseInput(), C4GUI::Screen::MouseInput(), C4GUI::ContextMenu::MouseLeaveEntry(), C4StartupOptionsDlg::OnBackBtn(), C4StartupScenSelDlg::OnClosed(), C4GUI::ListBox::OnGetFocus(), C4StartupPlrSelDlg::OnNewBtn(), C4GUI::ScrollBar::OnPosChanged(), C4StartupPlrSelDlg::OnPropertyBtn(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollBy(), C4GUI::ListBox::ScrollItemInView(), C4GUI::ScrollWindow::ScrollPages(), C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ScrollWindow::ScrollToBottom(), C4GUI::ComboBox::SetComboCB(), C4GUI::Tabular::SetGfx(), C4GoalDisplay::SetGoals(), C4GUI::TextWindow::SetPicture(), C4GUI::Dialog::SetTitle(), C4LeagueSignupDialog::ShowModal(), C4GUI::ScrollBar::Update(), C4GUI::ScrollWindow::Update(), C4StartupNetListEntry::UpdateCollapsed(), C4StartupPlrSelDlg::PlayerListItem::UpdateCore(), C4GUI::ListBox::UpdateElementPosition(), C4Menu::UpdateElementPositions(), C4GUI::ListBox::UpdateElementPositions(), C4GUI::ScrollWindow::UpdateOwnPos(), C4Menu::UpdateScrollBar(), C4GUI::TextWindow::UpdateSize(), C4Network2ClientDlg::UpdateText(), and C4GameOverDlg::~C4GameOverDlg().

445 { return rcBounds; }
C4Rect rcBounds
Definition: C4Gui.h:385
Here is the caller graph for this function:

◆ GetChildByID()

C4ScriptGuiWindow * C4ScriptGuiWindow::GetChildByID ( int32_t  child)

Definition at line 1251 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::Element().

1252 {
1253  for (Element * element : *this)
1254  {
1255  C4ScriptGuiWindow * child = static_cast<C4ScriptGuiWindow*>(element);
1256  if (child->id != childID) continue;
1257  return child;
1258  }
1259  return nullptr;
1260 }
Here is the call graph for this function:

◆ GetChildByName()

C4ScriptGuiWindow * C4ScriptGuiWindow::GetChildByName ( C4String childName)

Definition at line 1262 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::Element().

Referenced by CreateFromPropList().

1263 {
1264  // invalid child names never match
1265  if (childName == nullptr) return nullptr;
1266 
1267  for (Element * element : *this)
1268  {
1269  C4ScriptGuiWindow * child = static_cast<C4ScriptGuiWindow*>(element);
1270  // every C4String is unique, so we can compare pointers here
1271  if (child->name != childName) continue;
1272  return child;
1273  }
1274  return nullptr;
1275 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClientRect()

C4Rect& C4GUI::Window::GetClientRect ( )
inlineoverridevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 864 of file C4Gui.h.

Referenced by C4ChartDialog::C4ChartDialog(), C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextMenu::CheckOpenSubmenu(), C4GUI::ListBox::ContractToElementHeight(), C4MapFolderData::CreateGUIElements(), C4GUI::InfoDialog::CreateSubComponents(), C4GUI::ListBox::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::ListBox::GetItemWidth(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4GUI::ContextMenu::MouseInput(), C4GUI::Screen::MouseInput(), C4GUI::ScrollBar::OnPosChanged(), C4GUI::ProgressDialog::ProgressDialog(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollBy(), C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ScrollWindow::ScrollToBottom(), C4GUI::ScrollWindow::ScrollWindow(), C4GoalDisplay::SetGoals(), C4GUI::FullscreenDialog::SetTitle(), C4LeagueSignupDialog::ShowModal(), C4GUI::TextWindow::TextWindow(), C4GUI::ScrollBar::Update(), C4StartupNetListEntry::UpdateCollapsed(), C4GUI::ListBox::UpdateColumnCount(), C4GUI::TextWindow::UpdateSize(), and C4DownloadDlg::~C4DownloadDlg().

864 { return rcClientRect; }
C4Rect rcClientRect
Definition: C4Gui.h:851
Here is the caller graph for this function:

◆ GetClippingRect()

bool C4ScriptGuiWindow::GetClippingRect ( int32_t &  left,
int32_t &  top,
int32_t &  right,
int32_t &  bottom 
)

Definition at line 2007 of file C4ScriptGuiWindow.cpp.

References C4Rect::Hgt, C4ScriptGuiWindowPropertyName::left, C4ScriptGuiWindowStyleFlag::NoCrop, C4GUI::Element::rcBounds, C4ScriptGuiWindowPropertyName::style, C4ScriptGuiWindowPropertyName::top, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by DrawChildren().

2008 {
2009  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
2010  if (IsRoot() || (style & C4ScriptGuiWindowStyleFlag::NoCrop))
2011  return false;
2012 
2013  // Other windows always clip their children.
2014  // This implicitly clips childrens' text to the parent size, too.
2015  left = rcBounds.x;
2016  top = rcBounds.y;
2017  right = rcBounds.Wdt + left;
2018  bottom = rcBounds.Hgt + top;
2019  return true;
2020 }
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ GetContainedClientRect()

◆ GetContainer()

Container* C4GUI::Container::GetContainer ( )
inlineoverridevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 831 of file C4Gui.h.

831 { return this; } // returns parent for elements; this for containers

◆ GetContextHandler()

ContextHandler * C4GUI::Element::GetContextHandler ( )
virtualinherited

Reimplemented in C4GUI::Dialog.

Definition at line 429 of file C4Gui.cpp.

Referenced by C4GUI::ContextButton::ContextButton(), and C4GUI::ContextButton::~ContextButton().

430  {
431  // fallback to parent context, if own is not assigned
433  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
virtual ContextHandler * GetContextHandler()
Definition: C4Gui.cpp:429
Container * pParent
Definition: C4Gui.h:376
Here is the caller graph for this function:

◆ GetDialogWindow()

virtual class DialogWindow* C4GUI::Element::GetDialogWindow ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::Dialog.

Definition at line 404 of file C4Gui.h.

404 { return nullptr; } // return DialogWindow if this element is a dialog

◆ GetDlg()

Dialog * C4GUI::Element::GetDlg ( )
virtualinherited

Reimplemented in C4GUI::Dialog.

Definition at line 288 of file C4Gui.cpp.

References C4GUI::Dialog::GetDlg().

Referenced by C4GUI::Control::DisableFocus(), C4ChatControl::DlgEnter(), C4ChatControl::GetDefaultControl(), C4GUI::ContextMenu::GetTargetDialog(), C4GUI::Control::HasDrawFocus(), C4GUI::Edit::InsertText(), C4GUI::Tabular::KeyCloseTab(), C4GUI::Label::MouseInput(), C4GUI::Control::MouseInput(), C4GUI::Screen::MouseInput(), C4StartupPlrSelDlg::PlayerListItem::MoveFilename(), C4ChatControl::OnConnectBtn(), C4GUI::RenameEdit::OnFinishInput(), C4GUI::Label::OnHotkey(), C4ChatControl::OnLoginDataEnter(), C4GUI::RenameEdit::RenameEdit(), C4GUI::Container::SetVisibility(), C4GUI::Screen::ShowDialog(), and C4StartupPlrSelDlg::PlayerListItem::UpdateCore().

288 { if (pParent) return pParent->GetDlg (); return nullptr; }
Container * pParent
Definition: C4Gui.h:376
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:288
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetElementByIndex()

Element * C4GUI::Container::GetElementByIndex ( int32_t  i)
inherited

Definition at line 223 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, and C4GUI::Element::pNext.

Referenced by C4Menu::GetItem(), and C4GUI::ContextMenu::SelectItem().

224  {
225  // get next until end of list or queried index is reached
226  // if i is negative or equal or larger than childcount, the loop will never break and nullptr returned
227  Element *pEl;
228  for (pEl = pFirst; i-- && pEl; pEl=pEl->pNext) {}
229  return pEl;
230  }
Element * pFirst
Definition: C4Gui.h:750
Element * pNext
Definition: C4Gui.h:377
Here is the caller graph for this function:

◆ GetElementCount()

int32_t C4GUI::Container::GetElementCount ( )
inherited

Definition at line 232 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, and C4GUI::Element::pNext.

Referenced by ExecuteCommand(), and C4GUI::ListBox::SortElements().

233  {
234  int32_t cnt=0;
235  for (Element *pEl = pFirst; pEl; pEl=pEl->pNext) ++cnt;
236  return cnt;
237  }
Element * pFirst
Definition: C4Gui.h:750
Element * pNext
Definition: C4Gui.h:377
Here is the caller graph for this function:

◆ GetFirst()

◆ GetFirstContained()

Element* C4GUI::Container::GetFirstContained ( )
inlineoverridevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 773 of file C4Gui.h.

Referenced by C4GUI::ContextMenu::MouseLeaveEntry(), and C4GUI::ListBox::OnGetFocus().

773 { return pFirst; }
Element * pFirst
Definition: C4Gui.h:750
Here is the caller graph for this function:

◆ GetFirstNestedElement()

Element * C4GUI::Container::GetFirstNestedElement ( bool  fBackwards)
overridevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 204 of file C4GuiContainers.cpp.

References C4GUI::Element::GetFirstNestedElement(), C4GUI::Container::pFirst, and C4GUI::Container::pLast.

Referenced by C4GUI::Container::GetNextNestedElement().

205  {
206  // get first/last in own list
207  if (pFirst) return (fBackwards ? pLast : pFirst)->GetFirstNestedElement(fBackwards);
208  // no own list: return this one
209  return this;
210  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHeight()

int32_t C4GUI::Element::GetHeight ( )
inlineinherited

Definition at line 444 of file C4Gui.h.

References C4Rect::Hgt.

Referenced by C4GUI::Screen::ShowDialog().

444 { return rcBounds.Hgt; }
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ GetID()

int32_t C4ScriptGuiWindow::GetID ( )
inline

Definition at line 256 of file C4ScriptGuiWindow.h.

Referenced by AddChild(), C4ScriptGuiWindowAction::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), and RemoveChild().

256 { return id; }
Here is the caller graph for this function:

◆ GetLast()

Element* C4GUI::Container::GetLast ( )
inlineinherited

Definition at line 830 of file C4Gui.h.

Referenced by C4GUI::ListBox::GetLast(), C4Menu::InitSize(), and C4Menu::UpdateScrollBar().

830 { return pLast; }
Element * pLast
Definition: C4Gui.h:750
Here is the caller graph for this function:

◆ GetLastContained()

virtual Element* C4GUI::Container::GetLastContained ( )
inlinevirtualinherited

Definition at line 774 of file C4Gui.h.

Referenced by C4GUI::ContextMenu::MouseLeaveEntry(), and C4GUI::ListBox::OnGetFocus().

774 { return pLast; }
Element * pLast
Definition: C4Gui.h:750
Here is the caller graph for this function:

◆ GetListItemTopSpacing()

virtual int32_t C4GUI::Element::GetListItemTopSpacing ( )
inlinevirtualinherited

Reimplemented in C4StartupNetListEntry.

Definition at line 461 of file C4Gui.h.

References C4GUI_DefaultListSpacing.

Referenced by C4GUI::ListBox::AddElement(), C4GUI::ListBox::DrawElement(), C4GUI::ContextMenu::MouseLeaveEntry(), C4StartupOptionsDlg::OnBackBtn(), C4PlayerInfoListBox::ListItem::ID::operator==(), and C4GUI::ListBox::UpdateElementPositions().

461 { return C4GUI_DefaultListSpacing; }
#define C4GUI_DefaultListSpacing
Definition: C4Gui.h:123
Here is the caller graph for this function:

◆ GetListItemTopSpacingBar()

virtual bool C4GUI::Element::GetListItemTopSpacingBar ( )
inlinevirtualinherited

Definition at line 462 of file C4Gui.h.

Referenced by C4GUI::ListBox::DrawElement(), and C4PlayerInfoListBox::ListItem::ID::operator==().

462 { return false; }
Here is the caller graph for this function:

◆ GetMarginBottom()

virtual int32_t C4GUI::Window::GetMarginBottom ( )
inlinevirtualinherited

Reimplemented in C4GUI::FullscreenDialog, C4GUI::Dialog, C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::Tabular, C4GUI::ListBox, C4GUI::Edit, C4GUI::GroupBox, C4Menu, and C4StartupPlrPropertiesDlg.

Definition at line 876 of file C4Gui.h.

Referenced by C4GUI::Dialog::GetMarginBottom(), C4Menu::InitSize(), and C4GUI::Window::UpdateOwnPos().

876 { return 0; }
Here is the caller graph for this function:

◆ GetMarginLeft()

virtual int32_t C4GUI::Window::GetMarginLeft ( )
inlinevirtualinherited

Reimplemented in C4GUI::FullscreenDialog, C4GUI::Dialog, C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::Tabular, C4GUI::ListBox, C4GUI::Edit, C4GUI::GroupBox, C4Menu, and C4StartupPlrPropertiesDlg.

Definition at line 874 of file C4Gui.h.

Referenced by C4GUI::Dialog::GetMarginLeft(), C4Menu::InitSize(), and C4GUI::Window::UpdateOwnPos().

874 { return 0; }
Here is the caller graph for this function:

◆ GetMarginRight()

virtual int32_t C4GUI::Window::GetMarginRight ( )
inlinevirtualinherited

Reimplemented in C4GUI::FullscreenDialog, C4GUI::Dialog, C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::Tabular, C4GUI::ListBox, C4GUI::Edit, C4GUI::GroupBox, C4Menu, and C4StartupPlrPropertiesDlg.

Definition at line 875 of file C4Gui.h.

Referenced by C4GUI::Dialog::GetMarginRight(), C4Menu::InitSize(), and C4GUI::Window::UpdateOwnPos().

875 { return 0; }
Here is the caller graph for this function:

◆ GetMarginTop()

virtual int32_t C4GUI::Window::GetMarginTop ( )
inlinevirtualinherited

Reimplemented in C4GUI::FullscreenDialog, C4GUI::Dialog, C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::Tabular, C4GUI::ListBox, C4GUI::Edit, C4GUI::GroupBox, C4StartupScenSelDlg, C4StartupPlrPropertiesDlg, and C4StartupPlrSelDlg.

Definition at line 873 of file C4Gui.h.

Referenced by C4GUI::Dialog::GetMarginTop(), C4Menu::InitSize(), and C4GUI::Window::UpdateOwnPos().

873 { return 0; }
Here is the caller graph for this function:

◆ GetNext()

◆ GetNextNestedElement()

Element * C4GUI::Container::GetNextNestedElement ( Element pPrevElement,
bool  fBackwards 
)
inherited

Definition at line 171 of file C4GuiContainers.cpp.

References C4GUI::Element::GetFirstContained(), C4GUI::Element::GetFirstNestedElement(), C4GUI::Container::GetFirstNestedElement(), C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::Dialog::AdvanceFocus().

172  {
173  if (fBackwards)
174  {
175  // this is last
176  if (pPrevElement == this) return nullptr;
177  // no previous given?
178  if (!pPrevElement)
179  // then use last nested for backwards search
180  return GetFirstNestedElement(true);
181  // get nested, previous element if present
182  if (pPrevElement->pPrev) return pPrevElement->pPrev->GetFirstNestedElement(true);
183  // if not, return parent (could be this)
184  return pPrevElement->pParent;
185  }
186  else
187  {
188  // forward search: first element is this
189  if (!pPrevElement) return this;
190  // check next nested
191  Element *pEl;
192  if ((pEl = pPrevElement->GetFirstContained())) return pEl;
193  // check next in list, going upwards until this container is reached
194  while (pPrevElement && pPrevElement != this)
195  {
196  if ((pEl = pPrevElement->pNext)) return pEl;
197  pPrevElement = pPrevElement->pParent;
198  }
199  // nothing found
200  }
201  return nullptr;
202  }
Element * GetFirstNestedElement(bool fBackwards) override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOwnToolTip()

const char* C4GUI::Element::GetOwnToolTip ( )
inlineinherited

Definition at line 440 of file C4Gui.h.

References StdStrBuf::getData().

440 { return ToolTip.getData(); } // return tooltip const char*, without fallback to parent
const char * getData() const
Definition: StdBuf.h:442
Here is the call graph for this function:

◆ GetParent()

◆ GetPrev()

Element* C4GUI::Element::GetPrev ( ) const
inlineinherited

Definition at line 450 of file C4Gui.h.

Referenced by C4GUI::ListBox::AddElement(), C4GUI::Screen::CloseAllDialogs(), C4GUI::Screen::GetDialog(), C4GUI::Screen::GetTopDialog(), C4GUI::Window::MouseInput(), C4GUI::Screen::MouseInput(), C4GUI::ContextMenu::MouseLeaveEntry(), C4GUI::ListBox::OnGetFocus(), and C4GUI::Container::ReverseIterator::operator++().

450 { return pPrev; }
Element * pPrev
Definition: C4Gui.h:377
Here is the caller graph for this function:

◆ GetScreen()

Screen * C4GUI::Element::GetScreen ( )
virtualinherited

Reimplemented in C4GUI::Screen, and C4GUI::ContextMenu.

Definition at line 289 of file C4Gui.cpp.

References C4GUI::Screen::GetScreen().

Referenced by C4GUI::Dialog::Close(), C4StartupScenSelDlg::DoOK(), C4GUI::Dialog::Draw(), C4StartupAboutDlg::DrawElement(), C4GUI::ContextButton::DrawElement(), C4GUI::ComboBox::DrawElement(), C4GUI::Dialog::FadeOut(), C4GUI::Control::HasDrawFocus(), C4GUI::Dialog::IsActive(), C4StartupScenSelDlg::KeyDelete(), C4GUI::ComboBox::MouseInput(), C4StartupPlrSelDlg::PlayerListItem::MoveFilename(), C4GameOptionButtons::OnBtnComment(), C4GameOptionButtons::OnBtnPassword(), C4StartupNetDlg::OnBtnRecord(), C4StartupOptionsDlg::OnClosed(), C4StartupPlrPropertiesDlg::OnClosed(), C4StartupPlrPropertiesDlg::OnClrChangeCustom(), C4ChatControl::OnConnectBtn(), C4GUI::CBContextHandler< CBClass >::OnContext(), C4StartupPlrSelDlg::OnCrewBtn(), C4StartupPlrSelDlg::OnDelBtn(), C4StartupPlrSelDlg::OnDelBtnConfirm(), C4StartupPlrSelDlg::OnItemCheckChange(), C4StartupPlrSelDlg::OnNewBtn(), C4StartupPlrPropertiesDlg::OnPictureBtn(), C4StartupPlrSelDlg::OnPropertyBtn(), C4StartupMainDlg::OnShown(), C4StartupMainDlg::OnTODO(), C4StartupOptionsDlg::RecreateDialog(), C4StartupOptionsDlg::SaveConfig(), C4GUI::ComboBox::SetComboCB(), C4GameLobby::MainDlg::Start(), C4StartupScenSelDlg::StartScenario(), C4ScoreboardDlg::Update(), C4StartupPlrSelDlg::PlayerListItem::UpdateCore(), C4FileSelDlg::UserClose(), C4StartupPlrPropertiesDlg::UserClose(), C4ChatControl::UserQueryQuit(), and C4GUI::ContextButton::~ContextButton().

289 { if (pParent) return pParent->GetScreen(); return nullptr; }
Container * pParent
Definition: C4Gui.h:376
virtual Screen * GetScreen()
Definition: C4Gui.cpp:289
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetScrollY()

int32_t C4GUI::ScrollWindow::GetScrollY ( )
inlineinherited

Definition at line 987 of file C4Gui.h.

Referenced by Draw(), C4GUI::TextWindow::GetScrollPos(), and C4GUI::ListBox::MouseInput().

987 { return iScrollY; }
int32_t iScrollY
Definition: C4Gui.h:943
Here is the caller graph for this function:

◆ GetSubWindow()

C4ScriptGuiWindow * C4ScriptGuiWindow::GetSubWindow ( int32_t  childID,
C4Object childTarget 
)

Definition at line 1277 of file C4ScriptGuiWindow.cpp.

Referenced by C4ScriptGuiWindowAction::Execute().

1278 {
1279  std::pair<std::multimap<int32_t, C4ScriptGuiWindow*>::iterator, std::multimap<int32_t, C4ScriptGuiWindow*>::iterator> range;
1280  range = childrenIDMap.equal_range(childID);
1281 
1282  for (std::multimap<int32_t, C4ScriptGuiWindow*>::iterator iter = range.first; iter != range.second; ++iter)
1283  {
1284  C4ScriptGuiWindow *subwindow = iter->second;
1285  if (subwindow->GetTarget() != childTarget) continue;
1286  return subwindow;
1287  }
1288  return nullptr;
1289 }
Here is the caller graph for this function:

◆ GetToolTip()

const char * C4GUI::Element::GetToolTip ( )
inherited

Definition at line 423 of file C4Gui.cpp.

Referenced by C4GUI::CMouse::Draw(), C4GameLobby::MainDlg::OnRightTabContext(), and C4GameLobby::MainDlg::UpdateRightTab().

424  {
425  // fallback to parent tooltip, if own is not assigned
426  return (!pParent || !ToolTip.isNull()) ? ToolTip.getData() : pParent->GetToolTip();
427  }
const char * GetToolTip()
Definition: C4Gui.cpp:423
bool isNull() const
Definition: StdBuf.h:441
Container * pParent
Definition: C4Gui.h:376
const char * getData() const
Definition: StdBuf.h:442
Here is the caller graph for this function:

◆ GetToprightCornerRect()

C4Rect C4GUI::Element::GetToprightCornerRect ( int32_t  iWidth = 16,
int32_t  iHeight = 16,
int32_t  iHIndent = 4,
int32_t  iVIndent = 4,
int32_t  iIndexX = 0 
)
inherited

Definition at line 399 of file C4Gui.cpp.

References C4Rect::Hgt, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::ContextButton::ContextButton(), C4GUI::Dialog::SetTitle(), C4GUI::Dialog::UpdateSize(), and C4Network2ClientDlg::UpdateText().

400  {
401  // bounds by topright corner of element
402  C4Rect rtBounds = (GetContainer() != this) ? GetClientRect() : GetContainedClientRect();
403  rtBounds.x += rtBounds.Wdt - (iWidth + iHIndent) * (iIndexX + 1);
404  rtBounds.y += iVIndent;
405  rtBounds.Wdt = rtBounds.Hgt = iHeight;
406  return rtBounds;
407  }
virtual Container * GetContainer()
Definition: C4Gui.h:410
Definition: C4Rect.h:27
C4Rect GetContainedClientRect()
Definition: C4Gui.h:448
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:447
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ GetWidth()

int32_t C4GUI::Element::GetWidth ( )
inlineinherited

Definition at line 443 of file C4Gui.h.

References C4Rect::Wdt.

Referenced by C4GUI::Screen::ShowDialog().

443 { return rcBounds.Wdt; }
int32_t Wdt
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
Here is the caller graph for this function:

◆ HasMouseFocus()

bool C4ScriptGuiWindow::HasMouseFocus ( )
inline

Definition at line 345 of file C4ScriptGuiWindow.h.

Referenced by MouseInput(), OnMouseIn(), OnMouseOut(), and ProcessMouseInput().

345 { return currentMouseState & MouseState::Focus; }
Here is the caller graph for this function:

◆ InsertElement()

void C4GUI::Container::InsertElement ( Element pChild,
Element pInsertBefore 
)
inherited

Definition at line 150 of file C4GuiContainers.cpp.

References C4GUI::Container::AddElement(), C4GUI::Container::pFirst, C4GUI::Element::pNext, C4GUI::Element::pParent, C4GUI::Element::pPrev, and C4GUI::Container::RemoveElement().

Referenced by AddChild(), C4GUI::ListBox::InsertElement(), C4GUI::ContextMenu::RemoveElement(), and C4GUI::Screen::ShowDialog().

151  {
152  // add?
153  if (!pInsertBefore) { AddElement(pChild); return; }
154  // safety
155  if (!pChild || pInsertBefore->pParent != this) return;
156  // remove from any previous container
157  if (pChild->pParent) pChild->pParent->RemoveElement(pChild);
158  // add before given element
159  if ((pChild->pPrev = pInsertBefore->pPrev))
160  pInsertBefore->pPrev->pNext = pChild;
161  else
162  pFirst = pChild;
163  pChild->pNext = pInsertBefore; pInsertBefore->pPrev = pChild;
164  pChild->pParent = this;
165 
166  assert(pChild->pNext != pChild);
167  assert(pChild->pPrev != pChild);
168  assert(pChild->pParent != pChild);
169  }
Element * pFirst
Definition: C4Gui.h:750
void AddElement(Element *pChild)
Element * pPrev
Definition: C4Gui.h:377
Container * pParent
Definition: C4Gui.h:376
Element * pNext
Definition: C4Gui.h:377
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsComponentOutsideClientArea()

bool C4GUI::ScrollWindow::IsComponentOutsideClientArea ( )
inlineoverridevirtualinherited

Reimplemented from C4GUI::Window.

Definition at line 966 of file C4Gui.h.

966 { return true; } // always clip drawing routine of subcomponents to Bounds

◆ IsExternalDrawDialog()

virtual bool C4GUI::Element::IsExternalDrawDialog ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::Dialog, and C4Menu.

Definition at line 402 of file C4Gui.h.

402 { return false; }

◆ IsFocused()

virtual bool C4GUI::Container::IsFocused ( Control pCtrl)
inlinevirtualinherited

Reimplemented in C4GUI::Dialog, and C4GUI::ListBox.

Definition at line 836 of file C4Gui.h.

Referenced by C4GUI::ListBox::IsFocused(), and C4ChatControl::ChatSheet::NickItem::SortFunc().

836 { return pParent ? pParent->IsFocused(pCtrl) : false; }
Container * pParent
Definition: C4Gui.h:376
virtual bool IsFocused(Control *pCtrl)
Definition: C4Gui.h:836
Here is the caller graph for this function:

◆ IsFocusElement()

virtual Control* C4GUI::Element::IsFocusElement ( )
inlinevirtualinherited

Reimplemented in C4GUI::ComboBox, C4GUI::TextWindow, C4GUI::Tabular, C4GUI::ListBox, C4GUI::CheckBox, and C4GUI::Control.

Definition at line 432 of file C4Gui.h.

Referenced by C4GUI::Dialog::AdvanceFocus().

432 { return nullptr; }; // return control to gain focus in search-cycle
Here is the caller graph for this function:

◆ IsFrozen()

bool C4GUI::ScrollWindow::IsFrozen ( ) const
inlineinherited

Definition at line 971 of file C4Gui.h.

Referenced by C4Menu::Add().

971 { return !!iFrozen; }
int32_t iFrozen
Definition: C4Gui.h:946
Here is the caller graph for this function:

◆ IsImmediateToolTip()

bool C4GUI::Element::IsImmediateToolTip ( ) const
inlineinherited

Definition at line 441 of file C4Gui.h.

Referenced by C4GUI::CMouse::Draw().

441 { return is_immediate_tooltip; }
Here is the caller graph for this function:

◆ IsInActiveDlg()

bool C4GUI::Element::IsInActiveDlg ( bool  fForKeyboard)
inherited

Definition at line 435 of file C4Gui.cpp.

References C4GUI::Dialog::IsActive().

Referenced by C4GUI::ControlKeyDlgCB< TargetClass >::CheckCondition(), C4GUI::Button::DrawElement(), C4GUI::IconButton::DrawElement(), C4GUI::ArrowButton::DrawElement(), C4GUI::FacetButton::DrawElement(), C4GUI::CheckBox::DrawElement(), and C4GUI::ContextButton::DrawElement().

436  {
437  // get dlg
438  Dialog *pDlg=GetDlg();
439  if (!pDlg) return false;
440  // check if dlg is active
441  return pDlg->IsActive(fForKeyboard);
442  }
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:288
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsMenu()

virtual bool C4GUI::Element::IsMenu ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::ContextMenu, and C4GUI::ContextMenu::Entry.

Definition at line 403 of file C4Gui.h.

403 { return false; }

◆ IsOwnPtrElement()

virtual bool C4GUI::Element::IsOwnPtrElement ( )
inlineprotectedvirtualinherited

Reimplemented in C4Menu.

Definition at line 401 of file C4Gui.h.

Referenced by C4GUI::Container::ClearChildren().

401 { return false; } // if true is returned, item will not be deleted when container is cleared
Here is the caller graph for this function:

◆ IsParentOf()

bool C4GUI::Container::IsParentOf ( Element pEl)
overridevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 239 of file C4GuiContainers.cpp.

References C4GUI::Element::GetParent().

Referenced by C4GUI::Tabular::IsSelectedChild(), C4GUI::Control::MouseInput(), and C4GUI::Container::SetVisibility().

240  {
241  // return whether this is the parent container (directly or recursively) of the passed element
242  for (Container *pC = pEl->GetParent(); pC; pC = pC->GetParent())
243  if (pC == this) return true;
244  return false;
245  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsRangeInView()

bool C4GUI::ScrollWindow::IsRangeInView ( int32_t  iY,
int32_t  iHgt 
)
inherited

Definition at line 605 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4Rect::Hgt, and C4GUI::ScrollWindow::iScrollY.

Referenced by C4GUI::ListBox::OnGetFocus().

606  {
607  // returns whether scrolling range is in view
608  // check top
609  if (iScrollY > iY) return false;
610  // check height
611  return iScrollY + GetBounds().Hgt >= iY+iHgt;
612  }
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsScrollBarEnabled()

bool C4GUI::ScrollWindow::IsScrollBarEnabled ( )
inlineinherited

Definition at line 990 of file C4Gui.h.

Referenced by C4Menu::UpdateScrollBar().

990 { return fHasBar; }
Here is the caller graph for this function:

◆ IsScrollingActive()

bool C4GUI::ScrollWindow::IsScrollingActive ( )
inlineinherited

Definition at line 992 of file C4Gui.h.

References C4GUI::ScrollBar::IsScrolling().

Referenced by C4GUI::ListBox::IsScrollingActive().

992 { return fHasBar && pScrollBar && pScrollBar->IsScrolling(); }
ScrollBar * pScrollBar
Definition: C4Gui.h:942
bool IsScrolling()
Definition: C4Gui.h:916
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsScrollingNecessary()

bool C4GUI::ScrollWindow::IsScrollingNecessary ( )
inlineinherited

Definition at line 993 of file C4Gui.h.

Referenced by C4GUI::ListBox::IsScrollingNecessary(), and UpdateLayout().

993 { return iClientHeight > rcBounds.Hgt; }
int32_t iClientHeight
Definition: C4Gui.h:944
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ IsSelectedChild()

virtual bool C4GUI::Container::IsSelectedChild ( Element pChild)
inlinevirtualinherited

Reimplemented in C4GUI::Tabular, and C4GUI::ListBox.

Definition at line 837 of file C4Gui.h.

Referenced by C4GUI::Dialog::AdvanceFocus(), and C4StartupNetListEntry::DrawElement().

837 { return pParent ? pParent->IsSelectedChild(pChild) : true; } // whether the child element is selected - only false for list-box-containers which can have unselected children
virtual bool IsSelectedChild(Element *pChild)
Definition: C4Gui.h:837
Container * pParent
Definition: C4Gui.h:376
Here is the caller graph for this function:

◆ IsVisible()

bool C4GUI::Element::IsVisible ( )
inherited

◆ IsVisibleTo()

bool C4ScriptGuiWindow::IsVisibleTo ( int32_t  player)

Definition at line 2352 of file C4ScriptGuiWindow.cpp.

References ANY_OWNER, C4GUI::Element::IsVisible(), and C4ScriptGuiWindowPropertyName::player.

Referenced by Draw(), MouseInput(), and ProcessMouseInput().

2353 {
2354  // Not visible at all?
2355  if (!IsVisible()) return false;
2356  // We have a player assigned and it's a different one?
2357  const int32_t &myPlayer = props[C4ScriptGuiWindowPropertyName::player].GetInt();
2358  if (myPlayer != ANY_OWNER && player != myPlayer) return false;
2359  // We have a target object which is invisible to the player?
2360  if (target && !target->IsVisible(player, false)) return false;
2361  // Default to visible!
2362  return true;
2363 }
bool IsVisible()
Definition: C4Gui.cpp:201
const int ANY_OWNER
Definition: C4Constants.h:138
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
Definition: C4Object.cpp:4053
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeLastElement()

void C4GUI::Container::MakeLastElement ( Element pChild)
inherited

Definition at line 106 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::Screen::ActivateDialog().

107  {
108  // must be from same container
109  if (pChild->pParent != this) return;
110  // unlink from list
111  if (pChild->pPrev) pChild->pPrev->pNext = pChild->pNext; else pFirst = pChild->pNext;
112  if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
113  // readd to front of list
114  if (pLast) pLast->pNext = pChild; else pFirst = pChild;
115  pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
116  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Element * pNext
Definition: C4Gui.h:377
Here is the caller graph for this function:

◆ MouseEnter()

void C4ScriptGuiWindow::MouseEnter ( C4GUI::CMouse rMouse)
overridevirtual

Reimplemented from C4GUI::Element.

Definition at line 2038 of file C4ScriptGuiWindow.cpp.

References C4MouseControl::GetPlayer(), MouseControl, and NO_OWNER.

2039 {
2040  assert(::MouseControl.GetPlayer() != NO_OWNER);
2041 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t GetPlayer()
const int NO_OWNER
Definition: C4Constants.h:137
Here is the call graph for this function:

◆ MouseInput() [1/2]

bool C4ScriptGuiWindow::MouseInput ( int32_t  iButton,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
virtual

Definition at line 2098 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowProperty::GetInt(), C4MouseControl::GetPlayer(), HasMouseFocus(), C4Rect::Hgt, C4GUI::ScrollWindow::iScrollY, IsVisibleTo(), MouseControl, C4ScriptGuiWindowStyleFlag::Multiple, NO_OWNER, OnMouseOut(), C4ScriptGuiWindowPropertyName::player, ProcessMouseInput(), C4GUI::Container::rbegin(), C4GUI::Element::rcBounds, C4GUI::Container::rend(), C4ScriptGuiWindowPropertyName::style, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

2099 {
2100  // only called on root
2101  assert(IsRoot());
2102  // This is only called during a mouse move event, where the MouseControl's player is available.
2103  const int32_t &player = ::MouseControl.GetPlayer();
2104  assert(player != NO_OWNER);
2105  // Only allow one window to catch the mouse input.
2106  // Do not simply return, however, since other windows might need OnMouseOut().
2107  bool oneActionAlreadyExecuted = false;
2108  // non-multiple-windows have a higher priority
2109  // this is important since they are also drawn on top
2110  for (int withMultipleFlag = 0; withMultipleFlag <= 1; ++withMultipleFlag)
2111  {
2112  for (auto iter = rbegin(); iter != rend(); ++iter)
2113  {
2114  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(*iter);
2115 
2116  const int32_t &style = child->props[C4ScriptGuiWindowPropertyName::style].GetInt();
2117  if ((withMultipleFlag == 0) && (style & C4ScriptGuiWindowStyleFlag::Multiple)) continue;
2118  if ((withMultipleFlag == 1) && !(style & C4ScriptGuiWindowStyleFlag::Multiple)) continue;
2119 
2120  // Do the visibility check first. The child itself won't do it, because we are handling mouse in/out here, too.
2121  if (!child->IsVisibleTo(player)) continue;
2122 
2123  // we are root, we have to adjust the position for the "main" windows that are centered
2124  int32_t adjustedMouseX = 0, adjustedMouseY = mouseY;
2125  int32_t offsetX = 0, offsetY = 0;
2126  if (withMultipleFlag == 0)
2127  {
2128  offsetX = -rcBounds.x;
2129  offsetY = -rcBounds.y;
2130  }
2131 
2132  adjustedMouseX = mouseX + offsetX;
2133  adjustedMouseY = mouseY + offsetY;
2134 
2135  int32_t childLeft = child->rcBounds.x;
2136  int32_t childRight = child->rcBounds.x + child->rcBounds.Wdt;
2137  int32_t childTop = child->rcBounds.y;
2138  int32_t childBottom = child->rcBounds.y + child->rcBounds.Hgt;
2139 
2140  bool inArea = true;
2141  if ((adjustedMouseX < childLeft) || (adjustedMouseX > childRight)) inArea = false;
2142  else if ((adjustedMouseY < childTop) || (adjustedMouseY > childBottom)) inArea = false;
2143 
2144  if (!inArea) // notify child if it had mouse focus before
2145  {
2146  if (child->HasMouseFocus())
2147  child->OnMouseOut(player);
2148  continue;
2149  }
2150  // Don't break since some more OnMouseOut might be necessary
2151  if (oneActionAlreadyExecuted) continue;
2152 
2153 
2154  // keep the mouse coordinates relative to the child's bounds
2155  if (child->ProcessMouseInput(button, adjustedMouseX - childLeft, adjustedMouseY - childTop - iScrollY, dwKeyParam, childLeft - offsetX, childTop + iScrollY - offsetY))
2156  {
2157  oneActionAlreadyExecuted = true;
2158  }
2159  }
2160  }
2161 
2162  return oneActionAlreadyExecuted;
2163 }
virtual bool ProcessMouseInput(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, int32_t parentOffsetX, int32_t parentOffsetY)
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t iScrollY
Definition: C4Gui.h:943
bool IsVisibleTo(int32_t player)
int32_t Wdt
Definition: C4Rect.h:30
void OnMouseOut(int32_t player)
int32_t GetPlayer()
int32_t y
Definition: C4Rect.h:30
ReverseIterator rend()
Definition: C4Gui.h:827
C4Rect rcBounds
Definition: C4Gui.h:385
const int NO_OWNER
Definition: C4Constants.h:137
ReverseIterator rbegin()
Definition: C4Gui.h:826
int32_t x
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:

◆ MouseInput() [2/2]

void C4GUI::ScrollWindow::MouseInput ( CMouse rMouse,
int32_t  iButton,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
overridevirtualinherited

Reimplemented from C4GUI::Window.

Definition at line 644 of file C4GuiContainers.cpp.

References C4MC_Button_Wheel, C4GraphicsResource::CaptionFont, GraphicsResource, C4GUI::Window::MouseInput(), and C4GUI::ScrollWindow::ScrollBy().

Referenced by Draw().

645  {
646  // process wheel: Scroll
647  if (iButton == C4MC_Button_Wheel)
648  {
649  short iDelta = (short)(dwKeyParam >> 16);
650  ScrollBy(-iDelta);
651  return;
652  }
653  // other mouse input: inherited (forward to children)
654  Window::MouseInput(rMouse, iButton, iX, iY, dwKeyParam);
655  }
void ScrollBy(int iAmount)
const int32_t C4MC_Button_Wheel
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MouseLeave()

void C4ScriptGuiWindow::MouseLeave ( C4GUI::CMouse rMouse)
overridevirtual

Reimplemented from C4GUI::Element.

Definition at line 2073 of file C4ScriptGuiWindow.cpp.

References C4MouseControl::GetPlayer(), MouseControl, and NO_OWNER.

2074 {
2075  assert(::MouseControl.GetPlayer() != NO_OWNER);
2076 
2077 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t GetPlayer()
const int NO_OWNER
Definition: C4Constants.h:137
Here is the call graph for this function:

◆ OnHotkey()

bool C4GUI::Container::OnHotkey ( uint32_t  cHotkey)
overrideprotectedvirtualinherited

Reimplemented from C4GUI::Element.

Reimplemented in C4GUI::CheckBox, and C4GUI::Button.

Definition at line 212 of file C4GuiContainers.cpp.

References C4GUI::Element::IsVisible(), C4GUI::Container::pFirst, and C4GUI::Element::pNext.

Referenced by C4GUI::Dialog::CharIn().

213  {
214  if (!IsVisible()) return false;
215  // check all nested elements
216  for (Element *pEl = pFirst; pEl; pEl=pEl->pNext)
217  if (pEl->fVisible)
218  if (pEl->OnHotkey(cHotkey)) return true;
219  // no match found
220  return false;
221  }
bool IsVisible()
Definition: C4Gui.cpp:201
Element * pFirst
Definition: C4Gui.h:750
Element * pNext
Definition: C4Gui.h:377
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnMouseIn()

void C4ScriptGuiWindow::OnMouseIn ( int32_t  player,
int32_t  parentOffsetX,
int32_t  parentOffsetY 
)

Definition at line 2043 of file C4ScriptGuiWindow.cpp.

References currentMouseState, C4ScriptGuiWindowAction::Execute(), C4Viewport::GetGUIZoom(), C4ViewportList::GetViewport(), HasMouseFocus(), C4Rect::Hgt, MouseControl, C4ScriptGuiWindowPropertyName::onMouseInAction, C4GUI::Element::rcBounds, C4MouseControl::SetTooltipRectangle(), C4MouseControl::SetTooltipText(), C4ScriptGuiWindowPropertyName::tooltip, Viewports, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by ProcessMouseInput().

2044 {
2045  assert(!HasMouseFocus() && "custom menu window properly loaded incorrectly!");
2046  currentMouseState = MouseState::Focus;
2047 
2048  // no need to notify children, this is done in MouseInput
2049 
2050  // update tooltip info if applicable
2052  if (strBuf)
2053  {
2054  C4Viewport * viewport = ::Viewports.GetViewport(player);
2055  if (viewport)
2056  {
2057  const float guiZoom = viewport->GetGUIZoom();
2058  const float x = float(parentOffsetX + rcBounds.x) / guiZoom;
2059  const float y = float(parentOffsetY + rcBounds.y) / guiZoom;
2060  const float wdt = float(rcBounds.Wdt) / guiZoom;
2061  const float hgt = float(rcBounds.Hgt) / guiZoom;
2062  ::MouseControl.SetTooltipRectangle(C4Rect(x, y, wdt, hgt));
2063  ::MouseControl.SetTooltipText(*strBuf);
2064  }
2065  }
2066  // execute action
2068  C4ScriptGuiWindowAction *action = props[actionType].GetAction();
2069  if (!action) return;
2070  action->Execute(this, player, actionType);
2071 }
void SetTooltipRectangle(const C4Rect &rectangle)
Definition: C4Rect.h:27
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t Wdt
Definition: C4Rect.h:30
void SetTooltipText(const StdStrBuf &text)
void Execute(C4ScriptGuiWindow *parent, int32_t player, int32_t actionType)
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
float GetGUIZoom() const
Definition: C4Viewport.h:47
C4ScriptGuiWindowAction * GetAction()
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnMouseOut()

void C4ScriptGuiWindow::OnMouseOut ( int32_t  player)

Definition at line 2078 of file C4ScriptGuiWindow.cpp.

References currentMouseState, C4ScriptGuiWindowAction::Execute(), HasMouseFocus(), C4ScriptGuiWindowStyleFlag::None, OnMouseOut(), and C4ScriptGuiWindowPropertyName::onMouseOutAction.

Referenced by MouseInput(), OnMouseOut(), and ProcessMouseInput().

2079 {
2080  assert(HasMouseFocus() && "custom menu window probably loaded incorrectly!");
2082 
2083  // needs to notify children
2084  for (C4GUI::Element *iter : *this)
2085  {
2086  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(iter);
2087  if (child->HasMouseFocus())
2088  child->OnMouseOut(player);
2089  }
2090 
2091  // execute action
2093  C4ScriptGuiWindowAction *action = props[actionType].GetAction();
2094  if (!action) return;
2095  action->Execute(this, player, actionType);
2096 }
void OnMouseOut(int32_t player)
void Execute(C4ScriptGuiWindow *parent, int32_t player, int32_t actionType)
C4ScriptGuiWindowAction * GetAction()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMouseInput()

bool C4ScriptGuiWindow::ProcessMouseInput ( int32_t  iButton,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam,
int32_t  parentOffsetX,
int32_t  parentOffsetY 
)
virtual

Definition at line 2165 of file C4ScriptGuiWindow.cpp.

References C4MC_Button_LeftDouble, C4MC_Button_LeftDown, C4MC_Button_LeftUp, C4MC_Button_Wheel, currentMouseState, C4ScriptGuiWindowAction::Execute(), C4MouseControl::GetPlayer(), HasMouseFocus(), C4Rect::Hgt, C4ScriptGuiWindowStyleFlag::IgnoreMouse, C4GUI::ScrollWindow::iScrollY, C4MouseControl::IsLeftDown(), C4GUI::Element::IsVisible(), IsVisibleTo(), C4GUI::CMouse::LDown, MouseControl, MouseDown, C4GUI::ScrollBar::MouseInput(), NO_OWNER, C4ScriptGuiWindowPropertyName::onClickAction, OnMouseIn(), OnMouseOut(), C4ScriptGuiWindowPropertyName::player, ProcessMouseInput(), C4GUI::ScrollWindow::pScrollBar, C4GUI::Container::rbegin(), C4GUI::Element::rcBounds, C4GUI::Container::rend(), C4GUI::ScrollWindow::ScrollBy(), C4ScriptGuiWindowPropertyName::style, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by MouseInput(), and ProcessMouseInput().

2166 {
2167  const int32_t &player = ::MouseControl.GetPlayer();
2168  assert(player != NO_OWNER);
2169 
2170  // completely ignore mouse if the appropriate flag is set
2171  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
2173  return false;
2174 
2175  // we have mouse focus! Is this new?
2176  if (!HasMouseFocus())
2177  OnMouseIn(player, parentOffsetX, parentOffsetY);
2178 
2179  // Make sure the UI does not catch release events without matching key-down events.
2180  // Otherwise, you could e.g. open a menu on left-down and then the menu would block the left-up event, leading to issues.
2181  if (button == C4MC_Button_LeftUp)
2182  {
2183  // Do not catch up-events without prior down-events!
2184  if (!(currentMouseState & MouseState::MouseDown)) return false;
2185  }
2186 
2187  // do not simply break the loop since some OnMouseOut might go missing
2188  bool oneActionAlreadyExecuted = false;
2189 
2190  const int32_t scrollAdjustedMouseY = mouseY + iScrollY;
2191 
2192  // children actually have a higher priority
2193  bool overChild = false; // remember for later, catch all actions that are in theory over children, even if not reaction (if main window)
2194  // use reverse iterator since children with higher Priority appear later in the list
2195  for (auto iter = rbegin(); iter != rend(); ++iter)
2196  {
2197  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(*iter);
2198 
2199  // Do the visibility check first. The child itself won't do it, because we are handling mouse in/out here, too.
2200  if (!child->IsVisibleTo(player)) continue;
2201 
2202  const int32_t childLeft = child->rcBounds.x;
2203  const int32_t childRight = child->rcBounds.x + child->rcBounds.Wdt;
2204  const int32_t childTop = child->rcBounds.y;
2205  const int32_t childBottom = child->rcBounds.y + child->rcBounds.Hgt;
2206 
2207  bool inArea = true;
2208  if ((mouseX <= childLeft) || (mouseX > childRight)) inArea = false;
2209  else if ((scrollAdjustedMouseY <= childTop) || (scrollAdjustedMouseY > childBottom)) inArea = false;
2210 
2211  if (!inArea) // notify child if it had mouse focus before
2212  {
2213  if (child->HasMouseFocus())
2214  child->OnMouseOut(player);
2215  continue;
2216  }
2217 
2218  if (oneActionAlreadyExecuted) continue;
2219 
2220  overChild = true;
2221  // keep coordinates relative to children
2222  if (child->ProcessMouseInput(button, mouseX - childLeft, scrollAdjustedMouseY - childTop, dwKeyParam, parentOffsetX + rcBounds.x, parentOffsetY + rcBounds.y - iScrollY))
2223  {
2224  oneActionAlreadyExecuted = true;
2225  }
2226  }
2227 
2228  if (oneActionAlreadyExecuted) return true;
2229 
2230  //C4GUI::Element::MouseInput(rMouse, button, mouseX, mouseY, dwKeyParam);
2231 
2232  // remember button-down events. The action will only be executed on button-up
2233  // The sequence for double-clicks is LeftDown-LeftUp-LeftDouble-LeftUp, so treat double as down
2234  if (button == C4MC_Button_LeftDown || button == C4MC_Button_LeftDouble)
2235  currentMouseState |= MouseState::MouseDown;
2236  // trigger!
2237  if (button == C4MC_Button_LeftUp)
2238  {
2241  if (action)
2242  {
2244  return true;
2245  }
2246  }
2247 
2248  // for scroll-enabled windows, scroll contents with wheel
2249  if (pScrollBar->IsVisible() && (button == C4MC_Button_Wheel))
2250  {
2251  short delta = (short)(dwKeyParam >> 16);
2252  ScrollBy(-delta);
2253  //float fac = (lastDrawPosition.bottomMostChild - lastDrawPosition.topMostChild);
2254  //if (fac == 0.0f) fac = 1.0f;
2255  //scrollBar->ScrollBy(-float(delta) / fac);
2256  return true;
2257  }
2258 
2259  // forward to scroll-bar if in area
2260  if (pScrollBar->IsVisible())
2261  {
2262  if ((mouseX > pScrollBar->rcBounds.x && mouseX < pScrollBar->rcBounds.x + pScrollBar->rcBounds.Wdt)
2263  && (mouseY > pScrollBar->rcBounds.y && mouseY < pScrollBar->rcBounds.y + pScrollBar->rcBounds.Hgt))
2264  {
2265  C4GUI::CMouse mouse(mouseX, mouseY);
2266  if (::MouseControl.IsLeftDown()) mouse.LDown = true;
2267  pScrollBar->MouseInput(mouse, button, mouseX - pScrollBar->rcBounds.x, mouseY - pScrollBar->rcBounds.y, dwKeyParam);
2268  }
2269  }
2270 
2271 
2272  // if the user still clicked on a menu - even if it didn't do anything, catch it
2273  // but do that only on the top-level to not stop traversing other branches
2274  if (isMainWindow)
2275  return overChild;
2276  return false;
2277 }
const int32_t C4MC_Button_LeftDown
bool IsVisible()
Definition: C4Gui.cpp:201
virtual bool ProcessMouseInput(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, int32_t parentOffsetX, int32_t parentOffsetY)
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t iScrollY
Definition: C4Gui.h:943
const int32_t C4MC_Button_LeftDouble
bool IsVisibleTo(int32_t player)
int32_t Wdt
Definition: C4Rect.h:30
void OnMouseOut(int32_t player)
void Execute(C4ScriptGuiWindow *parent, int32_t player, int32_t actionType)
const int32_t C4MC_Button_LeftUp
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
int32_t GetPlayer()
int32_t y
Definition: C4Rect.h:30
ScrollBar * pScrollBar
Definition: C4Gui.h:942
ReverseIterator rend()
Definition: C4Gui.h:827
C4Rect rcBounds
Definition: C4Gui.h:385
void ScrollBy(int iAmount)
const int NO_OWNER
Definition: C4Constants.h:137
ReverseIterator rbegin()
Definition: C4Gui.h:826
void OnMouseIn(int32_t player, int32_t parentOffsetX, int32_t parentOffsetY)
int32_t x
Definition: C4Rect.h:30
const int32_t C4MC_Button_Wheel
C4ScriptGuiWindowAction * GetAction()
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rbegin()

ReverseIterator C4GUI::Container::rbegin ( )
inlineinherited

Definition at line 826 of file C4Gui.h.

Referenced by MouseInput(), and ProcessMouseInput().

826 { return ReverseIterator(pLast); }
Element * pLast
Definition: C4Gui.h:750
Here is the caller graph for this function:

◆ ReaddElement()

void C4GUI::Container::ReaddElement ( Element pChild)
inherited

Definition at line 134 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::ListBox::SortElements().

135  {
136  // safety
137  if (!pChild || pChild->pParent != this) return;
138  // remove from any previous container
139  if (pChild->pPrev) pChild->pPrev->pNext = pChild->pNext; else pFirst = pChild->pNext;
140  if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
141  // add to end of list
142  if (pLast) pLast->pNext = pChild; else pFirst = pChild;
143  pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
144 
145  assert(pChild->pNext != pChild);
146  assert(pChild->pPrev != pChild);
147  assert(pChild->pParent != pChild);
148  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Element * pNext
Definition: C4Gui.h:377
Here is the caller graph for this function:

◆ RemoveChild()

void C4ScriptGuiWindow::RemoveChild ( C4ScriptGuiWindow child,
bool  close = true,
bool  all = false 
)

Definition at line 1291 of file C4ScriptGuiWindow.cpp.

References C4GUI::Container::ClearChildren(), Close(), C4GUI::Element::Element(), GetID(), C4GUI::Container::RemoveElement(), and RequestLayoutUpdate().

Referenced by ClearChildren(), Close(), and CreateFromPropList().

1292 {
1293  // do a layout update asap
1294  if (!all && !IsRoot())
1296 
1297  if (child)
1298  {
1299  child->wasRemoved = true;
1300  if (close) child->Close();
1301  if (child->GetID() != 0)
1302  ChildWithIDRemoved(child);
1303  RemoveElement(static_cast<C4GUI::Element*>(child));
1304  // RemoveElement does NOT delete the child itself.
1305  delete child;
1306  }
1307  else if (close) // close all children
1308  {
1309  assert(all);
1310  for (Element * element : *this)
1311  {
1312  C4ScriptGuiWindow * child = static_cast<C4ScriptGuiWindow*>(element);
1313  child->wasRemoved = true;
1314  child->Close();
1315  if (child->GetID() != 0)
1316  ChildWithIDRemoved(child);
1317  }
1318  }
1319 
1320  if (all)
1322 }
void RemoveElement(Element *pChild) override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveElement()

void C4GUI::Container::RemoveElement ( Element pChild)
overridevirtualinherited

Reimplemented from C4GUI::Element.

Reimplemented in C4GUI::Screen, C4GUI::Dialog, C4GUI::ContextMenu, C4GUI::Tabular, and C4GUI::ListBox.

Definition at line 89 of file C4GuiContainers.cpp.

References C4GUI::Container::AfterElementRemoval(), C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, C4GUI::Element::pPrev, and C4GUI::Element::RemoveElement().

Referenced by C4GUI::Container::AddElement(), C4GUI::Container::InsertElement(), RemoveChild(), C4GUI::ListBox::RemoveElement(), C4GUI::Tabular::RemoveElement(), C4GUI::ContextMenu::RemoveElement(), C4GUI::Dialog::RemoveElement(), and C4GUI::Screen::RemoveElement().

90  {
91  // safety
92  if (!pChild) return;
93  // inherited
94  Element::RemoveElement(pChild);
95  // must be from same container
96  if (pChild->pParent != this) return;
97  // unlink from list
98  if (pChild->pPrev) pChild->pPrev->pNext = pChild->pNext; else pFirst = pChild->pNext;
99  if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
100  // unset parent; invalidates pPrev/pNext
101  pChild->pParent = nullptr;
102  // element has been removed
104  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
virtual void AfterElementRemoval()
Definition: C4Gui.h:756
virtual void RemoveElement(Element *pChild)
Definition: C4Gui.cpp:173
Container * pParent
Definition: C4Gui.h:376
Element * pNext
Definition: C4Gui.h:377
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rend()

ReverseIterator C4GUI::Container::rend ( )
inlineinherited

Definition at line 827 of file C4Gui.h.

Referenced by MouseInput(), and ProcessMouseInput().

827 { return ReverseIterator(nullptr); }
Here is the caller graph for this function:

◆ RequestLayoutUpdate()

void C4ScriptGuiWindow::RequestLayoutUpdate ( )

Definition at line 1647 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::GetParent(), C4ScriptGuiWindowStyleFlag::Multiple, and C4ScriptGuiWindowPropertyName::style.

Referenced by Close(), CreateFromPropList(), Denumerate(), RemoveChild(), and SetTag().

1648 {
1649  // directly requested on the root window?
1650  // That usually comes from another part of the engine (f.e. C4Viewport::RecalculateViewports) or from a multiple-window child
1651  if (!GetParent())
1652  {
1653  mainWindowNeedsLayoutUpdate = true;
1654  return;
1655  }
1656 
1657  // are we a direct child of the root?
1658  if (isMainWindow)
1659  {
1660  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
1661 
1662  if (!(style & C4ScriptGuiWindowStyleFlag::Multiple)) // are we a simple centered window?
1663  {
1664  mainWindowNeedsLayoutUpdate = true;
1665  return;
1666  }
1667  else // we are one of the multiple windows.. the root better do a full refresh
1668  {}
1669  }
1670  // propagate to parent window
1671  static_cast<C4ScriptGuiWindow*>(GetParent())->RequestLayoutUpdate();
1672 }
Container * GetParent()
Definition: C4Gui.h:429
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScreenPos2ClientPos()

void C4GUI::Element::ScreenPos2ClientPos ( int32_t &  riX,
int32_t &  riY 
)
inherited

Definition at line 218 of file C4Gui.cpp.

References C4GUI::Container::ApplyElementOffset(), and C4GUI::Element::GetParent().

Referenced by C4GUI::Screen::MouseInput(), and C4GUI::CMouse::ReleaseElements().

219  {
220  // apply all parent offsets
221  Container *pCont = pParent;
222  while (pCont)
223  {
224  pCont->ApplyElementOffset(riX, riY);
225  pCont = pCont->GetParent();
226  }
227  // apply own offset
228  riX -= rcBounds.x; riY -= rcBounds.y;
229  }
int32_t y
Definition: C4Rect.h:30
virtual void ApplyElementOffset(int32_t &riX, int32_t &riY)
Definition: C4Gui.h:840
C4Rect rcBounds
Definition: C4Gui.h:385
Container * pParent
Definition: C4Gui.h:376
int32_t x
Definition: C4Rect.h:30
friend class Container
Definition: C4Gui.h:472
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollBy()

void C4GUI::ScrollWindow::ScrollBy ( int  iAmount)
inherited

Definition at line 564 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4GUI::Window::GetClientRect(), C4Rect::Hgt, C4GUI::ScrollWindow::iScrollY, and C4GUI::ScrollWindow::Update().

Referenced by C4GUI::ScrollWindow::MouseInput(), ProcessMouseInput(), and C4GUI::ScrollWindow::ScrollPages().

565  {
566  int32_t iVisHgt = GetBounds().Hgt;
567  int32_t iClientHgt = GetClientRect().Hgt;
568  int32_t iMaxScroll = iClientHgt - iVisHgt;
569  int iNewScrollY = Clamp<int>(iScrollY + iAmount, 0, iMaxScroll);
570  if (iScrollY != iNewScrollY)
571  {
572  // scrolling possible: do it
573  iScrollY = iNewScrollY;
574  // update (self + bar)
575  Update();
576  }
577  }
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetClientRect() override
Definition: C4Gui.h:864
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollPages()

void C4GUI::ScrollWindow::ScrollPages ( int  iPageCount)
inherited

Definition at line 558 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4Rect::Hgt, and C4GUI::ScrollWindow::ScrollBy().

Referenced by C4GUI::ListBox::OnGetFocus().

559  {
560  int32_t iVisHgt = GetBounds().Hgt;
561  ScrollBy(iPageCount * iVisHgt);
562  }
void ScrollBy(int iAmount)
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollRangeInView()

void C4GUI::ScrollWindow::ScrollRangeInView ( int32_t  iY,
int32_t  iHgt 
)
inherited

Definition at line 579 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4GUI::Window::GetClientRect(), C4Rect::Hgt, C4GUI::ScrollWindow::iScrollY, C4GUI::ScrollWindow::ScrollToBottom(), and C4GUI::ScrollWindow::Update().

Referenced by C4Menu::AdjustPosition(), C4GUI::ListBox::ScrollItemInView(), and C4GUI::TextWindow::SetScrollPos().

580  {
581  // safety bounds
582  if (iY<0) iY=0;
583  int32_t iClientHgt = GetClientRect().Hgt;
584  if (iY+iHgt > iClientHgt) { ScrollToBottom(); return; }
585  // check top
586  if (iScrollY > iY)
587  {
588  iScrollY = iY;
589  Update(); // update (self+bar)
590  }
591  else
592  {
593  // check bottom
594  int32_t iVisHgt = GetBounds().Hgt;
595  // if no height is given, scroll given Y-pos to top
596  if (!iHgt) iHgt = iVisHgt;
597  if (iScrollY + iVisHgt < iY + iHgt)
598  {
599  iScrollY = iY + iHgt - iVisHgt;
600  Update(); // update (self+bar)
601  }
602  }
603  }
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetClientRect() override
Definition: C4Gui.h:864
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollToBottom()

void C4GUI::ScrollWindow::ScrollToBottom ( )
inherited

Definition at line 544 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4GUI::Window::GetClientRect(), C4Rect::Hgt, C4GUI::ScrollWindow::iScrollY, and C4GUI::ScrollWindow::Update().

Referenced by C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ListBox::ScrollToBottom(), and C4GUI::TextWindow::ScrollToBottom().

545  {
546  int32_t iVisHgt = GetBounds().Hgt;
547  int32_t iClientHgt = GetClientRect().Hgt;
548  int32_t iMaxScroll = iClientHgt - iVisHgt;
549  if (iScrollY < iMaxScroll)
550  {
551  // scrolling possible: do it
552  iScrollY = iMaxScroll;
553  // update (self + bar)
554  Update();
555  }
556  }
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetClientRect() override
Definition: C4Gui.h:864
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBounds()

void C4GUI::Element::SetBounds ( const C4Rect rcNewBound)
inlineinherited

Definition at line 446 of file C4Gui.h.

Referenced by C4GameOptionButtons::C4GameOptionButtons(), C4GoalDisplay::C4GoalDisplay(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4GUI::ContextButton::ContextButton(), C4GUI::ListBox::ContractToElementHeight(), C4GUI::Control::Control(), C4GUI::Dialog::Dialog(), C4ChatDlg::DoPlacement(), C4StartupPlrSelDlg::DrawElement(), C4StartupNetListEntry::Execute(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::Screen::Init(), C4Menu::InitSize(), C4GUI::LabeledEdit::LabeledEdit(), C4StartupScenSelDlg::OnClosed(), C4Game::OnResolutionChanged(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollWindow(), C4DefinitionSelDlg::SelectDefinitions(), C4GUI::InputDialog::SetCustomEdit(), C4GUI::Tabular::SetGfx(), C4GoalDisplay::SetGoals(), C4StartupNetListEntry::SetReference(), C4StartupNetListEntry::SetRefQuery(), C4GUI::Tabular::Sheet::Sheet(), C4GUI::TextWindow::TextWindow(), C4ScoreboardDlg::Update(), C4StartupNetListEntry::UpdateCollapsed(), C4Menu::UpdateElementPositions(), C4GUI::ListBox::UpdateElementPositions(), C4ChatControl::ChatSheet::NickItem::UpdateOwnPos(), C4FileSelDlg::DefaultListItem::UpdateOwnPos(), C4GUI::ScrollWindow::UpdateOwnPos(), C4ChatControl::UpdateSize(), C4ChatDlg::UpdateSize(), C4GUI::TextWindow::UpdateSize(), C4GUI::Dialog::UpdateSize(), C4Network2ClientDlg::UpdateText(), and C4DownloadDlg::~C4DownloadDlg().

446 { rcBounds=rcNewBound; UpdatePos(); UpdateSize(); }
virtual void UpdateSize()
Definition: C4Gui.cpp:185
C4Rect rcBounds
Definition: C4Gui.h:385
virtual void UpdatePos()
Definition: C4Gui.cpp:193
Here is the caller graph for this function:

◆ SetClientHeight()

void C4GUI::ScrollWindow::SetClientHeight ( int32_t  iToHgt)
inlineinherited

Definition at line 973 of file C4Gui.h.

Referenced by C4GUI::ListBox::AddElement(), C4GUI::TextWindow::ElementPosChanged(), C4GUI::TextWindow::ElementSizeChanged(), C4GUI::TextWindow::TextWindow(), C4Menu::UpdateElementPositions(), and C4GUI::ListBox::UpdateElementPositions().

974  { iClientHeight=iToHgt; Update(); }
int32_t iClientHeight
Definition: C4Gui.h:944
Here is the caller graph for this function:

◆ SetContextHandler()

void C4GUI::Element::SetContextHandler ( ContextHandler pNewHd)
inlineinherited

Definition at line 465 of file C4Gui.h.

References C4GUI::ContextHandler::Ref().

Referenced by C4StartupMainDlg::C4StartupMainDlg(), C4GUI::ContextButton::ContextButton(), and C4GUI::Edit::Edit().

466  {
468  if ((pContextHandler = pNewHd)) pNewHd->Ref();
469  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDecoration()

void C4GUI::ScrollWindow::SetDecoration ( ScrollBarFacets pToGfx,
bool  fAutoScroll 
)
inlineinherited

Definition at line 977 of file C4Gui.h.

References C4GUI::ScrollBar::SetDecoration().

Referenced by C4GUI::ListBox::SetDecoration(), and C4GUI::TextWindow::SetDecoration().

978  { if (pScrollBar) pScrollBar->SetDecoration(pToGfx, fAutoScroll); }
ScrollBar * pScrollBar
Definition: C4Gui.h:942
void SetDecoration(ScrollBarFacets *pToGfx, bool fAutoHide)
Definition: C4Gui.h:929
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDragTarget()

void C4GUI::Element::SetDragTarget ( Window pToWindow)
inlineinherited

Definition at line 464 of file C4Gui.h.

Referenced by C4GUI::Dialog::SetTitle().

464 { pDragTarget = pToWindow; }
Window * pDragTarget
Definition: C4Gui.h:378
Here is the caller graph for this function:

◆ SetEnumeratedID()

void C4ScriptGuiWindow::SetEnumeratedID ( int  enumID)
inline

Definition at line 276 of file C4ScriptGuiWindow.h.

276 { id = enumID; }

◆ SetPos()

void C4GUI::Window::SetPos ( int32_t  iXPos,
int32_t  iYPos 
)
inlineinherited

Definition at line 860 of file C4Gui.h.

Referenced by C4ScoreboardDlg::DoPlacement(), C4Menu::InitLocation(), C4StartupPlrSelDlg::OnNewBtn(), C4StartupPlrSelDlg::OnPropertyBtn(), C4Menu::SetLocation(), C4GUI::Screen::ShowDialog(), and C4LeagueSignupDialog::ShowModal().

861  { rcBounds.x=iXPos; rcBounds.y=iYPos; UpdatePos(); }
int32_t y
Definition: C4Rect.h:30
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:30
virtual void UpdatePos()
Definition: C4Gui.cpp:193
Here is the caller graph for this function:

◆ SetScroll()

void C4GUI::ScrollWindow::SetScroll ( int32_t  iToScroll)
inherited

Definition at line 538 of file C4GuiContainers.cpp.

References C4GUI::ScrollWindow::iScrollY, C4GUI::Window::rcClientRect, and C4Rect::y.

Referenced by C4GUI::ScrollBar::OnPosChanged(), and C4Menu::SetPosition().

539  {
540  // set values
541  rcClientRect.y = -(iScrollY = iToScroll);
542  }
C4Rect rcClientRect
Definition: C4Gui.h:851
int32_t iScrollY
Definition: C4Gui.h:943
int32_t y
Definition: C4Rect.h:30
Here is the caller graph for this function:

◆ SetScrollBarEnabled()

void C4GUI::ScrollWindow::SetScrollBarEnabled ( bool  fToVal,
bool  noAutomaticPositioning = false 
)
inherited

Definition at line 635 of file C4GuiContainers.cpp.

References C4GUI::ScrollWindow::fHasBar, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::SetVisibility(), and C4GUI::ScrollWindow::UpdateOwnPos().

Referenced by Close(), and C4Menu::InitSize().

636  {
637  if (fHasBar == fToVal) return;
638  pScrollBar->SetVisibility(fHasBar = fToVal);
639  // in some cases the windows will already care for the correct positioning themselves (see C4ScriptGuiWindow)
640  if (!noAutomaticPositioning)
641  UpdateOwnPos();
642  }
virtual void SetVisibility(bool fToValue)
Definition: C4Gui.cpp:207
ScrollBar * pScrollBar
Definition: C4Gui.h:942
void UpdateOwnPos() override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTag()

void C4ScriptGuiWindow::SetTag ( C4String tag)

Definition at line 2022 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowPropertyName::_lastProp, C4ScriptGuiWindowPropertyName::priority, C4ScriptGuiWindowPropertyName::relBottom, RequestLayoutUpdate(), C4ScriptGuiWindowPropertyName::style, and C4ScriptGuiWindowPropertyName::text.

Referenced by CreateFromPropList(), and C4ScriptGuiWindowAction::Execute().

2023 {
2024  // set tag on all properties
2025  for (uint32_t i = 0; i < C4ScriptGuiWindowPropertyName::_lastProp; ++i)
2026  if (props[i].SwitchTag(tag))
2027  {
2028  // only if tag could have changed position etc.
2031  }
2032 
2033  // .. and children
2034  for (C4GUI::Element * element : *this)
2035  (static_cast<C4ScriptGuiWindow*>(element))->SetTag(tag);
2036 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetToolTip()

void C4GUI::Element::SetToolTip ( const char *  szNewTooltip,
bool  is_immediate = false 
)
inherited

Definition at line 409 of file C4Gui.cpp.

Referenced by C4GUI::ContextMenu::AddItem(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4MenuItem::C4MenuItem(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::InfoDialog::CreateSubComponents(), C4StartupScenSelDlg::DoRefresh(), C4StartupPlrSelDlg::DrawElement(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::IconButton::IconButton(), C4GUI::InputDialog::InputDialog(), C4GameLobby::MainDlg::MainDlg(), C4StartupScenSelDlg::OnClosed(), C4GUI::ProgressDialog::ProgressDialog(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::InputDialog::SetCustomEdit(), C4StartupPlrSelDlg::SetSelection(), C4GUI::Dialog::SetTitle(), C4GUI::FullscreenDialog::SetTitle(), C4StartupNetListEntry::SetVisibility(), C4ChatControl::ChatSheet::NickItem::SortFunc(), C4ChatControl::ChatSheet::NickItem::Update(), C4StartupNetListEntry::UpdateCollapsed(), C4GameLobby::MainDlg::UpdateRightTab(), C4Network2ClientDlg::UpdateText(), and C4DownloadDlg::~C4DownloadDlg().

410  {
411  // store tooltip
412  if (szNewTooltip) ToolTip.Copy(szNewTooltip); else ToolTip.Clear();
413  // store immediate flag
414  is_immediate_tooltip = is_immediate;
415  }
void Clear()
Definition: StdBuf.h:466
void Copy()
Definition: StdBuf.h:467
Here is the caller graph for this function:

◆ SetVisibility()

void C4GUI::Container::SetVisibility ( bool  fToValue)
overridevirtualinherited

Reimplemented from C4GUI::Element.

Reimplemented in C4StartupNetListEntry.

Definition at line 247 of file C4GuiContainers.cpp.

References C4GUI::Element::GetDlg(), C4GUI::Dialog::GetFocus(), C4GUI::Container::IsParentOf(), C4GUI::Dialog::SetFocus(), and C4GUI::Element::SetVisibility().

Referenced by C4GUI::Tabular::AddCustomSheet(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Menu::C4Menu(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4Menu::Draw(), C4StartupPlrSelDlg::DrawElement(), C4Menu::InitLocation(), C4StartupNetDlg::OnBtnRecord(), C4StartupScenSelDlg::OnClosed(), C4StartupNetListEntry::SetVisibility(), C4LeagueSignupDialog::ShowModal(), and C4GameOverDlg::~C4GameOverDlg().

248  {
249  // inherited
250  Element::SetVisibility(fToValue);
251  // remove focus from contained elements
252  if (!fToValue)
253  {
254  Dialog *pDlg = GetDlg();
255  if (pDlg)
256  {
257  Control *pFocus = pDlg->GetFocus();
258  if (pFocus)
259  {
260  if (IsParentOf(pFocus))
261  {
262  pDlg->SetFocus(nullptr, false);
263  }
264  }
265  }
266  }
267  }
bool IsParentOf(Element *pEl) override
virtual void SetVisibility(bool fToValue)
Definition: C4Gui.cpp:207
C4GameControl Control
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:288
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartDragging()

void C4GUI::Element::StartDragging ( CMouse rMouse,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
virtualinherited

Definition at line 259 of file C4Gui.cpp.

References C4GUI::CMouse::pDragElement.

Referenced by C4MenuItem::MouseInput().

260  {
261  // set flag
262  fDragging = true;
263  // set drag start pos
264  iDragX = iX; iDragY = iY;
265  // mark drag in mouse
266  rMouse.pDragElement = this;
267  }
int32_t iDragY
Definition: C4Gui.h:379
bool fDragging
Definition: C4Gui.h:380
int32_t iDragX
Definition: C4Gui.h:379
Here is the caller graph for this function:

◆ StopDragging()

void C4GUI::Element::StopDragging ( CMouse rMouse,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
virtualinherited

Definition at line 282 of file C4Gui.cpp.

Referenced by C4GUI::Screen::MouseInput(), and C4GUI::CMouse::ReleaseElements().

283  {
284  // move element pos
285  DoDragging(rMouse, iX, iY, dwKeyParam);
286  }
virtual void DoDragging(CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
Definition: C4Gui.cpp:269
Here is the caller graph for this function:

◆ ToC4Value()

const C4Value C4ScriptGuiWindow::ToC4Value ( )

Definition at line 886 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowPropertyName::backgroundColor, C4ScriptGuiWindowPropertyName::bottom, currentMouseState, StdStrBuf::Format(), C4ScriptGuiWindowPropertyName::frameDecoration, C4ScriptGuiWindowPropertyName::left, C4PropList::New(), C4ScriptGuiWindowPropertyName::onClickAction, C4ScriptGuiWindowPropertyName::onCloseAction, C4ScriptGuiWindowPropertyName::onMouseInAction, C4ScriptGuiWindowPropertyName::onMouseOutAction, P_BackgroundColor, P_Bottom, P_Decoration, P_GraphicsName, P_ID, P_Left, P_Margin, P_Mode, P_OnClick, P_OnClose, P_OnMouseIn, P_OnMouseOut, P_Player, P_Priority, P_Right, P_Style, P_Symbol, P_Target, P_Text, P_Tooltip, P_Top, C4ScriptGuiWindowPropertyName::player, C4ScriptGuiWindowPropertyName::priority, PROPERTY_TUPLE, C4StringTable::RegString(), C4ScriptGuiWindowPropertyName::relBottom, C4ScriptGuiWindowPropertyName::relLeft, C4ScriptGuiWindowPropertyName::relRight, C4ScriptGuiWindowPropertyName::relTop, C4ScriptGuiWindowPropertyName::right, C4PropList::SetProperty(), C4PropList::SetPropertyByS(), Strings, C4ScriptGuiWindowPropertyName::style, C4ScriptGuiWindowPropertyName::symbolDef, C4ScriptGuiWindowPropertyName::symbolGraphicsName, C4ScriptGuiWindowPropertyName::symbolObject, C4ScriptGuiWindowPropertyName::text, C4ScriptGuiWindowProperty::ToC4Value(), ToC4Value(), C4ScriptGuiWindowPropertyName::tooltip, and C4ScriptGuiWindowPropertyName::top.

Referenced by C4ScriptGuiWindowAction::C4ScriptGuiWindowAction(), C4ScriptGuiWindowProperty::GetCurrentTag(), and ToC4Value().

887 {
888  C4PropList *proplist = C4PropList::New();
889 
890  // it is necessary that this list contains all of the properties which can also be set somehow
891  // if you add something, don't forget to also add the real serialization to the loop below
892  int32_t toSave[] =
893  {
894  P_Left,
895  P_Top,
896  P_Right,
897  P_Bottom,
898  P_Margin,
900  P_Decoration,
901  P_Symbol,
902  P_Target,
903  P_Text,
904  P_ID,
905  P_OnClick,
906  P_OnMouseIn,
907  P_OnMouseOut,
908  P_OnClose,
909  P_Style,
910  P_Mode,
911  P_Priority,
912  P_Player,
913  P_Tooltip
914  };
915 
916  const int32_t entryCount = sizeof(toSave) / sizeof(int32_t);
917 
918  for (int prop : toSave)
919  {
920  C4Value val;
921 
922  switch (prop)
923  {
924  case P_Left:
925  case P_Top:
926  case P_Right:
927  case P_Bottom:
928  {
929 #define PROPERTY_TUPLE(p, prop1, prop2) if (prop == p) { val = PositionToC4Value(prop1, prop2); }
934 #undef PROPERTY_TUPLE
935  break;
936  }
937  case P_Margin: val = MarginsToC4Value(); break;
940  case P_Symbol:
941  // either object or def
943  if (val == C4Value()) // is nil?
945  break;
946  case P_Target: val = C4Value(target); break;
947  case P_Text: val = props[C4ScriptGuiWindowPropertyName::text].ToC4Value(); break;
949  case P_Tooltip: val = props[C4ScriptGuiWindowPropertyName::tooltip].ToC4Value(); break;
950  case P_ID: val = C4Value(id); break;
955  case P_Style: val = props[C4ScriptGuiWindowPropertyName::style].ToC4Value(); break;
956  case P_Mode: val = C4Value(int32_t(currentMouseState)); break;
958  case P_Player: val = props[C4ScriptGuiWindowPropertyName::player].ToC4Value(); break;
959 
960  default:
961  assert(false);
962  break;
963  }
964 
965  // don't save "nil" values
966  if (val == C4Value()) continue;
967 
968  proplist->SetProperty(C4PropertyName(prop), val);
969  }
970 
971  // save children now, construct new names for them if necessary
972  int32_t childIndex = 0;
973  for (C4GUI::Element * element : *this)
974  {
975  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(element);
976  C4Value val = child->ToC4Value();
977  C4String *childName = child->name;
978  if (!childName)
979  {
980  StdStrBuf childNameBuf;
981  childNameBuf.Format("_child_%03d", ++childIndex);
982  childName = Strings.RegString(childNameBuf);
983  }
984  proplist->SetPropertyByS(childName, val);
985  }
986 
987  return C4Value(proplist);
988 }
C4String * RegString(StdStrBuf String)
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropertyName
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:971
#define PROPERTY_TUPLE(p, prop1, prop2)
const C4Value ToC4Value()
static C4PropList * New(C4PropList *prototype=nullptr)
Definition: C4PropList.cpp:64
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnFreeze()

void C4GUI::ScrollWindow::UnFreeze ( )
inlineinherited

Definition at line 970 of file C4Gui.h.

Referenced by C4Menu::RefillInternal(), and C4GUI::ListBox::UnFreezeScrolling().

970 { if (!--iFrozen) Update(); }
int32_t iFrozen
Definition: C4Gui.h:946
Here is the caller graph for this function:

◆ Update()

void C4GUI::ScrollWindow::Update ( )
inherited

Definition at line 523 of file C4GuiContainers.cpp.

References C4GUI::Element::GetBounds(), C4Rect::Hgt, C4GUI::ScrollWindow::iClientHeight, C4GUI::ScrollWindow::iFrozen, C4GUI::ScrollWindow::iScrollY, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4GUI::Window::rcClientRect, C4GUI::ScrollBar::Update(), C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::ScrollWindow::ScrollBy(), C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ScrollWindow::ScrollToBottom(), UpdateLayout(), and C4GUI::ScrollWindow::UpdateOwnPos().

524  {
525  // not if window is being refilled
526  if (iFrozen) return;
527  // do not scroll outside range
528  iScrollY = Clamp<int32_t>(iScrollY, 0, std::max<int32_t>(iClientHeight - GetBounds().Hgt, 0));
529  // update client rect
530  rcClientRect.x = 0;
534  // update scroll bar
535  if (pScrollBar) pScrollBar->Update();
536  }
C4Rect rcClientRect
Definition: C4Gui.h:851
int32_t iScrollY
Definition: C4Gui.h:943
int32_t Wdt
Definition: C4Rect.h:30
int32_t y
Definition: C4Rect.h:30
ScrollBar * pScrollBar
Definition: C4Gui.h:942
int32_t iClientHeight
Definition: C4Gui.h:944
C4Rect rcBounds
Definition: C4Gui.h:385
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t x
Definition: C4Rect.h:30
int32_t iFrozen
Definition: C4Gui.h:946
int32_t Hgt
Definition: C4Rect.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateChildLayout()

bool C4ScriptGuiWindow::UpdateChildLayout ( C4TargetFacet cgo,
float  parentWidth,
float  parentHeight 
)

Definition at line 1674 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::Element(), and UpdateLayout().

Referenced by UpdateLayout().

1675 {
1676  for (Element * element : *this)
1677  {
1678  C4ScriptGuiWindow *window = static_cast<C4ScriptGuiWindow*>(element);
1679  window->UpdateLayout(cgo, parentWidth, parentHeight);
1680  }
1681  return true;
1682 }
bool UpdateLayout(C4TargetFacet &cgo)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateLayout() [1/2]

bool C4ScriptGuiWindow::UpdateLayout ( C4TargetFacet cgo)

Definition at line 1684 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowPropertyName::bottom, C4GUI::Element::Element(), C4ScriptGuiWindowProperty::GetInt(), C4Rect::Hgt, C4Facet::Hgt, C4ScriptGuiWindowPropertyName::left, C4ScriptGuiWindowStyleFlag::Multiple, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4ScriptGuiWindowPropertyName::right, C4GUI::Element::SetVisibility(), standardHeight, standardWidth, C4ScriptGuiWindowPropertyName::style, C4ScriptGuiWindowPropertyName::top, UpdateLayout(), C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, C4Facet::Y, and C4TargetFacet::Zoom.

Referenced by Draw(), DrawAll(), UpdateChildLayout(), and UpdateLayout().

1685 {
1686  assert(IsRoot()); // we are root
1687 
1688  // assume I am the root and use the a special rectangle in the viewport for drawing
1689  const float fullWidth = cgo.Wdt * cgo.Zoom - cgo.X;
1690  const float fullHeight = cgo.Hgt * cgo.Zoom - cgo.Y;
1691 
1692  // golden ratio defined default size!
1693  const float &targetWidthEm = C4ScriptGuiWindow::standardWidth;
1694  const float &targetHeightEm = C4ScriptGuiWindow::standardHeight;
1695 
1696  // adjust by viewport size
1697  const float minMarginPx = 50.0f;
1698  const float targetWidthPx = std::min(Em2Pix(targetWidthEm), fullWidth - 2.0f * minMarginPx);
1699  const float targetHeightPx = std::min(Em2Pix(targetHeightEm), fullHeight - 2.0f * minMarginPx);
1700 
1701  // calculate margins to center the window
1702  const float marginLeftRight = (fullWidth - targetWidthPx) / 2.0f;
1703  const float marginTopBottom = (fullHeight- targetHeightPx) / 2.0f;
1704 
1705  // we can only position the window by adjusting left/right/top/bottom
1706  const float &left = marginLeftRight;
1707  const float right = -marginLeftRight;
1708  const float &top = marginTopBottom;
1709  const float bottom = -marginTopBottom;
1710 
1711  // actual size, calculated from borders
1712  const float wdt = fullWidth - left + right;
1713  const float hgt = fullHeight - top + bottom;
1714 
1715  const bool needUpdate = mainWindowNeedsLayoutUpdate || (rcBounds.Wdt != int32_t(wdt)) || (rcBounds.Hgt != int32_t(hgt));
1716 
1717  if (needUpdate)
1718  {
1719  mainWindowNeedsLayoutUpdate = false;
1720 
1721  // these are the coordinates for the centered non-multiple windows
1722  rcBounds.x = static_cast<int>(left);
1723  rcBounds.y = static_cast<int>(top);
1724  rcBounds.Wdt = wdt;
1725  rcBounds.Hgt = hgt;
1726 
1727  // first update all multiple windows (that can cover the whole screen)
1728  for (Element * element : *this)
1729  {
1730  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(element);
1731  const int32_t &style = child->props[C4ScriptGuiWindowPropertyName::style].GetInt();
1732  if (!(style & C4ScriptGuiWindowStyleFlag::Multiple)) continue;
1733  child->UpdateLayout(cgo, fullWidth, fullHeight);
1734  }
1735  // then update all "main" windows in the center of the screen
1736  // todo: adjust the size of the main window based on the border-windows drawn before
1737  for (Element * element : *this)
1738  {