NAMESPACE_UPP CH_STYLE(MultiButton, Style, StyleDefault) { for(int i = 0; i < 4; i++) { simple[i] = left[i] = right[i] = lmiddle[i] = rmiddle[i] = Button::StyleEdge().look[i]; monocolor[i] = Button::StyleEdge().monocolor[i]; fmonocolor[i] = i == 3 ? SColorDisabled() : SColorText(); look[i] = trivial[i] = ChLookWith(simple[i], CtrlsImg::DA(), monocolor[i]); edge[i] = EditFieldEdge(); } activeedge = false; trivialborder = DPI(1); border = DPI(1); pressoffset = Button::StyleEdge().pressoffset; sep1 = SColorHighlight(); sep2 = SColorLight(); sepm = DPI(2); stdwidth = FrameButtonWidth(); trivialsep = false; margin = Rect(DPI(2), 2, DPI(2), 2); usetrivial = false; overpaint = loff = roff = 0; error = Blend(LtRed(), Red()); }
void Tab12_Linked::Init() { CtrlLayout(*this); SizePos(); scatter1.SetRange(1000, 40).SetXYMin(0, -20); scatter1.SetMouseHandling(true).SetMaxRange(5000).SetMinRange(2); scatter2.SetRange(1000, 40).SetXYMin(0, -20); scatter2.SetMouseHandling(true).SetMaxRange(5000).SetMinRange(2); scatter3.SetRange(1000, 40).SetXYMin(0, -20); scatter3.SetMouseHandling(true).SetMaxRange(5000).SetMinRange(2); for (int t = 0; t < 1000; ++t) { s1 << Pointf(t, 20*sin(6*M_PI*t/500)); s2 << Pointf(t, 20*sin(6*1.1*M_PI*t/500)); s3 << Pointf(t, 20*sin(6*1.2*M_PI*t/500)); } scatter1.AddSeries(s1).Legend("Series 1").NoMark().Stroke(2, LtRed()); scatter2.AddSeries(s2).Legend("Series 2").NoMark().Stroke(2, LtBlue()); scatter3.AddSeries(s3).Legend("Series 3").NoMark().Stroke(2, LtGreen()); scatter1.ShowInfo(); scatter2.ShowInfo(); scatter3.ShowInfo(); link = true; OnLink(); link.WhenAction = THISBACK(OnLink); }
void TextStrokeGradient(Painter& sw) { const char *txt = "GRADIENT TEXT"; Font fnt = Arial(100).Bold(); Size tsz = GetTextSize(txt, fnt); sw.Text(100, 100, txt, fnt) .Stroke(4, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed()); }
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()); }
Color EditorSyntax::IfColor(char c) { switch(c){ case IfState::IF: return LtBlue(); case IfState::ELIF: return Gray(); case IfState::ELSE: return Green(); case IfState::ELSE_ERROR: return LtRed(); case IfState::ENDIF_ERROR: return LtMagenta(); default: return Null; } }
bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild) { GuiLock __; LTIMING("PaintOpaqueAreas"); if(!IsShown() || r.IsEmpty() || !r.Intersects(clip) || !w.IsPainting(r)) return true; Point off = r.TopLeft(); Point viewpos = off + GetView().TopLeft(); if(backpaint == EXCLUDEPAINT) return w.ExcludeClip(r); Rect cview = clip & (GetView() + off); for(Ctrl *q = lastchild; q; q = q->prev) if(!q->PaintOpaqueAreas(w, q->GetRect() + (q->InView() ? viewpos : off), q->InView() ? cview : clip)) return false; if(nochild && (lastchild || GetNext())) return true; Rect opaque = (GetOpaqueRect() + viewpos) & clip; if(opaque.IsEmpty()) return true; #ifdef SYSTEMDRAW if(backpaint == FULLBACKPAINT && !dynamic_cast<BackDraw *>(&w)) #else if(backpaint == FULLBACKPAINT && !w.IsBack()) #endif { ShowRepaintRect(w, opaque, LtRed()); BackDraw bw; bw.Create(w, opaque.GetSize()); bw.Offset(viewpos - opaque.TopLeft()); bw.SetPaintingDraw(w, opaque.TopLeft()); { LEVELCHECK(bw, this); Paint(bw); PaintCaret(bw); } bw.Put(w, opaque.TopLeft()); } else { w.Clip(opaque); ShowRepaintRect(w, opaque, Green()); w.Offset(viewpos); { LEVELCHECK(w, this); Paint(w); PaintCaret(w); } w.End(); w.End(); } LLOG("Exclude " << opaque); return w.ExcludeClip(opaque); }
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 Ctrl::UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint) { GuiLock __; LTIMING("UpdateArea"); LLOG("========== UPDATE AREA " << UPP::Name(this) << " =========="); if(globalbackbuffer) { CtrlPaint(draw, clip); LLOG("========== END (TARGET IS BACKBUFFER)"); return; } if(backpaint == FULLBACKPAINT || globalbackpaint && !hasdhctrl && !dynamic_cast<DHCtrl *>(this)) { ShowRepaintRect(draw, clip, LtRed()); BackDraw bw; bw.Create(draw, clip.GetSize()); bw.Offset(-clip.TopLeft()); bw.SetPaintingDraw(draw, clip.TopLeft()); CtrlPaint(bw, clip); bw.Put(draw, clip.TopLeft()); LLOG("========== END (FULLBACKPAINT)"); return; } if(backpaint == TRANSPARENTBACKPAINT) { LLOG("TransparentBackpaint"); Vector<Rect> area; GatherTransparentAreas(area, draw, GetRect().GetSize(), clip); for(int i = 0; i < area.GetCount(); i++) { Rect ar = area[i]; LLOG("Painting area: " << ar); ShowRepaintRect(draw, ar, LtBlue()); BackDraw bw; bw.Create(draw, ar.GetSize()); bw.Offset(-ar.TopLeft()); bw.SetPaintingDraw(draw, ar.TopLeft()); CtrlPaint(bw, ar); bw.Put(draw, ar.TopLeft()); if(!draw.ExcludeClip(ar)) { LLOG("========== END"); return; } } PaintOpaqueAreas(draw, GetRect().GetSize(), clip); LLOG("========== END"); return; } CtrlPaint(draw, clip); LLOG("========== END"); }
void TabBubblePlot::Init() { CtrlLayout(*this); SizePos(); scatter.SetMouseHandling(true, true).ShowContextMenu(); for (double size = 0; size <= 10; size += 2.) { Vector<double> &data = s1.Add(); data << size << (10 + 10*Random(30)*size) << Random(80); } idsBubble << 2; static Vector<int> idVoid; scatter.AddSeries(s1, 0, 1, idVoid, idVoid, idsBubble).Legend("Importance").MarkStyle<BubblePlot>() .NoPlot().MarkColor(Green()).MarkBorderColor(LtRed()).MarkBorderWidth(3); scatter.SetLabelY("Size"); scatter.ZoomToFit(true, true, 0.2); }
//============================================================================================== /*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(); }
void RedDisplay::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword s) const { w.DrawRect(r, paper); DrawSmartText(w, r.left, r.top, r.Width(), String(q), StdFont(), LtRed()); }
void Tab1_Basic::Init() { CtrlLayout(*this); SizePos(); s1 << Pointf(10, 26) << Pointf(20, 37) << Pointf(30, 31) << Pointf(40, 33) << Pointf(50, 28); scatter.AddSeries(s1).Legend("Series 1").Opacity(0.3).Fill().MarkBorderColor(); s2y[0] = 22; s2y[1] = 33; s2y[2] = 27; s2y[3] = 29; s2y[4] = 24; scatter.AddSeries(s2y, 5, 10, 10).Legend("Series 2").Id(SERIE2).PlotStyle<LineSeriesPlot>() .Dash("").MarkColor(Red()).Fill().Opacity(0.5).MarkBorderColor(); s3y[0] = 18; s3y[1] = 29; s3y[2] = 23; s3y[3] = 25; s3y[4] = 20; s3x[0] = 10; s3x[1] = 20; s3x[2] = 30; s3x[3] = 40; s3x[4] = 50; scatter.AddSeries(s3x, s3y, 5).Legend("Series 3").MarkBorderColor(); s4y << 14 << 25 << 19 << 21 << 16; s4x << 10 << 20 << 30 << 40 << 50; scatter.AddSeries(s4x, s4y).Legend("Series 4").PlotStyle<StaggeredSeriesPlot>().Dash("").NoMark().Fill().Stroke(3, LtRed()); s5.Add(10, 10); s5.Add(20, 21); s5.Add(30, 15); s5.Add(40, 16); s5.Add(50, 12); int barWidth = 4; scatter.AddSeries(s5).Legend("Series 5").PlotStyle<BarSeriesPlot>(barWidth).Dash("").NoMark().Fill(); scatter.SetRange(60, 50).SetMajorUnits(10, 10); scatter.ShowInfo().ShowContextMenu().ShowPropertiesDlg().ShowProcessDlg().SetPopText("h", "v", "v2").SetMouseHandling(true, true); scatter.SetLegendPos(Point(20, 20)); }
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()); } } }
void FormView::DrawSprings(Draw& w, const Rect& r, dword align, dword valign, bool drawLeft, bool drawTop, bool drawRight, bool drawBottom, bool centered) { if (!IsLayout()) return; int x = r.CenterPoint().x; int y = r.CenterPoint().y; if (drawLeft) { if (!centered) y = YToGrid(r.top + r.Height() / 3); if (align == Ctrl::LEFT || align == Ctrl::SIZE) w.DrawLine(2, y, r.left, y, 1, LtRed()); else for (int i = 5; i <= r.left; i += 5) w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1, LtRed()); } if (drawRight) { if (!centered) y = YToGrid(r.top + r.Height() * 2 / 3); if (align == Ctrl::RIGHT || align == Ctrl::SIZE) w.DrawLine(r.right, y, GetRect().Width() - 2, y, 1, LtRed()); else for (int i = r.right; i < GetRect().Width() + 5; i += 5) w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1, LtRed()); } if (drawTop) { if (!centered) x = XToGrid(r.left + r.Width() / 3); if (valign == Ctrl::TOP || valign == Ctrl::SIZE) w.DrawLine(x, 2, x, r.top, 1, LtRed()); else for (int i = 5; i <= r.top; i += 5) w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1, LtRed()); } if (drawBottom) { if (!centered) x = XToGrid(r.left + r.Width() * 2 / 3); if (valign == Ctrl::BOTTOM || valign == Ctrl::SIZE) w.DrawLine(x, r.bottom, x, GetRect().Height() - 2, 1, LtRed()); else for (int i = r.bottom; i < GetRect().Height() + 5; i += 5) w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1, LtRed()); } }
void HighlightSetup::DefaultHlStyles() { SetHlStyle(INK_COMMENT, Green, false, true); SetHlStyle(PAPER_COMMENT_WORD, Yellow, false, false); SetHlStyle(INK_COMMENT_WORD, Blue, true, true); SetHlStyle(INK_CONST_STRING, Red); SetHlStyle(INK_CONST_STRINGOP, LtBlue); SetHlStyle(INK_CONST_INT, Red); SetHlStyle(INK_CONST_FLOAT, Magenta); SetHlStyle(INK_CONST_HEX, Blue); SetHlStyle(INK_CONST_OCT, Blue); SetHlStyle(INK_OPERATOR, LtBlue); SetHlStyle(INK_KEYWORD, LtBlue, true); SetHlStyle(INK_UPP, Cyan); SetHlStyle(PAPER_LNG, Color(255, 255, 224)); SetHlStyle(INK_ERROR, LtRed); SetHlStyle(INK_PAR0, Black); SetHlStyle(INK_PAR1, Green); SetHlStyle(INK_PAR2, Magenta); SetHlStyle(INK_PAR3, Brown); SetHlStyle(INK_UPPER, Black); SetHlStyle(INK_SQLBASE, Black); SetHlStyle(INK_SQLFUNC, Black); SetHlStyle(INK_SQLBOOL, Black); SetHlStyle(INK_UPPMACROS, Cyan); SetHlStyle(INK_UPPLOGS, Green); SetHlStyle(INK_DIFF_FILE_INFO, Black, true); SetHlStyle(INK_DIFF_HEADER, Color(28, 127, 200)); SetHlStyle(INK_DIFF_ADDED, Color(28, 42, 255)); SetHlStyle(INK_DIFF_REMOVED, Color(255, 0, 0)); SetHlStyle(INK_DIFF_COMMENT, Green); SetHlStyle(PAPER_BLOCK1, Blend(LtBlue, White, 240)); SetHlStyle(PAPER_BLOCK2, Blend(LtGreen, White, 240)); SetHlStyle(PAPER_BLOCK3, Blend(LtYellow, White, 240)); SetHlStyle(PAPER_BLOCK4, Blend(LtMagenta, White, 240)); SetHlStyle(INK_MACRO, Magenta); SetHlStyle(PAPER_MACRO, Color(255, 255, 230)); SetHlStyle(PAPER_IFDEF, Color(230, 255, 255)); SetHlStyle(INK_IFDEF, Color(170, 170, 170)); SetHlStyle(PAPER_BRACKET0, LtYellow); SetHlStyle(PAPER_BRACKET, Yellow, true); SetHlStyle(INK_NORMAL, SColorText); SetHlStyle(INK_DISABLED, SColorDisabled); SetHlStyle(INK_SELECTED, SColorHighlightText); SetHlStyle(PAPER_NORMAL, SColorPaper); SetHlStyle(PAPER_READONLY, SColorFace); SetHlStyle(PAPER_SELECTED, SColorHighlight); SetHlStyle(PAPER_SELWORD, Yellow); SetHlStyle(PAPER_ERROR, Blend(White(), LtRed(), 50)); SetHlStyle(PAPER_WARNING, Blend(White(), Yellow(), 50)); SetHlStyle(SHOW_LINE, Color(199, 247, 198)); SetHlStyle(WHITESPACE, Blend(SColorLight, SColorHighlight)); SetHlStyle(WARN_WHITESPACE, Blend(SColorLight, SRed)); }