Listing 4: Class DeltaControlPair
excerpt from delta.h class DeltaControlPair : public DeltaControl { public: DeltaControlPair(DeltaControl *A, DeltaControl *B); virtual ~DeltaControlPair() {}; virtual int GetLength() {return m_Major.len;}; virtual BOOL Next(); protected: virtual void OnMajorChange(int Current) {m_PMajor->Next();}; virtual void OnMinorChange(int Current) {m_PMinor->Next();}; DeltaControl *m_PMajor; DeltaControl *m_PMinor; }; excerpt from delta.cpp DeltaControlPair::DeltaControlPair(DeltaControl *A, DeltaControl *B) { SetFrom(0, 0); if (A->GetLength() > B->GetLength()) { SetTo(A->GetLength(), B->GetLength()); m_PMajor = A; m_PMinor = B; } else { SetTo(B->GetLength(), A->GetLength()); m_PMajor = B; m_PMinor = A; } } BOOL DeltaControlPair::Next() { m_ErrorTerm += m_Minor.len; if (m_ErrorTerm > m_Major.len && m_Minor.togo) { m_Minor.current += m_Minor.delta; OnMinorChange(m_Minor.current); m_ErrorTerm -= m_Major.len; m_Minor.togo--; } if (!m_Major.togo) return FALSE; m_Major.current += m_Major.delta; m_Major.togo--; OnMajorChange(m_Major.current); return TRUE; } End of Listing