MDIApplication Example

#ifndef SKETCHCHILD_H
#define SKETCHCHILD_H

#include <QtitanRibbon.h>
#include <QAbstractScrollArea>
#include "childinterface.h"

class QStatusBar;
class QCheckBox;
class SketchChildPrivate;
class GeometricTool;
class SketchDocument;

class SketchChild : public RibbonWorkspace,
                    public ChildInterface
{
    Q_OBJECT
    Q_INTERFACES(ChildInterface)
public:
    SketchChild();
    virtual ~SketchChild();
    QSize viewportSizeHint() const override;
public:
    virtual TypeDocument typeDocument() const { return td_Sketch; }
    virtual void buildUserInterface(RibbonBar* rib, QStatusBar* statusBar, RibbonPage* pageHome);
    virtual void removeUserInterface(RibbonBar* rib, QStatusBar* statusBar, RibbonPage* pageHome);

    void newFile();
    bool loadFile(const QString& fileName);
    virtual bool save();
    virtual bool saveAs();
    bool saveFile(const QString& fileName);

    virtual QString userFriendlyCurrentFile();
    virtual QString currentFile() const { return m_curFile; }

    virtual bool hasSelection() const;
    SketchDocument* document() const;
protected: // section of the ribbon
    void createActions();
    void updateActions();

    void fillRibbonSketch(RibbonBar* rib);
    void clearRibbonSketch(RibbonBar* rib);

    void createGeometryGroup(RibbonGroup* geomGroup);
    void createEditGroup();
    void clearEditGroup();
    void createGrigGroup();

    void fillStatusBarSketch(QStatusBar* statusBar);
    void clearStatusBarSketch(QStatusBar* statusBar);

    void startTool(GeometricTool& tool);
    void stopTool();
private Q_SLOTS:
    void selectionAction();
    void lineAction();
    void rectangleAction();
    void circleAction();
    void ellipseAction();
    void stateChanged(int st);
    void createObject();
    void cyclicalTool();
    void showGrid(int);
    void stepGrid(double);
protected:
    QPointF mapToScene(const QPoint& point) const;
    QPointF mapScreenToMM(const QPointF& point) const;
protected:
    virtual void closeEvent(QCloseEvent*);
    virtual void mousePressEvent(QMouseEvent*);
    virtual void mouseReleaseEvent(QMouseEvent*);
    virtual void mouseDoubleClickEvent(QMouseEvent*);
    virtual void mouseMoveEvent(QMouseEvent*);
    virtual void keyPressEvent(QKeyEvent*);
protected:
    virtual void paintEvent(QPaintEvent*);
    virtual void resizeEvent(QResizeEvent*);
private Q_SLOTS:
    void documentWasModified();
private:
    bool maybeSave();
    void setCurrentFile(const QString& fileName);
    QString strippedName(const QString& fullFileName);
protected:
    QString m_curFile;
    bool m_isUntitled;
    RibbonGroup* m_geomGridObject;
    RibbonGroup* m_geomEditObject;
    QAction* m_selectionAction;
    QAction* m_lineAction;
    QAction* m_rectangleAction;
    QAction* m_circleAction;
    QAction* m_ellipseAction;
    QAction* m_createObjectAction;
    QAction* m_stopToolAction;
    QAction* m_repeatToolAction;
    GeometricTool* m_workTool;
private:
    friend class SketchChildPrivate;
    SketchChildPrivate* m_pimpl;
};

#endif // SKETCHCHILD_H