Beispiel #1
0
void* ItemJSBinding::GetRealItem(int32 id)
{
	return GetItem((uint32)id);
}
Beispiel #2
0
/* UniformSegment: and cluster within each state/segment */
void UniformSegment(void)
{
   Sequence **seqMat;   /* Matrix [2..numStates-1][1..numStreams]*/
   Sequence seq;
   int count,size,i,vqidx,s,n,m,M,j,k;
   ClusterSet *cset;
   Cluster *c;
   StreamElem *ste;
   Covariance cov;
   CovKind ck;
   MixPDF *mp;
   TMixRec *tmRec = NULL;
   ShortVec dw;
   float x,z;
   Vector floor;

   if (trace & T_UNI)
      printf(" Uniform Segmentation\n");
   seqMat = CreateSeqMat();
   cov.var = NULL;      /* dummy */
   UCollectData(seqMat);
   if (trace&T_UNI) ShowSeqMat(seqMat);

   /* Cluster Each State/Stream and Init HMM Parms */
   for (n=2; n<nStates; n++) {
      if (trace&T_UNI) printf(" state %d ",n);
      for (s=1; s<=nStreams; s++){
         size = hset.swidth[s];
         floor = vFloor[s];
         ste = hmmLink->svec[n].info->pdf+s;
         if (hset.hsKind == TIEDHS){
            tmRec = &(hset.tmRecs[s]);
            M = tmRec->nMix;
            tmRec->topM = tmRec->nMix;
         }
         else
            M = ste->nMix; 
         if (trace&T_UNI) printf(" stream %d\n",s);
         seq = seqMat[n][s];
         switch (hset.hsKind){
         case PLAINHS:
         case SHAREDHS:
            ck = ste->spdf.cpdf[1].mpdf->ckind;
            cset = FlatCluster(&clustSetStack,seq,M,NULLC,ck,cov);
            if (trace&T_UNI) ShowClusterSet(cset);
            for (m=1; m<=M; m++){
               mp = ste->spdf.cpdf[m].mpdf;
               if (mp->ckind != ck)
                  HError(2123,"UniformSegment: different covkind within a mix\n");
               c = cset->cl+m;
               if (uFlags&UPMIXES)
                  ste->spdf.cpdf[m].weight = (float)c->csize/(float)seq->nItems;
               if (uFlags&UPMEANS)
                  CopyVector(c->vCtr,mp->mean);
               if (uFlags&UPVARS)
                  switch(ck){
                  case DIAGC:
                     for (j=1; j<=size; j++){
                        z= c->cov.var[j];
                        mp->cov.var[j] = (z<floor[j])?floor[j]:z;
                     }
                     break;
                  case FULLC:
                     for (j=1; j<=size; j++){
                        for (k=1; k<j; k++) {
                           mp->cov.inv[j][k] = c->cov.inv[j][k];
                        }
                        z = c->cov.inv[j][j];
                        mp->cov.inv[j][j] = (z<floor[j])?floor[j]:z;
                     }
                     break;
                  default:
                     HError(2124,"UniformSegment: bad cov kind %d\n",ck);
                  }
            }
            break;
         case DISCRETEHS:
            count = 0; dw = ste->spdf.dpdf;
            ZeroShortVec(dw);             
            for (i=1; i<=seq->nItems; i++){
               vqidx = (int)GetItem(seq,i);
               if (vqidx<1 || vqidx>M)
                  HError(2170,"UniformSegment: vqidx out of range[%d]",vqidx);
               ++dw[vqidx]; ++count;
            }
            for (m=1; m<=M; m++){
               x = (float)dw[m]/(float)count;
               if (x<mixWeightFloor) x = mixWeightFloor;
               dw[m] = DProb2Short(x);
            }
            break;
         case TIEDHS:
            ck = tmRec->mixes[1]->ckind;
            cset = FlatCluster(&clustSetStack,seq,M,NULLC,ck,cov);
            if (trace&T_UNI) ShowClusterSet(cset);
            for (m=1; m<=M; m++){
               mp = tmRec->mixes[m];
               if (mp->ckind != ck)
                  HError(2123,"UniformSegment: different covkind within a mix\n");
               c = cset->cl+m;
               if (uFlags&UPMIXES)
                  ste->spdf.tpdf[m] = (float)c->csize/(float)seq->nItems;
               if (uFlags&UPMEANS)
                  CopyVector(c->vCtr,mp->mean);
               if (uFlags&UPVARS)
                  switch(ck){
                  case DIAGC:
                     for (j=1; j<=size; j++){
                        z= c->cov.var[j];
                        mp->cov.var[j] = (z<floor[j])?floor[j]:z;
                     }
                     break;
                  case FULLC:
                     for (j=1; j<=size; j++){
                        for (k=1; k<j; k++) {
                           mp->cov.inv[j][k] = c->cov.inv[j][k];
                        }
                        z = c->cov.inv[j][j];
                        mp->cov.inv[j][j] = (z<floor[j])?floor[j]:z;
                     }
                     break;                     
                  default:
                     HError(2124,"UniformSegment: bad cov kind %d\n",ck);
                  }                 
            }
            break;       
         }
         ResetHeap(&clustSetStack);
      }
      if ((hset.hsKind == PLAINHS) || (hset.hsKind == SHAREDHS))
         FixGConsts(hmmLink);
   }
   ResetHeap(&sequenceStack);
}
Beispiel #3
0
void Selection(void)			// This Is Where Selection Is Done
{
     GLuint	buffer[512];		// Set Up A Selection Buffer
     GLint	hits;			// The Number Of Objects That We Selected


	  // The Size Of The Viewport. [0] Is <x>, [1] Is <y>, [2] Is <length>, [3] Is <width>
	  GLint	viewport[4];

	  // This Sets The Array <viewport> To The Size And Location Of The Screen Relative To The Window
	  glGetIntegerv(GL_VIEWPORT, viewport);
	  glSelectBuffer(512, buffer);								// Tell OpenGL To Use Our Array For Selection

	  // Puts OpenGL In Selection Mode. Nothing Will Be Drawn.  Object ID's and Extents Are Stored In The Buffer.
	  (void) glRenderMode(GL_SELECT);

	  glInitNames();	// Initializes The Name Stack
	  glPushName(0);	// Push 0 (At Least One Entry) Onto The Stack

	  glMatrixMode(GL_PROJECTION);	// Selects The Projection Matrix
	  glPushMatrix();		// Push The Projection Matrix
	  glLoadIdentity();		// Resets The Matrix

	  // This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen, Where The Mouse Is.
	  gluPickMatrix((GLdouble) resX/2.0, (GLdouble) resY/2.0, 2.0f, 2.0f, viewport);

	  // Apply The Perspective Matrix
	  gluPerspective(45.0f, (GLfloat) (viewport[2]-viewport[0])/(GLfloat) (viewport[3]-viewport[1]), 0.1f, 100.0f);
	  glMatrixMode(GL_MODELVIEW);			// Select The Modelview Matrix
// 	  DrawTargets();				// Render The Targets To The Selection Buffer

	  if(display == LAND1)dLand1(0);
	  if(display == DUNG1)dDungeon(1);

	  glMatrixMode(GL_PROJECTION);			// Select The Projection Matrix
	  glPopMatrix();				// Pop The Projection Matrix
	  glMatrixMode(GL_MODELVIEW);			// Select The Modelview Matrix
	  hits=glRenderMode(GL_RENDER);			// Switch To Render Mode, Find Out How Many
	  // Objects Were Drawn Where The Mouse Was

	 //test
	 int dmg = you[0].dmg + you[0].dmgB;




	 if (hits > 0)		// If There Were More Than 0 Hits
	  {
	       int choose = buffer[3];	// Make Our Selection The First Object
	       int depth = buffer[1];		// Store How Far Away It Is
	       int loop;

	       for (loop = 1; loop < hits; loop++)		// Loop Through All The Detected Hits
	       {
		    // If This Object Is Closer To Us Than The One We Have Selected
		    if (buffer[loop*4+1] < depth  && buffer[loop*4+3] != 6 && buffer[loop*4+3] != 5)
		    {
			 choose = buffer[loop*4+3];		// Select The Closer Object
			 depth = buffer[loop*4+1];		// Store How Far Away It Is
		    }
	       }
	       if(display == LAND1)
		{
		      if (choose == 1)//anubis
		      {
			    anb[0].Hp -= (you[0].dmg + you[0].dmgB);
			    sprintf(tmppp,"You hit Anubis%d for %d damage\n",1,dmg);
			    tmpC=tmppp; tmp_text = 90;

			    if(anb[0].Hp <= 0)
			    {
				  you[0].XP += anb[0].XP;
				  anb[0].alive = 0;
				  Mix_PlayChannel(-1, AnbDie, 0);
				  GetItem(QList[1].itemNeeded);
				  tmpC = "You killed Anubis, gained 1 item";
			    }
		      }
		      if (choose == 2)//Spider #1
		      {
			    spd[0].Hp -= (you[0].dmg + you[0].dmgB);
			    sprintf(tmppp,"You hit Spider%d for %d damage\n",1,dmg);
			    tmpC=tmppp; tmp_text = 90;

			    if(spd[0].Hp <= 0)
			    {
				  you[0].XP += spd[0].XP;
				  spd[0].alive = 0;
				  Mix_PlayChannel(-1, SpdDie, 0);
				  tmpC = "You killed Giant Spider";
			    }
		      }

	       }
	       if(display == DUNG1)
		{
		     if (choose > 2)
		     {
			   Dun0Mobs[choose-3].Hp -= (you[0].dmg + you[0].dmgB);
			   sprintf(tmppp,"You hit Spider%d for %d damage\n",choose-3,dmg);
			   tmpC=tmppp; tmp_text = 90;

			   if(Dun0Mobs[choose-3].Hp <= 0)
			   {
				 you[0].XP += spd[0].XP;
				 Dun0Mobs[choose-3].alive = 0;
				 Mix_PlayChannel(-1, SpdDie, 0);
				 sprintf(tmppp,"You killed Spider%d \n",choose-3);
				 tmpC=tmppp; tmp_text = 90;
// 				 tmpC = "You killed Giant Spider";
			   }
		     }
// 		     printf("Debug::Hit%d\n",choose);
		}

	       checkLevel();
	  }

}
void CIrcChannelTabCtrl::OnContextMenu(CWnd*, CPoint point)
{
    int iCurTab = GetTabUnderMouse(point);
    if (iCurTab < 2)
    {
        return;
    }
    TCITEM item;
    item.mask = TCIF_PARAM;
    GetItem(iCurTab, &item);

    Channel* pChan = FindChannelByName(((Channel*)item.lParam)->m_sName);
    if( !pChan )
    {
        return;
    }

    CTitleMenu menuChat;
    menuChat.CreatePopupMenu();
    menuChat.AddMenuTitle(GetResString(IDS_IRC)+_T(" : ")+pChan->m_sName);
    menuChat.AppendMenu(MF_STRING, Irc_Close, GetResString(IDS_FD_CLOSE));
    if (iCurTab < 2) // no 'Close' for status log and channel list
        menuChat.EnableMenuItem(Irc_Close, MF_GRAYED);

    int iCurIndex = 0;
    int iLength = m_sChannelModeSettingsTypeA.GetLength();
    CString sMode;
    for( int iIndex = 0; iIndex < iLength; iIndex++)
    {
        sMode = m_sChannelModeSettingsTypeA.Mid(iIndex,1);
        if( pChan->m_sModesA.Find(sMode) == -1 )
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeA Set +") + sMode + _T(" ( Not Supported Yet )") );
            menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED);
        }
        else
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeA Set -") + sMode + _T(" ( Not Supported Yet )") );
            menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex+50, MF_GRAYED);
        }
        iCurIndex++;
    }
    iLength = m_sChannelModeSettingsTypeB.GetLength();
    for( int iIndex = 0; iIndex < iLength; iIndex++)
    {
        sMode = m_sChannelModeSettingsTypeB.Mid(iIndex,1);
        if( pChan->m_sModesB.Find(sMode) == -1 )
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeB Set +") + sMode + _T(" ( Not Supported Yet )") );
            menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED);
        }
        else
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeB Set -") + sMode + _T(" ( Not Supported Yet )") );
            menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex+50, MF_GRAYED);
        }
        iCurIndex++;
    }
    iLength = m_sChannelModeSettingsTypeC.GetLength();
    for( int iIndex = 0; iIndex < iLength; iIndex++)
    {
        sMode = m_sChannelModeSettingsTypeC.Mid(iIndex,1);
        if( pChan->m_sModesC.Find(sMode) == -1 )
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeC Set +") + sMode + _T(" ( Not Supported Yet )") );
            menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED);
        }
        else
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeC Set -") + sMode + _T(" ( Remove ") + sMode + _T(" )") );
        }
        iCurIndex++;
    }
    iLength = m_sChannelModeSettingsTypeD.GetLength();
    for( int iIndex = 0; iIndex < iLength; iIndex++)
    {
        sMode = m_sChannelModeSettingsTypeD.Mid(iIndex,1);
        if( pChan->m_sModesD.Find(sMode) == -1 )
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeD Set +") + sMode + _T(" ( Add ") + sMode + _T(" )") );
        }
        else
        {
            menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeD Set -") + sMode + _T(" ( Remove ") + sMode + _T(" )") );
        }
        iCurIndex++;
    }

    menuChat.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
    VERIFY( menuChat.DestroyMenu() );
}
BOOL CIrcChannelTabCtrl::OnCommand(WPARAM wParam, LPARAM)
{
    int iChanItem = m_pParent->m_tabctrlChannelSelect.GetCurSel();
    switch( wParam )
    {
    case Irc_Close:
    {
        //Pressed the close button
        m_pParent->OnBnClickedClosechat();
        return true;
    }
    }
    uint32 uCommand = Irc_ChanCommands;
    if( wParam >= uCommand && wParam < uCommand+50)
    {
        CString sMode, sSend;
        int iIndex = wParam - uCommand;
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeA.Mid(iIndex,1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s +%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeB.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s +%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength()+m_sChannelModeSettingsTypeC.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeC.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength()-m_sChannelModeSettingsTypeB.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s +%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength()+m_sChannelModeSettingsTypeC.GetLength()+m_sChannelModeSettingsTypeD.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeD.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength()-m_sChannelModeSettingsTypeB.GetLength()-m_sChannelModeSettingsTypeC.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s +%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        return true;
    }
    if( wParam >= uCommand+50 && wParam < uCommand+100)
    {
        int iIndex = wParam - uCommand - 50;
        CString sMode, sSend;
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeA.Mid(iIndex,1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s -%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeB.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s -%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength()+m_sChannelModeSettingsTypeC.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeC.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength()-m_sChannelModeSettingsTypeB.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s -%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        if( iIndex < m_sChannelModeSettingsTypeA.GetLength()+m_sChannelModeSettingsTypeB.GetLength()+m_sChannelModeSettingsTypeC.GetLength()+m_sChannelModeSettingsTypeD.GetLength() )
        {
            sMode = m_sChannelModeSettingsTypeD.Mid(iIndex-m_sChannelModeSettingsTypeA.GetLength()-m_sChannelModeSettingsTypeB.GetLength()-m_sChannelModeSettingsTypeC.GetLength(),1);
            TCITEM item;
            item.mask = TCIF_PARAM;
            GetItem(iChanItem,&item);
            Channel* pChan = (Channel*)item.lParam;
            if( pChan )
            {
                //We have a chan, send the command.
                sSend.Format( _T("MODE %s -%s"), pChan->m_sName, sMode );
                m_pParent->m_pIrcMain->SendString(sSend);
            }
            return true;
        }
        return true;
    }
    return true;
}
Beispiel #6
0
void CQListCtrl::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
    
    *pResult = 0;
	
    // Request item-specific notifications if this is the
    // beginning of the paint cycle.
    if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
	{
        *pResult = CDRF_NOTIFYITEMDRAW;
	}
    else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
	{
        LVITEM   rItem;
        int      nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
        CDC*     pDC   = CDC::FromHandle ( pLVCD->nmcd.hdc );
        COLORREF crBkgnd;
        BOOL     bListHasFocus;
        CRect    rcItem;
		
        bListHasFocus = ( GetSafeHwnd() == ::GetFocus() );
        
        // Get the image index and selected/focused state of the
        // item being drawn.
        ZeroMemory ( &rItem, sizeof(LVITEM) );
        rItem.mask  = LVIF_STATE;
        rItem.iItem = nItem;
        rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
        GetItem(&rItem);
		
        // Get the rect that bounds the text label.
        GetItemRect(nItem, rcItem, LVIR_LABEL);
		rcItem.left -= DUMMY_COL_WIDTH;
		
		COLORREF OldColor = -1;
		int nOldBKMode = -1;

		CString csText;
		LPTSTR lpszText = csText.GetBufferSetLength(g_Opt.m_bDescTextSize);
		GetItemText(nItem, 0, lpszText, g_Opt.m_bDescTextSize);
		csText.ReleaseBuffer();

		// extract symbols
		CString strSymbols;
		int nSymEnd = csText.Find('|');
		if (nSymEnd >= 0)
		{
			strSymbols = csText.Left(nSymEnd);
			csText = csText.Mid(nSymEnd + 1);
		}
		
		// Draw the background of the list item.  Colors are selected 
		// according to the item's state.
		if(rItem.state & LVIS_SELECTED)
		{
            if(bListHasFocus)
			{
                crBkgnd = g_Opt.m_Theme.ListBoxSelectedBG();
                OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxSelectedText());
			}
            else
			{
                crBkgnd = g_Opt.m_Theme.ListBoxSelectedNoFocusBG();
                OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxSelectedNoFocusText());
			}
		}
        else
		{
            //Shade alternating Rows
			if((nItem % 2) == 0)
			{
				crBkgnd = g_Opt.m_Theme.ListBoxOddRowsBG();
				OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxOddRowsText());
			}
			else
			{
				crBkgnd = g_Opt.m_Theme.ListBoxEvenRowsBG();
				OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxEvenRowsText());
			}
		}
		
        pDC->FillSolidRect(rcItem, crBkgnd);
        nOldBKMode = pDC->SetBkMode(TRANSPARENT);
		
        CRect rcText = rcItem;
        rcText.left += ROW_LEFT_BORDER;
		rcText.top++;
		
		if (m_showIfClipWasPasted &&
			strSymbols.GetLength() > 0 &&
			strSymbols.Find(_T("<pasted>")) >= 0) //clip was pasted from ditto 
		{
			CRect pastedRect(rcItem);
			pastedRect.left++;
			pastedRect.right = rcItem.left + theApp.m_metrics.ScaleX(3);
				
			pDC->FillSolidRect(pastedRect, g_Opt.m_Theme.ClipPastedColor());

			rcText.left += theApp.m_metrics.ScaleX(4);
		}
		        		
		// set firstTenNum to the first ten number (1-10) corresponding to
		//  the current nItem.
		// -1 means that nItem is not in the FirstTen block.
		int firstTenNum = GetFirstTenNum(nItem);
		
		if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
		{
			rcText.left += theApp.m_metrics.ScaleX(12);
		}
		
		bool drawInGroupIcon = true;
		// if we are inside a group, don't display the "in group" flag
		if( theApp.m_GroupID > 0 )
		{
			int nFlag = strSymbols.Find(_T("<ingroup>"));
			if (nFlag >= 0)
				drawInGroupIcon = false;
		}
		
		DrawBitMap(nItem, rcText, pDC, csText);			

		// draw the symbol box
		if( strSymbols.GetLength() > 0 )
		{
			if(strSymbols.Find(_T("<group>")) >= 0) //group 
			{
				m_groupFolder.Draw(pDC, this, rcText.left, rcText.top, false, false);
				rcText.left += m_groupFolder.ImageWidth() + theApp.m_metrics.ScaleX(2);
			}
			if (strSymbols.Find(_T("<noautodelete>")) >= 0 &&
				strSymbols.Find(_T("<group>")) < 0 &&
				strSymbols.Find(_T("<sticky>")) < 0) //don't auto delete
			{
				m_dontDeleteImage.Draw(pDC, this, rcText.left, rcText.top, false, false);
				rcText.left += m_dontDeleteImage.ImageWidth() + theApp.m_metrics.ScaleX(2);
			}
			if (strSymbols.Find(_T("<shortcut>")) >= 0) // has shortcut
			{
				m_shortCutImage.Draw(pDC, this, rcText.left, rcText.top, false, false);
				rcText.left += m_shortCutImage.ImageWidth() + theApp.m_metrics.ScaleX(2);
			}
			if (drawInGroupIcon &&
				strSymbols.Find(_T("<ingroup>")) >= 0) // in group
			{
				m_inFolderImage.Draw(pDC, this, rcText.left, rcText.top, false, false);
				rcText.left += m_inFolderImage.ImageWidth() + theApp.m_metrics.ScaleX(2);
			}
			if (strSymbols.Find(_T("<qpastetext>")) >= 0) // has quick paste text
			{
			}
			if (strSymbols.Find(_T("<sticky>")) >= 0) //sticky clip
			{
				m_stickyImage.Draw(pDC, this, rcText.left, rcText.top, false, false);
				rcText.left += m_stickyImage.ImageWidth() + theApp.m_metrics.ScaleX(2);
			}			
		}
		
		if(DrawRtfText(nItem, rcText, pDC) == FALSE)
		{
			if (m_searchText.GetLength() > 0 &&
				FindNoCaseAndInsert(csText, m_searchText, _T("<font color='#ff0000'>"), _T("</font>")) > 0)
			{				
				DrawHTML(pDC->m_hDC, csText, csText.GetLength(), rcText, DT_VCENTER | DT_EXPANDTABS | DT_NOPREFIX);
			}
			else
			{
				pDC->DrawText(csText, rcText, DT_VCENTER | DT_EXPANDTABS | DT_NOPREFIX);
			}
		}
		
        // Draw a focus rect around the item if necessary.
        if(bListHasFocus && (rItem.state & LVIS_FOCUSED))
			pDC->DrawFocusRect(rcItem);
						
		if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
		{
			CString cs;
			if( firstTenNum == 10 )
				cs = "0";
			else
				cs.Format(_T("%d"), firstTenNum);
			
			CRect crClient;
			
			GetWindowRect(crClient);
			ScreenToClient(crClient);
			
			CRect crHotKey = rcItem;

			int extraFromClipWasPaste = 0;
			if (m_showIfClipWasPasted)
				extraFromClipWasPaste = 3;
			
			crHotKey.right = crHotKey.left + theApp.m_metrics.ScaleX(11);
			crHotKey.left += theApp.m_metrics.ScaleX(1 + extraFromClipWasPaste);
			crHotKey.top += theApp.m_metrics.ScaleX(1 + extraFromClipWasPaste);
			
			HFONT hOldFont = (HFONT)pDC->SelectObject(m_SmallFont);
			
			pDC->DrawText(cs, crHotKey, DT_BOTTOM);
			
			pDC->MoveTo(CPoint(rcItem.left + theApp.m_metrics.ScaleX(8 + extraFromClipWasPaste), rcItem.top));
			pDC->LineTo(CPoint(rcItem.left + theApp.m_metrics.ScaleX(8 + extraFromClipWasPaste), rcItem.bottom));
			
			pDC->SelectObject(hOldFont);
		}
		
		// restore the previous values		
		if(OldColor > -1)
			pDC->SetTextColor(OldColor);
		
		if(nOldBKMode > -1)
			pDC->SetBkMode(nOldBKMode);
		
        *pResult = CDRF_SKIPDEFAULT;    // We've painted everything.
	}
}
Beispiel #7
0
void CWndVendorCtrl::OnDraw( C2DRender* p2DRender )
{
	if( m_pMover == NULL )
		return;
	
	CRect rect	= GetClientRect();
	int nWidth	= rect.Width() / 32;
	int nHeight		= rect.Height() / 32;

#if __VER >= 8 //__S8_VENDOR_REVISION
	int i; for( i = 0; i < MAX_VENDOR_REVISION; i++ )
#else //__S8_VENDOR_REVISION
	int i; for( i = 0; i < MAX_VENDITEM; i++ )
#endif //__S8_VENDOR_REVISION
	{
		int x	= i % 2;
		int y	= i / 2;
		
		int nX;
		int nY = y * 32 + 8 + y * 4;
		if( x == 0 )
			nX = x * 32 + 15;
		else
			nX = 235;

		CRect rectHittest = CRect( nX, nY, nX + 180, nY + 32 );
		CPoint point	= GetMousePoint();
		if( rectHittest.PtInRect( point ) )
		{
			if( CWndBase::m_GlobalShortcut.m_dwData )
			{
				m_nCurSel = -1;
				{
					CPoint ptx = CPoint(nX, nY);
					m_pTex->Render( p2DRender, ptx );		// 아이템 테두리 그리기
				}
			}
		}			
		CItemBase* pItemBase = GetItem( i );
		if( pItemBase )
		{

			// 툴팁
			float fScal = 1.0f;
			CPoint point	= GetMousePoint();
			if( rectHittest.PtInRect( point ) )
			{
				fScal = 1.15f;
				CPoint point2 = point;
				ClientToScreen( &point2 );
				ClientToScreen( &rectHittest );
				g_WndMng.PutToolTip_Item( pItemBase, point2, &rectHittest, APP_VENDOR );
			}

			// 아이템 아이콘 
			if( ((CItemElem*)pItemBase)->IsFlag( CItemElem::expired ) )
				pItemBase->GetTexture()->Render2( p2DRender, CPoint( nX, nY ), D3DCOLOR_XRGB( 255, 100, 100 ) );					
			else
				pItemBase->GetTexture()->Render2( p2DRender, CPoint( nX, nY ), D3DCOLOR_XRGB( 255, 255, 255 ), fScal, fScal );

			// 아이템 이름, 판매가격
			OnDrawItemInfo( p2DRender, ((CItemElem*)pItemBase), nX, nY );

			if( i == m_nCurSel )
				p2DRender->RenderRect( CRect( nX, nY, nX + 32, nY + 32 ), 0xff00ffff );
			CItemElem* pItemElem	= (CItemElem*)pItemBase;
			if( pItemElem->GetProp()->dwPackMax > 1 )
			{
				short nItemNum	= pItemBase->GetExtra();
				TCHAR szTemp[32];
				_stprintf( szTemp, "%d", nItemNum );
				CSize size	= p2DRender->m_pFont->GetTextExtent( szTemp );
				p2DRender->TextOut( nX - 7 + 32 - size.cx+5, nY - 11 + 32 - size.cy+12, szTemp, 0xff1010ff );
			}
		}
	}
}
Beispiel #8
0
void QFitWidget::SetWidgetItemText(bool trace)
{
    if (fxPanel!=0)
        fxPanel->SetItemText(GetItem(), trace);
}
Beispiel #9
0
void Corpse::LootItem(Client* client, const EQApplicationPacket* app) {
	/* This gets sent no matter what as a sort of ACK */
	client->QueuePacket(app);

	if (!loot_cooldown_timer.Check()) {
		SendEndLootErrorPacket(client);
		//unlock corpse for others
		if (this->being_looted_by = client->GetID()) {
			being_looted_by = 0xFFFFFFFF;
		}
		return;
	}

	/* To prevent item loss for a player using 'Loot All' who doesn't have inventory space for all their items. */
	if (RuleB(Character, CheckCursorEmptyWhenLooting) && !client->GetInv().CursorEmpty()) {
		client->Message(13, "You may not loot an item while you have an item on your cursor.");
		SendEndLootErrorPacket(client);
		/* Unlock corpse for others */
		if (this->being_looted_by = client->GetID()) {
			being_looted_by = 0xFFFFFFFF;
		}
		return;
	}

	LootingItem_Struct* lootitem = (LootingItem_Struct*)app->pBuffer;

	if (this->being_looted_by != client->GetID()) {
		client->Message(13, "Error: Corpse::LootItem: BeingLootedBy != client");
		SendEndLootErrorPacket(client);
		return;
	}
	if (IsPlayerCorpse() && !CanPlayerLoot(client->CharacterID()) && !become_npc && (char_id != client->CharacterID() && client->Admin() < 150)) {
		client->Message(13, "Error: This is a player corpse and you dont own it.");
		SendEndLootErrorPacket(client);
		return;
	}
	if (is_locked && client->Admin() < 100) {
		SendLootReqErrorPacket(client, 0);
		client->Message(13, "Error: Corpse locked by GM.");
		return;
	}
	if (IsPlayerCorpse() && (char_id != client->CharacterID()) && CanPlayerLoot(client->CharacterID()) && GetPlayerKillItem() == 0){
		client->Message(13, "Error: You cannot loot any more items from this corpse.");
		SendEndLootErrorPacket(client);
		being_looted_by = 0xFFFFFFFF;
		return;
	}
	const Item_Struct* item = 0;
	ItemInst *inst = 0;
	ServerLootItem_Struct* item_data = nullptr, *bag_item_data[10];

	memset(bag_item_data, 0, sizeof(bag_item_data));
	if (GetPlayerKillItem() > 1){
		item = database.GetItem(GetPlayerKillItem());
	}
	else if (GetPlayerKillItem() == -1 || GetPlayerKillItem() == 1){
		item_data = GetItem(lootitem->slot_id - EmuConstants::CORPSE_BEGIN); //dont allow them to loot entire bags of items as pvp reward
	}
	else{
		item_data = GetItem(lootitem->slot_id - EmuConstants::CORPSE_BEGIN, bag_item_data);
	}

	if (GetPlayerKillItem()<=1 && item_data != 0) {
		item = database.GetItem(item_data->item_id);
	}

	if (item != 0) {
		if (item_data){ 
			inst = database.CreateItem(item, item_data ? item_data->charges : 0, item_data->aug_1, item_data->aug_2, item_data->aug_3, item_data->aug_4, item_data->aug_5, item_data->aug_6, item_data->attuned);
		}
		else {
			inst = database.CreateItem(item);
		}
	}

	if (client && inst) {
		if (client->CheckLoreConflict(item)) {
			client->Message_StringID(0, LOOT_LORE_ERROR);
			SendEndLootErrorPacket(client);
			being_looted_by = 0;
			delete inst;
			return;
		}

		if (inst->IsAugmented()) {
			for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
				ItemInst *itm = inst->GetAugment(i);
				if (itm) {
					if (client->CheckLoreConflict(itm->GetItem())) {
						client->Message_StringID(0, LOOT_LORE_ERROR);
						SendEndLootErrorPacket(client);
						being_looted_by = 0;
						delete inst;
						return;
					}
				}
			}
		}

		char buf[88];
		char corpse_name[64];
		strcpy(corpse_name, corpse_name);
		snprintf(buf, 87, "%d %d %s", inst->GetItem()->ID, inst->GetCharges(), EntityList::RemoveNumbers(corpse_name));
		buf[87] = '\0';
		std::vector<EQEmu::Any> args;
		args.push_back(inst);
		args.push_back(this);
		parse->EventPlayer(EVENT_LOOT, client, buf, 0, &args);
		parse->EventItem(EVENT_LOOT, client, inst, this, buf, 0);

		if (!IsPlayerCorpse() && RuleB(Character, EnableDiscoveredItems)) {
			if (client && !client->GetGM() && !client->IsDiscovered(inst->GetItem()->ID))
				client->DiscoverItem(inst->GetItem()->ID);
		}

		if (zone->adv_data) {
			ServerZoneAdventureDataReply_Struct *ad = (ServerZoneAdventureDataReply_Struct*)zone->adv_data;
			if (ad->type == Adventure_Collect && !IsPlayerCorpse()) {
				if (ad->data_id == inst->GetItem()->ID) {
					zone->DoAdventureCountIncrease();
				}
			}
		}

		/* First add it to the looter - this will do the bag contents too */
		if (lootitem->auto_loot) {
			if (!client->AutoPutLootInInventory(*inst, true, true, bag_item_data))
				client->PutLootInInventory(MainCursor, *inst, bag_item_data);
		}
		else {
			client->PutLootInInventory(MainCursor, *inst, bag_item_data);
		}

		/* Update any tasks that have an activity to loot this item */
		if (RuleB(TaskSystem, EnableTaskSystem))
			client->UpdateTasksForItem(ActivityLoot, item->ID);

		/* Remove it from Corpse */
		if (item_data){
			/* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */
			database.DeleteItemOffCharacterCorpse(this->corpse_db_id, item_data->equip_slot, item_data->item_id);
			/* Delete Item Instance */
			RemoveItem(item_data->lootslot);
		}

		/* Remove Bag Contents */
		if (item->ItemClass == ItemClassContainer && (GetPlayerKillItem() != -1 || GetPlayerKillItem() != 1)) {
			for (int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
				if (bag_item_data[i]) {
					/* Delete needs to be before RemoveItem because its deletes the pointer for item_data/bag_item_data */
					database.DeleteItemOffCharacterCorpse(this->corpse_db_id, bag_item_data[i]->equip_slot, bag_item_data[i]->item_id);
					/* Delete Item Instance */
					RemoveItem(bag_item_data[i]);
				}
			}
		}

		if (GetPlayerKillItem() != -1) {
			SetPlayerKillItemID(0);
		}

	/* Send message with item link to groups and such */
	Client::TextLink linker;
	linker.SetLinkType(linker.linkItemInst);
	linker.SetItemInst(inst);

		auto item_link = linker.GenerateLink();

		client->Message_StringID(MT_LootMessages, LOOTED_MESSAGE, item_link.c_str());

	if (!IsPlayerCorpse()) {
			Group *g = client->GetGroup();
			if(g != nullptr) {
				g->GroupMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE, client->GetName(), item_link.c_str());
			}
			else {
				Raid *r = client->GetRaid();
				if(r != nullptr) {
					r->RaidMessage_StringID(client, MT_LootMessages, OTHER_LOOTED_MESSAGE, client->GetName(), item_link.c_str());
				}
			}
		}
	}
	else {
		SendEndLootErrorPacket(client);
		safe_delete(inst);
		return;
	}

	if (IsPlayerCorpse()){
		client->SendItemLink(inst);
	}
	else{
		client->SendItemLink(inst, true);
	}

	safe_delete(inst);
}
Beispiel #10
0
TObject * QFitWidget::GetObject()
{
    if(GetItem()) return GetItem()->Object();
    else return 0;
}
Beispiel #11
0
void QFitWidget::UpdateWidgetItem(bool trace)
{
    if (fxPanel!=0)
        fxPanel->UpdateItem(GetItem(), trace);
}
Beispiel #12
0
void QFitWidget::UpdateItemsOfType(int typ, bool allitems)
{
    if (fxPanel!=0)
        fxPanel->UpdateItemsOfType(typ, allitems ? 0 : GetItem());
}
void COutlook2Ctrl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_iDragging == 1)
	{
		CRect rc1(m_dragRect);
		m_dragRect.SetRect(point.x-5 + m_iDragoffset, rc1.top, point.x + m_iDragoffset, rc1.bottom);
		if (rc1 != m_dragRect)
		{
			OnInvertTracker(rc1);
			OnInvertTracker(m_dragRect);
		}
	}
	else
	{
		int f,i,s;
		int r = HitTest(f,i,s,point);
		if (r == 1)
		{
			CClientDC dc(this); 
			if (iHiFolder >= 0 && iHiFolder != f)
			{
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
			}
			if (iHiFolder != f)
			{
				iHiFolder = f;
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, true);
			}
		}
		if (r == 4)
		{
			COL2SubItem	* ps = GetSubItem(f,i,s);
			CClientDC dc(this); 
			if (pLastHilink && pLastHilink != ps)
			{
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
			}
			if (pLastHilink != ps)
			{
				pLastHilink = ps;
				DrawSubItem(&dc, GetFolder(f), GetItem(f,i), ps, true);
				iHilinkFolder = f;
				iHilinkItem = i;
			}
		}

		if (r == 0)
		{
			if (iHiFolder >= 0)
			{
				CClientDC dc(this); 
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
				iHiFolder = -1;
			}
			if (pLastHilink != NULL)
			{
				CClientDC dc(this); 
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
				pLastHilink = NULL;
			}
		}
	}

	OLCTRL2_BASE_CLASS::OnMouseMove(nFlags, point);
}
Beispiel #14
0
void CUIListWnd::SendMessage(CUIWindow *pWnd, s16 msg, void *pData)
{
	if(pWnd == m_ScrollBar)
	{
		if(msg == SCROLLBAR_VSCROLL)
		{
			m_iFirstShownIndex = m_ScrollBar->GetScrollPos();
			UpdateList();
			GetMessageTarget()->SendMessage(this, SCROLLBAR_VSCROLL, NULL);
		}
	}
	else 
	{
		//если сообщение пришло от одного из элементов списка

		if( IsChild(pWnd) )
		{
			CUIListItem* pListItem2;
			CUIListItem* pListItem = smart_cast<CUIListItem*>(pWnd);
			R_ASSERT(pListItem);

			if(BUTTON_CLICKED == msg)
			{				
				for (WINDOW_LIST_it it = m_ChildWndList.begin(); it != m_ChildWndList.end(); ++it)
				{
					pListItem2 = smart_cast<CUIListItem*>(*it);
					if (!pListItem2) 
						continue;
					if (pListItem2->GetGroupID() == -1) 
						continue;
					if (pListItem2->GetGroupID() == 
						pListItem->GetGroupID())
					{
						pListItem2->SetHighlightText(true);
						pListItem2->SendMessage(this, LIST_ITEM_SELECT, pData);
						m_iSelectedItem = pListItem2->GetIndex();
						m_iSelectedItemGroupID = pListItem2->GetGroupID();
					}					
					else
					{
						pListItem2->SetHighlightText(false);
						pListItem2->SendMessage(this, LIST_ITEM_UNSELECT, pData);
					}
				}
				GetMessageTarget()->SendMessage(this, LIST_ITEM_CLICKED, pListItem);
			}
			
			else if(STATIC_FOCUS_RECEIVED == msg)
			{
				if (!m_bForceFocusedItem)
				{
					m_iFocusedItem = pListItem->GetIndex();
					m_iFocusedItemGroupID = pListItem->GetGroupID();
				}
				else if (m_iFocusedItem >= 0)
						m_iFocusedItemGroupID = GetItem(m_iFocusedItem)->GetGroupID();


				// prototype code
				
				for (WINDOW_LIST_it it = m_ChildWndList.begin(); it != m_ChildWndList.end(); ++it)
				{
					pListItem2 = smart_cast<CUIListItem*>(*it);
					if (!pListItem2) continue;
					if (pListItem2->GetGroupID() == -1) continue;
					if (pListItem2->GetGroupID() == pListItem->GetGroupID())
					{
						pListItem2->SetHighlightText(true);
						pListItem2->SendMessage(this, STATIC_FOCUS_RECEIVED, pData);
					}					
					else
					{
						pListItem2->SetHighlightText(false);
						pListItem2->SendMessage(this, STATIC_FOCUS_LOST, pData);
					}
				}
				// end prototype code
			}
			else if(STATIC_FOCUS_LOST == msg)
			{
				if(pListItem->GetIndex() == m_iFocusedItem && !m_bForceFocusedItem) m_iFocusedItem = -1;

				for (WINDOW_LIST_it it = m_ChildWndList.begin(); it != m_ChildWndList.end(); ++it)
				{
					pListItem2 = smart_cast<CUIListItem*>(*it);
					if (!pListItem2) continue;
					pListItem2->SetHighlightText(false);
					pListItem2->SendMessage(this, STATIC_FOCUS_LOST, pData);
				}
				m_bUpdateMouseMove = true;
			}
		}
	}

	CUIWindow::SendMessage(pWnd, msg, pData);
}
Beispiel #15
0
void CanvasMode_Normal::mouseDoubleClickEvent(QMouseEvent *m)
{
	m->accept();
	m_canvas->m_viewMode.m_MouseButtonPressed = false;
	m_canvas->resetRenderMode();
//	m_view->stopDragTimer();
	PageItem *currItem = 0;
	if (m_doc->m_Selection->isMultipleSelection())
	{
		if (GetItem(&currItem))
		{
			/* CB: old code, removing this as shift-alt select on an unselected table selects a cell now.
			//#6789 is closed by sorting this.
			if (currItem->isTableItem)
			{
				m_view->Deselect(false);
				m_doc->m_Selection->addItem(currItem);
				currItem->isSingleSel = true;
				//CB FIXME dont call this if the added item is item 0
				if (!m_doc->m_Selection->primarySelectionIs(currItem))
					currItem->emitAllToGUI();
				m_view->updateContents(currItem->getRedrawBounding(m_canvas->scale()));
			}*/
		}
		return;
	}
	if (GetItem(&currItem))
	{
		if (currItem->asLatexFrame()) 
		{
			if ((currItem->locked()) || (!currItem->ScaleType))
			{
				return;
			}
			if (currItem->imageShown())
				m_view->requestMode(modeEdit);
		} 
		else if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText))
		{
			if ((currItem->locked()) || (!currItem->ScaleType))
			{
				//mousePressEvent(m);
				return;
			}
			//If we double click on an image frame and theres no image assigned, open the
			//load picture dialog, else put it into edit mode if the frame is set to show the image
			if (currItem->itemType() == PageItem::ImageFrame)
			{
				if (currItem->Pfile.isEmpty())
					m_view->requestMode(submodeLoadPic);
				else if (!currItem->PictureIsAvailable)
					m_view->requestMode(submodeStatusPic);
				else if (currItem->imageShown())
					m_view->requestMode(modeEdit);
 			}
 			else if (currItem->itemType() == PageItem::TextFrame)
			{
 				m_view->requestMode(modeEdit);
			}
			else
				m_view->requestMode(modeEditClip);				
		}
		else if (currItem->itemType() == PageItem::TextFrame)
		{
			//CB old code
			//emit currItem->isAnnotation() ? AnnotProps() : Amode(modeEdit);
			//mousePressEvent(m);
			//CB if annotation, open the annotation dialog
			if (currItem->isAnnotation())
			{
				m_view->requestMode(submodeAnnotProps);
				//mousePressEvent(m);
			}
			//else if not in mode edit, set mode edit
			else if (m_doc->appMode != modeEdit)
			{
				m_view->requestMode(modeEdit);
				m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y());
				//CB ignore the double click and go with a single one
				//if we werent in mode edit before.
				//unsure if this is correct, but its ok given we had no
				//double click select until now.
//				mousePressEvent(m);
			}
		}
	}
}
Beispiel #16
0
void CTabCtrlEx::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    if(lpDrawItemStruct->CtlType == ODT_TAB)
    {
        CRect rect = lpDrawItemStruct->rcItem;
        INT nTabIndex = lpDrawItemStruct->itemID;
        if (nTabIndex < 0) return;

        TCHAR label[64];
        TC_ITEM tci;
        tci.mask = TCIF_TEXT|TCIF_IMAGE;
        tci.pszText = label;
        tci.cchTextMax = 63;
        GetItem(nTabIndex, &tci );

        CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
        if (!pDC) return;
        int nSavedDC = pDC->SaveDC();

        //填充背景色
        COLORREF rcBack;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
            rcBack = RGB(255, 255,255);
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            rcBack = RGB(0, 255, 0);
        else
            rcBack = GetSysColor(COLOR_BTNFACE);
        pDC->FillSolidRect(rect, rcBack);

        rect.top += ::GetSystemMetrics(SM_CYEDGE);

        pDC->SetBkMode(TRANSPARENT);

        //绘制图片
        CImageList *pImageList = GetImageList();
        if (pImageList && tci.iImage >= 0)
        {
            rect.left += pDC->GetTextExtent(_T(" ")).cx;       // Margin

            // Get height of image so we
            IMAGEINFO info;
            pImageList->GetImageInfo(tci.iImage, &info);
            CRect ImageRect(info.rcImage);
            INT nYpos = rect.top;

            pImageList->Draw(pDC, tci.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
            rect.left += ImageRect.Width();
        }

        //绘制字体
        COLORREF txtColor;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
        {
            rect.top -= ::GetSystemMetrics(SM_CYEDGE);

            txtColor = RGB(0,0,255);
        }
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            txtColor = RGB(128, 128, 128);
        else
            txtColor = GetSysColor(COLOR_WINDOWTEXT);
        pDC->SetTextColor(txtColor);
		int r=rect.right;
		rect.right-=15;
        pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
		rect.right=r;
		rect.left=rect.right-17;
		rect.top+=3;
		rect.bottom-=6;
		pDC->DrawFrameControl(&rect,DFCS_CAPTIONCLOSE,DFCS_BUTTONPUSH);
        pDC->RestoreDC(nSavedDC);

    }
}
void PilotListBox::update()
{
	aObject::update();

	timeSinceStart += frameLength;
	if ( timeSinceStart < 1.0 )
		return;

	if ( this->curItem >= itemCount )
	{
		for ( int i = 0; i < itemCount; i++ )
		{
			GetItem( i )->showGUIWindow( true );
			GetItem( i )->update();
		}

		bDone = true;
		return;	
	}// done

	for ( int i = 0; i < itemCount; i++ )
	{
		bDone = 0;
		aListItem* item = GetItem( i );
		if ( item )
		{
			if ( i < curItem )
			{
				item->showGUIWindow( true );
			}
			else if ( i == curItem )
			{
				PilotListItem* pilotItem = dynamic_cast<PilotListItem*>(item);
				if ( pilotItem )
				{

					
					if ( pilotItem->isDone()  )
					{
						pilotItem = NULL;
						while ( !pilotItem )
						{
							curItem++;
							scrollTime = 0.f;
							oldScroll = scrollBar->GetScrollPos();

							if ( curItem <= itemCount )
							{
								item = GetItem( curItem );					
								pilotItem = dynamic_cast<PilotListItem*>(item);
							}
							else
							{
								curItem++;
								break;
							}
						}
						if ( pilotItem )
						{
							pilotItem->begin();						
						}
					}
					else
						pilotItem->update();
				}
				else
					curItem++;

				if ( item )
				{
					float itemTop = item->globalY();
					if ( itemTop  > bottom() - 3 * height() / 4 && !newScroll )
					{
						// need to scroll
						oldScroll = scrollBar->GetScrollPos();
						newScroll = oldScroll + itemTop - bottom()  + 3 * height() / 4;

						if ( newScroll < oldScroll )
							newScroll = 0;
					}
					else if ( !newScroll )
						items[curItem]->showGUIWindow(1);


				}
				
			}
			else 
			{
				item->showGUIWindow( false );
			}

		}
	}

	if ( newScroll )
	{
		scrollTime += frameLength;
		long delta = 140.f * scrollTime;
		if ( delta + oldScroll < newScroll && delta + oldScroll < scrollBar->GetScrollMax() )
			scrollBar->SetScroll( oldScroll + delta );
		else
		{
			scrollBar->SetScroll( newScroll );
			if ( items[curItem] )
				items[curItem]->showGUIWindow(1);
			newScroll = 0;
			scrollTime = 0;
		}
	}
}
Beispiel #18
0
//
// Check items
// -----------
//
bool wxCheckListBox::IsChecked(unsigned int uiIndex) const
{
    return GetItem(uiIndex)->IsChecked();
} // end of wxCheckListBox::IsChecked
void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	CRect rect(lpDIS->rcItem);
	int nTabIndex = lpDIS->itemID;
	if (nTabIndex < 0)
		return;

	TCHAR szLabel[256];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
	tci.pszText = szLabel;
	tci.cchTextMax = _countof(szLabel);
	tci.dwStateMask = TCIS_HIGHLIGHTED;
	if (!GetItem(nTabIndex, &tci))
		return;
	szLabel[_countof(szLabel) - 1] = _T('\0');
	//TRACE("CClosableTabCtrl::DrawItem: item=%u, state=%08x, color=%08x, rc=%3d,%3d,%3dx%3d\n", nTabIndex, tci.dwState, GetTextColor(lpDIS->hDC), lpDIS->rcItem.left, lpDIS->rcItem.top, lpDIS->rcItem.right - lpDIS->rcItem.left, lpDIS->rcItem.bottom - lpDIS->rcItem.top);

	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	if (!pDC)
		return;

	CRect rcFullItem(lpDIS->rcItem);
	bool bSelected = (lpDIS->itemState & ODS_SELECTED) != 0;

	///////////////////////////////////////////////////////////////////////////////////////
	// Adding support for XP Styles (Vista Themes) for owner drawn tab controls simply
	// does *not* work under Vista. Maybe it works under XP (did not try), but that is
	// meaningless because under XP a owner drawn tab control is already rendered *with*
	// the proper XP Styles. So, for XP there is no need to care about the theme API at all.
	//
	// However, under Vista, a tab control which has the TCS_OWNERDRAWFIXED
	// style gets additional 3D-borders which are applied by Vista *after* WM_DRAWITEM
	// was processed. Thus, there is no known workaround available to prevent Vista from
	// adding those old fashioned 3D-borders. We can render the tab control items within
	// the WM_DRAWITEM handler in whatever style we want, but Vista will in each case
	// overwrite the borders of each tab control item with old fashioned 3D-borders...
	//
	// To complete this experience, tab controls also do not support NMCUSTOMDRAW. So, the
	// only known way to customize a tab control is by using TCS_OWNERDRAWFIXED which does
	// however not work properly under Vista.
	//
	// The "solution" which is currently implemented to prevent Vista from drawing those
	// 3D-borders is by using "ExcludeClipRect" to reduce the drawing area which is used
	// by Windows after WM_DRAWITEM was processed. This "solution" is very sensitive to
	// the used rectangles and offsets in general. Incrementing/Decrementing one of the
	// "rcItem", "rcFullItem", etc. rectangles makes the entire "solution" flawed again
	// because some borders would become visible again.
	//
	HTHEME hTheme = NULL;
	int iPartId = TABP_TABITEM;
	int iStateId = TIS_NORMAL;
	bool bVistaHotTracked = false;
	bool bVistaThemeActive = theApp.IsVistaThemeActive();
	if (bVistaThemeActive)
	{
		// To determine if the current item is in 'hot tracking' mode, we need to evaluate
		// the current foreground color - there is no flag which would indicate this state 
		// more safely. This applies only for Vista and for tab controls which have the
		// TCS_OWNERDRAWFIXED style.
		bVistaHotTracked = pDC->GetTextColor() == GetSysColor(COLOR_HOTLIGHT);

		hTheme = g_xpStyle.OpenThemeData(m_hWnd, L"TAB");
		if (hTheme)
		{
			if (bSelected) {
				// get the real tab item rect
				rcFullItem.left += 1;
				rcFullItem.right -= 1;
				rcFullItem.bottom -= 1;
			}
			else
				rcFullItem.InflateRect(2, 2); // get the real tab item rect

			CRect rcBk(rcFullItem);
			if (bSelected)
			{
				iStateId = TTIS_SELECTED;
				if (nTabIndex == 0) {
					// First item
					if (nTabIndex == GetItemCount() - 1)
						iPartId = TABP_TOPTABITEMBOTHEDGE; // First & Last item
					else
						iPartId = TABP_TOPTABITEMLEFTEDGE;
				}
				else if (nTabIndex == GetItemCount() - 1) {
					// Last item
					iPartId = TABP_TOPTABITEMRIGHTEDGE;
				}
				else {
					iPartId = TABP_TOPTABITEM;
				}
			}
			else
			{
				rcBk.top += 2;
				iStateId = bVistaHotTracked ? TIS_HOT : TIS_NORMAL;
				if (nTabIndex == 0) {
					// First item
					if (nTabIndex == GetItemCount() - 1)
						iPartId = TABP_TABITEMBOTHEDGE; // First & Last item
					else
						iPartId = TABP_TABITEMLEFTEDGE;
				}
				else if (nTabIndex == GetItemCount() - 1) {
					// Last item
					iPartId = TABP_TABITEMRIGHTEDGE;
				}
				else {
					iPartId = TABP_TABITEM;
				}
			}
			if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
				g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcFullItem);
			g_xpStyle.DrawThemeBackground(hTheme, *pDC, iPartId, iStateId, &rcBk, NULL);
		}
	}

	// Following background clearing is needed for:
	//	WinXP/Vista (when used without an application theme)
	//	Vista (when used with an application theme but without a theme for the tab control)
	if (   (!g_xpStyle.IsThemeActive() || !g_xpStyle.IsAppThemed())
		|| (hTheme == NULL && bVistaThemeActive) )
		pDC->FillSolidRect(&lpDIS->rcItem, GetSysColor(COLOR_BTNFACE));

	int iOldBkMode = pDC->SetBkMode(TRANSPARENT);

	// Draw image on left side
	CImageList *piml = GetImageList();
	if (tci.iImage >= 0 && piml && piml->m_hImageList)
	{
		IMAGEINFO ii;
		piml->GetImageInfo(0, &ii);
		rect.left += bSelected ? 8 : 4;
		piml->Draw(pDC, tci.iImage, CPoint(rect.left, rect.top + 2), ILD_TRANSPARENT);
		rect.left += (ii.rcImage.right - ii.rcImage.left);
		if (!bSelected)
			rect.left += 4;
	}

	bool bCloseable = m_bCloseable;
	if (bCloseable && GetParent()->SendMessage(UM_QUERYTAB, nTabIndex))
		bCloseable = false;

	// Draw 'Close button' at right side
	if (bCloseable && m_ImgLstCloseButton.m_hImageList)
	{
		CRect rcCloseButton;
		GetCloseButtonRect(nTabIndex, rect, rcCloseButton, bSelected, bVistaThemeActive);

		HTHEME hThemeNC = bVistaThemeActive ? g_xpStyle.OpenThemeData(m_hWnd, _T("WINDOW")) : NULL;
		if (hThemeNC) {
			// Possible "Close" parts: WP_CLOSEBUTTON, WP_SMALLCLOSEBUTTON, WP_MDICLOSEBUTTON
			int iPartId = WP_SMALLCLOSEBUTTON;
			int iStateId = (bSelected || bVistaHotTracked) ? CBS_NORMAL : CBS_DISABLED;
			if (g_xpStyle.IsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId))
				g_xpStyle.DrawThemeParentBackground(m_hWnd, *pDC, &rcCloseButton);
			g_xpStyle.DrawThemeBackground(hThemeNC, *pDC, iPartId, iStateId, rcCloseButton, NULL);
			g_xpStyle.CloseThemeData(hThemeNC);
		}
		else {
			m_ImgLstCloseButton.Draw(pDC, (bSelected || bVistaHotTracked) ? 0 : 1, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
		}

		rect.right = rcCloseButton.left - 2;
		if (bSelected)
			rect.left += hTheme ? 4 : 2;
	}

	COLORREF crOldColor = CLR_NONE;
	if (tci.dwState & TCIS_HIGHLIGHTED)
		crOldColor = pDC->SetTextColor(RGB(192, 0, 0));
	else if (bVistaHotTracked)
		crOldColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));

	rect.top += bSelected ? 4 : 3;
	// Vista: Tab control has troubles with determining the width of a tab if the
	// label contains one '&' character. To get around this, we use the old code which
	// replaces one '&' character with two '&' characters and we do not specify DT_NOPREFIX
	// here when drawing the text.
	//
	// Vista: "DrawThemeText" can not be used in case we need a certain foreground color. Thus we always us
	// "DrawText" to always get the same font and metrics (just for safety).
	pDC->DrawText(szLabel, rect, DT_SINGLELINE | DT_TOP | DT_CENTER /*| DT_NOPREFIX*/);

	if (crOldColor != CLR_NONE)
		pDC->SetTextColor(crOldColor);
	pDC->SetBkMode(iOldBkMode);

	if (hTheme)
	{
		CRect rcClip(rcFullItem);
		if (bSelected) {
			rcClip.left -= 2 + 1;
			rcClip.right += 2 + 1;
		}
		else {
			rcClip.top += 2;
		}
		pDC->ExcludeClipRect(&rcClip);
		g_xpStyle.CloseThemeData(hTheme);
	}
}
Beispiel #20
0
void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck)
{
    GetItem(uiIndex)->Check(bCheck);
} // end of wxCheckListBox::Check
Beispiel #21
0
void CWndVendorCtrl::OnDraw( C2DRender* p2DRender )
{
	if( m_pMover == NULL )
		return;

	CRect rect	= GetClientRect();
	int nWidth	= rect.Width() / 32;
	int nHeight		= rect.Height() / 32;

	int i; for( i = 0; i < MAX_VENDITEM; i++ )
	{
		int x	= i % 6;
		int y	= i / 6;
		//p2DRender->RenderRect( CRect( x * 32 + 7, y * 32 + 11, x * 32 + 32 + 5, y * 32 + 32 + 9 ), 0xff00ffff );
		CRect rectHittest	= CRect( x * 32 + 7, y * 32 + 11, x * 32 + 32 + 5, y * 32 + 32 + 9 );

		CPoint point	= GetMousePoint();

		if( rectHittest.PtInRect( point ) )
		{
			if( CWndBase::m_GlobalShortcut.m_dwData )
			{
				m_nCurSel = -1;
				CPoint ptx = CPoint(x * 32 + 7, y * 32 + 11);
				{
					m_pTex->Render( p2DRender, ptx );
				}
			}
		}			
		CItemBase* pItemBase = GetItem( i );
		if( pItemBase )
		{
			if( ((CItemElem*)pItemBase)->IsFlag( CItemElem::expired ) )
			{
				pItemBase->GetTexture()->Render2( p2DRender, CPoint( x * 32 + 6, y * 32 + 10 ), D3DCOLOR_XRGB( 255, 100, 100 ) );
			}
			else
			{
				pItemBase->GetTexture()->Render( p2DRender, CPoint( x * 32 + 6, y * 32 + 10 ) );
			}

			CPoint point	= GetMousePoint();
			if( rectHittest.PtInRect( point ) )
			{
				CPoint point2 = point;
				ClientToScreen( &point2 );
				ClientToScreen( &rectHittest );
				g_WndMng.PutToolTip_Item( pItemBase, point2, &rectHittest, APP_VENDOR );
			}
			if( i == m_nCurSel )
				p2DRender->RenderRect( CRect( x * 32 + 7, y * 32 + 11, x * 32 + 32 + 5, y * 32 + 32 + 9 ), 0xff00ffff );
			CItemElem* pItemElem	= (CItemElem*)pItemBase;
			if( pItemElem->GetProp()->dwPackMax > 1 )
			{
				short nItemNum	= pItemBase->GetExtra();
				TCHAR szTemp[32];
				_stprintf( szTemp, "%d", nItemNum );
				CSize size	= p2DRender->m_pFont->GetTextExtent( szTemp );
				p2DRender->TextOut( x * 32 + 32 - size.cx+5, y * 32 + 32 - size.cy+12, szTemp, 0xff1010ff );
			}
		}
	}
}
Beispiel #22
0
void CTBHeaderCtrl::DrawHeader(CDC* pDC)
{
	bool bGet = false;
	if (NULL == pDC)
	{
		pDC = GetDC();
		bGet = true;
	} 
	CDC dc;
	dc.CreateCompatibleDC(pDC);
	CBitmap memBmp;
	CRect memRect;
	GetClientRect(&memRect);
	memBmp.CreateCompatibleBitmap(pDC, memRect.Width(), memRect.Height());
	CBitmap* pOldBmp = dc.SelectObject(&memBmp);
	dc.FillSolidRect(0, 0, memRect.Width(), memRect.Height(), RGB(m_R, m_G, m_B));

	int nItem; 
	nItem = GetItemCount();
	for(int i = 0; i<nItem;i ++) 
	{ 
		CRect tRect;
		GetItemRect(i,&tRect);
		int R = m_R,G = m_G,B = m_B;
		CRect nRect(tRect);
		nRect.left++;

		for(int j = tRect.top;j<=tRect.bottom;j++) 
		{ 
			nRect.bottom = nRect.top+1; 
			CBrush _brush; 
			_brush.CreateSolidBrush(RGB(R,G,B));
			dc.FillRect(&nRect,&_brush); 
			_brush.DeleteObject(); 
			R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
			if (R<0)R = 0;
			if (G<0)G = 0;
			if (B<0)B= 0;
			nRect.top = nRect.bottom; 
		} 
		dc.SetBkMode(TRANSPARENT);
		CFont nFont ,* nOldFont; 
		//dc.SetTextColor(RGB(250,50,50)); 
		dc.SetTextColor(m_color);
		HDITEM hdItem;
		ZeroMemory(&hdItem, sizeof(hdItem));
		hdItem.mask = HDI_TEXT;
		hdItem.pszText = new TCHAR[256];
		ZeroMemory(hdItem.pszText, 256);
		hdItem.cchTextMax = 256;
		if (GetItem(i, &hdItem))
		{
			nFont.CreateFont(m_fontHeight,m_fontWith,0,0,0,FALSE,FALSE,0,0,0,0,0,0,_TEXT("SimSun"));
			nOldFont = dc.SelectObject(&nFont);

			TEXTMETRIC metric;
			dc.GetTextMetrics(&metric);
			int ofst = 0;
			ofst = tRect.Height() - metric.tmHeight;
			tRect.OffsetRect(0,ofst/2);
			dc.DrawText(hdItem.pszText,&tRect,DT_CENTER);

			dc.SelectObject(nOldFont); 
			nFont.DeleteObject(); 
		}
		delete []hdItem.pszText;
	} 

	CRect rtRect;
	CRect clientRect;
	GetItemRect(nItem - 1,rtRect);
	GetClientRect(clientRect);
	rtRect.left = rtRect.right+1;
	rtRect.right = clientRect.right;
	int R = m_R,G = m_G,B = m_B;
	CRect nRect(rtRect);

	for(int j = rtRect.top;j<=rtRect.bottom;j++) 
	{ 
		nRect.bottom = nRect.top+1; 
		CBrush _brush; 
		_brush.CreateSolidBrush(RGB(R,G,B));
		dc.FillRect(&nRect,&_brush);
		_brush.DeleteObject(); 
		R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
		if (R<0)R = 0;
		if (G<0)G = 0;
		if (B<0)B= 0;
		nRect.top = nRect.bottom; 
	} 

	pDC->BitBlt(0, 0, memRect.Width(), memRect.Height(), &dc, 0, 0, SRCCOPY);
	dc.SelectObject(pOldBmp);
	memBmp.DeleteObject();
	dc.DeleteDC();

	if (bGet)
	{
		ReleaseDC(pDC);
	}
}
void CIrcChannelTabCtrl::OnTcnSelchangeTab2(NMHDR*, LRESULT* pResult)
{
    TCITEM item;
    item.mask = TCIF_PARAM;
    //What channel did we select?
    int iCurSell = GetCurSel();
    if (iCurSell == -1)
    {
        //No channel, abort..
        return;
    }
    if (!GetItem(iCurSell, &item))
    {
        //We had no valid item here.. Something isn't right..
        //TODO: this should never happen, so maybe we should remove this tab?
        return;
    }
    Channel* pUpdate = (Channel*)item.lParam;
    Channel* pCh2 = NULL;

    //Set our current channel to the new one for quick reference..
    m_pCurrentChannel = pUpdate;

    if (m_pCurrentChannel->m_uType == 1)
        m_pParent->m_editTitleWindow.SetWindowText(GetResString(IDS_STATUS));
    if (m_pCurrentChannel->m_uType == 2)
    {
        //Since some channels can have a LOT of nicks, hide the window then remove them to speed it up..
        m_pParent->m_listctrlNickList.ShowWindow(SW_HIDE);
        m_pParent->m_listctrlNickList.DeleteAllItems();
        m_pParent->m_listctrlNickList.UpdateNickCount();
        m_pParent->m_listctrlNickList.ShowWindow(SW_SHOW);
        //Set title to ChanList
        m_pParent->m_editTitleWindow.SetWindowText(GetResString(IDS_IRC_CHANNELLIST));
        //Show our ChanList..
        m_pParent->m_listctrlServerChannelList.ShowWindow(SW_SHOW);
        TCITEM tci;
        tci.mask = TCIF_PARAM;
        //Go through the channel tabs and hide the channels..
        //Maybe overkill? Maybe just remember our previous channel and hide it?
        int iIndex = 0;
        while (GetItem(iIndex++, &tci))
        {
            pCh2 = (Channel*)tci.lParam;
            if (pCh2 != m_pCurrentChannel && pCh2->m_editctrlLog.m_hWnd != NULL)
                pCh2->m_editctrlLog.ShowWindow(SW_HIDE);
        }
        return;
    }
    //We entered the channel, set activity flag off.
    SetActivity( m_pCurrentChannel->m_sName, false );
    CRect rcChannel;
    m_pParent->m_listctrlServerChannelList.GetWindowRect(&rcChannel);
    m_pParent->ScreenToClient(&rcChannel);
    //Show new current channel..
    m_pCurrentChannel->m_editctrlLog.SetWindowPos(NULL, rcChannel.left, rcChannel.top, rcChannel.Width(), rcChannel.Height(), SWP_NOZORDER);
    m_pCurrentChannel->m_editctrlLog.ShowWindow(SW_SHOW);
    TCITEM tci;
    tci.mask = TCIF_PARAM;
    //Hide all channels not in focus..
    //Maybe overkill? Maybe remember previous channel and hide?
    int iIndex = 0;
    while (GetItem(iIndex++, &tci))
    {
        pCh2 = (Channel*)tci.lParam;
        if (pCh2 != m_pCurrentChannel && pCh2->m_editctrlLog.m_hWnd != NULL)
            pCh2->m_editctrlLog.ShowWindow(SW_HIDE);
    }
    //Make sure channelList is hidden.
    m_pParent->m_listctrlServerChannelList.ShowWindow(SW_HIDE);
    //Update nicklist to the new channel..
    m_pParent->m_listctrlNickList.RefreshNickList( pUpdate->m_sName );
    //Set title to the new channel..
    m_pParent->SetTitle( pUpdate->m_sName, pUpdate->m_sTitle );
    //Push focus back to the input box..
    m_pParent->GetDlgItem(IDC_INPUTWINDOW)->SetFocus();
    if( pResult )
        *pResult = 0;
}
Beispiel #24
0
void MyListCtrl::OnListKeyDown(wxListEvent& event)
{
    long item;

    if ( !wxGetKeyState(WXK_SHIFT) )
    {
        LogEvent(event, wxT("OnListKeyDown"));
        event.Skip();
        return;
    }

    switch ( event.GetKeyCode() )
    {
        case 'C': // colorize
            {
                wxListItem info;
                info.m_itemId = event.GetIndex();
                if ( info.m_itemId == -1 )
                {
                    // no item
                    break;
                }

                GetItem(info);

                wxListItemAttr *attr = info.GetAttributes();
                if ( !attr || !attr->HasTextColour() )
                {
                    info.SetTextColour(*wxCYAN);

                    SetItem(info);

                    RefreshItem(info.m_itemId);
                }
            }
            break;

        case 'N': // next
            item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
            if ( item++ == GetItemCount() - 1 )
            {
                item = 0;
            }

            wxLogMessage(wxT("Focusing item %ld"), item);

            SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
            EnsureVisible(item);
            break;

        case 'R': // show bounding rectangle
            {
                item = event.GetIndex();
                wxRect r;
                if ( !GetItemRect(item, r) )
                {
                    wxLogError(wxT("Failed to retrieve rect of item %ld"), item);
                    break;
                }

                wxLogMessage(wxT("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
                             item, r.x, r.y, r.x + r.width, r.y + r.height);
            }
            break;

        case '1': // show sub item bounding rectangle for the given column
        case '2': // (and icon/label rectangle if Shift/Ctrl is pressed)
        case '3':
        case '4': // this column is invalid but we want to test it too
            if ( InReportView() )
            {
                int subItem = event.GetKeyCode() - '1';
                item = event.GetIndex();
                wxRect r;

                int code = wxLIST_RECT_BOUNDS;
                if ( wxGetKeyState(WXK_SHIFT) )
                    code = wxLIST_RECT_ICON;
                else if ( wxGetKeyState(WXK_CONTROL) )
                    code = wxLIST_RECT_LABEL;

                if ( !GetSubItemRect(item, subItem, r, code) )
                {
                    wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item, subItem + 1);
                    break;
                }

                wxLogMessage(wxT("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)"),
                             item, subItem + 1,
                             r.x, r.y, r.x + r.width, r.y + r.height);
            }
            break;

        case 'U': // update
            if ( !IsVirtual() )
                break;

            if ( m_updated != -1 )
                RefreshItem(m_updated);

            m_updated = event.GetIndex();
            if ( m_updated != -1 )
            {
                // we won't see changes to this item as it's selected, update
                // the next one (or the first one if we're on the last item)
                if ( ++m_updated == GetItemCount() )
                    m_updated = 0;

                wxLogMessage("Updating colour of the item %ld", m_updated);
                RefreshItem(m_updated);
            }
            break;

        case 'D': // delete
            item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            while ( item != -1 )
            {
                DeleteItem(item);

                wxLogMessage(wxT("Item %ld deleted"), item);

                // -1 because the indices were shifted by DeleteItem()
                item = GetNextItem(item - 1,
                                   wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            }
            break;

        case 'I': // insert
            if ( GetWindowStyle() & wxLC_REPORT )
            {
                if ( GetWindowStyle() & wxLC_VIRTUAL )
                {
                    SetItemCount(GetItemCount() + 1);
                }
                else // !virtual
                {
                    InsertItemInReportView(event.GetIndex());
                }
            }
            //else: fall through

        default:
            LogEvent(event, wxT("OnListKeyDown"));

            event.Skip();
    }
}
Beispiel #25
0
void CNewHeaderCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CDC dc;

	dc.Attach( lpDrawItemStruct->hDC );

	// Save DC
	int nSavedDC = dc.SaveDC();

/*	if(m_RTL)
	{
		dc.SetViewportOrg(0, 0);
		dc.SetMapMode(MM_TEXT);
	}
*/
	// Get the column rect
	CRect rcLabel( lpDrawItemStruct->rcItem );

/*	CTLFrame *pFrame = (CTLFrame *)GetParent();

	CRect m_clientRect;
	pFrame->m_tree.GetClientRect(&m_clientRect);

	if(m_RTL)
	{
		int left = rcLabel.left;
		int right = rcLabel.right;

		rcLabel.left = m_clientRect.Width() - right;
		rcLabel.right = m_clientRect.Width() - left;
	}
*/
	// Set clipping region to limit drawing within column
	CRgn rgn;
	rgn.CreateRectRgnIndirect( &rcLabel );
	dc.SelectObject( &rgn );
	rgn.DeleteObject();

	// Labels are offset by a certain amount  
	// This offset is related to the width of a space character
	int offset = dc.GetTextExtent(_T(" "), 1 ).cx*2;


	// Draw image from image list

	// Get the column text and format
	TCHAR buf[256];
	HD_ITEM hditem;
	
	hditem.mask = HDI_TEXT | HDI_FORMAT;
	hditem.pszText = buf;
	hditem.cchTextMax = 255;

	GetItem( lpDrawItemStruct->itemID, &hditem );

	// Determine format for drawing column label
	UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP 
						| DT_VCENTER | DT_END_ELLIPSIS ;

	if( hditem.fmt & HDF_CENTER)
		uFormat |= DT_CENTER;
	else if( hditem.fmt & HDF_RIGHT)
		uFormat |= DT_RIGHT;
	else
		uFormat |= DT_LEFT;

	if(!(uFormat & DT_RIGHT))
	{
		// Adjust the rect if the mouse button is pressed on it
		if( lpDrawItemStruct->itemState == ODS_SELECTED )
		{
			rcLabel.left++;
			rcLabel.top += 2;
			rcLabel.right++;
		}

		rcLabel.left += offset;
		rcLabel.right -= offset;

		// Draw column label
		if( rcLabel.left < rcLabel.right )
			dc.DrawText(buf,-1,rcLabel, uFormat);
	}


	int imageIndex;
	if (m_pImageList && 
		m_mapImageIndex.Lookup( lpDrawItemStruct->itemID, imageIndex ) )
	{
		if( imageIndex != -1 )
		{
			if(uFormat & DT_RIGHT)
			// draw to the left of the label
				m_pImageList->Draw(&dc, imageIndex, 
						CPoint( rcLabel.left + offset,offset/3 ),
						ILD_TRANSPARENT );
			else
			// draw to the right
				m_pImageList->Draw(&dc, imageIndex, 
						CPoint( rcLabel.right - dc.GetTextExtent(_T(buf), 1 ).cx*2,offset/3 ),
						ILD_TRANSPARENT );


			// Now adjust the label rectangle
			IMAGEINFO imageinfo;
			if( m_pImageList->GetImageInfo( imageIndex, &imageinfo ) )
			{
				rcLabel.left += offset/2 + 
					imageinfo.rcImage.right - imageinfo.rcImage.left;
			}
		}
	}

	if(uFormat & DT_RIGHT)
	{
		// Adjust the rect if the mouse button is pressed on it
		if( lpDrawItemStruct->itemState == ODS_SELECTED )
		{
			rcLabel.left++;
			rcLabel.top += 2;
			rcLabel.right++;
		}

		rcLabel.left += offset;
		rcLabel.right -= offset;

		// Draw column label
		if( rcLabel.left < rcLabel.right )
			dc.DrawText(buf,-1,rcLabel, uFormat);
	}

/*	if(m_RTL)
	{
		dc.SetViewportOrg(m_clientRect.Width(), 0);
		CSize ext = dc.GetViewportExt();
		ext.cx = ext.cx > 0 ? -ext.cx : ext.cx;

		dc.SetMapMode(MM_ANISOTROPIC);
		dc.SetViewportExt(ext);
	}
*/
	// Restore dc
	dc.RestoreDC( nSavedDC );

	// Detach the dc before returning
	dc.Detach();
}
Beispiel #26
0
void GlobalCFG::got_input(std::vector<std::string> params, std::vector<int> intparams, std::string command)
{
	if (params[0] == "help")
	{
		ng_slogout("gcfg","gcfg_list - show all global config values set");
		ng_slogout("gcfg","gcfg <name> <value> - set a global cfg value");
	}

	if (params[0] == "gcfg_list")
	{
		ng_slogout("gcfg","listing:");
		ConfigMap *cmdata = GetData();
		ConfigMap::iterator it;
		for (it=cmdata->begin(); it != cmdata->end(); it++) {
			ConfigData *entry = (*it).second;
			if (!entry) continue;

			switch (entry->GetType())
			{
				case 0:
						ng_slogout("gcfg","int %s: %d",(*it).first.c_str(),entry->GetInt());
						break;
				case 1:
						ng_slogout("gcfg","str %s: %s",(*it).first.c_str(),entry->GetStr().c_str());
						break;
				default:
						ng_slogout("gcfg","%s: <unkown type>",(*it).first.c_str());
			}
		}
	}

	if (params[0] == "gcfg")
	{
			
		if (params.size() >= 3)
		{
			if (intparams[2]!=MININT)
			{
				SetInt(params[1],intparams[2]);
			} else {
				std::string mydata;
				for( unsigned int i=2; i < params.size(); i++ )
				{
					if (i>2)
						mydata.append(" ");
					mydata.append(params[i]);
				}
				SetStr(params[1],mydata);
			}

			ConfigData *entry = GetItem(params[1]);
			if (!entry) {
				ng_slogerror("gcfg","could not set %s",params[1].c_str());
				return;
			}

			switch (entry->GetType())
			{
				case 0:
						ng_slogout("gcfg","set int %s: %d",params[1].c_str(),entry->GetInt());
						break;
				case 1:
						ng_slogout("gcfg","set str %s: %s",params[1].c_str(),entry->GetStr().c_str());
						break;
			}
		} else ng_slogout_ret("gcfg",RET_WRONG_SYNTAX,"usage: gcfg <name> <value> - set a global cfg value");
	}
}
Beispiel #27
0
void CanvasMode_FrameLinks::mousePressEvent(QMouseEvent *m)
{
// 	const double mouseX = m->globalX();
// 	const double mouseY = m->globalY();
	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());

	double Rxp = 0;
	double Ryp = 0;
	PageItem *currItem, *bb;
	m_canvas->PaintSizeRect(QRect());
	m_canvas->m_viewMode.m_MouseButtonPressed = true;
	m_canvas->m_viewMode.operItemMoving = false;
	m_view->HaveSelRect = false;
	m_doc->DragP = false;
	m_doc->leaveDrag = false;
