/** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #include #include #include #include ETK_DECLARE_TYPE(ewol::widget::Gird); ewol::widget::Gird::Gird() : this.sizeRow(0), this.tmpWidget(null), this.gavityButtom(true), this.borderSize(0,0) { addObjectType("ewol::widget::Gird"); requestUpdateSize(); } ewol::widget::Gird::~Gird() { Log.debug("[" + getId() + "]={" + getObjectType() + "} Gird : destroy"); subWidgetRemoveAll(); } void ewol::widget::Gird::setBorderSize( Vector2i _newBorderSize) { this.borderSize = _newBorderSize; if (this.borderSize.x() < 0) { Log.error("Try to set a border size <0 on x : " + this.borderSize.x() + " == > restore to 0"); this.borderSize.setX(0); } if (this.borderSize.y() < 0) { Log.error("Try to set a border size <0 on y : " + this.borderSize.y() + " == > restore to 0"); this.borderSize.setY(0); } markToRedraw(); requestUpdateSize(); } void ewol::widget::Gird::onChangeSize() { //Log.debug("Update size"); this.size -= this.borderSize*2; for (int iii=0; iii lastLineID) { // change of line : lastLineID = this.subWidget[iii].row; } if (this.subWidget[iii].widget != null) { this.subWidget[iii].widget.calculateMinMaxSize(); Vector2f tmpSize = this.subWidget[iii].widget.getCalculateMinSize(); Log.debug(" [" + iii + "] subWidgetMinSize=" + tmpSize); // for all we get the max size : this.uniformSizeRow = etk::max((int)tmpSize.y(), this.uniformSizeRow); // for the colomn size : We set the autamatic value in negative : if (this.sizeCol[this.subWidget[iii].col] <= 0) { this.sizeCol[this.subWidget[iii].col] = etk::min(this.sizeCol[this.subWidget[iii].col], (int)-tmpSize.x() ); } } } if (this.sizeRow > 0) { this.uniformSizeRow = this.sizeRow; } int tmpSizeWidth = 0; for (int iii=0; iii it is not the case ==> the herited class must call the \"OnObjectRemove\" function..."); } } else { Log.warning("[" + getId() + "] Must not have null pointer on the subWidget list ..."); this.subWidget.erase(this.subWidget.begin()+iii); } errorControl = this.subWidget.size(); } } // just add the col size: this.sizeCol.erase(this.sizeCol.end()); } else { // just add the col size: for (int iii=this.sizeCol.size()-1; iii<_colNumber-1 ; iii++) { this.sizeCol.pushBack(0); } } } void ewol::widget::Gird::setColSize(int _colId, int _size) { if ((long)this.sizeCol.size() > _colId) { this.sizeCol[_colId] = _size; } else { Log.error("Can not set the Colomn size : " + _colId+1 + " at " + _size + "px we have " + this.sizeCol.size() + " colomn"); } } void ewol::widget::Gird::setRowSize(int _size) { this.sizeRow = _size; } int ewol::widget::Gird::getColSize(int _colId) { if ((long)this.sizeCol.size() > _colId) { if (this.sizeCol[_colId] <= 0) { return 0; } return this.sizeCol[_colId]; } Log.error("Can not get the Colomn size : " + _colId+1 + " we have "+ this.sizeCol.size() + " colomn"); return 0; } int ewol::widget::Gird::getRowSize() { return this.sizeRow; } void ewol::widget::Gird::subWidgetRemoveAll() { int errorControl = this.subWidget.size(); this.subWidget.clear(); } void ewol::widget::Gird::subWidgetAdd(int _colId, int _rowId, Widget _newWidget) { if (_newWidget == null) { return; } GirdProperties prop; prop.row = _rowId; prop.col = _colId; prop.widget = _newWidget; // need to find the correct position : for (int iii=0; iii prop.row) { // find a new position; this.subWidget.insert(this.subWidget.begin()+iii, prop); return; } else { if (this.subWidget[iii].col < prop.col) { continue; } else if (this.subWidget[iii].col > prop.col) { // find a new position; this.subWidget.insert(this.subWidget.begin()+iii, prop); return; } else { // The element already exist == > replace it ... this.tmpWidget = this.subWidget[iii].widget; this.subWidget[iii].widget = _newWidget; if (this.tmpWidget != null) { this.tmpWidget.reset(); if (this.tmpWidget != null) { Log.critical("[" + getId() + "] Error while replacing a widget ... == > never call when free"); this.tmpWidget = null; } } } } } // not find == > just adding it ... this.subWidget.pushBack(prop); } void ewol::widget::Gird::subWidgetRemove(Widget _newWidget) { for (int iii=0; iii= _pos.x()) LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (tmpOrigin.y() <= _pos.y() LOMLOMLOMLOMLOM tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { Widget tmpWidget = it.widget.getWidgetAtPos(_pos); if (tmpWidget != null) { return tmpWidget; } // stop searching break; } } return null; }