/*
========================
idSWFSpriteInstance::StopFrame
========================
*/
void idSWFSpriteInstance::StopFrame( const idSWFParmList & parms ) {
	if ( parms.Num() > 0 ) {
		if ( parms[0].IsNumeric() && parms[0].ToInteger() < 1 ) {
			RunTo( FindFrame( "1" ) );
		} else {
			RunTo( FindFrame( parms[0].ToString() ) );
		}
		Stop();
	} else {
		idLib::Warning( "gotoAndStop: expected 1 paramater" );
	}
}
Example #2
0
HRESULT CLcXSkinSrc::FindBones(SFrame *pframeCur)
{
	HRESULT hr = S_OK;
	SMeshContainer *pmcMesh;
	SFrame *pframeChild;

	pmcMesh = pframeCur->pmcMesh;
	while (pmcMesh != NULL)
	{
		if (pmcMesh->pSkinInfo)
		{
			for (DWORD i = 0; i < pmcMesh->pSkinInfo->GetNumBones(); ++i)
			{
				SFrame* pFrame = FindFrame((char*)pmcMesh->pSkinInfo->GetBoneName(i));
				
				
				if(pFrame)
					pmcMesh->m_pBoneMatrix[i] = &(pFrame->tmWorld);
			}
		}
		pmcMesh = (SMeshContainer*)pmcMesh->pNextMeshContainer;
	}

	pframeChild = pframeCur->pFrameFirstChild;
	while (pframeChild != NULL)
	{
		hr = FindBones(pframeChild);
		if (FAILED(hr))
			return hr;

		pframeChild = pframeChild->pFrameSibling;
	}

	return S_OK;
}
Example #3
0
NPError   wxPluginApp::NPP_Destroy(NPP instance, NPSavedData** save)
{
    wxPluginFrame *frame = FindFrame(instance);
    if ( frame )
    {
        frame->Close();
    }
    return NPERR_NO_ERROR;
}
Example #4
0
void      wxPluginApp::NPP_StreamAsFile(NPP instance, NPStream* stream, const char *fname)
{
    wxPluginFrame *frame = FindFrame(instance);
    if ( frame )
    {
        wxString str(fname);
        frame->OnNPNewFile(stream, str);
    }
}
/*
========================
idSWFSpriteInstance::PlayFrame
========================
*/
void idSWFSpriteInstance::PlayFrame( const idSWFParmList & parms ) {
	if ( parms.Num() > 0 ) {
		actions.Clear();
		RunTo( FindFrame( parms[0].ToString() ) );
		Play();
	} else {
		idLib::Warning( "gotoAndPlay: expected 1 paramater" );
	}
}
Example #6
0
NPError   wxPluginApp::NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream,
                        NPBool seekable, uint16* stype)
{
    // By default, we want to receive a file instead of a stream.
    wxPluginFrame *frame = FindFrame(instance);
    if ( frame )
    {
        return frame->OnNPNewStream(type, stream, seekable, stype);
    }
    return NPERR_NO_ERROR;
}
Example #7
0
void wxPluginApp::NPP_Print(NPP instance, NPPrint* printInfo)
{
    if (instance == NULL)
        return;

    wxPluginFrame *frame = FindFrame(instance);
    if ( frame )
    {
        frame->OnNPPrint(printInfo);
    }
}
Example #8
0
CMessageFrame *CMessageFrame::Open( MSG_FolderInfo *folderInfo, MessageKey key )
{
	CMessageFrame *pFrame = FindFrame( folderInfo, key );

	if (!pFrame) {
		pFrame = CMessageFrame::Open();
		if ( pFrame ) {
			pFrame->LoadMessage( folderInfo, key );
		}
	}
	return pFrame;
}
Example #9
0
//--------------------------------------------------------------------
// BufMgr::FreePage
//
// Input    : pid     - page id of a particular page 
// Output   : None
// Purpose  : Free the memory allocated for the page with 
//            page id = pid  
// Condition: Either the page is already in the buffer and is pinned
//            no more than once, or the page is not in the buffer.
// PostCond : The page is unpinned, and the frame where it resides in
//            the buffer pool is freed.  Also the page is deallocated
//            from the database. 
// Return   : OK if operation is successful.  FAIL otherwise.
// Note     : You can call MINIBASE_DB->DeallocatePage(pid) to
//            deallocate a page.
//--------------------------------------------------------------------
Status BufMgr::FreePage(PageID pid)
{
	//std::cout << "Free PageID " << pid << std::endl;
	////std::cout << "Free page:  " << pid << std::endl;

	Frame* targetFrame;
	int frameIndex = FindFrame(pid);
	if (frameIndex != INVALID_FRAME) {
		targetFrame = &frames[frameIndex];

		if (targetFrame->GetPinCount() > 1) return FAIL;
		
		UnpinPage(pid, true);
		FlushPage(pid);
	}
	
	return MINIBASE_DB->DeallocatePage(pid);
}
Example #10
0
//--------------------------------------------------------------------
// BufMgr::UnpinPage
//
// Input    : pid     - page id of a particular page 
//            dirty   - indicate whether the page with page id = pid
//                      is dirty or not. (Optional, default to false)
// Output   : None
// Purpose  : Unpin the page with page id = pid in the buffer. Mark 
//            the page dirty if dirty is true.  
// Condition: The page is already in the buffer and is pinned.
// PostCond : The page is unpinned and the number of pin on the
//            page decrease by one. 
// Return   : OK if operation is successful.  FAIL otherwise.
//--------------------------------------------------------------------
Status BufMgr::UnpinPage(PageID pid, bool dirty)
{
	//std::cout << "Unin PageID " << pid << std::endl;
	////std::cout << "Unpinning page  " << pid << " Dirty?: " << dirty << std::endl;
	int frameIndex = FindFrame(pid);
	if (frameIndex == INVALID_FRAME) return FAIL;

	Frame* targetFrame = &frames[frameIndex];
	if (targetFrame->NotPinned()) return FAIL;

	if (dirty) targetFrame->DirtyIt();

	targetFrame->Unpin();

	if (targetFrame->NotPinned()) replacer->AddFrame(targetFrame->GetPageID());

	return OK;
}
Example #11
0
NPError      wxPluginApp::NPP_SetWindow(NPP instance, NPWindow* window)
{
//    MessageBox(NULL, "wxPluginApp::NPP_SetWindow", "wxPlugin", MB_OK);

    if ( window )
        wxDebugMsg("%d\n", (int) window->window);

    wxPluginFrame *frame = FindFrame(instance);
    if ( frame )
    {
        frame->SetNPWindow(window);
    }
    else
    {
#if 0
        // No such frame: must make it.
        if ( m_data.m_instance == NULL )
        {
            MessageBox(NULL, "wxPluginApp::NPP_SetWindow: whoops, no data to create window. SetWindow called in funny order?", "wxPlugin", MB_OK);
            return NPERR_NO_ERROR;
        }

        if ( window->window == NULL )
        {
            // We're receiving a NULL window before we've even received
            // a valid window. Ignore this silly thing.
            return NPERR_NO_ERROR;
        }

        m_data.m_window = window;
        m_data.m_instance = instance;

//        wxPluginFrame *frame = OnNewInstance(m_data);

        m_data.m_instance = NULL;
        m_data.m_window = NULL;
        delete[] m_data.m_argv;
        delete[] m_data.m_argn;
        m_data.m_argv = NULL;
        m_data.m_argn = NULL;
#endif
    }
    return NPERR_NO_ERROR;
}
Example #12
0
//--------------------------------------------------------------------
// BufMgr::FlushPage
//
// Input    : pid  - page id of a particular page 
// Output   : None
// Purpose  : Flush the page with the given pid to disk.
// Condition: The page with page id = pid must be in the buffer,
//            and is not pinned. pid cannot be INVALID_PAGE.
// PostCond : The page with page id = pid is written to disk if it's dirty. 
//            The frame where the page resides is empty.
// Return   : OK if operation is successful.  FAIL otherwise.
//--------------------------------------------------------------------
Status BufMgr::FlushPage(PageID pid)
{
	//std::cout << "Flush Page" << pid << std::endl;
	////std::cout << "Flush Page  " << pid << std::endl;
	int frameIndex = FindFrame(pid);
	if (frameIndex == INVALID_FRAME) return FAIL;

	Frame* targetFrame = &frames[frameIndex];
	if(!targetFrame->IsValid() || !targetFrame->NotPinned()) return FAIL;

	if (targetFrame->IsDirty()){
		if (targetFrame->Write() != OK) return FAIL;
		numDirtyPageWrites++;
	}
	
	replacer->RemoveFrame(targetFrame->GetPageID());
	targetFrame->EmptyIt();
	//std::cout << "Flush OK " << std::endl;
	return OK;
} 
Example #13
0
File: FSKModem.cpp Project: EQ4/FSK
void CFSKModem::SmoothingWave(short *InDataBuf,unsigned long length, 
							  unsigned long LowF, unsigned long HighF, unsigned long SampleRate)
{
	unsigned long i, j, k, N;
	long start, end;
	unsigned long l, h;

	/*
	unsigned long NumberOfLow = 0;//小幅度波的个数
	for(;i<length;)
	{   
	NumberOfLow = 0;
	while((InDataBuf[i] < 500)&&(InDataBuf[i] > -500)) //去除 连续 3点小于500的点
	{
	i++;
	NumberOfLow++;
	if(i == length)
	{
	return;
	}
	}
	if(NumberOfLow < 3)//对于中间出现的小幅度波小于3,要退回去
	{
	i -= NumberOfLow;
	}
	//InDataBuf[i] = (InDataBuf[i - 1] + InDataBuf[i] + InDataBuf[i + 1])/3;

	//i++;		
	}*/

#if 0
	for(i = 0; i < length;) {
		FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(this->m_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < N; j ++)	{
				this->m_fPoint[2*j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			cdft(N*2, -1, this->m_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				this->m_fPoint[2*k] = this->m_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				this->m_fPoint[2*k] =  this->m_fPoint[2*k+1] = 0;
			}

			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);
			icdft(N*2, -1, this->m_fPoint);
			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)this->m_fPoint[2*k+256];
			}
			i += end;
		}
		else
			break;
	}
