void CParticle::AddSize(SSize size) { m_vSizes.push_back(SSize()); m_vSizes[m_vSizes.size()-1].time = size.time; m_vSizes[m_vSizes.size()-1].size1 = size.size1; m_vSizes[m_vSizes.size()-1].size2 = size.size2; }
void CListBox::OnDraw(const SRect &rUpdate) { if (mpDrawPrimitives == NULL) { mpDrawPrimitives = IDrawPrimitives::Create(); mpDrawPrimitives->Init(GetParentWindow()); } SRect rctDraw(GetPos(), SSize(GetSize().iCX, 10)); tint32 iIndex = 0; std::list<std::string>::const_iterator it = mTexts.begin(); for (; it != mTexts.end(); it++, iIndex++) { const std::string& sText = *it; DrawFont(dynamic_cast<IFontResource*>(GetBitmapResource()), rUpdate, rctDraw, (const tchar*)(sText.c_str())); if (iIndex == miDragIndex) { SRect rctInvert(rctDraw); rctInvert.iY -= 2; rctInvert.iCY += 4; mpDrawPrimitives->InvertRect(rUpdate, rctInvert); } rctDraw.iY += 14; } } // OnDraw
void CBrowser::SetSize(const SSize& Size) { CControl::SetSize(Size); if (mSizeMin == SSize(0, 0)) { mSizeMin = GetSize(); } }
void C2DRectangleCollision::AddToWorld(b2World * world) { CheckParametres(); CStatic2DShape::AddToWorld(world); AddRectangleToBody(m_body , SSize(m_width, m_height) , GetOrigin()); }
void CWall::AddToWorld(b2World * world) { CheckParametres(); CStaticShape::AddToWorld(world); SetVisual(); AddRectangleToBody(m_body , SSize(m_width, m_height) , GetOrigin()); }
void CParticleEmitter::Copy(CParticleEmitter &other) { m_vPos = other.GetPos(); m_Type = other.GetType(); m_fMinTimeLife = other.GetMinTimeLife(); m_fMaxTimeLife = other.GetMaxTimeLife(); m_fMinEmitRate = other.GetMinRate(); m_fMaxEmitRate = other.GetMaxRate(); m_bGravity = other.GetGravity(); m_fAngle = other.GetAngle(); std::vector<SColor> l_ColorVector = other.GetColorVector(); for(unsigned int i=0; i<l_ColorVector.size(); i++) { m_vColors.push_back(SColor()); m_vColors[m_vColors.size()-1].time = l_ColorVector[i].time; m_vColors[m_vColors.size()-1].col1 = l_ColorVector[i].col1; m_vColors[m_vColors.size()-1].col2 = l_ColorVector[i].col2; } std::vector<SDirection> l_DirectionVector = other.GetDirectionVector(); for(unsigned int i=0; i<l_DirectionVector.size(); i++) { m_vDirections.push_back(SDirection()); m_vDirections[m_vDirections.size()-1].time = l_DirectionVector[i].time; m_vDirections[m_vDirections.size()-1].dir1 = l_DirectionVector[i].dir1; m_vDirections[m_vDirections.size()-1].dir2 = l_DirectionVector[i].dir2; } std::vector<SSize> l_SizeVector = other.GetSizeVector(); for(unsigned int i=0; i<l_SizeVector.size(); i++) { m_vSizes.push_back(SSize()); m_vSizes[m_vSizes.size()-1].time = l_SizeVector[i].time; m_vSizes[m_vSizes.size()-1].size1 = l_SizeVector[i].size1; m_vSizes[m_vSizes.size()-1].size2 = l_SizeVector[i].size2; } std::vector<SAceleration> l_AcelVector = other.GetAcelerationVector(); for(unsigned int i=0; i<l_AcelVector.size(); i++) { m_vAcelerations.push_back(SAceleration()); m_vAcelerations[m_vAcelerations.size()-1].time = l_AcelVector[i].time; m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_AcelVector[i].acel1; m_vAcelerations[m_vAcelerations.size()-1].acel2 = l_AcelVector[i].acel2; } m_fNumNewPartsExcess = other.GetNumNewPartsExcess(); m_sTexture = other.GetTexture(); }
void CEQDisplay::SetSize(const SSize& Size, tbool bRedraw) { CPane::SetSize(Size, bRedraw); if (mpfBufferCurveBand) { delete[] mpfBufferCurveBand; } mpfBufferCurveBand = new tfloat32[GetSize().iCX]; if (mpfBufferCurveTotal) { delete[] mpfBufferCurveTotal; } mpfBufferCurveTotal = new tfloat32[GetSize().iCX]; std::list<IControl*>::iterator it = mControls.begin(); for (; it != mControls.end(); it++) { IControl* pControl = *it; pControl->SetSize(GetSize() + SSize(miDotOffsetX * 2, miDotOffsetY * 2)); } }
static Result X_EvalExpression() { long double buf[ARG_MAX]; Result res = R_SUCCE; size_t len; Stack *sval = SCreate(); Stack *sopr = SCreate(); while (*x_cur && *x_cur != ',' && *x_cur != ')') { switch (*x_cur) { case '+': XEE_PBU(BIN_ADD, UNA_PLS); break; case '-': XEE_PBU(BIN_SUB, UNA_MNS); break; case '*': XEE_PBE(BIN_MUL); break; case '/': XEE_PBE(BIN_DIV); break; case '%': XEE_PBE(BIN_MOD); break; case '^': XEE_PBE(BIN_PWR); break; case '(': XX_Next(); if ((res = X_EvalExpression())) XEE_RET(res); if (!XX_ParseChar(')')) { r_in0 = *x_cur; r_in1 = ')'; XEE_RET(*x_cur ? ERR(RS_ECHR) : ERR(RS_UTRM)); } if (SPushLdb(sval, x_pval)) XEE_RET(R_ITRNL); XX_Next(); x_lav = true; break; default: if (CIsDigD(*x_cur)) { if ((res = X_ParseNumber())) XEE_RET(res); if (SPushLdb(sval, x_pval)) XEE_RET(R_ITRNL); x_lav = true; } else if(CIsAlpha(*x_cur)) { //=>X_EvalFunctionCall if ((res = X_ParseName())) XEE_RET(res); MathFunction *fun = FGetFunction(x_pstr); if (!fun) { strcpy(r_str, x_pstr); XEE_RET(ERR(RS_NDEF)); } if (XX_ParseChar('(')) { for (len = 0; len < ARG_MAX; ++len) { if (!XX_Next()) XEE_RET(ERR(RS_UTRM)); if (*x_cur == ')') break; if ((res = X_EvalExpression())) XEE_RET(res); buf[len] = x_pval; if (!XX_ParseChar(',')) { ++len; break; } } if (!XX_ParseChar(')')) { r_in0 = *x_cur; r_in1 = ')'; XEE_RET(*x_cur ? ERR(RS_ECHR) : ERR(RS_UTRM)); } XX_Next(); if ((res = fun(&x_pval, buf, len))) XEE_RET(ERR(res)); } else if ((res = fun(&x_pval, nullptr, 0))) XEE_RET(ERR(res)); if (SPushLdb(sval, x_pval)) XEE_RET(R_ITRNL); x_lav = true; } else { r_in0 = *x_cur; XEE_RET(*x_cur ? ERR(RS_UCHR) : ERR(RS_UTRM)); } break; } } if ((res = XXX_PushOpr(sopr, sval, 0))) XEE_RET(res); if (!x_lav || SSize(sopr) != 1 || SSize(sval) != 1) XEE_RET(ERR(RS_ILLE)); x_pval = *STopLdb(sval); XEE_RET(R_SUCCE); }
SRect CScrollBar::GetHandleRect() { SRect rctHandle; if (mpScrollPane) mpScrollPane->GetScrollPos(mScrollPos); switch(mType) { case TypeHorizontal: { // The leftmost top-left point is 1 pixel to the right of the top-right point of the left arrow std::list<IControl*>::iterator it = mControls.begin(); if (mControls.size() > 2) { it++; } IControl* pControl = *it++; SRect RctArrow; pControl->GetRect(RctArrow); SPos Pos(RctArrow.iX + RctArrow.iCX, RctArrow.iY); // Calculate the relative position (top-left point) tint iDiff = mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX; tfloat64 fPositionRelative; if (iDiff == 0) { fPositionRelative = 0; } else { fPositionRelative = (double)mScrollPos.VisibleRect.iX / iDiff; } // Calculate the maximum width of the handle pControl = *it; SPos PosRightArrow; pControl->GetPos(PosRightArrow); tint iMaxWidth = PosRightArrow.iX - Pos.iX; // Calculate the relative width we occupy tfloat64 fWidthRelative = mScrollPos.VisibleRect.iCX / (double)mScrollPos.AreaSize.iCX; // Calculate the absolute size rctHandle = SRect(Pos, SSize(0, 0)); rctHandle.iCY = mpBitmapSizes[BitmapCenterHandle].iCY; rctHandle.iCX = (int)((fWidthRelative * iMaxWidth) + 0.5); // Calculate the absolute position rctHandle.iX += (int)((fPositionRelative * (iMaxWidth - rctHandle.iCX)) + 0.5); if (rctHandle.iCX < mpBitmapSizes[BitmapLeftTopHandle].iCX + mpBitmapSizes[BitmapRightDownHandle].iCX) { rctHandle.iCX = mpBitmapSizes[BitmapLeftTopHandle].iCX + mpBitmapSizes[BitmapRightDownHandle].iCX; } } break; case TypeVertical: { // The topmost top-left point is 1 pixel below the bottom-left point of the up arrow std::list<IControl*>::iterator it = mControls.begin(); if (mControls.size() > 2) { it++; } IControl* pControl = *it++; SRect RctArrow; pControl->GetRect(RctArrow); SPos Pos(RctArrow.iX, RctArrow.iY + RctArrow.iCY); // Calculate the relative position (top-left point) tint iDiff = mScrollPos.AreaSize.iCY - mScrollPos.VisibleRect.iCY; tfloat64 fPositionRelative; if (iDiff == 0) { fPositionRelative = 0; } else { fPositionRelative = (double)mScrollPos.VisibleRect.iY / iDiff; } // Calculate the maximum height of the handle pControl = *it; SPos PosDownArrow; pControl->GetPos(PosDownArrow); tint iMaxHeight = PosDownArrow.iY - Pos.iY; // Calculate the relative height we occupy tfloat64 fHeightRelative = mScrollPos.VisibleRect.iCY / (double)mScrollPos.AreaSize.iCY; // Calculate the absolute size rctHandle = SRect(Pos, SSize(0, 0)); rctHandle.iCX = mpBitmapSizes[BitmapCenterHandle].iCX; rctHandle.iCY = (int)((fHeightRelative * iMaxHeight) + 0.5); // Calculate the absolute position rctHandle.iY += (int)((fPositionRelative * (iMaxHeight - rctHandle.iCY)) + 0.5); if (rctHandle.iCY < mpBitmapSizes[BitmapLeftTopHandle].iCY + mpBitmapSizes[BitmapRightDownHandle].iCY) { rctHandle.iCY = mpBitmapSizes[BitmapLeftTopHandle].iCY + mpBitmapSizes[BitmapRightDownHandle].iCY; } } break; } return rctHandle; }
OSStatus WindowEventHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon) { OSStatus err = eventNotHandledErr; WindowRef Ref; switch ( GetEventClass( inEvent ) ) { case kEventClassCommand: { HICommandExtended cmd; verify_noerr( GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof( cmd ), NULL, &cmd ) ); switch ( GetEventKind( inEvent ) ) { case kEventCommandProcess: switch ( cmd.commandID ) { // Add your own command-handling cases here default: break; } break; } break; } case kEventClassWindow: switch (GetEventKind(inEvent)) { case kEventWindowClose:{ // kspi::IGUI* pGUI = (kspi::IGUI*)inRefcon; // pGUI->Destroy(); // Hide window, but don't close it Ref = (WindowRef)inRefcon; ::HideWindow(Ref); gpMainContext->WindowClosed((void*)Ref); return noErr; } case kEventWindowActivated:{ Ref = (WindowRef)inRefcon; return noErr; } /* case kEventWindowDeactivated:{ WindowRef Ref = (WindowRef)inRefcon; if(Ref == gWndZoom){ ::HideWindow(gWndZoom); //gbShowZoom = false; } break; } */ case kEventWindowBoundsChanged: { UInt32 Attributes; OSStatus err; err = GetEventParameter (inEvent, kEventParamAttributes, typeUInt32, NULL, sizeof(UInt32), NULL, &Attributes); if (!err) { if (Attributes & kWindowBoundsChangeSizeChanged) { // Window is being resized WindowRef Ref = (WindowRef)inRefcon; Rect rct; ::GetWindowBounds(Ref, kWindowContentRgn, &rct); gpMainContext->SizeChanged(Ref, SSize(rct.right - rct.left+1, rct.bottom - rct.top+1)); return noErr; } else if (Attributes & kWindowBoundsChangeOriginChanged) { // Window is being moved } } return noErr; } case kEventWindowCursorChange: { ((CWindowOSX*)inRefcon)->SetCurrentMouseCursor(); } return noErr; } break; default: break; } return err; }
void CParticleEmitter::Load(CXMLTreeNode &parser) { m_vColors.clear(); m_vDirections.clear(); m_vAcelerations.clear(); m_vSizes.clear(); //m_Type = parser.GetPszProperty("type", "point"); m_bGravity = parser.GetBoolProperty("gravity"); m_fMinTimeLife = parser.GetFloatProperty("life_time_min", 0.0f); m_fMaxTimeLife = parser.GetFloatProperty("life_time_max", 0.0f); m_fMinEmitRate = parser.GetFloatProperty("emit_rate_min", 1.0f); m_fMaxEmitRate = parser.GetFloatProperty("emit_rate_max", 1.0f); std::string l_texturePath = parser.GetPszProperty("tex", ""); m_fAngle = parser.GetFloatProperty("angle", 0.0f); m_sTexture = CORE->GetTextureManager()->GetTexture(l_texturePath); //Variación de los colores CXMLTreeNode l_Node = parser["color"]; m_vColors.push_back(SColor()); //SColor l_color = new SColor(); m_vColors[m_vColors.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node.GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f))); m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node.GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f))); //m_vColors.push_back(l_color); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vColors.push_back(SColor()); m_vColors[m_vColors.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vColors[m_vColors.size()-1].col1.SetArgb(l_Node(i).GetVect4fProperty("color1",Vect4f(1.0f,1.0f,1.0f,1.0f))); m_vColors[m_vColors.size()-1].col2.SetArgb(l_Node(i).GetVect4fProperty("color2",Vect4f(1.0f,1.0f,1.0f,1.0f))); } //Variación de los vectores directores l_Node = parser["direction"]; m_vDirections.push_back(SDirection()); //SDirection* l_direction = new SDirection(); m_vDirections[m_vDirections.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vDirections[m_vDirections.size()-1].dir1 = l_Node.GetVect3fProperty("dir1", Vect3f(0.0f,0.0f,0.0f)); m_vDirections[m_vDirections.size()-1].dir2 = l_Node.GetVect3fProperty("dir2", Vect3f(0.0f,0.0f,0.0f)); //m_vDirections.push_back(l_direction); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vDirections.push_back(SDirection()); m_vDirections[m_vDirections.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vDirections[m_vDirections.size()-1].dir1 = l_Node(i).GetVect3fProperty("dir1",Vect3f(0.0f,0.0f,0.0f)); m_vDirections[m_vDirections.size()-1].dir2 = l_Node(i).GetVect3fProperty("dir2",Vect3f(0.0f,0.0f,0.0f)); } //Variación de los tamaños l_Node = parser["size"]; m_vSizes.push_back(SSize()); //SSize* l_size = new SSize(); m_vSizes[m_vSizes.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vSizes[m_vSizes.size()-1].size1 = l_Node.GetFloatProperty("mins", 1.0f); m_vSizes[m_vSizes.size()-1].size2 = l_Node.GetFloatProperty("maxs", 1.0f); //m_vSizes.push_back(l_size); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vSizes.push_back(SSize()); m_vSizes[m_vSizes.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vSizes[m_vSizes.size()-1].size1 = l_Node(i).GetFloatProperty("mins",1.0f); m_vSizes[m_vSizes.size()-1].size2 = l_Node(i).GetFloatProperty("maxs",1.0f); } //Variación de las aceleraciones l_Node = parser["aceleration"]; m_vAcelerations.push_back(SAceleration()); //SAceleration* l_aceleration = new SAceleration(); m_vAcelerations[m_vAcelerations.size()-1].time = l_Node.GetFloatProperty("time", 0.0f); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node.GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f)); m_vAcelerations[m_vAcelerations.size()-1].acel2 = l_Node.GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f)); //m_vAcelerations.push_back(l_aceleration); for(int i=0;i<l_Node.GetNumChildren();i++){ m_vAcelerations.push_back(SAceleration()); m_vAcelerations[m_vAcelerations.size()-1].time = l_Node(i).GetFloatProperty("time", 0.0f); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel1", Vect3f(0.0f,0.0f,0.0f)); m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_Node(i).GetVect3fProperty("acel2", Vect3f(0.0f,0.0f,0.0f)); } }
SSize CompareSize() const { return SSize(1, 1); }