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