// Creates a sound buffer with a loop in the middle.  The sound will play
// the start sound, play the loop sound until it gets a soft stop, then
// play the rest of the sound.  
HRESULT DS3DSoundEngine::CreateASRBuffer(TRef<ISoundInstance>& psoundNew, 
    ISoundPCMData* pcmdata, unsigned uLoopStart, unsigned uLoopLength, 
    ISoundPositionSource* psource)
{
    // check the parameters
    if (pcmdata == NULL)
    {
        ZAssert(false);
        return E_POINTER;
    }

    // make sure the loop is contained in the buffer
    if (uLoopStart + uLoopLength > pcmdata->GetSize())
    {
        ZAssert(false);
        return E_INVALIDARG;
    }

    TRef<DSVirtualSoundBuffer> pvirtualsound;

    if (psource != NULL)
    {
        pvirtualsound = new DS3DVirtualSoundBuffer(pcmdata, uLoopStart, uLoopLength, psource);
    }
    else
    {
        pvirtualsound = new DSVirtualSoundBuffer(pcmdata, uLoopStart, uLoopLength);
    }

    m_listActiveSounds.push_back(pvirtualsound);
    psoundNew = pvirtualsound;

    return S_OK;
}
	void SetColorKey(const Color& color)
	{
		ZAssert(m_datas.GetCount() == 0);
		ZAssert(m_datasConverted.GetCount()	== 0);

		m_bColorKey	= true;
		m_colorKey = color;

		// Update the ddraw	surface
		SetSurfaceMode(SurfaceModeDD);
		DDCOLORKEY key;
		key.dwColorSpaceLowValue  =
		key.dwColorSpaceHighValue =	m_data.m_ppf->MakePixel(m_colorKey).Value();

//		DDCall(m_data.m_pdds->SetColorKey(DDCKEY_SRCBLT, &key));

		// Update the converted	ddraw surface
		if( m_dataConverted.m_pd3dtexture )	
		{
			_ASSERT( false );
//			DDCall(m_dataConverted.m_pdds->SetColorKey(DDCKEY_SRCBLT, &key));
		}

		SurfaceChanged();
	}
Beispiel #3
0
void ZServer::Start(ZRef<ZCaller> iCaller,
	ZRef<ZStreamerRWFactory> iFactory,
	ZRef<Callable_Connection> iCallable_Connection)
	{
	ZAssert(iCaller);
	ZAssert(iFactory);

	// Declared before the acq, so it goes out of scope after it, and any
	// callable on the roster is invoked with our mutex released.
	ZRef<ZRoster> priorRoster;

	ZAcqMtx acq(fMtx);

	ZAssert(not fWorker);
	ZAssert(not fFactory);
	ZAssert(not fCallable_Connection);

	priorRoster = fRoster;
	fRoster = new ZRoster;

	fFactory = iFactory;
	fCallable_Connection = iCallable_Connection;

	fWorker = new ZWorker(
		sCallable(sWeakRef(this), &ZServer::pWork),
		sCallable(sWeakRef(this), &ZServer::pWorkDetached));

	fWorker->Attach(iCaller);

	fWorker->Wake();
	}
ZBlackBerryServer::~ZBlackBerryServer()
	{
	ZAssert(fHandlers_ManagerChanged.empty());

	for (vector<Entry_t>::iterator i = fEntries.begin(); i != fEntries.end(); ++i)
		ZAssert(i->fHandlers.empty());

	fManager->SetCallable(null);
	}
Beispiel #5
0
    void ChildChanged(Value* pvalue, Value* pvalueNew)
    {
        ZAssert(NULL == pvalueNew);
        ZAssert(GetChild(0) == pvalue);
        pvalue->Update();

        m_nValueCurrent = (int)Number::Cast(pvalue)->GetValue();
        UpdatePane();
    }
Beispiel #6
0
void ZServer::Finalize()
	{
	ZGuardMtx guard(fMtx);
	ZAssert(not fWorker);
	ZAssert(not fFactory);
	fRoster.Clear();
	fCallable_Connection.Clear();
	guard.Release();

	ZCounted::Finalize();
	}
