1 // Copyright (c) 2012 Dennco Project
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // Created by tkawata on Sep-30, 2012.
22 #include "dcvcomponent.h"
24 class DCVPageComponent;
27 class DCVCPage : public DCVComponent
29 QString d_locationPath;
33 bool d_shouldUpdateShape;
39 QList<DCVPageComponent*> d_cells;
40 QList<DCVPageComponent*> d_cellCodeClasses;
42 DCVPageComponent *d_editCursor;
47 DCVCPage(const QString &locationPath);
50 virtual DCVCPage * getPageBelonging() const { return const_cast<DCVCPage*>(this);}
51 virtual DCCell* getOwnerCell() const { return NULL; }
52 virtual DCVVisibility getIsVisible() const { return d_colorA == 0 ? DCV_VISIBLE_NONE : DCVComponent::getIsVisible(); }
53 virtual bool isResizingArea(float x, float y, float z) const { return false; }
54 QString getLocationPath() const { return d_locationPath; }
55 bool getIsModified(DCContainer *container) const;
57 const QList<DCVPageComponent*>* getCells() const { return &d_cells; }
58 const QList<DCVPageComponent*>* getCellCodeClasses() const { return &d_cellCodeClasses; }
60 // register / unregister cell to this page.
61 // They are called from DCVCCell.
62 // Other classes shouldn't call this directly.
63 // To change the page a cell belonging,
64 // DCMoveCellCommand() should be used instead.
65 void registerCell(DCVPageComponent *cell);
66 void unregisterCell(DCVPageComponent *cell);
68 // register / unregister cellcode to this page.
69 // They are called from DCVCCellCode.
70 // Other classes shouldn't call this directly.
71 // To change the page a cell code class belonging,
72 // DCMoveCellCodeClassCommand should be used instead.
73 void registerCellCodeClass(DCVPageComponent *cellCodeClass);
74 void unregisterCellCodeClass(DCVPageComponent *cellCodeClass);
76 // register / unregister cellcode to this page.
77 // They are called from DCVCEditModeCursor.
78 // Other classes shouldn't call this directly.
79 // To change the page a cell code class belonging,
80 // DCVCEditModeCursor::changePageBelonging() should be called instead.
81 void registerEditCursor(DCVPageComponent *ecursor);
82 void unregisterEditCursor();
85 * @brief Move cells and cell codes belong to this page to newPage.
86 * @param newPage : the target page cells and cell codes are moving into.
88 * This will move cells, cell codes and connections belong to this page to the page passed in the parameter.
89 * This expected to be called from DCContainer.
90 * This shouldn't be called directly.
91 * To change the path / file name for a container file, DCMovePageCommand should be used.
93 * @return true for succuss, false for failure.
95 bool moveComponentsTo(DCVCPage *newPage);
97 void updateVisiblity(bool linkedCellVisible, bool linkedCellRenderFull, bool linkedCellSelectable, bool otherCellVisible, bool otherCellRenderFull, bool otherCellSelectable);
99 virtual void prepareChildrenForDraw(bool isAnimationInterval);
100 virtual void drawChildren(bool isAnimationInterval);
101 virtual void drawChildrenForSelection(QList<DCVComponent*> *itemList);
102 virtual void translate();
103 virtual void setSelected(bool selected, bool updateChildren);
104 virtual void setVisible(DCVVisibility visibleSelf, DCVVisibility visibleChildren);
105 virtual void renderOwnShape(bool isAnimationInterval, bool renderAsWireframe);
107 virtual bool startDrag(float x, float y, float z, bool isResizingDrag);
108 virtual bool dragging(float x, float y, float z, bool isResizingDrag);
109 virtual bool endDrag(float x, float y, float z, bool isResizingDrag);
110 virtual void updateShape() {}
112 virtual void saveAttributesToXML(QDomDocument *document, QDomElement* element) const;
113 virtual void loadAttributesFromXML(QDomElement element);
115 void setHeight(float height);
116 void setWidth(float width);
117 void setDepth(float depth);
118 void setColor(float r, float g, float b, float a);
120 void updateSavedState(DCContainer *container);