// Updates the position of the document based on the style properties. void ElementDocument::UpdatePosition() { // We are only positioned relative to our parent, so if we're not parented we may as well bail now. if (GetParentNode() == NULL) return; Vector2f position; // Work out our containing block; relative offsets are calculated against it. Vector2f containing_block = GetParentNode()->GetBox().GetSize(Box::CONTENT); const Property *left = GetLocalProperty(LEFT); const Property *right = GetLocalProperty(RIGHT); if (left != NULL && left->unit != Property::KEYWORD) position.x = ResolveProperty(LEFT, containing_block.x); else if (right != NULL && right->unit != Property::KEYWORD) position.x = (containing_block.x - GetBox().GetSize(Box::MARGIN).x) - ResolveProperty(RIGHT, containing_block.x); else position.x = GetBox().GetEdge(Box::MARGIN, Box::LEFT); const Property *top = GetLocalProperty(TOP); const Property *bottom = GetLocalProperty(BOTTOM); if (top != NULL && top->unit != Property::KEYWORD) position.y = ResolveProperty(TOP, containing_block.y); else if (bottom != NULL && bottom->unit != Property::KEYWORD) position.y = (containing_block.y - GetBox().GetSize(Box::MARGIN).y) - ResolveProperty(BOTTOM, containing_block.y); else position.y = GetBox().GetEdge(Box::MARGIN, Box::TOP); SetOffset(position, NULL); }
void EParticlesObject::OnFrame() { inherited::OnFrame(); Fbox bb; GetBox(bb); if (::Render->occ_visible(bb)) if (m_Particles) m_Particles->OnFrame(Device.dwTimeDelta); }
// Lays out, sizes, and positions all absolute elements in this block relative to the containing block. void LayoutBlockBox::CloseAbsoluteElements() { if (!absolute_elements.empty()) { // The size of the containing box, including the padding. This is used to resolve relative offsets. Vector2f containing_block = GetBox().GetSize(Box::PADDING); for (size_t i = 0; i < absolute_elements.size(); i++) { Element* absolute_element = absolute_elements[i].element; Vector2f absolute_position = absolute_elements[i].position; absolute_position -= position - offset_root->GetPosition(); // Lay out the element. LayoutEngine layout_engine; layout_engine.FormatElement(absolute_element, containing_block); // Now that the element's box has been built, we can offset the position we determined was appropriate for // it by the element's margin. This is necessary because the coordinate system for the box begins at the // border, not the margin. absolute_position.x += absolute_element->GetBox().GetEdge(Box::MARGIN, Box::LEFT); absolute_position.y += absolute_element->GetBox().GetEdge(Box::MARGIN, Box::TOP); // Set the offset of the element; the element itself will take care of any RCSS-defined positional offsets. absolute_element->SetOffset(absolute_position, element); } absolute_elements.clear(); } }
void Get_Object(unsigned int X, unsigned int Y) { cimage_order = -1; box_order = -1; // CImages for ( _object_count = 0 ; _object_count < CurrentScreen->CImagesCount ; _object_count++ ) { local_cimage = GetCImage(_object_count); if (local_cimage->Active == 1) { if (IsInsideObject(X, Y, local_cimage->Left, local_cimage->Top, local_cimage->Width, local_cimage->Height) == 1) { cimage_order = local_cimage->Order; exec_cimage = local_cimage; } } } // Boxes for ( _object_count = 0 ; _object_count < CurrentScreen->BoxesCount ; _object_count++ ) { local_box = GetBox(_object_count); if (local_box->Active == 1) { if (IsInsideObject(X, Y, local_box->Left, local_box->Top, local_box->Width, local_box->Height) == 1) { box_order = local_box->Order; exec_box = local_box; } } } _object_count = -1; if (cimage_order > _object_count ) _object_count = cimage_order; if (box_order > _object_count ) _object_count = box_order; }
void PictSelection::WriteComments (ostream& to) { to << "%!PS-Adobe-2.0 EPSF-1.2\n"; to << "%%DocumentFonts:"; int linelen = strlen("%%DocumentFonts:"); const int MAXLINELEN = 256; IFontList* fontlist = new IFontList; CollectFonts(fontlist); for (fontlist->First(); !fontlist->AtEnd(); fontlist->Next()) { IFont* font = fontlist->GetCur()->GetFont(); if (linelen + strlen(font->GetPrintFont()) + 2 <= MAXLINELEN) { to << " "; ++linelen; } else { to << "\n%%+ "; linelen = strlen("%%+ "); } to << font->GetPrintFont(); linelen += strlen(font->GetPrintFont()); } to << "\n"; delete fontlist; to << "%%Pages: 1\n"; Coord l, b, r, t; GetBox(l, b, r, t); to << "%%BoundingBox: " << l << " " << b << " " << r << " " << t << "\n"; to << "%%EndComments\n\n"; to << "50 dict begin\n\n"; }
void CBoxHolder::Serialize(CArchive &ar) { CBox* box=NULL; int n; CString st; CObject::Serialize(ar); if (ar.IsStoring()){ n=m_Children.GetSize(); ar << n; for (int i=0; i<n; i++){ box=GetBox(i); st=box->Signature(); if (st=="") st=box->ClassName(); TRACE("Serialize Class Name: %s\n", st); ar << st; box->Serialize(ar); } } else{ ar >> n; for (int i=0; i<n; i++){ ar >> st; box=CFactory::instance(st); if (box==NULL) AfxThrowArchiveException(CArchiveException::generic,""); box->Serialize(ar); AddBox(box); } } }
void EditBoxCollection::track_cancel() { for(int i = 0; i < Count(); i++) { GetBox(i)->track_cancel(); } }
void * DropDown::GetItemData(INT32 ItemIndex) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return NULL; return m_pPopup->GetItemClientData(ItemIndex); }
CLuaImage::CLuaImage(const char *file) : CBaseLuaWidget(""), m_bHasImage(false) { m_pPixBuf = gdk_pixbuf_new_from_file(file, NULL); if (m_pPixBuf) { int w = gdk_pixbuf_get_width(m_pPixBuf); int h = gdk_pixbuf_get_height(m_pPixBuf); int neww, newh; if ((w > MaxImageW()) || (h > MaxImageH())) { GetScaledImageSize(w, h, MaxImageW(), MaxImageH(), neww, newh); GdkPixbuf *tmp = gdk_pixbuf_scale_simple(m_pPixBuf, neww, newh, GDK_INTERP_BILINEAR); g_object_unref(m_pPixBuf); m_pPixBuf = tmp; } if (m_pPixBuf) { GtkWidget *img = gtk_image_new_from_pixbuf(m_pPixBuf); g_object_unref(m_pPixBuf); gtk_widget_show(img); gtk_container_add(GTK_CONTAINER(GetBox()), img); m_bHasImage = true; } } }
INT32 DropDown::GetNumberOfItems(void) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return 0; return((INT32)pGadget->GetCount()); }
boolean FillPolygonObj::Intersects (BoxObj& ub) { BoxObj b; GetBox(b); if (!b.Intersects(ub)) { return false; } if (b.Within(ub)) { return true; } LineObj bottom(ub._left, ub._bottom, ub._right, ub._bottom); if (Intersects(bottom)) { return true; } LineObj right(ub._right, ub._bottom, ub._right, ub._top); if (Intersects(right)) { return true; } LineObj top(ub._right, ub._top, ub._left, ub._top); if (Intersects(top)) { return true; } LineObj left(ub._left, ub._top, ub._left, ub._bottom); return Intersects(left); }
// This function adds an object to an existing bounding volume hierarchy. // It first constructs a bounding box for the new object, then finds the // optimal place to insert it into the hierachy using branch-and-bound, and // finally inserts it at the determined location, updating all the costs // associated with the nodes in the hierarchy as a side-effect. void abvh::Insert( const Object *obj, double relative_cost ) { AABB box( GetBox( *obj ) ); double bound = 0.0; node *n = new node; n->bbox = box; n->object = obj; n->SA = SurfaceArea( box ); n->EC = 1.0; n->SEC_ = relative_cost; n->AIC = relative_cost * n->SA; n->SAIC = 0.0; // There are no child volumes yet. // If this is the first node being added to the hierarchy, // it becomes the root. if( root == NULL ) { root = n; return; } // Look for the optimal place to add the new node. // The branch-and-bound procedure will figure out where // to put it so as to cause the smallest increase in the // estimated cost of the tree. bound = Infinity; node *insert_here = NULL; Branch_and_Bound( root, n, insert_here, bound ); // Now actually insert the node in the optimal place. insert_here->AddChild( n ); }
void DropDown::ClearList(void) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return; pGadget->Clear(); }
void DropDown::SetSelectedIndex(INT32 SelectedIndex) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return; pGadget->SetSelection(SelectedIndex); // And set the appropriate selected item }
void ElementImage::GenerateGeometry() { // Release the old geometry before specifying the new vertices. geometry.Release(true); std::vector< Rocket::Core::Vertex >& vertices = geometry.GetVertices(); std::vector< int >& indices = geometry.GetIndices(); vertices.resize(4); indices.resize(6); // Generate the texture coordinates. Vector2f texcoords[2]; if (using_coords) { Vector2f texture_dimensions((float) texture.GetDimensions(GetRenderInterface()).x, (float) texture.GetDimensions(GetRenderInterface()).y); if (texture_dimensions.x == 0) texture_dimensions.x = 1; if (texture_dimensions.y == 0) texture_dimensions.y = 1; texcoords[0].x = (float) coords[0] / texture_dimensions.x; texcoords[0].y = (float) coords[1] / texture_dimensions.y; texcoords[1].x = (float) coords[2] / texture_dimensions.x; texcoords[1].y = (float) coords[3] / texture_dimensions.y; } else { texcoords[0] = Vector2f(0, 0); texcoords[1] = Vector2f(1, 1); } const Property* element_colour = GetProperty(BACKGROUND_COLOR); float opacity = GetProperty<float>(OPACITY); Colourb quad_colour = Colourb(255, 255, 255); if (element_colour) { Colourb background_colour = element_colour->Get<Colourb>(); // Should be a non-transparent background if (background_colour.alpha != 0) quad_colour = background_colour; } // Apply opacity quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha); Rocket::Core::GeometryUtilities::GenerateQuad(&vertices[0], // vertices to write to &indices[0], // indices to write to Vector2f(0, 0), // origin of the quad GetBox().GetSize(Rocket::Core::Box::CONTENT), // size of the quad quad_colour, // colour of the vertices texcoords[0], // top-left texture coordinate texcoords[1]); // top-right texture coordinate geometry_dirty = false; }
static errcode GetObject(FILE * dfile, SceneHandle scene) { char objtype[80]; fscanf(dfile, "%s", objtype); if (!stringcmp(objtype, "END_SCENE")) { return PARSEEOF; /* end parsing */ } if (!stringcmp(objtype, "TEXDEF")) { return GetTexDef(dfile); } if (!stringcmp(objtype, "TEXALIAS")) { return GetTexAlias(dfile); } if (!stringcmp(objtype, "BACKGROUND")) { return GetBackGnd(dfile); } if (!stringcmp(objtype, "CYLINDER")) { return GetCylinder(dfile); } if (!stringcmp(objtype, "FCYLINDER")) { return GetFCylinder(dfile); } if (!stringcmp(objtype, "POLYCYLINDER")) { return GetPolyCylinder(dfile); } if (!stringcmp(objtype, "SPHERE")) { return GetSphere(dfile); } if (!stringcmp(objtype, "PLANE")) { return GetPlane(dfile); } if (!stringcmp(objtype, "RING")) { return GetRing(dfile); } if (!stringcmp(objtype, "BOX")) { return GetBox(dfile); } if (!stringcmp(objtype, "SCALARVOL")) { return GetVol(dfile); } if (!stringcmp(objtype, "TRI")) { return GetTri(dfile); } if (!stringcmp(objtype, "STRI")) { return GetSTri(dfile); } if (!stringcmp(objtype, "LIGHT")) { return GetLight(dfile); } if (!stringcmp(objtype, "SCAPE")) { return GetLandScape(dfile); } if (!stringcmp(objtype, "TPOLYFILE")) { return GetTPolyFile(dfile); } fprintf(stderr, "Found bad token: %s expected an object type\n", objtype); return PARSEBADSYNTAX; }
bool LLRegion::IntersectOut(const LLBBox &box) const { // First do faster test of bounding boxes if(GetBox().IntersectOut(box)) return true; return NoIntersection(box); }
// internal test to see if regions don't intersect (optimization) bool LLRegion::NoIntersection(const LLRegion& region) const { if(Empty() || region.Empty()) return true; LLBBox box = GetBox(), rbox = region.GetBox(); return box.IntersectOut(rbox) || NoIntersection(rbox) || region.NoIntersection(box); }
void DrawScreen(TScreen *aScreen) { unsigned int order; unsigned short rotation; unsigned short cimage_idx; TCImage *local_cimage; unsigned short box_idx; TBox *local_box; object_pressed = 0; order = 0; cimage_idx = 0; box_idx = 0; CurrentScreen = aScreen; if ((display_width != CurrentScreen->Width) || (display_height != CurrentScreen->Height)) { rotation = TFTIntern_GetDisplayRotation(); if (display_width > CurrentScreen->Width) { if (rotation == _TFT_INTERN_ROTATE_270) rotation = _TFT_INTERN_ROTATE_0; else rotation++; } else { if (rotation == _TFT_INTERN_ROTATE_0) rotation = _TFT_INTERN_ROTATE_270; else rotation--; } TFTIntern_SetDisplayRotation(rotation); TSC2006_SetDisplaySize(CurrentScreen->Width, CurrentScreen->Height); TFTIntern_Fill_Screen(CurrentScreen->Color); display_width = CurrentScreen->Width; display_height = CurrentScreen->Height; } else TFTIntern_Fill_Screen(CurrentScreen->Color); while (order < CurrentScreen->ObjectsCount) { if (box_idx < CurrentScreen->BoxesCount) { local_box = GetBox(box_idx); if (order == local_box->Order) { box_idx++; order++; DrawBox(local_box); } } if (cimage_idx < CurrentScreen->CImagesCount) { local_cimage = GetCImage(cimage_idx); if (order == local_cimage->Order) { cimage_idx++; order++; DrawCImage(local_cimage); } } } }
void DropDown::AddItem(void * ItemData) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return; INT32 n=pGadget->Append(wxEmptyString); // put in an empty string first m_pPopup->SetItemClientData(n, ItemData, wxClientData_Void); if (ItemData) pGadget->SetString(n, GetText(ItemData, n)); }
CString CBoxHolder::ToMathML() { int i; CString tab=""; CString st; BOOL bObmit=(GetChildrenCount()==1 && GetBox(0)->ClassName()!="MSymbol"); if (!bObmit) st=tab + "<mrow>" + crlf; else st=""; for (i=0; i<GetChildrenCount(); i++) if (!bObmit) st+=GetBox(i)->ToMathML(1) + crlf; else st+=GetBox(i)->ToMathML(0); if (!bObmit) st+=tab + "</mrow>"; return st; }
void DropDown::SetListRedraw(BOOL Enable) { wxOwnerDrawnComboBox * pGadget = GetBox(); if (!pGadget) return; if (Enable) pGadget->Thaw(); else pGadget->Freeze(); }
void CGutsRockmanBullet::Update(CTimer* gameTime) { if (!_isAtFirst) { if (_master->_isThrowRock||_master->_currentSkill!=Skill::GUTS) { if (_master->_currentSkill == Skill::GUTS) { _master->_canFire = true; _spriteStatus = ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL; _sprite = ResourceManager::GetSprite(_spriteStatus); } D3DXVECTOR2 v = D3DXVECTOR2(135.0f / 1000.0f, 5.0f / 1000.0f); if (!_master->_isRight) v.x *= -1.0f; CBulletRockman *bullet1 = new CBulletRockman(v + D3DXVECTOR2(48.0f / 1000.0f, 5.0f / 1000.0f), _position + D3DXVECTOR2(-8, 8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet2 = new CBulletRockman(v + D3DXVECTOR2(32.0f / 1000.0f, 10.0f / 1000.0f), _position + D3DXVECTOR2(8, 8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet3 = new CBulletRockman(v + D3DXVECTOR2(16.0f / 1000.0f, 0.0f / 1000.0f), _position + D3DXVECTOR2(-8, -8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); CBulletRockman *bullet4 = new CBulletRockman(v + D3DXVECTOR2(8.0f / 1000.0f, 5.0f), _position + D3DXVECTOR2(8, -8), ID_BULLET_ROCKMAN_GUTS, ResourceManager::GetSprite(ID_SPRITE_BULLET_ROCKMAN_GUTS_SMALL), DAME_BULLET_GUTS_ROCKMAN); _master->_bullets.push_back(bullet1); _master->_bullets.push_back(bullet2); _master->_bullets.push_back(bullet3); _master->_bullets.push_back(bullet4); Die(); } _position = _master->_position + D3DXVECTOR2(0, _master->GetBox()._height / 2 + GetBox()._height / 2); } else { _deltaTime += gameTime->GetTime(); if (_deltaTime >= 50) { _isAtFirst = false; _deltaTime = 0; _position = _master->_position + D3DXVECTOR2(0, _master->GetBox()._height / 2 + GetBox()._height / 2); } } UpdateBox(); }
void EditBoxCollection::select(EditBox* new_box) { for(int i = 0; i < Count(); i++) { if(new_box == GetBox(i)) { select(i); break; } } }
EditBox* EditBoxCollection::locate(int num) { for(int i = 0; i < Count(); i++) { if(GetBox(i)->number() == num) { select(i); break; } } return current(); }
bool CGroupObject::FrustumPick(const CFrustum& frustum) { if (m_Objects.empty()){ Fbox bb; GetBox (bb); u32 mask = u32(-1); return (frustum.testAABB(bb.data(),mask)); }else{ for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) if ((*it)->FrustumPick(frustum)) return true; } return false; }
void EParticlesObject::Render(int priority, bool strictB2F) { inherited::Render(priority,strictB2F); Fbox bb; GetBox(bb); if (::Render->occ_visible(bb)){ RCache.set_xform_world(Fidentity); if (1==priority){ if (false==strictB2F){ // draw emitter Device.SetShader(Device.m_WireShader); DU.DrawCross (PPosition,0.20f,0.25f,0.20f,0.20f,0.25f,0.20f,0xFFFFEBAA,false); // DU.DrawLineSphere(PPosition, PSOBJECT_SIZE/10, C, true); if( Selected() ){ Fbox bb; GetBox(bb); u32 clr = Locked()?0xFFFF0000:0xFFFFFFFF; DU.DrawSelectionBox(bb,&clr); } } } if (m_Particles) ::Render->model_Render(m_Particles,_Transform(),priority,strictB2F,1.f); } }
void OcTree::BuildTree(OctNode* node, int trisPerNode, const TRI* tris, int triCount) { // if the node has more than threshold number of triangles, create children if (node->TriIdxCount > trisPerNode) { for (int i = 0; i < NUM_CHILDREN; i++) { OctNode TIKI_NEWNode; // Set this node's child pointer. node->ChildIdx[i] = OctNodeList.GetCount(); // partition the TIKI_NEW box for the child. TIKI_NEWNode.BBox = engine->librarys->CreateResource<IBoundingBox>(); GetBox(node->BBox, TIKI_NEWNode.BBox, i); // Initialize fields for (int j = 0; j < NUM_CHILDREN; j++) TIKI_NEWNode.ChildIdx[i] = NULL_NODE; for (int j = 0; j < NUM_NEIGHBORS; j++) TIKI_NEWNode.NeighborIdx[i] = NULL_NODE; // See which of the parent's triangles lie within the TIKI_NEW node. TIKI_NEWNode.TriIdxCount = 0; TIKI_NEWNode.TriIdxStart = TriIdxList.GetCount(); TriIdxList.PositionAt(node->TriIdxStart); for (int j = 0; j < node->TriIdxCount; j++) { unsigned int* TriIdx = (unsigned int*)TriIdxList.GetCurrent(); const TRI* Tri = &tris[*TriIdx]; if (TriBoxIntersect(TIKI_NEWNode.BBox, *Tri) == INSIDE) { TriIdxList.Append(TriIdx, sizeof(unsigned int)); TIKI_NEWNode.TriIdxCount++; } // if TriIdxList.Advance(); } // for (j) // Add the TIKI_NEW node ad recurse on its children OctNodeList.Append(&TIKI_NEWNode, sizeof(OctNode)); BuildTree((OctNode*)OctNodeList.GetLast(), trisPerNode, tris, triCount); } // for (i) } // if }
wxBitmap wxRegion::ConvertToBitmap() const { wxRect box = GetBox(); wxBitmap bmp(box.GetRight(), box.GetBottom()); wxMemoryDC dc; dc.SelectObject(bmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); dc.SetClippingRegion(*this); dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); return bmp; }
wxBitmap wxRegionBase::ConvertToBitmap() const { wxRect box = GetBox(); wxBitmap bmp(box.GetWidth(), box.GetHeight()); wxMemoryDC dc; dc.SelectObject(bmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); dc.SetDeviceClippingRegion(*static_cast<const wxRegion *>(this)); dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); return bmp; }