Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

os::Window Class Reference

#include <window.h>

Inheritance diagram for os::Window:

os::Looper os::Handler os::Alert os::FileRequester os::MenuWindow os::ProgressRequester List of all members.

Public Methods

 Window (const Rect &cFrame, const std::string &cName, const std::string &cTitle, uint32 nFlags=0, uint32 nDesktopMask=CURRENT_DESKTOP)
 Initialize the window. More...

 ~Window ()
 Destruct a window. More...

virtual void FrameMoved (const Point &cDelta)
virtual void FrameSized (const Point &cDelta)
virtual void ScreenModeChanged (const IPoint &cNewRes, color_space eColorSpace)
virtual void DesktopActivated (int nDesktop, bool bActive)
virtual void DesktopsChanged (uint32 nOldDesktops, uint32 nNewDesktops)
void SetFlags (uint32 nFlags)
uint32 GetFlags () const
void SetSizeLimits (const Point &cMinSize, const Point &cMaxSize)
 Limit the minimum and maximum window size. More...

void SetAlignment (const IPoint &cSize=IPoint(1, 1), const IPoint &cSizeOffset=IPoint(0, 0), const IPoint &cPos=IPoint(1, 1), const IPoint &cPosOffset=IPoint(0, 0))
void AddChild (View *pcChild, bool bAssignTabOrder=false)
 Add a view to the window. More...

void RemoveChild (View *pcChild)
 Remove a view from the window. More...

void MakeFocus (bool bFocus=true)
 Activate/Deactivate the window. More...

void Close ()
void Show (bool bMakeVisible=true)
 Hide/Unhide the window. More...

void Start ()
 Unlock the window and start the looper thread. More...

void SetTitle (const std::string &cTitle)
 Change the window title. More...

std::string GetTitle (void) const
 Obtain the current window title. More...

void Flush ()
 Flush the windows render queue. More...

void Sync ()
 Flush the render queue, and wait til the rendering is done. More...

ViewFindView (const std::string &cName) const
ViewFindView (const Point &cPos) const
 Find the view covering a given position on the window. More...

ViewGetFocusChild (void) const
ViewSetFocusChild (View *pcChild)
 Activate a view. More...

void SetDefaultButton (View *pcView)
 Assign a default button. More...

ViewGetDefaultButton () const
 Return the view assigned as the default button. More...

Rect GetFrame () const
 Get the windows position and size on the current desktop. More...

Rect GetBounds () const
 Get the window boundary. More...

void SetFrame (const Rect &cRect, bool bNotifyServer=true)
 Set the window's position and size. More...

void MoveBy (const Point &cDelta)
 Move the window relative to it's current position. More...

void MoveBy (float vDeltaX, float vDeltaY)
 Move the window relative to it's current position. More...

void MoveTo (const Point &cPos)
 Move the window to an absolute position. More...

void MoveTo (float x, float y)
 Move the window to an absolute position. More...

void ResizeBy (const Point &cDelta)
 Resize the window relative to it's current size. More...

void ResizeBy (float vDeltaW, float vDeltaH)
 Resize the window relative to it's current size. More...

void ResizeTo (const Point &cSize)
 Resize the window to a new absolute size. More...

void ResizeTo (float w, float h)
 Resize the window to a new absolute size. More...

bool IsActive () const
int ToggleDepth ()
void DispatchMessage (Message *pcMessage, Handler *pcHandler)
 The loopers message handling callback. More...


Friends

class  View
class  Bitmap
class  MenuItem

Detailed Description

Description:
See also:
Author(s):
Kurt Skauen (kurt@atheos.cx)


Constructor & Destructor Documentation

Window::Window ( const Rect & cFrame,
const std::string & cName,
const std::string & cTitle,
uint32 nFlags = 0,
uint32 nDesktopMask = CURRENT_DESKTOP )
 

Initialize the window.

Description:
The window contructor initialize the local object, and initiate the windows connection to the appserver. The window is invisible and locked when the contructor returns. The first call to Show() will unlock the widow, start the looper thread and make it visible. If you want the windows looper to start handling messages before the window is made visible, you can call Start(). This will unlock the window, and start the looper thread without making the window visible. Simply calling Run()/Unlock() will not work, since the internal state of the Window will not be updated.
Parameters:
cFrame   - The size and position of the window.
See also:
Show(), Start(), Looper::Lock(), Looper::Unlock()
Author(s):
Kurt Skauen (kurt@atheos.cx)

