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