Beispiel #7
0
    void InsertPane(Pane* pPane, ButtonPane* pButtonPane, int nPaneID)
    {
        ZAssert(nPaneID != -1); // reserved
        ZAssert(!m_fShowSelPane);

        if (m_mapPanes.Count() == 0) {
            m_nPaneIDCurrent = nPaneID;
            m_pPaneCurrent = pPane;
        }
        m_mapPanes.Set(nPaneID, pPane);
        m_pButtonBarPane->InsertButton(pButtonPane, nPaneID);
    }
Beispiel #8
0
// From ZUISelection::Responder
void ZUITextPane_TextEngine::HandleUISelectionEvent(ZUISelection* inSelection, ZUISelection::Event inEvent)
	{
	ASSERTLOCKED();
// For now the only selection we're connected to is our text engine
	ZAssert(inSelection == fTextEngine);
	static_cast<ZUISelection*>(this)->Internal_NotifyResponders(inEvent);
	}
Beispiel #9
0
// From ZUIScrollable::Responder
void ZUITextPane_TextEngine::ScrollableChanged(ZUIScrollable* inScrollable)
	{
	ASSERTLOCKED();
// For now the only scrollable we're connected to is our text engine
	ZAssert(inScrollable == fTextEngine);
	static_cast<ZUIScrollable*>(this)->Internal_NotifyResponders();
	}
	//////////////////////////////////////////////////////////////////////////////
	// CalculateSurfaceSize()
	//
	//////////////////////////////////////////////////////////////////////////////
	void CalculateSurfaceSize()
	{
		m_sizeSurface =	m_size;

		if (m_size.X() < 1)	
		{
			ZAssert(m_size.X() == 0);
			m_sizeSurface.SetX(1);
		}

		if (m_size.Y() < 1)	
		{
			ZAssert(m_size.Y() == 0);
			m_sizeSurface.SetY(1);
		}
	}
Beispiel #11
0
static ZOSApp* sCreateOSApp(const char* inSignature)
	{
	ZOSApp* theOSApp = nil;

	#if 0
	#elif ZCONFIG(API_OSWindow, Be)

		theOSApp = new ZOSApp_Be(inSignature);

	#elif ZCONFIG(API_OSWindow, Carbon)

		theOSApp = new ZOSApp_Carbon;

	#elif ZCONFIG(API_OSWindow, Mac)

		theOSApp = new ZOSApp_Mac;

	#elif ZCONFIG(API_OSWindow, Win32)

		theOSApp = new ZOSApp_Win(inSignature);

	#elif ZCONFIG(API_OSWindow, X)

		theOSApp = new ZOSApp_X;

	#endif

	ZAssert(theOSApp);
	return theOSApp;
	}
Beispiel #12
0
    void ScrollToItemByIdx(int iItem)
    {        
        if (m_vItems.GetCount() == 0)
            {
            // nothing to do
            return;
            }

        ZAssert((iItem == 0) || ((iItem > 0) && (iItem < m_vItems.GetCount())));

        // find the first and last matching item
        int iTop, iBottom;
        iTop = iBottom = iItem;
        while (iTop > 0 && m_vItems[iTop-1] == m_vItems[iTop])
            iTop--;
        while (iBottom < m_vItems.GetCount()-1 && m_vItems[iBottom+1] == m_vItems[iBottom])
            iBottom++;

        if (iBottom > LastVisibleItem())
            m_iTopItem = max(iBottom - (m_cVisibleItems - 1), 0);
        if (iTop < m_iTopItem)
            m_iTopItem = iTop;

        if (m_pScrollPane)
            m_pScrollPane->SetPos(m_iTopItem);            

        NeedPaint();
    }
Beispiel #13
0
    void InsertPane(Pane* pPane, int nPaneID)
    {
        ZAssert(nPaneID != -1); // reserved

        m_mapPanes.Set(nPaneID, pPane);
        UpdatePane();
    }
