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

sublime

ideal.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_IDEAL_H
00023 #define SUBLIME_IDEAL_H
00024 
00025 #include <QtGui>
00026 
00027 #include "ideallayout.h"
00028 #include "sublimedefs.h"
00029 
00030 class KAction;
00031 class KActionMenu;
00032 class KActionCollection;
00033 
00034 namespace Sublime {
00035 
00036 class Area;
00037 class View;
00038 class MainWindow;
00039 
00040 class IdealToolButton: public QToolButton
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045     IdealToolButton(Qt::DockWidgetArea area, QWidget *parent = 0);
00046 
00047     Qt::Orientation orientation() const;
00048 
00049     virtual QSize sizeHint() const;
00050 
00051 protected:
00052     virtual void paintEvent(QPaintEvent *event);
00053 
00054 private:
00055     Qt::DockWidgetArea _area;
00056 };
00057 
00058 class IdealDockWidgetButton: public QToolButton
00059 {
00060     Q_OBJECT
00061 
00062 public:
00063     IdealDockWidgetButton(QWidget *parent = 0);
00064     virtual ~IdealDockWidgetButton();
00065 
00066     QSize sizeHint() const;
00067     QSize minimumSizeHint() const;
00068 
00069 protected:
00070     virtual void enterEvent(QEvent *event);
00071     virtual void leaveEvent(QEvent *event);
00072     virtual void paintEvent(QPaintEvent *event);
00073 };
00074 
00075 
00076 class IdealButtonBarWidget: public QWidget
00077 {
00078     Q_OBJECT
00079 
00080 public:
00081     IdealButtonBarWidget(Qt::DockWidgetArea area, class IdealMainWidget *parent = 0);
00082 
00083     KAction *addWidget(const QString& title, IdealDockWidget *widget,
00084                        Area* area, View *view);
00085     void showWidget(IdealDockWidget* widget);
00086     void removeAction(QAction* action);
00087 
00088     IdealMainWidget* parentWidget() const;
00089 
00090     Qt::Orientation orientation() const;
00091 
00092     IdealDockWidget* widgetForAction(QAction* action) const;
00093 
00094 private Q_SLOTS:
00095     void showWidget(bool checked);
00096     void anchor(bool anchor);
00097     void maximize(bool maximized);
00098     void actionToggled(bool state);
00099 
00100 protected:
00101     virtual void actionEvent(QActionEvent *event);
00102 
00103 private:
00104     Qt::DockWidgetArea _area;
00105     QHash<QAction *, IdealToolButton *> _buttons;
00106     QHash<QAction *, IdealDockWidget*> _widgets;
00107     QActionGroup* _actions;
00108 };
00109 
00110 class IdealDockWidget : public QDockWidget
00111 {
00112     Q_OBJECT
00113 
00114 public:
00115     IdealDockWidget(QWidget *parent);
00116     virtual ~IdealDockWidget();
00117 
00118     Area *area() const;
00119     void setArea(Area *area);
00120 
00121     View *view() const;
00122     void setView(View *view);
00123 
00124     Qt::DockWidgetArea dockWidgetArea() const;
00125     void setDockWidgetArea(Qt::DockWidgetArea dockingArea);
00126 
00127     bool isAnchored() const;
00128     void setAnchored(bool anchored, bool emitSignals);
00129 
00130     bool isMaximized() const;
00131     void setMaximized(bool maximized);
00132 
00133     virtual bool event(QEvent *event);
00134 
00135 protected: // QWidget overrides
00136     virtual void contextMenuEvent(QContextMenuEvent *);
00137     virtual void mouseDoubleClickEvent(QMouseEvent *event);
00138 
00139 Q_SIGNALS:
00140     void anchor(bool anchor);
00141     void maximize(bool maximize);
00142     void close();
00143 
00144 private Q_SLOTS:
00145     void slotMaximize(bool maximized);
00146     void slotRemove();
00147 
00148 private:
00149     Qt::Orientation m_orientation;
00150     QAbstractButton* m_anchor;
00151     QAbstractButton* m_close;
00152     Area *m_area;
00153     View *m_view;
00154     Qt::DockWidgetArea m_docking_area;
00155     bool m_maximized;
00156 };
00157 
00158 class View;
00159 
00160 class IdealMainWidget : public QWidget
00161 {
00162     Q_OBJECT
00163 
00164 public:
00165     IdealMainWidget(MainWindow* parent, KActionCollection* ac);
00166 
00167     // Public api
00168     void setCentralWidget(QWidget* widget);
00169     QAction* actionForView(View* view) const;
00170     void addView(Qt::DockWidgetArea area, View* View);
00171     void raiseView(View* view);
00175     void removeView(View* view, bool nondestructive = false);
00176     void moveView(View *view, Qt::DockWidgetArea area);
00177 
00178     // Internal api
00179 
00180     // TODO can move the object filter here with judicious focusProxy?
00181     void centralWidgetFocused();
00182 
00183     void showDockWidget(IdealDockWidget* widget, bool show);
00184     void showDock(IdealMainLayout::Role role, bool show);
00185 
00186     void anchorDockWidget(IdealDockWidget* widget, bool anchor);
00187 
00188     IdealMainLayout* mainLayout() const;
00189 
00190     void anchorDockWidget(bool checked, IdealButtonBarWidget* bar);
00191     void maximizeDockWidget(bool checked, IdealButtonBarWidget* bar);
00192 
00193     QWidget* firstWidget(IdealMainLayout::Role role) const;
00194 
00195     IdealButtonBarWidget* barForRole(IdealMainLayout::Role role) const;
00196     IdealMainLayout::Role roleForBar(IdealButtonBarWidget* bar) const;
00197     KAction* actionForRole(IdealMainLayout::Role role) const;
00198 
00199     void setAnchorActionStatus(bool checked);
00200     void setMaximizeActionStatus(bool checked);
00201     void setShowDockStatus(IdealMainLayout::Role role, bool checked);
00202 
00203 Q_SIGNALS:
00204     void dockShown(Sublime::View*, Sublime::Position pos, bool shown);
00205 
00206 public Q_SLOTS:
00207     void showLeftDock(bool show);
00208     void showRightDock(bool show);
00209     void showBottomDock(bool show);
00210     void showTopDock(bool show);
00211     void toggleDocksShown();
00212     void focusEditor();
00213     void anchorCurrentDock(bool anchor);
00214     void maximizeCurrentDock(bool maximized);
00215     void selectNextDock();
00216     void selectPreviousDock();
00217     void removeView();
00218 
00219 private:
00220     // helpers for toggleDocksShown
00221     bool allDocksHidden();
00222     bool someDockMaximized();
00223     void restorePreviouslyShownDocks();
00224     void hideAllShownDocks();
00225 
00226 private:
00227     IdealButtonBarWidget *leftBarWidget;
00228     IdealButtonBarWidget *rightBarWidget;
00229     IdealButtonBarWidget *bottomBarWidget;
00230     IdealButtonBarWidget *topBarWidget;
00231 
00232     KAction* m_showLeftDock;
00233     KAction* m_showRightDock;
00234     KAction* m_showBottomDock;
00235     KAction* m_showTopDock;
00236     KAction* m_anchorCurrentDock;
00237     KAction* m_maximizeCurrentDock;
00238     KActionMenu* m_docks;
00239 
00240     class IdealMainLayout* m_mainLayout;
00241 
00242     QMap<IdealDockWidget*, Qt::DockWidgetArea> docks;
00245     QMap<View*, QAction*> m_view_to_action;
00248     QMap<IdealDockWidget*, QAction*> m_dockwidget_to_action;
00249 
00250     bool m_centralWidgetFocusing;
00251 
00253     QList<View*> m_previouslyShownDocks;
00254     bool m_switchingDocksShown;
00255 };
00256 
00257 class IdealSplitterHandle : public QWidget
00258 {
00259     Q_OBJECT
00260 
00261 public:
00262     IdealSplitterHandle(Qt::Orientation orientation, QWidget* parent, IdealMainLayout::Role resizeRole);
00263 
00264 Q_SIGNALS:
00265     void resize(int thickness, IdealMainLayout::Role resizeRole);
00266 
00267 protected:
00268     virtual void paintEvent(QPaintEvent* event);
00269     virtual void mouseMoveEvent(QMouseEvent* event);
00270     virtual void mousePressEvent(QMouseEvent* event);
00271 
00272 private:
00273     inline int convert(const QPoint& pos) const { return m_orientation == Qt::Horizontal ? pos.y() : pos.x(); }
00274 
00275     Qt::Orientation m_orientation;
00276     bool m_hover;
00277     int m_dragStart;
00278     IdealMainLayout::Role m_resizeRole;
00279 };
00280 
00281 }
00282 
00283 #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