📄 border.c
字号:
}
void ExposureBorder(Border* border,HDC hdc)
{
int rim = 0;
eFace_Style style;
rim = border->m_riActiveRect .m_eFrameThick;
style = border->m_riActiveRect.m_eFaceStyle;
ExposureBorderDrawFrame(border,rim,hdc);
if(!(border->m_riActiveRect.m_ulFaceColor & 0xff000000))
{
switch(style)
{
case S2D:
{
ExposureBorderDrawFace(border,rim,hdc);
}
break;
case S3D:
{
ExposureBorderDraw3D(border,rim,hdc);
ExposureBorderDrawFace(border,rim+2,hdc);
}
break;
case SHADED:
{
ExposureBorderDrawShade(border,rim,hdc);
}
break;
default:
break;
}
}
ExposureBorderDrawLabel(border,hdc);
return ;
}void ExposureBorderDrawLabel(Border* border,HDC hdc)
{
int i,j,index,offset;
lattice* latt;
int nwidth ,nheight,x,y,width,height,nx,ny;
eLocation loc;
unsigned long color;
int r,g,b;
if(!border->m_tiActiveText.m_szContent)
return ;
latt = (lattice*)SearchLattice(atoi(border->m_tiActiveText.m_szContent+1));
if(!latt)
return ;
nwidth= latt->width ;
nheight = latt->height;
x = border->m_rPosition.left;
y = border->m_rPosition.top;
width = border->m_rPosition.right - border->m_rPosition.left;
height = border->m_rPosition.bottom - border->m_rPosition.top ;
loc = border->m_tiActiveText.m_eLocation;
color = border->m_tiActiveText.m_ulTextColor;
r = (int)(color & 0xFF);
g = (int)((color >>8) & 0xFF);
b = (int)((color >> 16) & 0xFF);
switch(loc)
{
case UPPER_LEFT:
{
nx=x+2;
ny=y+2;
}
break;
case MIDDLE_LEFT:
{
nx=x+2;
ny = y+(height-nheight)/2;
}
break;
case LOWER_LEFT:
{
nx=x+2;
ny = y+height-nheight-2;
}
break;
case UPPER_CENTER:
{
nx = (width-nwidth)/2+x;
ny=y+2;
}
break;
case MIDDLE_CENTER:
{
nx = (width-nwidth)/2+x;
ny = (height-nheight)/2+y;
}
break;
case LOWER_CENTER:
{
nx = (width-nwidth)/2+x;
ny = y+height-nheight-2;
}
break;
case UPPER_RIGHT:
{
nx = width-nwidth+x-2;
ny=y+2;
}
break;
case MIDDLE_RIGHT:
{
nx = width-nwidth+x-2;
ny = y+(height-nheight)/2;
}
break;
case LOWER_RIGHT:
{
nx = width-nwidth+x-2;
ny = y+height-nheight-2;
}
break;
default:
break;
}
if(latt)
{
for (j = 0; j<nheight ; j++)
{
for ( i = 0; i<nwidth; i++)
{
index = (j*nwidth +i)/8;
offset = 1<<((j*nwidth +i)%8);
if(latt->pResdata[index] & offset)
{
SetPixel(hdc,i+nx,j+ny,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
}
}
}
}
return ;
}void ExposureBorderDraw3D(Border* border,int offset,HDC hdc)
{
}void ExposureBorderDrawShade(Border* border,int offset,HDC hdc)
{
int status = 0;
int x = border->m_rPosition.left+offset;
int y = border->m_rPosition.top+offset;
int width = border->m_rPosition.right - border->m_rPosition.left-2*offset;
int height = border->m_rPosition.bottom - border->m_rPosition.top-2*offset;
int r0,g0,b0;
int r,g,b;
int up,left,right,down,shade1,shade2;
int i;
unsigned long grColor;
grColor = border->m_riActiveRect.m_ulFaceColor;
up=border->m_riActiveRect .m_pTopLeft .x;
left=border->m_riActiveRect .m_pTopLeft .x;
right=border->m_riActiveRect .m_pBottomRight .x ;
down=border->m_riActiveRect .m_pBottomRight .x ;
shade1=border->m_riActiveRect .m_pTopLeft .y;
shade2=border->m_riActiveRect .m_pBottomRight .y;
r0 = (int)(grColor & 0xFF);
g0 = (int)((grColor >>8) & 0xFF);
b0 = (int)((grColor >> 16) & 0xFF);
SetPenType (hdc, PT_SOLID);
switch(border->m_eShape)
{
case Rectangular:
{
// up.
r = r0;
g = g0;
b = b0;
for(i=0;i<up;i++)
{
if(!status)
{
if(r < 255 - shade1) { r +=shade1;} else { r = 255;}
if(g < 255 - shade1) { g +=shade1;} else { g = 255;}
if(b < 255 - shade1) { b +=shade1;} else { b = 255;}
}
else
{
if(r > shade1) { r -=shade1;} else { r = 0; }
if(g > shade1) { g -=shade1;} else { g = 0; }
if(b > shade1) { b -=shade1;} else { b = 0; }
}
SetPenColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
MoveTo(hdc, x+left-(int)((float)left/(float)up*i), y+up-i);
LineTo(hdc, x+width-right+(int)((float)right/(float)up*i), y+up-i);
}
// right.
r = r0;
g = g0;
b = b0;
for(i=0;i<right;i++)
{
if(!status)
{
if(r >shade2) { r -=shade2;} else r = 0;
if(g >shade2) { g -=shade2;} else g = 0;
if(b >shade2) { b -=shade2;} else b = 0;
}
else
{
if(r < 255 - shade2) { r +=shade2;} else { r = 255;}
if(g < 255 - shade2) { g +=shade2;} else { g = 255;}
if(b < 255 - shade2) { b +=shade2;} else { b = 255;}
}
SetPenColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
MoveTo(hdc, x+width-right+i-1, y+up-(int)((float)up/(float)right*i));
LineTo(hdc, x+width-right+i-1, y+height-down+(int)((float)down/(float)right*i));
}
// down.
r = r0;
g = g0;
b = b0;
for(i=0;i<down;i++)
{
if(!status)
{
if(r > shade2) { r-=shade2;} else {r = 0;}
if(g > shade2) { g-=shade2;} else {g = 0;}
if(b > shade2) { b-=shade2;} else {b = 0;}
}
else
{
if(r < 255 - shade2) { r +=shade2;} else {r = 255;}
if(g < 255 - shade2) { g +=shade2;} else {g = 255;}
if(b < 255 - shade2) { b +=shade2;} else {b = 255;}
}
SetPenColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
MoveTo(hdc, x+left-(int)((float)left/(float)down*i), y+height-down+i-1);
LineTo(hdc, x+width-right+(int)((float)right/(float)down*i), y+height-down+i-1);
}
// left.
r = r0;
g = g0;
b = b0;
for(i=0;i<left;i++)
{
if(!status)
{
if(r <255 - shade1) { r+=shade1;} else {r = 255;}
if(g <255 - shade1) { g+=shade1;} else {g = 255;}
if(b <255 - shade1) { b+=shade1;} else {b = 255;}
}
else
{
if(r > shade1 ) { r -=shade1;} else {r = 0;}
if(g > shade1 ) { g -=shade1;} else {g = 0;}
if(b > shade1 ) { b -=shade1;} else {b = 0;}
}
SetPenColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
MoveTo(hdc, x+left-i,y+up-(int)((float)up/(float)left*i));
LineTo(hdc, x+left-i, y+height-down+(int)((float)down/(float)left*i));
}
r = r0;
g = g0;
b = b0;
SetBrushColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
FillBox(hdc,x+left,y+up,width-left-right,height-up-down);
}
break;
case Elliptical:
break;
case Obround:
break;
case Radius:
break;
default:
break;
}
}void ExposureBorderDrawFace(Border* border,int offset,HDC hdc)
{
int r,g,b;
unsigned long color;
int x = border->m_rPosition.left+offset;
int y = border->m_rPosition.top+offset;
int w = border->m_rPosition.right - border->m_rPosition.left-2*offset;
int h = border->m_rPosition.bottom - border->m_rPosition.top-2*offset;
color = border->m_riActiveRect.m_ulFaceColor;
r = (int)(color & 0xFF);
g = (int)((color >>8) & 0xFF);
b = (int)((color >> 16) & 0xFF);
SetBrushColor(hdc,(unsigned long)RGBA2Pixel(hdc,r,g,b,0xFF));
switch(border->m_eShape)
{
case Rectangular:
FillBox(hdc,x,y,w,h);
break;
case Elliptical:
FillEllipse (hdc,x+w/2,y+h/2,w/2,h/2);
break;
case Obround:
break;
case Radius:
break;
default:
break;
}
}void ExposureBorderDrawFrame(Border* border,int rim,HDC hdc)
{
}
void border_free_resource(Border* pBorder)
{
if(!pBorder)
return ;
if(pBorder->m_tiActiveText.m_LogFont)
free(pBorder->m_tiActiveText.m_LogFont);
if(pBorder->m_tiActiveText.m_szContent)
free (pBorder->m_tiActiveText.m_szContent);
free (pBorder);
pBorder = NULL;
return ;
}
BOOL RegisterBorderminiGUI (void)
{
WNDCLASS MyClass;
MyClass.spClassName = BORDER_MINIGUI;
MyClass.dwStyle = WS_NONE;
MyClass.dwExStyle = WS_EX_NONE;
MyClass.hCursor = GetSystemCursor (IDC_ARROW);
MyClass.iBkColor = COLOR_lightwhite;
MyClass.WinProc = Border_miniGUIProc;
return RegisterWindowClass (&MyClass);
}
void UnRegisterBorderminiGUI (void)
{
UnregisterWindowClass (BORDER_MINIGUI);
}
int Border_miniGUIProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case MSG_PAINT:
{
Border* border;
WinInfo* info = 0;
info = (WinInfo*)SearchInfo(hwnd);
if(!info)
return 0;
border = (Border*)info->obj;
// ExposureBorder(border);
}
break;
case MSG_LBUTTONDOWN:
{
Border* border;
WinInfo* info = 0;
info = (WinInfo*)SearchInfo(hwnd);
if(!info)
return 0;
border = (Border*)info->obj;
}
break;
case MSG_LBUTTONUP:
break;
default:
break;
}
return DefaultControlProc (hwnd, message, wParam, lParam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -