void paint_back (HDC hdc_scrn, RECT* m_rect, RECT *ptext) { HDC hdc = NULL; if (NULL == hdc_back) { unsigned grey_b = grey_value (mixcolors(&mStyle.MenuFrame)); unsigned grey_t = grey_value (mStyle.MenuFrame.TextColor); //dbg_printf("%d %d - #%06x #%06x", grey_b, grey_t, c1, c3); darkcolors = grey_b < grey_t; hdc = hdc_back = CreateCompatibleDC(hdc_scrn); m_hBitMap = CreateCompatibleBitmap(hdc_scrn, m_rect->right, m_rect->bottom); SelectObject(hdc_back, m_hBitMap); } draw_frame(hdc, m_rect, title_h, ptext); }
//--------------------------------------------------------------------------- float CalculateRules2(float hue, float saturation, float value, int color) { float ret_val,lower_sum=0; int RulesCounter=0; while (fuzzy_rules[RulesCounter].hue>=0) { /* if (do_grey_scale || (strcmp(fuzzy_rules[RulesCounter].color,"white") && strcmp(fuzzy_rules[RulesCounter].color,"light_grey") && strcmp(fuzzy_rules[RulesCounter].color,"dark_grey") && strcmp(fuzzy_rules[RulesCounter].color,"black"))) { */ if (fuzzy_rules[RulesCounter].color==color) /* calculate only rules of the same color */ { /* hue functions */ ret_val=color_value(fuzzy_rules[RulesCounter].hue,hue); if (ret_val==0) goto loop; /* saturation function */ if (fuzzy_rules[RulesCounter].saturation==SATURATION_GREY) ret_val=ret_val*grey_value(saturation); if (fuzzy_rules[RulesCounter].saturation==SATURATION_ALMOST_GREY) ret_val=ret_val*almost_grey_value(saturation); if (fuzzy_rules[RulesCounter].saturation==SATURATION_TEND_GREY) ret_val=ret_val*tend_grey_value(saturation); if (fuzzy_rules[RulesCounter].saturation==SATURATION_MEDIUM_GREY) ret_val=ret_val*medium_grey_value(saturation); if (fuzzy_rules[RulesCounter].saturation==SATURATION_TEND_CLEAR) ret_val=ret_val*tend_clear_value(saturation); if (fuzzy_rules[RulesCounter].saturation==SATURATION_CLEAR) ret_val=ret_val*clear_value(saturation); if (ret_val==0) goto loop; /* value functions */ if (fuzzy_rules[RulesCounter].value==VALUE_DARK) ret_val=ret_val*dark_value(value); if (fuzzy_rules[RulesCounter].value==VALUE_ALMOST_DARK) ret_val=ret_val*almost_dark_value(value); if (fuzzy_rules[RulesCounter].value==VALUE_TEND_DARK) ret_val=ret_val*tend_dark_value(value); if (fuzzy_rules[RulesCounter].value==VALUE_TEND_LIGHT) ret_val=ret_val*tend_light_value(value); if (fuzzy_rules[RulesCounter].value==VALUE_LIGHT) ret_val=ret_val*light_value(value); /* add the rule values */ lower_sum=lower_sum+ret_val; } loop: RulesCounter++; } return(lower_sum); }
/*----------------------------------------------------------------------------*/ void paint_window(HWND hwnd) { PAINTSTRUCT ps ; HFONT hfnt0; HDC hdc; int i,k,n,y,x; //int mm,yy; char bstr[256]; RECT rw, r; SIZE sz; #define MEMDC #ifdef MEMDC HBITMAP bm0,bm; HDC fhdc ; #endif #ifdef MEMDC fhdc = BeginPaint (hwnd, &ps); hdc = CreateCompatibleDC(fhdc); bm = CreateCompatibleBitmap(fhdc,cwx+FRM,cwy+FRM); bm0 = (HBITMAP)SelectObject(hdc,bm); #else hdc = BeginPaint(hwnd,&ps); #endif //goto pe; //fillpaint(&ps.rcPaint, Cbgd, hdc); GetClientRect(hwnd, &rw); paint_back(hdc, &rw, &r); BitBltRect(hdc, hdc_back, &ps.rcPaint); hfnt0 = (HFONT)SelectObject(hdc,hfnt_n); if (0!=synhilite) { memmove (My_Colors, darkcolors ? My_Colors_d : My_Colors_l, sizeof(My_Colors)); } My_Colors[0] = (COLORREF)-1; My_Colors[1] = mStyle.MenuFrame.TextColor; My_Colors[3] = mStyle.MenuHilite.TextColor; if (mStyle.MenuHilite.parentRelative) My_Colors[2] = grey_value (My_Colors[3]) > 128 ? 0x333333 : 0xeeeeee; else My_Colors[2] = mixcolors(&mStyle.MenuHilite); if (edp) { i=ps.rcPaint.top; k=ps.rcPaint.bottom; n=ps.rcPaint.right; i=(i-zy0)/zy; k=(k-zy0+zy-1)/zy; n=(n-zx0+zx-1)/zx; if (i<0) i=0; if (k<0) k=0; if (k>i && n>0) printpage(hdc,n,i,k); BitBlt(hdc, 0, rw.bottom-FRM, rw.right, FRM, hdc_back, 0, rw.bottom-FRM, SRCCOPY); BitBlt(hdc, rw.right-FRM, 0, FRM, rw.bottom, hdc_back, rw.right-FRM, 0, SRCCOPY); } SetTextColor (hdc, mStyle.MenuTitle.TextColor ); SetBkMode (hdc, TRANSPARENT); //SelectObject (hdc, hfnt_sb); SelectObject (hdc, fnt2); format_status(bstr,1); DrawText(hdc, bstr, strlen(bstr), &r, //mStyle.MenuTitle.justify|DT_VCENTER|DT_SINGLELINE DT_LEFT|DT_VCENTER|DT_SINGLELINE ); if (edp==NULL) goto paint_end; if (infomsg[0]) { SetBkColor (hdc, My_Colors[2]); SetTextColor (hdc, My_Colors[3]); SetBkMode (hdc,OPAQUE); SelectObject (hdc, fnt1); sprintf(bstr," %s ",infomsg); n=strlen(bstr); GetTextExtentPoint32 (hdc, bstr, n, &sz); y=cwy-sz.cy; x=cwx-sz.cx; if (x<0) x = 0; TextOut(hdc, x, y, bstr, n); } { StyleItem *pSI = &MenuInfo.Scroller; get_vscr_rect(&rw); MakeGradient_s(hdc, rw, pSI, pSI->bordered ? pSI->borderWidth : 0); } #if 0 if (lmax==0 && yy>=imin(tlin-plin,pgy) && mm>(pgx<50?pgx:pgx*6/5) ) lmax=mm; #endif paint_end: SelectObject (hdc, hfnt0); #ifdef MEMDC BitBltRect(fhdc, hdc, &ps.rcPaint); //BitBlt(fhdc,0,0,cwx+FRM,cwy+FRM,hdc,0,0,SRCCOPY); SelectObject (hdc, bm0); DeleteDC(hdc); DeleteObject (bm); #endif EndPaint (hwnd, &ps) ; if (edp && 0==scroll_lock && caret==1) ShowCaret(hwnd), caret=3; }