📄 drawcorner.cpp
字号:
#include "stdafx.h"
#include "Netmsg.h"
//this file holds DrawCorner() a function to draw 4 shitty corners of varying colors and blending
//i bloody hate the way so much code is needed to do the most simple graphical thing
#define R(cr) ((BYTE)(cr & 0xFF))
#define G(cr) ((BYTE)(cr >> 8))
#define B(cr) ((BYTE)(cr >> 16))
void DrawDot(CDC *pDC, int x, int y, COLORREF crCol);
void DrawCorner(CDC *pDC, int x, int y, COLORREF crCol, int nCorner, bool bMessage, COLORREF crMessageColor)
{
int r, g, b;
int rs1, gs1, bs1;
int rs2, gs2, bs2;
int rs3, gs3, bs3;
int rmax, gmax, bmax;
COLORREF crStage1;
COLORREF crStage2;
COLORREF crStage3;
r = R(crCol);
g = G(crCol);
b = B(crCol);
rmax = bMessage ? R(crMessageColor) : 255;
gmax = bMessage ? G(crMessageColor) : 255;
bmax = bMessage ? B(crMessageColor) : 255;
if (rmax > r)
{
rs1 = r + (rmax - r) / 4;
rs2 = r + ((rmax - r) / 4) * 2;
rs3 = r + ((rmax - r) / 4) * 3;
}
else
{
rs1 = r - (r - rmax) / 4;
rs2 = r - ((r - rmax) / 4) * 2;
rs3 = r - ((r - rmax) / 4) * 3;
}
if (gmax > g)
{
gs1 = g + (gmax - g) / 4;
gs2 = g + ((gmax - g) / 4) * 2;
gs3 = g + ((gmax - g) / 4) * 3;
}
else
{
gs1 = g - (g - gmax) / 4;
gs2 = g - ((g - gmax) / 4) * 2;
gs3 = g - ((g - gmax) / 4) * 3;
}
if (bmax > b)
{
bs1 = b + (bmax - b) / 4;
bs2 = b + ((bmax - b) / 4) * 2;
bs3 = b + ((bmax - b) / 4) * 3;
}
else
{
bs1 = b - (b - bmax) / 4;
bs2 = b - ((b - bmax) / 4) * 2;
bs3 = b - ((b - bmax) / 4) * 3;
}
crStage1 = RGB(rs1, gs1, bs1);
crStage2 = RGB(rs2, gs2, bs2);
crStage3 = RGB(rs3, gs3, bs3);
switch (nCorner)
{
case 1:
pDC->FillSolidRect(x, y, 4, 10, crCol);
pDC->FillSolidRect(x + 4, y, 5, 4, crCol);
DrawDot(pDC, x + 4, y + 4, crCol);
DrawDot(pDC, x + 4, y + 5, crCol);
DrawDot(pDC, x + 5, y + 4, crCol);
DrawDot(pDC, x + 6, y + 4, crStage1);
DrawDot(pDC, x + 4, y + 6, crStage1);
DrawDot(pDC, x + 5, y + 5, crStage2);
DrawDot(pDC, x + 7, y + 4, crStage2);
DrawDot(pDC, x + 4, y + 7, crStage2);
DrawDot(pDC, x + 8, y + 4, crStage3);
DrawDot(pDC, x + 4, y + 8, crStage3);
if (bMessage)
{
DrawDot(pDC, x + 4, y + 9, crMessageColor);
DrawDot(pDC, x + 9, y + 4, crMessageColor);
pDC->FillSolidRect(x + 5, y + 6, 5, 4, crMessageColor);
pDC->FillSolidRect(x + 6, y + 5, 4, 1, crMessageColor);
}
break;
case 2:
pDC->FillSolidRect(x, y, 10, 4, crCol);
pDC->FillSolidRect(x + 6, y + 4, 4, 6, crCol);
DrawDot(pDC, x + 1, y + 4, crStage3);
DrawDot(pDC, x + 2, y + 4, crStage2);
DrawDot(pDC, x + 3, y + 4, crStage1);
DrawDot(pDC, x + 4, y + 4, crCol);
DrawDot(pDC, x + 5, y + 4, crCol);
DrawDot(pDC, x + 4, y + 5, crStage2);
DrawDot(pDC, x + 5, y + 5, crCol);
DrawDot(pDC, x + 5, y + 6, crStage1);
DrawDot(pDC, x + 5, y + 7, crStage2);
DrawDot(pDC, x + 5, y + 8, crStage3);
if (bMessage)
{
DrawDot(pDC, x, y + 4, crMessageColor);
DrawDot(pDC, x + 5, y + 9, crMessageColor);
pDC->FillSolidRect(x, y + 5, 4, 6, crMessageColor);
pDC->FillSolidRect(x + 4, y + 6, 1, 5, crMessageColor);
}
break;
case 3:
pDC->FillSolidRect(x, y, 4, 6, crCol);
pDC->FillSolidRect(x, y + 6, 10, 4, crCol);
DrawDot(pDC, x + 4, y + 1, crStage3);
DrawDot(pDC, x + 4, y + 2, crStage2);
DrawDot(pDC, x + 4, y + 3, crStage1);
DrawDot(pDC, x + 4, y + 4, crCol);
DrawDot(pDC, x + 5, y + 4, crStage2);
DrawDot(pDC, x + 4, y + 5, crCol);
DrawDot(pDC, x + 5, y + 5, crCol);
DrawDot(pDC, x + 6, y + 5, crStage1);
DrawDot(pDC, x + 7, y + 5, crStage2);
DrawDot(pDC, x + 8, y + 5, crStage3);
if (bMessage)
{
DrawDot(pDC, x + 4, y, crMessageColor);
DrawDot(pDC, x + 9, y + 5, crMessageColor);
pDC->FillSolidRect(x + 5, y, 5, 4, crMessageColor);
pDC->FillSolidRect(x + 6, y + 4, 4, 1, crMessageColor);
}
break;
case 4:
pDC->FillSolidRect(x + 6, y, 4, 10, crCol);
pDC->FillSolidRect(x, y + 6, 10, 4, crCol);
DrawDot(pDC, x + 5, y + 1, crStage3);
DrawDot(pDC, x + 5, y + 2, crStage2);
DrawDot(pDC, x + 5, y + 3, crStage1);
DrawDot(pDC, x + 4, y + 4, crStage2);
DrawDot(pDC, x + 5, y + 4, crCol);
DrawDot(pDC, x + 1, y + 5, crStage3);
DrawDot(pDC, x + 2, y + 5, crStage2);
DrawDot(pDC, x + 3, y + 5, crStage1);
DrawDot(pDC, x + 4, y + 5, crCol);
DrawDot(pDC, x + 5, y + 5, crCol);
if (bMessage)
{
DrawDot(pDC, x, y + 5, crMessageColor);
DrawDot(pDC, x + 5, y, crMessageColor);
pDC->FillSolidRect(x, y, 4, 5, crMessageColor);
pDC->FillSolidRect(x + 4, y, 1, 4, crMessageColor);
}
break;
}
}
void DrawBitmap(CDC * pDC, CRect rc, UINT nFlags, CBitmap *pBitmap)
{
CDC memDC;
CBitmap* pOld = NULL;
memDC.CreateCompatibleDC(pDC);
BITMAP bmpInfo;
int Width;
int Height;
int xSrc = 0;
int ySrc = 0;
int xDesired;
int yDesired;
ASSERT(pBitmap->m_hObject != NULL);
pBitmap->GetBitmap(&bmpInfo);
pOld = memDC.SelectObject((CBitmap*) pBitmap);
if (pOld == NULL) return;
Width = (bmpInfo.bmWidth - rc.Width()) / 2;
Height = (bmpInfo.bmHeight - rc.Height()) / 2;
if ((nFlags & DB_HCENTER))
{
if (Width > 0)
{
xDesired = rc.left;
xSrc = abs(Width);
}
else xDesired = rc.left+ abs(Width);
}
else xDesired = rc.left;
if ((nFlags & DB_VCENTER))
{
if (Height > 0)
{
yDesired = rc.top;
ySrc = abs(Height);
}
else yDesired = rc.top + abs(Height);
} else
yDesired = rc.top;
pDC->BitBlt(xDesired, yDesired, rc.Width(), rc.Height(), &memDC, xSrc, ySrc, SRCCOPY);
memDC.SelectObject(pOld);
}
void DrawDot(CDC *pDC, int x, int y, COLORREF crCol)
{
pDC->FillSolidRect(x, y, 1, 1, crCol);
}
COLORREF GetColor(int nColor)
{
switch (nColor)
{
case COL_DISABLED:
return GetApp()->crDisabled;
case COL_LIGHTITEMS:
return GetApp()->crLightItems;
case COL_LINEFRAMES:
return GetApp()->crLineFrames;
case COL_NOTIFYTEXT:
return GetApp()->crNotifyText;
case COL_NORMALTEXT:
return GetApp()->crNormalText;
case COL_BTNACTIVE:
return GetApp()->crBtnActive;
case COL_BTNOVER:
return GetApp()->crBtnOver;
case COL_BTNBACK:
return GetApp()->crBtnBack;
}
return NULL;
}
void SetColor(int nColor, COLORREF crColor)
{
switch (nColor)
{
case COL_DISABLED:
GetApp()->crDisabled = crColor;
break;
case COL_LIGHTITEMS:
GetApp()->crLightItems = crColor;
break;
case COL_LINEFRAMES:
GetApp()->crLineFrames = crColor;
break;
case COL_NOTIFYTEXT:
GetApp()->crNotifyText = crColor;
break;
case COL_NORMALTEXT:
GetApp()->crNormalText = crColor;
break;
case COL_BTNACTIVE:
GetApp()->crBtnActive = crColor;
break;
case COL_BTNOVER:
GetApp()->crBtnOver = crColor;
break;
case COL_BTNBACK:
GetApp()->crBtnBack = crColor;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -