/* AbiSource Application Framework * Copyright (C) 1998-2000 AbiSource, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #include "ut_types.h" #include "xav_View.h" #include "xav_Listener.h" #include"ut_debugmsg.h" AV_View::AV_View(XAP_App * pApp, void* pParentData) : m_pApp(pApp), m_pParentData(pParentData), m_xScrollOffset(0), m_yScrollOffset(0), m_iWindowHeight(0), m_iWindowWidth(0), m_focus(AV_FOCUS_NONE), m_iTick(0), m_bInsertMode(UT_TRUE) { } AV_View::~AV_View() { } void* AV_View::getParentData() const { return m_pParentData; } UT_Bool AV_View::addListener(AV_Listener * pListener, AV_ListenerId * pListenerId) { UT_uint32 kLimit = m_vecListeners.getItemCount(); UT_uint32 k; // see if we can recycle a cell in the vector. for (k=0; knotify(this,hint); } return UT_TRUE; } UT_uint32 AV_View::getTick(void) { return m_iTick; } void AV_View::incTick(void) { m_iTick++; } void AV_View::setInsertMode(UT_Bool bInsert) { m_bInsertMode = bInsert; notifyListeners(AV_CHG_INSERTMODE); }; void AV_View::setWindowSize(UT_sint32 width, UT_sint32 height) { m_iWindowWidth = width; m_iWindowHeight = height; notifyListeners(AV_CHG_WINDOWSIZE); } void AV_View::addScrollListener(AV_ScrollObj* pObj) { m_scrollListeners.addItem((void *)pObj); } void AV_View::removeScrollListener(AV_ScrollObj* pObj) { UT_sint32 count = m_scrollListeners.getItemCount(); for (UT_sint32 i = 0; i < count; i++) { AV_ScrollObj* obj = (AV_ScrollObj*) m_scrollListeners.getNthItem(i); if (obj == pObj) { m_scrollListeners.deleteNthItem(i); break; } } } void AV_View::sendVerticalScrollEvent(UT_sint32 yoff, UT_sint32 ylimit) { UT_sint32 count = m_scrollListeners.getItemCount(); for (UT_sint32 i = 0; i < count; i++) { AV_ScrollObj* pObj = (AV_ScrollObj*) m_scrollListeners.getNthItem(i); pObj->m_pfnY(pObj->m_pData, yoff, ylimit); } } void AV_View::sendHorizontalScrollEvent(UT_sint32 xoff, UT_sint32 xlimit) { UT_sint32 count = m_scrollListeners.getItemCount(); for (UT_sint32 i = 0; i < count; i++) { AV_ScrollObj* pObj = (AV_ScrollObj*) m_scrollListeners.getNthItem(i); pObj->m_pfnX(pObj->m_pData, xoff, xlimit); } }