Beispiel #1
0
LRESULT CAutoListMembersWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	long scrollposY; m_vert->get_pos(&scrollposY);

	POINT oldOrg;
	dc.SetViewportOrg(0, -scrollposY*16, &oldOrg);

	HFONT hOldFont = dc.SelectFont((HFONT)GetStockObject(DEFAULT_GUI_FONT));

	dc.SetBkMode(TRANSPARENT);

	int y = 0;

	for (int i = 0; i < m_members.GetSize(); i++)
	{
		CMemberItem* pMItem = m_members[i];

		CRect itemrect(0, y, m_areaRect.Width(), y+16);

		if (i == m_selectedIndex)
		{
			dc.FillSolidRect(&itemrect, GetSysColor(COLOR_HIGHLIGHT));
			dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
		}
		else
		{
			dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
		}

		ImageList_Draw(m_memberImageList, pMItem->m_type, dc.m_hDC, 0, y, ILD_NORMAL);

		CRect trect = itemrect;
		trect.left += 20;
		dc.DrawText(pMItem->m_name, pMItem->m_name.length(), &trect, DT_SINGLELINE | DT_VCENTER);

		y += 16;
	}

	dc.SelectFont(hOldFont);

	dc.SetViewportOrg(oldOrg.x, oldOrg.y);

	return 0;
}
Beispiel #2
0
LRESULT CMarkupBar::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	CRect client;
	GetClientRect(&client);

	CRect rect = client;
	//rect.top = rect.bottom-16-1;

