• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

sublime

ideallayout.h

00001 /*
00002   Copyright 2007 Roberto Raggi <roberto@kdevelop.org>
00003   Copyright 2007 Hamish Rodda <rodda@kde.org>
00004 
00005   Permission to use, copy, modify, distribute, and sell this software and its
00006   documentation for any purpose is hereby granted without fee, provided that
00007   the above copyright notice appear in all copies and that both that
00008   copyright notice and this permission notice appear in supporting
00009   documentation.
00010 
00011   The above copyright notice and this permission notice shall be included in
00012   all copies or substantial portions of the Software.
00013 
00014   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00017   KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018   AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020 */
00021 
00022 #ifndef SUBLIME_IDEALLAYOUT_H
00023 #define SUBLIME_IDEALLAYOUT_H
00024 
00025 #include <QtGui/QLayout>
00026 #include <QtCore/QPointer>
00027 #include <QtCore/QMap>
00028 #include <QtCore/QHash>
00029 
00030 #include "sublimedefs.h"
00031 
00032 class KAction;
00033 class KActionCollection;
00034 
00035 namespace Sublime {
00036 
00037 class IdealDockWidget;
00038 
00039 class IdealButtonBarLayout: public QLayout
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     IdealButtonBarLayout(Qt::Orientation orientation, QWidget *parent = 0);
00045 
00046     virtual ~IdealButtonBarLayout();
00047 
00048     void setHeight(int height);
00049 
00050     inline Qt::Orientation orientation() const;
00051 
00052     virtual Qt::Orientations expandingDirections() const;
00053 
00054     virtual QSize minimumSize() const;
00055 
00056     virtual QSize sizeHint() const;
00057 
00058     virtual void setGeometry(const QRect &rect);
00059 
00060     virtual void addItem(QLayoutItem *item);
00061 
00062     virtual QLayoutItem* itemAt(int index) const;
00063 
00064     virtual QLayoutItem* takeAt(int index);
00065 
00066     virtual int count() const;
00067 
00068     virtual void invalidate();
00069 
00070 protected:
00071     int doVerticalLayout(const QRect &rect, bool updateGeometry = true) const;
00072 
00073     int doHorizontalLayout(const QRect &rect, bool updateGeometry = true) const;
00074 
00075 private:
00076     QList<QLayoutItem *> _items;
00077     Qt::Orientation _orientation;
00078     int _height;
00079     mutable bool m_minSizeDirty : 1;
00080     mutable bool m_sizeHintDirty : 1;
00081     mutable bool m_layoutDirty : 1;
00082     mutable QSize m_min;
00083     mutable QSize m_hint;
00084 };
00085 
00086 class IdealMainLayout : public QLayout
00087 {
00088     Q_OBJECT
00089 
00090 public:
00091     enum Role {
00092         Left    ,
00093         Right   ,
00094         Bottom  ,
00095         Top     ,
00096         Central 
00097     };
00098 
00099     IdealMainLayout(QWidget *parent = 0);
00100 
00101     virtual ~IdealMainLayout();
00102 
00103     void addWidget(QWidget* widget, Role role);
00104     void addButtonBar(QWidget* widget, Role role);
00105     void removeWidgets(Role role);
00106     void removeWidget(QWidget* widget, Role role);
00107     void removeUnanchored();
00108 
00109     int splitterWidth() const;
00110     int widthForRole(Role role) const;
00111     void setWidthForRole(Role role, int width);
00112 
00113     bool isAreaAnchored(Role role) const;
00114 
00118     void maximizeWidget(QWidget* widget);
00119 
00120     virtual QSize minimumSize() const;
00121 
00122     virtual QSize sizeHint() const;
00123 
00124     virtual void setGeometry(const QRect &rect);
00125 
00126     virtual void addItem(QLayoutItem *item);
00127 
00128     virtual QLayoutItem* itemAt(int index) const;
00129 
00130     virtual QLayoutItem* takeAt(int index);
00131 
00132     virtual int count() const;
00133 
00134     virtual void invalidate();
00135 
00136     IdealDockWidget* lastDockWidget() const;
00137     IdealDockWidget* lastDockWidget(Role role) const;
00138     Role lastDockWidgetRole() const;
00139 
00140     class IdealMainWidget* mainWidget() const;
00141 
00142     static Sublime::Position positionForRole(Role role);
00143 
00144 public Q_SLOTS:
00145     void resizeWidget(int thickness, IdealMainLayout::Role role);
00146     void anchorWidget(bool anchor, IdealMainLayout::Role role);
00147 
00148     void loadSettings();
00149 
00150 Q_SIGNALS:
00151     /* Reports that a dock widget for role now occupies 'thickness'
00152        pixels from the corresponding window edge, if shown.  */
00153     void widgetResized(IdealMainLayout::Role role, int thickness);
00154 
00155 protected:
00156     using QLayout::layout;
00157 
00158     void doLayout(QRect rect) const;
00159     void layout(Role role1, Role role2, Role role3, Role role4, QRect& rect) const;
00160     void layoutItem(Role role, QRect& rect) const;
00161     void minimumSize(Role role, int& minWidth, int& softMinWidth, int& minHeight, int& softMinHeight) const;
00162 
00163 private:
00164     void createArea(Role role);
00165     class IdealSplitterHandle* createSplitter(Role role, bool reverse = false);
00166 
00167     class DockArea {
00168     public:
00169         DockArea(IdealMainLayout* layout, Role role);
00170         ~DockArea();
00171 
00172         int count() const;
00173         QLayoutItem* itemAt(int index, int& at) const;
00174 
00175         const QList<QWidgetItem*> items() const;
00176         QWidgetItem* first() const;
00177         void addWidget(QWidget* widget);
00178         void removeWidget(QWidget* widget);
00179         void removeWidgets();
00180 
00181         QWidgetItem* mainSplitter() const;
00182         void setMainSplitter(QWidget* splitter);
00183 
00184         QWidgetItem* buttonBar() const;
00185         void setButtonBar(QWidget* buttonBar);
00186         void removeButtonBar();
00187 
00188         void setVisible(bool visible, bool showMainSplitter = false, QWidget* maximizedWidget = 0);
00189         void raise();
00190 
00191         int width;
00192         bool anchored;
00193         QPointer<QWidget> last;
00194 
00195     private:
00196         void removeMainSplitter();
00197 
00198         IdealMainLayout* m_layout;
00199         Role m_role;
00200         QList<QWidgetItem*> m_items;
00201         QList<int> m_heights;
00202         QWidgetItem* m_mainSplitter;
00203         QList<QWidgetItem*> m_subSplitters;
00204         QWidgetItem* m_buttonBarItem;
00205     };
00206 
00207     QMap<Role, DockArea*> m_items;
00208     mutable bool m_layoutDirty, m_minDirty;
00209     mutable QSize m_min;
00210     int m_splitterWidth;
00211     QPointer<QWidget> m_lastDockWidget;
00212     Role m_lastDockWidgetRole;
00213     int m_topOwnsTopLeft;
00214     int m_topOwnsTopRight;
00215     int m_bottomOwnsBottomLeft;
00216     int m_bottomOwnsBottomRight;
00217     Role m_maximizedRole;
00218     QWidget* m_maximizedWidget;
00219 };
00220 
00221 IdealMainLayout::Role roleForArea(Qt::DockWidgetArea area);
00222 
00223 Qt::DockWidgetArea areaForRole(IdealMainLayout::Role role);
00224 
00225 }
00226 
00227 #endif

sublime

Skip menu "sublime"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  •     interfaces
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal