Esempio n. 1
0
/*
 * Get the current position.
 *
 * Returns -1 on error.  Yes, that's bogus, but it's good enough for now.
 */
int MySpinCtrl::GetPos() const
{
    _ASSERTE(! (UDS_SETBUDDYINT & GetStyle())  &&  "'Auto Buddy Int' style *MUST* be unchecked");
//  _ASSERTE(  (UDS_AUTOBUDDY   & GetStyle())  &&  "'Auto Buddy' style *MUST* be checked");

    // Grab buddy edit control value.
    CString buddyStr;
    GetBuddy()->GetWindowText(buddyStr);

    long val;
    if (!ConvLong(buddyStr, &val))
        return -1;

    if (val < fLow || val > fHigh)
        return -1;

    // if they typed a "sloppy value" in, make it look nice
    CString reformatStr;
    if (GetBase() == 10)
        reformatStr.Format(L"%d", val);
    else
        reformatStr.Format(L"%X", val);
    if (buddyStr != reformatStr)
        GetBuddy()->SetWindowText(reformatStr);

    return val;
}
Esempio n. 2
0
/*******************************************************************************
 Function Name  : dGetPos
 Input(s)       :   -
 Output         : double - Double precession value of for the text box
 Functionality  : This method get the current virtual double precession value of
                  of the spin button.
 Member of      : CNumSpinCtrl
 Friend of      :
 Author(s)      : Raja N
 Date Created   : 22.07.2004
 Modifications  : Raja N on 30.07.2004.
                  Code review changes and Int 64 version implementation to
                  support signals > 52 bits length
*******************************************************************************/
double CNumSpinCtrl::dGetPos()
{
    // Get the text control first to get the value
    CWnd* pomEdit = GetBuddy();
    char* pDummy = NULL;
    double dVal = 0.0;
    // If the buddy is set then proceed
    if (pomEdit)
    {
        CString omStrText;
        // Get the text
        pomEdit->GetWindowText (omStrText);
        // Check for Base value
        if( GetBase() == defBASE_DEC )
        {
            // In decimal mode floating point values are possible so
            // Use Double Value function to get decimal points also
            dVal = _tcstod( omStrText, &pDummy);
        }
        else
        {
            // Double type should not be used for Hex values
            ASSERT ( FALSE );
        }
    }
    // Return calculated value
    return dVal;
}
Esempio n. 3
0
/*******************************************************************************
 Function Name  : vSetValueForBuddy
 Input(s)       : val - Double precession value of for the text box
 Output         :  -
 Functionality  : This will be called to set the value to the buddy text box.
                  This will format the value in the user specified format and
                  will set the text to the buddy text control.
 Member of      : CNumSpinCtrl
 Friend of      :
 Author(s)      : Raja N
 Date Created   : 22.07.2004
 Modifications  : Raja N on 30.07.2004.
                  Code review changes and Int 64 version implementation to
                  support signals > 52 bits length
*******************************************************************************/
void CNumSpinCtrl::vSetValueForBuddy (double dVal)
{
    // Get the Text window
    CWnd* pomEdit = GetBuddy();
    // If it is valid
    if ( pomEdit != NULL )
    {
        CString omStr;
        // Check for user defined format string
        if (m_omStrFormat.IsEmpty ())
        {
            // Use default format string
            omStr.Format( defSTR_DEFAULT_FORMAT_STRING ,dVal);
        }
        else
        {
            // For decimal mode format the value directly
            if( GetBase() == defBASE_DEC )
            {
                omStr.Format (m_omStrFormat, dVal);
            }
            else
            {
                // For hex double should not be used. Use __int64 member!
                ASSERT( FALSE );
            }
        }
        // Set the formatted text to buddy control
        pomEdit->SetWindowText (omStr);
    }
}
Esempio n. 4
0
/*******************************************************************************
 Function Name  : n64GetPos
 Input(s)       :   -
 Output         : __int64 - 64 bit int value of for the text box
 Functionality  : This method get the current 64 bit int value of the spin
                  button.
 Member of      : CNumSpinCtrl
 Friend of      :
 Author(s)      : Raja N
 Date Created   : 30.07.2004
 Modifications  :
*******************************************************************************/
__int64 CNumSpinCtrl::n64GetPos()
{
    __int64 n64Val = 0;
    // Get the text control first to get the value
    CWnd* pomEdit = GetBuddy();
    // If the buddy is set then proceed
    if (pomEdit != NULL )
    {
        CString omStrText;
        // Get the text
        pomEdit->GetWindowText (omStrText);
        // This can be used for both decimal and hex mode. So base check is not
        // required
        // Convert the text in to 64bit integer
        BOOL bSuccess =
            bConvertStringToInt64( omStrText,n64Val, GetBase());
        // Set the default value here incase of failure
        if( bSuccess == FALSE )
        {
            n64Val = 0;
        }
        // Extend the sign bit to get the actual value
        // If the value before is FF ( that is -1 )and data length is 8 bits
        // after extending the sign bit this will become FFFFFFFFFFFFFFFF
        // which is again -1 but the length is 64 bits
        if( m_bSigned == TRUE )
        {
            vExtendSignBit( n64Val, m_nDataLength);
        }
    }
    // Return calculated value
    return n64Val;
}
Esempio n. 5
0
//-------------------------------------------------------------
void CSpinButtonCtrlEx::SetBuddyValue (double val)
{
 CEditEx*	p_edit = static_cast<CEditEx*>(GetBuddy());
 ASSERT(p_edit);
 if (p_edit)
 {
  p_edit->SetValue((float)val);
 }
 return;
}
int CNumSpinCtrl::GetPos(void)
{
	CWnd* pEdit = GetBuddy();
	if (!pEdit) return 0;
	
	CString str;
	pEdit->GetWindowText(str);
	
	return GfxAtoX(str);
}
Esempio n. 7
0
//-------------------------------------------------------------
double CSpinButtonCtrlEx::GetPos()
{
 CEditEx* p_edit = static_cast<CEditEx*>(GetBuddy());
 if (p_edit)
 {
  float val;
  p_edit->GetValue(val);
  return (float)val;
 }
 else
  return 0.0f;
}
Esempio n. 8
0
double CFloatSpinCtrl::GetPos() {
    CWnd* pEdit = GetBuddy();
    if (pEdit) {
        CString str;
        pEdit->GetWindowText(str);
        double val = _wtof(str);
        return val;
    } else {
        //ASSERT (FALSE); // you didn't set buddy
        return 0.0;
    }
}
    void EnterCombat(Unit* pWho)
    {
        if (!pWho)
            return;

        if (Creature* pBuddy = GetBuddy())
        {
            if (!pBuddy->getVictim())
                pBuddy->AI()->AttackStart(pWho);
        }

        Aggro(pWho);
    }
