libyui  3.3.2
YImage.h
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.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YImage_h
26 #define YImage_h
27 
28 #include "YWidget.h"
29 #include <string>
30 
31 
32 class YImagePrivate;
33 
34 /**
35  * A picture, possibly animated, loaded from a file.
36  **/
37 class YImage : public YWidget
38 {
39 public:
40  /**
41  * Constructor.
42  *
43  * 'animated' indicates if 'imageFileName' is an animated image format
44  * (e.g., MNG).
45  **/
47  const std::string & imageFileName,
48  bool animated = false );
49 
50  /**
51  * Destructor.
52  **/
53  virtual ~YImage();
54 
55  /**
56  * Returns a descriptive name of this widget class for logging,
57  * debugging etc.
58  **/
59  virtual const char * widgetClass() const { return "YImage"; }
60 
61  /**
62  * Return the file name of this widget's image.
63  **/
64  std::string imageFileName() const;
65 
66  /**
67  * Returns 'true' if the current image is an animated image format (e.g.,
68  * MNG).
69  **/
70  bool animated() const;
71 
72  /**
73  * Set and display a new image (or movie if animated is 'true').
74  *
75  * Derived classes should overwrite this, but call this base class function
76  * in the new function.
77  **/
78  virtual void setImage( const std::string & imageFileName, bool animated = false );
79 
80  /**
81  * Set and display a movie (an animated image).
82  **/
83  void setMovie( const std::string & movieFileName )
84  { setImage( movieFileName, true ); }
85 
86  /**
87  * Return 'true' if the image widget should be stretchable with a default
88  * width of 0 in the specified dimension. This is useful if the widget
89  * width is determined by outside constraints, like the width of a
90  * neighbouring widget.
91  **/
92  bool hasZeroSize( YUIDimension dim ) const;
93 
94  /**
95  * Make the image widget stretchable with a default size of 0 in the
96  * specified dimension. This is useful if the widget width is determined by
97  * outside constraints, like the width of a neighbouring widget.
98  *
99  * This function is intentionally not virtual because it is only relevant
100  * during the next geometry update, in which case the derived class has to
101  * check this value anyway.
102  **/
103  void setZeroSize( YUIDimension dim, bool zeroSize = true );
104 
105  /**
106  * Return 'true' if the image should be scaled to fit into the available
107  * space.
108  **/
109  bool autoScale() const;
110 
111  /**
112  * Make the image fit into the available space.
113  *
114  * Derived classes should overwrite this, but call this base class function
115  * in the new function.
116  **/
117  virtual void setAutoScale( bool autoScale = true );
118 
119 
120 private:
121 
123 };
124 
125 
126 #endif // YImage_h
bool animated() const
Returns &#39;true&#39; if the current image is an animated image format (e.g., MNG).
Definition: YImage.cc:76
virtual const char * widgetClass() const
Returns a descriptive name of this widget class for logging, debugging etc.
Definition: YImage.h:59
virtual ~YImage()
Destructor.
Definition: YImage.cc:64
YWidget * parent() const
Return this widget&#39;s parent or 0 if it doesn&#39;t have a parent.
Definition: YWidget.cc:269
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 setMovie(const std::string &movieFileName)
Set and display a movie (an animated image).
Definition: YImage.h:83
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
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
A picture, possibly animated, loaded from a file.
Definition: YImage.h:37
Abstract base class of all UI widgets.
Definition: YWidget.h:54