ResizableWindow Class Reference

A base class for top-level windows that can be dragged around and resized. More...

Inherits TopLevelWindow.

Inherited by DocumentWindow, and FileChooserDialogBox.

List of all members.

Public Types

enum  ColourIds { backgroundColourId = 0x1005700 }
 

A set of colour IDs to use to change the colour of various aspects of the window.

More...

Public Member Functions

 ResizableWindow (const String &name, bool addToDesktop)
 Creates a ResizableWindow.
 ResizableWindow (const String &name, const Colour &backgroundColour, bool addToDesktop)
 Creates a ResizableWindow.
 ~ResizableWindow ()
 Destructor.
const Colour getBackgroundColour () const throw ()
 Returns the colour currently being used for the window's background.
void setBackgroundColour (const Colour &newColour)
 Changes the colour currently being used for the window's background.
void setResizable (bool shouldBeResizable, bool useBottomRightCornerResizer)
 Make the window resizable or fixed.
bool isResizable () const throw ()
 True if resizing is enabled.
void setResizeLimits (int newMinimumWidth, int newMinimumHeight, int newMaximumWidth, int newMaximumHeight) throw ()
 This sets the maximum and minimum sizes for the window.
ComponentBoundsConstrainergetConstrainer () throw ()
 Returns the bounds constrainer object that this window is using.
void setConstrainer (ComponentBoundsConstrainer *newConstrainer)
 Sets the bounds-constrainer object to use for resizing and dragging this window.
void setBoundsConstrained (const Rectangle< int > &bounds)
 Calls the window's setBounds method, after first checking these bounds with the current constrainer.
bool isFullScreen () const
 Returns true if the window is currently in full-screen mode.
void setFullScreen (bool shouldBeFullScreen)
 Puts the window into full-screen mode, or restores it to its normal size.
bool isMinimised () const
 Returns true if the window is currently minimised.
void setMinimised (bool shouldMinimise)
 Minimises the window, or restores it to its previous position and size.
const String getWindowStateAsString ()
 Returns a string which encodes the window's current size and position.
bool restoreWindowStateFromString (const String &previousState)
 Restores the window to a previously-saved size and position.
ComponentgetContentComponent () const throw ()
 Returns the current content component.
void setContentComponent (Component *newContentComponent, bool deleteOldOne=true, bool resizeToFit=false)
 Changes the current content component.
void setContentComponentSize (int width, int height)
 Changes the window so that the content component ends up with the specified size.

Protected Member Functions

void paint (Graphics &g)
void moved ()
 (if overriding this, make sure you call ResizableWindow::resized() in your subclass)
void resized ()
 (if overriding this, make sure you call ResizableWindow::resized() in your subclass)
void mouseDown (const MouseEvent &e)
void mouseDrag (const MouseEvent &e)
void lookAndFeelChanged ()
void childBoundsChanged (Component *child)
void parentSizeChanged ()
void visibilityChanged ()
void activeWindowStatusChanged ()
int getDesktopWindowStyleFlags () const
virtual const BorderSize getBorderThickness ()
 Returns the width of the border to use around the window.
virtual const BorderSize getContentComponentBorder ()
 Returns the insets to use when positioning the content component.

Protected Attributes

ScopedPointer
< ResizableCornerComponent
resizableCorner
ScopedPointer
< ResizableBorderComponent
resizableBorder

Detailed Description

A base class for top-level windows that can be dragged around and resized.

To add content to the window, use its setContentComponent() method to give it a component that will remain positioned inside it (leaving a gap around the edges for a border).

It's not advisable to add child components directly to a ResizableWindow: put them inside your content component instead. And overriding methods like resized(), moved(), etc is also not recommended - instead override these methods for your content component. (If for some obscure reason you do need to override these methods, always remember to call the super-class's resized() method too, otherwise it'll fail to lay out the window decorations correctly).

By default resizing isn't enabled - use the setResizable() method to enable it and to choose the style of resizing to use.

See also:
TopLevelWindow

Member Enumeration Documentation