Esempio n. 10
0
void CFloatSpinCtrl::SetValueForBuddy(double val) {
    CWnd* pEdit = GetBuddy();
    if (pEdit) {
        CString str;
        if (m_strFormat.IsEmpty ()) {
            str = FormatValue (val);
        } else {
            str.Format (m_strFormat, val);
        }

        pEdit->SetWindowText(str);
    }
}
    void JustReachedHome()
    {
        if (Creature* pBuddy = GetBuddy())
        {
            if (pBuddy->isDead())
                pBuddy->Respawn();
        }

        if (Creature* pGhost = (Creature*)Unit::GetUnit(*m_creature, m_uiGhostGUID))
        {
            if (pGhost->isAlive())
                pGhost->ForcedDespawn();
        }
    }
Esempio n. 12
0
/*
 * Handle UDN_DELTAPOS notification.
 */
void MySpinCtrl::OnDeltaPos(NMHDR* pNMHDR, LRESULT* pResult)
{
    _ASSERTE(! (UDS_SETBUDDYINT & GetStyle())  &&  "'Auto Buddy Int' style *MUST* be unchecked");
//  _ASSERTE(  (UDS_AUTOBUDDY   & GetStyle())  &&  "'Auto Buddy' style *MUST* be checked");
    _ASSERTE(  (UDS_NOTHOUSANDS & GetStyle())  &&  "'No Thousands' style *MUST* be checked");

    NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;

    /* grab value from buddy ctrl */
    ASSERT(GetBuddy() != NULL);
    CString buddyStr;
    GetBuddy()->GetWindowText(buddyStr);

    long buddyVal, proposedVal;

    if (!ConvLong(buddyStr, &buddyVal))
        goto bail;      // bad string
    proposedVal = buddyVal - pNMUpDown->iDelta;

    /* peg at the end */
    if (proposedVal < fLow)
        proposedVal = fLow;
    if (proposedVal > fHigh)
        proposedVal = fHigh;

    if (proposedVal != buddyVal) {
        /* set buddy control to new value */
        if (GetBase() == 10)
            buddyStr.Format(L"%d", proposedVal);
        else
            buddyStr.Format(L"%X", proposedVal);
        GetBuddy()->SetWindowText(buddyStr);
    }
    
bail:
    *pResult = 0;
}
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiYellDelayTimer)
        {
            if (m_uiYellDelayTimer <= uiDiff)
            {
                if (Creature* pBuddy = GetBuddy())
                    DoScriptText(m_aYell[0].m_iTextReplyId, pBuddy);

                m_uiYellDelayTimer = 0;
            }
            else
                m_uiYellDelayTimer -= uiDiff;
        }

        if (m_uiChargeTimer < uiDiff)
        {
            if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1))
                DoCastSpellIfCan(pTarget, SPELL_CHARGE);

            m_uiChargeTimer = urand(8000, 16000);
        }
        else
            m_uiChargeTimer -= uiDiff;

        if (m_uiEnrageTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature, SPELL_ENRAGE);
            m_uiEnrageTimer = 20000;
        }
        else
            m_uiEnrageTimer -= uiDiff;

        if (m_uiStoneStrikeTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_STONE_STRIKE);
            m_uiStoneStrikeTimer = urand(5000, 15000);
        }
        else
            m_uiStoneStrikeTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
