libyui  3.3.1
YSquash.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: YSquash.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #include "YSquash.h"
26 #include "YBothDim.h"
27 
28 
30 {
31  /**
32  * Constructor.
33  **/
34  YSquashPrivate( bool horSquash, bool vertSquash )
35  {
36  squash.hor = horSquash;
37  squash.vert = vertSquash;
38  }
39 
40  YBothDim<bool> squash;
41 };
42 
43 
44 YSquash::YSquash( YWidget * parent, bool horSquash, bool vertSquash )
45  : YSingleChildContainerWidget( parent )
46  , priv( new YSquashPrivate( horSquash, vertSquash ) )
47 {
48  YUI_CHECK_NEW( priv );
49 }
50 
51 
53 {
54  // NOP
55 }
56 
57 
58 bool YSquash::horSquash() const
59 {
60  return priv->squash.hor;
61 }
62 
63 
64 bool YSquash::vertSquash() const
65 {
66  return priv->squash.vert;
67 }
68 
69 
70 bool YSquash::stretchable( YUIDimension dim ) const
71 {
72  if ( ! hasChildren() )
73  return false;
74 
75  return ! priv->squash[ dim ] && firstChild()->stretchable( dim );
76 }
77 
78 
79 const char *
81 {
82  if ( priv->squash.hor && priv->squash.vert ) return "YHVSquash";
83  else if ( priv->squash.hor ) return "YHSquash";
84  else if ( priv->squash.vert ) return "YVSquash";
85  else return "YSquash_NoSquash";
86 }
bool vertSquash() const
Returns &#39;true&#39; if this widget squashes vertically.
Definition: YSquash.cc:64
YWidget * firstChild() const
Returns the first child or 0 if there is none.
Definition: YWidget.h:199
bool hasChildren() const
Returns &#39;true&#39; if this widget has any children.
Definition: YWidget.h:192
bool horSquash() const
Returns &#39;true&#39; if this widget squashes horizontally.
Definition: YSquash.cc:58
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:567
YSquash(YWidget *parent, bool horSquash, bool vertSquash)
Constructor.
Definition: YSquash.cc:44
virtual ~YSquash()
Destructor.
Definition: YSquash.cc:52
Container widget class that manages one child.
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YSquash.cc:80
bool stretchable(YUIDimension dim) const
In a squashed dimension the widget NOT stretchable.
Definition: YSquash.cc:70
Abstract base class of all UI widgets.
Definition: YWidget.h:54
YSquashPrivate(bool horSquash, bool vertSquash)
Constructor.
Definition: YSquash.cc:34