Window::~Window ( )
 

Destruct a window.

Description:
The window destructor will delete all View's still atached to it, and shut down the connection to the appserver.
See also:
Window::Window()
Author(s):
Kurt Skauen (kurt@atheos.cx)


Member Function Documentation

void Window::AddChild ( View * pcChild,
bool bAssignTabOrder = false )
 

Add a view to the window.

Description:
AddChild() add a view to the windows top-view. The view's View::AttachedToWindow() and View::AllAttached() will be called to let the view know about it's new status.

If bAssignTabOrder is true, the view will be assigned a tab order making it possible to activate the view with the keyboard.
Note:
The window share the tab-order counter with the View class.

When the window is later closed, it will automatically delete all remaining child views.
Parameters:
pcChild   - The View to add to the window.
bAssignTabOrder   - If true the view will be assigned a tab-order one higher than the previously added view.
Returns:
See also:
RemoveChild(), View::AddChild(), View::AttachedToWindow(), View::SetTabOrder()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void os::Window::Close ( ) [inline]
 

void Window::DesktopActivated ( int nDesktop,
bool bActive ) [virtual]
 

void Window::DesktopsChanged ( uint32 nOldDesktops,
uint32 nNewDesktops ) [virtual]
 

void Window::DispatchMessage ( Message * pcMsg,
Handler * pcHandler ) [virtual]
 

The loopers message handling callback.

Description:
When a message arrives, the looper extract's it from the queue and call this member with the message as a parameter. The default implementation will attempt to pass the message on to a Handler through it's HandleMessage() member. The Handler that should receive the message is selected as follows:

If the message targets a specific Handler, that Handler will receive the message. DispatchMessage() can determine wether the message had a final destination by examining the pcHandler argument. I not NULL it points at the handler targeted by the message.

If the message destination however is not fully qualified DispatchMessage() attempts to pass the message on to the Default handler (as set through the Looper::SetDefaultHandler()).

If there is no final destination and no default handler, the Looper will handle the message itself by calling its own version of HandleMessage() (The looper is itself a Handler)

Not all messages are passed on to a handler. If the message code is M_QUIT the Looper::OkToQuit() member is called instead, and if it return true Looper::Quit() will be called, and the message loop terminated.

If you would like to handle certain messages directly by the looper, bypassing the normal scheduling you can overload DispatchMessage() to process messages before they are passed on to any handler. If you do so, you should call the loopers version of DispatchMessage() for each message you don't know how to handle.

Note:
The looper is automatically locked prior to calling this member.
Parameters:
pcMsg   - Pointer to the received messge. Note that this message will be deleted when DispatchMessage() returns, unless detatched from the looper through DetachCurrentMessage().
pcHandler   - Pointer to the handler targeted by this message. If the message was not targeted at any spesific handler this argument is NULL.
See also:
SetDefaultHandler(), GetDefaultHandler(), PostMessage(), GetCurrentMessage() , DetachCurrentMessage(), Handler::HandleMessage()
Author(s):
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::Looper.

View * Window::FindView ( const Point & cPos ) const
 

Find the view covering a given position on the window.

Description:
FindView( const Point& cPos ) will do a reqursive search through all attached view's to find the topmost view covering the given point. If no view is intersecting the point NULL is returned.
Returns:
Pointer to the View, or NULL.
See also:
FindView( const char* pzName )
Author(s):
Kurt Skauen (kurt@atheos.cx)

View * os::Window::FindView ( const std::string & cName ) const [inline]
 

void Window::Flush ( void )
 

Flush the windows render queue.

Description:
When a view is rendering graphics, the render commands is buffered in the window, and sendt to the appserver in batches to reduce the overhead of message passing. When the View::Paint() member is called by the system, the render queue will be automatically flushed when View::Paint() returnes. If the view however desides to render anything between paint messages, the render queue must be flushed manually to execute the rendering.
Note:
Flush() do not guarantee that the pixels are indead on-screen when it returns, it only guarantee that the rendering will take place as soon as possible. If you want to make sure all the pixels is rendered, you must use Sync() instead.
See also:
Sync(), Bitmap::Sync(), Bitmap::Flush(), View::Flush(), View::Sync()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::FrameMoved ( const Point & cDelta ) [virtual]
 

void Window::FrameSized ( const Point & cDelta ) [virtual]
 

Reimplemented in os::FileRequester.

Rect Window::GetBounds ( void ) const
 

Get the window boundary.

