OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 absoluteProperty, C4ScriptGuiWindowPropertyName 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 173 of file C4ScriptGuiWindow.h.

Member Enumeration Documentation

Enumerator
None 
Focus 
MouseDown 

Definition at line 327 of file C4ScriptGuiWindow.h.

Constructor & Destructor Documentation

C4ScriptGuiWindow::C4ScriptGuiWindow ( )

Definition at line 624 of file C4ScriptGuiWindow.cpp.

Referenced by AddChild(), and CreateFromPropList().

624  : C4GUI::ScrollWindow(this)
625 {
626  Init();
627 }

Here is the caller graph for this function:

C4ScriptGuiWindow::~C4ScriptGuiWindow ( )
override

Definition at line 688 of file C4ScriptGuiWindow.cpp.

References C4GUI::Container::ClearChildren(), C4RefCnt::DecRef(), and C4GUI::ScrollWindow::pScrollBar.

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

C4ScriptGuiWindow * C4ScriptGuiWindow::AddChild ( C4ScriptGuiWindow child)

Definition at line 1189 of file C4ScriptGuiWindow.cpp.

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 }
C4ScriptGuiWindow* C4ScriptGuiWindow::AddChild ( )
inline

Definition at line 274 of file C4ScriptGuiWindow.h.

References AddChild(), and C4ScriptGuiWindow().

Referenced by AddChild(), and CreateFromPropList().

274 { return AddChild(new C4ScriptGuiWindow()); }
C4ScriptGuiWindow * AddChild()

Here is the call graph for this function:

Here is the caller graph for this function:

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 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(), C4GUI::ProgressDialog::ProgressDialog(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollWindow(), C4GUI::InputDialog::SetCustomEdit(), C4GoalDisplay::SetGoals(), C4GUI::Dialog::SetTitle(), C4GUI::FullscreenDialog::SetTitle(), and C4GUI::TextWindow::TextWindow().

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:

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

Reimplemented in C4GUI::ListBox.

Definition at line 756 of file C4Gui.h.

References C4GUI::Container::AfterElementRemoval(), and C4GUI::Element::pParent.

Referenced by C4GUI::Container::AfterElementRemoval(), 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 call graph for this function:

Here is the caller graph for this function:

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:

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:

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:

float C4ScriptGuiWindow::CalculateRelativeSize ( float  parentWidthOrHeight,
C4ScriptGuiWindowPropertyName  absoluteProperty,
C4ScriptGuiWindowPropertyName  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:

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:

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(), 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:

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:

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:

void C4ScriptGuiWindow::ClearPointers ( C4Object pObj)

Definition at line 1161 of file C4ScriptGuiWindow.cpp.

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

Referenced by ClearPointers().

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:

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

Definition at line 231 of file C4Gui.cpp.

References C4GUI::Container::ApplyInvElementOffset(), C4GUI::Element::GetParent(), C4GUI::Element::pParent, C4GUI::Element::rcBounds, C4Rect::x, and C4Rect::y.

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:

void C4ScriptGuiWindow::Close ( )

Definition at line 1329 of file C4ScriptGuiWindow.cpp.

References Call, C4GUI::Container::ClearChildren(), C4ScriptGuiWindowAction::ExecuteCommand(), C4ScriptGuiWindowProperty::GetAction(), C4GUI::Element::GetParent(), NO_OWNER, onCloseAction, and RemoveChild().

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:

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

Definition at line 990 of file C4ScriptGuiWindow.cpp.

References AddChild(), backgroundColor, bottom, C4ScriptGuiWindow(), CreateFromPropList(), currentMouseState, frameDecoration, GetChildByName(), C4String::GetCStr(), C4GUI::Element::GetParent(), C4PropList::GetProperties(), C4PropList::GetPropertyByS(), C4Value::getStr(), C4RefCnt::IncRef(), left, MenuDebugLogF, onClickAction, onCloseAction, onMouseInAction, 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, player, priority, relBottom, relLeft, relRight, relTop, RemoveChild(), RequestLayoutUpdate(), right, C4ScriptGuiWindowProperty::Set(), SetTag(), Strings, style, symbolDef, symbolGraphicsName, symbolObject, text, tooltip, and 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
const char * GetCStr() const
Definition: C4StringTable.h:49
void SetTag(C4String *tag)
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:757
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:914
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)
void Set(const C4Value &value, C4String *tag)

Here is the call graph for this function:

Here is the caller graph for this function:

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 }
bool CreateFromPropList(C4PropList *proplist, bool resetStdTag=false, bool isUpdate=false, bool isLoading=false)
const C4Value & GetValue(uint32_t)
Definition: C4Value.cpp:243
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

bool C4GUI::Element::DoContext ( )
inherited

Definition at line 417 of file C4Gui.cpp.

References C4Rect::Hgt, C4GUI::ContextHandler::OnContext(), C4GUI::Element::pContextHandler, C4GUI::Element::rcBounds, and C4Rect::Wdt.

Referenced by C4GUI::Control::KeyContext(), and C4GUI::ContextButton::MouseInput().

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 call graph for this function:

Here is the caller graph for this function:

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.

