Beispiel #1
0
void ColorAPI::remove(QString replace)
{
	if (ScCore->primaryMainWindow()->HaveDoc)
	{
		if (ScCore->primaryMainWindow()->doc->PageColors.contains(colorName) 
			&& (ScCore->primaryMainWindow()->doc->PageColors.contains(replace) 
				|| (replace == CommonStrings::None)))
		{
			ScCore->primaryMainWindow()->doc->PageColors.remove(colorName);
			ReplaceColor(colorName, replace);
		}
		else
		{
			RAISE("Color not found in document.");
			return;
		}
	}
	else
	{
		ColorList* colorList=PrefsManager::instance()->colorSetPtr();
		if (colorList->contains(colorName))
			colorList->remove(colorName);
		else
		{
			RAISE("Color not found in default colors");
			return;
		}
	}	
}
Beispiel #2
0
int imProcessHoughLinesDraw(const imImage* src_image, const imImage *hough, const imImage *hough_points, imImage *dst_image)
{
  int theta, line_count = 0;

  if (src_image != dst_image)
    imImageCopyData(src_image, dst_image);

  listnode* maxima = findMaxima(hough_points, &line_count, hough);

  ReplaceColor(dst_image);

  costab = (double*)malloc(180*sizeof(double));
  sintab = (double*)malloc(180*sizeof(double));

  for (theta=0; theta < 180; theta++)
  {
    double th = (M_PI*theta)/180.;
    costab[theta] = cos(th);
    sintab[theta] = sin(th);
  }

  DrawPoints(dst_image, maxima);

  free(costab); costab = NULL;
  free(sintab); sintab = NULL;

  return line_count;
}
Beispiel #3
0
// Handles clicking on different colors on the menu
void CNoteDlg::OnChangeBkgndColor(COLORREF clrColor)
{
	ATLASSERT(m_brBkgnd.m_hBrush);
	
	// Change the dialog's background color
	m_brBkgnd.DeleteObject();
	m_brBkgnd.CreateSolidBrush(clrColor);
	Invalidate();
	
	// Change the background color of the control displaying date and time
	m_wndStaticDateTime.ChangeBkgndColor(clrColor);
	
	// Change the background color of the edit control 
	m_wndEdit.ChangeBkgndColor(clrColor);

	// Change the background color of the 'Note' bitmap
	HBITMAP hBmpOldNote = m_wndStaticNote.GetBitmap();
	m_hBmpNote = NULL;
	m_hBmpNote = ReplaceColor(hBmpOldNote, GetNoteColor(), clrColor);

	// Change the background color of the 'Close' button
	m_wndBtnClose.SetColor(clrColor);

	// Change the background color of the 'Pin' bitmaps
	CImageList imageList = m_wndBtnPin.GetImageList();
	m_hBmpPinopen = ReplaceColor(m_hBmpPinopen, GetNoteColor(), clrColor);
	m_hBmpPinclose = ReplaceColor(m_hBmpPinclose, GetNoteColor(), clrColor);
	m_hBmpPinhoover = ReplaceColor(m_hBmpPinhoover, GetNoteColor(), clrColor);
	// Replace the images in the image list 
	imageList.Replace(0, m_hBmpPinopen, 0);
	imageList.Replace(1, m_hBmpPinclose, 0);
	imageList.Replace(2, m_hBmpPinhoover, 0);

	// Draw the new 'Note' bitmap in the static control
	m_wndStaticNote.SetBitmap(m_hBmpNote);

	// Delete the old bitmaps
	DeleteObject(hBmpOldNote);

	// Save the color
	SetNoteColor(clrColor);
}
Beispiel #4
0
void ColorAPI::replace(QString replace)
{
	if(replace.isEmpty())
	{
		RAISE("Cannot replace a color with an empty name.");
	}
	if (ScCore->primaryMainWindow()->doc->PageColors.contains(colorName) 
		&& (ScCore->primaryMainWindow()->doc->PageColors.contains(replace) 
			|| (replace == CommonStrings::None)))
		ReplaceColor(colorName, replace);
	else
	{
		RAISE("Color not found.");
	}
}
void StyleSheetLoader::UpdateStyleSheet(QWidget *widget) {
  QString filename(filenames_[widget]);

  // Load the file
  QFile file(filename);
  if (!file.open(QIODevice::ReadOnly)) {
    qLog(Warning) << "error opening" << filename;
    return;
  }
  QString contents(file.readAll());


  // Replace %palette-role with actual colours
  QPalette p(widget->palette());

  QColor alt = p.color(QPalette::AlternateBase);
  alt.setAlpha(50);
  contents.replace("%palette-alternate-base", QString("rgba(%1,%2,%3,%4%)")
      .arg(alt.red()).arg(alt.green()).arg(alt.blue()).arg(alt.alpha()));

  ReplaceColor(&contents, "Window", p, QPalette::Window);
  ReplaceColor(&contents, "Background", p, QPalette::Background);
  ReplaceColor(&contents, "WindowText", p, QPalette::WindowText);
  ReplaceColor(&contents, "Foreground", p, QPalette::Foreground);
  ReplaceColor(&contents, "Base", p, QPalette::Base);
  ReplaceColor(&contents, "AlternateBase", p, QPalette::AlternateBase);
  ReplaceColor(&contents, "ToolTipBase", p, QPalette::ToolTipBase);
  ReplaceColor(&contents, "ToolTipText", p, QPalette::ToolTipText);
  ReplaceColor(&contents, "Text", p, QPalette::Text);
  ReplaceColor(&contents, "Button", p, QPalette::Button);
  ReplaceColor(&contents, "ButtonText", p, QPalette::ButtonText);
  ReplaceColor(&contents, "BrightText", p, QPalette::BrightText);
  ReplaceColor(&contents, "Light", p, QPalette::Light);
  ReplaceColor(&contents, "Midlight", p, QPalette::Midlight);
  ReplaceColor(&contents, "Dark", p, QPalette::Dark);
  ReplaceColor(&contents, "Mid", p, QPalette::Mid);
  ReplaceColor(&contents, "Shadow", p, QPalette::Shadow);
  ReplaceColor(&contents, "Highlight", p, QPalette::Highlight);
  ReplaceColor(&contents, "HighlightedText", p, QPalette::HighlightedText);
  ReplaceColor(&contents, "Link", p, QPalette::Link);
  ReplaceColor(&contents, "LinkVisited", p, QPalette::LinkVisited);

#ifdef Q_OS_DARWIN
  contents.replace("darwin", "*");
#endif

  widget->setStyleSheet(contents);
}
Beispiel #6
0
// Create a font from a bitmapped font sheet.
// sheet: a 8bpp (paletted) sheet to create the font from.
// fgindex: color index of foreground color of letters.
// color: the color you want the letters to be.
bool NXFont::InitBitmapChars(SDL_Surface *sheet, uint32_t fgcolor, uint32_t color)
{
Uint32 format = screen->Format()->format;
SDL_Rect srcrect, dstrect;
SDL_Surface *letter;
int x, y, i;

	SDL_PixelFormat* pxformat = SDL_AllocFormat(format);
	if (!pxformat)
	{
		staterr("InitBitmapChars: SDL_AllocFormat failed: %s", SDL_GetError());
		return 1;
	}

	// NULL out letters we don't have a character for
	memset(this->letters, 0, sizeof(this->letters));
	
	// change the color of the letters by messing with the palette on the sheet
	ReplaceColor(sheet, fgcolor, color);
	
	// start at the top of the letter sheet.
	x = 0;
	y = 0;
	for(i=0;bitmap_map[i];i++)
	{
		uint8_t ch = bitmap_map[i];
		//stat("copying letter %d: '%c' from [%d,%d]", i, ch, x, y);
		
		// make character surface one pixel larger than the actual char so that there
		// is some space between letters in autospaced text such as on the menus.
		letter = SDL_CreateRGBSurface(0, \
							BITMAP_CHAR_WIDTH+1, BITMAP_CHAR_HEIGHT+1,
							pxformat->BitsPerPixel, \
							pxformat->Rmask, pxformat->Gmask,
							pxformat->Bmask, pxformat->Amask);
		if (!letter)
		{
			staterr("InitBitmapChars: failed to create surface for character %d/%d", i, ch);
			SDL_FreeFormat(pxformat);
			return 1;
		}
		
		SDL_FillRect(letter, NULL, SDL_MapRGB(pxformat, 0, 0, 0));
		
		// copy letter off of sheet
		srcrect.x = x;
		srcrect.y = y;
		srcrect.w = BITMAP_CHAR_WIDTH;
		srcrect.h = BITMAP_CHAR_HEIGHT;
		
		dstrect.x = 0;
		dstrect.y = 0;
		
		SDL_BlitSurface(sheet, &srcrect, letter, &dstrect);
		
		// make background transparent and copy into final position
		SDL_SetColorKey(letter, SDL_TRUE, SDL_MapRGB(pxformat, 0, 0, 0));

		SDL_PixelFormat * format = screen->Format();
		letters[ch] = SDL_ConvertSurfaceFormat(letter, format->format, 0);
		
		SDL_FreeSurface(letter);
		// letters[ch] = letter;
		
		// advance to next position on sheet
		x += BITMAP_SPAC_WIDTH;
		if (x >= sheet->w)
		{
			x = 0;
			y += BITMAP_SPAC_HEIGHT;
		}
	}

	return 0;
}
Beispiel #7
0
void cImage::CreateMaskFromColor( const eeColorA& ColorKey, Uint8 Alpha ) {
	ReplaceColor( ColorKey, eeColorA( ColorKey.R(), ColorKey.G(), ColorKey.B(), Alpha ) );
}
Beispiel #8
0
LRESULT CNoteDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	BOOL bRet;
	HWND hWnd;
	DWORD dwStyle;

	// Create the brush 
	m_brBkgnd.CreateSolidBrush(GetNoteColor());
	
	// Set the sizing border width/height
	m_nSizeFrame = GetSystemMetrics(SM_CXSIZEFRAME);
	
	// Center the dialog on the screen
	CenterWindow();
	
	// Retrieve the coordinates of a dialog's client area
	CRect rectDlg; 
	GetClientRect(&rectDlg);
	
	// Subclass the static control displaying current date and time and 
	// attach it to the CStaticDateTime object
	bRet = m_wndStaticDateTime.SubclassWindow(GetDlgItem(IDC_STATIC_TIME));
	ATLASSERT(bRet);
	// Set the size and position of the control
	m_wndStaticDateTime.MoveWindow(5, rectDlg.Height() - 14, rectDlg.Width() / 2, 14);
	// Set the current date and time
	m_wndStaticDateTime.SetCurrentDateTime(GetTimestamp());
	// Set the background color
	m_wndStaticDateTime.SetBkgndColor(GetNoteColor());
	
	// Subclass the bar static control and attach it to the CGradientStatic object
	bRet = m_wndStaticBar.SubclassWindow(GetDlgItem(IDC_STATIC_BAR));
	ATLASSERT(bRet);
	// Set the size and position of the control
	m_wndStaticBar.MoveWindow(42, 2, rectDlg.Width() - 66, 16);
	// Change the font
	m_wndStaticBar.ChangeFont();
	// Set the note's title
	m_wndStaticBar.SetWindowText(GetNoteTitle().c_str());

	// Subclass the edit control and attach it to the CNoteEdit object
	bRet = m_wndEdit.SubclassWindow(GetDlgItem(IDC_EDIT));
	ATLASSERT(bRet);
	// Set the ENM_LINK mask for a rich edit control to receive 
	// EN_LINK notifications
	m_wndEdit.SetEventMask(ENM_LINK);		
	// Enable automatic detection of URLs by a rich edit control
	m_wndEdit.SetAutoURLDetect();
	// Set the edit control's background color
	m_wndEdit.SetBackgroundColor(GetNoteColor());
	// Sets the initial character formatting attributes
	m_wndEdit.SetDefaultFont();
	// Set the edit control's text
	if (GetNoteRTF().length() != 0)
		m_wndEdit.SetRTF(GetNoteRTF().c_str());
	else
		m_wndEdit.SetWindowText(GetNoteText().c_str());
	// Set the size and position of the control
	m_wndEdit.MoveWindow(5, 20, rectDlg.Width() - 10, rectDlg.Height() - 40);
	
	// Create the static control holding the 'Note' bitmap
	CRect rectStatic(1, 2, 17, 18);
	hWnd = m_wndStaticNote.Create(m_hWnd, rectStatic, NULL,
		WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE|SS_NOTIFY);
	ATLASSERT(hWnd);
	
	// Create the button with the 'Close' bitmap
	rectStatic.SetRect(rectDlg.right - 21, 1, rectDlg.right - 1, 20);
	hWnd = m_wndBtnClose.Create(m_hWnd, rectStatic, NULL, 0, 0);
	ATLASSERT(hWnd);

	m_hFontClose = ::CreateFont(15, 0, 0, 0, FW_SEMIBOLD, 0, 0, 0, 1, 0, 0, 4, 
					FF_DONTCARE, _T("Marlett"));
	ATLASSERT(m_hFontClose);
	m_wndBtnClose.SetFont(m_hFontClose);
	m_wndBtnClose.SetTextColor(BLACK);
	m_wndBtnClose.SetColor(GetNoteColor());
	m_wndBtnClose.SetWindowText((TCHAR*)"\x72");		// 'x' sign
	m_wndBtnClose.SetToolTipText(_T("Close the note"));

	// Create the button with the 'Pin' bitmap
	rectStatic.SetRect(19, 1, 39, 21);
	hWnd = m_wndBtnPin.Create(m_hWnd, rectStatic, NULL, 0, 0);
	ATLASSERT(hWnd);
	// Change the button extended style
	dwStyle = BMPBTN_AUTOSIZE | BMPBTN_AUTO3D_SINGLE | BMPBTN_HOVER | BTNEX_CHECKBUTTON;
	m_wndBtnPin.SetBitmapButtonExtendedStyle(dwStyle);

	// Load the 'Pinopen' bitmap from the application's resources
	HBITMAP hBmpTemp2 = ::LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_PINOPEN));
	ATLASSERT(hBmpTemp2);
	// Load the 'Pinclose' bitmap from the application's resources
	HBITMAP hBmpTemp3 = ::LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_PINCLOSE));
	ATLASSERT(hBmpTemp3);
	// Load the 'Pinhoover' bitmap from the application's resources
	HBITMAP hBmpTemp4 = ::LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_PINHOOVER));
	ATLASSERT(hBmpTemp4);
	
	// Replace the white background color with the saved or default (yellow) note's color
	m_hBmpPinopen = ReplaceColor(hBmpTemp2, WHITE, GetNoteColor());
	ATLASSERT(m_hBmpPinopen);
	// Replace the white background color with the saved or default (yellow) note's color
	m_hBmpPinclose = ReplaceColor(hBmpTemp3, WHITE, GetNoteColor());
	ATLASSERT(m_hBmpPinclose);
	// Replace the white background color with the saved or default (yellow) note's color
	m_hBmpPinhoover = ReplaceColor(hBmpTemp4, WHITE, GetNoteColor());
	ATLASSERT(m_hBmpPinhoover);
	
	// Create the pin button's imagelist
	m_wndBtnPin.m_ImageList.Create(20, 20, ILC_COLORDDB | ILC_MASK, 3, 1);
	// Add images to the image list.
	m_wndBtnPin.m_ImageList.Add(m_hBmpPinopen);
	m_wndBtnPin.m_ImageList.Add(m_hBmpPinclose);
	m_wndBtnPin.m_ImageList.Add(m_hBmpPinhoover);
	// Set normal, pressed and hover images
	m_wndBtnPin.SetImages(0, 1, 2);
	// ToolTip text
	m_wndBtnPin.SetToolTipText(_T("Keep the Note Visible"));

	// Load the 'Note' bitmap from the application's resources
	HBITMAP hBmpTemp1 = ::LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_NOTE));
	ATLASSERT(hBmpTemp1);

	// Replace the white background color with the saved or default (yellow) note's color
	m_hBmpNote = ReplaceColor(hBmpTemp1, WHITE, GetNoteColor());
	ATLASSERT(m_hBmpNote);

	// Delete the original bitmaps
	DeleteObject(hBmpTemp1);
	DeleteObject(hBmpTemp2);
	DeleteObject(hBmpTemp3);
	DeleteObject(hBmpTemp4);

	// Draw the 'Note' bitmap in the static control
	m_wndStaticNote.SetBitmap(m_hBmpNote);
	
	// To support a transparency try to get a SetLayeredWindowAttributes function address
	// and set WS_EX_LAYERED style
	HMODULE hUser32 = GetModuleHandle(_T("User32.dll"));
	if (hUser32)
	{
		m_pfSetLayeredWindowAttributes = 
			(PFUNCSETLAYEREDWINDOWATTR)::GetProcAddress(hUser32, "SetLayeredWindowAttributes");
		if (m_pfSetLayeredWindowAttributes)
		{
			::SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(GWL_EXSTYLE)^WS_EX_LAYERED);
			// After the SetWindowLong call, the layered window will not become visible 
			// until the SetLayeredWindowAttributes function has been called for this window
			m_pfSetLayeredWindowAttributes(m_hWnd, 0, (BYTE)255, LWA_ALPHA);

			// Set the transparency of the note dialog
			MakeTransparent(GetNoteAlpha());
		}
	}

	// Register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	return TRUE;
}