⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aeeimagectl.c

📁 test return point or point as param
💻 C
📖 第 1 页 / 共 3 页
字号:
/*======================================================

                   ** IMPORTANT ** 

This source is provide strictly for reference and debug
purposes to licensed parties.  Modification of this
code will likely cause instability and/or incompatibility with
future software versions and failure of applications
that leverage these interfaces.  

FILE:  AEEImageCtl.c

SERVICES:  AEE Image Viewer Control

GENERAL DESCRIPTION:  Provides support for IImageCtl for image 
viewing in AEE

PUBLIC CLASSES AND STATIC FUNCTIONS: IImageCtl

Copyright ?1999-2005 QUALCOMM Incorporated.
         All Rights Reserved.
       QUALCOMM Proprietary/GTDR

=====================================================*/

/*=========================================================================

INCLUDE FILES FOR MODULE

===========================================================================*/

#include "AEE_OEM.h"
#include "AEEStdLib.h"
#include "AEEGraphics.h"
#include "AEEImageCtl.h"
#include "AEEImageCtl_priv.h"

/*===========================================================================

DEFINITIONS

===========================================================================*/

// Pen Tracking Hit flags 8-bit (1 byte)
#define  PTRCK_HIT_ABOVE   (0x01)      // Above the thumb, y position < thumb.y OR x position < thumb.x
#define  PTRCK_HIT_THUMB   (0x02)      // On the thumb
#define  PTRCK_HIT_BELOW   (0x04)      // Below the thumb, y position > thumb.y + thumb.dy OR x position < thumb.x + thumb.dx
#define  PTRCK_HIT_VSCRL   (0x08)      // 1: Hit Vertical Scrollbar; 0: Hit Horizontal Scrollbar
#define  PTRCK_NOTTHUMB    (PTRCK_HIT_BELOW | PTRCK_HIT_ABOVE)

// Pen Tracking General flags
#define  PTRCK_GEN_TMRSET  (0x01)   // Scroll Timer is set

typedef struct
{
   uint8    cbHit;
   uint8    cbFlags;
   uint16   wThumbOffset;
   AEEPoint ptPosition;
} PenTracker;

/*===========================================================================

Class Definitions

===========================================================================*/

OBJECT(ImageCtl)
{
   DECLARE_VTBL(IImageCtl)

   uint32         m_nRefs;
   IShell *       m_pShell;
   IImage *       m_pImage;
   IDisplay *     m_pDisplay;
   AEERect        m_rc;
   AEEImageInfo   m_ii;
   int            m_yOffset;
   int            m_xOffset;
   int            m_cxScreen;
   int            m_cyScreen;
   int            m_nSBWidth;
   uint32         m_dwProps;
   PFNNOTIFY      m_pfnRedraw;
   void *         m_pRedraw;
   PenTracker     m_ptTracker;
   AEEAutoRepeat  m_arPenRepeat;
   AEEPoint       m_ptViewSize;

   flg            m_bActive:1;
   flg            m_bStarted:1;
   flg            m_bScrollX:1;
   flg            m_bScrollY:1;
};

#define PT_IN_RECT(a,b,rct)      (boolean)( ((a) >= (rct).x && (a) <= ((rct).x + (rct).dx)) && ((b) >= (rct).y && (b) <= ((rct).y + (rct).dy)) )


//---------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------

static uint32  ImageCtl_AddRef(IImageCtl * po);
static uint32  ImageCtl_Release(IImageCtl * po);
static boolean ImageCtl_HandleEvent(IImageCtl * po, AEEEvent eCode, uint16 wParam, uint32 dwParam);
static boolean ImageCtl_Redraw(IImageCtl * po);
static void    ImageCtl_SetActive(IImageCtl * po, boolean bActive);
static boolean ImageCtl_IsActive(IImageCtl * po);
static void    ImageCtl_SetRect(IImageCtl * po, const AEERect * prc);
static void    ImageCtl_GetRect(IImageCtl * po, AEERect * prc);
static void    ImageCtl_SetProperties(IImageCtl * po, uint32 dwProp);
static uint32  ImageCtl_GetProperties(IImageCtl * po);
static void    ImageCtl_Reset(IImageCtl * po);
static void    ImageCtl_SetImage(IImageCtl * po, IImage * pi);
static void    ImageCtl_SetRedraw(IImageCtl * po, PFNNOTIFY pfn, void * pUser);

static void    ImageCtl_DrawScrollBar(ImageCtl * pme,boolean bVertical);
static int     ImageCtl_GetScrollBarRects(ImageCtl * pme,AEERect * prcFrame, AEERect * prcThumb,boolean bVertical);
static void    ImageCtl_RedrawCB(ImageCtl * pme);
static void    ImageCtl_CheckScroll(ImageCtl * pme);
static void    ImageCtl_ScrollTimerCB(ImageCtl * pme);
static boolean ImageCtl_ScrollByPos(ImageCtl * pme, int nDir, int16 wXPos, int16 wYPos);

//---------------------------------------------------------------------
// Global Constant Definitions
//---------------------------------------------------------------------

static const VTBL(IImageCtl) gViewerFuncs = {         
    ImageCtl_AddRef,                                
    ImageCtl_Release,
    ImageCtl_HandleEvent,
    ImageCtl_Redraw,
    ImageCtl_SetActive,
    ImageCtl_IsActive,
    ImageCtl_SetRect,
    ImageCtl_GetRect,
    ImageCtl_SetProperties,
    ImageCtl_GetProperties,
    ImageCtl_Reset,
    ImageCtl_SetImage,
    ImageCtl_SetRedraw
};

