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 ()
 
virtual ~C4ScriptGuiWindow ()
 
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 ()
 
virtual void Draw (C4TargetFacet &cgo)
 
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)
 
virtual void MouseEnter (C4GUI::CMouse &rMouse)
 
virtual void MouseLeave (C4GUI::CMouse &rMouse)
 
void OnMouseOut (int32_t player)
 
void OnMouseIn (int32_t player, int32_t parentOffsetX, int32_t parentOffsetY)
 
bool HasMouseFocus ()
 
bool IsVisibleTo (int32_t player)
 
virtual void MouseInput (CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual bool IsComponentOutsideClientArea ()
 
void Update ()
 
virtual void UpdateOwnPos ()
 
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)
 
virtual C4RectGetClientRect ()
 
virtual void ApplyElementOffset (int32_t &riX, int32_t &riY)
 
virtual void ApplyInvElementOffset (int32_t &riX, int32_t &riY)
 
virtual int32_t GetMarginTop ()
 
virtual int32_t GetMarginLeft ()
 
virtual int32_t GetMarginRight ()
 
virtual int32_t GetMarginBottom ()
 
void Clear ()
 
void ClearChildren ()
 
virtual void RemoveElement (Element *pChild)
 
void MakeLastElement (Element *pChild)
 
void AddElement (Element *pChild)
 
void ReaddElement (Element *pChild)
 
void InsertElement (Element *pChild, Element *pInsertBefore)
 
ElementGetNextNestedElement (Element *pPrevElement, bool fBackwards)
 
virtual ElementGetFirstContained ()
 
virtual ElementGetLastContained ()
 
virtual ElementGetFirstNestedElement (bool fBackwards)
 
Iterator begin ()
 
Iterator end ()
 
ReverseIterator rbegin ()
 
ReverseIterator rend ()
 
ElementGetFirst ()
 
ElementGetLast ()
 
virtual ContainerGetContainer ()
 
ElementGetElementByIndex (int32_t i)
 
int32_t GetElementCount ()
 
virtual void SetVisibility (bool fToValue)
 
virtual bool IsFocused (Control *pCtrl)
 
virtual bool IsSelectedChild (Element *pChild)
 
virtual bool IsParentOf (Element *pEl)
 
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
 

Static Public Attributes

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

Protected Member Functions

virtual void ElementSizeChanged (Element *pOfElement)
 
virtual void ElementPosChanged (Element *pOfElement)
 
virtual void AfterElementRemoval ()
 
virtual bool OnHotkey (uint32_t cHotkey)
 
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
 
ElementpPrev
 
ElementpNext
 
WindowpDragTarget
 
int32_t iDragX
 
int32_t iDragY
 
bool fDragging
 
ContextHandler * pContextHandler
 
C4Rect rcBounds
 

Friends

class C4ScriptGuiWindowAction
 
class C4ScriptGuiWindowScrollBar
 

Detailed Description

Definition at line 176 of file C4ScriptGuiWindow.h.

Member Enumeration Documentation

Enumerator
None 
Focus 
MouseDown 

Definition at line 330 of file C4ScriptGuiWindow.h.

Constructor & Destructor Documentation

C4ScriptGuiWindow::C4ScriptGuiWindow ( )

Definition at line 627 of file C4ScriptGuiWindow.cpp.

Referenced by AddChild(), and CreateFromPropList().

627  : C4GUI::ScrollWindow(this)
628 {
629  Init();
630 }

Here is the caller graph for this function:

C4ScriptGuiWindow::~C4ScriptGuiWindow ( )
virtual

Definition at line 691 of file C4ScriptGuiWindow.cpp.

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

692 {
693  ClearChildren(false);
694 
695  // delete certain properties that contain allocated elements or referenced strings
696  for (int32_t i = 0; i < C4ScriptGuiWindowPropertyName::_lastProp; ++i)
697  props[i].CleanUpAll();
698 
699  if (pScrollBar)
700  delete pScrollBar;
701  if (name)
702  name->DecRef();
703 }
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 1193 of file C4ScriptGuiWindow.cpp.

1194 {
1195  if (IsRoot())
1196  {
1197  child->SetID(GenerateMenuID());
1198  child->isMainWindow = true;
1199  // update all windows asap
1200  mainWindowNeedsLayoutUpdate = true;
1201  }
1202 
1203  // child's priority is ususally 0 here, so just insert it in front of other windows with a priority below 0
1204  // when the child's priority updates, the update function will be called and the child will be sorted to the correct position
1205  ChildChangedPriority(child);
1206 
1207  return child;
1208 }
C4ScriptGuiWindow* C4ScriptGuiWindow::AddChild ( )
inline

Definition at line 277 of file C4ScriptGuiWindow.h.

References AddChild(), and C4ScriptGuiWindow().

Referenced by AddChild(), and CreateFromPropList().

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

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

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:32
int32_t x
Definition: C4Rect.h:32

Here is the caller graph for this function:

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

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:32
int32_t x
Definition: C4Rect.h:32

Here is the caller graph for this function:

Iterator C4GUI::Container::begin ( )
inlineinherited

Definition at line 824 of file C4Gui.h.

Referenced by ClearPointers(), and DrawChildren().

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 1386 of file C4ScriptGuiWindow.cpp.

References C4ScriptGuiWindowProperty::GetFloat().

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

1387 {
1388  const float widthOrHeight = Em2Pix(props[absoluteProperty].GetFloat())
1389  + float(parentWidthOrHeight) * props[relativeProperty].GetFloat();
1390  return widthOrHeight;
1391 }

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 1328 of file C4ScriptGuiWindow.cpp.

References RemoveChild().

1329 {
1330  RemoveChild(0, close, true);
1331 }
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 1165 of file C4ScriptGuiWindow.cpp.

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

Referenced by ClearPointers().

1166 {
1167  // not removing or clearing anything twice
1168  // if this flag is set, the object will not be used after this frame (callbacks?) anyway
1169  if (wasRemoved) return;
1170 
1171  if (target == pObj)
1172  {
1173  Close();
1174  return;
1175  }
1176 
1177  // all properties which have anything to do with objects need to be called from here!
1183 
1184  for (auto iter = begin(); iter != end();)
1185  {
1186  C4ScriptGuiWindow *child = static_cast<C4ScriptGuiWindow*>(*iter);
1187  // increment the iterator before (possibly) deleting the child
1188  ++iter;
1189  child->ClearPointers(pObj);
1190  }
1191 }
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 232 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().

233  {
234  // apply all parent offsets
235  Container *pCont = pParent;
236  while (pCont)
237  {
238  pCont->ApplyInvElementOffset(riX, riY);
239  pCont = pCont->GetParent();
240  }
241  // apply own offset
242  riX += rcBounds.x; riY += rcBounds.y;
243  }
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
Container * pParent
Definition: C4Gui.h:376
int32_t x
Definition: C4Rect.h:32
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 1333 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().

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

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

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

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

Here is the call graph for this function:

bool C4GUI::Element::DoContext ( )
inherited

Definition at line 418 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().

