Vaca::Frame Class Reference

#include <Frame.h>

Inheritance diagram for Vaca::Frame:

Vaca::Register< T > Vaca::Widget Vaca::Component Vaca::Referenceable Vaca::NonCopyable Vaca::Dialog Vaca::DockFrame Vaca::MdiChild Vaca::MdiFrame Vaca::FindTextDialog

List of all members.


Detailed Description

A window with title-bar that can be minimized, maximized, etc.

Public Member Functions

 Frame (const String &title, Widget *parent=NULL, Style style=FrameStyle)
 Creates a frame using the FrameClass.
 Frame (const WidgetClassName &className, const String &title, Widget *parent=NULL, Style style=FrameStyle)
 Creates a frame with a custom WNDCLASS.
virtual ~Frame ()
virtual void setVisible (bool visible)
 Hides or shows the window.
MenuBargetMenuBar ()
 Returns the window's menu bar.
virtual MenuBarsetMenuBar (MenuBar *menuBar)
 Changes the window's menu bar.
void setSmallIcon (const Icon &icon)
 Sets the Icon used in the title bar.
void setBigIcon (const Icon &icon)
 Sets the Icon used in the ALT+TAB dialog box.
void setIcon (ResourceId iconId)
 Set the big icon (32x32) and the small icon (16x16) of the Frame using the ICON resource speficied by iconId.
Size getNonClientSize ()
 Returns the Size of non-client area of the frame.
virtual Rect getLayoutBounds ()
 The area where the Layout must arrange the children don't include the dock areas.
void addDockArea (DockArea *dockArea)
 Adds a new DockArea in the Frame.
void removeDockArea (DockArea *dockArea)
 Remove the dockArea from the Frame.
void defaultDockAreas ()
 Setups the default dock areas for the Frame window.
void deleteDockAreas ()
 Deletes all the registered DockAreas.
std::vector< DockArea * > getDockAreas ()
 Returns the collection of registered DockAreas in the Frame.
DockAreagetDockArea (Side side)
 Returns the first DockArea in the specified side.
virtual DockAreagetDefaultDockArea ()
 Returns a default DockArea for the floating DockBar that want to be docked by double-click by first-time.
virtual void layout ()
 Must arranges the children bounds.
virtual bool isLayoutFree ()
 Returns true if the widget is layout-free, that means the Layout shouldn't arrange this widget.
virtual bool keepSynchronized ()
 You can customize this method to return true, so the Frame's enabled-and-visible-state will keep synchronized to the enabled-and-visible-state of its parent.
virtual bool preTranslateMessage (Message &msg)
 This routine is called before to dispatch the message.

Public Attributes

Signal1< void, Event & > Activate
Signal1< void, Event & > Deactivate
Signal1< void, CloseEvent & > Close
Signal2< void,
CardinalDirection, Rect & > 
Resizing

Protected Member Functions

virtual void onPreferredSize (Size &sz)
 Adds space for the non-client size.
virtual void onResize (const Size &sz)
 Calls the layout() method.
virtual bool onCommand (CommandId id)
 Convert a WM_COMMAND notification from a menus to a MenuItem::onAction event.
virtual void onUpdateIndicators ()
 Event called to update the state of indicators.
virtual void onRemoveChild (Widget *child)
virtual void onActivate (Event &ev)
virtual void onDeactivate (Event &ev)
virtual void onClose (CloseEvent &ev)
 Event called when the Frame want to be closed.