References C4GUI::Element::iDragX, C4GUI::Element::iDragY, C4GUI::Element::pDragTarget, C4GUI::Element::rcBounds, C4GUI::Element::UpdatePos(), C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Screen::MouseInput(), and C4GUI::Element::StopDragging().

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 call graph for this function:

Here is the caller graph for this function:

void C4ScriptGuiWindow::Draw ( C4TargetFacet cgo)
inlineoverridevirtual

Reimplemented from C4GUI::Window.

Definition at line 296 of file C4ScriptGuiWindow.h.

Referenced by DrawChildren().

296 {}

Here is the caller graph for this function:

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

Definition at line 1885 of file C4ScriptGuiWindow.cpp.

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

1886 {
1887  assert(!IsRoot()); // not root, root needs to receive DrawAll
1888 
1889  // message hidden?
1890  if (!IsVisibleTo(player)) return false;
1891 
1892  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
1893 
1894  if (mainWindowNeedsLayoutUpdate)
1895  {
1896  assert(GetParent() && (static_cast<C4ScriptGuiWindow*>(GetParent())->IsRoot()));
1897  assert(isMainWindow);
1898  assert(!(style & C4ScriptGuiWindowStyleFlag::Multiple) && "\"Multiple\"-style window not updated by a full refresh of the root window.");
1899  C4ScriptGuiWindow * parent = static_cast<C4ScriptGuiWindow*>(GetParent());
1900  UpdateLayout(cgo, parent->rcBounds.Wdt, parent->rcBounds.Hgt);
1901  assert(!mainWindowNeedsLayoutUpdate);
1902  }
1903 
1904  const int32_t outDrawX = cgo.X + cgo.TargetX + rcBounds.x;
1905  const int32_t outDrawY = cgo.Y + cgo.TargetY + rcBounds.y;
1906  const int32_t outDrawWdt = rcBounds.Wdt;
1907  const int32_t outDrawHgt = rcBounds.Hgt;
1908  const int32_t outDrawRight = outDrawX + rcBounds.Wdt;
1909  const int32_t outDrawBottom = outDrawY + rcBounds.Hgt;
1910  // draw various properties
1911  C4Facet cgoOut(cgo.Surface, outDrawX, outDrawY, outDrawWdt, outDrawHgt);
1912 
1914  if (backgroundColor)
1915  pDraw->DrawBoxDw(cgo.Surface, outDrawX, outDrawY, outDrawRight - 1.0f, outDrawBottom - 1.0f, backgroundColor);
1916 
1918 
1919  if (frameDecoration)
1920  {
1921  // the frame decoration will adjust for cgo.TargetX/Y itself
1922  C4Rect rect(
1923  outDrawX - frameDecoration->iBorderLeft - cgo.TargetX,
1924  outDrawY - frameDecoration->iBorderTop - cgo.TargetY,
1925  outDrawWdt + frameDecoration->iBorderRight + frameDecoration->iBorderLeft,
1926  outDrawHgt + frameDecoration->iBorderBottom + frameDecoration->iBorderTop);
1927  frameDecoration->Draw(cgo, rect);
1928  }
1929 
1931  if (symbolObject)
1932  {
1933  symbolObject->DrawPicture(cgoOut, false, nullptr);
1934  }
1935  else
1936  {
1939  if (symbolDef)
1940  {
1941  symbolDef->Draw(cgoOut, false, 0UL, nullptr, 0, 0, nullptr, graphicsName ? graphicsName->getData() : nullptr);
1942  }
1943  }
1944 
1946 
1947  if (strBuf)
1948  {
1949  StdStrBuf sText;
1950  int alignment = ALeft;
1951  // If we are showing a scrollbar, we need to leave a bit of space for it so that it doesn't overlap the text.
1952  const int scrollbarXOffset = pScrollBar->IsVisible() ? pScrollBar->rcBounds.Wdt : 0;
1953  const int scrollbarScroll = pScrollBar->IsVisible() ? this->GetScrollY() : 0;
1954  const int actualDrawingWidth = outDrawWdt - scrollbarXOffset;
1955 
1956  // If we are set to NoCrop, the message will be split by string-defined line breaks only.
1957  int allowedTextWidth = actualDrawingWidth;
1958 
1960  allowedTextWidth = std::numeric_limits<int>::max();
1961  int32_t textHgt = ::GraphicsResource.FontRegular.BreakMessage(strBuf->getData(), allowedTextWidth, &sText, true);
1962  float textYOffset = static_cast<float>(-scrollbarScroll), textXOffset = 0.0f;
1964  textYOffset = float(outDrawHgt) / 2.0f - float(textHgt) / 2.0f;
1965  else if (style & C4ScriptGuiWindowStyleFlag::TextBottom)
1966  textYOffset = float(outDrawHgt) - float(textHgt);
1968  {
1969  int wdt, hgt;
1970  ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(), wdt, hgt, true);
1971  textXOffset = float(actualDrawingWidth) / 2.0f;
1972  alignment = ACenter;
1973  }
1974  else if (style & C4ScriptGuiWindowStyleFlag::TextRight)
1975  {
1976  alignment = ARight;
1977  int wdt, hgt;
1978  ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(), wdt, hgt, true);
1979  textXOffset = float(actualDrawingWidth);
1980  }
1981  pDraw->TextOut(sText.getData(), ::GraphicsResource.FontRegular, 1.0, cgo.Surface, outDrawX + textXOffset, outDrawY + textYOffset, 0xffffffff, alignment);
1982  }
1983 
1984 
1985  if (GraphicsSystem.ShowMenuInfo) // print helpful debug info
1986  {
1987  DWORD frameColor = C4RGB(100, 150, 100);
1988  if (currentMouseState & MouseState::Focus) frameColor = C4RGB(0, 255, 0);
1989 
1990  pDraw->DrawFrameDw(cgo.Surface, outDrawX, outDrawY, outDrawRight, outDrawBottom, frameColor);
1991  if (target || id)
1992  {
1993  StdStrBuf buf = FormatString("%s(%d)", target ? target->GetName() : "", id);
1994  pDraw->TextOut(buf.getData(), ::GraphicsResource.FontCaption, 1.0, cgo.Surface, cgo.X + outDrawRight, cgo.Y + outDrawBottom - ::GraphicsResource.FontCaption.GetLineHeight(), 0xffff00ff, ARight);
1995  }
1996  //StdStrBuf buf2 = FormatString("(%d, %d, %d, %d)", rcBounds.x, rcBounds.y, rcBounds.Wdt, rcBounds.Hgt);
1997  //pDraw->TextOut(buf2.getData(), ::GraphicsResource.FontCaption, 1.0, cgo.Surface, cgo.X + outDrawX + rcBounds.Wdt / 2, cgo.Y + outDrawY + +rcBounds.Hgt / 2, 0xff00ffff, ACenter);
1998  }
1999 
2000  DrawChildren(cgo, player, -1, currentClippingRect);
2001  return true;
2002 }
const char * getData() const
Definition: StdBuf.h:442
int32_t GetScrollY()
Definition: C4Gui.h:987
int GetLineHeight() const
Definition: C4FontLoader.h:125
float Y
Definition: C4Facet.h:118
void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
Definition: C4Object.cpp:2336
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
virtual const char * GetName() const
Definition: C4PropList.cpp:649
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
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
bool UpdateLayout(C4TargetFacet &cgo)
const int ALeft
Definition: C4Surface.h:41
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:

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(), C4Rect::Hgt, pDraw, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

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:

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

Definition at line 1863 of file C4ScriptGuiWindow.cpp.

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

1864 {
1865  assert(IsRoot()); // we are root
1866  if (!IsVisible()) return false;
1867  // if the viewport shows an upper-board, apply an offset to everything
1868  const int oldTargetX = cgo.TargetX;
1869  const int oldTargetY = cgo.TargetY;
1870  cgo.TargetX += cgo.X;
1871  cgo.TargetY += cgo.Y;
1872  // this will check whether the viewport resized and we need an update
1873  UpdateLayout(cgo);
1874  // step one: draw all multiple-tagged windows
1875  DrawChildren(cgo, player, 1);
1876  // TODO: adjust rectangle for main menu if multiple windows exist
1877  // step two: draw one "main" menu
1878  DrawChildren(cgo, player, 0);
1879  // ..and restore the offset
1880  cgo.TargetX = oldTargetX;
1881  cgo.TargetY = oldTargetY;
1882  return true;
1883 }
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:

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, C4Rect::Hgt, C4Facet::Hgt, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, and C4Rect::y.

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:

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

Definition at line 1554 of file C4ScriptGuiWindow.cpp.

References Draw(), C4GUI::ScrollBar::DrawElement(), GetClippingRect(), C4ScriptGuiWindowProperty::GetInt(), C4Rect::Hgt, C4Facet::Hgt, C4GUI::ScrollWindow::iScrollY, C4GUI::Element::IsVisible(), Multiple, pDraw, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, C4Draw::RestorePrimaryClipper(), C4Draw::SetPrimaryClipper(), C4Draw::StorePrimaryClipper(), 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().

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

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

Definition at line 365 of file C4Gui.cpp.

References C4GUI::Element::DrawHVBar(), C4Rect::Hgt, C4GUI::Element::rcBounds, C4BltTransform::SetRotate(), C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

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:

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, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Element::DrawHBarByVGfx(), and C4GUI::Element::DrawVBar().

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:

Here is the caller graph for this function:

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

Definition at line 359 of file C4Gui.cpp.

References C4GUI::Element::DrawHVBar(), C4Rect::Hgt, and C4GUI::Element::rcBounds.

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 call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from C4GUI::Container.

Definition at line 954 of file C4Gui.h.

References C4GUI::Container::ElementPosChanged(), and C4GUI::Element::pParent.

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:

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

Reimplemented from C4GUI::Container.

Definition at line 949 of file C4Gui.h.

References C4GUI::Container::ElementSizeChanged(), and C4GUI::Element::pParent.

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:

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:

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

Definition at line 2276 of file C4ScriptGuiWindow.cpp.

References ExecuteCommand(), C4ScriptGuiWindowProperty::GetAllActions(), C4GUI::Container::GetElementCount(), and MenuDebugLogF.

Referenced by ExecuteCommand().

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

