void axGrid::OnPaint() { axGC* gc = GetGC(); axRect rect(GetRect()); axRect rect0(axPoint(0, 0), rect.size); gc->SetColor(_info.normal, 1.0); gc->DrawRectangle(rect0); gc->SetColor(_info.contour, 1.0); int y = 0; glLineWidth(1.0); for(int j = 0; j <= _dimension.y; j++) { int y = (double(j) / _dimension.y) * rect.size.y; gc->DrawLine(axPoint(0, y), axPoint(rect.size.x, y)); } int x = 0; for(int i = 0; i <= _dimension.x; i++) { int x = (double(i) / _dimension.x) * rect.size.x; gc->DrawLine(axPoint(x, 0), axPoint(x, rect.size.y)); } axSize element_size(1.0 / _dimension.x * rect.size.x - 1, 1.0 / _dimension.y * rect.size.y - 1); for(int j = 0;j < _dimension.y; j++) { for(int i = 0; i < _dimension.x; i++) { if(_gridElements[j][i].on) { gc->SetColor(_gridElements[j][i].color); axSize elem_size(floor((double(i+1)/ _dimension.x * rect.size.x)) - floor((double(i) / _dimension.x * rect.size.x)) - 1, 1.0 / _dimension.y * rect.size.y - 1); gc->DrawRectangle(axRect(_gridElements[j][i].position, elem_size)); } } } //_selectedElement gc->SetColor(axColor(0.0, 0.0, 1.0)); //glLineWidth(4.0); gc->DrawRectangleContour(axRect(GetPositionOfElement(_selectedElement), element_size), 2); // glLineWidth(1.0); // gc->DrawCircle(axPoint(50, 50), 10, 500); }
/* ---------------------------------------------------------------------- */ static btnode node_Make(BTREE tree, void *data) { btnode ret; ret = malloc(node_size(tree) + elem_size(tree)); if (ret) { data_copy(tree, data(tree, ret), data); parent(ret) = left(ret) = right(ret) = NULL; } return ret; }
/* convert an element to a text string */ APU_DECLARE(void) apr_xml_to_text(apr_pool_t * p, const apr_xml_elem *elem, int style, apr_array_header_t *namespaces, int *ns_map, const char **pbuf, apr_size_t *psize) { /* get the exact size, plus a null terminator */ apr_size_t size = elem_size(elem, style, namespaces, ns_map) + 1; char *s = apr_palloc(p, size); (void) write_elem(s, elem, style, namespaces, ns_map); s[size - 1] = '\0'; *pbuf = s; if (psize) *psize = size; }
static apr_size_t elem_size(const apr_xml_elem *elem, int style, apr_array_header_t *namespaces, int *ns_map) { apr_size_t size; if (style == APR_XML_X2T_FULL || style == APR_XML_X2T_FULL_NS_LANG) { const apr_xml_attr *attr; size = 0; if (style == APR_XML_X2T_FULL_NS_LANG) { int i; /* ** The outer element will contain xmlns:ns%d="%s" attributes ** and an xml:lang attribute, if applicable. */ for (i = namespaces->nelts; i--;) { /* compute size of: ' xmlns:ns%d="%s"' */ size += (9 + APR_XML_NS_LEN(i) + 2 + strlen(APR_XML_GET_URI_ITEM(namespaces, i)) + 1); } if (elem->lang != NULL) { /* compute size of: ' xml:lang="%s"' */ size += 11 + strlen(elem->lang) + 1; } } if (elem->ns == APR_XML_NS_NONE) { /* compute size of: <%s> */ size += 1 + strlen(elem->name) + 1; } else { int ns = ns_map ? ns_map[elem->ns] : elem->ns; /* compute size of: <ns%d:%s> */ size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(elem->name) + 1; } if (APR_XML_ELEM_IS_EMPTY(elem)) { /* insert a closing "/" */ size += 1; } else { /* * two of above plus "/": * <ns%d:%s> ... </ns%d:%s> * OR <%s> ... </%s> */ size = 2 * size + 1; } for (attr = elem->attr; attr; attr = attr->next) { if (attr->ns == APR_XML_NS_NONE) { /* compute size of: ' %s="%s"' */ size += 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1; } else { /* compute size of: ' ns%d:%s="%s"' */ int ns = ns_map ? ns_map[attr->ns] : attr->ns; size += 3 + APR_XML_NS_LEN(ns) + 1 + strlen(attr->name) + 2 + strlen(attr->value) + 1; } } /* ** If the element has an xml:lang value that is *different* from ** its parent, then add the thing in: ' xml:lang="%s"'. ** ** NOTE: we take advantage of the pointer equality established by ** the parsing for "inheriting" the xml:lang values from parents. */ if (elem->lang != NULL && (elem->parent == NULL || elem->lang != elem->parent->lang)) { size += 11 + strlen(elem->lang) + 1; } } else if (style == APR_XML_X2T_LANG_INNER) { /* * This style prepends the xml:lang value plus a null terminator. * If a lang value is not present, then we insert a null term. */ size = elem->lang ? strlen(elem->lang) + 1 : 1; } else size = 0; size += text_size(elem->first_cdata.first); for (elem = elem->first_child; elem; elem = elem->next) { /* the size of the child element plus the CDATA that follows it */ size += (elem_size(elem, APR_XML_X2T_FULL, NULL, ns_map) + text_size(elem->following_cdata.first)); } return size; }