Eneboo - Documentación para desarrolladores
src/qt/tools/designer/designer/layout.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002 ** Copyright (C) 2005-2007 Trolltech ASA.  All rights reserved.
00003 **
00004 ** This file is part of Qt Designer.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00012 ** licenses may use this file in accordance with the Qt Commercial License
00013 ** Agreement provided with the Software.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00020 **   information about Qt Commercial License Agreements.
00021 **
00022 ** Contact info@trolltech.com if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 #ifndef LAYOUT_H
00028 #define LAYOUT_H
00029 
00030 #include <qwidget.h>
00031 #include <qmap.h>
00032 #include <qguardedptr.h>
00033 #include <qobject.h>
00034 #include <qlayout.h>
00035 #include <qmap.h>
00036 #include <qwidgetlist.h>
00037 
00038 class FormWindow;
00039 class QPaintEvent;
00040 
00041 class Layout : public QObject
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046     Layout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
00047     virtual ~Layout() {}
00048 
00049     virtual void doLayout() = 0;
00050     virtual void undoLayout();
00051     virtual void breakLayout();
00052     virtual bool prepareLayout( bool &needMove, bool &needReparent );
00053     virtual void finishLayout( bool needMove, QLayout *layout );
00054 
00055 protected:
00056     QWidgetList widgets;
00057     QWidget *parent;
00058     QPoint startPoint;
00059     QMap<QGuardedPtr<QWidget>, QRect> geometries;
00060     QWidget *layoutBase;
00061     FormWindow *formWindow;
00062     QRect oldGeometry;
00063     bool isBreak;
00064     bool useSplitter;
00065 
00066 protected:
00067     virtual void setup();
00068 
00069 protected slots:
00070     void widgetDestroyed();
00071 
00072 };
00073 
00074 class HorizontalLayout : public Layout
00075 {
00076 public:
00077     HorizontalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
00078 
00079     void doLayout();
00080 
00081 protected:
00082     void setup();
00083 
00084 };
00085 
00086 class VerticalLayout : public Layout
00087 {
00088 public:
00089     VerticalLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, bool doSetup = TRUE, bool splitter = FALSE );
00090 
00091     void doLayout();
00092 
00093 protected:
00094     void setup();
00095 
00096 };
00097 
00098 class Grid;
00099 
00100 class GridLayout : public Layout
00101 {
00102 public:
00103     GridLayout( const QWidgetList &wl, QWidget *p, FormWindow *fw, QWidget *lb, const QSize &res, bool doSetup = TRUE );
00104     ~GridLayout();
00105 
00106     void doLayout();
00107 
00108 protected:
00109     void setup();
00110 
00111 protected:
00112     void buildGrid();
00113     QSize resolution;
00114     Grid* grid;
00115 
00116 };
00117 
00118 class Spacer : public QWidget
00119 {
00120     Q_OBJECT
00121 
00122     Q_OVERRIDE( QCString name )
00123     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
00124     Q_ENUMS( SizeType )
00125     Q_PROPERTY( SizeType sizeType READ sizeType WRITE setSizeType )
00126     Q_PROPERTY( QSize sizeHint READ sizeHint WRITE setSizeHint DESIGNABLE true STORED true )
00127     Q_OVERRIDE( QRect geometry DESIGNABLE false )
00128 
00129 private:
00130     enum { HSize = 6, HMask = 0x3f, VMask = HMask << HSize,
00131            MayGrow = 1, ExpMask = 2, MayShrink = 4 };
00132 
00133 public:
00134     enum SizeType { Fixed = 0,
00135                     Minimum = MayGrow,
00136                     Maximum = MayShrink,
00137                     Preferred = MayGrow|MayShrink ,
00138                     MinimumExpanding = Minimum|ExpMask,
00139                     Expanding = MinimumExpanding|MayShrink };
00140 
00141     Spacer( QWidget *parent, const char *name );
00142 
00143     QSize minimumSize() const;
00144     QSize sizeHint() const;
00145     void setSizeType( SizeType t );
00146     SizeType sizeType() const;
00147     int alignment() const;
00148     Orientation orientation() const;
00149     void setOrientation( Orientation o );
00150     void setInteraciveMode( bool b ) { interactive = b; };
00151     void setSizeHint( const QSize &s );
00152 
00153 protected:
00154     void paintEvent( QPaintEvent *e );
00155     void resizeEvent( QResizeEvent* e );
00156     void updateMask();
00157     Qt::Orientation orient;
00158     bool interactive;
00159     QSize sh;
00160 };
00161 
00162 class QDesignerGridLayout : public QGridLayout
00163 {
00164    Q_OBJECT
00165 public:
00166     QDesignerGridLayout( QWidget *parent ) : QGridLayout( parent ){};
00167     QDesignerGridLayout( QLayout *parentLayout ) : QGridLayout( parentLayout ){};
00168 
00169     void addWidget( QWidget *, int row, int col, int align = 0 );
00170     void addMultiCellWidget( QWidget *, int fromRow, int toRow,
00171                                int fromCol, int toCol, int align = 0 );
00172 
00173     struct Item
00174     {
00175         Item(): row(0), column(0),rowspan(1),colspan(1){}
00176         Item( int r, int c, int rs, int cs): row(r), column(c), rowspan(rs), colspan(cs){}
00177         int row;
00178         int column;
00179         int rowspan;
00180         int colspan;
00181         Q_DUMMY_COMPARISON_OPERATOR( Item )
00182     };
00183 
00184     QMap<QWidget*, Item> items;
00185 };
00186 
00187 
00188 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'