static void draw_scroll_button (HWND hWnd, HDC hdc, RECT *title_rc, PPROPSHEETDATA propsheet, DWORD style) { RECT btn_rect = {0, 0, 0, 0}; int l, r, t, b; btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->top + 1 : title_rc->top; btn_rect.right = GetMainWinMetrics (MWM_SB_WIDTH) - 4; btn_rect.bottom = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->bottom + 2: title_rc->bottom - 2; t = btn_rect.top + 5; r = btn_rect.right; b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 7 : btn_rect.bottom - 4; SelectClipRect (hdc, &btn_rect); SetBrushColor (hdc, GetWindowBkColor (hWnd)); FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right + 3, btn_rect.bottom); SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK)); for ( ; t <= b; r--, t++, b--) { MoveTo (hdc, r, t); LineTo (hdc, r, b); } btn_rect.left = propsheet->head_rc.right - GetMainWinMetrics(MWM_SB_WIDTH); //btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.top - 1 : btn_rect.top; l = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.left + 5 : btn_rect.left + 4; r = btn_rect.right = propsheet->head_rc.right; b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 8 : btn_rect.bottom - 5; t = btn_rect.top + 6; SelectClipRect (hdc, &btn_rect); SetBrushColor (hdc, GetWindowBkColor (hWnd)); FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right, btn_rect.bottom); SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK)); for ( ; t <= b; l++, t++, b--) { MoveTo (hdc, l, t); LineTo (hdc, l, b); } }
static void this_paint_desktop(void* context, HDC dc_desktop, const RECT* inv_rc) { PBITMAP bg_bmp = NULL; int i = 0; DSPITEM* item; if(((Context *)context)->bg) bg_bmp = ((Context *)context)->bg; SelectClipRect (dc_desktop, inv_rc); if (bg_bmp) { FillBoxWithBitmap (dc_desktop, 0, 0, g_rcDesktop.right, g_rcDesktop.bottom, bg_bmp); }else { SetBrushColor (dc_desktop, PIXEL_blue); FillBox(dc_desktop, g_rcDesktop.left, g_rcDesktop.top, RECTW(g_rcDesktop), RECTH(g_rcDesktop)); } item = icon_info.app_items; for(i = 0; i < icon_info.nr_apps; i++, item++) { if(i == icon_info.focus) { SetBrushColor (dc_desktop, PIXEL_darkblue); FillBox(dc_desktop, item->hot_spot_rc.left, item->hot_spot_rc.top, RECTW(item->hot_spot_rc), RECTH(item->hot_spot_rc)); } FillBoxWithBitmap (dc_desktop, item->hot_spot_rc.left, item->hot_spot_rc.top, RECTW(item->hot_spot_rc), RECTH(item->hot_spot_rc), &item->bmp); SetBkMode(dc_desktop, BM_TRANSPARENT); TextOut(dc_desktop, item->text_rc.left, item->text_rc.top, item->name); } }
static void pbarOnDraw (HWND hwnd, HDC hdc, PROGRESSDATA* pData, BOOL fVertical) { RECT rcClient; int x, y, w, h; ldiv_t ndiv_progress; unsigned int nAllPart; unsigned int nNowPart; int whOne, nRem; int ix, iy; int i; int step; if (pData->nMax == pData->nMin) return; if ((pData->nMax - pData->nMin) > 5) step = 5; else step = 1; GetClientRect (hwnd, &rcClient); x = rcClient.left + WIDTH_PBAR_BORDER; y = rcClient.top + WIDTH_PBAR_BORDER; w = RECTW (rcClient) - (WIDTH_PBAR_BORDER << 1); h = RECTH (rcClient) - (WIDTH_PBAR_BORDER << 1); ndiv_progress = ldiv (pData->nMax - pData->nMin, step); nAllPart = ndiv_progress.quot; ndiv_progress = ldiv (pData->nPos - pData->nMin, step); nNowPart = ndiv_progress.quot; if (fVertical) ndiv_progress = ldiv (h, nAllPart); else ndiv_progress = ldiv (w, nAllPart); whOne = ndiv_progress.quot; nRem = ndiv_progress.rem; SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL)); if (whOne >= 4) { if (fVertical) { for (i = 0, iy = y + h - 1; i < nNowPart; ++i) { if ((iy - whOne) < y) whOne = iy - y; FillBox (hdc, x + 1, iy - whOne, w - 2, whOne - 1); iy -= whOne; if(nRem > 0) { iy --; nRem --; } } } else { for (i = 0, ix = x + 1; i < nNowPart; ++i) { if ((ix + whOne) > (x + w)) whOne = x + w - ix; FillBox (hdc, ix, y + 1, whOne - 1, h - 2); ix += whOne; if(nRem > 0) { ix ++; nRem --; } } } } else { // no vertical support double d = (nNowPart*1.0)/nAllPart; if (fVertical) { int prog = (int)(h*d); FillBox (hdc, x + 1, rcClient.bottom - WIDTH_PBAR_BORDER - prog, w - 2, prog); } else { char szText[8]; SIZE text_ext; RECT rc_clip = rcClient; int prog = (int)(w*d); FillBox (hdc, x, y + 1, (int)(w*d), h - 2); SetBkMode (hdc, BM_TRANSPARENT); sprintf (szText, "%.0f%%", (d*100)); GetTextExtent (hdc, szText, -1, &text_ext); x += ((w - text_ext.cx) >> 1); y += ((h - text_ext.cy) >> 1); rc_clip.right = prog; SelectClipRect (hdc, &rc_clip); SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_HILIGHT_NORMAL)); SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL)); TextOut (hdc, x, y, szText); rc_clip.right = rcClient.right; rc_clip.left = prog; SelectClipRect (hdc, &rc_clip); SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL)); SetBkColor (hdc, GetWindowBkColor (hwnd)); TextOut (hdc, x, y, szText); } } }
/* re-draw */ static void draw_propsheet (HWND hwnd, HDC hdc, PCONTROL ctrl, PPROPSHEETDATA propsheet, PPROPPAGE page) { int x, ty, by, text_extent; RECT title_rc = {0, 0, 1, 0}; title_rc.bottom = propsheet->head_rc.bottom; if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { title_rc.top = propsheet->head_rc.top; } /* Draw the content window */ #ifdef _FLAT_WINDOW_STYLE if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { DrawFlatControlFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 1 , 1, DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0); } else { DrawFlatControlFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2, propsheet->head_rc.right, ctrl->bottom - ctrl->top, 1, DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0); } #else if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { Draw3DThickFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 2 , DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0); } else { Draw3DThickFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2, propsheet->head_rc.right, ctrl->bottom - ctrl->top, DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0); } #endif SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF)); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { FillBox (hdc, 0, propsheet->head_rc.top + 1, propsheet->head_rc.right, propsheet->head_rc.bottom ); }else { FillBox (hdc, 0, 0, propsheet->head_rc.right, propsheet->head_rc.bottom - 2); } /* Just for PSS_SCROLLABLE style if title is overload (too many titles for the propsheet) we should move-right the leftmot title some pixel and we should draw a small icon (left arrow) for the sheet */ if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) { title_rc.right = (propsheet->overload == TRUE) ? title_rc.right + GetMainWinMetrics (MWM_SB_WIDTH) : title_rc.right; } while (page) { SIZE size; int eff_chars, eff_len; /* draw some box for title */ if (title_rc.right == 1) title_rc.left = title_rc.right - 1; else title_rc.left = title_rc.right; title_rc.right = title_rc.left + page->width; SelectClipRect (hdc, &title_rc); x = title_rc.left + _ICON_OFFSET; ty = title_rc.top; if (page != propsheet->active) { /* bottom tab or top tab */ if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { ty -= 2; by = title_rc.bottom - 2; } else { ty += 2; by = title_rc.bottom; } } else { by = title_rc.bottom ; FillBox (hdc, title_rc.left+1, ty, title_rc.right - title_rc.left, by); } /* draw the title's edge */ /* pc3d style & flat & grap */ SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER)); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { MoveTo (hdc, title_rc.left, ty); LineTo (hdc, title_rc.left, by - 1); LineTo (hdc, title_rc.right, by - 1); } else { MoveTo (hdc, title_rc.left, by - 1); LineTo (hdc, title_rc.left, ty); LineTo (hdc, title_rc.right, ty); } SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_RIGHT_OUTER)); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { if (page != propsheet->active) { MoveTo (hdc, title_rc.left + 1, ty + 3); } else { MoveTo (hdc, title_rc.left + 1, ty - 2); } LineTo (hdc, title_rc.left + 1, by - 2); LineTo (hdc, title_rc.right - 1, by - 2); } else { if (page != propsheet->active) { MoveTo (hdc, title_rc.left + 1, by - 2); } else { MoveTo (hdc, title_rc.left + 1, by); } LineTo (hdc, title_rc.left + 1, ty + 1); LineTo (hdc, title_rc.right - 1, ty + 1); } SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER)); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { MoveTo (hdc, title_rc.right - 1, by -1); LineTo (hdc, title_rc.right - 1, ty); }else { if (!page->next && (title_rc.right == propsheet->head_rc.right)) { MoveTo (hdc, title_rc.right - 2, ty ); LineTo (hdc, title_rc.right - 2, by - 1); SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_OUTER)); MoveTo (hdc, title_rc.right -1, ty ); LineTo (hdc, title_rc.right -1, by - 1); } else { MoveTo (hdc, title_rc.right - 1, ty ); LineTo (hdc, title_rc.right - 1, by - 1); } } /* draw the ICON */ ty += _ICON_OFFSET + 2; text_extent = RECTW (title_rc) - _ICON_OFFSET * 2; if (page->icon) { DrawIcon (hdc, x, ty, GetMainWinMetrics (MWM_ICONX), GetMainWinMetrics (MWM_ICONY), page->icon); x += GetMainWinMetrics (MWM_ICONX); x += _GAP_ICON_TEXT; text_extent -= GetMainWinMetrics (MWM_ICONX) + _GAP_ICON_TEXT; } /* draw the TEXT */ /* #if defined(_FLAT_WINDOW_STYLE) && !defined(_GRAY_SCREEN) */ #ifdef _FLAT_WINDOW_STYLE if (page != propsheet->active) { SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_DISABLED)); } else { SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL)); } #else SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF)); #endif text_extent -= 4; eff_len = GetTextExtentPoint (hdc, page->title, strlen(page->title), text_extent, &eff_chars, NULL, NULL, &size); TextOutLen (hdc, x + 2, ty, page->title, eff_len); page = page->next; } /* draw scroll button , just for PSS_SCROLLABLE style */ if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE && propsheet->overload == TRUE) { draw_scroll_button (hwnd, hdc, &title_rc, propsheet, ctrl->dwStyle); } }