Classes | Public Member Functions | Protected Member Functions

ResizableBorderComponent Class Reference

A component that resizes its parent component when dragged. More...

Inherits Component.

List of all members.

Classes

class  Zone
 Represents the different sections of a resizable border, which allow it to resized in different ways. More...

Public Member Functions

 ResizableBorderComponent (Component *componentToResize, ComponentBoundsConstrainer *constrainer)
 Creates a resizer.
 ~ResizableBorderComponent ()
 Destructor.
void setBorderThickness (const BorderSize< int > &newBorderSize)
 Specifies how many pixels wide the draggable edges of this component are.
const BorderSize< int > getBorderThickness () const
 Returns the number of pixels wide that the draggable edges of this component are.

Protected Member Functions

void paint (Graphics &g)
 Components can override this method to draw their content.
void mouseEnter (const MouseEvent &e)
 Called when the mouse first enters this component.
void mouseMove (const MouseEvent &e)
 Called when the mouse moves inside this component.
void mouseDown (const MouseEvent &e)
 Called when a mouse button is pressed while it's over this component.
void mouseDrag (const MouseEvent &e)
 Called when the mouse is moved while a button is held down.
void mouseUp (const MouseEvent &e)
 Called when a mouse button is released.
bool hitTest (int x, int y)
 Tests whether a given point inside the component.

Detailed Description

A component that resizes its parent component when dragged.

This component forms a frame around the edge of a component, allowing it to be dragged by the edges or corners to resize it - like the way windows are resized in MSWindows or Linux.

To use it, just add it to your component, making it fill the entire parent component (there's a mouse hit-test that only traps mouse-events which land around the edge of the component, so it's even ok to put it on top of any other components you're using). Make sure you rescale the resizer component to fill the parent each time the parent's size changes.

See also:
ResizableCornerComponent

Constructor & Destructor Documentation

ResizableBorderComponent::ResizableBorderComponent ( Component componentToResize,
ComponentBoundsConstrainer constrainer 
)

Creates a resizer.

Pass in the target component which you want to be resized when this one is dragged.

The target component will usually be a parent of the resizer component, but this isn't mandatory.

Remember that when the target component is resized, it'll need to move and resize this component to keep it in place, as this won't happen automatically.

If the constrainer parameter is non-zero, then this object will be used to enforce limits on the size and position that the component can be stretched to. Make sure that the constrainer isn't deleted while still in use by this object.

See also:
ComponentBoundsConstrainer
ResizableBorderComponent::~ResizableBorderComponent (  )

Destructor.


Member Function Documentation

void ResizableBorderComponent::setBorderThickness ( const BorderSize< int > &  newBorderSize )

Specifies how many pixels wide the draggable edges of this component are.

See also:
getBorderThickness
const BorderSize<int> ResizableBorderComponent::getBorderThickness (  ) const

Returns the number of pixels wide that the draggable edges of this component are.

See also:
setBorderThickness
void ResizableBorderComponent::paint ( Graphics g ) [protected, virtual]

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In Juce (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters:
gthe graphics context that must be used to do the drawing operations.
See also:
repaint, paintOverChildren, Graphics

Reimplemented from Component.

void ResizableBorderComponent::mouseEnter ( const MouseEvent e ) [protected, virtual]

Called when the mouse first enters this component.

If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.

When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released.

If you're writing a component that needs to repaint itself when the mouse enters and exits, it might be quicker to use the setRepaintsOnMouseActivity() method.

Parameters:
edetails about the position and status of the mouse event
See also:
mouseExit, mouseDrag, mouseMove, contains

Reimplemented from Component.

void ResizableBorderComponent::mouseMove ( const MouseEvent e ) [protected, virtual]

Called when the mouse moves inside this component.

If the mouse button isn't pressed and the mouse moves over a component, this will be called to let the component react to this.

A component will always get a mouseEnter callback before a mouseMove.

Parameters:
edetails about the position and status of the mouse event
See also:
mouseEnter, mouseExit, mouseDrag, contains

Reimplemented from Component.

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

Called when a mouse button is pressed while it's over this component.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters:
edetails about the position and status of the mouse event
See also:
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from Component.

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

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

If you want to be able to drag things off the edge of a component and have the component scroll when you get to the edges, the beginDragAutoRepeat() method might be useful.

Parameters:
edetails about the position and status of the mouse event
See also:
mouseDown, mouseUp, mouseMove, contains, beginDragAutoRepeat

Reimplemented from Component.

void ResizableBorderComponent::mouseUp ( const MouseEvent e ) [protected, virtual]

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

Parameters:
edetails about the position and status of the mouse event
See also:
mouseDown, mouseDrag, mouseDoubleClick, contains

Reimplemented from Component.

bool ResizableBorderComponent::hitTest ( int  x,
int  y 
) [protected, virtual]

Tests whether a given point inside the component.

Overriding this method allows you to create components which only intercept mouse-clicks within a user-defined area.

This is called to find out whether a particular x, y coordinate is considered to be inside the component or not, and is used by methods such as contains() and getComponentAt() to work out which component the mouse is clicked on.

Components with custom shapes will probably want to override it to perform some more complex hit-testing.

The default implementation of this method returns either true or false, depending on the value that was set by calling setInterceptsMouseClicks() (true is the default return value).

Note that the hit-test region is not related to the opacity with which areas of a component are painted.

Applications should never call hitTest() directly - instead use the contains() method, because this will also test for occlusion by the component's parent.

Note that for components on the desktop, this method will be ignored, because it's not always possible to implement this behaviour on all platforms.

Parameters:
xthe x coordinate to test, relative to the left hand edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's width
ythe y coordinate to test, relative to the top edge of this component. This value is guaranteed to be greater than or equal to zero, and less than the component's height
Returns:
true if the click is considered to be inside the component
See also:
setInterceptsMouseClicks, contains

Reimplemented from Component.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines