XnStatus XnDeviceSensor::Destroy() { XnStatus nRetVal = XN_STATUS_OK; // destroy actual nRetVal = XnDeviceBaseProxy::Destroy(); XN_IS_STATUS_OK(nRetVal); IXnDevice* pActual = GetActual(); ReplaceActualDevice(NULL); XN_DELETE(pActual); return (XN_STATUS_OK); }
void Box::Resize () { register BoxElement* e; /* box element */ Shape aggrshape; /* combined shape of components */ BoxCanonical total; /* components' shape along major axis */ int major, minor; /* actual dimensions of box */ register int have; /* how much box is willing to change */ register int need; /* how much box needs to change to fit */ boolean grow; /* true if stretching, false if shrinking */ BoxCanonical s; /* element shape along major axis */ register int pos; /* where to put next element on major axis */ register int len; /* size of element along major axis */ register int n; /* temporary variable */ ComputeShape(&aggrshape); GetActual(major, minor); GetCanonical(&aggrshape, total); n = total.major.natural; if (major > n) { /* more space than desired ==> stretch elements */ grow = true; have = total.major.stretch; need = min(major - n, have); } else { /* less (or equal) space than desired ==> (maybe) shrink elements */ grow = false; have = total.major.shrink; need = min(n - major, have); } pos = 0; for (e = head; e != nil; e = e->next) { GetCanonical(e->child->GetShape(), s); len = s.major.natural; if (have > 0) { if (grow) { n = int(double(s.major.stretch)*double(need)/double(have)); len += n; have -= s.major.stretch; } else { n = int(double(s.major.shrink)*double(need)/double(have)); len -= n; have -= s.major.shrink; } need -= n; } n = s.minor.natural; if (n == 0) { n = minor; } else if (n > minor) { n = max(n - s.minor.shrink, minor); } else if (n < minor) { n = min(n + s.minor.stretch, minor); } if (n > 0 && len > 0) { e->visible = true; PlaceElement(e->child, pos, len, minor, n); } else { e->visible = false; } pos += len; } }