void CNumSpinCtrl::SetValueForBuddy(int val)
{
	CWnd* pEdit = GetBuddy();
	if (!pEdit) return;
	
	int lower=0,upper=0;
	GetRange32(lower,upper);
	val=max(lower,min(upper,val));

	CString str;
	pEdit->GetWindowText(str);
	if (str.Left(2).CompareNoCase("0x")==0)
		str.Format("0x%X", val);
	else
		str.Format("%d", val);
	
	pEdit->SetWindowText (str);
}
Esempio n. 15
0
void CNumSpinCtrl::vSetValueForBuddy (UINT64 n64Val)
{
    // Get the Text window
    CWnd* pomEdit = GetBuddy();
    // If it is valid
    if ( pomEdit != NULL )
    {
        CString omStr;
        // Check for user defined format string
        if (m_omStrFormat.IsEmpty ())
        {
            // Use default format string
            omStr.Format( defFORMAT_UINT64_DEC ,n64Val);
        }
        else
        {
            // Check the Base value
            // For decima mode (Base 10) negative numbers are represented
            // as - (val). Say -1. But in hex mode '-' is invalid and 2s
            // complement form will be used to represent the negative value.
            // In 2s complement the most significant bit is Sign bit. So data
            // length should be considered to get and set the value if the mode
            // is in Hex

            // For decimal mode format the value directly
            if( GetBase() == defBASE_DEC )
            {
                omStr.Format (m_omStrFormat, n64Val);
            }
            // For hex take the value and mask unwanted portion
            else
            {
                // In Hex change the negative number as - Positive Num
                // Format the min value
                //vRemoveUnwantedBits( n64Val, m_nDataLength);
                omStr.Format (m_omStrFormat, n64Val);
            }
        }
        // Set the formatted text to buddy control
        pomEdit->SetWindowText (omStr);
    }
}
Esempio n. 16
0
	void MRIMAccount::handleGotContacts (const QList<Proto::ContactInfo>& contacts)
	{
		Q_FOREACH (const Proto::ContactInfo& contact, contacts)
		{
			qDebug () << Q_FUNC_INFO
					<< GetAccountName ()
					<< contact.Email_
					<< contact.Phone_
					<< contact.Alias_
					<< contact.ContactID_
					<< contact.UA_
					<< contact.Features_;
			MRIMBuddy *buddy = GetBuddy (contact);

			if (buddy->GetID () != contact.ContactID_)
				buddy->UpdateID (contact.ContactID_);

			buddy->SetGroup (GM_->GetGroup (contact.GroupNumber_));
			Buddies_ [contact.Email_] = buddy;
		}
Esempio n. 17
0
/*
 * Set the current position.
 *
 * Returns the previous position.
 */
int MySpinCtrl::SetPos(int nPos)
{
    _ASSERTE(! (UDS_SETBUDDYINT & GetStyle())  &&  "'Auto Buddy Int' style *MUST* be unchecked");
//  _ASSERTE(  (UDS_AUTOBUDDY   & GetStyle())  &&  "'Auto Buddy' style *MUST* be checked");

    CString buddyStr;

    if (nPos < fLow || nPos > fHigh) {
        //LOGI(" MSP setpos out of range");
        return -1;
    }

    if (GetBase() == 10)
        buddyStr.Format(L"%d", nPos);
    else
        buddyStr.Format(L"%X", nPos);

    GetBuddy()->SetWindowText(buddyStr);

    return -1;      // broken
}
    void JustDied(Unit* pKiller)
    {
        if (Creature* pBuddy = GetBuddy())
        {
            if (pBuddy->isAlive())
            {
                DoScriptText(m_creature->GetEntry() == NPC_SKARVALD ? m_aYell[1].m_iTextId : m_aYell[2].m_iTextId, m_creature);
                DoScriptText(m_creature->GetEntry() == NPC_SKARVALD ? m_aYell[1].m_iTextReplyId : m_aYell[2].m_iTextReplyId, pBuddy);

                pBuddy->CastSpell(m_creature, m_creature->GetEntry() == NPC_SKARVALD ? SPELL_SUMMON_SKA_GHOST : SPELL_SUMMON_DAL_GHOST, true);

                m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
            }
            else
            {
                if (Creature* pGhost = (Creature*)Unit::GetUnit(*m_creature,m_uiGhostGUID))
                    pGhost->ForcedDespawn();

                pBuddy->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
            }
        }
    }
//*****************************************************************************************
void CBCGPSpinButtonCtrl::OnDraw (CDC* pDC)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDC);

	CRect rectClient;
	GetClientRect (rectClient);

	if (GetBuddy ()->GetSafeHwnd () != NULL && (m_bOnGlass || CBCGPToolBarImages::m_bIsDrawOnGlass || m_bVisualManagerStyle))
	{
		CRect rectBorder (0, 0, 0, 0);

		if (GetStyle () & UDS_ALIGNRIGHT)
		{
			rectBorder = rectClient;
			rectClient.DeflateRect (1, 1);
		}
		else if (GetStyle () & UDS_ALIGNLEFT)
		{
			rectBorder = rectClient;
			rectClient.DeflateRect (1, 1);
		}

		if (!rectBorder.IsRectEmpty ())
		{
			visualManager->OnDrawControlBorder (
				pDC, rectBorder, this, CBCGPToolBarImages::m_bIsDrawOnGlass || m_bOnGlass);
		}
	}

	if (CBCGPToolBarImages::m_bIsDrawOnGlass || m_bOnGlass)
	{
		CBCGPDrawManager dm (*pDC);
		dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1);
	}
	else
	{
		pDC->FillRect (rectClient, &globalData.brWindow);
	}

	int nState = 0;

	if (m_bIsButtonPressedUp)
	{
		nState |= SPIN_PRESSEDUP;
	}

	if (m_bIsButtonPressedDown)
	{
		nState |= SPIN_PRESSEDDOWN;
	}

	if (m_bIsButtonHighligtedUp)
	{
		nState |= SPIN_HIGHLIGHTEDUP;
	}

	if (m_bIsButtonHighligtedDown)
	{
		nState |= SPIN_HIGHLIGHTEDDOWN;
	}

	if (!IsWindowEnabled ())
	{
		nState |= SPIN_DISABLED;
	}

	CBCGPDrawOnGlass dog (m_bOnGlass || CBCGPToolBarImages::m_bIsDrawOnGlass);

	visualManager->OnDrawSpinButtons (
		pDC, rectClient, nState, (GetStyle() & UDS_HORZ) == UDS_HORZ, this);
}