void Matrix::Set(int row, int col, float value)
{
    ZAssert(row >= 0 && row <= 3 && col >= 0 && col <= 3);

    m_m[row][col] = value;
    m_type = TransformUnknown;
}
Beispiel #15
0
ValueList::ValueList(Site* psite) :
    m_psite(psite),
    m_list(),
    m_iter(m_list)
{
    ZAssert(psite == NULL || (((DWORD)psite) > 0x10));
}
Beispiel #16
0
 void ChildChanged(Value* pvalue, Value* pvalueNew)
 {
     ZAssert(NULL == pvalueNew);
     
     pvalue->Update();
     if (pvalue == m_pcolor)
         {
         ZAssert(pvalue == GetChild(1));
         SetTextColor(m_pcolor->GetValue());
         }
     else
         {
         ZAssert(pvalue == GetChild(0));
         StringPane::SetString(StringValue::Cast(pvalue)->GetValue());
         }
 }
Beispiel #17
0
    void ChildChanged(Value* pvalue, Value* pvalueNew)
    {
        ZAssert(NULL == pvalueNew);

        if (pvalue == GetChild(0)) // number changed
            {
            pvalue->Update();
            SetValue(Number::Cast(pvalue)->GetValue(), true);
            }
       else // time changed
            {
            ZAssert(GetChild(1) == pvalue);
            pvalue->Update();
            Update(Number::Cast(pvalue)->GetValue());
            }
    }
Beispiel #18
0
    int FindNearestNewIndex(int nOldIndex)
    {
        if (nOldIndex == -1 || m_vectItemsOld.GetCount() == 0)
            return -1;
        
        ZAssert(nOldIndex >= 0 && nOldIndex < m_vectItemsOld.GetCount());

        int nNewIndex;

        // check to see if the old item exists in the new list
        nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex]);

        // if we haven't found a new index yet, try searching the items around it
        int iDelta = 1;
        while (nNewIndex == -1 
            && (nOldIndex - iDelta >= 0 
                || nOldIndex + iDelta < m_vectItemsOld.GetCount()))
        {
            if (nOldIndex - iDelta >= 0)
                nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex - iDelta]);

            if (nNewIndex != -1 && nOldIndex + iDelta < m_vectItemsOld.GetCount())
                nNewIndex = m_plist->GetIndex(m_vectItemsOld[nOldIndex - iDelta]);

            ++iDelta;
        }

        // if we still haven't found a new index, default to the first item
        if (nNewIndex == -1)
        {
            nNewIndex = 0;
        }

        return nNewIndex;
    }
Beispiel #19
0
    void MouseMove(IInputProvider* pprovider, const Point& point, bool bCaptured, bool bInside)
    {
        if (bCaptured)
        {
            ZAssert(m_bDragging && m_bCanDrag);

            float fScale = (m_xMax - m_xMin)/m_rectMap.XSize();

            float fDeltaX = fScale * (m_pointLastDrag.X() - point.X());
            float fDeltaY = fScale * (m_pointLastDrag.Y() - point.Y());

            // make sure we don't drag the map off of the screen
            m_xDrag = max(min((m_xClusterMax - m_xClusterMin) - (m_xMax - m_xMin), m_xDrag + fDeltaX), 0);
            m_yDrag = max(min((m_yClusterMax - m_yClusterMin) - (m_yMax - m_yMin), m_yDrag + fDeltaY), 0);

            m_pointLastDrag = point;
            GetWindow()->SetCursor(AWF_CURSOR_DRAG);
            Changed();
        }
        else
        {
 
            if (m_bCanDrag)
            {
                GetWindow()->SetCursor(AWF_CURSOR_DRAG);
            }
            else
            {
                GetWindow()->SetCursor(AWF_CURSOR_DEFAULT);
            }
        }

        Changed();
    }
