libyui  3.0.10
/usr/src/RPM/BUILD/libyui-3.0.10/src/YAlignment.h
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:         YAlignment.h
00020 
00021   Author:       Stefan Hundhammer <sh@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef YAlignment_h
00026 #define YAlignment_h
00027 
00028 #include "YSingleChildContainerWidget.h"
00029 
00030 
00031 class YAlignmentPrivate;
00032 
00033 /**
00034  * Implementation of all the alignment widgets:
00035  *
00036  * - Left, Right,  HCenter,
00037  * - Top,  Bottom, VCenter,
00038  * - HVCenter
00039  * - MinSize, MinWidth, MinHeight
00040  **/
00041 class YAlignment : public YSingleChildContainerWidget
00042 {
00043 protected:
00044     /**
00045      * Constructor.
00046      **/
00047     YAlignment( YWidget *       parent,
00048                 YAlignmentType  horAlign,
00049                 YAlignmentType  vertAlign );
00050 
00051 public:
00052     /**
00053      * Destructor.
00054      **/
00055     virtual ~YAlignment();
00056 
00057     /**
00058      * Return a descriptive name of this widget class for logging,
00059      * debugging etc.
00060      **/
00061     virtual const char * widgetClass() const;
00062 
00063     /**
00064      * Return the alignment in the specified dimension.
00065      **/
00066     YAlignmentType alignment( YUIDimension dim ) const;
00067 
00068     /**
00069      * Return the left margin in pixels, the distance between the left edge of
00070      * this alignment and the left edge of the child widget.
00071      **/
00072     int leftMargin() const;
00073 
00074     /**
00075      * Return the right margin in pixels, the distance between the right edge
00076      * of this alignment and the right edge of the child widget.
00077      **/
00078     int rightMargin() const;
00079 
00080     /**
00081      * Return the top margin in pixels, the distance between the top edge of
00082      * this alignment and the top edge of the child widget.
00083      **/
00084     int topMargin() const;
00085 
00086     /**
00087      * Return the bottom margin in pixels, the distance between the bottom
00088      * edge of this alignment and the bottom edge of the child widget.
00089      **/
00090     int bottomMargin() const;
00091 
00092     /**
00093      * Return the sum of all margins in the specified dimension.
00094      **/
00095     int totalMargins( YUIDimension dim ) const;
00096 
00097     /**
00098      * Set the left margin in pixels.
00099      **/
00100     void setLeftMargin( int margin );
00101 
00102     /**
00103      * Set the right margin in pixels.
00104      **/
00105     void setRightMargin( int margin );
00106 
00107     /**
00108      * Set the top margin in pixels.
00109      **/
00110     void setTopMargin( int margin );
00111 
00112     /**
00113      * Set the bottom margin in pixels.
00114      **/
00115     void setBottomMargin( int margin );
00116 
00117     /**
00118      * Return the minimum width of this alignment or 0 if none is set.
00119      * preferredWidth() will never return less than this value.
00120      **/
00121     int minWidth() const;
00122 
00123     /**
00124      * Return the minimum height of this alignment or 0 if none is set.
00125      * preferredHeight() will never return less than this value.
00126      **/
00127     int minHeight() const;
00128 
00129     /**
00130      * Set the minimum width to return for preferredWidth().
00131      **/
00132     void setMinWidth( int width );
00133 
00134     /**
00135      * Set the minimum height to return for preferredHeight().
00136      **/
00137     void setMinHeight( int height );
00138 
00139     /**
00140      * Set a background pixmap.
00141      *
00142      * Derived classes may want to overwrite this.
00143      *
00144      * This parent method should be called first in the overwritten method to
00145      * ensure path expansion is done as specified (prepend the theme path
00146      * ("/usr/share/libyui/theme/") if the path doesn't start with "/"
00147      * or ".").
00148      **/
00149     virtual void setBackgroundPixmap( const std::string & pixmapFileName );
00150 
00151     /**
00152      * Return the name of the background pixmap or an empty string, if there
00153      * is none.
00154      **/
00155     std::string backgroundPixmap() const;
00156 
00157     /**
00158      * Add a child widget.
00159      *
00160      * Reimplemented from YSingleChildContainerWidget to propagate
00161      * stretchability down to the single child.
00162      **/
00163     virtual void addChild( YWidget * child );
00164 
00165     /**
00166      * Move a child widget to a new position.
00167      **/
00168     virtual void moveChild( YWidget *child, int newx, int newy ) = 0;
00169 
00170     /**
00171      * Return this widget's stretchability.
00172      * Reimplemented from YWidget.
00173      *
00174      * In an aligned dimension the widget is always stretchable.
00175      * In an unchanged dimension the widget is stretchable if the
00176      * child is stretchable.
00177      **/
00178     virtual bool stretchable( YUIDimension dim ) const;
00179 
00180     /**
00181      * Preferred width of the widget.
00182      *
00183      * Reimplemented from YWidget.
00184      **/
00185     virtual int preferredWidth();
00186 
00187     /**
00188      * Preferred height of the widget.
00189      *
00190      * Reimplemented from YWidget.
00191      **/
00192     virtual int preferredHeight();
00193 
00194     /**
00195      * Set the current size and move the child widget according to its
00196      * alignment.
00197      *
00198      * Derived classes should reimplement this, but call this base class
00199      * function in their own implementation.
00200      **/
00201     virtual void setSize( int newWidth, int newHeight );
00202 
00203 
00204 protected:
00205 
00206     ImplPtr<YAlignmentPrivate> priv;
00207 };
00208 
00209 
00210 #endif // YAlignment_h
 All Classes Functions Variables Enumerations Friends