libyui  3.4.2
YSpacing.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YEmpty.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include "YSpacing.h"
27 #include "YUI.h"
28 #include "YApplication.h"
29 
30 
32 {
33  YSpacingPrivate( YUIDimension dim, int size )
34  : dim( dim )
35  , size( size )
36  {}
37 
38  YUIDimension dim;
39  int size;
40 };
41 
42 
43 
44 
45 YSpacing::YSpacing( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t layoutUnits )
46  : YWidget( parent )
47  , priv( new YSpacingPrivate( dim, YUI::app()->deviceUnits( dim, layoutUnits ) ) )
48 {
49  YUI_CHECK_NEW( priv );
50  setStretchable( dim, stretchable );
51  setStretchable( dim == YD_HORIZ ? YD_VERT : YD_HORIZ, false );
52 }
53 
54 
56 {
57  // NOP
58 }
59 
60 
61 YUIDimension
63 {
64  return priv->dim;
65 }
66 
67 
68 int YSpacing::size() const
69 {
70  return priv->size;
71 }
72 
73 
74 int YSpacing::size( YUIDimension dim ) const
75 {
76  if ( dim == priv->dim ) return priv->size;
77  else return 0;
78 }
79 
80 
82 {
83  if ( priv->dim == YD_HORIZ )
84  return priv->size;
85  else
86  return 0;
87 }
88 
89 
91 {
92  if ( priv->dim == YD_VERT )
93  return priv->size;
94  else
95  return 0;
96 }
97 
98 
99 const char *
101 {
102  if ( priv->size > 0 )
103  return ( priv->dim == YD_HORIZ ) ? "YHSpacing" : "YVSpacing";
104 
105  if ( stretchable( YD_HORIZ ) ) return "YHStretch";
106  if ( stretchable( YD_VERT ) ) return "YVStretch";
107 
108  return "YSpacing";
109 }
virtual int preferredHeight()
Preferred height of the widget.
Definition: YSpacing.cc:90
Abstract base class of a libYUI user interface.
Definition: YUI.h:48
virtual ~YSpacing()
Destructor.
Definition: YSpacing.cc:55
virtual bool stretchable(YUIDimension dim) const
This is a boolean value that determines whether the widget is resizable beyond its preferred size in ...
Definition: YWidget.cc:570
int size() const
Return the size in the primary dimension.
Definition: YSpacing.cc:68
YSpacing(YWidget *parent, YUIDimension dim, bool stretchable=false, YLayoutSize_t layoutUnits=0.0)
Constructor.
Definition: YSpacing.cc:45
virtual int preferredWidth()
Preferred width of the widget.
Definition: YSpacing.cc:81
virtual const char * widgetClass() const
Return a descriptive name of this widget class for logging, debugging etc.
Definition: YSpacing.cc:100
YUIDimension dimension() const
Return the primary dimension of this Spacing/Stretch, i.e.
Definition: YSpacing.cc:62
void setStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch" regardless of any hstretch or vstretch options.
Definition: YWidget.cc:558
Abstract base class of all UI widgets.
Definition: YWidget.h:54