UTFWin::Window class

Base classes

class ILayoutElement
This class represents an element that is part of a user interfaces.
class IWindow
An interface that represents a component in the user interface.

Derived classes

class InteractiveWindow
class SporeAnimatedIconWin
class WinButton
class WinGrid

Public static variables

static const uint32_t TYPE

Constructors, destructors, conversion operators

Window()
~Window() virtual

Public functions

auto AddRef() -> int override
auto Release() -> int override
auto Cast(uint32_t type) const -> void* override
void SetSerializer(Serializer& dst) override
auto GetProxyID() const -> uint32_t override
Returns the ID that identifies this type of element in a SPUI file.
auto GetParent() const -> IWindow* override
Returns the parent IWindow of this window, or nullptr if it has no parent window.
auto GetWindowManager() const -> IWindowManager* override
Returns the WindowManager that is operating on this window.
auto func6() const -> int override
auto GetControlID() const -> uint32_t override
Sets the unique ID of this object.
auto GetCommandID() const -> uint32_t override
Get the message ID sent by this window.
auto func9() const -> int override
auto GetFlags() const -> WindowFlags override
Gets the current window flags.
auto GetState() const -> int override
Gets the current state (selected, pressed, mouse hover, etc) of this window.
auto GetShadeColor() const -> Math::Color override
Returns the color modulation value.
auto GetArea() const -> const Math::Rectangle& override
Gets the rectangular extent of this window, relative to the window's parent.
auto GetRealArea() const -> const Math::Rectangle& override
Gets the real rectangular extent of this window, in window coordinates.
auto GetCaption() const -> const char16_t* override
Returns the text contents or title of the window.
auto GetTextFontID() const -> uint32_t override
Returns the text font style ID used in this window.
auto func17() const -> const char16_t* override
auto func18() const -> int override
auto func19() const -> int override
void SetControlID(uint32_t controlID) override
Sets the unique ID of this object.
void SetCommandID(uint32_t commandID) override
Set the message ID sent by this window.
void SetState(int state) override
Sets the current state (selected, pressed, mouse hover, etc) of this window.
void SetShadeColor(Color color) override
Returns the color modulation value.
void SetArea(const Math::Rectangle& area) override
Sets the rectangular extent of this window.
void SetLocation(float fX, float fY) override
Sets the location of this window, relative to its parent.
void SetSize(float fWidth, float fHeight) override
Assigns the width and height of this window.
void SetLayoutArea(const Math::Rectangle& layoutArea) override
Sets the area that this component should have, relative to its parent window, after all layout styles are applied.
void SetLayoutLocation(float fX, float fY) override
Assigns the location, relative to the parent window, that this window should have after all layouts are applied.
void SetLayoutSize(float fWidth, float fHeight) override
Assigns the width and height that this window should have after all layouts are applied.
void func30(int) override
void SetFlag(WindowFlags nFlag, bool bValue) override
Assigns the given value to the specified window flag.
void SetCaption(const char16_t* pCaption) override
Assigns the text contents or title of the window.
void SetTextFontID(uint32_t styleID) override
Sets the text font style ID used in this window.
void func34(int) override
void func35(int) override
auto Invalidate() -> int override
void Revalidate() override
Updates the real area of this window and all its children, using the 'area' property and applying all the ILayoutStyle objects (added as IWinProc) in this window.
auto InvalidateTransform() -> int override
auto func39() -> int override
auto func40() -> int override
auto GetFillColor() const -> Color override
Returns the fill color of this window.
auto GetDrawable() const -> IDrawable* override
Returns the fill drawable of this window.
void SetFillColor(Color color) override
Sets the fill color of this window.
void SetDrawable(IDrawable* drawable) override
Sets the fill drawable of this window.
auto func45(int) -> int override
auto func46(int, int) -> int override
auto func47(float, float) -> int override
auto func48(float, float) -> Point override
auto func49(float, float) -> Point override
auto func50(float, float, Point& dst) -> bool override
auto GetChildrenBegin() -> IWindowList_t::iterator override
Returns the begin iterator of the list of children windows contained in this window.
auto GetChildrenEnd() -> IWindowList_t::iterator override
Returns the end iterator of the list of children windows contained in this window.
auto LocateChild(const IWindow* pChild) const -> IWindowList_t::iterator override
Converts a pointer to a child window in the list back to an iterator, or returns end() if it is not part of the children list.
void AddWindow(IWindow* pWindow) override
Adds the given window to this IWindow's children.
void RemoveWindow(IWindow* pWindow) override
Removes the given window from this IWindow's children.
void DisposeWindowFamily(IWindow* pChildWindow) override
Disposes the given window and all its hierarchy.
void DisposeAllWindowFamilies() override
Disposes all the children windows and all their hierarchy.
void BringToFront(IWindow* pWindow) override
Moves the specified child window at the front of the rest of its siblings, so it is the last one to be rendered.
void SendToBack(IWindow* pWindow) override
Moves the specified child window at the back of the rest of its siblings, so it is the first one to be rendered.
auto FindWindowByID(uint32_t controlID, bool bRecursive) -> IWindow* override
Returns the first child window that has the given controlID.
auto FindWindowTypeByID(uint32_t controlID, uint32_t type, bool bRecursive) -> IWindow* override
Returns the first child window that has the given controlID and is of the given type.
auto IsAncestorOf(const IWindow* pChildWindow) -> bool override
Checks if the given window is contained in the component hierarchy of this IWindow.
auto func63(int index) -> bool override
auto func64(int index) -> bool override
void AddWinProc(IWinProc* pWinProc) override
Adds the given IWinProc at the end of this window's list.
void RemoveWinProc(IWinProc* pWinProc) override
Removes the given IWinProc from this window's list.
auto GetNextWinProc(const IWinProc* pWinProc) const -> IWinProc* override
Gets the IWinProc in this window that follows the given procedure.
auto func68(int) -> int override
auto SendMsg(Message& msg) -> bool override
Sends the given message through this window, using this window as the source.
auto GetComponentName() const -> const char* override
Returns the name of this component type (e.g.

Protected types

struct UnkMatrix4
using IWinProcList_t = list<pair<intrusive_ptr<IWinProc>, int>, FixedPoolAllocatorAdapter>

Protected functions

auto Initialize() -> bool virtual
A function that initializes this window.
auto Dispose() -> bool virtual
A function that disposes this window, preparing it to be deleted.
auto DoMessage(const UTFWin::Message& msg) -> bool virtual
A function called every time a message arrives to this window.
auto OnPaint(UIRenderer* pRenderer) -> bool virtual
A method called every time this window needs to be painted.

Protected variables

int field_10
int field_14
int field_18
int field_1C
int field_20
int field_24
int mnRefCount
int mnFlags
bool field_30
int8_t field_31
IWindowManager* mpWindowManager
intrusive_ptr<Window> mpParentWindow
IWindowList_t mChildrenWindows
FixedPoolAllocator mPoolAllocator
IWinProcList_t mWinProcs
int field_74
int field_78
int field_7C
uint32_t mControlID
uint32_t mCommandID
Math::Rectangle mRealArea
Math::Rectangle mArea
int property_EEC1B009
int mnStateFlags
string16 mCaption
uint32_t mTextFontID
UnkMatrix4 field_C4
UnkMatrix4 field_108
UnkMatrix4 field_14C
UnkMatrix4 field_190
int field_1D4
Math::Color mShadeColor
Math::Color mFillColor
intrusive_ptr<IDrawable> mpDrawable
intrusive_ptr<Object> field_1E4
intrusive_ptr<Object> field_1E8
hash_map<int, int> field_1EC

Function documentation

IWindow* UTFWin::Window::GetParent() const override

Returns the parent IWindow of this window, or nullptr if it has no parent window.

Returns A pointer to the IWindow parent of this window, or nullptr if there is none.

IWindowManager* UTFWin::Window::GetWindowManager() const override

Returns the WindowManager that is operating on this window.

Returns A pointer to the WindowManager being used in this window.

uint32_t UTFWin::Window::GetControlID() const override

Sets the unique ID of this object.

Returns The value of the 'controlID' property.

This ID is used to identfy windows, as it is the one used by FindWindowByID(). This ID can also be used on message handling, to check what window raised the message.

uint32_t UTFWin::Window::GetCommandID() const override

Get the message ID sent by this window.

Returns The value of the 'commandID' property.

WindowFlags UTFWin::Window::GetFlags() const override

Gets the current window flags.

Returns The value of the 'flags' property.

This can be used, for example, to check if a window is visible:

IWindow* pWindow = ....;

if (pWindow->GetFlags() & kWinFlagVisible) ...

int UTFWin::Window::GetState() const override

Gets the current state (selected, pressed, mouse hover, etc) of this window.

Returns The value of the 'state' property.

Only certain types use this, like buttons.

Math::Color UTFWin::Window::GetShadeColor() const override

Returns the color modulation value.

Returns The integer color representation of the value of the 'shadeColor' property.

This color acts as a tint: after the window is painted, it gets multiplied by this color.

const Math::Rectangle& UTFWin::Window::GetArea() const override

Gets the rectangular extent of this window, relative to the window's parent.

Returns The area of this window, in screen coordinates.

Note this is the 'area' property, but the real area of the window might be different depending on its parent and the IWinProcs operating in this window.

const Math::Rectangle& UTFWin::Window::GetRealArea() const override

Gets the real rectangular extent of this window, in window coordinates.

Returns The real Math::Rectangle area of this window, in screen coordinates.

This has all the IWinProcs and parent position applied, so this is the real area of the window that gets painted onto the screen.

const char16_t* UTFWin::Window::GetCaption() const override

Returns the text contents or title of the window.

Returns The char16_t* caption used in this window.

This value might be used or not depending on the implementation and type of window.

uint32_t UTFWin::Window::GetTextFontID() const override

Returns the text font style ID used in this window.

Returns The text font ID used in this window.

This value might be used or not depending on the implementation and type of window.

void UTFWin::Window::SetControlID(uint32_t controlID) override

Sets the unique ID of this object.

Parameters
controlID The new value of the 'controlID' property.

This ID is used to identfy windows, as it is the one used by FindWindowByID(). This ID can also be used on message handling, to check what window raised the message.

void UTFWin::Window::SetCommandID(uint32_t commandID) override

Set the message ID sent by this window.

Parameters
commandID The new value of the 'commandID' property.

void UTFWin::Window::SetState(int state) override

Sets the current state (selected, pressed, mouse hover, etc) of this window.

Parameters
state The new value of the 'state' property.

Only certain types use this, like buttons. This will generate a StateChanged message.

void UTFWin::Window::SetShadeColor(Color color) override

Returns the color modulation value.

Parameters
color The color to use as the 'shadeColor' property.

This color acts as a tint: after the window is painted, it gets multiplied by this color.

void UTFWin::Window::SetArea(const Math::Rectangle& area) override

Sets the rectangular extent of this window.

Parameters
area The new value of the 'area' property.

Note that this will only affect the 'area' property of the window; the real area might use these values differently depending on the IWinProc objects operating on this window (e.g. SimpleLayout). Calling this method effectively calls the Revalidate() method, which ensures the real area of the window is updated using the new values.

void UTFWin::Window::SetLocation(float fX, float fY) override

Sets the location of this window, relative to its parent.

Parameters
fX The X coordinate to use in the 'area' property.
fY The Y coordinate to use in the 'area' property.

Note that this will only affect the 'area' property of the window; the real area might use these values differently depending on the IWinProc objects operating on this window (e.g. SimpleLayout). Calling this method effectively calls the Revalidate() method, which ensures the real area of the window is updated using the new values.

void UTFWin::Window::SetSize(float fWidth, float fHeight) override

Assigns the width and height of this window.

Parameters
fWidth The width to use in the 'area' property.
fHeight The height to use in the 'area' property.

Note that this will only affect the 'area' property of the window; the real area might use these values differently depending on the IWinProc objects operating on this window (e.g. SimpleLayout). Calling this method effectively calls the Revalidate() method, which ensures the real area of the window is updated using the new values.

void UTFWin::Window::SetLayoutArea(const Math::Rectangle& layoutArea) override

Sets the area that this component should have, relative to its parent window, after all layout styles are applied.

Parameters
layoutArea The area this window should have.

This will call the ILayoutStyle::RevertLayout() method on all the layout styles in this window, starting with the last one (so the first layout applied will be the last one to be reverted), and then SetArea is called. This ensures that the given layoutArea parameter will be the real area of this window, but relative to the parent.

void UTFWin::Window::SetLayoutLocation(float fX, float fY) override

Assigns the location, relative to the parent window, that this window should have after all layouts are applied.

Parameters
fX The X coordinate, relative to the parent, that this window's location should have.
fY The Y coordinate, relative to the parent, that this window's location should have.

This will call the ILayoutStyle::RevertLayout() method on all the layout styles in this window, starting with the last one (so the first layout applied will be the last one to be reverted), and then SetArea is called. This ensures that the given location parameters will be the real loctions of this window (relative to its parent). Calling this method effectively calls the Revalidate() method, which ensures the real area of the window is updated using the new values.

void UTFWin::Window::SetLayoutSize(float fWidth, float fHeight) override

Assigns the width and height that this window should have after all layouts are applied.

Parameters
fWidth The width this window should have.
fHeight The height this window should have.

This will call the ILayoutStyle::RevertLayout() method on all the layout styles in this window, starting with the last one (so the first layout applied will be the last one to be reverted), and then SetArea is called. This ensures that the given width and height parameters will be the real dimensions of this window. Calling this method effectively calls the Revalidate() method, which ensures the real area of the window is updated using the new values.

void UTFWin::Window::SetFlag(WindowFlags nFlag, bool bValue) override

Assigns the given value to the specified window flag.

Parameters
nFlag The window flag whose value will be changed.
bValue The value that will be assigned to the flag.

This can be used, for example, to toggle visibility:

IWindow* pWindow = ....;

pWindow->SetFlag(kWinFlagVisible, false);  // hide this window

void UTFWin::Window::SetCaption(const char16_t* pCaption) override

Assigns the text contents or title of the window.

Parameters
pCaption The text to be used as caption.

This value might be used or not depending on the implementation and type of window.

void UTFWin::Window::SetTextFontID(uint32_t styleID) override

Sets the text font style ID used in this window.

Parameters
styleID The ID of the text font to use.

This value might be used or not depending on the implementation and type of window. This method will not update the current text font.

Color UTFWin::Window::GetFillColor() const override

Returns the fill color of this window.

Returns The integer color representation of the value of the 'fillColor' property.

The fill color acts as a background color: when rendering the window, the area will be filled with the fill color and then the fill drawable will be drawn on top of it.

IDrawable* UTFWin::Window::GetDrawable() const override

Returns the fill drawable of this window.

Returns The drawable used in this window.

When rendering the window, the area will be filled with the fill color and then the fill drawable will be drawn on top of it.

void UTFWin::Window::SetFillColor(Color color) override

Sets the fill color of this window.

Parameters
color The color to use as the 'fillColor' property.

The fill color acts as a background color: when rendering the window, the area will be filled with the fill color and then the fill drawable will be drawn on top of it.

void UTFWin::Window::SetDrawable(IDrawable* drawable) override

Sets the fill drawable of this window.

When rendering the window, the area will be filled with the fill color and then the fill drawable will be drawn on top of it.

IWindowList_t::iterator UTFWin::Window::GetChildrenBegin() override

Returns the begin iterator of the list of children windows contained in this window.

Pair it with GetChildrenEnd() to iterate through the children. Children windows are listed according to their Z-index; that is, the first children is the one on front, and the last children is the one on the bottom.

IWindowList_t::iterator UTFWin::Window::GetChildrenEnd() override

Returns the end iterator of the list of children windows contained in this window.

Pair it with GetChildrenBegin() to iterate through the children. Children windows are listed according to their Z-index; that is, the first children is the one on front, and the last children is the one on the bottom.

IWindowList_t::iterator UTFWin::Window::LocateChild(const IWindow* pChild) const override

Converts a pointer to a child window in the list back to an iterator, or returns end() if it is not part of the children list.

Parameters
pChild The IWindow whose next sibling will be returned.
Returns The iterator to the next sibling of pChild.

This can be used to check if a window is a direct child of this window, using "LocateChild(pChild) != GetChildrenEnd()

void UTFWin::Window::AddWindow(IWindow* pWindow) override

Adds the given window to this IWindow's children.

Parameters
pWindow The window to add to this object's children.

The window will be added last, so it will have the lowest Z-index. The parent of pWindow will be set to this object.

void UTFWin::Window::RemoveWindow(IWindow* pWindow) override

Removes the given window from this IWindow's children.

Parameters
pWindow The window to remove from this object's children.

pWindow will be removed from its parent hierarchy even if its parent is not this object. The parent of pWindow will be set to nullptr.

void UTFWin::Window::DisposeWindowFamily(IWindow* pChildWindow) override

Disposes the given window and all its hierarchy.

Parameters
pChildWindow The IWindow to dispose.

If pChildWindow is a child of this window, it will be removed from it. The pChildWindow hierarchy will be disposed even if it is not a child of this window.

void UTFWin::Window::DisposeAllWindowFamilies() override

Disposes all the children windows and all their hierarchy.

After this method is called, this window will not have any children.

void UTFWin::Window::BringToFront(IWindow* pWindow) override

Moves the specified child window at the front of the rest of its siblings, so it is the last one to be rendered.

Parameters
pWindow The child window to bring to the front.

This is the equivalent to setting the Z-index to the highest. Note that the window will remain behind of windows with the flag kWinFlagAlwaysInFront set to true.

void UTFWin::Window::SendToBack(IWindow* pWindow) override

Moves the specified child window at the back of the rest of its siblings, so it is the first one to be rendered.

Parameters
pWindow The child window to send to the back.

This is the equivalent to setting the Z-index to the lowest. Note that the window will remain behind of windows with the flag kWinFlagAlwaysInFront set to true.

IWindow* UTFWin::Window::FindWindowByID(uint32_t controlID, bool bRecursive) override

Returns the first child window that has the given controlID.

Parameters
controlID The controlID of the window to find.
bRecursive Whether the children hierarchy should be checked as well, true by default.
Returns The first window in the hierarchy that has the given controlID, or nullptr if there is no match.

By default, this also checks on the children' children, so the controlID is searched in all the window hierarchy.

IWindow* UTFWin::Window::FindWindowTypeByID(uint32_t controlID, uint32_t type, bool bRecursive) override

Returns the first child window that has the given controlID and is of the given type.

Parameters
controlID The controlID of the window to find.
type The type of the window to find. It will be used calling Cast(type) on the match.
bRecursive Whether the children hierarchy should be checked as well, true by default.
Returns The first window in the hierarchy that has the given controlID and type, or nullptr if there is no match.

The type is something like WinButton::TYPE, so it is safe to assume that the returned type will be a WinButton in this case. If a window with the given controlID is found but calling Cast(type) on it returns nullptr, nullptr will be returned (so it will stop searching). By default, this also checks on the children' children, so the controlID is searched in all the window hierarchy.

bool UTFWin::Window::IsAncestorOf(const IWindow* pChildWindow) override

Checks if the given window is contained in the component hierarchy of this IWindow.

Parameters
pChildWindow The child window to check.
Returns True if pChildWindow is contained in the hierarchy of this window, false otherwise.

All the hierarchy will be checked, so the function can return true even if this window is not a direct parent of pChildWindow.

void UTFWin::Window::AddWinProc(IWinProc* pWinProc) override

Adds the given IWinProc at the end of this window's list.

Parameters
pWinProc The IWinProc to add.

IWinProcs are called when a message is received in the window. Also some of them might be called on layout-related methods. Some IWinProcs can also act as effects.

void UTFWin::Window::RemoveWinProc(IWinProc* pWinProc) override

Removes the given IWinProc from this window's list.

Parameters
pWinProc The IWinProc to remove from this window.

IWinProcs are called when a message is received in the window. Also some of them might be called on layout-related methods. Some IWinProcs can also act as effects.

IWinProc* UTFWin::Window::GetNextWinProc(const IWinProc* pWinProc) const override

Gets the IWinProc in this window that follows the given procedure.

Parameters
pWinProc The IWinProc that comes after this one will be returned. nullptr to return the first one.
Returns The next IWinProc, or nullptr if there's none.

If pWinProc is not included in this window, nullptr will be returned. If pWinProc is nullptr, the first IWinProc in this window will be returned.

bool UTFWin::Window::SendMsg(Message& msg) override

Sends the given message through this window, using this window as the source.

Parameters
msg The message.
Returns True if the message was handled successfully.

const char* UTFWin::Window::GetComponentName() const override

Returns the name of this component type (e.g.

"Window", "WinButton").

bool UTFWin::Window::Initialize() virtual protected

A function that initializes this window.

It is not always called so you should not rely on it.

bool UTFWin::Window::Dispose() virtual protected

A function that disposes this window, preparing it to be deleted.

This method is called on the destructor, but it can be called before the window gets destructed as well.

bool UTFWin::Window::OnPaint(UIRenderer* pRenderer) virtual protected

A method called every time this window needs to be painted.

This does not paint the children windows.