MultiDocumentPanel Class Reference

A component that contains a set of other components either in floating windows or tabs. More...

Inherits Component, and ComponentListener.

List of all members.

Public Types

enum  LayoutMode { FloatingWindows, MaximisedWindowsWithTabs }
 

The different layout modes available.

More...

Public Member Functions

 MultiDocumentPanel ()
 Creates an empty panel.
 ~MultiDocumentPanel ()
 Destructor.
bool closeAllDocuments (bool checkItsOkToCloseFirst)
 Tries to close all the documents.
bool addDocument (Component *component, const Colour &backgroundColour, bool deleteWhenRemoved)
 Adds a document component to the panel.
bool closeDocument (Component *component, bool checkItsOkToCloseFirst)
 Closes one of the documents.
int getNumDocuments () const throw ()
 Returns the number of open document windows.
ComponentgetDocument (int index) const throw ()
 Returns one of the open documents.
ComponentgetActiveDocument () const throw ()
 Returns the document component that is currently focused or on top.
void setActiveDocument (Component *component)
 Makes one of the components active and brings it to the top.
virtual void activeDocumentChanged ()
 Callback which gets invoked when the currently-active document changes.
void setMaximumNumDocuments (int maximumNumDocuments)
 Sets a limit on how many windows can be open at once.
void useFullscreenWhenOneDocument (bool shouldUseTabs)
 Sets an option to make the document fullscreen if there's only one document open.
bool isFullscreenWhenOneDocument () const throw ()
 Returns the result of the last time useFullscreenWhenOneDocument() was called.
void setLayoutMode (LayoutMode newLayoutMode)
 Changes the panel's mode.
LayoutMode getLayoutMode () const throw ()
 Returns the current layout mode.
void setBackgroundColour (const Colour &newBackgroundColour)
 Sets the background colour for the whole panel.
const ColourgetBackgroundColour () const throw ()
 Returns the current background colour.
virtual bool tryToCloseDocument (Component *component)=0
 A subclass must override this to say whether its currently ok for a document to be closed.
virtual MultiDocumentPanelWindowcreateNewDocumentWindow ()
 Creates a new window to be used for a document.
void paint (Graphics &g)
void resized ()
void componentNameChanged (Component &)

Detailed Description

A component that contains a set of other components either in floating windows or tabs.

This acts as a panel that can be used to hold a set of open document windows, with different layout modes.

Use addDocument() and closeDocument() to add or remove components from the panel - never use any of the Component methods to access the panel's child components directly, as these are managed internally.


Member Enumeration Documentation

The different layout modes available.

Enumerator:
FloatingWindows 

In this mode, there are overlapping DocumentWindow components for each document.

MaximisedWindowsWithTabs 

In this mode, a TabbedComponent is used to show one document at a time.


Constructor & Destructor Documentation

MultiDocumentPanel::MultiDocumentPanel (  ) 

Creates an empty panel.

Use addDocument() and closeDocument() to add or remove components from the panel - never use any of the Component methods to access the panel's child components directly, as these are managed internally.

MultiDocumentPanel::~MultiDocumentPanel (  ) 

Destructor.

When deleted, this will call closeAllDocuments (false) to make sure all its components are deleted. If you need to make sure all documents are saved before closing, then you should call closeAllDocuments (true) and check that it returns true before deleting the panel.


Member Function Documentation

bool MultiDocumentPanel::closeAllDocuments ( bool  checkItsOkToCloseFirst  ) 

Tries to close all the documents.

If checkItsOkToCloseFirst is true, then the tryToCloseDocument() method will be called for each open document, and any of these calls fails, this method will stop and return false, leaving some documents still open.

If checkItsOkToCloseFirst is false, then all documents will be closed unconditionally.

See also:
closeDocument
bool MultiDocumentPanel::addDocument ( Component component,
const Colour backgroundColour,
bool  deleteWhenRemoved 
)

Adds a document component to the panel.

If the number of documents would exceed the limit set by setMaximumNumDocuments() then this will fail and return false. (If it does fail, the component passed-in will not be deleted, even if deleteWhenRemoved was set to true).

The MultiDocumentPanel will deal with creating a window border to go around your component, so just pass in the bare content component here, no need to give it a ResizableWindow or DocumentWindow.