virtual void onResizing (CardinalDirection dir, Rect &rc)
virtual bool wndProc (UINT message, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 This method converts next messages to events:.

Private Member Functions

void initialize (const String &title)
void updateMenuItem (MenuItem *menuItem)
Container getSynchronizedGroup ()
 Returns the collection of frames that are synchronized to its parent (see keepSynchronized).

Private Attributes

MenuBarm_menuBar
StatusBarm_statusBar
std::vector< DockArea * > m_dockAreas
bool m_counted
Icon m_smallIcon
Icon m_bigIcon

Constructor & Destructor Documentation

Frame::Frame ( const String title,
Widget parent = NULL,
Style  style = FrameStyle 
)

Creates a frame using the FrameClass.

Also, remember that by default a Frame hasn't a Layout manager.

See also:
onClose()

Frame::Frame ( const WidgetClassName className,
const String title,
Widget parent = NULL,
Style  style = FrameStyle 
)

Creates a frame with a custom WNDCLASS.

className can be NULL if you want to call Widget::create() by your self.

Frame::~Frame (  )  [virtual]


Member Function Documentation

void Frame::setVisible ( bool  visible  )  [virtual]

Hides or shows the window.

If visible is true, the window'll be shown, if it's false the window'll be hidden.

Reimplemented from Vaca::Widget.

MenuBar * Frame::getMenuBar (  ) 

Returns the window's menu bar.

You can't delete it, the Frame destructor does this for you. If you want to delete the current menu bar, you should do something like this:

   ...
   MenuBar* oldMenuBar = myFrame->setMenuBar(NULL);
   if (oldMenuBar != NULL)
     delete oldMenuBar;
   ...

Or, if you are sure that the Frame has a MenuBar, you can do:

   ...
   delete myFrame->setMenuBar(NULL);
   ...

See also:
setMenuBar

MenuBar * Frame::setMenuBar ( MenuBar menuBar  )  [virtual]

Changes the window's menu bar.

The menuBar pointer is deleted automatically only if you don't setMenuBar(NULL) in some place before the Frame's destructor.

Returns:
The old MenuBar (you should delete it). All Frames start without a menu bar (=NULL).
See also:
getMenuBar, MdiFrame::setMenuBar, MenuBar::isAutoDelete, TN010: Auto-deleted objects

Reimplemented in Vaca::MdiFrame.

void Frame::setSmallIcon ( const Icon icon  ) 

Sets the Icon used in the title bar.

Warning:
It's like the Win32 WM_SETICON message.
See also:
setBigIcon, setIcon

void Frame::setBigIcon ( const Icon icon  ) 

Sets the Icon used in the ALT+TAB dialog box.

Warning:
It's like the Win32 WM_SETICON message.
See also:
setSmallIcon, setIcon

void Frame::setIcon ( ResourceId  iconId  ) 

Set the big icon (32x32) and the small icon (16x16) of the Frame using the ICON resource speficied by iconId.

See also:
setSmallIcon, setBigIcon

Size Frame::getNonClientSize (  ) 

Returns the Size of non-client area of the frame.

It's useful to known how much space of the rectangle passed to setBounds will be used in non-client area.

See also:
getBounds

Rect Frame::getLayoutBounds (  )  [virtual]

The area where the Layout must arrange the children don't include the dock areas.

See also:
Widget::getLayoutBounds

Reimplemented from Vaca::Widget.

void Frame::addDockArea ( DockArea dockArea  ) 

Adds a new DockArea in the Frame.

Parameters:
dockArea It'll be automatically deleted in Frame's destructor or deleteDockAreas. (if you don't want it, you should use removeDockArea).
See also:
TN010: Auto-deleted objects

void Frame::removeDockArea ( DockArea dockArea  ) 

Remove the dockArea from the Frame.

You should delete the dockArea pointer.

void Frame::defaultDockAreas (  ) 

Setups the default dock areas for the Frame window.

Warning:
This isn't called automatically in the Frame's constructor. If you want to use dockable ToolBars, you must to call this routine before (or you can setup your own DockAreas with addDockArea())

void Frame::deleteDockAreas (  ) 

Deletes all the registered DockAreas.

std::vector< DockArea * > Frame::getDockAreas (  ) 

Returns the collection of registered DockAreas in the Frame.

DockArea * Frame::getDockArea ( Side  side  ) 

Returns the first DockArea in the specified side.

Returns NULL if there aren't registered a DockArea for the specified side.

DockArea * Frame::getDefaultDockArea (  )  [virtual]

Returns a default DockArea for the floating DockBar that want to be docked by double-click by first-time.

The default implementation returns the first DockArea that you added using addDockArea(); if you use defaultDockAreas(), it will be the bar from the top side.

void Frame::layout (  )  [virtual]

Must arranges the children bounds.

The default implementation calls the Layout::layout method of the Widget's layout manager (Widget::m_layout), but you can override this to obtain your own behavior (you can avoid to use Layout manager if you want).

This method is called from Widget::onResize by default, so when the Widget is shown for first time or it's resized, this method is called.

See also:
getLayout, setLayout, getLayoutBounds.

Reimplemented from Vaca::Widget.

bool Frame::isLayoutFree (  )  [virtual]

Returns true if the widget is layout-free, that means the Layout shouldn't arrange this widget.

The default implementation looks for the VisibleStyle (if it's hidden, it's free of layout).

See also:
getLayout, setLayout

Reimplemented from Vaca::Widget.

bool Frame::keepSynchronized (  )  [virtual]

You can customize this method to return true, so the Frame's enabled-and-visible-state will keep synchronized to the enabled-and-visible-state of its parent.

See also:
getSynchronizedGroup

Reimplemented in Vaca::DockFrame.

bool Frame::preTranslateMessage ( Message msg  )  [virtual]

This routine is called before to dispatch the message.

Win32 Specific:
It's used by Dialog to call IsDialogMessage(W32) for example.

Returns:
True if the message was translated and sent, so the GUI thread doesn't need to dispatch it.

Reimplemented from Vaca::Widget.

Reimplemented in Vaca::Dialog.

void Frame::onPreferredSize ( Size sz  )  [protected, virtual]

Adds space for the non-client size.

See also:
getNonClientSize

Reimplemented from Vaca::Widget.

void Frame::onResize ( const Size sz  )  [protected, virtual]

Calls the layout() method.

Reimplemented from Vaca::Widget.

bool Frame::onCommand ( CommandId  id  )  [protected, virtual]

Convert a WM_COMMAND notification from a menus to a MenuItem::onAction event.

Reimplemented from Vaca::Widget.

void Frame::onUpdateIndicators (  )  [protected, virtual]

Event called to update the state of indicators.

See also:
Widget::updateIndicators

Reimplemented from Vaca::Widget.

void Frame::onRemoveChild ( Widget child  )  [protected, virtual]

Reimplemented from Vaca::Widget.

void Frame::onActivate ( Event ev  )  [protected, virtual]

void Frame::onDeactivate ( Event ev  )  [protected, virtual]

void Frame::onClose ( CloseEvent ev  )  [protected, virtual]

Event called when the Frame want to be closed.

The default implementation fire the signal Frame::Close, and hide the widget (setVisible(false)). If you cancel the ev event, the window'll not hidden.

The next example shows how to avoid to hide the Frame when the user press the close button:

 class MyFrame : public Frame
 {
 public:
   ...
   virtual void onClose(WidgetEvent& ev) {
     Frame::onClose(ev); // it fires the Close signal
     ev.cancel();        // cancel the event (don't hide the frame)
   }
 }

Win32 Specific:
This event is generated by the WM_CLOSE(W32) Message.

void Frame::onResizing ( CardinalDirection  dir,
Rect rc 
) [protected, virtual]

Parameters:
edge From where the user is resizing.

Reimplemented in Vaca::DockFrame.

bool Frame::wndProc ( UINT  message,
WPARAM  wParam,
LPARAM  lParam,
LRESULT &  lResult 
) [protected, virtual]

This method converts next messages to events:.

When the event generated by WM_CLOSE message isn't cancelled, the Frame is automatically hidden.

Reimplemented from Vaca::Widget.

Reimplemented in Vaca::Dialog, Vaca::DockFrame, Vaca::MdiChild, and Vaca::MdiFrame.

void Frame::initialize ( const String title  )  [private]

void Frame::updateMenuItem ( MenuItem menuItem  )  [private]

Widget::Container Frame::getSynchronizedGroup (  )  [private]

Returns the collection of frames that are synchronized to its parent (see keepSynchronized).

If this routine returns true, the enabled-and-visible-state of the Frame will be synchronized with the state of its parent (for example DockFrame).

See also:
keepSynchronized


Member Data Documentation

std::vector<DockArea*> Vaca::Frame::m_dockAreas [private]

bool Vaca::Frame::m_counted [private]

See also:
onActivate

See also:
onDeactivate

See also:
onClose

See also:
onResizing