//	oldClip = 0;
	m->accept();
	m_view->registerMousePress(m->globalPos());
	Mxp = mousePointDoc.x(); //qRound(m->x()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.x());
	Myp = mousePointDoc.y(); //qRound(m->y()/m_canvas->scale() + 0*m_doc->minCanvasCoordinate.y());
	Rxp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).x();
	Mxp = qRound(Rxp);
	Ryp = m_doc->ApplyGridF(FPoint(Mxp, Myp)).y();
	Myp = qRound(Ryp);
	SeRx = Mxp;
	SeRy = Myp;
	if (m->button() == Qt::MidButton)
	{
		m_view->MidButt = true;
		if (m->modifiers() & Qt::ControlModifier)
			m_view->DrawNew();
		return;
	}
	switch (m_doc->appMode)
	{
		case modeLinkFrames:
			if (m->button() != Qt::LeftButton)
				break;
			currItem = m_doc->ElemToLink;
			if (currItem==NULL)
				break;
			SeleItem(m);
			if (GetItem(&bb) && (bb->asTextFrame()))
			{
				PageItem* bblast = bb;
				while (bblast->nextInChain())
					bblast = bblast->nextInChain();
				
				if (currItem->nextInChain() == 0 && bb->prevInChain() == 0 && currItem != bblast)
				{
					currItem->link(bb);
					// CB We need to do this because we draw in the order of the item list
					// Which is also item number list.. but #3488: we must also renumber the items
					if (bb->ItemNr < currItem->ItemNr)
					{
						m_doc->Items->insert(currItem->ItemNr+1, bb);
						bb = m_doc->Items->takeAt(bb->ItemNr);
						m_doc->renumberItemsInListOrder();
					}
					// m_view->updateContents();
					// link calls PageItem::update	
					// emit DocChanged();
					m_doc->ElemToLink = bb;
				}
				else if (currItem == bblast)
				{
					//CB Mouse is released when this messagebox takes focus
					m_canvas->m_viewMode.m_MouseButtonPressed = false;
					QMessageBox::warning(m_view, ScribusView::tr("Linking Text Frames"),
											 "<qt>" + ScribusView::tr("You are trying to link a frame to itself.") + "</qt>");
				}
				else
				{
					//CB Mouse is released when this messagebox takes focus
					m_canvas->m_viewMode.m_MouseButtonPressed = false;
					QMessageBox::warning(m_view, ScribusView::tr("Linking Text Frames"),
										 "<qt>" + ScribusView::tr("You are trying to link a frame which is already linked.") + "</qt>");
				}
			}
			else
				m_doc->ElemToLink = NULL;
			break;
		case modeUnlinkFrames:
			if (m->button() != Qt::LeftButton)
				break;
			SeleItem(m);
			if (GetItem(&currItem) && (currItem->asTextFrame()))
			{
				if (currItem->prevInChain() != 0)
				{
					currItem->prevInChain()->unlink();
				}
				// unlink calls PageItem::update				emit DocChanged();
				// m_view->updateContents();
			}
			break;
	}
}
Beispiel #28
0
void CMyHeaderCtrl::OnPaint()
{
	CPaintDC dc(this); 
	CRect rect,rectItem;
	GetClientRect(&rect);

	CDC hdcMem;
	hdcMem.CreateCompatibleDC(NULL);
	CBitmap hBitmap;
	hBitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
	hdcMem.SelectObject(&hBitmap);

	//CMemDC memDC(&dc, rect);
	int nItems = GetItemCount();

	if( m_pBitmapBk != NULL )
	{
		m_pBitmapBk->SetCDibRect( rect );
		m_pBitmapBk->Draw( &hdcMem,FALSE );
	}

	
	CFont* def_font;
	CFont font;
	LOGFONT lf;
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 12;
	strcpy(lf.lfFaceName, "宋体");
	font.CreateFontIndirect(&lf);
	def_font = hdcMem.SelectObject(&font);	


	hdcMem.SetBkMode(TRANSPARENT);
	hdcMem.SetTextColor(m_fontColor) ;
			
	for(int i = 0; i <nItems; i++)
	{
		TCHAR buf1[256];
		HD_ITEM hditem1;
		
		hditem1.mask = HDI_TEXT | HDI_FORMAT | HDI_ORDER;
		hditem1.pszText = buf1;
		hditem1.cchTextMax = 255;
		GetItem( i, &hditem1 );	
		GetItemRect(i, &rect);

		if( m_nHoverItem == i )
		{
			if(this->m_bLButtonDown)
			{
				m_pBitmapBkDown->SetCDibRect( rect );
				m_pBitmapBkDown->Draw( &hdcMem,FALSE );
			}
			else
			{
				m_pBitmapBkOver->SetCDibRect( rect );
				m_pBitmapBkOver->Draw( &hdcMem,FALSE );
			}
		}
		if( m_pBitmapMidLine != NULL )
		{
			if(m_nHoverItem == i)
			{
				m_pBitmapMidLineOver->SetCDibRect(CRect(rect.BottomRight().x-1,rect.TopLeft().y,rect.BottomRight().x,rect.BottomRight().y));
				m_pBitmapMidLineOver->Draw(&hdcMem,FALSE);
// 				int start = rect.TopLeft().x == 0 ? 0 : rect.TopLeft().x - 1;
// 				m_pBitmapMidLineOver->SetCDibRect(CRect(start ,rect.TopLeft().y,start + 1,rect.BottomRight().y));
// 				m_pBitmapMidLineOver->Draw(&hdcMem,FALSE);
			}
			else
			{
// 				m_pBitmapMidLine->SetCDibRect(CRect(rect.BottomRight().x-1,rect.TopLeft().y,rect.BottomRight().x+2,rect.BottomRight().y));
// 				m_pBitmapMidLine->Draw(&hdcMem,FALSE);

				m_pBitmapMidLineOver->SetCDibRect(CRect(rect.BottomRight().x-1,rect.TopLeft().y,rect.BottomRight().x,rect.BottomRight().y));
				m_pBitmapMidLineOver->Draw(&hdcMem,FALSE);
			}
		}

		GetItemRect(i, &rectItem);
		//DRAWITEMSTRUCT	DrawItemStruct;
		//		
		//DrawItemStruct.CtlType		= ODT_HEADER;
		//DrawItemStruct.hDC			= dc.GetSafeHdc();
		//DrawItemStruct.itemAction	= ODA_DRAWENTIRE; 
		//DrawItemStruct.hwndItem 	= GetSafeHwnd(); 
		//DrawItemStruct.rcItem	= rectItem;
		//DrawItemStruct.itemID	= i;*/
////		DrawItem(&DrawItemStruct);
		
		UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_TOP |DT_CENTER | DT_END_ELLIPSIS | DT_VCENTER;

		rectItem.DeflateRect(2,2,2,2);
		
		TCHAR buf[256];
		HD_ITEM hditem;
		
		hditem.mask = HDI_TEXT | HDI_FORMAT | HDI_ORDER ;
		hditem.pszText = buf;
		hditem.cchTextMax = 255;
		GetItem( i, &hditem );
		
		CRect calRect = rectItem;
		hdcMem.DrawText(buf, &calRect, DT_CALCRECT | DT_CENTER |DT_VCENTER);
		hdcMem.DrawText(buf, &rectItem, uFormat);
		

		if( i == m_pList->m_iSortItem )
		{
			CDibBitmap * pBmp = NULL;

			if( !m_pList->m_bAsc )
			{
				pBmp = m_pBitmapAsc;
			}
			else
			{
				pBmp = m_pBitmapDesc;
			}

			CSize imaSize;
			CPoint p;

			imaSize = pBmp->GetDimensions();
			p.x = calRect.right + 2 + rectItem.Width() / 2 - calRect.Width() / 2;
			p.y = rectItem.CenterPoint().y - imaSize.cy / 2;
			
			if(p.x  < rectItem.right)
			{
				if(p.x + imaSize.cx > rectItem.right)
				{
					imaSize.cx = rectItem.right - p.x;
				}
				pBmp->SetCDibRect(CRect(p, imaSize));
				pBmp->Draw(&hdcMem,  true);
			}
		}
	}

	GetClientRect(&rect);
	dc.BitBlt(rect.TopLeft().x,rect.TopLeft().y,rect.Width(),rect.Height(),&hdcMem,0,0,SRCCOPY);

	hdcMem.SelectObject(def_font);
	font.DeleteObject();
}
Beispiel #29
0
void CItemList::SortItems (void)