Description:
Same as GetFrame() except that the rectangle is moved so the left/top corner is located at 0,0.
Returns:
The windows boundary.
See also:
GetFrame(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

View * Window::GetDefaultButton ( ) const
 

Return the view assigned as the default button.

Description:
Return the pointer last set through SetDefaultButton() or NULL if not default button is assigned. Note that this is a os::View pointer, and if you want to call any os::Button spesific member you must static_cast it to a os::Button. If you are not 100% sure that the View is in fact a os::Button, you should use dynamic_cast, and test the result before touching it.
Returns:
Pointer to the default button, or NULL if no default button is assigned.
See also:
SetDefaultButton()
Author(s):
Kurt Skauen (kurt@atheos.cx)

uint32 Window::GetFlags ( ) const
 

View * os::Window::GetFocusChild ( void ) const [inline]
 

Rect Window::GetFrame ( void ) const
 

Get the windows position and size on the current desktop.

Returns:
The windows client rectangle.
See also:
SetFrame(), GetBounds()
Author(s):
Kurt Skauen (kurt@atheos.cx)

std::string Window::GetTitle ( void ) const
 

Obtain the current window title.

Returns:
A const pointer to the internal window title.
See also:
SetTitle()
Author(s):
Kurt Skauen (kurt@atheos.cx)

bool Window::IsActive ( ) const
 

void Window::MakeFocus ( bool bFocus = true )
 

Activate/Deactivate the window.

Description:
If bFocus is true the window will gain focus, and start receiving input events generated by the mouse and keyboard. If bFocus is false the window will lose focus to the window that previously had it.
Note:
The appserver keeps a small stack of previously active windows. When a window give up focus volunterly it will then pop one window off the stack and if the stack was not empty that window will receive focus.
Parameters:
bFocus   - True to activate the window, false to deactivate it.
See also:
View::MakeFocus(), SetFocusChild()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::MoveBy ( float vDeltaX,
float vDeltaY )
 

Move the window relative to it's current position.

Parameters:
nDeltaX   - The horizontal distance to move the window.
nDeltaY   - The vertical distance to move the window.
See also:
MoveTo(), ResizeBy(), ResizeTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::MoveBy ( const Point & cDelta )
 

Move the window relative to it's current position.

Parameters:
cDelta   - The distance to move the window.
See also:
MoveTo(), ResizeBy(), ResizeTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::MoveTo ( float x,
float y )
 

Move the window to an absolute position.

Description:
Move the window so the upper left corner of the client area is at the given position.
Parameters:
x   - The new horizontal position.
y   - The new vertical position.
See also:
MoveBy(), ResizeBy(), ResizeTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::MoveTo ( const Point & cPos )
 

Move the window to an absolute position.

Description:
Move the window so the upper left corner of the client area is at the given position
Parameters:
cPos   - The new position
See also:
MoveBy(), ResizeBy(), ResizeTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::RemoveChild ( View * pcChild )
 

Remove a view from the window.

Description:
Unlink the view from the windows top-view and call the view's View::DetachedFromWindow() and View::AllDetached()
Parameters:
pcChild   - The view to remove.
See also:
AddChild(), View::RemoveChild()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::ResizeBy ( float vDeltaW,
float vDeltaH )
 

Resize the window relative to it's current size.

Parameters:
nDeltaW   - The horizontal distance to move the lower-right corner of the window.
nDeltaH   - The vertical distance to move the lower-right corner of the window.
See also:
ResizeTo(), MoveBy(), MoveTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::ResizeBy ( const Point & cDelta )
 

Resize the window relative to it's current size.

Parameters:
cDelta   - The distance to move the lower-right corner of the window.
See also:
ResizeTo(), MoveBy(), MoveTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::ResizeTo ( float w,
float h )
 

Resize the window to a new absolute size.

Parameters:
W   - The new width of the windows client area.
W   - The new heigth of the windows client area.
See also:
ResizeBy(), MoveBy(), MoveTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::ResizeTo ( const Point & cSize )
 

Resize the window to a new absolute size.

Parameters:
cSize   - The new size of the windows client area.
See also:
ResizeBy(), MoveBy(), MoveTo(), SetFrame()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::ScreenModeChanged ( const IPoint & cNewRes,
color_space eColorSpace ) [virtual]
 

void Window::SetAlignment ( const IPoint & cSize = IPoint(1,1),
const IPoint & cSizeOffset = IPoint(0,0),
const IPoint & cPos = IPoint(1,1),
const IPoint & cPosOffset = IPoint(0,0) )
 

void Window::SetDefaultButton ( View * pcView )
 

Assign a default button.

Description:
Set the default button. The default button will receive KeyDown()/KeyUp() events generated by the <ENTER> key even when not having focus. Since the os::Button class will invoke itself when the <ENTER> key is hit, it will allow the user to activate the default button by simply hitting the <ENTER> key without making the button active first.
Parameters:
pcView   - Pointer to the View that should receive all events generated by the <ENTER> key. This will typically be an instance of the os::Button class.
See also:
GetDefaultButton(), os::Button, View::KeyUp(), View::KeyDown()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::SetFlags ( uint32 nFlags )
 

View * Window::SetFocusChild ( View * pcView )
 

Activate a view.

Description:
Give a view focus, or remove the focus from the current active view by passing in a NULL pointer. This has the same effect as calling pcView->MakeFocus(true).
Parameters:
pcView   - The View that should receive focus, or a NULL pointer to remove focus from the currently active view.
Returns:
Pointer to the previously active view, or NULL if no view had focus.
See also:
View::MakeFocus()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::SetFrame ( const Rect & cRect,
bool bNotifyServer = true )
 

Set the window's position and size.

Description:
SetFrame() will set the windows client position and size on the current desktop.
Parameters:
cRect   - The new frame rectangle of the window's client area.
See also:
GetFrame(), GetBounds(), MoveBy(), MoveTo(), ResizeBy(), ResizeTo()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::SetSizeLimits ( const Point & cMinSize,
const Point & cMaxSize )
 

Limit the minimum and maximum window size.

Description:
SetSizeLimits() sets the maximum and minimum size the window can be resized to by the user. The limits are not enforced by ResizeBy(), ResizeTo(), and SetFrame()
Note:
If you want to prevent the user from resizing the window at all it is normally better to set the WND_NOT_RESIZABLE flag in the constructor or with the SetFlags() member than to set the same size as minimum and maximum. Setting the WND_NOT_RESIZABLE flag will cause visual changes to notify the user that the window can not be resized.

Also think twice before making a window non-resizable it is normally better to make the window layout dynamic through the builtin layout engine.
Parameters:
cMinSize   Minimum size in pixels.
cMaxSize   Maximum size in pixels.

See also:
SetFlags()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::SetTitle ( const std::string & cTitle )
 

Change the window title.

Description:
SetTitle() will change the title rendered in the window border.
Parameters:
pzTitle   The new window title.
See also:
GetTitle()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::Show ( bool bMakeVisible = true )
 

Hide/Unhide the window.

Description:
When a window is first constructed, it is not made visible on the screen. You must first call Show(true), The first time Show() is called it will also unlock the window, and start the looper thread if it is not done already by calling Start().

You can nest calls to Show(false). It will then require the same numbers of Show(true) calls to make the window visible.
Note:
The Window visibility state is global across all desktops.
Parameters:
bMakeVisible   - Set to true to make the window visible, and false to hide it.
See also:
Start(), Window::Window()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::Start ( )
 

Unlock the window and start the looper thread.

Description:
If you whould like to unlock the window and start the looper thread without making the window visible, you can call Start() instead of Show(). This will invert the locking done by the contructor and make the looper run. It will also prevent Show() from doing the same when it is called later to make the window visible.

See also:
Show(), Window::Window()
Author(s):
Kurt Skauen (kurt@atheos.cx)

void Window::Sync ( void )
 

Flush the render queue, and wait til the rendering is done.

Description:
Sync() will like the Flush() member flush the render queue. The difference is that Sync() will wait for the appserver to finnish the rendering and send a reply informing that the rendering is done. This means that when Sync() returnes you have a guarante that all the previously issued rendering operations are indead executed.
Note:
Sync() is normally not used on normal windows, since it have a higher overhead than Flush(), and you normally dont need to wait for the appserver to finnish. It is only useful when the window is attached to a bitmap, and you want to assure that the rendering indead have taken place before you start using the bitmap.
See also:
Flush(), Bitmap::Sync(), Bitmap::Flush(), View::Sync(), View::Flush()
Author(s):
Kurt Skauen (kurt@atheos.cx)

int Window::ToggleDepth ( )
 


Friends And Related Function Documentation

class Bitmap [friend]
 

class MenuItem [friend]
 

class View [friend]
 


The documentation for this class was generated from the following files:
Generated at Sat Apr 7 16:11:45 2001 for AtheOS higlevel API by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001