juce_ComponentBoundsConstrainer.h

Go to the documentation of this file.
00001 /*
00002   ==============================================================================
00003 
00004    This file is part of the JUCE library - "Jules' Utility Class Extensions"
00005    Copyright 2004-7 by Raw Material Software ltd.
00006 
00007   ------------------------------------------------------------------------------
00008 
00009    JUCE can be redistributed and/or modified under the terms of the
00010    GNU General Public License, as published by the Free Software Foundation;
00011    either version 2 of the License, or (at your option) any later version.
00012 
00013    JUCE is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with JUCE; if not, visit www.gnu.org/licenses or write to the
00020    Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00021    Boston, MA 02111-1307 USA
00022 
00023   ------------------------------------------------------------------------------
00024 
00025    If you'd like to release a closed-source product which uses JUCE, commercial
00026    licenses are also available: visit www.rawmaterialsoftware.com/juce for
00027    more information.
00028 
00029   ==============================================================================
00030 */
00031 
00032 #ifndef __JUCE_COMPONENTBOUNDSCONSTRAINER_JUCEHEADER__
00033 #define __JUCE_COMPONENTBOUNDSCONSTRAINER_JUCEHEADER__
00034 
00035 #include "../juce_Component.h"
00036 
00037 
00038 //==============================================================================
00050 class JUCE_API  ComponentBoundsConstrainer
00051 {
00052 public:
00053     //==============================================================================
00055     ComponentBoundsConstrainer() throw();
00056 
00058     virtual ~ComponentBoundsConstrainer();
00059 
00060     //==============================================================================
00062     void setMinimumWidth (const int minimumWidth) throw();
00063 
00065     int getMinimumWidth() const throw()                         { return minW; }
00066 
00068     void setMaximumWidth (const int maximumWidth) throw();
00069 
00071     int getMaximumWidth() const throw()                         { return maxW; }
00072 
00074     void setMinimumHeight (const int minimumHeight) throw();
00075 
00077     int getMinimumHeight() const throw()                        { return minH; }
00078 
00080     void setMaximumHeight (const int maximumHeight) throw();
00081 
00083     int getMaximumHeight() const throw()                        { return maxH; }
00084 
00086     void setMinimumSize (const int minimumWidth,
00087                          const int minimumHeight) throw();
00088 
00090     void setMaximumSize (const int maximumWidth,
00091                          const int maximumHeight) throw();
00092 
00094     void setSizeLimits (const int minimumWidth,
00095                         const int minimumHeight,
00096                         const int maximumWidth,
00097                         const int maximumHeight) throw();
00098 
00099     //==============================================================================
00116     void setMinimumOnscreenAmounts (const int minimumWhenOffTheTop,
00117                                     const int minimumWhenOffTheLeft,
00118                                     const int minimumWhenOffTheBottom,
00119                                     const int minimumWhenOffTheRight) throw();
00120 
00121     //==============================================================================
00129     void setFixedAspectRatio (const double widthOverHeight) throw();
00130 
00135     double getFixedAspectRatio() const throw();
00136 
00137 
00138     //==============================================================================
00153     virtual void checkBounds (int& x, int& y, int& w, int& h,
00154                               const Rectangle& previousBounds,
00155                               const Rectangle& limits,
00156                               const bool isStretchingTop,
00157                               const bool isStretchingLeft,
00158                               const bool isStretchingBottom,
00159                               const bool isStretchingRight);
00160 
00162     virtual void resizeStart();
00163 
00165     virtual void resizeEnd();
00166 
00168     void setBoundsForComponent (Component* const component,
00169                                 int x, int y, int w, int h,
00170                                 const bool isStretchingTop,
00171                                 const bool isStretchingLeft,
00172                                 const bool isStretchingBottom,
00173                                 const bool isStretchingRight);
00174 
00181     virtual void applyBoundsToComponent (Component* component,
00182                                          int x, int y, int w, int h);
00183 
00184     //==============================================================================
00185     juce_UseDebuggingNewOperator
00186 
00187 private:
00188     int minW, maxW, minH, maxH;
00189     int minOffTop, minOffLeft, minOffBottom, minOffRight;
00190     double aspectRatio;
00191 
00192     ComponentBoundsConstrainer (const ComponentBoundsConstrainer&);
00193     const ComponentBoundsConstrainer& operator= (const ComponentBoundsConstrainer&);
00194 };
00195 
00196 
00197 #endif   // __JUCE_COMPONENTBOUNDSCONSTRAINER_JUCEHEADER__