libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YImage.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YImage_h 00026 #define YImage_h 00027 00028 #include "YWidget.h" 00029 #include <string> 00030 00031 00032 class YImagePrivate; 00033 00034 00035 class YImage : public YWidget 00036 { 00037 public: 00038 /** 00039 * Constructor. 00040 * 00041 * 'animated' indicates if 'imageFileName' is an animated image format 00042 * (e.g., MNG). 00043 **/ 00044 YImage( YWidget * parent, 00045 const std::string & imageFileName, 00046 bool animated = false ); 00047 00048 /** 00049 * Destructor. 00050 **/ 00051 virtual ~YImage(); 00052 00053 /** 00054 * Returns a descriptive name of this widget class for logging, 00055 * debugging etc. 00056 **/ 00057 virtual const char * widgetClass() const { return "YImage"; } 00058 00059 /** 00060 * Return the file name of this widget's image. 00061 **/ 00062 std::string imageFileName() const; 00063 00064 /** 00065 * Returns 'true' if the current image is an animated image format (e.g., 00066 * MNG). 00067 **/ 00068 bool animated() const; 00069 00070 /** 00071 * Set and display a new image (or movie if animated is 'true'). 00072 * 00073 * Derived classes should overwrite this, but call this base class function 00074 * in the new function. 00075 **/ 00076 virtual void setImage( const std::string & imageFileName, bool animated = false ); 00077 00078 /** 00079 * Set and display a movie (an animated image). 00080 **/ 00081 void setMovie( const std::string & movieFileName ) 00082 { setImage( movieFileName, true ); } 00083 00084 /** 00085 * Return 'true' if the image widget should be stretchable with a default 00086 * width of 0 in the specified dimension. This is useful if the widget 00087 * width is determined by outside constraints, like the width of a 00088 * neighbouring widget. 00089 **/ 00090 bool hasZeroSize( YUIDimension dim ) const; 00091 00092 /** 00093 * Make the image widget stretchable with a default size of 0 in the 00094 * specified dimension. This is useful if the widget width is determined by 00095 * outside constraints, like the width of a neighbouring widget. 00096 * 00097 * This function is intentionally not virtual because it is only relevant 00098 * during the next geometry update, in which case the derived class has to 00099 * check this value anyway. 00100 **/ 00101 void setZeroSize( YUIDimension dim, bool zeroSize = true ); 00102 00103 /** 00104 * Return 'true' if the image should be scaled to fit into the available 00105 * space. 00106 **/ 00107 bool autoScale() const; 00108 00109 /** 00110 * Make the image fit into the available space. 00111 * 00112 * Derived classes should overwrite this, but call this base class function 00113 * in the new function. 00114 **/ 00115 virtual void setAutoScale( bool autoScale = true ); 00116 00117 00118 private: 00119 00120 ImplPtr<YImagePrivate> priv; 00121 }; 00122 00123 00124 #endif // YImage_h