void C4GUI::ScrollWindow::Freeze ( )
inlineinherited

Definition at line 969 of file C4Gui.h.

References C4GUI::ScrollWindow::iFrozen.

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:

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

Definition at line 445 of file C4Gui.h.

References C4GUI::Element::rcBounds.

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::ScrollBar::GetMaxScroll(), 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(), 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::Tabular::SetGfx(), C4GoalDisplay::SetGoals(), C4GUI::TextWindow::SetPicture(), C4GUI::Dialog::SetTitle(), C4GUI::ScrollBar::Update(), C4GUI::ScrollWindow::Update(), C4StartupPlrSelDlg::PlayerListItem::UpdateCore(), C4GUI::ListBox::UpdateElementPosition(), C4Menu::UpdateElementPositions(), C4GUI::ListBox::UpdateElementPositions(), C4GUI::ScrollWindow::UpdateOwnPos(), C4Menu::UpdateScrollBar(), and C4GUI::TextWindow::UpdateSize().

445 { return rcBounds; }
C4Rect rcBounds
Definition: C4Gui.h:385

Here is the caller graph for this function:

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:

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:

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

Reimplemented from C4GUI::Element.

Definition at line 864 of file C4Gui.h.

References C4GUI::Window::rcClientRect.

Referenced by 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::Window::Draw(), 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::Window::MouseInput(), 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(), C4GUI::TextWindow::TextWindow(), C4GUI::ScrollBar::Update(), C4GUI::ListBox::UpdateColumnCount(), and C4GUI::TextWindow::UpdateSize().

864 { return rcClientRect; }
C4Rect rcClientRect
Definition: C4Gui.h:851

Here is the caller graph for this function:

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

Definition at line 2004 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowProperty::GetInt(), C4Rect::Hgt, left, NoCrop, C4GUI::Element::rcBounds, style, top, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by DrawChildren().

2005 {
2006  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
2007  if (IsRoot() || (style & C4ScriptGuiWindowStyleFlag::NoCrop))
2008  return false;
2009 
2010  // Other windows always clip their children.
2011  // This implicitly clips childrens' text to the parent size, too.
2012  left = rcBounds.x;
2013  top = rcBounds.y;
2014  right = rcBounds.Wdt + left;
2015  bottom = rcBounds.Hgt + top;
2016  return true;
2017 }
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 call graph for this function:

Here is the caller graph for this function:

C4Rect C4GUI::Element::GetContainedClientRect ( )
inlineinherited

Definition at line 448 of file C4Gui.h.