A set of colour IDs to use to change the colour of various aspects of the window.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also:
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator:
backgroundColourId 

A colour to use to fill the window's background.

Reimplemented in FileChooserDialogBox, and DocumentWindow.


Constructor & Destructor Documentation

ResizableWindow::ResizableWindow ( const String name,
bool  addToDesktop 
)

Creates a ResizableWindow.

This constructor doesn't specify a background colour, so the LookAndFeel's default background colour will be used.

Parameters:
name the name to give the component
addToDesktop if true, the window will be automatically added to the desktop; if false, you can use it as a child component
ResizableWindow::ResizableWindow ( const String name,
const Colour backgroundColour,
bool  addToDesktop 
)

Creates a ResizableWindow.

Parameters:
name the name to give the component
backgroundColour the colour to use for filling the window's background.
addToDesktop if true, the window will be automatically added to the desktop; if false, you can use it as a child component
ResizableWindow::~ResizableWindow (  ) 

Destructor.

If a content component has been set with setContentComponent(), it will be deleted.


Member Function Documentation

const Colour ResizableWindow::getBackgroundColour (  )  const throw ()

Returns the colour currently being used for the window's background.

As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour.

This method is the same as retrieving the colour for ResizableWindow::backgroundColourId.

See also:
setBackgroundColour
void ResizableWindow::setBackgroundColour ( const Colour newColour  ) 

Changes the colour currently being used for the window's background.

As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour.

Note that the opaque state of this window is altered by this call to reflect the opacity of the colour passed-in. On window systems which can't support semi-transparent windows this might cause problems, (though it's unlikely you'll be using this class as a base for a semi-transparent component anyway).

You can also use the ResizableWindow::backgroundColourId colour id to set this colour.

See also:
getBackgroundColour
void ResizableWindow::setResizable ( bool  shouldBeResizable,
bool  useBottomRightCornerResizer 
)

Make the window resizable or fixed.

Parameters:
shouldBeResizable whether it's resizable at all
useBottomRightCornerResizer if true, it'll add a ResizableCornerComponent at the bottom-right; if false, it'll use a ResizableBorderComponent around the edge
See also:
setResizeLimits, isResizable
bool ResizableWindow::isResizable (  )  const throw ()

True if resizing is enabled.

See also:
setResizable
void ResizableWindow::setResizeLimits ( int  newMinimumWidth,
int  newMinimumHeight,
int  newMaximumWidth,
int  newMaximumHeight 
) throw ()

This sets the maximum and minimum sizes for the window.

If the window's current size is outside these limits, it will be resized to make sure it's within them.

Calling setBounds() on the component will bypass any size checking - it's only when the window is being resized by the user that these values are enforced.

See also:
setResizable, setFixedAspectRatio
ComponentBoundsConstrainer* ResizableWindow::getConstrainer (  )  throw ()

Returns the bounds constrainer object that this window is using.

You can access this to change its properties.

void ResizableWindow::setConstrainer ( ComponentBoundsConstrainer newConstrainer  ) 

Sets the bounds-constrainer object to use for resizing and dragging this window.

A pointer to the object you pass in will be kept, but it won't be deleted by this object, so it's the caller's responsiblity to manage it.

If you pass 0, then no contraints will be placed on the positioning of the window.

void ResizableWindow::setBoundsConstrained ( const Rectangle< int > &  bounds  ) 

Calls the window's setBounds method, after first checking these bounds with the current constrainer.

See also:
setConstrainer
bool ResizableWindow::isFullScreen (  )  const

Returns true if the window is currently in full-screen mode.

See also:
setFullScreen
void ResizableWindow::setFullScreen ( bool  shouldBeFullScreen  ) 

Puts the window into full-screen mode, or restores it to its normal size.

If true, the window will become full-screen; if false, it will return to the last size it was before being made full-screen.

See also:
isFullScreen
bool ResizableWindow::isMinimised (  )  const

Returns true if the window is currently minimised.

See also:
setMinimised
void ResizableWindow::setMinimised ( bool  shouldMinimise  ) 

