class TopWindow : public Ctrl
TopWindow represents top-level independent window of host OS, usually decorated with caption, close/zoom/restore buttons etc.
Important fact to note is that window-rectangle (as defined by Ctrl::SetRect and Ctrl::GetRect methods) does not include any host GUI specific decorations (caption, thick border for resizing), just the area that is "controlled" by U++.
When TopWindow is opened, it is by default centered w.r.t. to its owner (if there is any). This behaviour can be altered by NoCenter or CenterScreen methods.
Derived from Ctrl
virtual void Reject()
This virtual method is overloaded to perform Restore operation if there was any previous call to Backup method.
virtual void Close()
This virtual method is implemented in TopWindow so that it breaks modal loop if TopWindow runs it. If there is Breaker with IDCANCEL defined, performs RejectBreak(IDCANCEL). Otherwise, if there is Breaker with IDYES (as assigned to exit Ctrl by CtrlLayoutExit), performs AcceptBreak(IDYES). If none if that is true, AcceptBreak(IDOK) is performed.
If TopWindow does not run modal loop, it is closed - in this case, any state backup created by Backup method is scratched. Override in descendant class is allowed to call 'delete this' as the very last thing it does (as long as the instance is allocated on the heap).
Event<> WhenClose
This callback is by default invoked when Close button of host GUI window is pushed. Default assigned action is to perform Close virtual method. Assigned event is allowed to call 'delete this' as the very last thing it does (as long as the instance is allocated on the heap).
void Backup()
Serializes the content of all contained Ctrls (using Serialize virtual method) into internal storage of TopWindow. Useful when implementing Cancel buttons.
void Restore()
Restores content of all contained Ctrls from internal storage. If internal storage is empty, does nothing.
void Break(int ID = IDEXIT)
If TopWindow is running its loop (see Run or RunAppModal methods), breaks the loop with specified exit code.
bool AcceptBreak(int ID)
Tries to accept all contained Ctrls by calling Accept for all child Ctrls, until some returns false - in such case this method returns false. If all child Ctrls return true, calls Break with specified ID and returns true.
|
Return value |
True if all child Ctrls were accepted and Break(ID) was invoked. |
void RejectBreak(int ID)
Rejects all contained widgets by calling Reject for all child Ctrls, then calls Break with specified ID.
void WorkAreaTrim()
Adjusts window position so that it does not exceeds desktop workspace. Exceeding parts are trimmed (decreasing window size).
Callback Breaker(int ID = IDEXIT)
Returns Callback that, when invoked, invokes Break with the specified exit code. Note that Callback as return value is used for backward compatibility with pre-C++11 U++ and for practical purposes, you could consider Event<> being returned.
|
ID |
Message loop exit code. |
Callback Acceptor(int ID)
Returns Callback that, when invoked, invokes AcceptBreak with the specified exit code. Note that Callback as return value is used for backward compatibility with pre-C++11 U++ and for practical purposes, you could consider Event<> being returned.
|
ID |
Message loop exit code. |
Callback Rejector(int ID)
Returns Callback that, when invoked, invokes RejectBreak with the specified exit code. Note that Callback as return value is used for backward compatibility with pre-C++11 U++ and for practical purposes, you could consider Event<> being returned.
|
ID |
Message loop exit code. |
TopWindow& Breaker(Ctrl& m, int ID = -1)
Same as m <<= Breaker(ID) - assigns Breaker callback to WhenAction method of specified Ctrl.
|
ID |
Message loop exit code. |
TopWindow& Acceptor(Ctrl& m, int ID)
Same as m <<= Acceptor(ID) - assigns Acceptor callback to WhenAction method of specified Ctrl.
|
ID |
Message loop exit code. |
TopWindow& Rejector(Ctrl& m, int ID)
Same as m <<= Rejector(ID) - assigns Rejector callback to WhenAction method of specified Ctrl.
|
ID |
Message loop exit code. |
TopWindow& NoCenter()
Sets TopWindow not to be centered when being created on the screen. Returns *this.
TopWindow& CenterOwner()
Sets TopWindow to be centered w.r.t. its owner when being created on the screen. This is default. Returns *this.
TopWindow& CenterScreen()
Sets TopWindow to be desktop centered when being created on the screen. Returns *this.
virtual void SetMinSize(Size sz)
Sets the minimal size for window. This size is then returned by GetMinSize virtual method. If window is resizable, it cannot be made smaller than this size.
|
sz |
Minimal size of window. |
void Open(HWND ownerhwnd)
Opens window with owner specified as Win32 handle.
Win32 specific.
|
ownerhwnd |
Owner window handle. |
TopWindow& Style(dword _style)
Sets Win32 window style.
Win32 specific.
dword GetStyle() const
Sets Win32 window extended style.
Win32 specific.
TopWindow& ExStyle(dword _exstyle)
Win32 specific.
dword GetExStyle() const
Win32 specific.
void Open(Ctrl *owner)
Opens TopWindow as window in host GUI with specified owner. Window can be open as hidden is visibility flag is set to false (Hide()), however on closing, window is set to visible.
|
owner |
Owner of window. If NULL, window has no owner. |
void Open()
Opens TopWindow with owner equal to current active window if it is owned by the process.
void OpenMain()
Opens window without owner.
int Run(bool appmodal = false)
Execute modal loop for TopWindow. If TopWindow is not open, it calls Open before starting loop, but it does not close it.
|
appmodal |
If true, all application window are disabled while performing loop. If false, only TopWindow's relative windows (with the same "super"-owner) are disabled. |
|
Return value |
Result code of modal loop. |
int RunAppModal()
Same as Run(true).
|
Return value |
Result code of modal loop. |
int Execute()
Similar to Run, but closes TopWindow when loop exits.
|
Return value |
Result code of modal loop. |
bool ExecuteOK()
Same as Execute but return true if button OK was pressed.
|
Return value |
Result true if OK otherwise false. |
bool ExecuteCancel()
Same as Execute but return true if button Cancel was pressed.
|
Return value |
Result true if Cancel otherwise false. |
int GetExitCode() const
Returns the result code of last Execute or Run methods.
void Minimize(bool effect = false)
Minimize window.
|
effect |
Do platform specific GUI effects. |
void Maximize(bool effect = false)
Maximize window.
|
effect |
Do platform specific GUI effects. |
void Overlap(bool effect = false)
Put window to normal overlapped state.
|
effect |
Do platform specific GUI effects. |
bool IsMaximized() const
|
Return value |
True if TopWindow is maximized. |
bool IsMinimized() const
|
Return value |
True if TopWindow is minimized. |
bool IsOverlapped() const
|
Return value |
True if TopWindow is in normal (overlapped) state. |
TopWindow& ActiveFocus(Ctrl& ctrl)
Sets the ActiveFocus Ctrl. This Ctrl gets focus when TopWindow is activated. If there is no Ctrl with active focus, first Ctrl is activated. When TopWindow is deactivated, Ctrl that has focus is stored as new ActiveFocus Ctrl and gets focus once TopWindow is activated again (unless this method changes ActiveFocus meanwhile). When this, method is called while TopWindow is active, it is equivalent to ctrl.SetFocus().
TopWindow& Title(const WString& _title)
TopWindow& Title(const char *_title)
Sets the title of the window.
const WString& GetTitle() const
|
Return value |
Current title of window. |
TopWindow& Sizeable(bool b = true)
Indicates whether TopWindow should be resizeable by user.
TopWindow& NoSizeable()
Same as Sizeable(false).
bool IsSizeable() const
TopWindow& MinimizeBox(bool b = true)
Sets TopWindow to have a minimize box.
TopWindow& MaximizeBox(bool b = true)
Sets TopWindow to have a maximize box.
TopWindow& Zoomable(bool b = true)
Sets TopWindow to be Zoomable - to have maximize/minimize flags, if supported by host platform. Same as MinimizeBox(b).MaximizeBox(b).
TopWindow& NoZoomable()
Same as Zoomable(false).
bool IsZoomable() const
|
Return value |
Value of Zoomable flag. |
TopWindow& Background(const PaintRect& prect)
Sets PaintRect that will be used to paint TopWindow background. Default PaintRect paints background with SColorFace.
const PaintRect& GetBackground() const
Returns active PaintRect used to paint TopWindow background.
TopWindow& ToolWindow(bool b = true)
Makes TopWindow appear with thin caption, if supported by host platform. Must be set before opening.
TopWindow& NoToolWindow()
Same as ToolWindow(false).
bool IsToolWindow() const
|
Return value |
Value of ToolWindow flag. |
TopWindow& TopMost(bool b = true, bool stay_top = true)
Makes window stay over any other window. Returns *this.
TopWindow& NoTopMost()
Same as TopMost(false).
bool IsTopMost() const
Value of TopMost flag.
TopWindow& FullScreen(bool b = true)
Sets window to fullscreen if b is true, otherwise sets window to regular state. Returns *this.
bool IsFullScreen() const
Return value True if window is in fullscreen mode.
TopWindow& FrameLess(bool b = true)
Creates window without border decorations (like windows title var or any resizing borders).
bool IsFrameLess() const
Returns FrameLess status.
TopWindow& Urgent(bool b = true)
Calling Urgent(true) causes title of inactive window and its item in taskbar to flash to catch users attention. The effect lasts until either Urgent(false) is called or the window is taken to foreground. If Urgent(true) is called on currently active window then it has no effect.
Note: Most of the window managers on X11 do support this feature, but there still might be some obscure ones that simply ignore this setting.
bool IsUrgent() const
Return value True if window tries to catch users attention by flashing.
TopWindow& NoAccessKeysDistribution()
Disables distribution of access keys. Normally, TopWindow tries to assign access-keys (also known as "hot-keys") to all of its child windows before opening. This method disables this behaviour.
TopWindow& CloseBoxRejects(bool b = true)
When active, pressing window title close button always rejects the dialog. When not active, the action depends on Acceptors/Rejectors present, performing first of IDCANCEL -> reject, IDNO -> reject, IDEXIT -> accept, IDYES -> Accept, and IDOK -> Accept as default action if nothing else is present.
TopWindow& Icon(const Image& m)
Defines icon for TopWindow that is usually displayed in window caption (platform specif).
TopWindow& LargeIcon(const Image& m)
Defines "large" icon for TopWindow. It can be displayed e.g. in task switcher and other places (platform specific).
TopWindow& Icon(const Image& smallicon, const Image& largeicon)
Defines both "small" and "large" icons for TopWindow.
void SerializePlacement(Stream& s, bool reminimize = false)
Serializes current placement of TopWindow. It is platform specific, however information can include screen position in "normal" state and current status (maximized, minimized, normal).
|
reminimize |
If false and loading the information from the stream, minimized state is not restored. |
TopWindow()
Constructor.
~TopWindow()
Destructor.
|