#else
	for(i = 0; i < length;) {
		this->FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = this->GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(this->m_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < end - start + 256; j ++)	{
				this->m_fPoint[j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			rdft(N, 1, this->m_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				this->m_fPoint[2*k] = this->m_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				this->m_fPoint[2*k] =  this->m_fPoint[2*k+1] = 0;
			}

			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);

			rdft(N, -1, this->m_fPoint);
			for (j = 0; j <= N - 1; j++) {
				//this->m_fPoint[j] *= 2.0/ N;
				this->m_fPoint[j] /= N;
			}

			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)this->m_fPoint[k+256];
			}

			i += end;
		}
		else
			break;
	}

#endif
}
/*
========================
idSWFSpriteInstance::IsBetweenFrames
Checks if the current frame is between the given inclusive range.
========================
*/
bool idSWFSpriteInstance::IsBetweenFrames( const char * frameLabel1, const char * frameLabel2 ) const {
	return currentFrame >= FindFrame( frameLabel1 ) && currentFrame <= FindFrame( frameLabel2 );
}
Example #15
0
void CFSKModem::SmoothingWave(short *InDataBuf,unsigned long length,
							  unsigned long LowF, unsigned long HighF, unsigned long SampleRate)
{
	unsigned long i, j, k, N;
	long start, end;
	unsigned long l, h;
    
    
#if 0
	for(i = 0; i < length;) {
		FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(this->m_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < N; j ++)	{
				this->m_fPoint[2*j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			cdft(N*2, -1, this->m_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				this->m_fPoint[2*k] = this->m_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				this->m_fPoint[2*k] =  this->m_fPoint[2*k+1] = 0;
			}
            
			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);
			icdft(N*2, -1, this->m_fPoint);
			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)this->m_fPoint[2*k+256];
			}
			i += end;
		}
		else
			break;
	}
#else
	for(i = 0; i < length;) {
		this->FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = this->GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(this->m_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < end - start + 256; j ++)	{
				this->m_fPoint[j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			rdft(N, 1, this->m_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				this->m_fPoint[2*k] = this->m_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				this->m_fPoint[2*k] =  this->m_fPoint[2*k+1] = 0;
			}
            
			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);
            
			rdft(N, -1, this->m_fPoint);
			for (j = 0; j <= N - 1; j++) {
				//this->m_fPoint[j] *= 2.0/ N;
				this->m_fPoint[j] /= N;
			}
            
			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)this->m_fPoint[k+256];
			}
            
			i += end;
		}
		else
			break;
	}
    
#endif
}
Example #16
0
File: FSKModem.c Project: EQ4/FSK
void SmoothingWave(short *InDataBuf,unsigned long length, 
							  unsigned long LowF, unsigned long HighF, unsigned long SampleRate)
{
	unsigned long i, j, k, N;
	long start, end;
	unsigned long l, h;
	float *g_fPoint;			/* pointer to time-domain samples */// 这个东西至今没有确切的了解是什么,先放着
	g_fPoint = (float*)malloc(2 * MAX_N_POINTS * sizeof(float));//滤波的时候保存数据 

#if 0
	for(i = 0; i < length;) {
		FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(m_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < N; j ++)	{
				m_fPoint[2*j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			cdft(N*2, -1, m_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				m_fPoint[2*k] = m_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				m_fPoint[2*k] =  m_fPoint[2*k+1] = 0;
			}

			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);
			icdft(N*2, -1, m_fPoint);
			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)m_fPoint[2*k+256];
			}
			i += end;
		}
		else
			break;
	}
