label.c
来自「rtCell 实时微内核-具有下列功能: 1. 完全抢占的实时微内核结构」· C语言 代码 · 共 123 行
C
123 行
/*
*******************************************************************************
* The real-time kernel "rtCell" *
* Copyright 2005 taowentao, allrights reserved. *
* File : Label.c *
* By : taowentao 2006-09-02 2007-05-20 *
*******************************************************************************
*/
#if !defined(LABEL_H)
#include "giCell\Wins\include\Label.h"
#endif
/*
*******************************************************************************
* *
*******************************************************************************
*/
static COLOR LabelColor = GD_GRAY;
static COLOR CaptionColor = GD_BLACK;
/*
*******************************************************************************
* *
*******************************************************************************
*/
static void LabelPaint(VIEW *pView)
{
LABEL* pLbl;
COLOR clr;
int xSize, ySize;
POINT pt;
pLbl = OBJ_FROM_VIEW(pView);
FillRect(&(pView->viewRect), pLbl->LabelColor);
if (pLbl->Status & CTRL_MOUSE_ENTER) clr = MOUSEENTERCOLOR;
else clr = pLbl->CaptionColor;
xSize = TextWidth(pLbl->pCaption);
ySize = TextHeight(pLbl->pCaption);
GetOrgFromAlign(xSize, ySize, &(pView->viewRect), pLbl->CaptionAlign, &pt);
DrawText(pt.x, pt.y, pLbl->pCaption, clr);
if (pLbl->Status & CTRL_HTML_LABEL) {
DrawHLine(pt.y+ySize, pt.x, pt.x+xSize, clr);
}
}
static CBOOL _cdecl_ LabelViewProc(VMSG *pMsg)
{
LABEL* pLbl = OBJ_FROM_VIEW(pMsg->pView);
MOUSE_INF mi;
switch (pMsg->MsgID) {
case MSM_LB_UP:
if ((pLbl->Status & CTRL_MOUSE_CATCH) == 0) return (true);
pLbl->Status &= ~(CTRL_MOUSE_CATCH);
UpdateView(pMsg->pView);
if ((pLbl->Status & CTRL_FOCUSSED) &&
(pLbl->Status & CTRL_MOUSE_ENTER)) {
if (pLbl->pOnClick != NULL) {
mi.raw = pMsg->vParam;
(*(pLbl->pOnClick))(pMsg->pt.x, pMsg->pt.y, mi);
}
}
return (true);
default:
return (CtrlViewProc(pMsg, LabelPaint, &(pLbl->Status)));
}
}
LABEL* CreateLabel(int left, int top, int width, int height, VIEW* pParent,
BYTE* pCaption, PCLICK pOnClick, CWORD Align, CWORD Style)
{
VIEW *pView;
LABEL *pLbl;
if (pParent == NULL)
return (NULL);
pView = CreateControl(left, top, width, height, pParent, 0,
LabelViewProc, sizeof(LABEL));
if (pView == NULL) return (NULL);
pLbl = OBJ_FROM_VIEW(pView);
pLbl->pView = pView;
pLbl->CaptionColor = CaptionColor;
pLbl->pOnClick = pOnClick;
pLbl->ptCatch.x = 0; pLbl->ptCatch.y = 0;
pLbl->LabelColor = LabelColor;
pLbl->pCaption = pCaption;
pLbl->Status = Style;
pLbl->CaptionAlign = Align;
ShowView(pLbl->pView);
return (pLbl);
}
void DeleteLabel(LABEL *pLbl)
{
if (pLbl == NULL) return;
DeleteView(pLbl->pView);
}
void SetLabelAlign(LABEL *pLbl, CWORD Align)
{
if (pLbl == NULL) return;
pLbl->CaptionAlign = Align;
UpdateView(pLbl->pView);
}
void SetLabelText(LABEL *pLbl, BYTE *pStr)
{
if (pLbl == NULL) return;
pLbl->pCaption = pStr;
UpdateView(pLbl->pView);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?