Window
Native window.
| Header | #include "nativeui/window.h" |
| Namespace | namespace nu |
| Type | class (RefCounted) |
| Inherits | Responder |
Constructors
Window(const Window::Options& options)
Create a new window with options.
Parameters
const Window::Options&options
Class properties
const char* kClassName
The class name of window.
Methods
void Close()
Request to close the window.
bool HasFrame() const
Return whether window has a native frame.
Return
boolbool IsTransparent() const
Return whether window is transparent.
Return
boolvoid SetHasShadow(bool has)
Set whether window should have shadow.
Depending on platform, this may not work.
Parameters
boolhas
bool HasShadow() const
Return whether window has shadow.
Return
boolvoid SetContentView(scoped_refptr<View> view)
Set the content view of the window.
The content view will always be resized to fill window's client area.
Parameters
scoped_refptr<View>view
View* GetContentView() const
Return the content view of the window.
Return
View*void Center()
Move the window to the center of the screen.
void SetContentSize(const SizeF& size)
Resize window to make the content view fit size.
Parameters
const SizeF&size
SizeF GetContentSize() const
Return the size of content view.
Return
SizeFvoid SetBounds(const RectF& bounds)
Change the position and size of the window.
Parameters
const RectF&bounds
RectF GetBounds() const
Return the position and size of the window.
Return
RectFvoid SetSizeConstraints(const SizeF& minsize, const SizeF& maxsize)
Set the minimum and maximum sizes of the window.
Passing an empty size means no constraint.
Parameters
const SizeF&minsize - Minimum size.const SizeF&maxsize - Maximum size.
std::tuple<SizeF, SizeF> GetSizeConstraints() const
Return minimum and maximum sizes of the window.
Return
std::tuple<SizeF, SizeF>void SetContentSizeConstraints(const SizeF& minsize, const SizeF& maxsize)
Set the minimum and maximum content sizes of the window.
Passing an empty size means no constraint.
Parameters
const SizeF&minsize - Minimum content size.const SizeF&maxsize - Maximum content size.
std::tuple<SizeF, SizeF> GetContentSizeConstraints() const
Return minimum and maximum content sizes of the window.
Return
std::tuple<SizeF, SizeF>void Activate()
Show the window and activate it.
void Deactivate()
Move the focus away from the window.
bool IsActive() const
Return whether window has focus.
Return
boolvoid SetVisible(bool visible)
Show/hide the window.
Parameters
boolvisible
bool IsVisible() const
Return whether window is visible.
Return
boolvoid SetAlwaysOnTop(bool top)
Make the window always show above other normal windows.
Parameters
booltop
bool IsAlwaysOnTop() const
Return whether window is always above other normal windows.
Return
boolvoid SetFullscreen(bool fullscreen)
Enter/leave fullscreen state.
Parameters
boolfullscreen
bool IsFullscreen() const
Return whether window is in fullscreen.
Return
boolvoid Maximize()
Maximize the window.
void Unmaximize()
Unmaximize the window.
bool IsMaximized() const
Return whether window is maximized.
Return
boolvoid Minimize()
Minimize the window.
void Restore()
Restore the minimized window.
bool IsMinimized() const
Return whether window is minimized.
Return
boolvoid SetResizable(bool resizable)
Set whether window can be resized.
Parameters
boolresizable
bool IsResizable() const
Return whether window can be resized.
Return
boolvoid SetMaximizable(bool maximizable)
Set whether window can be maximize.
Parameters
boolmaximizable
bool IsMaximizable() const
Return whether window can be maximize.
Return
boolvoid SetMinimizable(bool minimizable)
Set whether window can be minimized.
Parameters
boolminimizable
bool IsMinimizable() const
Return whether window can be minimized.
Return
boolvoid SetMovable(bool movable)
Set whether window can be moved.
Parameters
boolmovable
bool IsMovable() const
Return whether window can be moved.
Return
boolvoid SetTitle(const std::string& title)
Set window title.
Parameters
const std::string&title
std::string GetTitle() const
Get window title.
Return
std::stringvoid SetBackgroundColor(Color color)
Set the background color of the window.
Parameters
Colorcolor
void SetToolbar(scoped_refptr<Toolbar> toolbar) macOS
Set the window toolbar.
Parameters
scoped_refptr<Toolbar>toolbar
Toolbar* GetToolbar() const macOS
Return the window toolbar.
Return
Toolbar*void SetTitleVisible(bool visible) macOS
Set whether the title is visible, when title was hidden the toolber would be moved into the area previously occupied by the title.
Parameters
boolvisible
bool IsTitleVisible() const; macOS
Return whether title is visible.
Return
boolvoid SetFullSizeContentView(bool full) macOS
Set the NSFullSizeContentViewWindowMask style on the window.
Parameters
boolfull
bool IsFullSizeContentView() const macOS
Return whether the window has NSFullSizeContentViewWindowMask style.
Return
boolvoid SetSkipTaskbar(bool skip) Windows Linux
Set whether to hide the window from taskbar.
Parameters
boolskip
void SetIcon(scoped_refptr<Image> icon) Windows Linux
Set the window icon.
Parameters
scoped_refptr<Image>icon
void SetMenuBar(scoped_refptr<MenuBar> menubar) Windows Linux
Set the window menu bar.
Parameters
scoped_refptr<MenuBar>menubar
MenuBar* GetMenuBar() const Windows Linux
Return the window menu bar.
Return
MenuBar*Window* GetParentWindow() const
Return the parent window.
Return
Window*void AddChildWindow(scoped_refptr<Window> child)
Make child a child window of this window.
This method will do nothing if child already has a parent window.
Parameters
scoped_refptr<Window>child
void RemoveChildWindow(Window* child)
Remove this window as child's parent window.
Parameters
Window*child
std::vector<Window*> GetChildWindows() const
Return all the child windows of this window.
Return
std::vector<Window*>Events
void on_close(Window* self)
Emitted when the window is closed.
Parameters
Window*self
Preventable
No.void on_focus(Window* self)
Emitted when the window is focused.
Parameters
Window*self
Preventable
No.void on_blur(Window* self)
Emitted when the window lost focus.
Parameters
Window*self
Preventable
No.Delegates
bool should_close(Window* self)
Called when user requests to close the window, should return whether the window can be closed.
Parameters
Window*self
Return
bool