#else
	for(i = 0; i < length;) {
		FindFrame(InDataBuf + i, length - i, &start, &end);
		if(start >= 0) {
			if(end == -1)
				end = length - i - 1;
			N = GetN(end - start + 512); // 前后各至少填充256点,每点值为0
			memset(g_fPoint, 0, 2 * N * sizeof(float));
			for (j = 256; j < end - start + 256; j ++)	{
				g_fPoint[j] = InDataBuf[i+start+j-256];
			}
			/* Calculate FFT. */
			rdft(N, 1, g_fPoint);
			/* Filter */
			l = (unsigned long)(LowF/((float)SampleRate/N));
			h = (unsigned long)(HighF/((float)SampleRate/N));
			for(k = 0; k < l; k ++) {
				g_fPoint[2*k] = g_fPoint[2*k+1] = 0;
			}
			for(k = h; k < N; k ++) {
				g_fPoint[2*k] =  g_fPoint[2*k+1] = 0;
			}

			/* Clear time-domain samples and calculate IFFT. */
			memset(InDataBuf+i+start, 0, (end-start)*2);

			rdft(N, -1, g_fPoint);
			for (j = 0; j <= N - 1; j++) {
				//m_fPoint[j] *= 2.0/ N;
				g_fPoint[j] /= N;
			}

			for(k = 0; k < end-start; k ++) {
				InDataBuf[i+start+k] = (short)g_fPoint[k+256];
			}

			i += end;
		}
		else
		{
			free(g_fPoint);
			break;
		}
	}
	free(g_fPoint);

#endif
}
Example #17
0
	void CustomWebPage::handleUnsupportedContent (QNetworkReply *reply)
	{
		Util::DefaultHookProxy_ptr proxy (new Util::DefaultHookProxy);
		emit hookUnsupportedContent (proxy, this, reply);
		if (proxy->IsCancelled ())
			return;

		std::shared_ptr<void> replyGuard = std::shared_ptr<void> (nullptr,
				[reply] (void*) -> void
				{
					reply->abort ();
					reply->deleteLater ();
				});

		const auto& url = reply->url ();
		const auto& mime = reply->header (QNetworkRequest::ContentTypeHeader).toString ();

		qDebug () << Q_FUNC_INFO << reply->url () << reply->errorString ();

		auto sendEnt = [reply, mime, url, this] () -> void
		{
			auto e = Util::MakeEntity (url,
					{},
					LeechCraft::FromUserInitiated,
					mime);
			e.Additional_ ["IgnorePlugins"] = "org.LeechCraft.Poshuku";
			emit gotEntity (e);

			if (XmlSettingsManager::Instance ()->
					property ("CloseEmptyDelegatedPages").toBool () &&
					history ()->currentItem ().url ().isEmpty ())
				emit windowCloseRequested ();
		};

		switch (reply->error ())
		{
		case QNetworkReply::ProtocolUnknownError:
			if (XmlSettingsManager::Instance ()->
					property ("ExternalSchemes").toString ().split (' ')
					.contains (url.scheme ()))
				QDesktopServices::openUrl (url);
			else
				sendEnt ();
			break;
		case QNetworkReply::NoError:
		{
			auto found = FindFrame (url);
			if (!found)
			{
				if (XmlSettingsManager::Instance ()->
						property ("ParanoidDownloadsDetection").toBool () ||
						!mime.isEmpty ())
				{
					sendEnt ();
					break;
				}
				else
					qDebug () << Q_FUNC_INFO
							<< mime;
			}
			else
				qDebug () << Q_FUNC_INFO
					<< "but frame is found";
		}
		default:
		{
			int statusCode = reply->attribute (QNetworkRequest::HttpStatusCodeAttribute).toInt ();

			qDebug () << Q_FUNC_INFO
					<< "general unsupported content"
					<< url
					<< reply->error ()
					<< reply->errorString ();

			const auto& data = MakeErrorReplyContents (statusCode,
					url, reply->errorString (), QtNetwork);

			if (auto found = FindFrame (url))
				found->setHtml (data, url);
			else if (LoadingURL_ == url)
				mainFrame ()->setHtml (data, url);
			break;
		}
		}
	}
Example #18
0
/*  This code is called when you finish resizing a view by dragging the
    corner tab, but I think this implementation is lousy and will surprise
    the user more often than it will do what they are trying to do.  What
    I really need to be doing here is do a rewrite such that *no* sashes
    move except the ones immediately to the bottom and right of this window,
    and handle the case where you resize a window larger than it's neighbors
    by destroying the neighbors.

    But this will do for now.  */