//	SortItems
//
//	Sorts items in order:
//
//	installed/not-installed
//	armor/weapon/device/other

	{
	if (GetCount() == 0)
		return;

	int i;
	CSymbolTable Sort(false, true);

	for (i = 0; i < GetCount(); i++)
		{
		CItem &Item = GetItem(i);
		CItemType *pType = Item.GetType();

		//	All installed items first

		CString sInstalled;
		if (Item.IsInstalled())
			sInstalled = CONSTLIT("0");
		else
			sInstalled = CONSTLIT("1");

		//	Next, sort on category

		CString sCat;
		switch (pType->GetCategory())
			{
			case itemcatWeapon:
			case itemcatLauncher:
				sCat = CONSTLIT("0");
				break;

			case itemcatMissile:
				sCat = CONSTLIT("1");
				break;

			case itemcatShields:
				sCat = CONSTLIT("2");
				break;

			case itemcatReactor:
				sCat = CONSTLIT("3");
				break;

			case itemcatDrive:
				sCat = CONSTLIT("4");
				break;

			case itemcatCargoHold:
				sCat = CONSTLIT("5");
				break;

			case itemcatMiscDevice:
				sCat = CONSTLIT("6");
				break;

			case itemcatArmor:
				sCat = CONSTLIT("7");
				break;

			case itemcatFuel:
			case itemcatUseful:
				sCat = CONSTLIT("8");
				break;

			default:
				sCat = CONSTLIT("9");
			}

		//	Next, sort by install location

		if (Item.IsInstalled())
			sCat.Append(strPatternSubst(CONSTLIT("%03d%08x"), Item.GetInstalled(), Item.GetType()->GetUNID()));
		else
			sCat.Append(CONSTLIT("99900000000"));

		//	Within category, sort by level (highest first)

		sCat.Append(strPatternSubst(CONSTLIT("%02d"), MAX_ITEM_LEVEL - Item.GetType()->GetApparentLevel()));

		//	Enhanced items before others

		if (Item.IsEnhanced())
			sCat.Append(CONSTLIT("0"));
		else if (Item.IsDamaged())
			sCat.Append(CONSTLIT("2"));
		else
			sCat.Append(CONSTLIT("1"));

		CString sName = pType->GetSortName();
		CString sSort = strPatternSubst(CONSTLIT("%s%s%s%d"), sInstalled, sCat, sName, (i * (int)this) % 0x10000);
		Sort.AddEntry(sSort, (CObject *)i);
		}

	//	Allocate a new list

	TArray<CItem *> NewList;
	NewList.InsertEmpty(GetCount());

	//	Move the items from the old list to the new list in the new order

	for (i = 0; i < GetCount(); i++)
		{
		int iOld = (int)Sort.GetValue(i);
		NewList[i] = m_List[iOld];
		}

	//	Swap

	m_List.TakeHandoff(NewList);
	}
