Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXSpring.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                S p r i n g   C o n t a i n e r   W i d g e t                  *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2003,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library 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 Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXSpring.h,v 1.15 2009/01/06 13:07:27 fox Exp $                          *
00022 ********************************************************************************/
00023 #ifndef FXSPRING_H
00024 #define FXSPRING_H
00025 
00026 #ifndef FXPACKER_H
00027 #include "FXPacker.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /**
00034 * The spring widgets, when properly embedded side by side in a horizontal
00035 * frame or vertical frame widget, behave like a set of connected springs
00036 * of various lengths (hence the name!).  The parameters relw (or relh)
00037 * determines the length of the spring.  The actual length is not really
00038 * important; the only thing that counts is the relative length of one
00039 * spring widget to that of another, although the length does determine
00040 * the default size.  The special value zero may be given for relw (or relh)
00041 * to cause the spring to calculate its default width (height) normally,
00042 * just like the Packer base class does.
00043 * In a typical scenario, either the relative width or height is set to
00044 * zero, and the flag LAYOUT_FILL_X or LAYOUT_FILL_Y is passed. When
00045 * placed inside a horizontal frame, the LAYOUT_FILL_X together with
00046 * the relative widths of the springs will cause a fixed width-ratio
00047 * between the springs.
00048 * You also can mix normal controls and springs together in a horizontal
00049 * or vertical frames to provide arbitrary stretchable spacing between
00050 * widgets; in this case, the springs do not need to have any children.
00051 * Since the spring widget is derived from the packer layout manager,
00052 * it provides the same layout behavior as packer.
00053 */
00054 class FXAPI FXSpring : public FXPacker {
00055   FXDECLARE(FXSpring)
00056 protected:
00057   FXint   relWidth;     // Relative width
00058   FXint   relHeight;    // Relative height
00059 protected:
00060   FXSpring(){}
00061 private:
00062   FXSpring(const FXSpring&);
00063   FXSpring &operator=(const FXSpring&);
00064 public:
00065 
00066   /// Construct packer layout manager
00067   FXSpring(FXComposite *p,FXuint opts=0,FXint relw=0,FXint relh=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING,FXint hs=DEFAULT_SPACING,FXint vs=DEFAULT_SPACING);
00068 
00069   /// Return default width
00070   virtual FXint getDefaultWidth();
00071 
00072   /// Return default height
00073   virtual FXint getDefaultHeight();
00074 
00075   /// Change relative width
00076   void setRelativeWidth(FXint relw);
00077 
00078   /// Return relative width
00079   FXint getRelativeWidth() const { return relWidth; }
00080 
00081   /// Change relative height
00082   void setRelativeHeight(FXint relh);
00083 
00084   /// Return relative height
00085   FXint getRelativeHeight() const { return relHeight; }
00086 
00087   /// Save to stream
00088   virtual void save(FXStream& store) const;
00089 
00090   /// Load from stream
00091   virtual void load(FXStream& store);
00092   };
00093 
00094 }
00095 
00096 #endif

Copyright © 1997-2009 Jeroen van der Zijp