419  {
420  if (!pContextHandler) return false;
421  return pContextHandler->OnContext(this, rcBounds.Wdt/2, rcBounds.Hgt/2);
422  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
int32_t Wdt
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
virtual bool OnContext(Element *pOnElement, int32_t iX, int32_t iY)=0
int32_t Hgt
Definition: C4Rect.h:32

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4ScriptGuiWindow::Draw ( C4TargetFacet cgo)
inlinevirtual

Reimplemented from C4GUI::Window.

Definition at line 299 of file C4ScriptGuiWindow.h.

Referenced by DrawChildren().

299 {}

Here is the caller graph for this function:

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

Definition at line 1890 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.

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

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

293  {
294  DWORD dwAlpha = byAlpha<<24;
295  int32_t x0 = cgo.TargetX + rcBounds.x + iLeftOff,
296  y0 = cgo.TargetY + rcBounds.y + iTopOff,
297  x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1,
298  y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1;
299  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x1,(float)y0, C4GUI_BorderColor1 | dwAlpha);
300  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x0,(float)y1, C4GUI_BorderColor1 | dwAlpha);
301  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x1-1),(float)(y0+1), C4GUI_BorderColor2 | dwAlpha);
302  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x0+1),(float)(y1-1), C4GUI_BorderColor2 | dwAlpha);
303  pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y1,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
304  pDraw->DrawLineDw(cgo.Surface, (float)x1,(float)y0,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
305  pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y1-1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
306  pDraw->DrawLineDw(cgo.Surface, (float)(x1-1),(float)(y0+1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
307  }
#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:617
int32_t Wdt
Definition: C4Rect.h:32
#define C4GUI_BorderColor1
Definition: C4Gui.h:85
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
C4Draw * pDraw
Definition: C4Draw.cpp:45
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
#define C4GUI_BorderColor3
Definition: C4Gui.h:87
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167
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 1868 of file C4ScriptGuiWindow.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 309 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().

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

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 1558 of file C4ScriptGuiWindow.cpp.

References C4GUI::Container::begin(), Draw(), C4GUI::ScrollBar::DrawElement(), C4GUI::Container::end(), 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().

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

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

367  {
368  C4DrawTransform trf;
369  float fOffX = cgo.TargetX + rcBounds.x + rcBounds.Hgt/2;
370  float fOffY = cgo.TargetY + rcBounds.y + rcBounds.Hgt/2;
371  trf.SetRotate(-90.0f, fOffX, fOffY);
372 
373  DrawHVBar(cgo, rFacets, trf, rcBounds.Wdt);
374  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:376
int32_t Wdt
Definition: C4Rect.h:32
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
void SetRotate(float iAngle, float fOffX, float fOffY)
int32_t Hgt
Definition: C4Rect.h:32
float TargetY
Definition: C4Facet.h:167

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

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

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 360 of file C4Gui.cpp.

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

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

361  {
362  C4DrawTransform trf(1);
363  DrawHVBar(cgo, rFacets, trf, rcBounds.Hgt);
364  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:376
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4GUI::ScrollWindow::ElementPosChanged ( Element pOfElement)
inlineprotectedvirtualinherited

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:

virtual void C4GUI::ScrollWindow::ElementSizeChanged ( Element pOfElement)
inlineprotectedvirtualinherited

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(), and DrawChildren().

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 2281 of file C4ScriptGuiWindow.cpp.

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

Referenced by ExecuteCommand().

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

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 1255 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::Element().

1256 {
1257  for (Element * element : *this)
1258  {
1259  C4ScriptGuiWindow * child = static_cast<C4ScriptGuiWindow*>(element);
1260  if (child->id != childID) continue;
1261  return child;
1262  }
1263  return nullptr;
1264 }

Here is the call graph for this function:

C4ScriptGuiWindow * C4ScriptGuiWindow::GetChildByName ( C4String childName)

Definition at line 1266 of file C4ScriptGuiWindow.cpp.

References C4GUI::Element::Element().

Referenced by CreateFromPropList().

1267 {
1268  // invalid child names never match
1269  if (childName == nullptr) return nullptr;
1270 
1271  for (Element * element : *this)
1272  {
1273  C4ScriptGuiWindow * child = static_cast<C4ScriptGuiWindow*>(element);
1274  // every C4String is unique, so we can compare pointers here
1275  if (child->name != childName) continue;
1276  return child;
1277  }
1278  return nullptr;
1279 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual C4Rect& C4GUI::Window::GetClientRect ( )
inlinevirtualinherited

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

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

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:29
int32_t y
Definition: C4Rect.h:32
int32_t x
Definition: C4Rect.h:32
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:447

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Container* C4GUI::Container::GetContainer ( )
inlinevirtualinherited

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

431  {
432  // fallback to parent context, if own is not assigned
434  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
virtual ContextHandler * GetContextHandler()
Definition: C4Gui.cpp:430
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 289 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().

289 { if (pParent) return pParent->GetDlg (); return nullptr; }
Container * pParent
Definition: C4Gui.h:376
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:289

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:

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

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)
virtualinherited

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

Here is the caller graph for this function:

int32_t C4ScriptGuiWindow::GetID ( )
inline

Definition at line 253 of file C4ScriptGuiWindow.h.

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

253 { 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  }
virtual Element * GetFirstNestedElement(bool fBackwards)

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

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

290 { if (pParent) return pParent->GetScreen(); return nullptr; }
Container * pParent
Definition: C4Gui.h:376
virtual Screen * GetScreen()
Definition: C4Gui.cpp:290

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 1281 of file C4ScriptGuiWindow.cpp.

Referenced by C4ScriptGuiWindowAction::Execute().

1282 {
1283  std::pair<std::multimap<int32_t, C4ScriptGuiWindow*>::iterator, std::multimap<int32_t, C4ScriptGuiWindow*>::iterator> range;
1284  range = childrenIDMap.equal_range(childID);
1285 
1286  for (std::multimap<int32_t, C4ScriptGuiWindow*>::iterator iter = range.first; iter != range.second; ++iter)
1287  {
1288  C4ScriptGuiWindow *subwindow = iter->second;
1289  if (subwindow->GetTarget() != childTarget) continue;
1290  return subwindow;
1291  }
1292  return 0;
1293 }

Here is the caller graph for this function:

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

Definition at line 424 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().

425  {
426  // fallback to parent tooltip, if own is not assigned
427  return (!pParent || !ToolTip.isNull()) ? ToolTip.getData() : pParent->GetToolTip();
428  }
const char * getData() const
Definition: StdBuf.h:450
const char * GetToolTip()
Definition: C4Gui.cpp:424
Container * pParent
Definition: C4Gui.h:376
bool isNull() const
Definition: StdBuf.h:449

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

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

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:32
C4Rect rcBounds
Definition: C4Gui.h:385

Here is the caller graph for this function:

bool C4ScriptGuiWindow::HasMouseFocus ( )
inline

Definition at line 342 of file C4ScriptGuiWindow.h.

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

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

virtual bool C4GUI::ScrollWindow::IsComponentOutsideClientArea ( )
inlinevirtualinherited

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

437  {
438  // get dlg
439  Dialog *pDlg=GetDlg();
440  if (!pDlg) return false;
441  // check if dlg is active
442  return pDlg->IsActive(fForKeyboard);
443  }
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:289

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)
virtualinherited

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

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

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

203  {
204  // self and parent must be visible
205  return fVisible && (!pParent || pParent->IsVisible());
206  }
bool IsVisible()
Definition: C4Gui.cpp:202
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 2355 of file C4ScriptGuiWindow.cpp.

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

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

2356 {
2357  // Not visible at all?
2358  if (!IsVisible()) return false;
2359  // We have a player assigned and it's a different one?
2360  const int32_t &myPlayer = props[C4ScriptGuiWindowPropertyName::player].GetInt();
2361  if (myPlayer != ANY_OWNER && player != myPlayer) return false;
2362  // We have a target object which is invisible to the player?
2363  if (target && !target->IsVisible(player, false)) return false;
2364  // Default to visible!
2365  return true;
2366 }
bool IsVisible()
Definition: C4Gui.cpp:202
const int ANY_OWNER
Definition: C4Constants.h:139
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
Definition: C4Object.cpp:4062

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)
virtual

Reimplemented from C4GUI::Element.

Definition at line 2040 of file C4ScriptGuiWindow.cpp.

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

2041 {
2042  assert(::MouseControl.GetPlayer() != NO_OWNER);
2043 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t GetPlayer()
const int NO_OWNER
Definition: C4Constants.h:138

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 2100 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.

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

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 
)
virtualinherited

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  }
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
void ScrollBy(int iAmount)
const int32_t C4MC_Button_Wheel

Here is the call graph for this function:

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

Reimplemented from C4GUI::Element.

Definition at line 2075 of file C4ScriptGuiWindow.cpp.

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

2076 {
2077  assert(::MouseControl.GetPlayer() != NO_OWNER);
2078 
2079 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
int32_t GetPlayer()
const int NO_OWNER
Definition: C4Constants.h:138

Here is the call graph for this function:

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

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:202
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 2045 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().

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

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 2080 of file C4ScriptGuiWindow.cpp.

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

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

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

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

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 1295 of file C4ScriptGuiWindow.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

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:174
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 1649 of file C4ScriptGuiWindow.cpp.

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

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

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

220  {
221  // apply all parent offsets
222  Container *pCont = pParent;
223  while (pCont)
224  {
225  pCont->ApplyElementOffset(riX, riY);
226  pCont = pCont->GetParent();
227  }
228  // apply own offset
229  riX -= rcBounds.x; riY -= rcBounds.y;
230  }
int32_t y
Definition: C4Rect.h:32
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:32
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  }
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:864
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:32

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

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  }
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:864
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:32

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  }
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:864
int32_t iScrollY
Definition: C4Gui.h:943
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Hgt
Definition: C4Rect.h:32

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:186
C4Rect rcBounds
Definition: C4Gui.h:385
virtual void UpdatePos()
Definition: C4Gui.cpp:194

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

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 273 of file C4ScriptGuiWindow.h.

273 { 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:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
virtual void UpdatePos()
Definition: C4Gui.cpp:194

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

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:208
ScrollBar * pScrollBar
Definition: C4Gui.h:942
virtual void UpdateOwnPos()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ScriptGuiWindow::SetTag ( C4String tag)

Definition at line 2024 of file C4ScriptGuiWindow.cpp.

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

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

2025 {
2026  // set tag on all properties
2027  for (uint32_t i = 0; i < C4ScriptGuiWindowPropertyName::_lastProp; ++i)
2028  if (props[i].SwitchTag(tag))
2029  {
2030  // only if tag could have changed position etc.
2033  }
2034 
2035  // .. and children
2036  for (C4GUI::Element * element : *this)
2037  (static_cast<C4ScriptGuiWindow*>(element))->SetTag(tag);
2038 }

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

411  {
412  // store tooltip
413  if (szNewTooltip) ToolTip.Copy(szNewTooltip); else ToolTip.Clear();
414  // store immediate flag
415  is_immediate_tooltip = is_immediate;
416  }
void Clear()
Definition: StdBuf.h:474
void Copy()
Definition: StdBuf.h:475

Here is the call graph for this function:

Here is the caller graph for this function:

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

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  }
virtual void SetVisibility(bool fToValue)
Definition: C4Gui.cpp:208
C4GameControl Control
virtual class Dialog * GetDlg()
Definition: C4Gui.cpp:289
virtual bool IsParentOf(Element *pEl)

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