void CUser::BuyingMerchantBuy(Packet & pkt)
{
	uint32 nPrice;
	uint16 sStackSize, sRemainingStackSize;
	uint8 bSellerSrcSlot, bMerchantListSlot;

	CUser *pMerchant = g_pMain->GetUserPtr(m_sMerchantsSocketID);
	if (pMerchant == NULL)
		return;

	pkt >> bSellerSrcSlot >> bMerchantListSlot >> sStackSize;

	_MERCH_DATA *pWantedItem = &pMerchant->m_arMerchantItems[bMerchantListSlot];
	_ITEM_DATA *pSellerItem = GetItem(SLOT_MAX + bSellerSrcSlot);

	// Make sure the merchant actually has that item in that slot
	// and that they want enough, and the selling user has enough
	if (pWantedItem->nNum != pSellerItem->nNum
		|| pWantedItem->sCount < sStackSize
		|| pSellerItem->sCount < sStackSize)
		return;

	// If it's not stackable, and we're specifying something other than 1
	// we really don't care to handle this request...
	_ITEM_TABLE *proto = g_pMain->GetItemPtr(pWantedItem->nNum);
	if (proto == NULL
		|| !proto->m_bCountable && sStackSize != 1)
		return;

	// Do they have enough coins?
	nPrice = pWantedItem->nPrice * sStackSize;
	if (nPrice > pMerchant->m_iGold)
		return;

	// Now find the buyer a home for their item
	int8 bDstPos = pMerchant->FindSlotForItem(pWantedItem->nNum, sStackSize);
	if (bDstPos < 0)
		return;

	_ITEM_DATA *pMerchantItem = pMerchant->GetItem(bDstPos);
	// Take coins off the buying merchant
	if (!pMerchant->GoldLose(nPrice))
		return;

	// and give them all to me, me, me!
	GoldGain(nPrice);

	// Get the remaining stack size after purchase.
	sRemainingStackSize = pSellerItem->sCount - sStackSize;

	// Now we give the buying merchant their wares.
	pMerchantItem->nNum = pSellerItem->nNum;
	pMerchantItem->sDuration = pSellerItem->sDuration;
	pSellerItem->sCount -= sStackSize;
	pMerchantItem->sCount += sStackSize;

	// If the seller's all out, remove their item.
	if (pSellerItem->sCount == 0)
		memset(pSellerItem, 0, sizeof(_ITEM_DATA));

	// TO-DO : Proper checks for the removal of the items in the array, we're now assuming everything gets bought

	// Update players
	SendStackChange(pSellerItem->nNum, pSellerItem->sCount, pSellerItem->sDuration, bSellerSrcSlot);
	pMerchant->SendStackChange(pMerchantItem->nNum, pMerchantItem->sCount, pMerchantItem->sDuration, bDstPos,
		pMerchantItem->sCount == sStackSize); 	// if the buying merchant only has what they wanted, it's a new item.
												// (otherwise it was a stackable item that was merged into an existing slot)

	Packet result(WIZ_MERCHANT, uint8(MERCHANT_BUY_BOUGHT));
	result << bMerchantListSlot << uint16(0) << GetName();
	pMerchant->Send(&result);

	result.clear();
	result	<< uint8(MERCHANT_BUY_SOLD) << uint16(1)
			<< pMerchantItem->nNum << sRemainingStackSize
			<< bMerchantListSlot;
	Send(&result);

	if (bMerchantListSlot < 4 && sRemainingStackSize == 0)
	{
		result.Initialize(WIZ_MERCHANT_INOUT);
		result << uint8(2) << m_sMerchantsSocketID << uint16(bMerchantListSlot);
		pMerchant->SendToRegion(&result);
	}

	int nItemsRemaining = 0;
	for (int i = 0; i < MAX_MERCH_ITEMS; i++)
	{
		if (pMerchant->m_arMerchantItems[i].nNum != 0)
			nItemsRemaining++;
	}

	if (nItemsRemaining == 0)
		pMerchant->BuyingMerchantClose();
		
}