Beispiel #20
0
    ChatListItem(ChatInfo* pchatInfo, const WinPoint& ptLineSize) :
        m_lData((long)pchatInfo),
        m_pchatInfo(pchatInfo),
        m_ptLineSize(ptLineSize)
    {
        ZString strMsg = CensorBadWords (m_pchatInfo->GetMessage());
		IEngineFont* pfont = pchatInfo->IsFromLeader() ? TrekResources::SmallBoldFont() : TrekResources::SmallFont();
        int nStrLenLeft = strMsg.GetLength();
        int nStrLenLine;
        while ((nStrLenLine = pfont->GetMaxTextLength(strMsg, ptLineSize.X(), true))
                < nStrLenLeft)
        {
            int nStrLenWordBreak = nStrLenLine;
            while (nStrLenWordBreak > 2 && strMsg[nStrLenWordBreak] != ' ' && strMsg[nStrLenWordBreak-1] != ' ')
                nStrLenWordBreak--;
            if (nStrLenWordBreak != 2)
                nStrLenLine = nStrLenWordBreak;
            
            if (nStrLenLine <= 2)
            {
                // put a blank line without the character
                nStrLenLine = 3;
                m_vMsgLines.PushEnd("");
            }
            else
            {
                m_vMsgLines.PushEnd(strMsg.Left(nStrLenLine));
            }
            strMsg = "  " + strMsg.RightOf(nStrLenLine);
            nStrLenLeft -= nStrLenLine - 2;
            ZAssert(strMsg.GetLength() == nStrLenLeft);
        }
        m_vMsgLines.PushEnd(strMsg);
    }
Beispiel #21
0
ZString Value::Indent(int indent)
{
    static char* pchSpaces = "                                                                ";

    ZAssert(indent * 2 < 64);

    return ZString(pchSpaces, indent * 2);
}
Beispiel #22
0
void Window::SetTopMost(bool bTopMost)
{
    ZAssert(m_pwindowParent == NULL);

    //if (m_bTopMost != bTopMost) {
        m_bTopMost = bTopMost;
        CalcStyle();
    //}
}
Beispiel #23
0
void Value::ChangeTo(Value* pvalue)
{
    ZAssert(pvalue != this);
    TRef<Value> pvalueSave = this;

    while (m_listParents.GetCount() != 0) {
        m_listParents.GetFront()->ChildChanged(this, pvalue);
    };
}
Beispiel #24
0
void Window::SetSizeable(bool bSizeable)
{
    ZAssert(m_pwindowParent == NULL);

    if (m_bSizeable != bSizeable) {
        m_bSizeable = bSizeable;
        CalcStyle();
    }
}
Beispiel #25
0
ZApp::ZApp(const char* inSignature)
:	ZOSAppOwner(sCreateOSApp(inSignature)),
	ZMessageReceiver(this)
	{
	ZAssert(sApp == nil);
	sApp = this;
	fPostedInvalidateMenuBar = false;
	this->InvalidateMenuBar();
	}
Beispiel #26
0
ZClipboard::ZClipboard()
	{
	ZAssert(!sClipboard);
	sClipboard = this;

#if ZCONFIG(OS, MacOS7)
	fLastKnownScrapCount = ::InfoScrap()->scrapCount - 1;
#endif // ZCONFIG(OS, MacOS7)
	}
Beispiel #27
0
ZApp::ZApp(ZOSApp* inOSApp)
:	ZOSAppOwner(inOSApp),
	ZMessageReceiver(this)
	{
	ZAssert(sApp == nil);
	sApp = this;
	fPostedInvalidateMenuBar = false;
	this->InvalidateMenuBar();
	}
    TRef<IObject> Apply(ObjectStack& stack)
    {
        TRef<Number>         pnumGain;    CastTo(pnumGain, (IObject*)stack.Pop());
        TRef<ISoundTemplate> ptemplateBase; CastTo(ptemplateBase, (IObject*)stack.Pop());

        ZAssert(pnumGain && ptemplateBase);

        return new SoundGainValueTemplate(ptemplateBase, pnumGain);
    }
Beispiel #29
0
Worker::Worker(
	const ZRef<Callable_Work>& iCallable_Work,
	const ZRef<Callable_Detached>& iCallable_Detached)
:	fWorking(0)
,	fCallable_Work(iCallable_Work)
,	fCallable_Detached(iCallable_Detached)
	{
	ZAssert(fCallable_Work);
	}
Beispiel #30
0
DWORD ZFile::Write(void* p, DWORD length)
{
    DWORD cbActual;

    WriteFile(m_handle, p, length, (LPDWORD)&cbActual, NULL);

    ZAssert(cbActual == length);

    return cbActual;
}