Control* ListBox::RemoveItem( int Index ) { Control* c = Controls.at(Index); Controls.erase( Controls.begin() + Index ); ResolveLocation(); return c; }
Form::Form( tinyxml2::XMLElement* FormConfiguration ) : Control( nullptr ) { if( FormConfiguration == nullptr ) { return; } tinyxml2::XMLElement* node; tinyxml2::XMLElement* usenode = nullptr; int minw = -1; int minh = -1; std::string nodename; for( node = FormConfiguration->FirstChildElement(); node != nullptr; node = node->NextSiblingElement() ) { nodename = node->Name(); if( nodename == "style" ) { // TODO: Determine best "style" based on minwidth and minheight attributes usenode = node; } } if( usenode != nullptr ) { ConfigureFromXML( usenode ); ResolveLocation(); } }
void ListBox::AddItem(sp<Control> Item) { Item->SetParent(shared_from_this()); ResolveLocation(); if (selected == nullptr) { selected = Item; } }
void ListBox::Clear() { while( Controls.size() > 0 ) { delete Controls.back(); Controls.pop_back(); } ResolveLocation(); }
Control* ListBox::RemoveItem( Control* Item ) { for( auto i = Controls.begin(); i != Controls.end(); i++ ) { if( (Control*)*i == Item ) { Controls.erase( i ); ResolveLocation(); return Item; } } return nullptr; }
void ListBox::OnRender() { int offset = 0; if (scroller == nullptr) { ConfigureInternalScrollBar(); } for (auto c = Controls.begin(); c != Controls.end(); c++) { auto ctrl = *c; if (ctrl != scroller) { switch (ListOrientation) { case Orientation::Vertical: ctrl->Location.x = 0; ctrl->Location.y = offset - scroller->GetValue(); if (ItemSize != 0) { ctrl->Size.x = (scroller_is_internal ? scroller->Location.x : this->Size.x); ctrl->Size.y = ItemSize; } offset += ctrl->Size.y + ItemSpacing; break; case Orientation::Horizontal: ctrl->Location.x = offset - scroller->GetValue(); ctrl->Location.y = 0; if (ItemSize != 0) { ctrl->Size.x = ItemSize; ctrl->Size.y = (scroller_is_internal ? scroller->Location.y : this->Size.y); } offset += ctrl->Size.x + ItemSpacing; break; } } } ResolveLocation(); switch (ListOrientation) { case Orientation::Vertical: scroller->Maximum = std::max(offset - this->Size.y, scroller->Minimum); break; case Orientation::Horizontal: scroller->Maximum = std::max(offset - this->Size.x, scroller->Minimum); break; } scroller->LargeChange = static_cast<int>(std::max((scroller->Maximum - scroller->Minimum + 2) / 10.0f, 4.0f)); }
sp<Control> ListBox::RemoveItem(int Index) { auto c = Controls.at(Index); Controls.erase(Controls.begin() + Index); ResolveLocation(); if (c == this->selected) { this->selected = nullptr; } if (c == this->hovered) { this->selected = nullptr; } return c; }
void ListBox::Clear() { for (auto &c : Controls) { c->SetParent(nullptr); } Controls.clear(); this->selected = nullptr; this->hovered = nullptr; if (scroller_is_internal) { ConfigureInternalScrollBar(); } ResolveLocation(); }
sp<Control> ListBox::RemoveItem(sp<Control> Item) { for (auto i = Controls.begin(); i != Controls.end(); i++) { if (*i == Item) { Controls.erase(i); ResolveLocation(); return Item; } } if (Item == this->selected) { this->selected = nullptr; } if (Item == this->hovered) { this->selected = nullptr; } return nullptr; }
void Form::Update() { Control::Update(); ResolveLocation(); }
TextPointer TextPointer::GetPositionInsideRun (int offset) const { DependencyObject *parent = GetParent (); if (parent == NULL) return *this; if (offset > 0) { if (parent->Is(Type::RUN)) { int location = ResolveLocation (); const char *text = ((Run*)parent)->GetText(); if ((guint)location < strlen (text)) return GetPositionAtOffset_np (1, LogicalDirectionForward); } // we're at the end of the run (or not in a run at all). we need to walk the document until we hit another run. DocumentWalker walker (IDocumentNode::CastToIDocumentNode (parent), DocumentWalker::Forward); walker.Step (); while (true) { IDocumentNode *node; DocumentWalker::StepType type = walker.Step (&node); switch (type) { case DocumentWalker::Done: // there is no position beyond this return *this; case DocumentWalker::Enter: if (node->AsDependencyObject()->Is(Type::RUN)) return ((Run*)node->AsDependencyObject())->GetContentStart_np(); break; case DocumentWalker::Leave: // do nothing here break; } } } else { if (parent->Is(Type::RUN)) { int location = ResolveLocation (); if (location > 0) return GetPositionAtOffset_np (-1, LogicalDirectionForward); } // we're at the start of the run (or not in a run at all). we need to walk the document until we hit another run. DocumentWalker walker (IDocumentNode::CastToIDocumentNode (parent), DocumentWalker::Backward); walker.Step (); while (true) { IDocumentNode *node; DocumentWalker::StepType type = walker.Step (&node); switch (type) { case DocumentWalker::Done: // there is no position before this return *this; case DocumentWalker::Enter: if (node->AsDependencyObject()->Is(Type::RUN)) return ((Run*)node->AsDependencyObject())->GetContentEnd_np(); break; case DocumentWalker::Leave: // do nothing here break; } } } return *this; }
void ListBox::AddItem( Control* Item ) { Controls.push_back( Item ); Item->SetParent( this ); ResolveLocation(); }
void GhostCollision::RenderEctoplasmaBar(float ectoPercent, double ghostRotation) { CIwFMat ectoMatrix = CIwFMat(); ectoMatrix.CopyRot(*modelMatrix); ectoMatrix.CopyTrans(*modelMatrix); ectoMatrix.PostRotateY(PI-ghostRotation); IwGxSetModelMatrix(&ectoMatrix); IwGxSetScreenSpaceSlot(1); if (ghostW < 0 || ghostX < 0 || ghostY < 0) ResolveLocation(); const int16 w = 180; const int16 border_x1 = ghostX+ghostW/2 - (float)w*ectobarScale; const int16 border_x2 = ghostX+ghostW/2 + (float)w*ectobarScale; const float border_y1 = ghostY+0x20; const float border_y2 = ghostY+0x20 + (float)0x10*ectobarScale; const int16 z = 0x6; { CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL(); pMat->SetModulateMode(CIwMaterial::MODULATE_RGB); pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); pMat->SetTexture(borderTexture); int16 x1 = border_x1, x2 = border_x2; float y1 = border_y1, y2 = border_y2; border_Verts[0] = CIwFVec3(x1, y2, -z); border_Verts[1] = CIwFVec3(x2, y2, -z); border_Verts[2] = CIwFVec3(x2, y1, -z); border_Verts[3] = CIwFVec3(x1, y1, -z); border_Verts[4] = CIwFVec3(x1, y2, z); border_Verts[5] = CIwFVec3(x2, y2, z); border_Verts[6] = CIwFVec3(x2, y1, z); border_Verts[7] = CIwFVec3(x1, y1, z); IwGxSetMaterial(pMat); IwGxSetVertStream(border_Verts, 8); //IwGxSetColStream(s_Cols, 8); IwGxSetUVStream(s_UVs); IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4); } float start_y1 = border_y1 + fabs((float)(border_y2 - border_y1)*0.200); float start_y2 = start_y1 + fabs((float)(border_y2 - border_y1)*0.720); float startWhScale = (float)((double)startTexture->GetWidth() / startTexture->GetHeight()); int16 startW = (start_y2 - start_y1) * startWhScale; int16 start_x1 = border_x1 + abs((float)(border_x2 - border_x1)*0.0097); int16 start_x2 = start_x1 + startW; { CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL(); pMat->SetModulateMode(CIwMaterial::MODULATE_RGB); pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); pMat->SetTexture(startTexture); int16 x1 = start_x1, x2 = start_x2; float y1 = start_y1, y2 = start_y2; start_Verts[0] = CIwFVec3(x1, y2, -z); start_Verts[1] = CIwFVec3(x2, y2, -z); start_Verts[2] = CIwFVec3(x2, y1, -z); start_Verts[3] = CIwFVec3(x1, y1, -z); start_Verts[4] = CIwFVec3(x1, y2, z); start_Verts[5] = CIwFVec3(x2, y2, z); start_Verts[6] = CIwFVec3(x2, y1, z); start_Verts[7] = CIwFVec3(x1, y1, z); IwGxSetMaterial(pMat); IwGxSetVertStream(start_Verts, 8); //IwGxSetColStream(s_Cols, 8); IwGxSetUVStream(s_UVs); IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4); } float end_y1 = start_y1; float end_y2 = start_y2; float endWhScale = (float)((double)endTexture->GetWidth() / endTexture->GetHeight()); int16 endW = (end_y2 - end_y1) * endWhScale; int endMaxX = border_x2 - abs((float)(border_x2 - border_x1)*0.0097) - endW; int endMinX = start_x2; int16 end_x1 = (double)(endMaxX - endMinX)*ectoPercent + endMinX; int16 end_x2 = end_x1 + endW; { CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL(); pMat->SetModulateMode(CIwMaterial::MODULATE_RGB); pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); pMat->SetTexture(endTexture); int16 x1 = end_x1, x2 = end_x2; float y1 = end_y1, y2 = end_y2; end_Verts[0] = CIwFVec3(x1, y2, -z); end_Verts[1] = CIwFVec3(x2, y2, -z); end_Verts[2] = CIwFVec3(x2, y1, -z); end_Verts[3] = CIwFVec3(x1, y1, -z); end_Verts[4] = CIwFVec3(x1, y2, z); end_Verts[5] = CIwFVec3(x2, y2, z); end_Verts[6] = CIwFVec3(x2, y1, z); end_Verts[7] = CIwFVec3(x1, y1, z); IwGxSetMaterial(pMat); IwGxSetVertStream(end_Verts, 8); //IwGxSetColStream(s_Cols, 8); IwGxSetUVStream(s_UVs); IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4); } float center_y1 = start_y1; float center_y2 = start_y2; int16 center_x1 = start_x2 - 1; int16 center_x2 = end_x1 + 1; { CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL(); pMat->SetModulateMode(CIwMaterial::MODULATE_RGB); pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND); pMat->SetTexture(centerTexture); int16 x1 = center_x1, x2 = center_x2; float y1 = center_y1, y2 = center_y2; center_Verts[0] = CIwFVec3(x1, y2, -z); center_Verts[1] = CIwFVec3(x2, y2, -z); center_Verts[2] = CIwFVec3(x2, y1, -z); center_Verts[3] = CIwFVec3(x1, y1, -z); center_Verts[4] = CIwFVec3(x1, y2, z); center_Verts[5] = CIwFVec3(x2, y2, z); center_Verts[6] = CIwFVec3(x2, y1, z); center_Verts[7] = CIwFVec3(x1, y1, z); IwGxSetMaterial(pMat); IwGxSetVertStream(center_Verts, 8); //IwGxSetColStream(s_Cols, 8); IwGxSetUVStream(s_UVs); IwGxDrawPrims(IW_GX_QUAD_STRIP, s_QuadStrip, 4); } }