/*===========================================================================

EXTERNAL - Called from AEEControls.c.  Supports creation of analog clock class.

===========================================================================*/
int ImageCtl_New(IShell * ps, AEECLSID cls, void ** ppObj)
{
   ImageCtl *       pme;
   AEEDeviceInfo    di;
   IBitmap *        pbmDst;
   AEEBitmapInfo    bi;
   int              nSize;

   *ppObj = NULL;

  // allocate memory for object

   if((pme = (ImageCtl *)AEE_NewClass((IBaseVtbl *)&gViewerFuncs, sizeof(ImageCtl))) == NULL)
      return(ENOMEMORY);

   *ppObj = pme;

   ISHELL_CreateInstance(ps, AEECLSID_DISPLAY, (void **)(&pme->m_pDisplay));

   pme->m_pShell = ps;

   ISHELL_GetDeviceInfo(ps,&di);
   pme->m_nSBWidth = di.cxScrollBar;

   pbmDst = IDISPLAY_GetDestination(pme->m_pDisplay);
   IBITMAP_GetInfo(pbmDst, &bi, sizeof(bi));
   IBITMAP_Release(pbmDst);
   pme->m_cxScreen = (int16)bi.cx;
   pme->m_cyScreen = (int16)bi.cy;
   MEMSET((void *)&pme->m_ptTracker, 0, sizeof(pme->m_ptTracker));
   MEMSET((void *)&pme->m_ptViewSize, 0, sizeof(pme->m_ptViewSize));
   pme->m_arPenRepeat.wItem = AEEREPEAT_SCROLLBAR;
   nSize = sizeof(AEEAutoRepeat);
   ISHELL_GetDeviceInfoEx(ps, AEE_DEVICEITEM_REPEAT_TIME, (void *)&pme->m_arPenRepeat, &nSize);

   return(0);
}

/*=====================================================================

Public Method - Decrements the reference count.  When it reaches 0, the object
is freed.

======================================================================*/
static uint32 ImageCtl_Release(IImageCtl * po)
{
   ImageCtl * pme = (ImageCtl *)po;

   if(pme->m_nRefs){
      if(--pme->m_nRefs)
         return(pme->m_nRefs);
      aee_releaseobj((void **)(&pme->m_pImage));
      aee_releaseobj((void **)(&pme->m_pDisplay));
      FREE(pme);
   }
   return(0);
}

/*=====================================================================

Public Method - Increments the reference count on the object.

======================================================================*/
static uint32 ImageCtl_AddRef(IImageCtl * po)
{
   ImageCtl * pme = (ImageCtl *)po;

   return(++pme->m_nRefs);
}

/*===========================================================================

Public Method - Returns the rectangle of the clock. See AEEAClock.h

===========================================================================*/
static void ImageCtl_GetRect(IImageCtl * po, AEERect * prc)
{
   ImageCtl * pme = (ImageCtl *)po;

   if(prc)
      *prc = pme->m_rc;
}

/*===========================================================================

Public Method - Sets the rectangle for the clock. See AEEAClock.h

===========================================================================*/
static void ImageCtl_SetRect(IImageCtl * po, const AEERect * prc)
{
   ImageCtl * pme = (ImageCtl *)po;

   if(prc){
      pme->m_rc = *prc;
      ImageCtl_CheckScroll(pme);
   }
}

/*===========================================================================

Public Method - Ignored. See AEEAClock.h

===========================================================================*/
static void ImageCtl_SetActive(IImageCtl * po, boolean bActive)
{
   ImageCtl * pme = (ImageCtl *)po;

   if(bActive != pme->m_bActive){
      pme->m_bActive = bActive;
      ImageCtl_RedrawCB(pme);
   }
}

/*===========================================================================

Public Method - Ignored. See AEEAClock.h

===========================================================================*/
static boolean ImageCtl_IsActive(IImageCtl * po)
{
   ImageCtl * pme = (ImageCtl *)po;

   return(pme->m_bActive);
}

/*===========================================================================

Public Method - Ignored. See AEEAClock.h

===========================================================================*/
static boolean ImageCtl_HandleEvent
(
	IImageCtl*	po,
	AEEEvent	evt,
	uint16		wp,
	uint32		dwp
)
{
   ImageCtl* pme = (ImageCtl*)po;
   switch( evt ){
      case EVT_PEN_STALE_MOVE:
      {
         return FALSE; // Quickly not handled
      }
      case EVT_PEN_MOVE:
      {
         if( pme->m_ptTracker.cbHit ){
            // Need to do things in relation to where the pen is and whether on thumb or off
            if( pme->m_ptTracker.cbHit & PTRCK_HIT_THUMB ){
               int16       wXPos = AEE_GET_X(dwp);
               int16       wYPos = AEE_GET_Y(dwp);
               int         nRange = 0,nScrollRange = 0,nLen = 0;
               int *       pnOffset = NULL;     // If filled, means scrolled within a valid range
               int16       wIdx, wGenericPos = 0, wBase = 0;

               // This logic is married to ImageCtl_GetScrollBarRects()
               // It is inverted as in Solve for offsets
               if( pme->m_ptTracker.cbHit & PTRCK_HIT_VSCRL ){
                  if( wXPos >= ((pme->m_rc.x + pme->m_rc.dx) - pme->m_nSBWidth)
                     && wXPos < (pme->m_rc.x + pme->m_rc.dx) ){
                     int y,cy;
                     // Inside the Scrollbar still

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -