libyui  3.10.0
YImage.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: YImage.cc
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #include "YImage.h"
27 #include "YBothDim.h"
28 
29 using std::string;
30 
31 
33 {
34  /**
35  * Constructor.
36  **/
37  YImagePrivate( const string & imageFileName, bool animated )
38  : imageFileName( imageFileName )
39  , animated( animated )
40  , autoScale( false )
41  {
42  zeroSize.hor = false;
43  zeroSize.vert = false;
44  }
45 
46 
47  string imageFileName;
48  bool animated;
49  YBothDim<bool> zeroSize;
50  bool autoScale;
51 };
52 
53 
54 
55 
57  const string & imageFileName,
58  bool animated )
59  : YWidget( parent )
60  , priv( new YImagePrivate( imageFileName, animated ) )
61 {
62  YUI_CHECK_NEW( priv );
63 }
64 
65 
67 {
68  // NOP
69 }
70 
71 
72 string YImage::imageFileName() const
73 {
74  return priv->imageFileName;
75 }
76 
77 
78 bool YImage::animated() const
79 {
80  return priv->animated;
81 }
82 
83 
84 void YImage::setImage( const string & imageFileName, bool animated )
85 {
86  priv->imageFileName = imageFileName;
87  priv->animated = animated;
88 }
89 
90 
91 bool YImage::hasZeroSize( YUIDimension dim ) const
92 {
93  return priv->zeroSize[ dim ];
94 }
95 
96 
97 void YImage::setZeroSize( YUIDimension dim, bool zeroSize )
98 {
99  priv->zeroSize[ dim ] = zeroSize;
100  setStretchable( dim, zeroSize );
101 }
102 
103 
104 bool YImage::autoScale() const
105 {
106  return priv->autoScale;
107 }
108 
109 
110 void YImage::setAutoScale( bool autoScale )
111 {
112  priv->autoScale = autoScale;
113 }
YWidget
Abstract base class of all UI widgets.
Definition: YWidget.h:55
YBothDim< bool >
YImage::setZeroSize
void setZeroSize(YUIDimension dim, bool zeroSize=true)
Make the image widget stretchable with a default size of 0 in the specified dimension.
Definition: YImage.cc:97
YImage::setImage
virtual void setImage(const std::string &imageFileName, bool animated=false)
Set and display a new image (or movie if animated is 'true').
Definition: YImage.cc:84
YImage::animated
bool animated() const
Returns 'true' if the current image is an animated image format (e.g., MNG).
Definition: YImage.cc:78
YImage::~YImage
virtual ~YImage()
Destructor.
Definition: YImage.cc:66
YWidget::setStretchable
void setStretchable(YUIDimension dim, bool newStretch)
Set the stretchable state to "newStretch" regardless of any hstretch or vstretch options.
Definition: YWidget.cc:560
YImage::hasZeroSize
bool hasZeroSize(YUIDimension dim) const
Return 'true' if the image widget should be stretchable with a default width of 0 in the specified di...
Definition: YImage.cc:91
YImage::imageFileName
std::string imageFileName() const
Return the file name of this widget's image.
Definition: YImage.cc:72
YImagePrivate
Definition: YImage.cc:33
YImage::YImage
YImage(YWidget *parent, const std::string &imageFileName, bool animated=false)
Constructor.
Definition: YImage.cc:56
YImage::autoScale
bool autoScale() const
Return 'true' if the image should be scaled to fit into the available space.
Definition: YImage.cc:104
YImagePrivate::YImagePrivate
YImagePrivate(const string &imageFileName, bool animated)
Constructor.
Definition: YImage.cc:37
YImage::setAutoScale
virtual void setAutoScale(bool autoScale=true)
Make the image fit into the available space.
Definition: YImage.cc:110