bool IGraphics::DrawIText(IText* pTxt, char* str, IRECT* pR) { if (!str || str[0] == '\0') { return true; } LICE_IFont* font = pTxt->mCached; if (!font) { font = CacheFont(pTxt); if (!font) return false; } LICE_pixel color = LiceColor(&pTxt->mColor); font->SetTextColor(color); UINT fmt = DT_NOCLIP; if (LICE_GETA(color) < 255) fmt |= LICE_DT_USEFGALPHA; if (pTxt->mAlign == IText::kAlignNear) fmt |= DT_LEFT; else if (pTxt->mAlign == IText::kAlignCenter) fmt |= DT_CENTER; else // if (pTxt->mAlign == IText::kAlignFar) fmt |= DT_RIGHT; RECT R = { pR->L, pR->T, pR->R, pR->B }; font->DrawText(mDrawBitmap, str, -1, &R, fmt); return true; }
LICE_pixel LICE_AlterColorHSV_int(LICE_pixel color, int dH, int dS, int dV) // H is rolled over [0,384), S and V are clamped [0,255) { int h, s, v; LICE_RGB2HSV(LICE_GETR(color), LICE_GETG(color), LICE_GETB(color), &h, &s, &v); h += dH; s += dS; v += dV; if (h < 0) h += 384; else if (h >= 384) h -= 384; if (s & ~255) { if (s<0) s = 0; else s = 255; } if (v&~255) { if (v < 0) v = 0.; else v = 255; } return LICE_HSV2Pix(h, s, v, LICE_GETA(color)); }
bool IGraphics::DrawIText(IText* pTxt, char* str, IRECT* pR, bool measure) { if (!str || str[0] == '\0') { return true; } LICE_IFont* font = pTxt->mCached; if (!font) { font = CacheFont(pTxt); if (!font) return false; } LICE_pixel color = LiceColor(&pTxt->mColor); font->SetTextColor(color); UINT fmt = DT_NOCLIP; if (LICE_GETA(color) < 255) fmt |= LICE_DT_USEFGALPHA; if (pTxt->mAlign == IText::kAlignNear) fmt |= DT_LEFT; else if (pTxt->mAlign == IText::kAlignCenter) fmt |= DT_CENTER; else // if (pTxt->mAlign == IText::kAlignFar) fmt |= DT_RIGHT; if (measure) { fmt |= DT_CALCRECT; RECT R = {0,0,0,0}; font->DrawText(mDrawBitmap, str, -1, &R, fmt); if( pTxt->mAlign == IText::kAlignNear) { pR->R = R.right; } else if (pTxt->mAlign == IText::kAlignCenter) { pR->L = (int) pR->MW() - (R.right/2); pR->R = pR->L + R.right; } else // (pTxt->mAlign == IText::kAlignFar) { pR->L = pR->R - R.right; pR->R = pR->L + R.right; } pR->B = pR->T + R.bottom; } else { RECT R = { pR->L, pR->T, pR->R, pR->B }; font->DrawText(mDrawBitmap, str, -1, &R, fmt); } return true; }
IColor IGraphics::GetPoint(int x, int y) { LICE_pixel pix = _LICE::LICE_GetPixel(mDrawBitmap, x, y); return IColor(LICE_GETA(pix), LICE_GETR(pix), LICE_GETG(pix), LICE_GETB(pix)); }
bool IGraphics::DrawIText(IText* pTxt, char* str, IRECT* pR, bool measure) { if (!str || str[0] == '\0') { return true; } LICE_IFont* font = pTxt->mCached; if (!font) { font = CacheFont(pTxt); if (!font) return false; } LICE_pixel color = LiceColor(&pTxt->mColor); font->SetTextColor(color); #ifdef OS_WIN UINT fmt = DT_NOCLIP; #else // OS X doesn't have an ellipsis option. So we need another way to prevent // the text from leaving the rectangle. UINT fmt = 0; #endif if (LICE_GETA(color) < 255) fmt |= LICE_DT_USEFGALPHA; if (pTxt->mAlign == IText::kAlignNear) fmt |= DT_LEFT; else if (pTxt->mAlign == IText::kAlignCenter) fmt |= DT_CENTER; else // if (pTxt->mAlign == IText::kAlignFar) fmt |= DT_RIGHT; // Crop text on Windows if too long if (!measure) { fmt |= DT_END_ELLIPSIS; } if (measure) { fmt |= DT_CALCRECT; RECT R = {0,0,0,0}; font->DrawText(mDrawBitmap, str, -1, &R, fmt); if( pTxt->mAlign == IText::kAlignNear) { pR->R = R.right; } else if (pTxt->mAlign == IText::kAlignCenter) { pR->L = (int) pR->MW() - (R.right/2); pR->R = pR->L + R.right; } else // (pTxt->mAlign == IText::kAlignFar) { pR->L = pR->R - R.right; pR->R = pR->L + R.right; } pR->B = pR->T + R.bottom; } else { RECT R = { pR->L, pR->T, pR->R, pR->B }; font->DrawText(mDrawBitmap, str, -1, &R, fmt); } return true; }
void LICE_AlterRectHSV(LICE_IBitmap* src, int x, int y, int w, int h, float dH, float dS, float dV) // H is rolled over, S and V are clamped { if (!src) return; if (x < 0) { w += x; x = 0; } if (y < 0) { h += y; y = 0; } if (x+w > src->getWidth()) { w = src->getWidth()-x; } if (y+h > src->getHeight()) { h = src->getHeight()-y; } int span = src->getRowSpan(); LICE_pixel* px = src->getBits()+y*span+x; int dHi = (int)(dH*384.0f); int dSi = (int)(dS*255.0f); int dVi = (int)(dV*255.0f); if (dHi > 383) dHi=383; else if (dHi < -383) dHi=-383; if (!dHi && !dSi && !dVi) return; // no mod if (w*h > 8192) { // generate a table of HSV translations with clip/clamp unsigned char stab[256], vtab[256]; short htab[384]; int x; for(x=0;x<256;x++) { int a=x+dSi; if(a<0)a=0; else if (a>255)a=255; stab[x]=a; a=x+dVi; if(a<0)a=0; else if (a>255)a=255; vtab[x]=a; a=x+dHi; if(a<0)a+=384; else if (a>=384)a-=384; htab[x]=a; } for(;x<384;x++) { int a=x+dHi; if(a<0)a+=384; else if (a>=384)a-=384; htab[x]=a; } while (h-->0) { LICE_pixel* tpx = px; px+=span; int xi=w; while (xi-->0) { LICE_pixel color = *tpx; int h,s,v; LICE_RGB2HSV(LICE_GETR(color), LICE_GETG(color), LICE_GETB(color), &h, &s, &v); *tpx++ = LICE_HSV2Pix(htab[h],stab[s],vtab[v],LICE_GETA(color)); } } } else { while (h-->0) { LICE_pixel* tpx = px; px+=span; int xi=w; while (xi-->0) *tpx++ = LICE_AlterColorHSV_int(*tpx, dHi, dSi, dVi); } } }
void WDL_VirtualStaticText::OnPaint(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect) { RECT r=m_position; r.left+=origin_x; r.right+=origin_x; r.top += origin_y; r.bottom += origin_y; if (m_bkbm && m_bkbm->bgimage) { WDL_VirtualWnd_ScaledBlitBG(drawbm,m_bkbm, r.left,r.top,r.right-r.left,r.bottom-r.top, r.left,r.top,r.right-r.left,r.bottom-r.top, 1.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA); if (m_dotint && LICE_GETA(m_bg)) { float amt = LICE_GETA(m_bg)/255.0f; // todo: apply amt float rv=LICE_GETR(m_bg)/255.0f; float gv=LICE_GETG(m_bg)/255.0f; float bv=LICE_GETB(m_bg)/255.0f; float avg=(rv+gv+bv)*0.33333f; if (avg<0.05f)avg=0.05f; float sc=0.5f*amt; float sc2 = (amt-sc)/avg; float sc3=32.0f * amt; float sc4=64.0f*(avg-0.5f) * amt; // tint LICE_MultiplyAddRect(drawbm, r.left,r.top, r.right-r.left, r.bottom-r.top, sc+rv*sc2 + (1.0f-amt), sc+gv*sc2 + (1.0f-amt), sc+bv*sc2 + (1.0f-amt), 1.0f, (rv-avg)*sc3+sc4, (gv-avg)*sc3+sc4, (bv-avg)*sc3+sc4, 0.0f); } } else { if (LICE_GETA(m_bg)) { LICE_FillRect(drawbm,r.left,r.top,r.right-r.left,r.bottom-r.top,m_bg,LICE_GETA(m_bg)/255.0f,LICE_BLIT_MODE_COPY); } if (m_wantborder) { int cidx=COLOR_3DSHADOW; int pencol = GSC(cidx); pencol = LICE_RGBA_FROMNATIVE(pencol,255); LICE_Line(drawbm,r.left,r.bottom-1,r.left,r.top,pencol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left,r.top,r.right-1,r.top,pencol,1.0f,LICE_BLIT_MODE_COPY,false); cidx=COLOR_3DHILIGHT; pencol = GSC(cidx); pencol = LICE_RGBA_FROMNATIVE(pencol,255); LICE_Line(drawbm,r.right-1,r.top,r.right-1,r.bottom-1,pencol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.right-1,r.bottom-1,r.left,r.bottom-1,pencol,1.0f,LICE_BLIT_MODE_COPY,false); r.left++; r.bottom--; r.top++; r.right--; } } if (m_text.Get()[0]) { r.left += m_margin_l; r.right -= m_margin_r; r.top += m_margin_t; r.bottom -= m_margin_b; m_didvert=m_vfont && (r.right-r.left)<(r.bottom-r.top)/2; LICE_IFont *font = m_didvert ? m_vfont : m_font; if (font) { font->SetBkMode(TRANSPARENT); m_didalign=m_align; if (m_didalign==0) { RECT r2={0,0,0,0}; font->DrawText(drawbm,m_text.Get(),-1,&r2,DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); if (m_didvert) { if (r2.bottom > r.bottom-r.top) m_didalign=-1; } else { if (r2.right > r.right-r.left) m_didalign=-1; } } int dtflags=DT_SINGLELINE|DT_NOPREFIX; if (m_didvert) { dtflags |= DT_CENTER; if (m_didalign < 0) dtflags |= DT_TOP; else if (m_didalign > 0) dtflags |= DT_BOTTOM; else dtflags |= DT_VCENTER; } else { dtflags|=DT_VCENTER; if (m_didalign < 0) dtflags |= DT_LEFT; else if (m_didalign > 0) dtflags |= DT_RIGHT; else dtflags |= DT_CENTER; } const char* txt=m_text.Get(); const int len = m_text.GetLength(); int abbrx=0; char abbrbuf[64]; abbrbuf[0]=0; if (m_wantabbr) { if (len && isdigit(txt[len-1])) { RECT tr = { 0, 0, 0, 0 }; font->DrawText(drawbm, txt, -1, &tr, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); if (m_didvert ? (tr.bottom > r.bottom-r.top) : (tr.right > r.right-r.left)) { strcpy(abbrbuf, ".."); int i; for (i=len-1; i >= 0; --i) { if (!isdigit(txt[i]) || len-i > 4) break; } strcat(abbrbuf, txt+i+1); int f=dtflags&~(DT_TOP|DT_VCENTER|DT_BOTTOM|DT_LEFT|DT_CENTER|DT_RIGHT); RECT tr2 = { 0, 0, 0, 0 }; if (m_didvert) { font->DrawText(drawbm, abbrbuf, -1, &tr2, f|DT_CALCRECT); abbrx=tr2.bottom; } else { font->DrawText(drawbm, abbrbuf, -1, &tr2, f|DT_CALCRECT); abbrx=tr2.right; } } } } int tcol=m_fg ? m_fg : LICE_RGBA_FROMNATIVE(GSC(COLOR_BTNTEXT)); font->SetTextColor(tcol); if (m_fg && LICE_GETA(m_fg) != 0xff) font->SetCombineMode(LICE_BLIT_MODE_COPY,LICE_GETA(m_fg)/255.0f); if (abbrx && abbrbuf[0]) { if (m_didvert) { int f=dtflags&~(DT_TOP|DT_VCENTER|DT_BOTTOM); RECT r1 = { r.left, r.top, r.right, r.bottom-abbrx }; font->DrawText(drawbm, txt, -1, &r1, f|DT_TOP); RECT r2 = { r.left, r.bottom-abbrx, r.right, r.bottom }; font->DrawText(drawbm, abbrbuf, -1, &r2, f|DT_BOTTOM); } else { int f=dtflags&~(DT_LEFT|DT_CENTER|DT_RIGHT); RECT r1 = { r.left, r.top, r.right-abbrx, r.bottom }; font->DrawText(drawbm, txt, -1, &r1, f|DT_LEFT); RECT r2 = { r.right-abbrx, r.top, r.right, r.bottom }; font->DrawText(drawbm, abbrbuf, -1, &r2, f|DT_RIGHT); } } else { font->DrawText(drawbm,txt,-1,&r,dtflags); } if (m_fg && LICE_GETA(m_fg) != 0xff) font->SetCombineMode(LICE_BLIT_MODE_COPY,1.0f); } } WDL_VWnd::OnPaint(drawbm,origin_x,origin_y,cliprect); }
void WDL_VirtualStaticText::OnPaint(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect) { RECT r=m_position; r.left+=origin_x; r.right+=origin_x; r.top += origin_y; r.bottom += origin_y; if (m_bkbm && m_bkbm->bgimage) { WDL_VirtualWnd_ScaledBlitBG(drawbm,m_bkbm, r.left,r.top,r.right-r.left,r.bottom-r.top, r.left,r.top,r.right-r.left,r.bottom-r.top, 1.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA); if (m_dotint && LICE_GETA(m_bg)) { float amt = LICE_GETA(m_bg)/255.0f; // todo: apply amt float rv=LICE_GETR(m_bg)/255.0f; float gv=LICE_GETG(m_bg)/255.0f; float bv=LICE_GETB(m_bg)/255.0f; float avg=(rv+gv+bv)*0.33333f; if (avg<0.05f)avg=0.05f; float sc=0.5f*amt; float sc2 = (amt-sc)/avg; float sc3=32.0f * amt; float sc4=64.0f*(avg-0.5f) * amt; // tint LICE_MultiplyAddRect(drawbm, r.left,r.top, r.right-r.left, r.bottom-r.top, sc+rv*sc2 + (1.0-amt), sc+gv*sc2 + (1.0-amt), sc+bv*sc2 + (1.0-amt), 1, (rv-avg)*sc3+sc4, (gv-avg)*sc3+sc4, (bv-avg)*sc3+sc4, 0); } } else { if (LICE_GETA(m_bg)) { LICE_FillRect(drawbm,r.left,r.top,r.right-r.left,r.bottom-r.top,m_bg,LICE_GETA(m_bg)/255.0f,LICE_BLIT_MODE_COPY); } if (m_wantborder) { int cidx=COLOR_3DSHADOW; int pencol = WDL_STYLE_GetSysColor(cidx); pencol = LICE_RGBA_FROMNATIVE(pencol,255); LICE_Line(drawbm,r.left,r.bottom-1,r.left,r.top,pencol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left,r.top,r.right-1,r.top,pencol,1.0f,LICE_BLIT_MODE_COPY,false); cidx=COLOR_3DHILIGHT; pencol = WDL_STYLE_GetSysColor(cidx); pencol = LICE_RGBA_FROMNATIVE(pencol,255); LICE_Line(drawbm,r.right-1,r.top,r.right-1,r.bottom-1,pencol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.right-1,r.bottom-1,r.left,r.bottom-1,pencol,1.0f,LICE_BLIT_MODE_COPY,false); r.left++; r.bottom--; r.top++; r.right--; } } if (m_text.Get()[0]) { r.left += m_margin_l; r.right -= m_margin_r; r.top += m_margin_t; r.bottom -= m_margin_b; m_didvert=m_vfont && (r.right-r.left)<(r.bottom-r.top); LICE_IFont *font = m_didvert ? m_vfont : m_font; if (font) { font->SetBkMode(TRANSPARENT); m_didalign=m_align; if (m_didalign==0) { RECT r2={0,0,0,0}; font->DrawText(drawbm,m_text.Get(),-1,&r2,DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX|DT_CALCRECT); if (r2.right > r.right-r.left) m_didalign=-1; } int tcol=m_fg ? m_fg : LICE_RGBA_FROMNATIVE(WDL_STYLE_GetSysColor(COLOR_BTNTEXT)); font->SetTextColor(tcol); if (m_fg && LICE_GETA(m_fg) != 0xff) font->SetCombineMode(LICE_BLIT_MODE_COPY,LICE_GETA(m_fg)/255.0f); font->DrawText(drawbm,m_text.Get(),-1,&r,DT_SINGLELINE|DT_VCENTER|(m_didalign<0?DT_LEFT:m_didalign>0?DT_RIGHT:DT_CENTER)|DT_NOPREFIX); if (m_fg && LICE_GETA(m_fg) != 0xff) font->SetCombineMode(LICE_BLIT_MODE_COPY,1.0f); } } WDL_VWnd::OnPaint(drawbm,origin_x,origin_y,cliprect); }
int WDL_VirtualSlider::OnMouseDown(int xpos, int ypos) { if (m_grayed) return false; m_needflush=0; if (m__iaccess) m__iaccess->OnFocused(); bool isVert = GetIsVert(); int rsize=m_maxr-m_minr; if (rsize<1)rsize=1; int viewh=m_position.bottom-m_position.top; int vieww=m_position.right-m_position.left; if (vieww<1) vieww=1; if (viewh<1) viewh=1; LICE_IBitmap *bm_image=m_skininfo ? m_skininfo->thumbimage[isVert] : 0; int bm_w=16,bm_h=16; bool wantKnob=false; if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); AdjustThumbImageSize(vieww,viewh,m_skininfo,isVert,&bm_w,&bm_h,NULL,&wantKnob,m_knobbias); } else { bm_image=WDL_STYLE_GetSliderBitmap2(isVert); if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); } AdjustThumbImageSize(vieww,viewh,NULL,isVert,&bm_w,&bm_h,NULL,&wantKnob,m_knobbias); } m_is_knob = wantKnob; m_last_y=ypos; m_last_x=xpos; m_last_precmode=0; bool needsendcmd = m_sendmsgonclick; if (m_is_knob) { m_move_offset=0; m_click_pos=m_pos; } else if (isVert) { m_move_offset=ypos-( viewh - bm_h - ((double)((m_pos-m_minr) * (viewh-bm_h))/(double)rsize)); m_click_pos=m_pos; if (!m_is_knob && (m_move_offset < 0 || m_move_offset >= bm_h)) { int xcent=xpos - vieww/2; bool hit; if (m_skininfo && m_skininfo->bgimagecfg[1].bgimage) { LICE_pixel pix=WDL_VirtualWnd_ScaledBG_GetPix(&m_skininfo->bgimagecfg[1], vieww,viewh,xpos,ypos); hit = LICE_GETA(pix)>=64; } else hit= (xcent >= -2 && xcent < 3 && ypos >= bm_h/3 && ypos <= viewh-bm_h/3); if (hit) { m_move_offset=bm_h/2; int pos=m_minr+((viewh-bm_h - (ypos-m_move_offset))*rsize)/(viewh-bm_h); if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; m_pos=pos; needsendcmd=false; WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_VSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } else return false; } } else { m_move_offset=xpos-( ((double)((m_pos-m_minr) * (vieww-bm_w))/(double)rsize)); m_click_pos=m_pos; if (m_move_offset < 0 || m_move_offset >= bm_w) { int ycent=ypos - viewh/2; bool hit; if (m_skininfo && m_skininfo->bgimagecfg[0].bgimage) { LICE_pixel pix=WDL_VirtualWnd_ScaledBG_GetPix(&m_skininfo->bgimagecfg[0], vieww,viewh,xpos,ypos); hit = LICE_GETA(pix)>=64; } else hit = (ycent >= -2 && ycent < 3 && xpos >= bm_w/3 && xpos <= vieww-bm_w/3); if (hit) { m_move_offset=bm_w/2; int pos=m_minr+((xpos-m_move_offset)*rsize)/(vieww-bm_w); if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; m_pos=pos; needsendcmd=false; WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_HSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } else return false; } } m_captured=true; if (needsendcmd) { WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_VSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK() && m__iaccess) m__iaccess->OnStateChange(); } return 1; }
void WDL_VirtualSlider::OnPaint(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect) { origin_x += m_position.left; // convert drawing origin to local coords origin_y += m_position.top; bool isVert = GetIsVert(); int rsize=m_maxr-m_minr; if (rsize<1)rsize=1; int viewh=m_position.bottom-m_position.top; int vieww=m_position.right-m_position.left; WDL_VirtualWnd_BGCfg *back_image=m_skininfo && m_skininfo->bgimagecfg[isVert].bgimage ? &m_skininfo->bgimagecfg[isVert] : 0; LICE_IBitmap *bm_image=m_skininfo ? m_skininfo->thumbimage[isVert] : 0; int bm_w=16,bm_h=16,bm_w2=16,bm_h2=16; int imgoffset=0; HBITMAP bm=0; bool wantKnob=false; if (bm_image) { bm_w2=bm_w=bm_image->getWidth(); bm_h2=bm_h=bm_image->getHeight(); AdjustThumbImageSize(vieww,viewh,m_skininfo,isVert,&bm_w2,&bm_h2,&imgoffset,&wantKnob,m_knobbias); } else { bm_image=WDL_STYLE_GetSliderBitmap2(isVert); if (bm_image) { bm_w2=bm_w=bm_image->getWidth(); bm_h2=bm_h=bm_image->getHeight(); } AdjustThumbImageSize(vieww,viewh,NULL,isVert,&bm_w2,&bm_h2,&imgoffset,&wantKnob,m_knobbias); } float alpha = (m_grayed ? 0.25f : 1.0f); m_is_knob = wantKnob; if (isVert||wantKnob) { int pos = ((m_maxr-m_pos)*(viewh-bm_h2))/rsize; //viewh - bm_h2 - ((m_pos-m_minr) * (viewh - bm_h2))/rsize; if (wantKnob) { int sz= min(vieww,viewh); origin_x += (vieww-sz)/2; origin_y += (viewh-sz)/2; vieww = viewh = sz; back_image = m_knobbg[sz>28]; if (back_image && !back_image->bgimage) back_image=NULL; } if (back_image) { WDL_VirtualWnd_ScaledBlitBG(drawbm,back_image, origin_x,origin_y,vieww,viewh, origin_x,origin_y,vieww,viewh, 1.0f,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA); if (m_bgcol1_msg) { int brcol=-100; SendCommand(m_bgcol1_msg,(INT_PTR)&brcol,GetID(),this); if (brcol != -100) { static LICE_MemBitmap tmpbm;//not threadsafe tmpbm.resize(vieww,viewh); WDL_VirtualWnd_ScaledBlitBG(&tmpbm,back_image,0,0,vieww,viewh, 0,0,vieww,viewh,1.0f,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); LICE_ClearRect(&tmpbm,0,0,vieww,viewh,LICE_RGBA(0,0,0,255),LICE_RGBA(GetRValue(brcol),GetGValue(brcol),GetBValue(brcol),0)); RECT r={0,0,vieww,viewh}; LICE_Blit(drawbm,&tmpbm,origin_x,origin_y,&r,0.5,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); } } } if (!wantKnob) { int zlc = m_zl_color; if (!zlc && m_skininfo) zlc = m_skininfo->zeroline_color; if (!back_image || zlc) { int center=m_center; if (center < 0) center=WDL_STYLE_GetSliderDynamicCenterPos(); int y=((m_maxr-center)*(viewh-bm_h2))/rsize + ((bm_h-1)/2-imgoffset); if (!zlc) zlc = LICE_RGBA_FROMNATIVE(GSC(COLOR_BTNTEXT),255); LICE_Line(drawbm,origin_x+2,origin_y+y,origin_x+vieww-2,origin_y+y, zlc, LICE_GETA(zlc)/255.0, LICE_BLIT_MODE_COPY,false); } if (!back_image) { LICE_pixel fgcol = GSC(COLOR_3DHILIGHT); fgcol = LICE_RGBA_FROMNATIVE(fgcol,255); LICE_pixel bgcol=GSC(COLOR_3DSHADOW); if (m_bgcol1_msg) SendCommand(m_bgcol1_msg,(INT_PTR)&bgcol,GetID(),this); bgcol = LICE_RGBA_FROMNATIVE(bgcol,255); int offs= (vieww - 4)/2; // white with black border, mmm RECT r={origin_x + offs,origin_y + bm_h2/3, origin_x + offs + 5,origin_y + viewh - bm_h2/3}; LICE_FillRect(drawbm,r.left+1,r.top+1, r.right-r.left-2,r.bottom-r.top-2,bgcol,1.0f,LICE_BLIT_MODE_COPY); LICE_Line(drawbm,r.left+1,r.top,r.right-2,r.top,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left+1,r.bottom-1,r.right-2,r.bottom-1,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left,r.top+1,r.left,r.bottom-2,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.right-1,r.top+1,r.right-1,r.bottom-2,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); } if (bm_image) { int ypos=origin_y+pos-imgoffset; int xpos=origin_x; RECT r={0,0,bm_w2,bm_h}; /* if (vieww<bm_w) { r.left=(bm_w-vieww)/2; r.right=r.left+vieww; } else */ xpos+=(vieww-bm_w2)/2; m_tl_extra=origin_y-ypos; if (m_tl_extra<0)m_tl_extra=0; m_br_extra=ypos+(r.bottom-r.top) - (origin_y+m_position.bottom-m_position.top); if (m_br_extra<0)m_br_extra=0; LICE_Blit(drawbm,bm_image,xpos,ypos,&r,alpha,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); } } else { LICE_pixel col = m_knob_color ? m_knob_color : LICE_RGBA_FROMNATIVE(GSC(COLOR_3DHILIGHT),255); float alpha = LICE_GETA(col)/255.0f; int cx=origin_x+vieww/2; int cy=origin_y+viewh/2; float rd = vieww/2-4 + m_knob_lineextrasize; float r2=rd*0.125f; if (!back_image) LICE_Circle(drawbm, cx, cy, rd, col, alpha, LICE_BLIT_MODE_COPY, true); float val; int center=m_center; if (center < 0) center=WDL_STYLE_GetSliderDynamicCenterPos(); if (center > m_minr && (m_pos < center || center >= m_maxr)) val = (m_pos-center) / (double)(center-m_minr); else val = (m_pos-center) / (double)(m_maxr-center); #define KNOBANGLE_MAX (3.14159*7.0/8.0); float a = val*KNOBANGLE_MAX; float sina=sin(a); float cosa=cos(a); float x1=cx+r2*sina; float y1=cy-r2*cosa; float x2=cx+rd*sina; float y2=cy-rd*cosa; LICE_FLine(drawbm, x1, y1, x2, y2, col, alpha, LICE_BLIT_MODE_COPY, true); } } else { int pos = ((m_pos-m_minr) * (vieww - bm_w2))/rsize; if (back_image) { WDL_VirtualWnd_ScaledBlitBG(drawbm,back_image, origin_x,origin_y,vieww,viewh, origin_x,origin_y,vieww,viewh, 1.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA); // blit, tint color too? if (m_bgcol1_msg) { int brcol=-100; SendCommand(m_bgcol1_msg,(INT_PTR)&brcol,GetID(),this); if (brcol != -100) { static LICE_MemBitmap tmpbm; //not threadsafe tmpbm.resize(vieww,viewh); WDL_VirtualWnd_ScaledBlitBG(&tmpbm,back_image,0,0,vieww,viewh, 0,0,vieww,viewh,1.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); LICE_ClearRect(&tmpbm,0,0,vieww,viewh,LICE_RGBA(0,0,0,255),LICE_RGBA(GetRValue(brcol),GetGValue(brcol),GetBValue(brcol),0)); RECT r={0,0,vieww,viewh}; LICE_Blit(drawbm,&tmpbm,origin_x,origin_y,&r,0.5,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); } } } int zlc = m_zl_color; if (!zlc && m_skininfo) zlc = m_skininfo->zeroline_color; if (!back_image || zlc) { int center=m_center; if (center < 0) center=WDL_STYLE_GetSliderDynamicCenterPos(); int x=((center-m_minr)*(vieww-bm_w2))/rsize + bm_w/2 - imgoffset; if (!zlc) zlc = LICE_RGBA_FROMNATIVE(GSC(COLOR_BTNTEXT),255); LICE_Line(drawbm,origin_x+x,origin_y+2,origin_x+x,origin_y+viewh-2, zlc, LICE_GETA(zlc)/255.0, LICE_BLIT_MODE_COPY,false); } if (!back_image) { LICE_pixel fgcol = GSC(COLOR_3DHILIGHT); fgcol = LICE_RGBA_FROMNATIVE(fgcol,255); LICE_pixel bgcol=GSC(COLOR_3DSHADOW); if (m_bgcol1_msg) SendCommand(m_bgcol1_msg,(INT_PTR)&bgcol,GetID(),this); bgcol = LICE_RGBA_FROMNATIVE(bgcol,255); int offs= (viewh - 4)/2; // white with black border, mmm RECT r={origin_x + bm_w2/3,origin_y + offs, origin_x + vieww - bm_w2/3,origin_y + offs + 5}; LICE_FillRect(drawbm,r.left+1,r.top+1, r.right-r.left-2,r.bottom-r.top-2,bgcol,1.0f,LICE_BLIT_MODE_COPY); LICE_Line(drawbm,r.left+1,r.top,r.right-2,r.top,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left+1,r.bottom-1,r.right-2,r.bottom-1,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.left,r.top+1,r.left,r.bottom-2,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); LICE_Line(drawbm,r.right-1,r.top+1,r.right-1,r.bottom-2,fgcol,1.0f,LICE_BLIT_MODE_COPY,false); } if (bm_image) { int xpos=origin_x+pos-imgoffset; int ypos=origin_y; RECT r={0,0,bm_w,bm_h2}; /*if (viewh<bm_h) { r.top=(bm_h-viewh)/2; r.bottom=r.top+viewh; } else */ ypos+=(viewh-bm_h2)/2; m_tl_extra=origin_x-xpos; if (m_tl_extra<0)m_tl_extra=0; m_br_extra=xpos+(r.right-r.left) - (origin_x+m_position.right-m_position.left); if (m_br_extra<0)m_br_extra=0; /* if (xpos < origin_x) { r.left += (origin_x-xpos); xpos=origin_x; } if (xpos+(r.right-r.left) > origin_x+m_position.right-m_position.left) r.right = origin_x+m_position.right-m_position.left - (xpos-r.left); */ LICE_Blit(drawbm,bm_image,xpos,ypos,&r,alpha,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); } } }