tslediter/funcext/tvclib/utslvclevent.tsf

401 lines
11 KiB
Plaintext

unit utslvclevent;
interface
uses cstructurelib,utslvclconstant,utslvclmemstruct,utslvclauxiliary;
{**
@explan(说明) 消息相关对象相关类型 %%
@date(20220507)
**}
///////////////////////////消息对象////////////////////////////////////
type TMNOTIFY=class(tuieventbase,tslcstructureobj)
{**
@explan(说明) 系统控件通知消息 %%
**}
STATIC SFSTRUCT;
function getstruct();
begin
if not SFSTRUCT then SFSTRUCT := MemoryAlignmentCalculate(array(
("hwndfrom","intptr",0),
("idfrom","intptr",0),
("code","int",0)));
return SFSTRUCT;
end
function create(m,w,l,h);override;
begin
inherited;
class(tslcstructureobj).create(getstruct(),l);
end
property hwndfrom index "hwndfrom" read _getvalue_;
property code index "code" read _getvalue_;
{**
@param(hwndfrom)(pointer) 子控件句柄 %%
@param(code)(integer) 通知码 %%
**}
end
type TMALIGN=class(tuieventbase)
value;
top:integer;
left:integer;
width:integer;
height:integer;
function create(m,w,l,h);
begin
inherited;
top := left := right := bottom := 0;
end
end
type TMANCHOR=class(tuieventbase)
prec;
function create(m,w,l,h);
begin
inherited;
prec := array(0,0,0,0);
end
end
type TMMENUSELECT=class(tuieventbase)
{**
@explan(说明) 菜单选择消息 %%
**}
function create(m,w,l,h);override;
begin
inherited;
end
property itemid read lowparam;
property flags read hiwparam;
{**
@param(itemid)(integer) 菜单id %%
@param(flags)(integer) 状态 %%
**}
end
type TMKEY=class(tuieventbase)
{**
@param(说明) 按键消息
**}
private
FShiftsate;
function getshiftsate();
begin
if not ifarray(FShiftsate)then
begin
FShiftsate := array();
global G_O_TSWIN32API_;
w32 := G_O_TSWIN32API_;
if w32 then
begin
if getbitsfrominteger(w32.GetKeyState(VK_SHIFT),15,15)then FShiftsate[length(FShiftsate)]:= ssShift;
if getbitsfrominteger(w32.GetKeyState(VK_CONTROL),15,15)then FShiftsate[length(FShiftsate)]:= ssCtrl;
if getbitsfrominteger(w32.GetKeyState(VK_MENU),15,15)then FShiftsate[length(FShiftsate)]:= ssAlt;
end
//echo tostn(FShiftsate);
//echo getbitsfrominteger( w32.GetKeyState(VK_MENU),15,15),"*************\r\n";
end
return FShiftsate;
end
FChar;
public
function create(m,w,l,h);override;
begin
inherited;
FChar := chr(w);
end
property char read FChar;
property CharCode read wparam;
property shiftstate read getshiftsate;
{**
@param(char)(string) 键符号 %%
@param(CharCode)(integer) ascii码 %%
@param(shiftstate)(arry of TShiftStateEnum member ) ascii码 %%
**}
end
Type TtageDrawItem=class(tslcstructureobj)
private
static SFSTRUCT;
class function getstruct();virtual;
begin
if not SFSTRUCT then SFSTRUCT := MemoryAlignmentCalculate(array(
("ctltype","int",0),
("ctlid","int",0),
("itemid","int",0),
("itemaction","int",0),
("itemstate","int",0),
("hwnditem","intptr",0),
("hdc","intptr",0),
("rcitem","int[4]",
(0,0,0,0)),
("itemdata","intptr",0)));
return SFSTRUCT;
end
public
function create(ptr);
begin
inherited create(getstruct(),ptr);
end
{**
@ignore(忽略) %%
@param(ctltype)(integer) 控件类型 %%
@param(ctlid)(integer) 控件id %%
@param(id)(integer) 待绘制的子项序号 %%
@param(itemstate)(member of TDrawitemState ) 状态%%
@param(hdc)(pointer) canvas句柄 %%
@param(hwnditem)(pointer) windows句柄 %%
@param(rcitem)(array of integer) array(左,上,右,下) %%
@param(itemaction)(integer) ODA_DRAWENTIRE or ODA_FOCUS or ODA_SELECT %%
**}
property ctltype index "ctltype" read _getvalue_ write _setvalue_;
property ctlid index "ctlid" read _getvalue_ write _setvalue_;
property id index "itemid" read _getvalue_ write _setvalue_;
property itemid index "itemid" read _getvalue_ write _setvalue_;
property itemaction index "itemaction" read _getvalue_ write _setvalue_;
property itemstate index "itemstate" read _getvalue_ write _setvalue_;
property rcitem index "rcitem" read _getvalue_ write _setvalue_;
property hdc index "hdc" read _getvalue_ write _setvalue_;
property hwnditem index "hwnditem" read _getvalue_ write _setvalue_;
end
type TMDRAWITEM=class(tuieventbase,TtageDrawItem)
public
function create(m,w,l,h);override;
begin
inherited;
class(TtageDrawItem).create(l);
end
function destroy();override;
begin
inherited;
class(TtageDrawItem).destroy();
end
[weakref] canvas;
end
type TGRIDMDRAWITEM = class(tuieventbase)
{**
@explan(说明) 表格控件绘制消息 %%
**}
function create(m,w,l,h);override;
begin
inherited;
end
canvas;
itemid;
Subitemid;
rcitem;
SubItemRect;
{**
@param(canvas)(tcanvas) 画板对象 %%
@param(itemid)(integer) 行号 %%
@param(Subitemid)(integer) 列号 %%
@param(SubItemRect)(array(左上右下) ) 区域%%
@param(rcitem)(array(左上右下) ) 区域%%
**}
end
type TMMEASUREITEM=class(tuieventbase,tslcstructureobj)
{**
@ignore(忽略) %%
@explan(说明) 系统控件测量消息
**}
static SFSTRUCT;
class function getstruct();
begin
if not SFSTRUCT then SFSTRUCT := MemoryAlignmentCalculate(array(
("ctltype","int",0),
("ctlid","int",0),
("itemid","int",0),
("itemwidth","int",0),
("itemheight","int",0),
("itemdata","intptr",0)));
return SFSTRUCT;
end
function create(m,w,l,h);override;
begin
inherited;
class(tslcstructureobj).create(getstruct(),l);
end
property ctlid index "ctlid" read _getvalue_;
property ctltype index "ctltype" read _getvalue_;
property id index "itemid" read _getvalue_;
property width index "itemwidth" read _getvalue_ write _setvalue_;
property height index "itemheight" read _getvalue_ write _setvalue_;
property itemid index "itemid" read _getvalue_;
property itemwidth index "itemwidth" read _getvalue_ write _setvalue_;
property itemheight index "itemheight" read _getvalue_ write _setvalue_;
{**
@param(ctlid)(integer) 控件id %%
@param(itemid)(integer) 控件在父窗口中的序号 %%
@param(width)(integer) 设置或者获取宽度 %%
@param(height)(integer) 设置或者获取高度 %%
**}
end
type TSIFTSTATE = class(TSLUICONST)
//protected
//FKeyState;
class function KeysToShiftState(Keys: PtrUInt): TShiftState;
begin
{**
@explan(说明) 解析按键状态 %%
**}
Result := array();
if (Keys .& MK_Shift) <> 0 then includestate(Result, ssShift);
if (Keys .& MK_Control) <> 0 then includestate(Result, ssCtrl);
if (Keys .& MK_LButton) <> 0 then includestate(Result, ssLeft);
if (Keys .& MK_RButton) <> 0 then includestate(Result, ssRight);
if (Keys .& MK_MButton) <> 0 then includestate(Result, ssMiddle);
if (Keys .& MK_XBUTTON1) <> 0 then includestate(Result, ssExtra1);
if (Keys .& MK_XBUTTON2) <> 0 then includestate(Result, ssExtra2);
if (Keys .& MK_DOUBLECLICK) <> 0 then includestate(Result, ssDouble);
if (Keys .& MK_TRIPLECLICK) <> 0 then includestate(Result, ssTriple);
if (Keys .& MK_QUADCLICK) <> 0 then includestate(Result, ssQuad);
global G_O_TSWIN32API_;
if G_O_TSWIN32API_ then
begin
v := G_O_TSWIN32API_.GetKeyState(VK_MENU);
end else v := 0;
if _shr(v,15) then includestate(Result, ssAlt);
//if gettswin32api().GetKeyState(VK_MENU) < 0 then includestate(Result, ssAlt);
//if (GetKeyState(VK_LWIN) < 0) or (GetKeyState(VK_RWIN) < 0) then Include(Result, ssMeta);
return Result;
end;
end
type TMMOUSEWHEEL=class(tuieventbase)
{**
@explan(说明)鼠标滚动消息类 %%
**}
function create(m,w,l,h);override;
begin
inherited;
end
function shiftstate();
begin
{**
@explan(说明) 按键状态 %%
@return(array of TShiftStateEnum menuber) shift 键集合
**}
if ifnil(FKeyState)then
begin
FKeyState := class(TSIFTSTATE).KeysToShiftState(lowparam());
end
return FKeyState;
end
property delta read hiwparamsigned;
property ypos read hilparamsigned;
property xpos read lolparamsigned;
{**
@param(ypos)(integer)鼠标的y坐标 %%
@param(xpos)(integer)鼠标的x坐标 %%
@param(delta)(integer)运动距离 %%
**}
private
FKeyState;
end
type TMMouse=class(tuieventbase)
{**
@explan(说明) 鼠标消息类 %%
**}
protected FButton;
public
function create(m,w,l,h);override;
begin
inherited;
end
{**
@param(xpos)(integer) x 位置 %%
@param(ypos)(integer) y 位置 %%
@param(FButton)(integer) 按键状态,继承时候使用 %%
**}
property xpos:integer read lolparamsigned;
property ypos:integer read hilparamsigned;
function pos();
begin
{**
@explan(说明) 获得位置信息 %%
@return(array) x,y 位置 %%
**}
return array(xpos(),ypos());
end
property Dummy read Lparam;
function SetButton(v);
begin
{**
@ignore(忽略) %%
**}
if ifnumber(v)then FButton := v;
else return FButton;
end
function button();
begin
{**
@explan(说明) 鼠标按键情况 %%
@return(member of TMouseButton)
**}
return FButton;
end
function shiftstate();
begin
{**
@explan(说明) 按键状态 %%
@return( array of TShiftStateEnum menuber) %%
**}
if ifnil(FKeyState)then
begin
FKeyState := class(TSIFTSTATE).KeysToShiftState(Wparam);
end
return FKeyState;
end
function setshiftdouble(v);
begin
{**
@ignore(忽略) %%
**}
shiftstate();
if ifnumber(v)then
begin
includestate(FKeyState,v);
end
end
function shiftdouble();
begin
{**
@explan(说明) 是否双击 %%
@return(bool) 是否双击
**}
shiftstate();
return(ssDouble in FKeyState);
end
private
FKeyState;
end
type TMSTYLECHANG=class(tuieventbase)
{**
@explan(说明)窗口样式改变消息 %%
**}
private
FSTyle;
function _getvalue_(n);
begin
return FSTyle._getvalue_(n);
end
function _setvalue_(n,v);
begin
return FSTyle._setvalue_(n,v);
end
public
function create(m,w,l,h);override;
begin
inherited;
FSTyle := new TSTYLESTRUCT(l);
end
property styleold index "styleold" read _getvalue_ write _setvalue_;
property stylenew index "stylenew" read _getvalue_ write _setvalue_;
{**
@param(stylenew)(integer) 新样式 %%
@param(styleold)(integer) 旧样式 %%
**}
end
implementation
initialization
finalization
end.