# ZWindowFacet

Widgets that act like a type of window should return a implementation of `ZWindowFacet` from `QObject *Tui::ZWidget::facet(const QMetaObject &metaObject) const` when queried for this facet. This enables additional window behavior.

The window facet also is the interface to place a window into a `Tui::ZWindowContainer` which allows the container to take control over the placement of the window and to add items to the window’s system menu.

## ZWindowFacet

class Tui::ZWindowFacet : public QObject

  A facet for window related information and behavior.

  bool isExtendViewport() const

    If this function returns true and the window does not fit into the terminal size, the viewport mode of `Tui::ZTerminal` will be enabled to allow scrolling to view all parts of the window.

    The base class always returns false.

  bool isManuallyPlaced() const

    If this function returns true, the window will be considered as manually placed and automatic placement will be disabled.

    The base class always returns the last value passed to `void setManuallyPlaced(bool manual)` or true if that function was not called yet.

  void autoPlace(const QSize &available, ZWidget *self)

    For implementations of this facet that support this method and when automatic placement is enabled, it will apply automatic placement to the window which must be passed as `self` using `available` as the full size of the container.

    The base class will center the window in `available`.

  Tui::ZWindowContainer *container() const

    Return the current window container of the window associated with this facet instance.

    The base class always returns the last value passed to `void setContainer(ZWindowContainer *container)` or nullptr if that function was not called yet.

  void setContainer(ZWindowContainer *container)

    Set the current window container of the window associated with this facet instance.

    The base class saves the passed `container` and returns it when `Tui::ZWindowContainer *Tui::ZWindowFacet::container() const` is called.

  void setManuallyPlaced(bool manual)

    For implementations of this facet that support this method, it will set the value returned by `bool isManuallyPlaced() const`. Otherwise calls to this function might be ignored.

    The base class save the passed `manual` and returns it when `bool isManuallyPlaced() const` is called.