261  {
262  // set flag
263  fDragging = true;
264  // set drag start pos
265  iDragX = iX; iDragY = iY;
266  // mark drag in mouse
267  rMouse.pDragElement = this;
268  }
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 283 of file C4Gui.cpp.

References C4GUI::Element::DoDragging().

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

284  {
285  // move element pos
286  DoDragging(rMouse, iX, iY, dwKeyParam);
287  }
virtual void DoDragging(CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
Definition: C4Gui.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

const C4Value C4ScriptGuiWindow::ToC4Value ( )

Definition at line 889 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().

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

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:32
int32_t y
Definition: C4Rect.h:32
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:32
int32_t iFrozen
Definition: C4Gui.h:946
int32_t Hgt
Definition: C4Rect.h:32

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 1676 of file C4ScriptGuiWindow.cpp.

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

Referenced by UpdateLayout().

1677 {
1678  for (Element * element : *this)
1679  {
1680  C4ScriptGuiWindow *window = static_cast<C4ScriptGuiWindow*>(element);
1681  window->UpdateLayout(cgo, parentWidth, parentHeight);
1682  }
1683  return true;
1684 }
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 1686 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().

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

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 1752 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.

1753 {
1754  // fetch style
1755  const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
1756  // fetch current position as shortcut for overview
1757  const float &left = props[C4ScriptGuiWindowPropertyName::left].GetFloat();
1758  const float &right = props[C4ScriptGuiWindowPropertyName::right].GetFloat();
1759  const float &top = props[C4ScriptGuiWindowPropertyName::top].GetFloat();
1760  const float &bottom = props[C4ScriptGuiWindowPropertyName::bottom].GetFloat();
1761 
1764  const float &relTop = props[C4ScriptGuiWindowPropertyName::relTop].GetFloat();
1766 
1767  // same for margins
1772 
1775  const float &relTopMargin = props[