libyui
|
00001 /************************************************************************** 00002 Copyright (C) 2000 - 2010 Novell, Inc. 00003 All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00019 **************************************************************************/ 00020 00021 00022 /*---------------------------------------------------------------------\ 00023 | | 00024 | __ __ ____ _____ ____ | 00025 | \ \ / /_ _/ ___|_ _|___ \ | 00026 | \ V / _` \___ \ | | __) | | 00027 | | | (_| |___) || | / __/ | 00028 | |_|\__,_|____/ |_| |_____| | 00029 | | 00030 | core system | 00031 | (C) SuSE GmbH | 00032 \----------------------------------------------------------------------/ 00033 00034 File: YLayoutBox.h 00035 00036 Author: Stefan Hundhammer <sh@suse.de> 00037 00038 /-*/ 00039 00040 #ifndef YLayoutBox_h 00041 #define YLayoutBox_h 00042 00043 #include <vector> 00044 #include "YWidget.h" 00045 00046 using std::vector; 00047 00048 class YLayoutBoxPrivate; 00049 00050 00051 class YLayoutBox : public YWidget 00052 { 00053 public: 00054 typedef vector<int> sizeVector; 00055 typedef vector<int> posVector; 00056 00057 protected: 00063 YLayoutBox( YWidget * parent, YUIDimension dim ); 00064 00065 public: 00069 virtual ~YLayoutBox(); 00070 00075 virtual const char * widgetClass() const; 00076 00081 YUIDimension primary() const; 00082 00086 YUIDimension secondary() const; 00087 00091 bool debugLayout() const; 00092 00096 void setDebugLayout( bool deb = true ); 00097 00103 virtual int preferredSize( YUIDimension dim ); 00104 00110 virtual int preferredWidth(); 00111 00117 virtual int preferredHeight(); 00118 00128 virtual void setSize( int newWidth, int newHeight ); 00129 00138 virtual bool stretchable( YUIDimension dimension ) const; 00139 00145 virtual void moveChild( YWidget * child, int newX, int newY ) = 0; 00146 00151 static bool isLayoutStretch( YWidget * child, YUIDimension dimension ); 00152 00153 00154 protected: 00155 00159 int childrenTotalWeight( YUIDimension dimension ); 00160 00165 int childrenMaxPreferredSize( YUIDimension dimension ); 00166 00171 int totalNonWeightedChildrenPreferredSize( YUIDimension dimension ); 00172 00176 int countNonWeightedChildren( YUIDimension dimension ); 00177 00182 int countStretchableChildren( YUIDimension dimension ); 00183 00189 int countLayoutStretchChildren( YUIDimension dimension ); 00190 00198 YWidget * findDominatingChild(); 00199 00204 void calcPrimaryGeometry ( int newSize, 00205 sizeVector & childSize, 00206 posVector & childPos ); 00207 00212 void calcSecondaryGeometry ( int newSize, 00213 sizeVector & childSize, 00214 posVector & childPos ); 00215 00223 void doResize( sizeVector & width, 00224 sizeVector & height, 00225 posVector & x_pos, 00226 posVector & y_pos ); 00227 00228 00229 private: 00230 00231 ImplPtr<YLayoutBoxPrivate> priv; 00232 }; 00233 00234 00235 typedef YLayoutBox YVBox; 00236 typedef YLayoutBox YHBox; 00237 00238 00239 #endif // YLayoutBox_h