void SDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { sMakeTextGlyph g; g.font = font; g.color = White(); g.angle = angle; g.draw = this; for(int i = 0; i < n; i++) { g.chr = text[i]; LTIMING("Paint glyph"); if(font.GetHeight() > 200) { Point at(font[g.chr], font.GetLineHeight()); int n = at.x + at.y; Size bandsz(2 * n, 32); for(int yy = 0; yy < n; yy += bandsz.cy) { Image m = RenderGlyph(Point(0, -yy), angle, g.chr, font, White(), bandsz); SysDrawImageOp(x, y + yy, m, m.GetSize(), ink); } } else { Image m = MakeImage(g); Point h = m.GetHotSpot(); SysDrawImageOp(x - h.x, y - h.y, m, m.GetSize(), ink); } x += dx ? *dx++ : font[g.chr]; } }
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; }
void SystemDraw::DrawRectOp(int x, int y, int cx, int cy, Color color) { if(IsNull(color)) return; FlushText(); cairo_rectangle(cr, x, y, cx, cy); if(color == InvertColor()) { #if GTK_CHECK_VERSION(2,24,0) && (CAIRO_VERSION_MAJOR > 1 || CAIRO_VERSION_MINOR > 9) SetColor(White()); cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE); cairo_fill(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); #else if(drawable) { GdkGC *gc = gdk_gc_new(drawable); gdk_gc_set_function(gc, GDK_INVERT); Point o = GetOffset(); gdk_draw_drawable(drawable, gc, drawable, x + o.x, y + o.y, x + o.x, y + o.y, cx, cy); gdk_gc_set_function(gc, GDK_COPY); gdk_gc_destroy(gc); } #endif } else { SetColor(color); cairo_fill(cr); } }
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()); } }
void SDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) { sMakeTextGlyph g; g.font = font; g.color = White(); g.angle = angle; g.draw = this; for(int i = 0; i < n; i++) { g.chr = text[i]; LTIMING("Paint glyph"); if(font.GetHeight() > 200) { int bn = font[g.chr] + font.GetLineHeight(); for(g.yy = 0; g.yy < bn; g.yy += 32) { Image m; if(paintonly) m = MakeImagePaintOnly(g); else m = MakeImage(g); Point h = m.GetHotSpot(); SysDrawImageOp(x - h.x, y + g.yy - h.y, m, m.GetSize(), ink); } } else { g.yy = Null; Image m; if(paintonly) m = MakeImagePaintOnly(g); else m = MakeImage(g); Point h = m.GetHotSpot(); SysDrawImageOp(x - h.x, y - h.y, m, m.GetSize(), ink); } x += dx ? *dx++ : font[g.chr]; } }
// Update the Fade Pattern void FadeUpdate() { // Calculate linear interpolation between Color1 and Color2 // Optimise order of operations to minimize truncation error uint8_t red = ((Red(Color1) * (TotalSteps - Index)) + (Red(Color2) * Index)) / TotalSteps; uint8_t green = ((Green(Color1) * (TotalSteps - Index)) + (Green(Color2) * Index)) / TotalSteps; uint8_t blue = ((Blue(Color1) * (TotalSteps - Index)) + (Blue(Color2) * Index)) / TotalSteps; uint8_t white = ((White(Color1) * (TotalSteps - Index)) + (White(Color2) * Index)) / TotalSteps; // Serial.print(red); Serial.print(","); // Serial.print(green); Serial.print(","); // Serial.print(blue); Serial.print(","); // Serial.print(white); Serial.println(); ColorSet(Color(red, green, blue, white)); show(); Increment(); }
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
void Stats_Draw(widget_t *w) { //stats_gui_t *gf = (stats_gui_t*)w->wd; static int bg = 0; char buf[1024]; // Init if needed.. I guess this can be here. if( bg == 0 ) { glEnable(GL_TEXTURE_2D); bg = BuildStatsBG(); glDisable(GL_TEXTURE_2D); } // Draw background. glEnable(GL_TEXTURE_2D); White(); glCallList(bg); glDisable(GL_TEXTURE_2D); // Draw the xp info: Yellow(); sprintf(buf,"XP:"); glRasterPos2f(0.1f, 0.1f); printGLf(w->glw->font,"%s",buf); sprintf(buf,"%.1lf",Statec->player.xp); glRasterPos2f(0.4f, 0.1f); printGLf(w->glw->font,"%s",buf); // Draw the mana info: Purple(); sprintf(buf,"Mana:"); glRasterPos2f(0.1f, 0.2f); printGLf(w->glw->font,"%s",buf); sprintf(buf,"%.1lf /",Statec->player.mana); glRasterPos2f(0.4f, 0.2f); printGLf(w->glw->font,"%s",buf); sprintf(buf,"%.0lf",Statec->player.base_mana); glRasterPos2f(0.4f, 0.3f); printGLf(w->glw->font,"%s",buf); // Draw the wave info: Green(); sprintf(buf,"Wave:"); glRasterPos2f(0.1f, 0.4f); printGLf(w->glw->font,"%s",buf); sprintf(buf,"%lu",Statec->wave); glRasterPos2f(0.4f, 0.4f); printGLf(w->glw->font,"%s",buf); // Outline Yellow(); glBegin(GL_LINE_LOOP); glVertex2f(0.0f,0.0f); glVertex2f(0.0f,1.0f); glVertex2f(1.0f,1.0f); glVertex2f(1.0f,0.0f); glEnd(); }
void Stroke(Painter& sw) { const char *txt = "GRM"; Font fnt = Arial(100).Bold(); Size tsz = GetTextSize(txt, fnt); sw.Scale(3, 3); sw.Text(100, 100, txt, fnt) .Stroke(10, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed()) .Stroke(0.25, White()); sw.Path("M 100 100 L 200 100 L 210 90 L 220 40 L 230 90 L 240 100 L 400 100") .Stroke(24, Blue()); }
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); } }
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(); }
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; }
void Draw::DrawPaintingOp(const Rect& target, const Painting& pw) { if(!HasPainter()) return; Size sz = target.GetSize(); if((sz.cx > 2000 || sz.cy > 1500) && IsPrinter()) { int yy = 0; while(yy < sz.cy) { int ccy = min(sz.cy - yy, 100); ImageBuffer ib(sz.cx, ccy); Fill(~ib, White(), ib.GetLength()); PaintImageBuffer(ib, pw, sz, Point(0, yy), true); DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16); yy += ccy; } } else { ImageBuffer ib(sz); Fill(~ib, IsPrinter() ? White() : SColorPaper(), ib.GetLength()); PaintImageBuffer(ib, pw, sz, Point(0, 0), IsPrinter()); DrawImage(target.left, target.top, ib); } }
//Function draws game graphics void Fifteen::DrawGameArea() { PaintingPainter p(gamearea.GetSize()); for (int i=0; i<SIZE; i++) { for (int j=0; j<SIZE; j++) { Color colT = White(); Color colB = DarkGray(); if (GameArray[i][j] != 0) { if(!endOfGame) { if ( gamearea.mouseOn & (gamearea.movepos.x > GetTilePosX(i)) && (gamearea.movepos.x < GetTilePosX(i) + GetTileSizeX()) && (gamearea.movepos.y > GetTilePosY(j)) && (gamearea.movepos.y < GetTilePosY(j) + GetTileSizeY()) ) { if (Moveable(i,j)) { colT = LightGreen(); } else { colT = LightRed(); } colB = Silver(); } p.Rectangle(GetTilePosX(i)+1, GetTilePosY(j)+1, GetTileSizeX()-2, GetTileSizeY()-2) .Fill(GetTilePosX(i), GetTilePosY(j), LightGray(), GetTilePosX(i), GetTilePosY(j), GetTileSizeX(), colB, 3); p.DrawText(GetTilePosX(i)+3, GetTilePosY(j)+3, GetTileString(GameArray[i][j]), Arial(32).Bold(), DarkGray()); p.DrawText(GetTilePosX(i)+1, GetTilePosY(j)+1, GetTileString(GameArray[i][j]), Arial(32).Bold(), colT); } else { p.Rectangle(GetTilePosX(i)+1, GetTilePosY(j)+1, GetTileSizeX()-2, GetTileSizeY()-2) .Fill(GetTilePosX(i), GetTilePosY(j), LightGray(), GetTilePosX(i), GetTilePosY(j), GetTileSizeX(), DarkGray(), 3); p.DrawText(GetTilePosX(i)+3, GetTilePosY(j)+3, GetTileString(GameArray[i][j]), Arial(32).Bold(), DarkGray()); p.DrawText(GetTilePosX(i)+1, GetTilePosY(j)+1, GetTileString(GameArray[i][j]), Arial(32).Bold(), colT); } } } } result.SetData(points); gamearea = p; }
virtual void Paint2(Draw& w) { Size sz = GetSize(); w.DrawRect(GetSize(), White()); static GdkColormap* cm = gdk_x11_colormap_foreign_new( gdkx_visual_get(XVisualIDFromVisual(Xvisual)), Xcolormap); GdkWindow *gw = gdk_window_foreign_new(w.GetDrawable()); GtkStyle *style = gtk_widget_get_style((GtkWidget *)gtk__parent()); GdkRectangle r; r.x = r.y = 0; r.width = r.height = 64; gtk_paint_box(style, gw, (GtkStateType)0, (GtkShadowType)0, &r, (GtkWidget*)GTK().gtk_button_new(), "button", 0, 0, 64, 64); }
NAMESPACE_UPP Image NativePathIconX(const char *path, bool folder, int flags) { if (!(flags & BROWSE_LINKS)) return NativePathIcon(path, folder); if (!IsSymLink(path)) return NativePathIcon(path, folder); String linkPath = GetSymLinkPath(path); if (linkPath.IsEmpty()) linkPath = path; static Image ilink = Null; if (!ilink) { ImageDraw drw(8, 8); Rect r(0, 0, 8, 8); drw.DrawRect(r, White()); drw.DrawImage(r, CtrlImg::smallright); drw.DrawLine(r.left, r.top, r.right-1, r.top, 1, GrayColor(100)); drw.DrawLine(r.right-1, r.top, r.right-1, r.bottom-1, 1, GrayColor(100)); drw.DrawLine(r.right-1, r.bottom-1, r.left, r.bottom-1, 1, GrayColor(100)); drw.DrawLine(r.left, r.bottom-1, r.left, r.top, 1, GrayColor(100)); ilink = drw; } Image img = NativePathIcon(linkPath, DirectoryExists(linkPath)); int w = img.GetWidth(); int h = img.GetHeight(); ImageDraw drw(w, h); drw.Alpha().DrawImage(0, 0, img, GrayColor(255)); drw.DrawImage(0, 0, img); int ypos = img.GetHeight() - ilink.GetHeight(); drw.Alpha().DrawImage(0, ypos, ilink, GrayColor(255)); drw.DrawImage(0, ypos, ilink); return drw; }
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(); } } }
DlgCompareDir::DlgCompareDir() { CtrlLayout(*this, "Compare directories"); Sizeable().Zoomable(); refresh <<= THISBACK(CmdRefresh); splitter.Vert(tree, editor); editor << lineedit.SizePos() << qtf.SizePos(); qtf.Background(White()); qtf.SetFrame(InsetFrame()); path_a.AddFrame(browse_a); browse_a.SetImage(CtrlImg::right_arrow()); browse_a <<= THISBACK1(DoBrowse, &path_a); path_b.AddFrame(browse_b); browse_b.SetImage(CtrlImg::right_arrow()); browse_b <<= THISBACK1(DoBrowse, &path_b); file_mask <<= "*.cpp *.h *.hpp *.c *.C *.cxx *.cc *.lay *.iml *.upp *.sch *.dph"; tree.WhenCursor = THISBACK(DoTreeCursor); lineedit.SetReadOnly(); lineedit.SetFont(Courier(14)); }
//============================================================================================== /*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(); }
Image ReportView::GetPage(int i) { ASSERT(report); int ii = i & pm; if(pagei[ii] != i) { pagei[ii] = i; Size sz = Size(max(pagesize.cx - 2, 1), max(pagesize.cy - 2, 1)); if(HasPainter()) { ImageBuffer ib(sz); Fill(~ib, White(), ib.GetLength()); PaintImageBuffer(ib, report->GetPage(i)); page[ii] = ib; } else { ImageDraw iw(sz); iw.DrawRect(sz, White); iw.DrawDrawing(0, 0, sz.cx, sz.cy, report->GetPage(i)); page[ii] = iw; } } return page[ii]; }
/* added */ char* GetHobetaFileName(char*& p) { int o = 0; int o2 = 0; char* fn, * np; np = fn = new char[LINEMAX]; if (np == NULL) { Error("No enough memory!", 0, FATAL); } *fn = 0; SkipBlanks(p); if (!(*p)) { return fn; } if (*p == '"') { o = 1; ++p; } else if (*p == '<') { o = 2; ++p; } if (*p && strstr(p, ":")) { o2 = 1; } /* added */ while (*p && !White() && *p != '"' && *p != '>' && !(o == 0 && o2 == 1 && *p == ':')) { *np = *p; ++np; ++p; } if (*p && o == 1) { if (*p == '"') { ++p; } else { Error("No closing '\"'", 0); } } else if (*p && o == 2 && *p != '>') { Error("No closing '>'", 0); } else if (*p) { ++p; } *np = 0; return fn; }
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]); }
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)); }
Size Navigator::NavigatorDisplay::GetStdSize(const Value& q) const { NilDraw w; return Size(DoPaint(w, Size(999999, 999999), q, White(), White(), 0), Draw::GetStdFontCy()); }
void FormView::Paint(Draw& w) { if (!IsLayout()) { w.DrawRect(GetRect(), White()); return; } Rect r = Zoom(GetPageRect()); DrawGrid(w); DrawRect(w, r, 1, LtBlue()); w.DrawRect(0, 0, r.left, 3000, White()); w.DrawRect(r.right + 1, 0, 3000, 3000, White()); w.DrawRect(r.left, 0, 5000, r.top, White()); w.DrawRect(r.left, r.bottom + 1, 3000, 3000, White()); // if (_showInfo) // { // r.SetSize( Zoom(Size(804, 604)) ); // DrawRect(w, r.Offseted( Zoom(Size(-2, -2)) ), 1, LtMagenta()); // r = Zoom(GetPageRect()); // } if (GetObjectCount() > 0 && _showInfo == 2) { Rect b = Zoom(GetObjectsRect()).Offseted(1, 1); b.SetSize( b.GetSize() + Size(-2, -2) ); DrawRect(w, b, 1, Yellow()); } Vector<int> sel = GetSelected(); bool coloring = GetBool("View.Coloring"); int ci = 0; if (sel.GetCount() > 0) { if (sel.GetCount() == 1) { for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; if (coloring && i != sel[0]) DrawObject(w, i, _colors[ci], false); else DrawObject(w, i, (!coloring && (i == sel[0])) ? _colors[ci] : LtGray(), i == sel[0]); } } else { for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; bool found = false; for (int j = 0; j < sel.GetCount(); ++j) if ( i == sel[j]) { found = true; break; } if (coloring && !found) DrawObject(w, i, _colors[ci], false); else DrawObject(w, i, (!coloring && found) ? _colors[ci] : LtGray(), false); } Size g = GetGridSize(); Rect s = GetSelectionRect().Offseted(-g.cx / 2, -g.cy / 2); s.SetSize(s.GetSize() + Size(g.cx, g.cy)); Vector<int> sel = GetSelected(); bool a1 = true; // allow horz align bool a2 = true; // allow vert align dword f1; // first horz align dword f2; // first vert align for (int i = 0; i < sel.GetCount(); ++i) { FormObject *pI = GetObject(sel[i]); if (!pI) continue; if (i == 0) { f1 = pI->GetHAlign(); f2 = pI->GetVAlign(); } if (f1 != pI->GetHAlign()) { a1 = false; } if (f2 != pI->GetVAlign()) { a2 = false; } } DrawSprings(w, Zoom(s), f1, f2, a1, a2, a1, a2, false); DrawRect(w, Zoom(s), 1, LtRed()); s = GetSelectionRect().Offseted(-g.cx, -g.cy); s.SetSize(s.GetSize() + Size(g.cx * 2, g.cy * 2)); DrawGroupTools(w, Zoom(s)); } return; } for (int i = 0; i < GetObjectCount(); ++i) { if (ci++ == _colors.GetCount() - 1) ci = 0; DrawObject(w, i, coloring ? _colors[ci] : LtGray()); } if (sel.GetCount() == 0) w.DrawImage(r.right, r.bottom, FormViewImg::SizerBR()); }
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()); } } }
float Player::SubjectiveScore (const float& score) const { NatMap <Player, float> tab (0.0); tab[Black()] = score; tab[White()] = - score; return tab [*this]; }
string Player::ToGtpString () const { NatMap <Player, string> gtp_string (""); gtp_string [Black()] = "B"; gtp_string [White()] = "W"; return gtp_string [*this]; }
/* 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")); }
Size Navigator::ScopeDisplay::GetStdSize(const Value& q) const { NilDraw w; return Size(DoPaint(w, Size(999999, 999999), q, White(), White(), 0), StdFont().Bold().GetCy()); }