📄 window.c
字号:
SetPenColor (hdc, GetWindowElementColor (FGC_CONTROL_DEF)); Rectangle (hdc, rcHBar.left, rcHBar.top, rcHBar.right, rcHBar.bottom - 1);#endif // draw moving bar. start = rcHBar.left + GetMainWinMetrics (MWM_CXHSCROLL) + pWin->hscroll.barStart; if (start + pWin->hscroll.barLen > rcHBar.right) start = rcHBar.right - pWin->hscroll.barLen;#ifdef _FLAT_WINDOW_STYLE#ifdef _GRAY_SCREEN SetBrushColor (hdc, GetWindowElementColor (FGC_CONTROL_DEF)); FillBox (hdc, start, rcHBar.top + 2, pWin->hscroll.barLen, RECTH (rcHBar) - 4);#else SetBrushColor (hdc, PIXEL_lightgray); FillBox (hdc, start, rcHBar.top + 1, pWin->hscroll.barLen + 1, RECTH (rcHBar) - 2); SetPenColor (hdc, PIXEL_black); MoveTo (hdc, start, rcHBar.top + 1); LineTo (hdc, start, rcHBar.top + 1 + RECTH (rcHBar) - 2); MoveTo (hdc, start+pWin->hscroll.barLen + 1, rcHBar.top + 1); LineTo (hdc, start+pWin->hscroll.barLen + 1, rcHBar.top + 1 + RECTH (rcHBar) - 2);#endif#else Draw3DUpFrame (hdc, start, rcHBar.top, start + pWin->hscroll.barLen, rcHBar.bottom, PIXEL_invalid);#endif } if (pWin->dwStyle & WS_VSCROLL && !(pWin->vscroll.status & SBS_HIDE)) { SetBrushColor (hdc, GetWindowElementColor (BKC_CONTROL_DEF)); FillBox (hdc, rcVBar.left, rcVBar.top, RECTW (rcVBar), RECTH (rcVBar)); // draw top and bottom 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);#ifdef _FLAT_WINDOW_STYLE SetPenColor (hdc, GetWindowElementColor (FGC_CONTROL_DEF)); Rectangle (hdc, rcVBar.left, rcVBar.top, rcVBar.right - 1, rcVBar.bottom);#endif // draw moving bar start = rcVBar.top + GetMainWinMetrics (MWM_CYVSCROLL) + pWin->vscroll.barStart; if (start + pWin->vscroll.barLen > rcVBar.bottom) start = rcVBar.bottom - pWin->vscroll.barLen;#ifdef _FLAT_WINDOW_STYLE#ifdef _GRAY_SCREEN SetBrushColor (hdc, GetWindowElementColor (FGC_CONTROL_DEF)); FillBox (hdc, rcVBar.left + 2, start, RECTW (rcVBar) - 4, pWin->vscroll.barLen);#else SetBrushColor (hdc, PIXEL_lightgray); FillBox (hdc, rcVBar.left + 1, start, RECTW (rcVBar) - 2, pWin->vscroll.barLen); SetPenColor (hdc, PIXEL_black); MoveTo (hdc, rcVBar.left + 1, start); LineTo (hdc, rcVBar.left + 1 + RECTW (rcVBar) - 2, start); MoveTo (hdc, rcVBar.left + 1, start + pWin->vscroll.barLen - 1); LineTo (hdc, rcVBar.left + 1 + RECTW (rcVBar) - 2, start + pWin->vscroll.barLen - 1);#endif#else Draw3DUpFrame (hdc, rcVBar.left, start, rcVBar.right, start + pWin->vscroll.barLen, PIXEL_invalid);#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 ? GetWindowElementColor (WEC_FRAME_ACTIVED) : GetWindowElementColor (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 ? GetWindowElementColor (BKC_CAPTION_ACTIVED) : GetWindowElementColor (BKC_CAPTION_NORMAL)); FillBox (hdc, iBorder, iBorder, text_ext.cx + 4, bCaption); SetBrushColor(hdc, GetWindowElementColor (FGC_CAPTION_ACTIVED)); FillBox (hdc, iBorder + text_ext.cx + 4, iBorder, pWin->right - pWin->left, bCaption); SetPenColor(hdc, bFocus ? GetWindowElementColor (BKC_CAPTION_ACTIVED) : GetWindowElementColor (BKC_CAPTION_NORMAL)); MoveTo (hdc, iBorder, bCaption); LineTo (hdc, pWin->right - pWin->left, bCaption); SetPenColor(hdc, GetWindowElementColor (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, GetWindowElementColor (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, GetWindowElementColor (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 ? GetWindowElementColor (BKC_CAPTION_ACTIVED) : GetWindowElementColor (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 ? GetWindowElementColor (FGC_CAPTION_ACTIVED) : GetWindowElementColor (FGC_CAPTION_NORMAL)); SetBkColor(hdc, bFocus ? GetWindowElementColor (BKC_CAPTION_ACTIVED) : GetWindowElementColor (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, xx + 5, yy + hh); MoveTo (hdc, xx + w - 5, yy); LineTo (hdc, xx + w - 5, yy + hh); MoveTo (hdc, xx + 5, yy + hh / 2); LineTo (hdc, xx + w - 5, yy + hh / 2);#endif#else if (pWin->dwStyle & WS_MAXIMIZE) FillBoxWithBitmapPart (hdc, x, y, bw, bh, 0, 0, bmp, bw << 1, 0); else FillBoxWithBitmapPart (hdc, x, y, bw, bh, 0, 0, bmp, 0, 0);#endif x -= GetMainWinMetrics (MWM_SB_WIDTH); x -= GetMainWinMetrics (MWM_SB_INTERX); } if (pWin->dwStyle & WS_MINIMIZEBOX) { // minimize/ok 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); Circle (hdc, xx + w / 2, yy + hh / 2, hh / 2 - 2);#else FillBoxWithBitmapPart (hdc, x, y, bw, bh, 0, 0, bmp, bw, 0);#endif }}static void wndEraseBackground(const MAINWIN* pWin, HDC hdc, const RECT* pClipRect){ RECT rcTemp; BOOL fGetDC = FALSE; if (hdc == 0) { hdc = GetClientDC ((HWND)pWin); fGetDC = TRUE; } if (pClipRect) { rcTemp = *pClipRect; if (pWin->WinType == TYPE_MAINWIN) { ScreenToClient ((HWND)pWin, &rcTemp.left, &rcTemp.top); ScreenToClient ((HWND)pWin, &rcTemp.right, &rcTemp.bottom); } } else { rcTemp.left = rcTemp.top = 0; rcTemp.right = pWin->cr - pWin->cl; rcTemp.bottom = pWin->cb - pWin->ct; } SetBrushColor(hdc, pWin->iBkColor); FillBox(hdc, rcTemp.left, rcTemp.top, RECTW (rcTemp), RECTH (rcTemp)); if (fGetDC) ReleaseDC (hdc);}// this function is CONTROL safe.static void wndDrawNCFrame(MAINWIN* pWin, HDC hdc, const RECT* prcInvalid){ BOOL fGetDC = FALSE; if (hdc == 0) { hdc = GetDC ((HWND)pWin); fGetDC = TRUE; } if (prcInvalid) ClipRectIntersect (hdc, prcInvalid); wndDrawNCArea (pWin, hdc); wndDrawScrollBar (pWin, hdc); if (pWin->WinType == TYPE_MAINWIN) { wndDrawCaption (pWin, hdc, !(pWin->dwStyle & WS_DISABLED) && (GetActiveWindow() == (HWND)pWin)); DrawMenuBarHelper (pWin, hdc, prcInvalid); } else { wndDrawCaption (pWin, hdc, !(pWin->dwStyle & WS_DISABLED) && ((PCONTROL)pWin)->pParent->active == (PCONTROL)pWin); } if (fGetDC) ReleaseDC (hdc);}// this function is CONTROL safe.static void wndActiveMainWindow (PMAINWIN pWin, BOOL fActive){ HDC hdc; hdc = GetDC ((HWND)pWin); wndDrawCaption (pWin, hdc, fActive); ReleaseDC (hdc);}#if 0static void OnShowWindow (PMAINWIN pWin, int iShowCmd){ PCONTROL pCtrl; if (iShowCmd != SW_HIDE) { pCtrl = (PCONTROL)(pWin->hFirstChild); while (pCtrl) { ShowWindow ((HWND)pCtrl, i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -