Beispiel #1
0
//********************************************
// Alloc
//********************************************
int CTexture::Alloc(unsigned int width,
										unsigned int height,
										unsigned int depth)
{
	Free();

	unsigned int BytePerPixel = (unsigned int)(depth / 8);
	unsigned int Width32 = WidthByte32(width,depth);

	// Only rgb and rgba modes
	ASSERT(BytePerPixel == 3 || 
		     BytePerPixel == 4);

	m_pData = new unsigned char [Width32 * height];
	if(m_pData == NULL)
		{
		TRACE("CTexture::Alloc : Insuffisant memory\n");
		AfxMessageBox("CTexture::Alloc : Insufisant memory");
		return 0;
		}

	// Set members variables
	m_Width = width;
	m_WidthByte32 = Width32;
	m_Height = height;
	m_Depth = depth;
	UpdateHeader();

	return 1;
}
OP_STATUS
OpScopeHttpLogger::ResponseReceived(void* ptr, const char* ctx)
{
	if (IsEnabled())
	{
		double time = g_op_time_info->GetTimeUTC();
		OpScopeHttpInfo *info = reinterpret_cast<OpScopeHttpInfo *>(requests.First());
		for (; info; info = reinterpret_cast<OpScopeHttpInfo *>(info->Suc()))
		{
			if (info->ptr == ptr)
				break;
		}
		if (info)
		{
			info->time_response_sent = time;
			OP_STATUS status = OpStatus::OK;
			if (AcceptWindow(info->window))
			{
				Header msg;
				RETURN_IF_ERROR(UpdateHeader(msg, ptr, info->id, ctx, info->response_header.CStr(), info->response_header.Length(), info->window, info->time_response_sent));
				status = SendOnResponse(msg);
			}
			info->Out();
			OP_DELETE(info);
			return status;
		}
		else
			return OpStatus::ERR;
	}
	else
		return OpStatus::OK;
}
Beispiel #3
0
// Call this function after you create the window or after an prefs update
void CHeaderView::UpdateSettings( void )
{
  COLORREF *IRCColors = PrefsColorsToIRCEditCtrlColors(g_pPrefs->m_ColorPrefs);
  if (IRCColors)
  {
    m_EditCtrl.SetColors(IRCColors);
    free (IRCColors);
  }
  m_EditCtrl.SetFont(GetAppFont(PREF_fHeaderFont)); // TODO: new font pref needed
  m_EditCtrl.SetBackgroundColor(m_BackColor);

  if (m_CurrentHeader)
    UpdateHeader(m_CurrentHeader);
  else
  {
    m_EditCtrl.SetSel(0,-1);
    CHARFORMAT2 fmt;
    m_EditCtrl.GetDefaultCharFormat(fmt);  
    fmt.dwEffects = 0;
    fmt.dwMask = CFM_COLOR | CFM_BACKCOLOR;
    fmt.crTextColor = m_TextColor;
	  fmt.crBackColor = m_BackColor;
    fmt.cbSize = sizeof(CHARFORMAT2);
    m_EditCtrl.SetSelectionCharFormat(fmt);
  }
}
OP_STATUS 
OpScopeHttpLogger::RequestSent(void* ptr, const char* ctx, const char* buf, size_t buf_len)
{
	if (IsEnabled())
	{
		double time = g_op_time_info->GetTimeUTC();

		OpScopeHttpInfo *info = reinterpret_cast<OpScopeHttpInfo *>(requests.First());
		for (; info; info = reinterpret_cast<OpScopeHttpInfo *>(info->Suc()))
		{
			if (info->ptr == ptr)
				break;
		}

		if (!info || !AcceptWindow(info->window))
			return OpStatus::OK;

		info->time_request_sent = time;
		Header msg;
		RETURN_IF_ERROR(UpdateHeader(msg, ptr, info->id, ctx, buf, buf_len, info->window, time));
		return SendOnRequest(msg);
	}
	else
		return OpStatus::OK;
}
Beispiel #5
0
LRESULT CUIHandlerOnekey::OnCleanState(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    CleanRecord* pCleanRecord = (CleanRecord*)(PVOID)wParam;
    //CurrentCleanEntry* pCleanEntry = NULL;
    CleanEntry entry;

    if (!pCleanRecord)
        goto clean0;

    if (0 == lParam)
    {
        pCleanRecord->m_fBegined = TRUE;
        pCleanRecord->m_dwBeginTime = GetTickCount();
        pCleanRecord->m_dwEndTime = GetTickCount();
        goto clean0;
    }

    if (1 == lParam && !m_bCancel)
    {
        pCleanRecord->m_fFinished = TRUE;
        pCleanRecord->m_dwEndTime = GetTickCount();

        // 开始下一项扫描
        if (pCleanRecord == &m_ctrlClean.m_recordTrashClean)
        {
            m_cleanStates[0].PushData();
            _CleanTrack();
        }
        else if (pCleanRecord == &m_ctrlClean.m_recordTrackClean)
        {
            m_cleanStates[1].PushData();
            _CleanReg();
        }
        else if (pCleanRecord == &m_ctrlClean.m_recordRegClean)
        {
            m_cleanStates[2].PushData();
            _StopClean(FALSE);
        }

        goto clean0;
    }

    if (2 == lParam)
    {
        if (!pCleanRecord->m_fFinished)
        {
            pCleanRecord->m_fFinished = TRUE;
            pCleanRecord->m_fCanceled = TRUE;
        }
        m_bCancel = TRUE;
    }

clean0:
    UpdateHeader();
    UpdateMiddle();
    UpdateButtom();

    return 0L;
}
Beispiel #6
0
void CUIHandlerOnekey::InitDelay()
{
    LoadSetting();

    UpdateHeader();
    UpdateMiddle();
    m_ctrlClean.UpdateUI();
    _LoadProvider();
}
Beispiel #7
0
//********************************************
// Extract
//********************************************
int Texture::Extract(int left, int top, int right, int bottom)
{
  // Saturate
  if(right == -1)
    right = m_Width-1;
  if(bottom == -1)
    bottom = m_Height-1;

  // Check
  if(left >= right || top >= bottom)
    return 0;
  if(left < 0  || left >= (int)m_Width || 
    right < 0 || right >= (int)m_Width)
    return 0;
  if(top < 0  || top >= (int)m_Height || 
    bottom < 0 || bottom >= (int)m_Height)
    return 0;

  int NewWidth = right-left+1;
  int NewWidthByte32 = WidthByte32(NewWidth,m_Depth);
  int NewHeight = bottom-top+1;
  int BytePerPixel = m_Depth / 8;
  int i,j,k;

  //TRACE("Start extracting...\n");
  //TRACE("New width : %d\n",NewWidth);
  //TRACE("New height : %d\n",NewHeight);

  // Alloc
  unsigned char *pData = new unsigned char[NewWidthByte32*NewHeight];
  if(pData == NULL)
  {
    //TRACE("Insufficiant memory");
    return 0;
  }

  for(j=0;j<NewHeight;j++)
    for(i=0;i<NewWidth;i++)
      for(k=0;k<BytePerPixel;k++)
	pData[NewWidthByte32*j+i*BytePerPixel+k] = m_pData[m_WidthByte32*(m_Height-1-(j+top))+(i+left)*BytePerPixel+k];

  // Replace datas
  delete [] m_pData;
  m_pData = pData;
  m_Width = NewWidth;
  m_WidthByte32 = NewWidthByte32;
  m_Height = NewHeight;

  UpdateHeader();

  return 1;
}
Beispiel #8
0
//********************************************
// DuplicateRepeatWidth
//********************************************
int Texture::DuplicateRepeatWidth(int left, int top, int right, int bottom)
{
  if(!Extract(left,top,right,bottom))
    return 0;

  left = 0;
  right = m_Width-1;
  top = 0;
  bottom = m_Height-1;

  int NewWidth = 2*m_Width;
  int NewWidthByte32 = WidthByte32(NewWidth,m_Depth);
  int NewHeight = m_Height;
  int BytePerPixel = m_Depth / 8;
  int i,j,k;

  ////TRACE("Start duplicate repeat width...\n");
  ////TRACE("New width : %d\n",NewWidth);
  ////TRACE("New widthbyte32 : %d\n",NewWidthByte32);
  ////TRACE("New height : %d\n",NewHeight);

  // Alloc
  unsigned char *pData = new unsigned char[NewWidthByte32*NewHeight];
  if(pData == NULL)
  {
    ////TRACE("Insufficiant memory");
    return 0;
  }

  // x o
  for(j=0;j<NewHeight;j++)
    for(i=0;i<NewWidth/2;i++)
      for(k=0;k<BytePerPixel;k++)
	pData[NewWidthByte32*j+i*BytePerPixel+k] = m_pData[m_WidthByte32*(bottom-(j+top))+(i+left)*BytePerPixel+k];
  // o x
  for(j=0;j<NewHeight;j++)
    for(i=NewWidth/2;i<NewWidth;i++)
      for(k=0;k<BytePerPixel;k++)
	pData[NewWidthByte32*j+i*BytePerPixel+k] = m_pData[m_WidthByte32*(bottom-(j+top))+(i-NewWidth/2+left)*BytePerPixel+k];

  // Replace datas
  delete [] m_pData;
  m_pData = pData;
  m_Width = NewWidth;
  m_WidthByte32 = NewWidthByte32;
  m_Height = NewHeight;

  UpdateHeader();

  return 1;
}
Beispiel #9
0
BOOL L4DnDHndlr_PostMon(UINT8* buffer, UINT16 type, UINT16 length)
{
    int res;
    //Assert correct params
    if (FALSE == isInitialized)
    {
        TRACE(TR_MOD_DND_AGENT, TR_SEV_WARNING, "[L4DnDHndlr_PostMon]: L4 DnD Monitor Handler is not initialized yet");
        return FALSE;
    }

    if (length == 0)
    {
        TRACE(TR_MOD_DND_AGENT, TR_SEV_ERR, "[L4DnDHndlr_PostMon]: Length is 0 - illegal. ");
        return FALSE;
    }

    if (NULL == buffer)
    {
        TRACE(TR_MOD_DND_AGENT, TR_SEV_ERR, "[L4DnDHndlr_PostMon]: Buffer is NULL - illegal. ");
        return FALSE;
    }

    //Check if this type is requested
    if (FALSE == L4DnDHndlr_IsMonFiltered(type))
    {
        TRACE(TR_MOD_DND_AGENT, TR_SEV_INFO, "[L4DnDHndlr_PostMon]: Type = %d isn't filtered on. Not reporting");
        return TRUE;
    }

    //Lock this part.
    OSAL_enter_critical_section(&csWriteProt);

    //Update the header with correct params
    UpdateHeader(monHeader, type, length);

    //Add message to queue
    res = AddMessageAndHeaderToQueue(monHeader, BM_L4DnDMonitorHeader_BYTES_SIZE, buffer, length);

    //Unlock
    OSAL_exit_critical_section(&csWriteProt);

    if (res != 0)
    {
        TRACE(TR_MOD_DND_AGENT, TR_SEV_INFO, "[L4DnDHndlr_PostMon]: Failed to add message to queue");
        return FALSE;
    }

    return TRUE;
}
bool EDetailManager::Initialize()
{
	if (m_SnapObjects.empty()){
    	ELog.DlgMsg(mtError,"Snap list empty!");
    	return false;
    }
	if (!m_Base.Valid()){
    	ELog.DlgMsg(mtError,"Base texture empty!");
    	return false;
    }				
    if (!UpdateHeader())                return false;
    m_Base.CreateRMFromObjects			(m_BBox,m_SnapObjects);
    if (!UpdateSlots()) 		   		return false;
    if (!objects.empty()&&!UpdateObjects(false,false))	return false;
	return true;
}
Beispiel #11
0
CPLErr GSAGDataset::SetGeoTransform( double *padfGeoTransform )
{
    if( eAccess == GA_ReadOnly )
    {
	CPLError( CE_Failure, CPLE_NoWriteAccess,
		  "Unable to set GeoTransform, dataset opened read only.\n" );
	return CE_Failure;
    }

    GSAGRasterBand *poGRB = (GSAGRasterBand *)GetRasterBand( 1 );

    if( poGRB == NULL || padfGeoTransform == NULL)
	return CE_Failure;

    /* non-zero transform 2 or 4 or negative 1 or 5 not supported natively */
    CPLErr eErr = CE_None;
    /*if( padfGeoTransform[2] != 0.0 || padfGeoTransform[4] != 0.0
	|| padfGeoTransform[1] < 0.0 || padfGeoTransform[5] < 0.0 )
	eErr = GDALPamDataset::SetGeoTransform( padfGeoTransform );*/

    if( eErr != CE_None )
	return eErr;

    double dfOldMinX = poGRB->dfMinX;
    double dfOldMaxX = poGRB->dfMaxX;
    double dfOldMinY = poGRB->dfMinY;
    double dfOldMaxY = poGRB->dfMaxY;

    poGRB->dfMinX = padfGeoTransform[0] + padfGeoTransform[1] / 2;
    poGRB->dfMaxX =
        padfGeoTransform[1] * (nRasterXSize - 0.5) + padfGeoTransform[0];
    poGRB->dfMinY =
        padfGeoTransform[5] * (nRasterYSize - 0.5) + padfGeoTransform[3];
    poGRB->dfMaxY = padfGeoTransform[3] + padfGeoTransform[5] / 2;

    eErr = UpdateHeader();

    if( eErr != CE_None )
    {
	poGRB->dfMinX = dfOldMinX;
	poGRB->dfMaxX = dfOldMaxX;
	poGRB->dfMinY = dfOldMinY;
	poGRB->dfMaxY = dfOldMaxY;
    }

    return eErr;
}
Beispiel #12
0
nsresult
LookupCache::WriteFile()
{
  nsCOMPtr<nsIFile> storeFile;
  nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
  NS_ENSURE_SUCCESS(rv, rv);
  rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIOutputStream> out;
  rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out), storeFile,
                                       PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE);
  NS_ENSURE_SUCCESS(rv, rv);

  UpdateHeader();
  LOG(("Writing %d completions", mHeader.numCompletions));

  uint32_t written;
  rv = out->Write(reinterpret_cast<char*>(&mHeader), sizeof(mHeader), &written);
  NS_ENSURE_SUCCESS(rv, rv);

  rv = WriteTArray(out, mCompletions);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsISafeOutputStream> safeOut = do_QueryInterface(out);
  rv = safeOut->Finish();
  NS_ENSURE_SUCCESS(rv, rv);

  rv = EnsureSizeConsistent();
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIFile> psFile;
  rv = mStoreDirectory->Clone(getter_AddRefs(psFile));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = psFile->AppendNative(mTableName + NS_LITERAL_CSTRING(PREFIXSET_SUFFIX));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = mPrefixSet->StoreToFile(psFile);
  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store the prefixset");

  return NS_OK;
}
Beispiel #13
0
//********************************************
// Alloc
//********************************************
int Texture::Alloc(unsigned int width, unsigned int height, unsigned int depth)
{
  Free();

  unsigned int Width32 = WidthByte32(width,depth);

  m_pData = new unsigned char [Width32 * height];
  if(m_pData == NULL)
  {
    return 0;
  }

  // Set members variables
  m_Width       = width;
  m_WidthByte32 = Width32;
  m_Height      = height;
  m_Depth       = depth;
  UpdateHeader();

  return 1;
}
void PictureTestWindow::BuildGUI()
{
	BView* backdrop = new BView(Bounds(), "backdrop", B_FOLLOW_ALL, B_WILL_DRAW);
	backdrop->SetViewColor(::ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(backdrop);
	
	BMenuBar* mb = new BMenuBar(Bounds(), "menubar");
	BMenu* m = new BMenu("File");
		m->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
		m->SetTargetForItems(be_app_messenger);
	mb->AddItem(m);

	m = new BMenu("Tests");
		m->AddItem(new BMenuItem("Run", new BMessage(kMsgRunTests), 'R'));
		m->AddItem(new BMenuItem("Run Color Space B_RGB32", new BMessage(kMsgRunTests1), 'S'));
	mb->AddItem(m);

	backdrop->AddChild(mb);

	BRect b = Bounds();
	b.top = mb->Bounds().bottom + 1;
	
	fHeader = new BStringView(b, "header", 
		"X", B_FOLLOW_LEFT | B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	float width, height;
	fHeader->GetPreferredSize(&width, &height);
	fHeader->ResizeTo(b.Width(), height);
	backdrop->AddChild(fHeader);
	b.top = fHeader->Frame().bottom + 1;
	
	b.right -= B_V_SCROLL_BAR_WIDTH;
	b.bottom -= B_H_SCROLL_BAR_HEIGHT;
	fListView = new BListView(b, "Results", B_SINGLE_SELECTION_LIST, 
		B_FOLLOW_ALL_SIDES, 
		B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE);
	backdrop->AddChild(new BScrollView("scroll_results", fListView, B_FOLLOW_ALL_SIDES, 0, true, true));	

	UpdateHeader();
}
void
PictureTestWindow::RunTests(color_space *colorSpaces, int32 n)
{
	for (int testIndex = 0; testIndex < 2; testIndex ++) {
		BString text;
		switch (testIndex)
		{
			case 0:
				text = "Flatten Picture Test";
				break;
			case 1:
				text = "Archive Picture Test";
				break;
			default:
				text = "Unknown test method!";
		}
		fListView->AddItem(new BStringItem(text.String()));
		RunTests(testIndex, colorSpaces, n);
	}
		
	UpdateHeader();
}
Beispiel #16
0
void
LookupCache::ClearCompleteCache()
{
  mCompletions.Clear();
  UpdateHeader();
}