libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YEmpty.cc 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #include "YSpacing.h" 00027 #include "YUI.h" 00028 #include "YApplication.h" 00029 00030 00031 struct YSpacingPrivate 00032 { 00033 YSpacingPrivate( YUIDimension dim, int size ) 00034 : dim( dim ) 00035 , size( size ) 00036 {} 00037 00038 YUIDimension dim; 00039 int size; 00040 }; 00041 00042 00043 00044 00045 YSpacing::YSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t layoutUnits ) 00046 : YWidget( parent ) 00047 , priv( new YSpacingPrivate( dim, YUI::app()->deviceUnits( dim, layoutUnits ) ) ) 00048 { 00049 YUI_CHECK_NEW( priv ); 00050 setStretchable( dim, stretchable ); 00051 setStretchable( dim == YD_HORIZ ? YD_VERT : YD_HORIZ, false ); 00052 } 00053 00054 00055 YSpacing::~YSpacing() 00056 { 00057 // NOP 00058 } 00059 00060 00061 YUIDimension 00062 YSpacing::dimension() const 00063 { 00064 return priv->dim; 00065 } 00066 00067 00068 int YSpacing::size() const 00069 { 00070 return priv->size; 00071 } 00072 00073 00074 int YSpacing::size( YUIDimension dim ) const 00075 { 00076 if ( dim == priv->dim ) return priv->size; 00077 else return 0; 00078 } 00079 00080 00081 int YSpacing::preferredWidth() 00082 { 00083 if ( priv->dim == YD_HORIZ ) 00084 return priv->size; 00085 else 00086 return 0; 00087 } 00088 00089 00090 int YSpacing::preferredHeight() 00091 { 00092 if ( priv->dim == YD_VERT ) 00093 return priv->size; 00094 else 00095 return 0; 00096 } 00097 00098 00099 const char * 00100 YSpacing::widgetClass() const 00101 { 00102 if ( priv->size > 0 ) 00103 return ( priv->dim == YD_HORIZ ) ? "YHSpacing" : "YVSpacing"; 00104 00105 if ( stretchable( YD_HORIZ ) ) return "YHStretch"; 00106 if ( stretchable( YD_VERT ) ) return "YVStretch"; 00107 00108 return "YSpacing"; 00109 }