#include "sequence_ih.h"

#include <afxwin.h>

namespace roy {

    namespace ih {

        bool sequence_ih::OnLButtonDown(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnLButtonDown(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnLButtonUp(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnLButtonUp(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnLButtonDblClk(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnLButtonDblClk(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnRButtonDown(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnRButtonDown(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnRButtonUp(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnRButtonUp(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnRButtonDblClk(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnRButtonDblClk(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnMButtonDown(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnMButtonDown(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnMButtonUp(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnMButtonUp(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnMButtonDblClk(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnMButtonDblClk(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnMouseWheel(nFlags, zDelta, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnMouseMove(UINT nFlags, CPoint point)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnMouseMove(nFlags, point)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnKeyDown(nChar, nRepCnt, nFlags)) {
                    return true;
                }
            }

            return false;
        }

        bool sequence_ih::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                if (_seq[i]->OnKeyUp(nChar, nRepCnt, nFlags)) {
                    return true;
                }
            }

            return false;
        }

        void sequence_ih::OnEntering(void)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                _seq[i]->OnEntering();
            }
        }
        
        void sequence_ih::OnLeaving(void)
        {
            for (int i = 0; i < (int) _seq.size(); i++) {
                _seq[i]->OnLeaving();
            }
        }

        void sequence_ih::AddIH(const ref_ptr& ih)
        {
            _seq.push_back(ih);
        }

        void sequence_ih::Clear(void)
        {
            _seq.clear();
        }

    }

}