References C4GUI::Element::GetClientRect(), C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Tabular::AddSheet(), C4ChartDialog::C4ChartDialog(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4ChatDlg::DoPlacement(), C4GUI::Element::GetToprightCornerRect(), C4GUI::InputDialog::InputDialog(), C4GameLobby::MainDlg::MainDlg(), C4GUI::TextWindow::TextWindow(), C4Menu::UpdateElementPositions(), C4ChatControl::ChatSheet::NickItem::UpdateOwnPos(), C4FileSelDlg::DefaultListItem::UpdateOwnPos(), C4StartupScenSelDlg::ScenListItem::UpdateOwnPos(), C4GUI::ScrollWindow::UpdateOwnPos(), C4ChatControl::UpdateSize(), C4ChatDlg::UpdateSize(), C4GUI::Tabular::UpdateSize(), and C4GUI::TextWindow::UpdateSize().

448 { C4Rect rc=GetClientRect(); rc.x=rc.y=0; return rc; }
Definition: C4Rect.h:27
int32_t y
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:447

Here is the call graph for this function:

Here is the caller graph for this function:

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
ContextHandler * C4GUI::Element::GetContextHandler ( )
virtualinherited

Reimplemented in C4GUI::Dialog.

Definition at line 429 of file C4Gui.cpp.

References C4GUI::Element::GetContextHandler(), C4GUI::Element::pContextHandler, and C4GUI::Element::pParent.

Referenced by C4GUI::ContextButton::ContextButton(), C4GUI::Element::GetContextHandler(), and C4GUI::Element::MouseInput().

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 call graph for this function:

Here is the caller graph for this function:

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
Dialog * C4GUI::Element::GetDlg ( )
virtualinherited

Reimplemented in C4GUI::Dialog.

Definition at line 288 of file C4Gui.cpp.

References C4GUI::Element::GetDlg(), and C4GUI::Element::pParent.

Referenced by C4GUI::Control::DisableFocus(), C4ChatControl::DlgEnter(), C4ChatControl::GetDefaultControl(), C4GUI::Element::GetDlg(), C4GUI::ContextMenu::GetTargetDialog(), C4GUI::Control::HasDrawFocus(), C4GUI::Element::IsInActiveDlg(), C4GUI::Label::MouseInput(), C4GUI::Control::MouseInput(), C4GUI::Screen::MouseInput(), C4ChatControl::OnConnectBtn(), C4GUI::RenameEdit::OnFinishInput(), C4GUI::Label::OnHotkey(), C4ChatControl::OnLoginDataEnter(), C4GUI::CloseButton::OnPress(), C4GUI::CloseIconButton::OnPress(), C4GUI::RenameEdit::RenameEdit(), C4GUI::Container::SetVisibility(), and C4GUI::Screen::ShowDialog().

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:

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 C4GUI::ContextMenu::GetIndexedEntry(), C4Menu::GetItem(), C4GUI::Tabular::GetSheet(), 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:

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(), C4GUI::Tabular::GetSheetCount(), 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:

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

Reimplemented from C4GUI::Element.

Definition at line 773 of file C4Gui.h.

References C4GUI::Container::pFirst.

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

773 { return pFirst; }
Element * pFirst
Definition: C4Gui.h:750

Here is the caller graph for this function:

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:

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:

int32_t C4ScriptGuiWindow::GetID ( )
inline

Definition at line 250 of file C4ScriptGuiWindow.h.

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

250 { return id; }

Here is the caller graph for this function:

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

Definition at line 830 of file C4Gui.h.

References C4GUI::Container::pLast.

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:

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

Definition at line 774 of file C4Gui.h.

References C4GUI::Container::pLast.

774 { return pLast; }
Element * pLast
Definition: C4Gui.h:750
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(), and C4GUI::ListBox::UpdateElementPositions().

461 { return C4GUI_DefaultListSpacing; }
#define C4GUI_DefaultListSpacing
Definition: C4Gui.h:123

Here is the caller graph for this function:

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

Definition at line 462 of file C4Gui.h.

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

462 { return false; }

Here is the caller graph for this function:

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(), C4GoalDisplay::SetGoals(), and C4GUI::Window::UpdateOwnPos().

876 { return 0; }

Here is the caller graph for this function:

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:

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:

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(), C4GoalDisplay::SetGoals(), and C4GUI::Window::UpdateOwnPos().

873 { return 0; }

Here is the caller graph for this function:

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:

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:

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

Definition at line 450 of file C4Gui.h.

References C4GUI::Element::pPrev.

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

450 { return pPrev; }
Element * pPrev
Definition: C4Gui.h:377

Here is the caller graph for this function:

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

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

Definition at line 289 of file C4Gui.cpp.

References C4GUI::Element::GetScreen(), and C4GUI::Element::pParent.

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

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:

int32_t C4GUI::ScrollWindow::GetScrollY ( )
inlineinherited

Definition at line 987 of file C4Gui.h.

References C4GUI::ScrollWindow::iScrollY.

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:

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:

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

Definition at line 423 of file C4Gui.cpp.

References StdStrBuf::getData(), C4GUI::Element::GetToolTip(), StdStrBuf::isNull(), and C4GUI::Element::pParent.

Referenced by C4GUI::CMouse::Draw(), C4GUI::Element::GetToolTip(), 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 * getData() const
Definition: StdBuf.h:442
const char * GetToolTip()
Definition: C4Gui.cpp:423
Container * pParent
Definition: C4Gui.h:376
bool isNull() const
Definition: StdBuf.h:441

Here is the call graph for this function:

Here is the caller graph for this function:

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 C4GUI::Element::GetClientRect(), C4GUI::Element::GetContainedClientRect(), C4GUI::Element::GetContainer(), C4Rect::Hgt, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

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

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 call graph for this function:

Here is the caller graph for this function:

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:

bool C4ScriptGuiWindow::HasMouseFocus ( )
inline

Definition at line 339 of file C4ScriptGuiWindow.h.

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

339 { return currentMouseState & MouseState::Focus; }

Here is the caller graph for this function:

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 C4GUI::ListBox::InsertElement(), 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:

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
virtual bool C4GUI::Element::IsExternalDrawDialog ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::Dialog, and C4Menu.

Definition at line 402 of file C4Gui.h.

402 { return false; }
virtual bool C4GUI::Container::IsFocused ( Control pCtrl)
inlinevirtualinherited

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

Definition at line 836 of file C4Gui.h.

References C4GUI::Container::IsFocused(), and C4GUI::Element::pParent.

Referenced by C4GUI::Control::HasFocus(), C4GUI::Container::IsFocused(), and C4GUI::ListBox::IsFocused().

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 call graph for this function:

Here is the caller graph for this function:

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:

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

Definition at line 971 of file C4Gui.h.

References C4GUI::ScrollWindow::iFrozen.

971 { return !!iFrozen; }
int32_t iFrozen
Definition: C4Gui.h:946
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:

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

Definition at line 435 of file C4Gui.cpp.

References C4GUI::Element::GetDlg(), and 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:

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

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

Definition at line 403 of file C4Gui.h.

Referenced by C4GUI::Element::RemoveElement().

403 { return false; }

Here is the caller graph for this function:

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:

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::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:

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.

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:

bool C4GUI::ScrollWindow::IsScrollBarEnabled ( )
inlineinherited

Definition at line 990 of file C4Gui.h.

References C4GUI::ScrollWindow::fHasBar.

Referenced by C4Menu::UpdateScrollBar().

990 { return fHasBar; }

Here is the caller graph for this function:

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:

bool C4GUI::ScrollWindow::IsScrollingNecessary ( )
inlineinherited

Definition at line 993 of file C4Gui.h.

References C4Rect::Hgt, and C4GUI::Element::rcBounds.

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:

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

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

Definition at line 837 of file C4Gui.h.

References C4GUI::Container::IsSelectedChild(), and C4GUI::Element::pParent.

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

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 call graph for this function:

Here is the caller graph for this function:

bool C4GUI::Element::IsVisible ( )
inherited

Definition at line 201 of file C4Gui.cpp.

References C4GUI::Element::fVisible, C4GUI::Element::IsVisible(), and C4GUI::Element::pParent.

Referenced by C4GUI::Dialog::AdvanceFocus(), C4GUI::Screen::CharIn(), C4GUI::ControlKeyDlgCB< TargetClass >::CheckCondition(), Draw(), C4GUI::Container::Draw(), C4GUI::Window::Draw(), C4GUI::Screen::Draw(), DrawAll(), DrawChildren(), C4ChatControl::GetDefaultControl(), C4GUI::Screen::GetFullscreenDialog(), C4GUI::Element::IsVisible(), IsVisibleTo(), C4GUI::Window::MouseInput(), C4GUI::Control::MouseInput(), C4GUI::Screen::MouseInput(), C4GUI::Container::OnHotkey(), ProcessMouseInput(), C4Menu::SetPosition(), C4Menu::UpdateElementPositions(), and C4GUI::TextWindow::UpdateSize().

202  {
203  // self and parent must be visible
204  return fVisible && (!pParent || pParent->IsVisible());
205  }
bool IsVisible()
Definition: C4Gui.cpp:201
Container * pParent
Definition: C4Gui.h:376
bool fVisible
Definition: C4Gui.h:383

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ScriptGuiWindow::IsVisibleTo ( int32_t  player)

Definition at line 2349 of file C4ScriptGuiWindow.cpp.

References ANY_OWNER, C4ScriptGuiWindowProperty::GetInt(), C4Object::IsVisible(), C4GUI::Element::IsVisible(), and player.

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

2350 {
2351  // Not visible at all?
2352  if (!IsVisible()) return false;
2353  // We have a player assigned and it's a different one?
2354  const int32_t &myPlayer = props[C4ScriptGuiWindowPropertyName::player].GetInt();
2355  if (myPlayer != ANY_OWNER && player != myPlayer) return false;
2356  // We have a target object which is invisible to the player?
2357  if (target && !target->IsVisible(player, false)) return false;
2358  // Default to visible!
2359  return true;
2360 }
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:4047

Here is the call graph for this function:

Here is the caller graph for this function:

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:

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

Reimplemented from C4GUI::Element.

Definition at line 2035 of file C4ScriptGuiWindow.cpp.

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

2036 {
2037  assert(::MouseControl.GetPlayer() != NO_OWNER);
2038 }
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:

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

Definition at line 2095 of file C4ScriptGuiWindow.cpp.

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

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

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, C4GUI::Window::MouseInput(), and C4GUI::ScrollWindow::ScrollBy().

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:

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

Reimplemented from C4GUI::Element.

Definition at line 2070 of file C4ScriptGuiWindow.cpp.

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

2071 {
2072  assert(::MouseControl.GetPlayer() != NO_OWNER);
2073 
2074 }
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:

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.

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:

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

Definition at line 2040 of file C4ScriptGuiWindow.cpp.

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

Referenced by ProcessMouseInput().

2041 {
2042  assert(!HasMouseFocus() && "custom menu window properly loaded incorrectly!");
2043  currentMouseState = MouseState::Focus;
2044 
2045  // no need to notify children, this is done in MouseInput
2046 
2047  // update tooltip info if applicable
2049  if (strBuf)
2050  {
2051  C4Viewport * viewport = ::Viewports.GetViewport(player);
2052  if (viewport)
2053  {
2054  const float guiZoom = viewport->GetGUIZoom();
2055  const float x = float(parentOffsetX + rcBounds.x) / guiZoom;
2056  const float y = float(parentOffsetY + rcBounds.y) / guiZoom;
2057  const float wdt = float(rcBounds.Wdt) / guiZoom;
2058  const float hgt = float(rcBounds.Hgt) / guiZoom;
2059  ::MouseControl.SetTooltipRectangle(C4Rect(x, y, wdt, hgt));
2060  ::MouseControl.SetTooltipText(*strBuf);
2061  }
2062  }
2063  // execute action
2065  C4ScriptGuiWindowAction *action = props[actionType].GetAction();
2066  if (!action) return;
2067  action->Execute(this, player, actionType);
2068 }
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
C4ScriptGuiWindowAction * GetAction()
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
float GetGUIZoom() const
Definition: C4Viewport.h:47
int32_t Hgt
Definition: C4Rect.h:30

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ScriptGuiWindow::OnMouseOut ( int32_t  player)

Definition at line 2075 of file C4ScriptGuiWindow.cpp.

References currentMouseState, C4ScriptGuiWindowAction::Execute(), C4ScriptGuiWindowProperty::GetAction(), HasMouseFocus(), None, OnMouseOut(), and onMouseOutAction.

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

2076 {
2077  assert(HasMouseFocus() && "custom menu window probably loaded incorrectly!");
2079 
2080  // needs to notify children
2081  for (C4GUI::Element *iter : *this)
2082  {
2083  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(iter);
2084  if (child->HasMouseFocus())
2085  child->OnMouseOut(player);
2086  }
2087 
2088  // execute action
2090  C4ScriptGuiWindowAction *action = props[actionType].GetAction();
2091  if (!action) return;
2092  action->Execute(this, player, actionType);
2093 }
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:

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

Definition at line 2162 of file C4ScriptGuiWindow.cpp.

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

Referenced by MouseInput(), and ProcessMouseInput().

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

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:

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:

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:

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::Element::RemoveElement(), C4GUI::ListBox::RemoveElement(), C4GUI::Tabular::RemoveElement(), C4GUI::ContextMenu::RemoveElement(), C4GUI::Dialog::RemoveElement(), C4GUI::Screen::RemoveElement(), and C4GUI::Element::~Element().

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:

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:

void C4ScriptGuiWindow::RequestLayoutUpdate ( )

Definition at line 1644 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowProperty::GetInt(), C4GUI::Element::GetParent(), Multiple, and style.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 218 of file C4Gui.cpp.

References C4GUI::Container::ApplyElementOffset(), C4GUI::Element::GetParent(), C4GUI::Element::pParent, C4GUI::Element::rcBounds, C4Rect::x, and C4Rect::y.

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:

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:

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().

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:

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:

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:

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

Definition at line 446 of file C4Gui.h.

References C4GUI::Element::UpdatePos(), and C4GUI::Element::UpdateSize().

Referenced by C4GameOptionButtons::C4GameOptionButtons(), C4GoalDisplay::C4GoalDisplay(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4GUI::ContextButton::ContextButton(), C4GUI::ListBox::ContractToElementHeight(), C4GUI::Control::Control(), C4GUI::Dialog::Dialog(), C4ChatDlg::DoPlacement(), C4StartupNetListEntry::Execute(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::GroupBox::GroupBox(), C4GUI::HorizontalLine::HorizontalLine(), C4GUI::Screen::Init(), C4Menu::InitSize(), C4GUI::LabeledEdit::LabeledEdit(), C4Game::OnResolutionChanged(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollWindow(), C4GUI::InputDialog::SetCustomEdit(), C4GUI::Tabular::SetGfx(), C4GoalDisplay::SetGoals(), C4StartupNetListEntry::SetReference(), C4StartupNetListEntry::SetRefQuery(), C4GUI::Tabular::Sheet::Sheet(), C4GUI::TextWindow::TextWindow(), C4ScoreboardDlg::Update(), C4Menu::UpdateElementPositions(), C4GUI::ListBox::UpdateElementPositions(), C4GUI::ScrollWindow::UpdateOwnPos(), C4ChatControl::UpdateSize(), C4ChatDlg::UpdateSize(), C4GUI::TextWindow::UpdateSize(), and C4GUI::Dialog::UpdateSize().

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 call graph for this function:

Here is the caller graph for this function:

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

Definition at line 973 of file C4Gui.h.

References C4GUI::ScrollWindow::Update().

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 call graph for this function:

Here is the caller graph for this function:

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

Definition at line 465 of file C4Gui.h.

References C4GUI::ContextHandler::DeRef(), C4GUI::Element::pContextHandler, and 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:

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:

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

Definition at line 464 of file C4Gui.h.

References C4GUI::Element::pDragTarget.

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

464 { pDragTarget = pToWindow; }
Window * pDragTarget
Definition: C4Gui.h:378

Here is the caller graph for this function:

void C4ScriptGuiWindow::SetEnumeratedID ( int  enumID)
inline

Definition at line 270 of file C4ScriptGuiWindow.h.

270 { id = enumID; }
void C4GUI::Window::SetPos ( int32_t  iXPos,
int32_t  iYPos 
)
inlineinherited

Definition at line 860 of file C4Gui.h.

References C4GUI::Element::rcBounds, C4GUI::Element::UpdatePos(), C4Rect::x, and C4Rect::y.

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

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 call graph for this function:

Here is the caller graph for this function:

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:

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 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:

void C4ScriptGuiWindow::SetTag ( C4String tag)

Definition at line 2019 of file C4ScriptGuiWindow.cpp.

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

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

2020 {
2021  // set tag on all properties
2022  for (uint32_t i = 0; i < C4ScriptGuiWindowPropertyName::_lastProp; ++i)
2023  if (props[i].SwitchTag(tag))
2024  {
2025  // only if tag could have changed position etc.
2028  }
2029 
2030  // .. and children
2031  for (C4GUI::Element * element : *this)
2032  (static_cast<C4ScriptGuiWindow*>(element))->SetTag(tag);
2033 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 409 of file C4Gui.cpp.

References StdStrBuf::Clear(), and StdStrBuf::Copy().

Referenced by C4GUI::ContextMenu::AddItem(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4MenuItem::C4MenuItem(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::InfoDialog::CreateSubComponents(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::IconButton::IconButton(), C4GUI::InputDialog::InputDialog(), C4GameLobby::MainDlg::MainDlg(), C4GUI::ProgressDialog::ProgressDialog(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::InputDialog::SetCustomEdit(), C4GUI::Dialog::SetTitle(), C4GUI::FullscreenDialog::SetTitle(), C4ChatControl::ChatSheet::NickItem::Update(), and C4GameLobby::MainDlg::UpdateRightTab().

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 call graph for this function:

Here is the caller graph for this function:

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(), C4Menu::InitLocation(), and C4StartupNetListEntry::SetVisibility().

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:

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::Element::fDragging, C4GUI::Element::iDragX, C4GUI::Element::iDragY, and C4GUI::CMouse::pDragElement.

Referenced by C4MenuItem::MouseInput(), and C4GUI::Element::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:

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

Definition at line 282 of file C4Gui.cpp.

References C4GUI::Element::DoDragging().

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 call graph for this function:

Here is the caller graph for this function:

const C4Value C4ScriptGuiWindow::ToC4Value ( )

Definition at line 886 of file C4ScriptGuiWindow.cpp.

References backgroundColor, bottom, currentMouseState, StdStrBuf::Format(), frameDecoration, left, C4PropList::New(), onClickAction, onCloseAction, onMouseInAction, 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, player, priority, PROPERTY_TUPLE, C4StringTable::RegString(), relBottom, relLeft, relRight, relTop, right, C4PropList::SetProperty(), C4PropList::SetPropertyByS(), Strings, style, symbolDef, symbolGraphicsName, symbolObject, text, C4ScriptGuiWindowProperty::ToC4Value(), ToC4Value(), tooltip, and top.

Referenced by 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:952
#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:

void C4GUI::ScrollWindow::UnFreeze ( )
inlineinherited

Definition at line 970 of file C4Gui.h.

References C4GUI::ScrollWindow::Update().

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

970 { if (!--iFrozen) Update(); }
int32_t iFrozen
Definition: C4Gui.h:946

Here is the call graph for this function:

Here is the caller graph for this function:

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(), C4GUI::ScrollWindow::SetClientHeight(), C4GUI::ScrollWindow::UnFreeze(), 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:

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

Definition at line 1671 of file C4ScriptGuiWindow.cpp.

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

Referenced by UpdateLayout().

1672 {
1673  for (Element * element : *this)
1674  {
1675  C4ScriptGuiWindow *window = static_cast<C4ScriptGuiWindow*>(element);
1676  window->UpdateLayout(cgo, parentWidth, parentHeight);
1677  }
1678  return true;
1679 }
bool UpdateLayout(C4TargetFacet &cgo)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ScriptGuiWindow::UpdateLayout ( C4TargetFacet cgo)

Definition at line 1681 of file C4ScriptGuiWindow.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1747 of file C4ScriptGuiWindow.cpp.

References bottom, bottomMargin, CStdFont::BreakMessage(), C4GUI_ScrollBarWdt, C4GUI::Element::Element(), C4GraphicsResource::FontRegular, StdStrBuf::getData(), C4ScriptGuiWindowProperty::GetFloat(), C4ScriptGuiWindowProperty::GetInt(), C4ScriptGuiWindowProperty::GetStrBuf(), GraphicsResource, GridLayout, C4Rect::Hgt, C4GUI::ScrollWindow::iClientHeight, C4GUI::ScrollWindow::IsScrollingNecessary(), left, leftMargin, NoCrop, C4GUI::ScrollWindow::pScrollBar, C4GUI::Element::rcBounds, relBottom, relBottomMargin, relLeft, relLeftMargin, relRight, relRightMargin, relTop, relTopMargin, right, rightMargin, C4GUI::Element::SetVisibility(), style, text, TightGridLayout, top, topMargin, C4GUI::ScrollBar::Update(), C4GUI::ScrollWindow::Update(), UpdateChildLayout(), UpdateLayoutGrid(), UpdateLayoutTightGrid(), UpdateLayoutVertical(), VerticalLayout, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

1748 {
1749  // fetch style
1750  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
1751  // fetch current position as shortcut for overview
1752  const float &left = props[C4ScriptGuiWindowPropertyName::left].GetFloat();
1753  const float &right = props[C4ScriptGuiWindowPropertyName::right].GetFloat();
1754  const float &top = props[C4ScriptGuiWindowPropertyName::top].GetFloat();
1755  const float &bottom = props[C4ScriptGuiWindowPropertyName::bottom].GetFloat();
1756 
1759  const float &relTop = props[C4ScriptGuiWindowPropertyName::relTop].GetFloat();
1761 
1762  // same for margins
1767 
1772 
1773  // calculate drawing rectangle
1774  float leftDrawX = relLeft * parentWidth + Em2Pix(left) + (Em2Pix(leftMargin) + relLeftMargin * parentWidth);
1775  float rightDrawX = relRight * parentWidth + Em2Pix(right) - (Em2Pix(rightMargin) + relRightMargin * parentWidth);
1776  float topDrawY = relTop * parentHeight + Em2Pix(top) + (Em2Pix(topMargin) + relTopMargin * parentHeight);
1777  float bottomDrawY = relBottom * parentHeight + Em2Pix(bottom) - (Em2Pix(bottomMargin) + relBottomMargin * parentHeight);
1778  float width = rightDrawX - leftDrawX;
1779  float height = bottomDrawY - topDrawY;
1780 
1781  rcBounds.x = leftDrawX;
1782