Parameters:
component the component to add
backgroundColour the background colour to use to fill the component's window or tab
deleteWhenRemoved if true, then when the component is removed by closeDocument() or closeAllDocuments(), then it will be deleted. If false, then the caller must handle the component's deletion
bool MultiDocumentPanel::closeDocument ( Component component,
bool  checkItsOkToCloseFirst 
)

Closes one of the documents.

If checkItsOkToCloseFirst is true, then the tryToCloseDocument() method will be called, and if it fails, this method will return false without closing the document.

If checkItsOkToCloseFirst is false, then the documents will be closed unconditionally.

The component will be deleted if the deleteWhenRemoved parameter was set to true when it was added with addDocument.

See also:
addDocument, closeAllDocuments
int MultiDocumentPanel::getNumDocuments (  )  const throw ()

Returns the number of open document windows.

See also:
getDocument
Component* MultiDocumentPanel::getDocument ( int  index  )  const throw ()

Returns one of the open documents.

The order of the documents in this array may change when they are added, removed or moved around.

See also:
getNumDocuments
Component* MultiDocumentPanel::getActiveDocument (  )  const throw ()

Returns the document component that is currently focused or on top.

If currently using floating windows, then this will be the component in the currently active window, or the top component if none are active.

If it's currently in tabbed mode, then it'll return the component in the active tab.

See also:
setActiveDocument
void MultiDocumentPanel::setActiveDocument ( Component component  ) 

Makes one of the components active and brings it to the top.

See also:
getActiveDocument
virtual void MultiDocumentPanel::activeDocumentChanged (  )  [virtual]

Callback which gets invoked when the currently-active document changes.

void MultiDocumentPanel::setMaximumNumDocuments ( int  maximumNumDocuments  ) 

Sets a limit on how many windows can be open at once.

If this is zero or less there's no limit (the default). addDocument() will fail if this number is exceeded.

void MultiDocumentPanel::useFullscreenWhenOneDocument ( bool  shouldUseTabs  ) 

Sets an option to make the document fullscreen if there's only one document open.

If set to true, then if there's only one document, it'll fill the whole of this component without tabs or a window border. If false, then tabs or a window will always be shown, even if there's only one document. If there's more than one document open, then this option makes no difference.

bool MultiDocumentPanel::isFullscreenWhenOneDocument (  )  const throw ()

Returns the result of the last time useFullscreenWhenOneDocument() was called.

void MultiDocumentPanel::setLayoutMode ( LayoutMode  newLayoutMode  ) 

Changes the panel's mode.

See also:
LayoutMode, getLayoutMode
LayoutMode MultiDocumentPanel::getLayoutMode (  )  const throw ()

Returns the current layout mode.

void MultiDocumentPanel::setBackgroundColour ( const Colour newBackgroundColour  ) 

Sets the background colour for the whole panel.

Each document has its own background colour, but this is the one used to fill the areas behind them.

const Colour& MultiDocumentPanel::getBackgroundColour (  )  const throw ()

Returns the current background colour.

See also:
setBackgroundColour
virtual bool MultiDocumentPanel::tryToCloseDocument ( Component component  )  [pure virtual]

A subclass must override this to say whether its currently ok for a document to be closed.

This method is called by closeDocument() and closeAllDocuments() to indicate that a document should be saved if possible, ready for it to be closed.

If this method returns true, then it means the document is ok and can be closed.

If it returns false, then it means that the closeDocument() method should stop and not close.

Normally, you'd use this method to ask the user if they want to save any changes, then return true if the save operation went ok. If the user cancelled the save operation you could return false here to abort the close operation.

If your component is based on the FileBasedDocument class, then you'd probably want to call FileBasedDocument::saveIfNeededAndUserAgrees() and return true if this returned FileBasedDocument::savedOk

See also:
closeDocument, FileBasedDocument::saveIfNeededAndUserAgrees()
virtual MultiDocumentPanelWindow* MultiDocumentPanel::createNewDocumentWindow (  )  [virtual]

Creates a new window to be used for a document.

The default implementation of this just returns a basic MultiDocumentPanelWindow object, but you might want to override it to return a custom component.

void MultiDocumentPanel::paint ( Graphics g  )  [virtual]

For internal use only.

Reimplemented from Component.

void MultiDocumentPanel::resized (  )  [virtual]

For internal use only.

Reimplemented from Component.

void MultiDocumentPanel::componentNameChanged ( Component  )  [virtual]

For internal use only.

Reimplemented from ComponentListener.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:14 2010 for JUCE by  doxygen 1.6.3