diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index e37d61d..2f6726b 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -4,7 +4,8 @@ unit UtslCodeEditor; 20220520 分离调试器代码 } interface -uses utslvcldesignerresource,cstructurelib,utslvclauxiliary,utslvclmemstruct,utslvclgdi,tslvcl,UTslmemo,UTslSynMemo,utslvclsyntaxparser,utslvcldebuger; +uses utslvcldesignerresource,cstructurelib,utslvclauxiliary,utslvclmemstruct,utslvclgdi, + tslvcl,UTslmemo,UTslSynMemo,utslvclsyntaxparser,utslvcldebuger; { 1. page标签 TPagees; TPageItem @@ -16,7 +17,7 @@ TPagees; TPageItem } function gettslexe(); -type TPageItem=class //标签项 +type TPageItem=class() //标签项 function Create(AOwner); begin FCaption := ""; @@ -29,11 +30,11 @@ type TPageItem=class // Tag := nil; end published - property Caption read FCaption write SetCaption; - property BitmapA read FBitmapA write SetBitmapA; - property BitmapB read FBitmapB write SetBitmapB; - tag; - Rect; + property Caption read FCaption write SetCaption; //标题 + property BitmapA read FBitmapA write SetBitmapA; //前面的图标 + property BitmapB read FBitmapB write SetBitmapB; //后面的关闭图标 + tag; //绑定变量 + Rect; //区域 protected function SetCaption(s); begin @@ -105,7 +106,7 @@ type TPage=class(TCustomControl) // begin return new TPageItem(self); end - function itemcaptionchenged(it); + function itemcaptionchenged(it); //标签等改变 begin if GetItemIndex(it)>= 0 then begin @@ -113,15 +114,15 @@ type TPage=class(TCustomControl) // InValidateRect(nil,false); end end - function ItemBitmapAChenged(it); + function ItemBitmapAChenged(it); //保存改变 begin if GetItemIndex(it)>= 0 then InValidateRect(it.Rect,false); end - function ItemBitmapBChenged(it); + function ItemBitmapBChenged(it); //关闭改变 begin if GetItemIndex(it)>= 0 then InValidateRect(it.Rect,false); end - function FontChanged();override; + function FontChanged();override;//字体改变 begin FLineHeight := font.Height+6; DoControlAlign(); @@ -139,7 +140,7 @@ type TPage=class(TCustomControl) // DoControlAlign(); inherited; end - function GetClientRect();override; + function GetClientRect();override; //获得新的区域 begin r := inherited; FPageRect := R; @@ -147,7 +148,7 @@ type TPage=class(TCustomControl) // FPageRect[3]:= r[1]; return r; end - function Paint();override; + function Paint();override; //绘制 begin dc := Canvas; ps := PAINTSTRUCT().rcPaint; @@ -162,7 +163,7 @@ type TPage=class(TCustomControl) // if not rc then continue; if Intersectrect(it.Rect,ps)then begin - if FItemIndex=i then + if FItemIndex=i then //选中 begin //dc.Brush.Color := rgb(244,205,205); dc.Brush.Color := 0xFa901E; @@ -204,7 +205,7 @@ type TPage=class(TCustomControl) // //dc.Stretchdraw(rc,FBmpClose); end end - function SetSel(it); + function SetSel(it); //选中 begin idx := GetItemIndex(it); if idx >= 0 and idx <> FItemIndex then @@ -212,7 +213,7 @@ type TPage=class(TCustomControl) // ItemIndex := idx; end end - function CloseAllItem(it); + function CloseAllItem(it); //关闭 begin FItemINdex :=-1; FCurrentITem := nil; @@ -236,7 +237,7 @@ type TPage=class(TCustomControl) // DoControlAlign(); InValidateRect(nil,false); end - function DeleteItemByIndex(idx);virtual; + function DeleteItemByIndex(idx);virtual;//删除序号 begin if idx >= 0 and idx0 then begin @@ -636,20 +637,6 @@ type TEditerAuxiliary=class(TPage) // if p then p.DoControlAlign(); end end - {function MouseDown(o,e);override; - begin - if CloseBtn then - begin - rc := ClientRect; - rc := rc := array(rc[2]-25,1,rc[2]-1,19); - if PointInRect(e.pos,rc) then - begin - callDatafunction(FOnCloseClick,o,e); - end - end - inherited; - end } - //property OnCloseClick read FOnCloseClick write FOnCloseClick; function DoControlAlign();override; begin if FIgnoreSize then @@ -666,7 +653,7 @@ type TEditerAuxiliary=class(TPage) // if CurrentItem then wnd := CurrentItem.Tag; if wnd then wnd.SetBoundsRect(Rc); end - function ShowPopUp(); + function ShowPopUp();//弹出 begin if not WSpOPUp then begin @@ -675,7 +662,7 @@ type TEditerAuxiliary=class(TPage) // end if not Visible then Visible := true; end - function MouseDown(o,e);override; + function MouseDown(o,e);override;//点击处理 begin if e.shiftdouble()and e.button()=mbLeft then begin @@ -706,7 +693,6 @@ type TEditerAuxiliary=class(TPage) // FFileFindWnd := nil; FOnCloseClick := nil; inherited; - //FOnCloseClick := nil; end function ShowByTag(tg); //显示 begin @@ -735,10 +721,10 @@ type TEditerAuxiliary=class(TPage) // it.tag.Visible := true; caption := it.Tag.Caption; end else - it.tag.Visible := false; + it.tag.Visible := false; end end - function AddWnd(wnd); + function AddWnd(wnd); //加入窗口 begin if wnd is class(TWincontrol)then begin @@ -771,7 +757,7 @@ type TEditerAuxiliary=class(TPage) // end type TExecuteEditer=class(TCustomControl) //执行编辑器 Protected - Type TExecuteMemoComp=class(TSynCompletion) + Type TExecuteMemoComp=class(TSynCompletion) //自动完成对象 function Create(AOwner); begin inherited; @@ -794,7 +780,7 @@ type TExecuteEditer=class(TCustomControl) //执 SetCompData(d); end end - type TListBoxb=class(TListBOx) + type TListBoxb=class(TListbox)//选择下拉 function Create(AOwner); begin inherited; @@ -803,14 +789,14 @@ type TExecuteEditer=class(TCustomControl) //执 begin return ifobj(it); end - function GetItemText(i);override; + function GetItemText(i);override;//获得标签 begin it := GetItem(i); if it then return it.FCaption; return ""; end function InsureItemVisible(idx); //移动当前的格子 - begin + begin rc := GetIdxRect(idx); c := ClientRect; if rc[1]0; end - procedure EnsureMaxEntries(); + procedure EnsureMaxEntries(); //达到最大数量处理 begin if fItems.length()>fMaxUndoActions then begin //mh 2000-10-03 @@ -217,7 +217,7 @@ type TTslMenoUndoList=class() //undolist end; end; end - function GetItemCount():integer; + function GetItemCount():integer;//数量 begin return fItems.length(); end @@ -260,35 +260,35 @@ type TTslMenoUndoList=class() //undolist fItems.splices(nil,nil,array()); fFullUndoImposible := FALSE; end - procedure Lock(); + procedure Lock();//锁住 begin fLockCount++; end - procedure Unlock(); + procedure Unlock(); //解锁 begin if fLockCount>0 then fLockCount--; return fLockCount; end - function PeekItem():TSynEditUndoItem; + function PeekItem():TSynEditUndoItem; //取得 begin iLast := fItems.length()-1; if iLast >= 0 then return fItems[iLast]; return nil; end - function PopItem():TSynEditUndoItem; + function PopItem():TSynEditUndoItem;//弹出 begin if fLockCount>0 then return nil; if fItems.length()then return fItems.Pop(); return nil; end - procedure PushItem(Item); + procedure PushItem(Item); //插入 begin if fLockCount>0 then return nil; fItems.push(Item); if datatype(fOnAdded)=7 then call(fOnAdded,Self(true)); end public - function MergeReplaceItem(); //操作 + function MergeReplaceItem(); //合并操作 begin if fItems.Length()>= 2 then begin @@ -309,7 +309,7 @@ type TTslMenoUndoList=class() //undolist property MaxUndoActions:integer read fMaxUndoActions write SetMaxUndoActions; // property OnAddedUndo: TNotifyEvent read fOnAdded write fOnAdded; end; -type TCustomMemoCmd=class() +type TCustomMemoCmd=class() //编辑器操作码类 {** @explan(说明)编辑器控件操作码类%% **} @@ -627,51 +627,50 @@ type TCustomMemoCmd=class() end end -type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) +type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //编辑器基类 {** @explan(说明) 带滚动条的编辑控件 %% **} private - fundoing; - fredoing; + fundoing; //清空unredo标记 + fredoing; //清空unredo标记 fselectbkcolor;//rgb(192,192,192); fcurrentLineColor;//rgb(232,232,255); fguttercolor; - Fecruningto; //调试运行到 - FLineInterval; - FSetPostioned; - FIsCaretShow; - FCaretCareted; - fForceCaret; + Fecruningto; //调试运行到行 + FLineInterval; //行间距 + FSetPostioned; //位置改变 + FIsCaretShow; //光标可见 + fcaretcreated; //光标已经构造成功 + fForceCaret; FCharsInWindow; // - fTextHeight; - fLinesInWindow; // - fMaxCharsInRow; - FRowHeight; // - FCharHeight; - FCharWidth; - FLeftChar; + fTextHeight; //行高 + fLinesInWindow; //能显示的行数 + fMaxCharsInRow; //行容纳字符数目 + FCharHeight; //字符高度 + FCharWidth; //字符宽度 + FLeftChar; //左边隐藏的字符数 FTopLine; //首行 - FScroolChanged; - FGutterCharCount; - FGutter; + FScroolChanged; //滚动了 + FGutterCharCount; //gutter 字符个数 + FGutter; //gutter FMarginTop; FLines; - fLastCaretY; - fCaretLineNeedPaint; - fCaretX; - fCaretY; - fBlockBegin:TPoint; - fBlockEnd:TPoint; - FScrollTimer; + fLastCaretY; //最新y位置 + //fCaretLineNeedPaint; + fCaretX; //光标位置 + fCaretY; //光标位置 + fBlockBegin:TPoint; //选中位置 + fBlockEnd:TPoint; //选中位置 + //FScrollTimer; FMouseIsDown; - FInPutCache; - FSelectionMode; - FCopyer; - FReadOnly; + FInPutCache; //汉字输入缓存 + FSelectionMode; //选中模式 + FCopyer; //剪切板 + FReadOnly; //只读 fUndoList; //撤销 fRedoList; //反撤销 - //************** + //******操作标记******** static crInsert; static crPaste; static crDragDropInsert; @@ -950,26 +949,29 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) FSetPostioned := 0; InvalidateRect(nil,false); end - function sinit();override; + class function sinit();override; begin - crInsert := 1; - crPaste := 2; - crDragDropInsert := 3; - crDeleteAfterCursor := 4; - crDelete := 5; - crLineBreak := 6; - crIndent := 6; - crUnindent := 7; - crSilentDelete := 8; - crSilentDeleteAfterCursor := 9; - crNothing := 10; - smNormal := 0; - smLine := 1; - smColumn := 2; - InitCommandConst(); + if not crInsert then + begin + crInsert := 1; + crPaste := 2; + crDragDropInsert := 3; + crDeleteAfterCursor := 4; + crDelete := 5; + crLineBreak := 6; + crIndent := 6; + crUnindent := 7; + crSilentDelete := 8; + crSilentDeleteAfterCursor := 9; + crNothing := 10; + smNormal := 0; + smLine := 1; + smColumn := 2; + InitCommandConst(); + end inherited; end - public + public //滚动刷新,构造 function IncPaintLock(); begin BeginUpdate(); @@ -1034,14 +1036,14 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) fRedoList := new TTslMenoUndoList(); end - function ClipCursor(); + function ClipCursor(); //固定光标区域 begin FMouseIsDown := true; crect := ClientRect; ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3])); _wapi.clipcursor(ps); end - function UnClipCursor(); + function UnClipCursor(); //解除固定区域 begin if FMouseIsDown then begin @@ -1049,12 +1051,12 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) _wapi.ClipCursor(0); end end - function ComputeAndSelToCaret(y,x); + function ComputeAndSelToCaret(y,x);//计算光标位置 begin xy := PixelsToRowColumn(x,y); ExecuteCommand(ecSelGotoXY,xy); end - function ClearSelBlock(); + function ClearSelBlock(); //清楚选中 begin bg := BlockBegin; ed := BlockEnd; @@ -1066,11 +1068,11 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) InvalidateRect(nil,false); end end - function TrySetFoucs(); + function TrySetFoucs(); //设置focus begin if not FHasFocus then SetFocus(); end - function MouseMoveSel(x,y); + function MouseMoveSel(x,y);//移动鼠标选择 begin if FMouseIsDown then begin @@ -1097,7 +1099,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) return ; end end - function MouseDown(o,e);override; + function MouseDown(o,e);override; //按下鼠标 begin if class(tmemlocker).haslocker then return ; inherited; @@ -1128,11 +1130,11 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) end ; end - function MouseMove(o,e);override; + function MouseMove(o,e);override;//移动 begin return MouseMOVESel(e.xpos,e.ypos); end - function WMIMECHAR(o,e):WM_IME_CHAR; + function WMIMECHAR(o,e):WM_IME_CHAR;//imechar处理,无用到 begin return; r := " "; @@ -1171,7 +1173,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) UpDateCaret(); end end - function keypress(o,e);override; + function keypress(o,e);override; //输入字符 begin if class(tmemlocker).haslocker then return ; if e.skip then return; @@ -1200,7 +1202,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) end inherited; end - function InsertChars(s);virtual; + function InsertChars(s);virtual;//当前位置插入字符 begin if not(ifstring(s) {and s})then return; if SelAvail then @@ -1216,19 +1218,19 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) UpdateCaret(); memtextchanged(bb); end - function DoTextChanged(p);virtual; + function DoTextChanged(p);virtual;//文本改变 begin //改变 end - function DoCaretPosChanged();virtual; + function DoCaretPosChanged();virtual;//caret位置改变 begin end - function ClearUndo(); + function ClearUndo(); //清空undo begin fUndoList.Clear(); fRedoList.Clear(); end - function ClearAll(); + function ClearAll();//清空 begin fLines.text := ""; FCaretX := FCaretY := 1; @@ -1253,11 +1255,11 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) RedoItem(); end end - function CharInput(c);virtual; + function CharInput(c);virtual;//插入字符 begin if not ReadOnly then return InsertChars(c); end - function ExecuteCommand(cmd,data);override; + function ExecuteCommand(cmd,data);override;//执行命令 begin {** @explan(说明) 执行操作 %% @@ -1510,7 +1512,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) DecPaintLock(); end; end - function MoveCaretAndSelection(p1,p2,sel); + function MoveCaretAndSelection(p1,p2,sel);//移动选择 begin if not(ifarray(p2)and ifarray(p1)and p2[0]>= 1 and p2[1]>= 1)then return; SetCaretXY(p2); @@ -1539,29 +1541,29 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) DecPaintLock(); end published - property ReadOnly:bool read FReadOnly write setreadolny; + property ReadOnly:bool read FReadOnly write setreadolny; //只读 property SelAvail read GetSelAvail; - property Text:text read GetMemoText write SetMemoText; - property TopLine read FTopLine write SetTopLine; - property LeftChar read FLeftChar write SetLeftChar; + property Text:text read GetMemoText write SetMemoText; //文本 + property TopLine read FTopLine write SetTopLine; //首行 + property LeftChar read FLeftChar write SetLeftChar; property CharsInWindow:Integer read fCharsInWindow; property LinesInWindow:Integer read fLinesInWindow; - property LineHeight read fTextHeight; + property LineHeight read fTextHeight; //行高 property BlockBegin:TPoint read GetBlockBegin write SetBlockBegin; property BlockEnd:TPoint read GetBlockEnd write SetBlockEnd; property CaretX:Integer read fCaretX write SetCaretX; property CaretY:Integer read fCaretY write SetCaretY; property CaretXY:TPoint read GetCaretXY write SetCaretXY; - property SelText read GetSelText write SetSelTextExternal; - property LineText:AnsiString read GetLineText write SetLineText; - property Lines read fLines; + property SelText read GetSelText write SetSelTextExternal; //选中文本 + property LineText:AnsiString read GetLineText write SetLineText; //当前行 + property Lines read fLines; //文本集合 property SelectionMode read FSelectionMode write SetSelectionMode; - property GutterWidth read GetGutterWidth; - property LineInterval read FLineInterval write SetLineInterval; + property GutterWidth read GetGutterWidth; + property LineInterval read FLineInterval write SetLineInterval;//行间距 property GutterCharCnt:integer read FGutterCharCount write SetGutterCharCnt; property currentLineColor:color read fcurrentLineColor write setcurrentLineColor; - property guttercolor:color read fguttercolor write setguttercolor; - property selectbkcolor:color read fselectbkcolor write setselectbkcolor; + property guttercolor:color read fguttercolor write setguttercolor; //行标颜色 + property selectbkcolor:color read fselectbkcolor write setselectbkcolor; //选中的颜色 {** @param(ReadOnly)(bool) 是否只读%% @param(Text)(string) 文本%% @@ -1572,11 +1574,11 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) @param(GutterCharCnt)(integer) 行号的宽度%% **} public - function UpDateCaret(); + function UpDateCaret(); //更新光标 begin if IsUpDating()then return fForceCaret := true; fForceCaret := false; - if not FCaretCareted then return; + if not fcaretcreated then return; if HandleAllocated()then begin if fCaretX >= fLeftChar and(fCaretX= tl and fCaretY <= vl then begin - fCaretLineNeedPaint := false; + //fCaretLineNeedPaint := false; end else begin TopLine := fCaretY; @@ -2317,21 +2319,21 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) function CreateCaret(); //构造光标 begin if FReadOnly then return; - if FCaretCareted then return; + if fcaretcreated then return; h := Font.Height; hd := Handle; _wapi.CreateCaret(hd,nil,1,h); _wapi.ShowCaret(hd); - FCaretCareted := true; + fcaretcreated := true; end function DestroyCaret(); //销毁光标 begin - if FCaretCareted then + if fcaretcreated then begin _wapi.HideCaret(self.Handle); _wapi.DestroyCaret(); end - FCaretCareted := false; + fcaretcreated := false; FIsCaretShow := false; end FHasFocus; @@ -2441,16 +2443,7 @@ type TSynCompletionList = class(TcustomListBox) //展示list private function InsureItemVisible(idx); //移动当前的格子 begin - rc := GetIdxRect(idx); - c := ClientRect; - if rc[1]c[3] then - begin - SetYpos( 1+GetYPos()+(rc[3]-c[3]+1)/GetYScrollDelta()); - end + return InsureIdxInClient(idx); end end type TSynCompletion = class(TSynCompletionList) diff --git a/funcext/tvclib/utslvclstdctl.tsf b/funcext/tvclib/utslvclstdctl.tsf index e8c9021..f041a36 100644 --- a/funcext/tvclib/utslvclstdctl.tsf +++ b/funcext/tvclib/utslvclstdctl.tsf @@ -5,19 +5,19 @@ interface @date(20220509) **} uses utslvclauxiliary,utslvclbase,utslvclgdi,utslvclaction,utslvclmenu; -type TcustomClipBoard=class(tcomponent) +type TcustomClipBoard=class(tcomponent) //剪切板基类 {** @explan(说明) 剪切板类 %% **} private private FIsopen; - function CloseClipboard(); + function CloseClipboard(); //关闭 begin if FIsopen then FIsopen := not _wapi.CloseClipboard(); return not(FIsopen); end - function OpenClipboard(); + function OpenClipboard(); //打开 begin {** @explan(说明) 打开剪切板 %% @@ -25,14 +25,14 @@ type TcustomClipBoard=class(tcomponent) IF not(FIsopen)then FIsopen := _wapi.OpenClipboard(0); return FIsopen; end - function EmptyClipboard(); + function EmptyClipboard();//清空 begin {** @explan(说明) 清空剪切板 %% **} if FIsopen then _wapi.EmptyClipboard(); end - function SetText(s); + function SetText(s); //设置字符串 begin {** @explan(说明) 设置字符串到剪切板 %% @@ -41,7 +41,7 @@ type TcustomClipBoard=class(tcomponent) ret :=-1; if not(ifstring(s)and length(s)>0)then begin - return-1; + return -1; end OpenClipboard(); try @@ -52,7 +52,7 @@ type TcustomClipBoard=class(tcomponent) end; return ret; end - function GetText(); + function GetText(); //获得字符串 begin {** @explan(说明) 获得剪切板字符串 %% @@ -69,7 +69,7 @@ type TcustomClipBoard=class(tcomponent) end; return r; end - function SetBitmap(v); + function SetBitmap(v); //设置图片 begin if v is class(tcustombitmap)then begin @@ -86,7 +86,7 @@ type TcustomClipBoard=class(tcomponent) end end end - function Getbitmap(); + function Getbitmap(); //获得图片 begin OpenClipboard(); try @@ -236,7 +236,7 @@ type TCustomTimer = class(tcomponent)// {** @explan(说明)启动 %% **} - if not((datatype(FOntimer) = 7 )and FInterval)>0 then return-1; + if not((datatype(FOntimer) = 7 )and FInterval)>0 then return -1; if FStart then return FStart; ret := _wapi.SetTimer(nil,Fid,FInterval,getwinprocptr(2)); _kill0 := ret; @@ -276,7 +276,7 @@ type TCustomTimer = class(tcomponent)// begin inherited; end - class function _timeproc_(hwnd,message,wparam,lparam); + class function _timeproc_(hwnd,message,wparam,lparam); //消息分发 begin {** @explan(说明) 定时回调入接口 %% @@ -293,7 +293,7 @@ type TCustomTimer = class(tcomponent)// end //return _twinproc_(hwnd,message,wparam,lparam); end - class function Sinit();override; + class function Sinit();override; //初始化 begin {** @explan(说明)初始化定时器全局 %% @@ -305,7 +305,7 @@ type TCustomTimer = class(tcomponent)// end inherited; end - function tproc(e);virtual; + function tproc(e);virtual; //分发定时器 begin if e.wparam and(e.wparam=_kill0)then begin @@ -313,9 +313,9 @@ type TCustomTimer = class(tcomponent)// return 1; end end - property Interval:integer read FInterval write SetInterval; - property Ontimer:eventhandler read FOntimer write FOntimer; - property Enabled:bool read FStart Write SetEnabled; + property Interval:integer read FInterval write SetInterval; //间隔 + property Ontimer:eventhandler read FOntimer write FOntimer; //回调 + property Enabled:bool read FStart Write SetEnabled; //启动 property id read FID; {** @param(Interval)(integer) 设置运行间隔 %% @@ -323,7 +323,7 @@ type TCustomTimer = class(tcomponent)// @param(Enabled)(bool) 是否已经启动 %% **} end -type tcustombtn = class(TCustomControl) +type tcustombtn = class(TCustomControl) //按钮 {** @explan(说明) 普通按钮 %% **} @@ -337,14 +337,14 @@ type tcustombtn = class(TCustomControl) Height:=31; Color := _wapi.GetSysColor(COLOR_MENUBAR); end - function click();virtual; + function click();virtual; //点击 begin {** @explan(说明)模拟点击按钮一下的操作%% **} if handleAllocated() then _send_(BM_CLICK,0,0); end - function BMCLICK(o,e):BM_CLICK;virtual; + function BMCLICK(o,e):BM_CLICK;virtual; //点击消息处理 begin if csDesigning in ComponentState then return ; if FdoingClick then return ; @@ -359,7 +359,7 @@ type tcustombtn = class(TCustomControl) FdoingClick := false; // end; end - function WMKEYDOWN(o,e);override; + function WMKEYDOWN(o,e);override; //按键enter处理 begin inherited; case e.CharCode of @@ -370,7 +370,7 @@ type tcustombtn = class(TCustomControl) end ; end - function MouseDown(o,e);override; + function MouseDown(o,e);override; //按下 begin if csDesigning in ComponentState then return ; if not Fbtnstate then @@ -380,7 +380,17 @@ type tcustombtn = class(TCustomControl) end inherited; end - function WMLBUTTONUP(o,e):WM_LBUTTONUP;override; + function MouseUp(o,e);override;//处理点击事件 + begin + if csDesigning in ComponentState then return ; + click(); + if Fbtnstate then + begin + Fbtnstate := 0; + InvalidateRect(nil,false); + end + end + {function WMLBUTTONUP(o,e):WM_LBUTTONUP;override; begin if csDesigning in ComponentState then return ; click(); @@ -399,8 +409,8 @@ type tcustombtn = class(TCustomControl) Fbtnstate := 0; InvalidateRect(nil,false); end - end - function dosetfocus(o,e);override; + end } + function dosetfocus(o,e);override;//获得焦点 begin {** @explan(说明) 控件获得焦点 %% @@ -411,7 +421,7 @@ type tcustombtn = class(TCustomControl) FBtnfocused := true; InvalidateRect(nil,false); end - function dokillfocus(o,e);override; + function dokillfocus(o,e);override;//失掉焦点 begin {** @explan(说明) 控件失去焦点 %% @@ -423,7 +433,7 @@ type tcustombtn = class(TCustomControl) InvalidateRect(nil,false); end - function paint();override; + function paint();override;//绘制 begin if Fbtnstate then begin @@ -484,7 +494,7 @@ type tcustombtn = class(TCustomControl) end end - function FontChanged(o);override; + function FontChanged(o);override; //字体改变 begin inherited; InvalidateRect(nil,false); @@ -495,8 +505,8 @@ type tcustombtn = class(TCustomControl) FonSetFocus := nil; FonKillFocus := nil; end - property textPos:AlignStyle9 read FtextPosition write setTextPosition; - property pushLike:bool read FpushLike write setPushLike; + property textPos:AlignStyle9 read FtextPosition write setTextPosition; //文字对齐 + property pushLike:bool read FpushLike write setPushLike; property multiLine:bool read FmultiLine write setMultiLine; {** @param(textPos)(member of TAlignStyle9) 文本位置%% @@ -521,7 +531,7 @@ type tcustombtn = class(TCustomControl) if bs = caption then return ; InvalidateRect(nil,false); end - function PaintMouseDown();virtual; + function PaintMouseDown();virtual; //按下绘制 begin r := ClientRect; dc := Canvas; @@ -537,7 +547,7 @@ type tcustombtn = class(TCustomControl) dc.pen.style := bps; end private - function paintfocus(dc,r); + function paintfocus(dc,r); //绘制焦点 begin dc.pen.color := rgb(150,200,230); dc.pen.width := 1; @@ -586,7 +596,7 @@ type tcustombtn = class(TCustomControl) FtextPosition; Fbtnstate; end -type tcustomcheckbtn=class(tcustombtn) +type tcustomcheckbtn=class(tcustombtn) //checkbtn {** @explan(说明) 复选框 %% **} @@ -627,7 +637,7 @@ type tcustomcheckbtn=class(tcustombtn) FcheckState; FCheckRect; private - function drawchekd(r);virtual; + function drawchekd(r);virtual; //绘制选择按钮 begin if r then begin @@ -637,7 +647,7 @@ type tcustomcheckbtn=class(tcustombtn) dc.Draw("framecontrol",array(r[0:1],r[2:3]),DFC_BUTTON,(checked)?DFCS_CHECKED:DFCS_BUTTONCHECK); end end - function setChecked(v);virtual; + function setChecked(v);virtual; //设置选择 begin nv := v?true:false; if nv<>FcheckState then @@ -655,7 +665,7 @@ type tcustomcheckbtn=class(tcustombtn) InvalidateRect(nil,false); end end - function GetBtnTextRect();virtual; + function GetBtnTextRect();virtual; //选择框位置计算 begin r := ClientRect; h := r[3]-r[1]; @@ -672,7 +682,7 @@ type tcustomcheckbtn=class(tcustombtn) return r; end end -type tcustomradiobtn = class(tcustomcheckbtn) +type tcustomradiobtn = class(tcustomcheckbtn) //单选按钮 {** @explan(说明)radiobtn单选按钮控件 **} @@ -736,7 +746,7 @@ type tcustomradiobtn = class(tcustomcheckbtn) end end end -type teditable=class(TSLUIBASE) +type teditable=class(TSLUIBASE) //编辑控件基类 private FInsertState; FReadOnly; @@ -760,7 +770,7 @@ type teditable=class(TSLUIBASE) FClientRect; FFont; FVisible; - function SetVisible(v); + function SetVisible(v); //可见 begin nv := v?true:false; if nv <> FVisible then @@ -774,7 +784,7 @@ type teditable=class(TSLUIBASE) CalcFontSize(); end end - function SetFont(f); + function SetFont(f); //字体改变 begin if f then begin @@ -789,14 +799,14 @@ type teditable=class(TSLUIBASE) updatecaret(); end end - function InvalidateRect(rec,flg); + function InvalidateRect(rec,flg); //刷新 begin if FHost and FHost.HandleAllocated()then begin FHost.InvalidateRect(rec?rec:FClientRect,flg); end end - function SetHost(host); + function SetHost(host); //设置宿主 begin if FHost=host then return; ohost := FHost; @@ -810,7 +820,7 @@ type teditable=class(TSLUIBASE) if ohost then ohost.InvalidateRect(GetEntryRect(),false); end end - function SetBorder(v); + function SetBorder(v); //边框 begin n := v?true:false; if n <> FBorder then @@ -819,7 +829,7 @@ type teditable=class(TSLUIBASE) InvalidateRect(nil,false); end end - Function Setplaceholder(p); + Function Setplaceholder(p); //提示 begin if p and ifstring(p)and Fplaceholder <> p then begin @@ -827,7 +837,7 @@ type teditable=class(TSLUIBASE) if FHost and not(FString)and FHost.HandleAllocated()then InvalidateRect(nil,false); end end - function recreateCarete(); + function recreateCarete();//重构光标 begin DestroyCaret(); CreateCaret(); @@ -855,7 +865,7 @@ type teditable=class(TSLUIBASE) end FIsCaretShow := false; end - function updatecaret(); + function updatecaret();//更新光标 begin if FCanShowCaret and FHost and FHost.HandleAllocated()then begin @@ -864,7 +874,7 @@ type teditable=class(TSLUIBASE) _Wapi.SetCaretPos(cx,FCaretY); end end - function InitSel(); + function InitSel();//取消选择 begin FSelBegin := FCaretX; FSelLength := 0; @@ -892,7 +902,7 @@ type teditable=class(TSLUIBASE) InvalidateRect(nil,false); end end - function setEditText(s); + function setEditText(s); //设置文本 begin if ifstring(s)and s <> FString then begin @@ -948,7 +958,7 @@ type teditable=class(TSLUIBASE) InvalidateRect(nil,false); updatecaret(); end - function selectall(); + function selectall();//全选 begin if FString and(FSelBegin <> 1 or FSelLength <> length(FString))then begin @@ -957,7 +967,7 @@ type teditable=class(TSLUIBASE) InvalidateRect(nil,false); end end - function getselstring(b,e); + function getselstring(b,e);//获得选择的 begin if FSelLength <> 0 then begin @@ -969,7 +979,7 @@ type teditable=class(TSLUIBASE) end return ""; end - function DeleteSel(); + function DeleteSel();//删除选中 begin if FSelLength <> 0 then begin @@ -989,7 +999,7 @@ type teditable=class(TSLUIBASE) doOnChange(); end end - function DeletePerfect(); + function DeletePerfect();//向前删除 begin if FLeftCharCount>0 then begin @@ -1004,7 +1014,7 @@ type teditable=class(TSLUIBASE) end end end - function dodelete(); + function dodelete();//向后删除 begin if FReadOnly then return; if FSelLength <> 0 then return deletesel(); @@ -1030,7 +1040,7 @@ type teditable=class(TSLUIBASE) doOnChange(); end end - function BeginUpDate(); + function BeginUpDate(); //锁定 begin if FHost and FHost.HandleAllocated()then begin @@ -1044,7 +1054,7 @@ type teditable=class(TSLUIBASE) FHost.EndUpDate(); end end - function dobackspace(); + function dobackspace();//backsapce处理 begin if FReadOnly then return; if FSelLength <> 0 then return deletesel(); @@ -1071,7 +1081,7 @@ type teditable=class(TSLUIBASE) doOnChange(); end end - function GetCBoard(); + function GetCBoard(); //剪切板 begin if not FCopyer then begin @@ -1084,7 +1094,7 @@ type teditable=class(TSLUIBASE) r := getselstring(); GetCBoard().text := r; end - function PasteFromClipBoard(); + function PasteFromClipBoard();//粘贴 begin if readonly then return; t := GetCBoard().text; @@ -1212,7 +1222,7 @@ type teditable=class(TSLUIBASE) begin ns := c[1:nct+1]; end else - ns := c[1:nct]; + ns := c[1:nct]; return InsertChar(ns); end end @@ -1383,7 +1393,7 @@ type teditable=class(TSLUIBASE) r[3]-= 1; return r; end - function WMKEYDOWN(o,e);virtual; + function WMKEYDOWN(o,e);virtual;//按键 begin fsft := ssShift in e.shiftstate; fctl := ssCtrl in e.shiftstate; @@ -1446,8 +1456,9 @@ type teditable=class(TSLUIBASE) end end end - function WMCHAR(o,e);virtual; + function WMCHAR(o,e);virtual;//字符 begin + if fcanundo then fredolist.clear();//清空 c := e.CharCode; case c of VK_BACK: @@ -1468,9 +1479,11 @@ type teditable=class(TSLUIBASE) FHafChar := e.char; end end else - InsertChar(e.char); + begin + InsertChar(e.char); + end end - function FontChanged(o);override; + function FontChanged(o);override;//字体 begin if FHost and FHost.HandleAllocated()then begin @@ -1484,7 +1497,7 @@ type teditable=class(TSLUIBASE) end end end - function Paint(); + function Paint(); //绘制 begin if not FVisible then return; if not(FHost and FHost.HandleAllocated()and FHost.Canvas.HandleAllocated())then return; @@ -1589,7 +1602,7 @@ type teditable=class(TSLUIBASE) if not FIsCaretShow then return SetFocus(); end end - function SetFocus(); + function SetFocus(); //设置焦点 begin if not FVisible then return; FSetFocused := true; @@ -1602,7 +1615,7 @@ type teditable=class(TSLUIBASE) if FFocusBorder then InvalidateRect(nil,false); doonsetfocus(); end - function KillFocus(); + function KillFocus();//删除焦点 begin FMouseLbuttonDown := false; _wapi.ClipCursor(0); //添加输入焦点处理 @@ -1927,7 +1940,7 @@ type tVirtualCalender=class(TSLUIBASE) y := p1-FTop; pp := array(x,y); if pointinrect(pp,FIncRect)then return 1; - if pointinrect(pp,FDecRect)then return-1; + if pointinrect(pp,FDecRect)then return -1; end end "megetbypos": @@ -2965,7 +2978,7 @@ type TCustomListBoxbase=class(TCustomScrollControl) begin py := GetYPos(); r := integer(y/GetYScrollDelta())+py; - if r >= FItemCount then return-1; + if r >= FItemCount then return -1; return r; end function GetIdxRect(idx);virtual; @@ -3218,7 +3231,7 @@ type TcustomListBox=class(TCustomListBoxbase) begin return FSelBegin; end - return-1; + return -1; end function setCurrentSelection(n);virtual; begin @@ -3318,7 +3331,7 @@ type TcustomListBox=class(TCustomListBoxbase) class(TCustomListBoxbase).ItemCount := FitemData.length(); return ItemCount-1; end - return-1; + return -1; end function appendItems(ari);virtual; begin @@ -3352,7 +3365,7 @@ type TcustomListBox=class(TCustomListBoxbase) class(TCustomListBoxbase).ItemCount := FitemData.length(); return n; end - return-1; + return -1; end function insertItems(ari,n);virtual; begin @@ -3371,7 +3384,7 @@ type TcustomListBox=class(TCustomListBoxbase) class(TCustomListBoxbase).ItemCount := FitemData.length(); return n+length(ari)-1; end else - return-1; + return -1; end function deleteItem(n);override; begin @@ -3445,6 +3458,7 @@ type TcustomListBox=class(TCustomListBoxbase) function findStrExact(str,b,n);virtual; begin {** + @ignore(忽略) %% @explan(说明)在列表框中指定项之后查找与字符串相同的项,到达末尾即从头开始%% @param(str)(string)给定字符串%% @param(b)(bool)1:不区分大小写,0:区分大小写,默认为0%% @@ -3460,7 +3474,7 @@ type TcustomListBox=class(TCustomListBoxbase) else return findExact(str,n); end ShowErrorMessage("function findStrExact:ErrorParameter(s)"); - return-1; + return -1; end function setData(ari);virtual; begin @@ -3590,25 +3604,25 @@ type TcustomListBox=class(TCustomListBoxbase) begin len := class(TCustomListBoxbase).ItemCount; while i++<> len do if AnsiStartsStr(str,getItem((i+n)%len))then return(i+n)%len; - return-1; + return -1; end function findBeginwithCaseIndepent(str,n); begin len := class(TCustomListBoxbase).ItemCount; while i++<> len do if AnsiStartsText(str,getItem((i+n)%len))then return(i+n)%len; - return-1; + return -1; end function findExact(str,n); begin len := class(TCustomListBoxbase).ItemCount; - while i++<> len do if getItem((i+n)%len)=str then return(i+n)%len; - return-1; + while i++ <> len do if getItem((i+n)%len)=str then return(i+n)%len; + return -1; end function findExactCaseIndepent(str,n); begin len := class(TCustomListBoxbase).ItemCount; - while i++<> len do if UpperCase(getItem((i+n)%len))=UpperCase(str)then return(i+n)%len; - return-1; + while i++ <> len do if UpperCase(getItem((i+n)%len))=UpperCase(str)then return(i+n)%len; + return -1; end function SelRange(sel); begin @@ -4550,9 +4564,9 @@ type TcustomToolBar=class(TCustomControl) @param(btn)(TToolButton) 工具栏项 %% @param(idx)(TToolButton | integer) 位置 %% **} - if not(idx >= 0)then return-1; + if not(idx >= 0)then return -1; cidx := IndexOfBtn(btn); - if cidx<0 then return-1; + if cidx<0 then return -1; if cidx=idx then return idx; btnlength := FButtons.Length(); if idx>cidx then @@ -4607,7 +4621,7 @@ type TcustomToolBar=class(TCustomControl) @param(btn)(TToolButton) 工具栏项%% **} idx := IndexOfBtn(btn); - if idx=-1 then return-1; + if idx=-1 then return -1; if btn.willaddBar <>-1986 then begin return btn.Parent := nil; @@ -5167,7 +5181,7 @@ type TcustomStatusBar=class(TCustomControl) @param(str)(string) 文本 %% @param(wd)(number) 宽度 ,大于1 表示绝对宽阔 ,小于1 表示相对宽度 %% **} - if not ifstring(str)then return-1; + if not ifstring(str)then return -1; if not(wd>0)then wd := 100; Fitems[Length(Fitems)]:= array("text":str,"width":wd); if HandleAllocated()then @@ -5181,7 +5195,7 @@ type TcustomStatusBar=class(TCustomControl) @explan(说明) 删除项目 %% @param(id)(integer) 序号 %% **} - if not(itemidok(id))then return-1; + if not(itemidok(id))then return -1; deleteindex(Fitems,id,true); if HandleAllocated()then begin @@ -5196,7 +5210,7 @@ type TcustomStatusBar=class(TCustomControl) @param(id)(integer) 序号 %% **} if not ifstring(str)then return-1; - if not(itemidok(id))then return-1; + if not(itemidok(id))then return -1; Fitems[id,"text"]:= str; if HandleAllocated()then begin