// Draw white dividing line
	dc.FillSolidRect(0, rect.top, client.right, 1, GetSysColor(COLOR_3DHILIGHT));
	/*
	rect.right++;
	rect.bottom++;
	dc.Draw3dRect(&rect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
	*/
	rect.top += 1;
	//rect.InflateRect(-1,-1);
	dc.FillSolidRect(&rect, GetSysColor(COLOR_BTNFACE));

	HFONT hOldFont = dc.SelectStockFont(DEFAULT_GUI_FONT);

	dc.SetBkMode(TRANSPARENT);

	int x = 0;

	for (int i = 0; i < m_markupItems.GetSize(); i++)
	{
		CMarkupItem* pItem = m_markupItems[i];

		CRect itemrect(rect.left+x, rect.top, rect.left+x+pItem->m_width+4, rect.bottom);

		dc.DrawText(pItem->m_name, pItem->m_name.length(), &itemrect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		//dc.Draw3dRect(&itemrect, GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_3DSHADOW));

		x += itemrect.Width();
	}

	dc.SelectFont(hOldFont);

	return 0;
}
Beispiel #3
0
LRESULT CXMLKeyFrameValuesDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	HFONT hOldFont = dc.SelectFont((HFONT)GetStockObject(DEFAULT_GUI_FONT));

	dc.SetBkMode(TRANSPARENT);

	CRect client;
	GetClientRect(&client);

	int y = 0;

	for (int i = 0; i < m_controls.GetSize(); i++)
	{
		CControl* pControl = m_controls[i];

		if (pControl->m_bVisible)
		{
		//	CXMLAttribute* pAttr = pControl->m_pAttr;

			CRect itemrect(0, y, client.right, y+pControl->m_height);

			CRect trect = itemrect;
			trect.right = 80;

			dc.DrawText(pControl->m_name, pControl->m_name.GetLength(), &trect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);

			CRect vrect = itemrect;
			vrect.left = 82;

			pControl->Draw(dc.m_hDC, vrect);

			y += pControl->m_height;
			y += 1;	// Spacing
		}
	}

	dc.SelectFont(hOldFont);

	return 0;
}
Beispiel #4
0
void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
{
	ePtr<gFont> fnt;
	ePtr<gFont> fnt2;
	eRect itemrect(offset, m_itemsize);
	eListboxStyle *local_style = 0;
	bool cursorValid = this->cursorValid();
	gRGB border_color;
	int border_size = 0;

	painter.clip(itemrect);
	style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);

		/* get local listbox style, if present */
	if (m_listbox)
		local_style = m_listbox->getLocalStyle();

	if (local_style)
	{
		border_size = local_style->m_border_size;
		border_color = local_style->m_border_color;
		fnt = local_style->m_font;
		if (selected)
		{
			/* if we have a local background color set, use that. */
			if (local_style->m_background_color_selected_set)
				painter.setBackgroundColor(local_style->m_background_color_selected);
			/* same for foreground */
			if (local_style->m_foreground_color_selected_set)
				painter.setForegroundColor(local_style->m_foreground_color_selected);
		}
		else
		{
			/* if we have a local background color set, use that. */
			if (local_style->m_background_color_set)
				painter.setBackgroundColor(local_style->m_background_color);
			/* same for foreground */
			if (local_style->m_foreground_color_set)
				painter.setForegroundColor(local_style->m_foreground_color);
		}
	}

	if (fnt)
	{
		fnt2 = new gFont(fnt->family, fnt->pointSize - fnt->pointSize/5);
	}
	else
	{
		fnt = new gFont("Regular", 20);
		fnt2 = new gFont("Regular", 16);
	}

	if (!local_style || !local_style->m_transparent_background)
		/* if we have no transparent background */
	{
		/* blit background picture, if available (otherwise, clear only) */
		if (local_style && local_style->m_background && cursorValid)
			painter.blit(local_style->m_background, offset, eRect(), 0);
		else
			painter.clear();
	} else
	{
		if (local_style->m_background && cursorValid)
			painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST);
		else if (selected && !local_style->m_selection)
			painter.clear();
	}

	if (m_list && cursorValid)
	{
			/* get current list item */
		ePyObject item = PyList_GET_ITEM(m_list, m_cursor); // borrowed reference!
		ePyObject text, value;
		painter.setFont(fnt);
		int valueWidth(0);

		if (selected && local_style && local_style->m_selection)
			painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);

			/* the first tuple element is a string for the left side.
			   the second one will be called, and the result shall be an tuple.

			   of this tuple,
			   the first one is the type (string).
			   the second one is the value. */
		if (PyTuple_Check(item))
		{
				/* handle left part. get item from tuple, convert to string, display. */
			text = PyTuple_GET_ITEM(item, 0);
			text = PyObject_Str(text); /* creates a new object - old object was borrowed! */
			const char *configitemstring = (text && PyString_Check(text)) ? PyString_AsString(text) : "<not-a-string>";
			Py_XDECREF(text);
			eSize itemsize = eSize(m_itemsize.width()-10, m_itemsize.height());
			ePoint textoffset = ePoint(offset.x()+5, offset.y());

				/* when we have no label, align value to the left. (FIXME:
				   don't we want to specifiy this individually?) */
			int value_alignment_left = !*configitemstring;

				/* now, handle the value. get 2nd part from tuple*/
			if (PyTuple_Size(item) >= 2) // when no 2nd entry is in tuple this is a non selectable entry without config part
				value = PyTuple_GET_ITEM(item, 1);

			if (value)
			{
				ePyObject args = PyTuple_New(1);
				PyTuple_SET_ITEM(args, 0, PyInt_FromLong(selected));

					/* CallObject will call __call__ which should return the value tuple */
				value = PyObject_CallObject(value, args);

				if (PyErr_Occurred())
					PyErr_Print();

				Py_DECREF(args);
					/* the PyInt was stolen. */
			}

				/*  check if this is really a tuple */
			if (value && PyTuple_Check(value))
			{
					/* convert type to string */
				ePyObject type = PyTuple_GET_ITEM(value, 0);
				const char *atype = (type && PyString_Check(type)) ? PyString_AsString(type) : 0;

				if (atype)
				{
					if (!strcmp(atype, "text"))
					{
						ePyObject pvalue = PyTuple_GET_ITEM(value, 1);
						const char *value = (pvalue && PyString_Check(pvalue)) ? PyString_AsString(pvalue) : "<not-a-string>";
						eRect tmp = eRect(textoffset, itemsize);
						eTextPara *para = new eTextPara(tmp);
						para->setFont(fnt2);
						para->renderString(value);
						valueWidth = para->getBoundBox().width();

						painter.setFont(fnt2);
						painter.renderText(eRect(textoffset, itemsize), value, (value_alignment_left ?
							gPainter::RT_HALIGN_LEFT : gPainter::RT_HALIGN_RIGHT) |
							gPainter::RT_VALIGN_CENTER, border_color, border_size);

							/* pvalue is borrowed */
					} else if (!strcmp(atype, "slider"))
					{
						ePyObject pvalue = PyTuple_GET_ITEM(value, 1);
						ePyObject psize = PyTuple_GET_ITEM(value, 2);

							/* convert value to Long. fallback to -1 on error. */
						int value = (pvalue && PyInt_Check(pvalue)) ? PyInt_AsLong(pvalue) : -1;
						int size = (pvalue && PyInt_Check(psize)) ? PyInt_AsLong(psize) : 100;

							/* calc. slider length */
						valueWidth = (itemsize.width() - m_seperation) * value / size;
						int height = itemsize.height();

							/* draw slider */
						//painter.fill(eRect(offset.x() + m_seperation, offset.y(), width, height));
						//hack - make it customizable
						painter.fill(eRect(textoffset.x() + m_seperation, offset.y() + height/6, valueWidth, height*2/3));

							/* pvalue is borrowed */
					} else if (!strcmp(atype, "mtext"))
					{
						ePyObject pvalue = PyTuple_GET_ITEM(value, 1);
						const char *text = (pvalue && PyString_Check(pvalue)) ? PyString_AsString(pvalue) : "<not-a-string>";
						ePtr<eTextPara> para = new eTextPara(eRect(textoffset, itemsize));
						para->setFont(fnt2);
						para->renderString(text, gPainter::RT_VALIGN_CENTER);
						para->realign(value_alignment_left ? eTextPara::dirLeft : eTextPara::dirRight);
						int glyphs = para->size();

						ePyObject plist;

						if (PyTuple_Size(value) >= 3)
							plist = PyTuple_GET_ITEM(value, 2);

						int entries = 0;

						if (plist && PyList_Check(plist))
							entries = PyList_Size(plist);

						int left=0, right=0, last=-1;
						eRect bbox;
						for (int i = 0; i < entries; ++i)
						{
							ePyObject entry = PyList_GET_ITEM(plist, i);
							int num = PyInt_Check(entry) ? PyInt_AsLong(entry) : -1;

							if ((num < 0) || (num >= glyphs))
								eWarning("[eListboxPythonMultiContent] glyph index %d in PythonConfigList out of bounds!", num);
							else
							{
								if (last+1 != num && last != -1) {
									bbox = eRect(left, textoffset.y(), right-left,
										itemsize.height());
									painter.fill(bbox);
								}
								para->setGlyphFlag(num, GS_INVERT);
								bbox = para->getGlyphBBox(num);
								if (last+1 != num || last == -1)
									left = bbox.left();
								right = bbox.left() + bbox.width();
								last = num;
							}
							/* entry is borrowed */
						}
						if (last != -1) {
							bbox = eRect(left, textoffset.y(), right-left, itemsize.height());
							painter.fill(bbox);
						}
						painter.renderPara(para, ePoint(0, 0));
						/* pvalue is borrowed */
						/* plist is 0 or borrowed */
					}
				}
				/* type is borrowed */
			} else if (value)
				eWarning("[eListboxPythonConfigContent] second value of tuple is not a tuple.");
			if (value)
				Py_DECREF(value);

			valueWidth = valueWidth + 10;
			if (valueWidth > itemsize.width()) { valueWidth = itemsize.width(); }
			painter.setFont(fnt);
			painter.renderText(eRect(textoffset, eSize (itemsize.width()-valueWidth,itemsize.height())),
				configitemstring, gPainter::RT_HALIGN_LEFT | gPainter::RT_VALIGN_CENTER, border_color, border_size);
		}

		if (selected && (!local_style || !local_style->m_selection))
			style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
	}

	painter.clippop();
}
LRESULT CImageLayersDlg::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPoint point;
	point.x = (short)LOWORD(lParam);
	point.y = (short)HIWORD(lParam);

	CRect client;
	GetClientRect(&client);

	int m_itemHeight = 24;

	if (m_view)
	{
		CComPtr<IImageDocument> document;
		m_view->GetDocument(&document);

		int index = point.y / 24;

		CComPtr<IImageLayerGroup> layerGroup;
		document->GetImageLayerGroup(&layerGroup);

		long nsublayers;
		layerGroup->GetSubLayersCount(&nsublayers);

		if (index >= 0 && index < nsublayers)
		{
			CComPtr<IImageLayerUnknown> layer;
			layerGroup->GetSubLayer(index, &layer);

			//static_cast<CImageView*>(m_view.p)->m_pActiveLayer = layer;

			int y = index*m_itemHeight;

			CRect itemrect(0, y, client.right, y+m_itemHeight);

			CRect trect = itemrect;

			Gdiplus::Bitmap* pBitmap = static_cast<CImageLayerBitmap*>(layer.p)->m_pBitmap;
			if (pBitmap)
			{
				trect.left += 24;

				if (point.x < trect.left)
				{
					static_cast<CImageView*>(m_view.p)->m_pActiveBitmap = pBitmap;
					static_cast<CImageView*>(m_view.p)->m_pActiveGroup = static_cast<CImageLayerBitmap*>(layer.p)->m_group;
					return 0;
				}
			}

			Gdiplus::Bitmap* pBitmapMask = static_cast<CImageLayerBitmap*>(layer.p)->m_pBitmapMask;
			if (pBitmapMask)
			{
				trect.left += 24;

				if (point.x < trect.left)
				{
					static_cast<CImageView*>(m_view.p)->m_pActiveBitmap = pBitmapMask;
					static_cast<CImageView*>(m_view.p)->m_pActiveGroup = static_cast<CImageLayerBitmap*>(layer.p)->m_groupMask;
					return 0;
				}
			}
		}
	}

	return 0;
}
LRESULT CImageLayersDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	CRect client;
	GetClientRect(&client);

	int m_itemHeight = 24;

	if (m_view)
	{
		CComPtr<IImageDocument> document;
		m_view->GetDocument(&document);

		dc.SetBkMode(TRANSPARENT);

		CComPtr<IImageLayerGroup> layerGroup;
		document->GetImageLayerGroup(&layerGroup);

		long nsublayers;
		layerGroup->GetSubLayersCount(&nsublayers);

		int y = 0;

		for (int i = 0; i < nsublayers; i++)
		{
			CComPtr<IImageLayerUnknown> layer;
			layerGroup->GetSubLayer(i, &layer);

			CComBSTR name;
			layer->GetName(&name);

			CRect itemrect(0, y, client.right, y+m_itemHeight);

			CRect trect = itemrect;

			Gdiplus::Bitmap* pBitmap = static_cast<CImageLayerBitmap*>(layer.p)->m_pBitmap;
			if (pBitmap)
			{
				Gdiplus::Graphics graphics(dc.m_hDC);

				graphics.DrawImage(pBitmap,
					Gdiplus::Rect(trect.left, itemrect.top, 24, 24),
					0, 0, pBitmap->GetWidth(), pBitmap->GetHeight(),
					Gdiplus::UnitPixel);

				trect.left += 24;
			}

			Gdiplus::Bitmap* pBitmapMask = static_cast<CImageLayerBitmap*>(layer.p)->m_pBitmapMask;
			if (pBitmapMask)
			{
				Gdiplus::Graphics graphics(dc.m_hDC);

				graphics.DrawImage(pBitmapMask,
					Gdiplus::Rect(trect.left, itemrect.top, 24, 24),
					0, 0, pBitmapMask->GetWidth(), pBitmapMask->GetHeight(),
					Gdiplus::UnitPixel);

				trect.left += 24;
			}

			dc.DrawText(_bstr_t(name), name.Length(), &trect, DT_SINGLELINE | DT_VCENTER);

			y += m_itemHeight;
		}
	}

	return 0;
}
Beispiel #7
0
HRESULT CSwatchesList::OnDraw(ATL_DRAWINFO& di)
{
	RECT& rc = *(RECT*)di.prcBounds;
	HDC hDC = di.hdcDraw;

	if (m_swatches)
	{
		Draw3DRect(hDC, m_areaRect.left-1, m_areaRect.top-1, m_areaRect.Width()+2, m_areaRect.Height()+2, RGB(0,0,0), RGB(0,0,0));

		long scrollposY; m_vert->get_pos(&scrollposY);

		if (IntersectClipRect(hDC, m_areaRect.left, m_areaRect.top, m_areaRect.right, m_areaRect.bottom))
		{
			POINT oldOrg;
			SetViewportOrgEx(hDC, m_areaRect.left, m_areaRect.top - scrollposY, &oldOrg);
		// For CMYK conversion
			/*
			TCHAR colorDirectory[MAX_PATH];
			DWORD cbSize = sizeof(colorDirectory);
			GetColorDirectory(NULL, colorDirectory, &cbSize);

			HPROFILE hDestProfile = NULL;
			{
				TCHAR profilePath[MAX_PATH];
				_makepath(profilePath, NULL, colorDirectory, "sRGB Color Space Profile.ICM", NULL);

				PROFILE profile = {0};
				profile.dwType = PROFILE_FILENAME;
				profile.pProfileData = profilePath;
				profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR);
				hDestProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
				ATLASSERT(hDestProfile);
			}

			HPROFILE hTargetProfile = NULL;
			{
				TCHAR profilePath[MAX_PATH];
				_makepath(profilePath, NULL, colorDirectory, targetProfile, NULL);

				PROFILE profile = {0};
				profile.dwType = PROFILE_FILENAME;
				profile.pProfileData = profilePath;
				profile.cbDataSize = (_tcslen(profilePath)+1)*sizeof(TCHAR);
				hTargetProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);
				ATLASSERT(hTargetProfile);
			}

			LOGCOLORSPACE lcp = {0};
			lcp.lcsSignature = LCS_SIGNATURE;
			lcp.lcsVersion = 0x400;
			lcp.lcsSize = sizeof(lcp);
			lcp.lcsCSType = LCS_sRGB;
			lcp.lcsFilename;// = NULL; // ??

			HTRANSFORM hTransform = CreateColorTransform(&lcp, hDestProfile, hTargetProfile, BEST_MODE);
			ATLASSERT(hTransform);
			*/

		// Pattern for drawing ColorType symbols
			WORD bmdata[8] =
			{
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
				0xaaaa,
				0x5555,
			};

			HBITMAP hPatBitmap = CreateBitmap(8, 8, 1, 1, bmdata);
			ATLASSERT(hPatBitmap);

			HBRUSH hPatBrush = CreatePatternBrush(hPatBitmap);
			ATLASSERT(hPatBrush);
			DeleteObject(hPatBitmap);

		//
			HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

			LOGFONT lf;
			GetObject(hFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;

			HFONT hFontSelected = CreateFontIndirect(&lf);
			HFONT hOldFont = (HFONT)GetCurrentObject(hDC, OBJ_FONT);

			long nswatches;
			m_swatches->get_length(&nswatches);

			int y = 0;

			for (int i = 0; i < nswatches; i++)
			{
				CComPtr<IPDSwatch> swatch;
				m_swatches->item(i, &swatch);

				//Rectangle(hDC, itemrect.left, itemrect.top, itemrect.right+1, itemrect.bottom+1);
				MoveToEx(hDC, 0, y+m_itemHeight, NULL);
				LineTo(hDC, m_areaRect.Width()+1, y+m_itemHeight);

				CRect itemrect(0, y+1, m_areaRect.Width(), y+m_itemHeight-1);
	//			itemrect.top += 1;
	//			itemrect.bottom -= 1;

				bool bSelected = IsSwatchSelected(swatch);

				if (bSelected)
					FillSolidRect(hDC, itemrect.left, itemrect.top+1, itemrect.Width(), itemrect.Height()-1, (bSelected)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_WINDOW));

				int swatchSize = m_itemHeight-4;
				int swatchTop = (m_itemHeight-swatchSize)/2;
		//		CRect swatchRect(itemrect.left + 4, itemrect.top+itemrect.Height()/2-8, itemrect.left + 4 + 16, itemrect.top+itemrect.Height()/2-8+16);
				CRect swatchRect(itemrect.left + 4, itemrect.top+swatchTop, itemrect.left + 4 + swatchSize, itemrect.top+swatchTop+swatchSize);

				if (bSelected)
				{
					SelectObject(hDC, hFontSelected);
					SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
				}
				else
				{
					SelectObject(hDC, hFont);
					SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
				}

				SetBkMode(hDC, TRANSPARENT);

				BSTR bname;
				swatch->get_name(&bname);
				_bstr_t name = _bstr_t(bname, false);

				PDSwatchType swatchType;
				swatch->get_swatchType(&swatchType);

				CRect trect = itemrect;
				trect.left = swatchRect.right + 4;
				trect.right -= 30;

				if (swatchType == SWATCH_NONE)
				{
					FillSolidRect(hDC, &swatchRect, RGB(255, 255, 255));

					HPEN hPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
					HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

					MoveToEx(hDC, swatchRect.left+1, swatchRect.bottom-1, NULL);
					LineTo(hDC, swatchRect.right-1, swatchRect.top+1);

					SelectObject(hDC, hOldPen);
					DeleteObject(hPen);

					HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));
					Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom);
					SelectObject(hDC, hOldBrush);
				}
				else if (swatchType == SWATCH_COLOR ||
							swatchType == SWATCH_TINT)
				{
					CComPtr<IPDColor> color;
					CComQIPtr<IPDSwatchColor> swatchColor;

					if (swatchType == SWATCH_COLOR)
					{
						swatchColor = swatch;
						swatchColor->get_color(&color);
					}
					else
					{
						CComQIPtr<IPDSwatchTint> swatchTint = swatch;
						swatchTint->get_swatchColor(&swatchColor);

						swatchTint->get_finalColor(&color);

						CRect trect2 = trect;
						trect.right -= 28;
						trect2.left = trect.right;

						double tint;
						swatchTint->get_tint(&tint);

						CUString str;
						str.Format("%d %%", (int)(tint*100));

						DrawText(hDC, str, str.GetLength(), &trect2, DT_SINGLELINE | DT_VCENTER);
					}

					PDColorMode colorMode;
					color->get_colorMode(&colorMode);

					COLORREF clr;

					if (colorMode == COLORMODE_RGB)
					{
						double red; color->getChannel(0, &red);
						double green; color->getChannel(1, &green);
						double blue; color->getChannel(2, &blue);

						clr = RGB(red, green, blue);
					}
					else if (colorMode == COLORMODE_CMYK)
					{
	/*					if (hTransform)
						{
							double cyan; color->getChannel(0, &cyan);
							double magenta; color->getChannel(1, &magenta);
							double yellow; color->getChannel(2, &yellow);
							double black; color->getChannel(3, &black);

							COLOR incolor;
							incolor.cmyk.cyan = cyan*65535/255;
							incolor.cmyk.magenta = magenta*65535/255;
							incolor.cmyk.yellow = yellow*65535/255;
							incolor.cmyk.black = black*65535/255;

							COLOR outcolor;
							BOOL bSuccess = TranslateColors(hTransform, &incolor, 1, COLOR_CMYK, &outcolor, COLOR_RGB);
							ATLASSERT(bSuccess);

							clr = RGB(
								outcolor.rgb.red*255.0/65535,
								outcolor.rgb.green*255.0/65535,
								outcolor.rgb.blue*255.0/65535);
						}
						else
						*/
							clr = -1;
					}

					if (clr != -1)
					{
						HBRUSH hBrush = CreateSolidBrush(clr);
						HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

						Rectangle(hDC, swatchRect.left, swatchRect.top, swatchRect.right, swatchRect.bottom);

						SelectObject(hDC, hOldBrush);
						DeleteObject(hBrush);
					}

					{
						CRect rc(itemrect.right-15, itemrect.top+4, itemrect.right-15+10, itemrect.top+4+10);

						if (colorMode == COLORMODE_RGB)
						{
							Rectangle(hDC, rc.left, rc.top-1, rc.right+1, rc.bottom+1);

							FillSolidRect(hDC, rc.left+1, rc.top, 3, rc.Height(), RGB(255, 0, 0));
							FillSolidRect(hDC, rc.left+4, rc.top, 3, rc.Height(), RGB(0, 255, 0));
							FillSolidRect(hDC, rc.left+7, rc.top, 3, rc.Height(), RGB(0, 0, 255));
						}
						else if (colorMode == COLORMODE_CMYK)
						{
							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 255));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.top,
									rc.left+rc.Width(), rc.top,
									rc.left+rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 0));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.right, rc.top,
									rc.right, rc.top+rc.Height(),
									rc.right-rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.bottom,
									rc.left+rc.Width(), rc.bottom,
									rc.left+rc.Width()/2, rc.bottom-rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}

							//
							{
								HBRUSH hBrush = CreateSolidBrush(RGB(0, 255, 255));
								HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);

								POINT pts[3] =
								{
									rc.left, rc.top,
									rc.left, rc.top+rc.Height(),
									rc.left+rc.Width()/2, rc.top+rc.Height()/2,
								};

								Polygon(hDC, pts, 3);

								SelectObject(hDC, hOldBrush);
								DeleteObject(hBrush);
							}
						}
					}

					{
						CRect rc(m_areaRect.right-28, y+4, m_areaRect.right-28+10, y+4+10);

						PDColorType colorType;
						swatchColor->get_colorType(&colorType);

						int oldBkMode = SetBkMode(hDC, OPAQUE);
						COLORREF oldTextClr = SetTextColor(hDC, RGB(100,100,100));
						COLORREF oldBkClr = SetBkColor(hDC, RGB(255,255,255));

						if (colorType == COLORTYPE_PROCESS)
						{
							HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush);
							Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
							SelectObject(hDC, hOldBrush);
						}
						else if (colorType == COLORTYPE_SPOT)
						{
							Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);

							HPEN hPen = CreatePen(PS_SOLID, 1, RGB(120, 120, 120));
							HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, hPatBrush);
							HPEN hOldPen = (HPEN)SelectObject(hDC, hPen);

							Ellipse(hDC, rc.left+2, rc.top+2, rc.right-2, rc.bottom-2);

							SelectObject(hDC, hOldBrush);
							SelectObject(hDC, hOldPen);
							DeleteObject(hPen);
						}
						else
							ATLASSERT(0);

						SetBkMode(hDC, oldBkMode);
						SetTextColor(hDC, oldTextClr);
						SetBkColor(hDC, oldBkClr);
					}
				}
				else if (swatchType == SWATCH_GRADIENT)
				{
					Gdiplus::Graphics graphics(hDC);

					CComQIPtr<IPDSwatchGradient> swatchGradient = swatch;

					CComPtr<IPDGradient> gradient;
					swatchGradient->get_gradient(&gradient);

					PDGradientType gradientType;
					gradient->get_type(&gradientType);

					Gdiplus::Rect rc(swatchRect.left, swatchRect.top, swatchRect.Width(), swatchRect.Height());

					CArray<Gdiplus::REAL, Gdiplus::REAL> offsets;
					CArray<Gdiplus::Color,Gdiplus::Color&> colors;

					CreateGradient(offsets, colors, gradient);

					if (gradientType == GRADIENT_LINEAR)
					{
						Gdiplus::LinearGradientBrush brush(rc, Gdiplus::Color(0,0,0), Gdiplus::Color(0,0,0), Gdiplus::LinearGradientModeHorizontal);
						brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize());

						graphics.FillRectangle(&brush, rc);
					}
					else if (gradientType == GRADIENT_RADIAL)
					{
						Gdiplus::GraphicsPath path;
						path.AddEllipse(rc);

						Gdiplus::PathGradientBrush brush(&path);
						brush.SetInterpolationColors(colors.GetData(), offsets.GetData(), colors.GetSize());

						graphics.FillRectangle(&brush, rc);
					}
					else
						ATLASSERT(0);
				}
				else if (swatchType == SWATCH_PATTERN)
				{
					Gdiplus::Graphics graphics(hDC);

					CComQIPtr<IPDSwatchPattern> swatchPattern = swatch;

					CComPtr<IPDObjectGroup> objectGroup;
					swatchPattern->get_objectGroup(&objectGroup);

					RectD bbox;
					objectGroup->getExpandedBBox(&bbox);

					int width = swatchRect.Width();
					int height = (bbox.Height * width/bbox.Width);//+0.5;

					if (height > swatchRect.Height())
					{
						height = swatchRect.Height();
						width = (bbox.Width * height/bbox.Height);//+0.5;
					}
					ATLASSERT(width <= bbox.Width);

					double magnify = width/bbox.Width;

					int left = (swatchRect.Width()-width)/2;
					int top = (swatchRect.Height()-height)/2;

					CComPtr<IPDRenderer> renderer;
					renderer.CoCreateInstance(CLSID_PDRenderer);
					if (renderer)
					{
						Gdiplus::Bitmap bitmap(width, height);
						{
							Gdiplus::Graphics bmgraphics(&bitmap);
							bmgraphics.FillRectangle(&Gdiplus::SolidBrush(Gdiplus::Color(255, 255, 255)), 0, 0, width, height);

						//	Gdiplus::Graphics& bmgraphics = graphics;

						//	CComQIPtr<IPDObjectTransformable> transformable = objectGroup;
						//	RectD bounds;
						//	transformable->get_bounds(&bounds);

						//	bmgraphics.TranslateTransform(swatchRect.left+left, swatchRect.top+top);

							bmgraphics.ScaleTransform(magnify, magnify);
							bmgraphics.TranslateTransform(-bbox.X, -bbox.Y);
						//	bmgraphics.TranslateTransform(-bounds.X, -bounds.Y);

							renderer->put_magnify(magnify);
							renderer->put_targetHDC((HDC)&bmgraphics);

							renderer->RenderObject(objectGroup);
						}

						graphics.DrawImage(&bitmap, swatchRect.left+left, swatchRect.top+top);
					}
				}

				DrawText(hDC, name, name.length(), &trect, DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);

				y += m_itemHeight;
			}

			SelectObject(hDC, hOldFont);

			DeleteObject(hFontSelected);
			DeleteObject(hPatBrush);
	/*
			if (hTransform) DeleteColorTransform(hTransform);
			if (hDestProfile) CloseColorProfile(hDestProfile);
			*/

			SetViewportOrgEx(hDC, oldOrg.x, oldOrg.y, NULL);
		}
	}

	return S_OK;
}