📄 window.c
字号:
pWin->bottom - pWin->top - 1); }}// this function is CONTROL safe.static void wndDrawScrollBar (MAINWIN* pWin, HDC hdc){ int start = 0; RECT rcHBar, rcVBar, rcSlider; PBITMAP bmp; int xo, yo, bw, bh; wndGetVScrollBarRect (pWin, &rcVBar); rcVBar.left -= pWin->left; rcVBar.top -= pWin->top; rcVBar.right -= pWin->left; rcVBar.bottom -= pWin->top; wndGetHScrollBarRect (pWin, &rcHBar); rcHBar.left -= pWin->left; rcHBar.top -= pWin->top; rcHBar.right -= pWin->left; rcHBar.bottom -= pWin->top; bmp = GetSystemBitmap (SYSBMP_ARROWS); bw = bmp->bmWidth >> 2; bh = bmp->bmHeight >> 1; if ((pWin->dwStyle & WS_HSCROLL) && (pWin->dwStyle & WS_VSCROLL) && !(pWin->hscroll.status & SBS_HIDE && pWin->vscroll.status & SBS_HIDE)) { /* Always erase the bottom-right corner */#ifdef _FLAT_WINDOW_STYLE SetBrushColor (hdc, PIXEL_lightwhite);#else SetBrushColor (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF));#endif FillBox (hdc, rcVBar.left, rcHBar.top, RECTW (rcVBar), RECTH (rcHBar)); } if (pWin->dwStyle & WS_HSCROLL && !(pWin->hscroll.status & SBS_HIDE) && RectVisible (hdc, &rcHBar)) { /* draw left and right buttons. */ if (pWin->hscroll.status & SBS_DISABLED) { xo = bw << 1; yo = bh; } else { xo = bw << 1; yo = 0; } FillBoxWithBitmapPart (hdc, rcHBar.left, rcHBar.top, bw, bh, 0, 0, bmp, xo, yo); if (pWin->hscroll.status & SBS_DISABLED) { xo = (bw << 1) + bw; yo = bh; } else { xo = (bw << 1) + bw; yo = 0; } FillBoxWithBitmapPart (hdc, rcHBar.right - GetMainWinMetrics (MWM_CXHSCROLL), rcHBar.top, bw, bh, 0, 0, bmp, xo, yo); /* draw slider. */ start = rcHBar.left + GetMainWinMetrics (MWM_CXHSCROLL) + pWin->hscroll.barStart; if (start + pWin->hscroll.barLen > rcHBar.right) start = rcHBar.right - pWin->hscroll.barLen; rcSlider.left = start; rcSlider.top = rcHBar.top; rcSlider.right = start + pWin->hscroll.barLen; rcSlider.bottom = rcHBar.bottom;#ifdef _FLAT_WINDOW_STYLE SetBrushColor (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF)); FillBox (hdc, start + 1, rcHBar.top + 1, pWin->hscroll.barLen - 2, RECTH (rcHBar) - 1); SetPenColor (hdc, PIXEL_black); Rectangle (hdc, rcSlider.left, rcSlider.top, rcSlider.right - 1, rcSlider.bottom); xo = (rcSlider.left + rcSlider.right) >> 1; MoveTo (hdc, xo, rcSlider.top + 2); LineTo (hdc, xo, rcSlider.bottom - 1); MoveTo (hdc, xo - 2, rcSlider.top + 3); LineTo (hdc, xo - 2, rcSlider.bottom - 2); MoveTo (hdc, xo + 2, rcSlider.top + 3); LineTo (hdc, xo + 2, rcSlider.bottom - 2); SetPenColor (hdc, PIXEL_black); Rectangle (hdc, rcHBar.left - 1, rcHBar.top, rcHBar.right, rcHBar.bottom);#elif defined(_PHONE_WINDOW_STYLE) DrawBoxFromBitmap (hdc, &rcSlider, GetSystemBitmap (SYSBMP_SCROLLBAR_HSLIDER), TRUE, FALSE);#else Draw3DThickFrameEx (hdc, (HWND)pWin, rcSlider.left, rcHBar.top, rcSlider.right, rcHBar.bottom, DF_3DBOX_NORMAL | DF_3DBOX_FILL, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF));#endif rcHBar.left += GetMainWinMetrics (MWM_CXHSCROLL); rcHBar.right -= GetMainWinMetrics (MWM_CXHSCROLL); /* Exclude the rect of slider */ ExcludeClipRect (hdc, &rcSlider); /* Draw back bar */#ifdef _FLAT_WINDOW_STYLE SetBrushColor (hdc, PIXEL_lightwhite); FillBox (hdc, rcHBar.left + 1, rcHBar.top + 1, RECTW(rcHBar) - 1, RECTH (rcHBar) - 1);#elif defined(_PHONE_WINDOW_STYLE) DrawBoxFromBitmap (hdc, &rcHBar, GetSystemBitmap (SYSBMP_SCROLLBAR_HBG), TRUE, FALSE);#else SetBrushColor (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF)); FillBox (hdc, rcHBar.left, rcHBar.top, RECTW(rcHBar), RECTH (rcHBar));#endif } if (pWin->dwStyle & WS_VSCROLL && !(pWin->vscroll.status & SBS_HIDE) && RectVisible (hdc, &rcVBar)) { /* draw top and bottom arrow buttons. */ if (pWin->vscroll.status & SBS_DISABLED) { xo = 0; yo = bh; } else { xo = 0; yo = 0; } FillBoxWithBitmapPart (hdc, rcVBar.left, rcVBar.top, bw, bh, 0, 0, bmp, xo, yo); if (pWin->vscroll.status & SBS_DISABLED) { xo = bw; yo = bh; } else { xo = bw; yo = 0; } FillBoxWithBitmapPart (hdc, rcVBar.left, rcVBar.bottom - GetMainWinMetrics (MWM_CYVSCROLL), bw, bh, 0, 0, bmp, xo, yo); /* draw slider */ start = rcVBar.top + GetMainWinMetrics (MWM_CYVSCROLL) + pWin->vscroll.barStart; if (start + pWin->vscroll.barLen > rcVBar.bottom) start = rcVBar.bottom - pWin->vscroll.barLen; rcSlider.left = rcVBar.left; rcSlider.top = start; rcSlider.right = rcVBar.right; rcSlider.bottom = start + pWin->vscroll.barLen;#ifdef _FLAT_WINDOW_STYLE SetBrushColor (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF)); FillBox (hdc, rcVBar.left + 1, start + 1, RECTW (rcVBar) - 1, pWin->vscroll.barLen - 2); SetPenColor (hdc, PIXEL_black); Rectangle (hdc, rcSlider.left, rcSlider.top, rcSlider.right, rcSlider.bottom - 1); yo = (rcSlider.top + rcSlider.bottom) >> 1; MoveTo (hdc, rcSlider.left + 2, yo); LineTo (hdc, rcSlider.right - 1, yo); MoveTo (hdc, rcSlider.left + 3, yo - 2); LineTo (hdc, rcSlider.right - 2, yo - 2); MoveTo (hdc, rcSlider.left + 3, yo + 2); LineTo (hdc, rcSlider.right - 2, yo + 2); SetPenColor (hdc, PIXEL_black); Rectangle (hdc, rcVBar.left, rcVBar.top - 1, rcVBar.right, rcVBar.bottom);#elif defined(_PHONE_WINDOW_STYLE) DrawBoxFromBitmap (hdc, &rcSlider, GetSystemBitmap (SYSBMP_SCROLLBAR_VSLIDER), FALSE, FALSE);#else Draw3DThickFrameEx (hdc, (HWND)pWin, rcVBar.left, rcSlider.top, rcVBar.right, rcSlider.bottom, DF_3DBOX_NORMAL | DF_3DBOX_FILL, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF));#endif rcVBar.top += GetMainWinMetrics (MWM_CYVSCROLL); rcVBar.bottom -= GetMainWinMetrics (MWM_CYVSCROLL); /* Exclude the rect of slider */ ExcludeClipRect (hdc, &rcSlider); /* draw back bar */#ifdef _FLAT_WINDOW_STYLE SetBrushColor (hdc, PIXEL_lightwhite); FillBox (hdc, rcVBar.left + 1, rcVBar.top + 1, RECTW (rcVBar) - 1, RECTH (rcVBar) - 1);#elif defined(_PHONE_WINDOW_STYLE) DrawBoxFromBitmap (hdc, &rcVBar, GetSystemBitmap (SYSBMP_SCROLLBAR_VBG), FALSE, FALSE);#else SetBrushColor (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CONTROL_DEF)); FillBox (hdc, rcVBar.left, rcVBar.top, RECTW (rcVBar), RECTH (rcVBar));#endif }}// this function is CONTROL safe.static void wndDrawCaption(const MAINWIN* pWin, HDC hdc, BOOL bFocus){ int i; RECT rc; int iBorder = 0; int iCaption = 0, bCaption; int iIconX = 0; int iIconY = 0; int x, y, w, h;#if defined(_FLAT_WINDOW_STYLE) && defined(_GRAY_SCREEN) SIZE text_ext;#endif PBITMAP bmp; int bw, bh; bmp = GetSystemBitmap (SYSBMP_CAPBTNS); bw = bmp->bmWidth >> 2; bh = bmp->bmHeight; if (pWin->dwStyle & WS_BORDER) iBorder = GetMainWinMetrics(MWM_BORDER); else if( pWin->dwStyle & WS_THICKFRAME ) { iBorder = GetMainWinMetrics(MWM_THICKFRAME); SetPenColor (hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, WEC_FRAME_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, WEC_FRAME_NORMAL)); for (i=1; i<iBorder; i++) Rectangle(hdc, i, i, pWin->right - pWin->left - i - 1, pWin->bottom - pWin->top - i - 1); } else if (pWin->dwStyle & WS_THINFRAME) iBorder = GetMainWinMetrics (MWM_THINFRAME); if (!(pWin->dwStyle & WS_CAPTION)) return; if (pWin->hIcon ) { iIconX = GetMainWinMetrics(MWM_ICONX); iIconY = GetMainWinMetrics(MWM_ICONY); } iCaption = GetMainWinMetrics(MWM_CAPTIONY); bCaption = iBorder + iCaption - 1; // draw Caption rc.left = iBorder; rc.top = iBorder; rc.right = pWin->right - pWin->left - iBorder; rc.bottom = iBorder + iCaption; ClipRectIntersect (hdc, &rc); SelectFont (hdc, GetSystemFont (SYSLOGFONT_CAPTION));#ifdef _FLAT_WINDOW_STYLE#ifdef _GRAY_SCREEN GetTextExtent (hdc, pWin->spCaption, -1, &text_ext); if (pWin->hIcon) text_ext.cx += iIconX + 2; SetBrushColor (hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_NORMAL)); FillBox (hdc, iBorder, iBorder, text_ext.cx + 4, bCaption); SetBrushColor(hdc, GetWindowElementColorEx ((HWND)pWin, FGC_CAPTION_ACTIVED)); FillBox (hdc, iBorder + text_ext.cx + 4, iBorder, pWin->right - pWin->left, bCaption); SetPenColor(hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_NORMAL)); MoveTo (hdc, iBorder, bCaption); LineTo (hdc, pWin->right - pWin->left, bCaption); SetPenColor(hdc, GetWindowElementColorEx ((HWND)pWin, FGC_CAPTION_ACTIVED)); MoveTo (hdc, iBorder + text_ext.cx + 4, bCaption - 3); LineTo (hdc, iBorder + text_ext.cx + 2, bCaption - 1); MoveTo (hdc, iBorder + text_ext.cx + 4, bCaption - 2); LineTo (hdc, iBorder + text_ext.cx + 3, bCaption - 1); MoveTo (hdc, iBorder + text_ext.cx + 2, iBorder); LineTo (hdc, iBorder + text_ext.cx + 4, iBorder + 2); MoveTo (hdc, iBorder + text_ext.cx + 3, iBorder); LineTo (hdc, iBorder + text_ext.cx + 4, iBorder + 1);#else { unsigned char bits [256]; BITMAP bmp; InitBitmap (hdc, 64, 1, 128, bits, &bmp); if (bFocus) { int i; Uint8 r, g, b; gal_pixel pixel; Pixel2RGB (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_ACTIVED), &r, &g, &b); if (r > 191) r = 255; else r += 64; if (g > 191) g = 255; else g += 64; if (b > 191) b = 255; else b += 64; for (i = 0; i < 64; i++) { pixel = RGB2Pixel (hdc, r - i, g - i, b - i); SetPixelInBitmap (&bmp, 63 - i, 0, pixel); } } else { int i; Uint8 r, g, b; gal_pixel pixel; Pixel2RGB (hdc, GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_NORMAL), &r, &g, &b); if (r > 191) r = 255; else r += 64; if (g > 191) g = 255; else g += 64; if (b > 191) b = 255; else b += 64; for (i = 0; i < 64; i++) { pixel = RGB2Pixel (hdc, r - i, g - i, b - i); SetPixelInBitmap (&bmp, 63 - i, 0, pixel); } } FillBoxWithBitmap (hdc, iBorder, iBorder, pWin->right - pWin->left - (iBorder << 1), bCaption + 1, &bmp); }#endif#else SetBrushColor (hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_NORMAL)); FillBox(hdc, iBorder, iBorder, pWin->right - pWin->left - iBorder, bCaption + 1);#endif if (pWin->hIcon) DrawIcon (hdc, iBorder, iBorder + (bCaption - iIconY) / 2, iIconX, iIconY, pWin->hIcon); SetTextColor(hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, FGC_CAPTION_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, FGC_CAPTION_NORMAL)); SetBkColor(hdc, bFocus ? GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_ACTIVED) : GetWindowElementColorEx ((HWND)pWin, BKC_CAPTION_NORMAL)); SetBkMode(hdc, BM_TRANSPARENT); TextOut(hdc, iBorder + iIconX + 2, iBorder + 3, pWin->spCaption); // draw system button w = GetMainWinMetrics (MWM_SB_WIDTH); x = rc.right - w; y = GetMainWinMetrics (MWM_SB_HEIGHT); if (y < bCaption) { y = iBorder + ((bCaption - y)>>1); h = GetMainWinMetrics (MWM_SB_HEIGHT); } else { y = iBorder; h = iIconY; } if (!(pWin->dwExStyle & WS_EX_NOCLOSEBOX)) { // close box#if defined(_FLAT_WINDOW_STYLE) && !defined(_GRAY_SCREEN) int xx = x - 3; int yy = y + 1; int hh = h - 2; SetPenColor (hdc, PIXEL_lightwhite); Rectangle (hdc, xx, yy, xx + w, yy + hh); MoveTo (hdc, xx + 5, yy + hh / 2); LineTo (hdc, xx + w - 5, yy + hh / 2);#else FillBoxWithBitmapPart (hdc, x, y, bw, bh, 0, 0, bmp, (bw << 1) + bw, 0);#endif x -= GetMainWinMetrics (MWM_SB_WIDTH); x -= GetMainWinMetrics (MWM_SB_INTERX) << 1; } if (pWin->dwStyle & WS_MAXIMIZEBOX) { // restore/maximize/question box#if defined(_FLAT_WINDOW_STYLE) && !defined(_GRAY_SCREEN) int xx = x - 3; int yy = y + 1; int hh = h - 2; SetPenColor (hdc, PIXEL_lightwhite); Rectangle (hdc, xx, yy, xx + w, yy + hh);#if 1 MoveTo (hdc, xx + 2, yy + 3); LineTo (hdc, xx + w - 5, yy + 3); MoveTo (hdc, xx + 2, yy + 5); LineTo (hdc, xx + w - 3, yy + 5); MoveTo (hdc, xx + 2, yy + 7); LineTo (hdc, xx + w - 2, yy + 7); MoveTo (hdc, xx + 2, yy + 9); LineTo (hdc, xx + w - 4, yy + 9);#else MoveTo (hdc, xx + 5, yy); LineTo (hdc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -