Ejemplo n.º 1
0
void SystemDraw::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
                                       const int *subpolygon_counts, int subpolygon_count_count,
                                       const int *disjunct_polygon_counts, int disjunct_polygon_count_count,
                                       Color color, int width, Color outline, uint64 pattern, Color doxor)
{
    GuiLock __;
    if(vertex_count == 0)
        return;
    bool is_xor = !IsNull(doxor);
    HDC hdc = GetHandle();
    if(pattern) {
        int old_rop = GetROP2(hdc);
        HGDIOBJ old_brush = GetCurrentObject(hdc, OBJ_BRUSH);
        word wpat[8] = {
            (byte)(pattern >> 56), (byte)(pattern >> 48), (byte)(pattern >> 40), (byte)(pattern >> 32),
            (byte)(pattern >> 24), (byte)(pattern >> 16), (byte)(pattern >> 8), (byte)(pattern >> 0),
        };
        HBITMAP bitmap = CreateBitmap(8, 8, 1, 1, wpat);
        HBRUSH brush = ::CreatePatternBrush(bitmap);
        COLORREF old_bk = GetBkColor(hdc);
        COLORREF old_fg = GetTextColor(hdc);
        if(!is_xor) {
            SetROP2(hdc, R2_MASKPEN);
            SelectObject(hdc, brush);
            SetTextColor(hdc, Black());
            SetBkColor(hdc, White());
            SetDrawPen(PEN_NULL, Black);
            DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                                   subpolygon_counts, subpolygon_count_count,
                                   disjunct_polygon_counts, disjunct_polygon_count_count);
            SetROP2(hdc, R2_MERGEPEN);
            SetTextColor(hdc, color);
            SetBkColor(hdc, Black());
        }
        else {
            SetROP2(hdc, R2_XORPEN);
            SetTextColor(hdc, COLORREF(color) ^ COLORREF(doxor));
            SelectObject(hdc, brush);
        }
        DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                               subpolygon_counts, subpolygon_count_count,
                               disjunct_polygon_counts, disjunct_polygon_count_count);
        SelectObject(hdc, old_brush);
        SetTextColor(hdc, old_fg);
        SetBkColor(hdc, old_bk);
        SetROP2(hdc, old_rop);
        DeleteObject(brush);
        DeleteObject(bitmap);
        if(!IsNull(outline)) {
            SetColor(Null);
            SetDrawPen(width, outline);
            ASSERT(sizeof(POINT) == sizeof(Point));
            DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                                   subpolygon_counts, subpolygon_count_count,
                                   disjunct_polygon_counts, disjunct_polygon_count_count);
        }
    }
    else { // simple fill
Ejemplo n.º 2
0
void Div(Painter& sw)
{
	sw.Character(100, 100, 'O', Arial(100))
	  .Character(100, 150, 'O', Arial(100))
	  .Fill(Black());
	sw.Translate(200, 0);
	sw.Character(100, 100, 'O', Arial(100))
	  .Div()
	  .Character(100, 150, 'O', Arial(100))
	  .Fill(Black());
}
Ejemplo n.º 3
0
void RGBACtrl::Paint(Draw& w)
{
	w.DrawRect(GetSize(), SColorFace);
	if(alpha.IsMask())
		return;
	for(int x = 0; x <= 18; x++)
		w.DrawRect(x * cbox.cx + cs.x, cs.y, 1, cbox.cy * 14, SColorText());
	int i = 0;
	int my = cs.y + 1;
	w.DrawRect(cs.x, cs.y + 14 * cbox.cy, cbox.cx * 18 + 1, 1, SColorText());
	Point pp = Null;
	for(int y = 0; y < 14; y++) {
		w.DrawRect(cs.x, my - 1, cbox.cx * 18 + 1, 1, SColorText());
		int mx = cs.x + 1;
		for(int x = 0; x < 18; x++) {
			Color c = GetColor(i++);
			w.DrawRect(mx, my, cbox.cx - 1, cbox.cy - 1, c);
			if(c == color)
				pp = Point(mx, my);
			mx += cbox.cx;
		}
		my += cbox.cy;
	}
	if(!IsNull(pp)) {
		Size isz = CtrlImg::wheel_cursor().GetSize();
		pp = pp + (cbox - isz) / 2;
		w.DrawImage(pp.x, pp.y, CtrlImg::wheel_cursor(),
		            Grayscale(color) < 120 ? White() : Black());
	}
}
Ejemplo n.º 4
0
Image LetterImg(char c, Font fnt)
{
	ImagePainter iw(128, 128);
	iw.DrawRect(0, 0, 128, 128, White());
	iw.DrawText(0, 0, &c, fnt, Black(), 1);
	return iw;
}
Ejemplo n.º 5
0
void OnPath(Painter& sw)
{
	sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue());
	for(int i = -1; i <= 16; i++) {
		sw.BeginOnPath(i / 15.0);
		sw.Move(0, -6).Line(6, 0).Line(0, 6).Close().Stroke(1, Black());
		sw.End();
	}
}
Ejemplo n.º 6
0
void LineEdit::LeftDrag(Point p, dword flags)
{
	int c = GetMousePos(p);
	int l, h;
	if(!HasCapture() && GetSelection(l, h) && c >= l && c < h) {
		WString sample = GetW(l, min(h - l, 3000));
		Size sz = StdSampleSize();
		ImageDraw iw(sz);
		iw.DrawRect(sz, Black());
		iw.Alpha().DrawRect(sz, Black());
		DrawTLText(iw.Alpha(), 0, 0, 9999, sample, font, White());
		NextUndo();
		if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE) {
			RemoveSelection();
			Action();
		}
	}
}
Ejemplo n.º 7
0
void GradientStop(Painter& sw)
{
	sw.Rectangle(20.5, 20.5, 500, 100)
	  .ColorStop(0.25, Green())
	  .ColorStop(0.5, Yellow())
	  .ColorStop(0.75, Gray())
	  .Fill(0, 0, Blue(), 500, 0, LtRed())
	  .Stroke(1, Black());
}
Ejemplo n.º 8
0
void OnTextPath(Painter& sw)
{
	sw.Text(50, 50, "Hello!", Roman(350)).Stroke(1, Black());
	for(int i = 0; i <= 100; i++) {
		sw.BeginOnPath(i / 100.0);
		sw.Move(0, -6).Line(6, 0).Line(0, 6).Fill(Red());
		sw.End();
	}
}
Ejemplo n.º 9
0
void SudokuSolverFrame::DrawBoardBackground(wxPaintDC &dc)
{
	unsigned int spSq = 0;
    unsigned int smallSide;
    unsigned int i,j;

    wxColour LGray;
    wxBrush LGrayBr;

    LGray.Set(210,210,210);
    LGrayBr.SetColour(LGray);

    wxSize sz = GameBoardPanel->GetClientSize();
    if (sz.x < sz.y)
        smallSide = sz.x;
    else
        smallSide = sz.y;

    spSq = smallSide / 9;
    smallSide -= 10;

        // Set the Brush and Pen to red
    dc.SetBrush( LGrayBr );
    dc.SetPen(*wxBLACK_PEN );
    // Draw rectangle 40 pixels wide and 40 high
    // with upper left corner at 10 , 10.

    for(i=0;i<9;i++)
        for(j=0;j<9;j++)
        {
            if(i == col && j == row)
                dc.SetBrush(*wxBLUE_BRUSH);
            else
                dc.SetBrush(LGrayBr);
            dc.DrawRectangle( 0 + spSq*i, 0 + spSq*j, spSq - 5, spSq - 5 );
        }

    wxColor Black(0,0,0);
    wxPen myBlackPen(Black,5,wxSOLID);
    dc.SetPen(myBlackPen);

    // Section Borders
    dc.DrawLine( 0, smallSide/3 - 2, smallSide, smallSide/3 - 2);
    dc.DrawLine( 0, smallSide*2/3 - 1, smallSide, smallSide*2/3 - 1);
    dc.DrawLine( smallSide/3 - 2, 0, smallSide/3 - 2, smallSide);
    dc.DrawLine( smallSide*2/3 - 1, 0, smallSide*2/3 - 1, smallSide);

    // Edge Borders
    dc.DrawLine( 0, 0, smallSide, 0);
    dc.DrawLine( 0, 0, 0, smallSide);
    dc.DrawLine( 0, smallSide, smallSide, smallSide);
    dc.DrawLine( smallSide, 0, smallSide, smallSide);

}
Ejemplo n.º 10
0
void MenuItemBase::PaintTopItem(Draw& w, int state) {
	Size sz = GetSize();
	if(GUI_GlobalStyle() >= GUISTYLE_XP) {
		bool opaque = InOpaqueBar();
		bool opaque2 = opaque || state;
		Color bg = SColorFace();
		if(opaque2)
			ChPaint(w, 0, 0, sz.cx, sz.cy, style->topitem[state]);
		else
		if(opaque)
			w.DrawRect(0, 0, sz.cx, sz.cy, bg);
		String text = GetText();
		Size isz = GetTextSize(text, StdFont());
		Color txt = opaque ? style->topitemtext[0] : GetLabelTextColor(this);
		Color hltxt = opaque2 ? style->topitemtext[state] : GetLabelTextColor(this);
		if(!opaque && state != 2) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience)]
			Color c = state == 1 ? SColorHighlight() : bg;
			int g = Grayscale(c);
			bool dark = IsDark(c);
			if(abs(g - Grayscale(txt)) < 70)
				txt = dark ? White() : Black();
			if(abs(g - Grayscale(hltxt)) < 70)
				hltxt = dark ? White() : Black();
		}
		DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), state,
		             txt, hltxt);
	}
	else {
		w.DrawRect(sz, SColorFace);
		static const ColorF b0[] = { (ColorF)1, SColorLight, SColorLight, SColorShadow, SColorShadow, };
		static const ColorF b1[] = { (ColorF)1, SColorShadow, SColorShadow, SColorLight, SColorLight, };
		String text = GetText();
		Size isz = GetTextSize(text, StdFont());
		DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), false,
		             SColorMenuText, SColorHighlightText);
		if(state)
			DrawBorder(w, 0, 0, sz.cx, sz.cy, state == 2 ? b1 : b0);
	}
}
Ejemplo n.º 11
0
void Path(Painter& sw)
{
	sw.Translate(52, 52);
	for(int i = 0; i < 2; i++) {
		sw.Rectangle(20, 20, 60, 60);
		sw.Move(0, 0);
		sw.Cubic(99, 0,  50, 50,  99, 99);
		sw.Cubic(0, 99,  50, 50,  0, 0);
		sw.EvenOdd(i).Fill(Green());
		sw.Stroke(1, Black());
		sw.Translate(120, 0);
	}
}
Ejemplo n.º 12
0
Player Player::OfGtpStream (istream& in) {
  string s;
  in >> s;
  if (!in) return Invalid ();
  if (s == "b" || s == "B" || s == "Black" || s == "BLACK "|| s == "black") { 
    return Black();
  }
  if (s == "w" || s == "W" || s == "White" || s == "WHITE "|| s == "white") {
    return White();
  }
  in.setstate (ios_base::badbit); // TODO undo read?
  return Invalid();
}
Ejemplo n.º 13
0
RGBACtrl::RGBACtrl()
{
	color = Black();
	BackPaint();
	Add(ramp);
	ramp <<= THISBACK(Ramp);
	Add(alpha);
	alpha <<= THISBACK(Alpha);
	text.SetFont(CourierZ(11));
	text.NoWantFocus();
	text.SetReadOnly();
	Add(text);
	SyncText();
}
Ejemplo n.º 14
0
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
                        const VectorMap<String, ClipData>& data)
{
	LLOG("------------------------------");
	LLOG("DoDragAndDrop " << fmts);
	TopWindow *w = GetTopWindow();
	if(!w || !w->top)
		return DND_NONE;
	int gdk_actions = 0;
	if(actions & DND_MOVE)
		gdk_actions |= GDK_ACTION_MOVE;
	if(actions & DND_COPY)
		gdk_actions |= GDK_ACTION_COPY;
	GtkTargetList *list = CreateTargetList(data);
	dnd_fmts.Clear();
	for(int i = 0; i < data.GetCount(); i++)
		AddFmt(list, data.GetKey(i), i);
	Vector<String> f = Split(fmts, ';');
	for(int i = 0; i < f.GetCount(); i++) {
		AddFmt(list, f[i], data.GetCount() + i);
		dnd_fmts.Add(f[i]);
	}
	dnd_source_data = &data;
	dnd_result = DND_NONE;
	dnd_source = this;
	if(IsNull(sample))
		dnd_icon = Null;
	else {
		Size sz = sample.GetSize();
		if(sz.cx > 128)
			sz.cx = 128;
		if(sz.cy > 128)
			sz.cy = 128;
		sz += 2;
		ImageDraw iw(sz);
		iw.DrawRect(sz, White());
		DrawFrame(iw, sz, Black());
		iw.DrawImage(1, 1, sz.cx, sz.cy, sample);
		ImageBuffer b(128, 128);
		dnd_icon = iw;
	}
	gtk_drag_begin(w->top->window, list, GdkDragAction(gdk_actions),
	               GetMouseLeft() ? 1 : GetMouseMiddle() ? 2 : 3, CurrentEvent.event);
	while(dnd_source && GetTopCtrls().GetCount())
		ProcessEvents();
	dnd_source_data = NULL;
	gtk_target_list_unref (list);
	LLOG("-------- DoDragAndDrop");
	return dnd_result;
}
Ejemplo n.º 15
0
/*******************************************************************************

  Function : DDV_DrawSequenceName()
  
  Purpose : draw the name of the sequence (left column of the DDV panel)
  
  Parameters : GrData; graphical data (font size, etc)
				ScaleStyle;style of the ParaG scale
				top, left; coord to start the draw
  
  Return value : none

*******************************************************************************/
static void  DDV_DrawSequenceName(UnDViewerGraphDataPtr GrData,ParaGPtr pgp,
	Int2 top,Int2 left,Int4 cur_row,Int4 CurEditRow,Int4 CurMasterRow)
{
SeqIdPtr  sip = NULL;
RecT      rc;
Int2      x,y,decal=1,size;/*text position/size*/
Char      szAccess[21];
BioseqPtr bsp;

	/*get a name*/	
    bsp = BioseqLockById(pgp->sip);
    if(bsp) {
        sip = SeqIdFindBestAccession(bsp->id);
        BioseqUnlock(bsp);
    }
	if (!sip)
		sip = SeqIdFindBest(pgp->sip, 0);
	SeqIdWrite(sip, szAccess,PRINTID_TEXTID_ACCESSION, 20);   

	/*compute position*/
	if (pgp->ScaleStyle==SCALE_POS_TOP) decal++;
	
	/*draw name*/
	size=StringWidth(szAccess);
	x=left/*-GrData->udv_scale.cxLeftScale*/-size;
	y=top+decal*GrData->udv_font.LineHeight;
	MoveTo(x,y);
	if (cur_row==CurEditRow){
		Magenta();
	}
	PaintString (szAccess);
	if (cur_row==CurMasterRow){
		Blue();
		MoveTo(x,y);
		LineTo(x+size,y);
	}
	/*draw a little box (for selection a full sequence)*/
	left+=GrData->udv_font.cxChar;
	top+=GrData->udv_font.cxChar/2;
	LoadRect(&rc,left,top,left+GrData->udv_font.cxChar,
		top+GrData->udv_font.cxChar);	
	Blue();
	PaintOval(&rc);
	Black();
}
Ejemplo n.º 16
0
void TextOnPath(Painter& sw)
{
	Font fnt = Roman(100);
	FontInfo fi = fnt.Info();
	double pos = 0;
	const char *s = "Hello world, this is text on path!";
	int l = GetTextSize(s, fnt).cx;
	double r = l / (2 * M_PI);
	sw.Circle(300, 300, r).Stroke(1, Red());
	while(*s) {
		double w = fi[*s];
		sw.BeginOnPath(pos + w / 2, true);
		sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt)
		  .Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue())
		  .Stroke(1, Black());
		sw.End();
		pos += w;
	}
}
Ejemplo n.º 17
0
void BigStroke(Painter& sw)
{
	int n = 0;
	double r = 400;
	int    i = 0;
	while(r > 5) {
		Pointf p = Polar(i * M_2PI / 400) * r + Pointf(400, 400);
		if(i)
			sw.Line(p);
		else
			sw.Move(p);
		sw.Line(Polar((i * M_2PI / 400 + M_2PI / 800)) * (r - 3) + Pointf(400, 400));
		n += 2;
		r = r - 0.01;
		i++;
	}
	sw.Stroke(1, Black());
	sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue());
}
Ejemplo n.º 18
0
//==============================================================================================
/*static*/ Color ConnState::ConvertStateToColor(EnumConnState enumConnState) {
	
	switch (enumConnState) {
		case NOCON_NEVER: return Gray();
		case NOCON_WASSUCC: return Green();
		case NOCON_WASFAIL: return Red();
		case NOCON_UNDEF: return LtGray();
		case NOCON_MISCONFIG: return Magenta();
		case CONNECTING_START: return LtYellow();
		case CONNECTING_YAWN: return Yellow();
		case CONNECTING_2NDTRY: return LtMagenta();
		case CONNECTING_3RDTRY: return White();
		case CONNECTING_TIMEOUT: return Cyan();
		case CON_SUCCEED: return LtGreen();
		case CON_FAIL: return LtRed();
		case CON_STALE: return LtBlue();
	}
	
	return Black();
}
Ejemplo n.º 19
0
void Big(Painter& sw)
{
	int n = 0;
	double sgn = 1;
	for(int r = 400; r > 5; r -= 3) {
		for(int i = 0; i < 400; i++) {
			Pointf p = Polar(sgn * i * M_2PI / 400) * r + Pointf(400, 400);
			if(i)
				sw.Line(p);
			else
				sw.Move(p);
			sw.Line(Polar(sgn * (i * M_2PI / 400 + M_2PI / 800)) * (r - 6) + Pointf(400, 400));
			n += 2;
		}
		sw.Close();
		sgn = -sgn;
	}
	sw.Fill(Black());
	sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue());
}
Ejemplo n.º 20
0
static void Paint3dPlinth(CDC* pDC, CRect *rect, BOOL Indent = TRUE)
// Paints a 3-D plinth rectangle. If Indent is TRUE, it is indented, else it
// is raised. Other 3-D effects are not supported
// NOTE that the rectangle is drawn around the OUTSIDE of the given rectangle
{
// **** If 3d look is turned off, then we need to select black for BOTH of these

	CPen Black(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));
	CPen White(PS_SOLID, 0, GetSysColor(COLOR_BTNHIGHLIGHT));

	CPen *OldPen = CHECKPEN(pDC->SelectObject((Indent) ? &White : &Black));

	pDC->MoveTo(rect->left, rect->bottom-1);
	pDC->LineTo(rect->left, rect->top);
	pDC->LineTo(rect->right-1, rect->top);

	CHECKPEN(pDC->SelectObject((Indent) ? &Black : &White));
	pDC->MoveTo(rect->right-1, rect->top+1);	// Ensure corner pixel is correct
	pDC->LineTo(rect->right-1, rect->bottom-1);
	pDC->LineTo(rect->left, rect->bottom-1);

	CHECKPEN(pDC->SelectObject(OldPen));
}
Ejemplo n.º 21
0
Image ProcessSHIcon(const SHFILEINFO& info)
{
	AvoidPaintingCheck__();
	Color c = White();
	Image m[2];
	for(int i = 0; i < 2; i++) {
		ICONINFO iconinfo;
		if(!info.hIcon || !GetIconInfo(info.hIcon, &iconinfo))
			return Image();
		BITMAP bm;
		::GetObject((HGDIOBJ)iconinfo.hbmMask, sizeof(BITMAP), (LPVOID)&bm);
		Size sz(bm.bmWidth, bm.bmHeight);
		ImageDraw iw(sz);
		iw.DrawRect(sz, c);
		::DrawIconEx(iw.GetHandle(), 0, 0, info.hIcon, 0, 0, 0, NULL, DI_NORMAL|DI_COMPAT);
		::DeleteObject(iconinfo.hbmColor);
		::DeleteObject(iconinfo.hbmMask);
		c = Black();
		m[i] = iw;
	}
	::DestroyIcon(info.hIcon);
	return RecreateAlpha(m[0], m[1]);
}
Ejemplo n.º 22
0
void TrackerThread::calcBlobs(BitmapPtr pTrackBmp, BitmapPtr pTouchBmp, long long time) 
{
    BlobVectorPtr pTrackComps;
    BlobVectorPtr pTouchComps;
    {
        ScopeTimer timer(ProfilingZoneComps);
        boost::mutex::scoped_lock lock(*m_pMutex);
        BitmapPtr pDestBmp;
        if (m_bCreateFingerImage) {
            Pixel32 Black(0x00, 0x00, 0x00, 0x00);
            FilterFill<Pixel32>(Black).applyInPlace(
                    m_pBitmaps[TRACKER_IMG_FINGERS]);
            pDestBmp = m_pBitmaps[TRACKER_IMG_FINGERS];
        }
        {
            if (m_TrackThreshold != 0) {
                pTrackComps = findConnectedComponents(pTrackBmp, m_TrackThreshold);
                calcContours(pTrackComps);
                drawBlobs(pTrackComps, pTrackBmp, pDestBmp, m_TrackThreshold, false);
                pTrackComps = findRelevantBlobs(pTrackComps, false);
            }
            if (m_TouchThreshold != 0) {
                pTouchComps = findConnectedComponents(pTouchBmp, m_TouchThreshold);
                pTouchComps = findRelevantBlobs(pTouchComps, true);
                correlateHands(pTrackComps, pTouchComps);
                drawBlobs(pTouchComps, pTouchBmp, pDestBmp, m_TouchThreshold, true);
            }
        }
        // Send the blobs to the BlobTarget.
        {
            ScopeTimer timer(ProfilingZoneUpdate);
            m_pTarget->update(pTrackComps, pTouchComps, time);
        }
    }
    
}
Ejemplo n.º 23
0
void RulerCtrl::Paint(Draw& draw)
{
	Size client = GetSize();
	int csize = is_vert ? client.cy : client.cx;
	int cheight = is_vert ? client.cx : client.cy;
	Rect clip = GetSize();
	int cy = font.Info().GetHeight();
	double pos1 = FromClient(0);
	double pos2 = FromClient(csize);
	if(pos1 > pos2)
		Swap(pos1, pos2);
	double lrange = min_range, rrange = max_range;
	if(!IsNull(min_range) && pos1 < min_range) pos1 = min_range;
	if(!IsNull(max_range) && pos2 > max_range) pos2 = max_range;
	int cli1 = 0, cli2 = csize;
	if(scale < 0)
		Swap(lrange, rrange);
	if(!IsNull(lrange))
		cli1 = max<int>(cli1, ToClient(lrange));
	if(!IsNull(rrange))
		cli2 = min<int>(cli2, ToClient(rrange));
	Rect nclip;
	if(is_vert) {
		draw.DrawRect(0, 0, client.cx, cli1, outer_color);
		if(!IsNull(lrange))
			draw.DrawRect(0, cli1++, client.cx, 1, SBlack);
		draw.DrawRect(0, cli2, client.cx, client.cy - cli2, outer_color);
		if(!IsNull(rrange))
			draw.DrawRect(0, --cli2, client.cx, 1, SBlack);
		draw.DrawRect(0, cli1, 1, cli2 - cli1, SGray);
//		draw.DrawRect(0, cli1, 1, cli2 - cli1, SBlack);
		draw.DrawRect(client.cx - 1, cli1, 1, cli2 - cli1, SBlack);
		nclip = RectC(1, cli1, client.cx - 2, cli2 - cli1);
	}
	else {
		draw.DrawRect(0, 0, cli1, client.cy, outer_color);
		if(!IsNull(lrange))
			draw.DrawRect(cli1++, 0, 1, client.cy, SBlack);
		draw.DrawRect(cli2, 0, client.cx - cli2, client.cy, outer_color);
		if(!IsNull(rrange))
			draw.DrawRect(--cli2, 0, 1, client.cy, SBlack);
		draw.DrawRect(cli1, 0, cli2 - cli1, 1, SGray);
		draw.DrawRect(cli1, client.cy - 1, cli2 - cli1, 1, SBlack);
		nclip = RectC(cli1, 1, cli2 - cli1, client.cy - 2);
	}
	draw.DrawRect(nclip, background);
	draw.Clip(nclip);

	enum {
		SMALL_LIMIT = 100,
//		TEXT_LIMIT = 50,
		TGAP = 3,
		HGAP = 2,
		VGAP = 0,
		HXGAP = 3,
		VXGAP = 2,
		SMALL_SIZE = 5,
	};

	double rep_count = 1;
	double rep_delta = 0;
	if(!IsNull(small_repeat)) {
		rep_delta = small_repeat * floor(pos1 / small_repeat);
		rep_count = ceil(pos2 / small_repeat) - floor(pos1 / small_repeat);
	}
	if(!small_step.IsEmpty() && rep_count > 0
	&& rep_count * small_step.GetCount() <= cli2 - cli1) {
		int ix = BinFindIndex(small_step, pos1 - rep_delta);
		int ppos = (is_right ? 0 : cheight - SMALL_SIZE);
		for(int c = fround(rep_count); --c >= 0; ix = 0, rep_delta += small_repeat) {
			int lim = small_step.GetCount();
			if(small_step.Top() > pos2 - rep_delta)
				lim = BinFindIndex(small_step, pos2 - rep_delta);
			for(; ix < lim; ix++) {
				int cli = ToClient(small_step[ix] + rep_delta);
				if(is_vert)
					draw.DrawRect(ppos, cli, SMALL_SIZE, 1, Gray());
				else
					draw.DrawRect(cli, ppos, 1, SMALL_SIZE, Gray());
			}
		}
	}
	rep_count = 1;
	double rep_index = 0;
	if(!IsNull(text_repeat)) {
		rep_index = floor(pos1 / text_repeat);
		rep_count = ceil(pos2 / text_repeat) - floor(pos1 / text_repeat) + 1;
	}
	if(!text_step.IsEmpty() && (!text_value.IsEmpty() || text_convert)
	&& rep_count > 0 /*&& rep_count * text_step.GetCount() <= TEXT_LIMIT*/) {
		int ix = BinFindIndex(text_step, pos1 - rep_index * text_repeat);
		int ppos = (is_right ? SMALL_SIZE : cheight - cy - SMALL_SIZE);
		int rpos = (is_right ? 0 : cheight - SMALL_SIZE - 1);
		for(int c = fround(rep_count); --c >= 0; ix = 0, rep_index++) {
			int lim = text_step.GetCount();
			double dp2 = pos2 - rep_index * text_repeat;
			if(text_step.Top() > dp2) {
				lim = BinFindIndex(text_step, dp2);
				if(lim + 1 < text_step.GetCount() && text_step[lim + 1] - dp2 < dp2 - text_step[lim])
					lim++;
			}
			for(; ix < lim; ix++) {
				double value = text_step[ix] + rep_index * text_repeat;
				int cli = ToClient(value);
				String text;
				if(ix < text_value.GetCount())
					text = text_value[ix];
				else if(text_convert)
					text = StdFormat(text_convert -> Format(value));
				else
					text = StdFormat(value);
				Size tsize = GetTextSize(text, font);
				int half = tsize.cx >> 1;
				if(is_vert) {
					draw.DrawRect(0, cli, ppos, 1, Black());
					draw.DrawRect(rpos, cli, SMALL_SIZE + 1, 1, Black());
//					draw.DrawRect(ppos - VGAP, cli - half - HGAP, tsize.cy + 2 * VGAP, tsize.cx + 2 * HGAP, background);
					draw.DrawText(ppos, cli + half, 900, text, font, Gray());
				}
				else {
					draw.DrawRect(cli, 0, 1, ppos, Black());
					draw.DrawRect(cli, rpos, 1, SMALL_SIZE + 1, Black());
//					draw.DrawRect(cli - half - HGAP, ppos - VGAP, tsize.cx + 2 * HGAP, tsize.cy + 2 * VGAP, background);
					draw.DrawText(cli - half, ppos, text, font, Gray());
				}
			}
		}
	}
Ejemplo n.º 24
0
void FormView::DrawObject(Draw& w, int id, const Color& c, bool springs)
{
	if (!IsLayout())
		return;

	FormObject *pI = GetObject(id);
	if (!pI) return;

	Rect offseted = Offseted(pI->GetRect());
	offseted = Zoom(offseted);

	if (_showInfo == 2)	
		w.DrawRect(offseted, c);

	String type = pI->Get("Type");
	if (type == "Label")
		DrawRect(w, offseted.Offseted(-1, 0), 1, LtGray());

	if (pI->IsSelected() && springs)
	{
		DrawSprings(w, offseted, pI->GetHAlign(), pI->GetVAlign());
		w.DrawImage(offseted.right, offseted.bottom, FormViewImg::SizerBR());
		DrawRect(w, offseted, 1, LtRed());
	}
	else if (pI->IsSelected() && !springs)
		DrawRect(w, Point(offseted.left, offseted.top),
			Size(offseted.Width(), offseted.Height()), 1, LtRed());
	else if (_showInfo == 2 || pI->GetBool("OutlineDraw"))
		DrawRect(w, offseted, 1, Black());

	if (pI->GetBool("OutlineDraw"))
	{
		Rect l = offseted.Offseted( ZoomX(3), ZoomY(3) );
		l = Rect( l.TopLeft(), l.GetSize() - Size(ZoomX(6), ZoomY(6)) );
		DrawRect(w, l, 1, LtCyan());
	}

	String temp = pI->Get("Variable");
	Size t = GetTextSize( temp, _Font );
	int cx = t.cx;

	int y = offseted.BottomCenter().y - t.cy - ZoomY(3);

	if (_showInfo > 0)
	{
		if (offseted.Width() > t.cx + 15)
		{
			int x1 = ZoomX(pI->GetRect().right) - DeZoomX(2) - 4 - t.cx + ZoomX(X(0));
			w.DrawRect( x1 - 2, y, t.cx + 3, t.cy, White());
//			DrawRect(w, Point(x1 - 2, y), Size(t.cx + 3, t.cy), 1, LtGray());
			w.DrawText( x1, y, temp, _Font, LtBlue);
		}

		temp = AsString(id) + " " + type;
		t = GetTextSize(temp, _Font);
		Size s = GetTextSize(AsString(id), _Font);

		if (offseted.Width() - cx > t.cx + 10)
		{
			w.DrawRect( offseted.left + ZoomX(5) - 2, y, t.cx + 3, t.cy, White());
//			DrawRect(w, Point(offseted.left + ZoomX(5) - 2, y), Size(t.cx + 3, t.cy),
//				1, LtGray());
			w.DrawText( offseted.left + ZoomX(5), y, temp, _Font, Gray());
		}
		else if (offseted.Width() > s.cx + 5)
		{
			w.DrawRect( offseted.left + ZoomX(5) - 2, y, s.cx + 3, s.cy, White());
//			DrawRect(w, Point(offseted.left + ZoomX(5) - 2, y), Size(s.cx + 3, s.cy),
//				1, LtGray());
			w.DrawText( offseted.left + ZoomX(5), y, AsString(id), _Font, Gray());
		}
	}
}
Ejemplo n.º 25
0
float Player::SubjectiveScore (const float& score) const {
  NatMap <Player, float> tab (0.0);
  tab[Black()] = score;
  tab[White()] = - score;
  return tab [*this];
}
Ejemplo n.º 26
0
string Player::ToGtpString () const {
  NatMap <Player, string> gtp_string ("");
  gtp_string [Black()] = "B";
  gtp_string [White()] = "W";
  return gtp_string [*this];
}
Ejemplo n.º 27
0
void CGuiTabWnd::Drawtabs(CDC* dc)
{
	CPen light(PS_SOLID,1,GetSysColor(COLOR_BTNHIGHLIGHT));
	CPen Dark(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
	CPen Black(PS_SOLID,1,GetSysColor(BLACK_PEN));	
	CRect rectText;
	CFont* m_fontOld=dc->SelectObject(&m_cfont);
	for (int iCont=0; iCont< m_Numtabs;iCont++)
	{
		CGuiTab* ct=(CGuiTab*) m_pArray[iCont];
		CPen* oldPen= dc->SelectObject(&light);
		//si es la carpeta seleccionada, se debe 
		//eliminar las lineas oscuras de encima
		if (iCont ==m_iSelectTab)
		{
			CBrush cbr;
			CRect  m_rectTabAux=ct->rect;
			m_rectTabAux.DeflateRect(1,1);
			m_rectTabAux.top-=4;	
			m_rectTabAux.bottom=m_rectTabAux.top+4;
			cbr.CreateSysColorBrush(COLOR_BTNFACE);
			
			dc->FillRect(ct->rect,&cbr);
			dc->MoveTo(ct->rect.left,ct->rect.top-3);
			dc->LineTo(ct->rect.left,ct->rect.bottom-1);
			dc->FillRect(m_rectTabAux,&cbr);

			dc->SelectStockObject(BLACK_PEN);
			dc->MoveTo(ct->rect.left,ct->rect.bottom-1);
			dc->LineTo(ct->rect.right,ct->rect.bottom-1);
			
			//linea derecha observe que se pinta dos veces para
			//dar el efecto de redondeada en la puntas

			dc->SelectStockObject(BLACK_PEN);
			dc->MoveTo(ct->rect.right-1,ct->rect.top-1);
			dc->LineTo(ct->rect.right-1,ct->rect.bottom-1);

		}
		else
		{
			if ((iCont+1) != m_iSelectTab)
			{
				dc->SelectObject(&Dark);
				dc->MoveTo(ct->rect.right-1,ct->rect.top+2);
				dc->LineTo(ct->rect.right-1,ct->rect.bottom-2);
			}
				
			
		}
		//se dibuja el icono
		int nMode = dc->SetBkMode(TRANSPARENT);
		CSize m_sChar=dc->GetTextExtent(ct->lpMsg,strlen(ct->lpMsg));
		if (m_sizeImag.cx+m_sChar.cx < ct->rect.Width()-8)  
		{
			Image.Draw(dc,ct->uIcon,CPoint(ct->rect.left+2,ct->rect.top+2),ILD_TRANSPARENT);
			rectText=ct->rect;
			rectText.left+=m_sizeImag.cx+8;
			rectText.right-=2;
			dc->DrawText(ct->lpMsg,rectText,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
			CToolTip.SetToolRect(this,iCont+1,CRect(0,0,0,0));
		}
		else
		{
			//verificamos si se puede poner algun texto o
			//por lo memos el icono
			if (m_sizeImag.cx < ct->rect.Width())
			{
				Image.Draw(dc,ct->uIcon,CPoint(ct->rect.left+2,ct->rect.top+2),ILD_TRANSPARENT);
				rectText=ct->rect;
				rectText.left+=m_sizeImag.cx+8;
				rectText.right-=5;
				CString m_cadBreak=ct->lpMsg;
				int c=0;
				int cont=m_cadBreak.GetLength();
				while(cont > 1 )
				{
					CString m_scadtemp=m_cadBreak+"...";
					CSize coor=dc->GetTextExtent(m_scadtemp,m_scadtemp.GetLength());
					if(coor.cx > rectText.Width())
						m_cadBreak=m_cadBreak.Left(m_cadBreak.GetLength()-1);
					else
						break;
					cont--;

				}
				m_cadBreak+=_T("...");
				rectText.right+=3;
				dc->DrawText(m_cadBreak,rectText,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
				CToolTip.SetToolRect(this,iCont+1,&ct->rect);
			}
			
		}
		dc->SetBkMode(nMode);
		
		// Modified By SunZhenyu
		dc->SelectObject(oldPen);
	}	
	
	dc->SelectObject(m_fontOld);
}
Ejemplo n.º 28
0
void DrawPolyPolyPolygon(Draw& draw, const Point *vertices, int vertex_count,
	const int *subpolygon_counts, int subpolygon_count_count,
	const int *disjunct_polygon_counts, int disjunct_polygon_count_count,
	Color color, int width, Color outline, uint64 pattern, Color doxor)
{
	if(vertex_count == 0)
		return;

#ifdef PLATFORM_WIN32_ //!!TODO
	if(PdfDraw *pdf = dynamic_cast<PdfDraw *>(&draw)) {
		pdf->DrawPolyPolyPolygon(vertices, vertex_count, subpolygon_counts, subpolygon_count_count,
			disjunct_polygon_counts, disjunct_polygon_count_count, color, width, outline, pattern, doxor);
		return;
	}
#endif

//	LOG("DrawPolyPolyPolygon: drawing = " << (draw.IsDrawing() ? "yes" : "no")
//		<< ", backdraw = " << (draw.IsBack() ? "yes" : "no")
//		<< ", " << (draw.Dots() ? "dots" : "pixels")
//		<< ", printer = " << (draw.IsPrinter() ? "yes" : "no"));
//	LOG("#vertices = " << vertex_count << ", #subpolygons = " << subpolygon_count_count
//	<< ", #disjunct polygons = " << disjunct_polygon_count_count);
//	LOG("color = " << Dump(color) << ", width = " << width << ", outline = " << Dump(outline)
//	<< ", pattern = " << Dump(pattern) << ", doxor = " << doxor);

#ifdef _DEBUG
//	for(int v = 0; v < vertex_count; v++)
//		if(abs2(vertices[v] - vertices[(v ? v : vertex_count) - 1]) >= 500 * 500)
//			NEVER();
#endif

	if(!dynamic_cast<SystemDraw *>(&draw)) {
		draw.DrawPolyPolyPolygon(vertices, vertex_count,
			subpolygon_counts, subpolygon_count_count,
			disjunct_polygon_counts, disjunct_polygon_count_count,
			color, width, outline, pattern, doxor);
		return;
	}

//	TIMING("DrawPolyPolygon/hdc");
	bool is_xor = !IsNull(doxor);

#ifdef PLATFORM_X11
	unsigned xor_pixel = (is_xor ? GetXPixel(doxor) : 0);
	XGCValues gcv;
	gcv.function = is_xor ? X11_ROP2_XOR : X11_ROP2_COPY;
	GC fill_gc = NULL;
	Image pattern_image;
	if(!IsNull(color)) {
		gcv.foreground = GetXPixel(color) ^ xor_pixel;
		int fmask = GCForeground | GCFunction;
		if(pattern) {
			pattern_image = GetPatternImage(pattern);
			gcv.stipple = pattern_image.GetMaskPixmap();
			gcv.fill_style = FillStippled;
			fmask |= GCStipple | GCFillStyle;
		}
		fill_gc = XCreateGC(Xdisplay, draw.GetDrawable(), fmask, &gcv);
	}
	GC line_gc = NULL;
	if(!IsNull(outline)) {
		gcv.foreground = GetXPixel(outline) ^ xor_pixel;
		gcv.line_width = width;
		line_gc = XCreateGC(Xdisplay, draw.GetDrawable(), GCForeground | GCFunction | GCLineWidth, &gcv);
		Point offset = draw.GetOffset();
	}
#endif

	for(int i = 0; i < disjunct_polygon_count_count; i++, disjunct_polygon_counts++) {
		int poly = *disjunct_polygon_counts;
		int sub = 1;
		if(*subpolygon_counts < poly)
			if(disjunct_polygon_count_count > 1) {
				const int *se = subpolygon_counts;
				int total = 0;
				while(total < poly)
					total += *se++;
				sub = se - subpolygon_counts;
			}
			else
				sub = subpolygon_count_count;

		if(sub > poly) {
			vertices += poly;
			subpolygon_counts += sub;
			continue;
		}


#if defined(PLATFORM_WIN32)
	#ifdef SYSTEMDRAW
		SystemDraw *w = dynamic_cast<SystemDraw *>(&draw);
		if(w) { SystemDraw& draw = *w;
	#endif
		if(pattern) {
			int old_rop = GetROP2(draw);
			HGDIOBJ old_brush = GetCurrentObject(draw, OBJ_BRUSH);
			word wpat[8] = {
				(byte)(pattern >> 56), (byte)(pattern >> 48), (byte)(pattern >> 40), (byte)(pattern >> 32),
				(byte)(pattern >> 24), (byte)(pattern >> 16), (byte)(pattern >> 8), (byte)(pattern >> 0),
			};
			HBITMAP bitmap = CreateBitmap(8, 8, 1, 1, wpat);
			HBRUSH brush = ::CreatePatternBrush(bitmap);
			COLORREF old_bk = GetBkColor(draw);
			COLORREF old_fg = GetTextColor(draw);
			if(!is_xor) {
				SetROP2(draw, R2_MASKPEN);
				SelectObject(draw, brush);
				SetTextColor(draw, Black());
				SetBkColor(draw, White());
				DrawPolyPolygonRaw(draw, vertices, poly,
					subpolygon_counts, sub, true, PEN_NULL, Null);
				SetROP2(draw, R2_MERGEPEN);
				SetTextColor(draw, color);
				SetBkColor(draw, Black());
			}
			else { // xor fill with pattern data
				SetROP2(draw, R2_XORPEN);
				SelectObject(draw, brush);
			}
			DrawPolyPolygonRaw(draw, vertices, poly,
				subpolygon_counts, sub, true, PEN_NULL, Null);
			SelectObject(draw, old_brush);
			SetTextColor(draw, old_fg);
			SetBkColor(draw, old_bk);
			SetROP2(draw, old_rop);
			DeleteObject(brush);
			DeleteObject(bitmap);
			if(!IsNull(outline))
			{
				draw.SetColor(Null);
				draw.SetDrawPen(width, outline);
				ASSERT(sizeof(POINT) == sizeof(Point));
				PolyPolygon(draw, (const POINT *)vertices, subpolygon_counts, sub);
			}
		}
		else
		{ // simple fill
	//		RTIMING("AreaTool::Fill(solid color)");
			int out_wd = (IsNull(width) || IsNull(outline) ? PEN_NULL : width);
			Color out_co = Nvl(outline, Black);
			draw.SetDrawPen(out_wd, out_co);
			if(is_xor)
			{
				color = Color(color.GetR() ^ doxor.GetR(), color.GetG() ^ doxor.GetG(), color.GetB() ^ doxor.GetB());
				SetROP2(draw, R2_XORPEN);
			}
			HGDIOBJ old_brush = 0;
			if(IsNull(color))
			{
				static HGDIOBJ null_brush = GetStockObject(NULL_BRUSH);
				old_brush = SelectObject(draw, null_brush);
			}
			else
				draw.SetColor(color);
			DrawPolyPolygonRaw(draw, vertices, poly, subpolygon_counts, sub,
				!IsNull(color), out_wd, out_co);
			if(old_brush)
				SelectObject(draw, old_brush);
			if(is_xor)
				SetROP2(draw, R2_COPYPEN);
		}
	#ifdef SYSTEMDRAW
		}
	#endif
#elif defined(PLATFORM_X11)
		if(fill_gc)
			FillPolyPolygonRaw(fill_gc, draw.GetDrawable(), draw.GetClip(), draw.GetOffset(),
				vertices, poly, subpolygon_counts, sub);
		if(line_gc)
			DrawPolyPolygonRaw(line_gc, draw.GetDrawable(), draw.GetOffset(),
				vertices, poly, subpolygon_counts, sub);
#else
	#error
#endif
		vertices += poly;
		subpolygon_counts += sub;
	}
Ejemplo n.º 29
0
void GlPlanes::Fill(GlFillType ft)
{
	if (w < 1 || h < 1) return;
	if (ft == GL_FILL_BLACK) Black();
	else if (ft == GL_FILL_COLORWHEEL) ColorWheel(0, 0, w-1, h-1);
}
Ejemplo n.º 30
0
/* function that opens a window over the default screen */
void SetupXWindows(int w, int h, int setup_color, char *display_name,
		   const char *window_title)
{
  XEvent event;
  XGCValues gcvalues;
  int mask;
  
  display = XOpenDisplay((display_name ? display_name : ""));
  if (!display)
	{
	  printf("Error in open X display\n");
	  exit (1);
	}

  iScreen = DefaultScreen(display);
  dDepth = DefaultDepth(display,iScreen);
  switch (dDepth)
    {
    case 8:
      sizeofPixel=1;
      break;
    case 16:
      sizeofPixel=2;
      break;
    case 24:
    case 32: /* It should work; on my system 24 bits pixels are word-aligned */
      sizeofPixel=4;
      break;
    default:
      printf("SetupXWindows : unsupported Display depth %d\n",dDepth);
    }

  DEBUG(printf("Default display depth %d\n", dDepth));

  m_w=w;
  m_h=h;

  /* scanlines are rounded to 32 pixels to avoid any misalignment */
  rounded_length = (m_w+31)&(~31); 
  /* allocate window buffer space */
  m_image_buffer = /*(XImage *)*/
    (char *) calloc(sizeof(char)*sizeofPixel,rounded_length*m_h);

  fg=Black();
  bg=White();

  window = XCreateSimpleWindow(display, DefaultRootWindow(display),
			       0,0,w,h,2,fg,bg);

  mask = ExposureMask | ButtonPressMask | KeyPressMask;
  XSelectInput(display, window,mask);
  XStoreName(display, window, window_title);
  XMapWindow(display, window);

  for (;;)
	{
	  XNextEvent(display, &event);
	  if (event.type == Expose)
		break;
	}
  
  gcvalues.foreground = fg;
  gcvalues.background = bg;
  mask = GCForeground | GCBackground;
  gc = XCreateGC(display, window, mask, &gcvalues);

  DEBUG(printf("Window opened\n"));
}