void wxDynamicSashWindowImpl::Resize(int x, int y)
{
    wxDynamicSashWindowImpl *h_parent = FindParent(DSR_BOTTOM_EDGE);
    wxDynamicSashWindowImpl *v_parent = FindParent(DSR_RIGHT_EDGE);
    int h_unify = -1;
    int v_unify = -1;
    wxWindow *frame = FindFrame();

    if (x < 0)
        x = 0;
    if (y < 0)
        y = 0;

    if (h_parent)
    {
        m_container->ClientToScreen(NULL, &y);
        h_parent->m_container->ScreenToClient(NULL, &y);

        int py = (int)((y * 100) / h_parent->m_container->GetSize().GetHeight() + 0.5);

        if (py < 10)
        {
            wxDynamicSashWindowImpl *ho_parent = FindParent(DSR_TOP_EDGE);

            if (ho_parent)
            {
                if (FindUpperParent(h_parent, ho_parent) == ho_parent)
                {
                    h_unify = 1;
                }
                else
                {
                    py = (int)((ho_parent->m_child[0]->m_container->GetSize().GetHeight() * 100)
                                / h_parent->m_container->GetSize().GetHeight() + 0.5);
                    h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf(
                            h_parent->m_container, wxHeight, py);

                    h_parent = ho_parent;
                    h_unify = 0;
                }
            }
            else
            {
                h_unify = 1;
            }
        }
        else if (py > 90)
        {
            h_unify = 0;
        }
        else
        {
            h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf(
                    h_parent->m_container, wxHeight, py);
            h_parent->m_container->Layout();
        }
    }
    else
    {
        int do_resize = 1;
        h_parent = FindParent(DSR_TOP_EDGE);

        if (h_parent)
        {
            int py = (int)((y * 100) /
                        (h_parent->m_container->GetSize().GetHeight() +
                                y - m_container->GetSize().GetHeight()) + 0.5);

            if (py < 10)
                h_unify = 0;
        }
        else if (y < 64)
        {
            do_resize = 0;
        }

        if (do_resize)
        {
            wxSize size = frame->GetSize();
            frame->SetSize(size.GetWidth(), size.GetHeight() + y - m_container->GetSize().GetHeight());
        }
    }

    if (v_parent)
    {
        m_container->ClientToScreen(&x, NULL);
        v_parent->m_container->ScreenToClient(&x, NULL);

        int px = (int)((x * 100) / v_parent->m_container->GetSize().GetWidth() + 0.5);

        if (px < 10)
        {
            wxDynamicSashWindowImpl *vo_parent = FindParent(DSR_LEFT_EDGE);

            if (vo_parent)
            {
                if (FindUpperParent(v_parent, vo_parent) == vo_parent)
                {
                    v_unify = 1;
                }
                else
                {
                    px = (int)((vo_parent->m_child[0]->m_container->GetSize().GetWidth() * 100)
                                / v_parent->m_container->GetSize().GetWidth() + 0.5);
                    v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf(
                            v_parent->m_container, wxWidth, px);

                    v_parent = vo_parent;
                    v_unify = 0;
                }
            }
            else
            {
                v_unify = 1;
            }
        }
        else if (px > 90)
        {
            v_unify = 0;
        }
        else
        {
            v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf(
                    v_parent->m_container, wxWidth, px);
            v_parent->m_container->Layout();
        }
    }
    else
    {
        int do_resize = 1;
        v_parent = FindParent(DSR_LEFT_EDGE);

        if (v_parent)
        {
            int px = (int)((x * 100) /
                        (v_parent->m_container->GetSize().GetWidth() +
                                x - m_container->GetSize().GetWidth()) + 0.5);

            if (px < 10)
                v_unify = 0;
        }
        else if (x < 64)
        {
            do_resize = 0;
        }

        if (do_resize)
        {
            wxSize size = frame->GetSize();
            frame->SetSize(size.GetWidth() + x - m_container->GetSize().GetWidth(), size.GetHeight());
        }
    }

    if (h_unify != -1 && v_unify != -1)
    {
        wxDynamicSashWindowImpl *parent = FindUpperParent(h_parent, v_parent);

        if (parent == h_parent)
        {
            h_parent->Unify(h_unify);
        }
        else
        {
            v_parent->Unify(v_unify);
        }
    }
    else if (h_unify != -1)
    {
        h_parent->Unify(h_unify);
    }
    else if (v_unify != -1)
    {
        v_parent->Unify(v_unify);
    }
}
Example #19
0
EFFECTEXEC(frame,tags,PPTBase,EffectBase)
{
    ULONG sig, rc, *args;
    BOOL quit = FALSE, reallyrexx = FALSE;
    FRAME *newframe = NULL, *with = NULL;
    struct gFixRectMessage gfr = {0};
    ULONG fc, wc;
    struct Values *av;

    D(bug(MYNAME": Exec()\n"));

    /*
     *  Defaults
     */
    v.ratio = 128;
    v.method = Direct;
    v.bounds.Top = v.bounds.Left = ~0;
    v.bounds.Width = 200; v.bounds.Height = 100;
    v.tile = FALSE;

    if( av = GetOptions(MYNAME) ) {
        v = *av;
    }

    /*
     *  Copy to local variables
     */

    BGUIBase        = PPTBase->lb_BGUI;
    IntuitionBase   = (struct IntuitionBase *)PPTBase->lb_Intuition;
    DOSBase         = PPTBase->lb_DOS;
    SysBase         = PPTBase->lb_Sys;

    /*
     *  Parse AREXX message, which has to exist.
     *  BUG: If necessary, should wait for D&D from the main window.
     *  BUG: Should make sanity checks!
     */

    args = (ULONG *) TagData( PPTX_RexxArgs, tags );

    if( args ) {

        /* WITH */
        if( args[0] ) {
            with = FindFrame( (ID) PEEKL(args[0]) );
            if(!with) {
                SetErrorMsg(frame,"Unknown frame ID for WITH parameter");
                return NULL;
            }
        }

        /* TOP */
        if( args[1] ) {
            gfr.y = (WORD) PEEKL(args[1]);
            reallyrexx = TRUE;
        }

        /* LEFT */
        if( args[2] ) {
            gfr.x = (WORD) PEEKL(args[2]);
            reallyrexx = TRUE;
        }

        /* METHOD */
        if( args[3] ) {
            int i;

            for( i = 0; method_labels[i]; i++ ) {
                if(stricmp( method_labels[i], (char *)args[3] ) == 0 ) {
                    v.method = i;
                    reallyrexx = TRUE;
                    break;
                }
            }
        }

        /* RATIO */
        if( v.method == Mix ) {
            if( args[4] ) {
                v.ratio = PEEKL( args[4] );
            } else {
                SetErrorCode(frame,PERR_INVALIDARGS);
            }
        }

        /* TILE */
        if( args[5] ) {
            v.tile = TRUE;
        } else {
            v.tile = FALSE;
        }

    } else {
        SetErrorMsg(frame,"Image compositing can be used with Drag&Drop (or REXX) only");
        return NULL;
    }

    /*
     *  Make some sanity checks
     */

    if( frame->pix->width < with->pix->width ||
        frame->pix->height < with->pix->height ) {
            SetErrorMsg(frame,"You cannot composite a larger picture on a smaller one!");
            return NULL;
        }

    fc = frame->pix->colorspace;
    wc = with->pix->colorspace;

    if( ! (wc == fc || (fc == CS_ARGB && wc == CS_RGB) || (fc == CS_RGB && wc == CS_ARGB ))) {
        SetErrorMsg(frame, "Only images of the same color space can be composited");
        return NULL;
    }

    gfr.dim.Left   = 0;
    gfr.dim.Top    = 0;
    gfr.dim.Height = with->pix->height;
    gfr.dim.Width  = with->pix->width;

    /*
     *  Open window and start parsing
     */

    if( reallyrexx == FALSE ) {
        if( GimmeWindow(frame, with, PPTBase) ) {
            ULONG sigmask, gimask = 0L;

            GetAttr( WINDOW_SigMask, Win, &sigmask );

            StartInput(frame, GINP_FIXED_RECT, (struct PPTMessage *) &gfr);

            gimask = (1 << PPTBase->mport->mp_SigBit);

            while( !quit ) {
                sig = Wait( sigmask|gimask|SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_F );

                if( sig & SIGBREAKF_CTRL_C ) {
                    D(bug("BREAK!\n"));
                    SetErrorCode( frame, PERR_BREAK );
                    quit = TRUE;
                    break;
                }

                if( sig & SIGBREAKF_CTRL_F ) {
                    WindowToFront(win);
                    ActivateWindow(win);
                }

                if( sig & gimask ) {
                    struct gFixRectMessage *pmsg;

                    if(pmsg = (struct gFixRectMessage *)GetMsg( PPTBase->mport )) {
                        if( pmsg->msg.code == PPTMSG_FIXED_RECT ) {
                            D(bug("User picked a point @ (%d,%d)\n",pmsg->x, pmsg->y));
                            gfr.x = pmsg->x; gfr.y = pmsg->y;
                            // SetGadgetAttrs( ( struct Gadget *)OKButton, win, NULL, GA_Disabled, FALSE );
                        }
                        ReplyMsg( (struct Message *)pmsg );
                    }
                }

                if( sig & sigmask ) {
                    while( (rc = HandleEvent( Win )) != WMHI_NOMORE ) {
                        ULONG t;

                        switch(rc) {
                            case GID_OK:
                                GetAttr( CYC_Active, Method, (ULONG *)&v.method );
                                GetAttr( SLIDER_Level, Ratio, &v.ratio );

                                /*
                                 *  Save the window attributes for later retrieval.
                                 */

                                GetAttr( WINDOW_Bounds, Win, (ULONG *) &v.bounds );
                                GetAttr( GA_Selected, Tile, &t );

                                StopInput( frame );
                                v.tile = (BOOL) t;

                                WindowClose(Win);
                                newframe = DoComposite( frame, with, &gfr, v.method,
                                                        (WORD) v.ratio, v.tile, PPTBase );
                                quit = TRUE;
                                break;

                            case GID_CANCEL:
                                quit = TRUE;
                                StopInput( frame );
                                break;
                        }
                    }
                }
            }
        }
    } else {
        /* gfr is already set up */
        newframe = DoComposite( frame, with, &gfr,
                                v.method, (WORD) v.ratio, v.tile,
                                PPTBase );
    }

    if(Win) DisposeObject(Win);

    if( newframe ) {
        PutOptions( MYNAME, &v, sizeof(struct Values) );
    }

    D(bug("Returning %08X...\n",newframe));
    return newframe;
}