CH_STYLE(MenuBar, Style, StyleDefault) { topitem[0] = Null; topitem[1] = topitem[2] = item = SColorHighlight(); topitemtext[0] = menutext = SColorMenuText(); topitemtext[1] = topitemtext[2] = itemtext = SColorHighlightText(); topbar = SColorFace(); maxiconsize = Size(16, 16); arealook = Null; look = SColorFace(); separator = breaksep = SeparatorCtrl::StyleDefault(); ImageBuffer ib(7, 7); Fill(ib, SColorShadow(), 7 * 7); for(int i = 0; i < 5; i++) Fill(ib[i + 1] + 1, SColorMenu(), 5); ib.SetHotSpot(Point(3, 3)); ib.Set2ndSpot(Point(3, 3)); popupframe = Image(ib); popupbody = SColorMenu(); popupiconbar = Null; leftgap = DPI(16) + Zx(4); textgap = Zx(3); lsepm = rsepm = Zx(2); pullshift.x = 0; pullshift.y = -1; }
Size MenuItem::GetMinSize() const { Size sz1 = GetTextSize(text, font); Size sz2(0, 0); if(accel) { sz2 = GetTextSize(GetKeyDesc(accel), font); sz2.cx += Zx(12); } Size lsz = min(maxiconsize, licon.GetSize()); Size rsz = ricon.GetSize(); return AddFrameSize(Size(max(lsz.cx, leftgap) + sz1.cx + max(sz2.cx, (rsz.cx ? Zx(16) : 0)) + max(rsz.cx, Zx(16)) + textgap + Zx(10), max(max(lsz.cy, rsz.cy) + Zy(4), sz1.cy + Zy(6)))); }
virtual Size GetStdSize(const Value& q) const { ValueArray va = q; Size sz = GetTextSize(String(va[0]), fnt); sz.cx += Zx(20); sz.cy = max(sz.cy, Zy(16)); return sz; }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { ValueArray va = q; String txt = va[0]; Image icon = va[1]; if(IsNull(icon)) icon = IdeImg::Package(); else icon = DPI(icon, 16); w.DrawRect(r, paper); w.DrawImage(r.left, r.top + (r.Height() - icon.GetHeight()) / 2, icon); w.DrawText(r.left + Zx(20), r.top + (r.Height() - Draw::GetStdFontCy()) / 2, txt, fnt, ink); }
int Navigator::NavigatorDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { int ii = q; if(ii < 0 || ii >= item.GetCount()) return 0; const NavItem& m = *item[ii]; bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT); int x = r.left; int ry = r.top + r.GetHeight() / 2; int y = ry - Draw::GetStdFontCy() / 2; if(findarg(m.kind, KIND_FILE, KIND_NEST) >= 0) { w.DrawRect(r, focuscursor ? paper : m.kind == KIND_NEST ? Blend(SColorMark, SColorPaper, 220) : SColorFace); if(m.kind == KIND_FILE) return PaintFileName(w, r, m.type, ink); String h = FormatNest(m.type); w.DrawText(x, y, h, StdFont().Bold(), ink); return GetTextSize(h, StdFont().Bold()).cx; } w.DrawRect(r, paper); if(m.kind == KIND_LINE) { w.DrawText(x, y, m.type, StdFont().Bold(), ink); return GetTextSize(m.type, StdFont().Bold()).cx; } PaintCppItemImage(w, x, ry, m.access, m.kind, focuscursor); x += Zx(15); Vector<ItemTextPart> n = ParseItemNatural(m.name, m.natural, m.ptype, m.pname, m.type, m.tname, m.ctname, ~m.natural + m.at); int starti = 0; for(int i = 0; i < n.GetCount(); i++) if(n[i].type == ITEM_NAME) { starti = i; break; } PaintText(w, x, y, m.natural, n, starti, n.GetCount(), focuscursor, ink, false); if(starti) { const char *h = " : "; w.DrawText(x, y, h, BrowserFont(), SColorText); x += GetTextSize(h, BrowserFont()).cx; } PaintText(w, x, y, m.natural, n, 0, starti, focuscursor, ink, false); return x; }
AboutDlg() { Size isz = MakeLogo(*this, ctrl); int cx = min(isz.cx * 2, GetWorkArea().GetWidth()); SetRect(0, 0, cx, isz.cy); about.SetQTF(GetTopic("ide/app/About$en-us"), Zoom(DPI(120), 1024)); about.SetZoom(Zoom(1, 1)); about.RightPos(0, cx - isz.cx - DPI(1)).VSizePos(); about.HMargins(Zx(4)); about.SetFrame(NullFrame()); about.NoLazy(); Background(PaintRect(ColorDisplay(), SColorPaper())); Add(about); // separator.Color(Gray()); // Add(separator.RightPos(cx - isz.cx, DPI(1)).VSizePos()); Title("About TheIDE"); }
NAMESPACE_UPP #define LLOG(x) // DLOG(x) #define LTIMING(x) // RTIMING(x) MenuItemBase::MenuItemBase() { accel = 0; state = 0; isenabled = true; type = 0; font = StdFont(); leftgap = Zx(16); textgap = Zy(6); accesskey = 0; NoWantFocus(); style = &MenuBar::StyleDefault(); Transparent(); maxiconsize = Size(INT_MAX, INT_MAX); }
void MenuItem::Paint(Draw& w) { int q = text.Find('\t'); String txt, keydesc; if(accel) keydesc = GetKeyDesc(accel); if(q >= 0) { keydesc = text.Mid(q + 1); txt = text.Mid(0, q); } else txt = text; state = GetVisualState(); bool hl = state != NORMAL; Size sz = GetSize(); if(hl) { if(GUI_GlobalStyle() >= GUISTYLE_XP) ChPaint(w, 0, 0, sz.cx, sz.cy, style->item); else w.DrawRect(sz, SColorHighlight); } UPP::Image li = licon; if(li.IsEmpty()) { switch(type) { case CHECK0: li = CtrlImg::MenuCheck0(); break; case CHECK1: li = CtrlImg::MenuCheck1(); break; case RADIO0: li = CtrlImg::MenuRadio0(); break; case RADIO1: li = CtrlImg::MenuRadio1(); break; } } Size isz = li.GetSize(); // Size isz = min(maxiconsize, imsz); // if(isz != imsz) // li = CachedRescale(li, isz); int iy = (sz.cy - isz.cy) / 2; bool chk = false; int x = Zx(2); if(!licon.IsEmpty() && type) { chk = type == CHECK1 || type == RADIO1; if(GUI_GlobalStyle() >= GUISTYLE_XP) { if(chk && !hl) DrawXPButton(w, RectC(0, iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4)), BUTTON_EDGE|BUTTON_CHECKED); } else { w.DrawRect(x - Zx(1), iy - Zy(1), isz.cx + Zx(2), isz.cy + Zy(2), chk ? Blend(SColorFace, SColorLight) : SColorFace); DrawBorder(w, x - Zx(2), iy - Zy(2), isz.cx + Zx(4), isz.cy + Zy(4), chk ? ThinInsetBorder : ThinOutsetBorder); } } if(isenabled) DrawHighlightImage(w, x, iy, li, hl || chk, true); else w.DrawImage(x, iy, DisabledImage(li)); x = max(isz.cx, leftgap) + textgap; isz = GetTextSize(text, StdFont()); DrawMenuText(w, x, (sz.cy - isz.cy) / 2, txt, font, isenabled, hl, style->menutext, style->itemtext); isz = ricon.GetSize(); if(isenabled) w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, ricon, hl ? style->itemtext : style->menutext); else w.DrawImage(sz.cx - isz.cx, (sz.cy - isz.cy) / 2, DisabledImage(ricon)); x = sz.cx - max(isz.cx, Zx(16)) - Zx(1); if(!IsEmpty(keydesc)) { isz = GetTextSize(keydesc, StdFont()); UPP::DrawMenuText(w, x - isz.cx - Zx(2), (sz.cy - isz.cy) / 2, keydesc, font, isenabled, hl, 0, SColorMenuMark(), style->itemtext, false); } }
void VideoFluids::trackVelocity(Matrix& Zn1,Matrix& Zn,Matrix& U,Matrix& V) { Matrix Zx(height,width),Zy(height,width),ZZx(height,width),ZZy(height,width),Zt(height,width),ZZt(height,width),ZZtx(height,width),ZZty(height,width); Matrix Au1(height,width),Au2(height,width),Av1(height,width),Av2(height,width); Matrix Z2x(height,width),Z2y(height,width),Z2(height,width); Matrix Cu(height,width),Cv(height,width); Matrix tmp(height,width),tmp1(height,width); Matrix U_old(height,width),V_old(height,width),Ux(height,width),Uy(height,width),Vx(height,width),Vy(height,width),Uax(height,width),Uay(height,width),Vax(height,width),Vay(height,width),Uxy(height,width),Vxy(height,width); Matrix Coe(height,width); Zt = Zn; Zt -= Zn1; DotMul(Zn,Zt,ZZt); Zn.output("Zn.txt"); Zn1.output("Zn1.txt"); Zt.output("Zt.txt"); Partial(ZZt,ZZtx,AXIS_X); Partial(ZZt,ZZty,AXIS_Y); Partial(Zn,Zx,AXIS_X); Partial(Zn,Zy,AXIS_Y); DotMul(Zn,Zx,ZZx); DotMul(Zn,Zy,ZZy); DotMul(Zx,Zx,Au1); Partial(ZZx,tmp,AXIS_X); Au1-=tmp; DotMul(Zn,Zn,tmp); Au1+=tmp; Au1+=2*alpha*alpha; DotMul(Zx,Zy,Au2); Partial(ZZy,tmp,AXIS_X); Au2-=tmp; DotMul(Zx,Zy,Av1); Partial(ZZx,tmp,AXIS_Y); Av1-=tmp; DotMul(Zy,Zy,Av2); Partial(ZZy,tmp,AXIS_Y); Av2-=tmp; DotMul(Zn,Zn,tmp); Av2+=tmp; Av2+=2*alpha*alpha; DotMul(Zn,Zn,Z2); Partial(Z2,Z2x,AXIS_X); Partial(Z2,Z2y,AXIS_Y); for (int i = 0;i<height;i++) for (int j = 0;j<width;j++) Coe[i][j] = 1.0/(Au1[i][j]*Av2[i][j]-Au2[i][j]*Av1[i][j]); U = 0.0; V = 0.0; for (int iter_time = 0;iter_time<iterationTime;iter_time++) { V_old = V; U_old = U; Partial(U,Ux,AXIS_X); Partial(U,Uy,AXIS_Y); Partial(V,Vx,AXIS_X); Partial(V,Vy,AXIS_Y); Partial(Vx,Vxy,AXIS_Y); Partial(Ux,Uxy,AXIS_Y); Average(U,Uax,AXIS_X); Average(U,Uay,AXIS_Y); Average(V,Vax,AXIS_X); Average(V,Vay,AXIS_Y); DotMul(Z2x,Ux,Cu); DotMul(ZZy,Vx,tmp); Cu += tmp; tmp = ZZx*-1; tmp+=Z2x; DotMul(tmp,Vy,tmp1); Cu+=tmp1; tmp = Z2; tmp+=alpha*alpha; DotMul(tmp,Uax,tmp1); Cu+=tmp1; tmp1=Uay; tmp1*=alpha*alpha; Cu+=tmp1; DotMul(Z2,Vxy,tmp1); Cu+=tmp1; DotMul(Zx,Zt,tmp); Cu-=tmp; Cu+=ZZtx; DotMul(Z2y,Vy,Cv); DotMul(ZZx,Uy,tmp); Cv += tmp; tmp = ZZy; tmp*=-1; tmp+=Z2y; DotMul(tmp,Ux,tmp1); Cv+=tmp1; tmp = Z2; tmp+=alpha*alpha; DotMul(tmp,Vay,tmp1); Cv+=tmp1; tmp1=Vax; tmp1*=alpha*alpha; Cv+=tmp1; DotMul(Z2,Uxy,tmp1); Cv+=tmp1; DotMul(Zy,Zt,tmp); Cv-=tmp; Cv+=ZZty; for (int i = 0;i<height;i++) for (int j = 0;j<width;j++) { U[i][j] = Coe[i][j]*(Av2[i][j]*Cu[i][j]-Au2[i][j]*Cv[i][j]); V[i][j] = Coe[i][j]*(-Av1[i][j]*Cu[i][j]+Au1[i][j]*Cv[i][j]); } for (int i = 0;i<height;i++) { U[i][0] = U[i][1]; U[i][width-1] = U[i][width-2]; V[i][0] = V[i][1]; V[i][width-1] =V[i][width-2]; } for (int i = 0;i<width;i++) { U[0][i] = U[1][i]; U[height-1][i] = U[height-2][i]; V[0][i] = V[1][i]; V[height-1][i] =V[height-2][i]; } FILE* fp; // Au1.output("Au1.txt"); // Au2.output("Au2.txt"); // Av1.output("Av1.txt"); // Av2.output("Av2.txt"); // Cu.output("Cu.txt"); // Cv.output("Cv.txt"); float d1 = Difference(U,U_old); float d2 = Difference(V,V_old); // U.output("U.txt"); // U_old.output("U_old.txt"); // V.output("V.txt"); cout<<d1<<' '<<d2<<endl; if (d1<iterationTorlerance && d2<iterationTorlerance) break; } U.output("U.txt"); cv::Mat showV(height,width,CV_8UC3); float lowv=10000000,lowu=10000000,highu=-10000000,highv=-1000000; for(int j=0;j<height;j++){ for(int k=0;k<width;k++){ if(U[j][k]>highu) highu=U[j][k]; if(U[j][k]<lowu) lowu=U[j][k]; if(V[j][k]>highv) highv=V[j][k]; if(V[j][k]<lowv) lowv=V[j][k]; } } for(int j=0;j<height;j++){ for(int k=0;k<width;k++){ //printf("%d %d\n",j,k); //if(sfs_list[i][j][k]<low) // showH.at<uchar>(j,k)=0; //else float u=(U[j][k]-lowu)/(highu-lowu); float v=(V[j][k]-lowv)/(highv-lowv); if(u>0.5) showV.at<cv::Vec3b>(j,k)[2]=255; else showV.at<cv::Vec3b>(j,k)[2]=255*u; if(v>0.5){ showV.at<cv::Vec3b>(j,k)[0]=255; showV.at<cv::Vec3b>(j,k)[1]=255*(1-v); } else{ showV.at<cv::Vec3b>(j,k)[1]=255; showV.at<cv::Vec3b>(j,k)[0]=255*v; } } } cv::imwrite("testV.bmp",showV); printf("show you"); }