Minimises the window, or restores it to its previous position and size.

When being un-minimised, it'll return to the last position and size it was in before being minimised.

See also:
isMinimised
const String ResizableWindow::getWindowStateAsString (  ) 

Returns a string which encodes the window's current size and position.

This string will encapsulate the window's size, position, and whether it's in full-screen mode. It's intended for letting your application save and restore a window's position.

Use the restoreWindowStateFromString() to restore from a saved state.

See also:
restoreWindowStateFromString
bool ResizableWindow::restoreWindowStateFromString ( const String previousState  ) 

Restores the window to a previously-saved size and position.

This restores the window's size, positon and full-screen status from an string that was previously created with the getWindowStateAsString() method.

Returns:
false if the string wasn't a valid window state
See also:
getWindowStateAsString
Component* ResizableWindow::getContentComponent (  )  const throw ()

Returns the current content component.

This will be the component set by setContentComponent(), or 0 if none has yet been specified.

See also:
setContentComponent
void ResizableWindow::setContentComponent ( Component newContentComponent,
bool  deleteOldOne = true,
bool  resizeToFit = false 
)

Changes the current content component.

This sets a component that will be placed in the centre of the ResizableWindow, (leaving a space around the edge for the border).

You should never add components directly to a ResizableWindow (or any of its subclasses) with addChildComponent(). Instead, add them to the content component.

Parameters:
newContentComponent the new component to use (or null to not use one) - this component will be deleted either when replaced by another call to this method, or when the ResizableWindow is deleted. To remove a content component without deleting it, use setContentComponent (0, false).
deleteOldOne if true, the previous content component will be deleted; if false, the previous component will just be removed without deleting it.
resizeToFit if true, the ResizableWindow will maintain its size such that it always fits around the size of the content component. If false, the new content will be resized to fit the current space available.
void ResizableWindow::setContentComponentSize ( int  width,
int  height 
)

Changes the window so that the content component ends up with the specified size.

This is basically a setSize call on the window, but which adds on the borders, so you can specify the content component's target size.

void ResizableWindow::paint ( Graphics g  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

Reimplemented in DocumentWindow.

void ResizableWindow::moved (  )  [protected, virtual]

(if overriding this, make sure you call ResizableWindow::resized() in your subclass)

Reimplemented from Component.

void ResizableWindow::resized (  )  [protected, virtual]

(if overriding this, make sure you call ResizableWindow::resized() in your subclass)

Reimplemented from Component.

Reimplemented in DialogWindow, and DocumentWindow.

void ResizableWindow::mouseDown ( const MouseEvent e  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

void ResizableWindow::mouseDrag ( const MouseEvent e  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

void ResizableWindow::lookAndFeelChanged (  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

Reimplemented in DocumentWindow.

void ResizableWindow::childBoundsChanged ( Component child  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

void ResizableWindow::parentSizeChanged (  )  [protected, virtual]

For internal use only.

Reimplemented from Component.

void ResizableWindow::visibilityChanged (  )  [protected, virtual]

For internal use only.

Reimplemented from TopLevelWindow.

void ResizableWindow::activeWindowStatusChanged (  )  [protected, virtual]

For internal use only.

Reimplemented from TopLevelWindow.

Reimplemented in MultiDocumentPanelWindow, and DocumentWindow.

int ResizableWindow::getDesktopWindowStyleFlags (  )  const [protected, virtual]

For internal use only.

Reimplemented from TopLevelWindow.

Reimplemented in DocumentWindow.

virtual const BorderSize ResizableWindow::getBorderThickness (  )  [protected, virtual]

Returns the width of the border to use around the window.

See also:
getContentComponentBorder

Reimplemented in DocumentWindow.

virtual const BorderSize ResizableWindow::getContentComponentBorder (  )  [protected, virtual]

Returns the insets to use when positioning the content component.

See also:
getBorderThickness

Reimplemented in DocumentWindow.


Member Data Documentation


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:16 2010 for JUCE by  doxygen 1.6.3