From 5fb0e102d923a886d2ec024d8879c0ab0047b185 Mon Sep 17 00:00:00 2001 From: JianjunLiu Date: Fri, 26 Aug 2022 17:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 娣诲姞coolbar --- designer/tslvcldesigner.tsf | 63 +-- funcext/tvclib/tcontrol.tsf | 69 ++- funcext/tvclib/tgraphiccontrol.tsf | 11 +- funcext/tvclib/tslvcl.tsf | 4 +- funcext/tvclib/twincontrol.tsf | 43 +- funcext/tvclib/ugtkinterface.tsf | 4 +- funcext/tvclib/utslvclauxiliary.tsf | 27 +- funcext/tvclib/utslvclcoolbar.tsf | 677 ++++++++++++++++++++++++++++ 8 files changed, 839 insertions(+), 59 deletions(-) create mode 100644 funcext/tvclib/utslvclcoolbar.tsf diff --git a/designer/tslvcldesigner.tsf b/designer/tslvcldesigner.tsf index 5ccdf57..31c5263 100644 --- a/designer/tslvcldesigner.tsf +++ b/designer/tslvcldesigner.tsf @@ -1817,7 +1817,7 @@ type TVclDesigner = class(tvcform) pedits := new TPageControl(self); pedits.align := alclient; FProp := new TTabSheet(self); - FProp.caption := "propertys"; + FProp.caption := "properties"; FEvent := new TTabSheet(self); FEvent.caption := "events"; FPropGrid := new TPropEditGrid(self); @@ -4542,7 +4542,7 @@ type TGridCellNaturalEdit = class(TGridPropertyRender,TPropertyNatural) @explan(说明) 绘制格子 %% **} if FGrid is class(TDrawGrid) then - e.canvas.drawtext(numbertotext(d["value"]),e.subItemRect,DT_CENTER); + e.canvas.drawtext(numbertotext(d["value"]),e.subItemRect,DT_CENTER .| DT_VCENTER .| DT_SINGLELINE); end function CellLeave(grid);virtual; begin @@ -4771,7 +4771,7 @@ type TGridCellDirectoryEdit = class(TGridCellEditWithButton,TPropertyDirectory) **} if ifarray(d) then begin - dc.drawtext(d["value"],rect); + dc.drawtext(d["value"],rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function CellLeave();override; @@ -4812,7 +4812,7 @@ type TGridCellFileNameEdit = class(TGridCellEditWithButton,TPropertyFileName) **} if ifarray(d) then begin - dc.drawtext(d["value"],rect); + dc.drawtext(d["value"],rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function CellLeave();override; @@ -4856,7 +4856,7 @@ type TGridCellFontEdit = class(TGridCellEditWithButton,TPropertyFont) dc.SaveDC(); dc.font := d["value"]; - dc.drawtext("tfont",rect); + dc.drawtext("tfont",rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); dc.RestoreDC(); end function CellLeave();override; @@ -4924,7 +4924,7 @@ type TGridCellhotkeyEdit = class(TGridPropertyRender,TPropertyHotkey) **} if FGrid is class(TDrawGrid) then if ifarray(d) then - e.canvas.drawtext(class(thotkey).hotkeytostr(d["value"]),e.subItemRect,DT_CENTER); + e.canvas.drawtext(class(thotkey).hotkeytostr(d["value"]),e.subItemRect,DT_CENTER .| DT_VCENTER .| DT_SINGLELINE); end function CellLeave(grid);override; begin @@ -4987,7 +4987,7 @@ type TGridCellBoolEdit = class(TGridPropertyRender,TPropertyBool) begin src1 := src; src1[2]-=FRbuttonWidth; - dc.drawtext(dv?"TRUE":"FALSE",src1,DT_CENTER); + dc.drawtext(dv?"TRUE":"FALSE",src1,DT_CENTER .| DT_VCENTER .| DT_SINGLELINE); end DrawButton(dc,src,dv); end @@ -5023,7 +5023,7 @@ type TGridCellEditList = class(TGridCellEditWithButton) function CellDrawLabel(dc,rect,d);override; begin v := d["value"]; - dc.DrawText(v,rect,DT_LEFT); + dc.DrawText(v,rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end function nameFilter();virtual; begin @@ -5090,7 +5090,7 @@ type TGridCellSysCursorEidt=class(TOneSelectCell,TPropertyTypeSysCursor) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -5151,7 +5151,7 @@ type TGridCellVariableTactionEdit = class(TGridCellVariableEdit) v := d["value"]; if v is class(tcomponent) then begin - dc.DrawText(v.name,rect,DT_LEFT); + dc.DrawText(v.name,rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end else inherited; end function create(owner);override; @@ -5216,7 +5216,7 @@ type TGridCellVariabletimagelistEdit = class(TGridCellVariableTactionEdit) v := d["value"]; if v is class(tcomponent) then begin - dc.DrawText(v.name,rect,DT_LEFT); + dc.DrawText(v.name,rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end @@ -5251,7 +5251,7 @@ type TBtnCellDrawVTtype = class(TGridCellEditWithButton) **} if ifarray(d) then begin - dc.drawtext(self(true).EditType(),rect); + dc.drawtext(self(true).EditType(),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end end @@ -5279,7 +5279,7 @@ type TGridCellImagesEdit = class(TBtnCellDrawVTtype,TPropertyImagesData) begin its := dv["items"]; if ifarray(its) then - dc.DrawText("imgs:"+inttostr(length(its)),rect); + dc.DrawText("imgs:"+inttostr(length(its)),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -5420,7 +5420,7 @@ type TGridCellStatusItemsEdit = class(TBtnCellDrawVTtype,TPropertyStatusItems) begin if ifarray(d) and ifarray(d["value"]) then begin - dc.DrawText("item:"+inttostr(length(d["value"])),rect); + dc.DrawText("item:"+inttostr(length(d["value"])),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end @@ -5478,7 +5478,7 @@ type TGridCellFileFilterEdit = class(TGridCellEditWithButton,TPropertyFileFilter begin if ifarray(d) and ifarray(d["value"]) then begin - dc.DrawText("item:"+inttostr(length(d["value"])),rect); + dc.DrawText("item:"+inttostr(length(d["value"])),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function OnApplay(o,e);virtual; @@ -5607,7 +5607,7 @@ type tGridCellAlignPos3BoxEdit=class(TOneSelectCell ,TPropertyAlign3) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -5626,7 +5626,7 @@ type tGridCellDayOfWeekBoxEdit=class(TOneSelectCell,TPropertyDayOfWeek) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -5791,7 +5791,7 @@ public **} if FGrid is class(TDrawGrid) then begin str:=inttostr(d["value"][0])+":"+inttostr(d["value"][1]); - e.canvas.drawtext(str,e.subItemRect,DT_CENTER); + e.canvas.drawtext(str,e.subItemRect,DT_CENTER.|DT_VCENTER); end end function CellLeave(grid);override;begin @@ -5806,7 +5806,7 @@ type TGridCellPairSpliterTypeEdit=class(TOneSelectCell,TPropertySpliterType) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6170,11 +6170,12 @@ private FeditWindow.updateEditorData(d["value"],ifnil(FnodeNum)?0:FnodeNum); FeditWindow.show(); end - function CellDrawLabel(dc,rect,d);override;begin + function CellDrawLabel(dc,rect,d);override; + begin // FnodeNum:=getnodenum(d["value"]["items"]); // str:="itemstats:"+(ifnil(d["value"])?"0":inttostr(FnodeNum)); str:="itemstrings"; - dc.drawtext(str,rect,DT_LEFT); + dc.drawtext(str,rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end @@ -6183,7 +6184,7 @@ type tGridCellAlignPosBoxEdit = class(TOneSelectCell,TPropertyAlign9) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6414,7 +6415,7 @@ type TGridCellAnchorsEdit = class(TMultiSelectCell,TPropertyAnchors) if ifarray(d) then begin FListSel := d["value"]; - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6437,7 +6438,7 @@ type TGridCellAlignEdit = class(TOneSelectCell,TPropertyAlign) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6460,7 +6461,7 @@ type TGridCellTabAlignEdit = class(TOneSelectCell,TPropertyTabAlign) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6644,7 +6645,7 @@ type TGridCellTextEdit = class(TGridCellEditWithButton,TPropertyText) {** @explan(说明) 绘制格子 %% **} - dc.drawtext(cellName(),rect); + dc.drawtext(cellName(),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end @@ -6759,7 +6760,7 @@ type TGridCellEsAlignEdit = class(TOneSelectCell,TPropertyEsAlign) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6780,7 +6781,7 @@ type TGridCellColorBoxEdit = class(TOneSelectCell,TPropertyColorList) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6799,7 +6800,7 @@ type tGridCellMbbtnstyleEdit=class(TOneSelectCell,TPropertymbbtnstyle) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -6818,7 +6819,7 @@ type tGridCellMbiconstyleEdit=class(TOneSelectCell,TPropertymbicostyle) begin if ifarray(d) then begin - dc.drawtext(FormatTMF(d["value"]),rect); + dc.drawtext(FormatTMF(d["value"]),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE); end end function create(AOwner);override; @@ -9412,7 +9413,7 @@ begin o := class(TVclDesigner); o.RegestorClassItems(its); its := array(); - for i,v in ini.ReadSectionValues("propertys") do //属性 + for i,v in ini.ReadSectionValues("properties") do //属性 begin if v then begin diff --git a/funcext/tvclib/tcontrol.tsf b/funcext/tvclib/tcontrol.tsf index ad72df8..808e7aa 100644 --- a/funcext/tvclib/tcontrol.tsf +++ b/funcext/tvclib/tcontrol.tsf @@ -166,17 +166,23 @@ type tcontrol = class(tcomponent) begin if not(Value in array(alLeft,alRight,alBottom,alTop,alNone,alClient))then exit; if FAlign=Value then exit; - bds := UnAlignBounds; - FAlign := Value; + oalign := FAlign; //旧对齐方式 + FAlign := Value; //调其兄弟节点的位置 %% if (FParent is getparenttype()) and FParent.HandleAllocated()then - begin - if FAlign=alNone then + begin + if (FAlign=alNone) or (oalign = alNone) then begin - //bds := UnAlignBounds; - SetBounds(bds[0],bds[1],bds[2],bds[3]); - end - FParent.DoControlAlign(); + if oalign=alClient then //恢复原有 + begin + bds := UnAlignBounds; + SetBounds(bds[0],bds[1],bds[2]-bds[0],bds[3]-bds[1]); + end else //保存现在 + begin + FUnAlignBounds := BoundsRect; + end + end + FParent.DoControlAlign(); //调整位置 end end procedure SetAnchors(Value);virtual; @@ -225,10 +231,10 @@ type tcontrol = class(tcomponent) end Function GetUnAlignBounds();virtual; //type_tcontrol begin - if alNone=FAlign then + {if alNone=FAlign then begin FUnAlignBounds := GetBoundsRect(); - end + end} if not ifarray(FUnAlignBounds)then FUnAlignBounds := GetBoundsRect(); return FUnAlignBounds; end @@ -516,13 +522,13 @@ type tcontrol = class(tcomponent) end; return Result; end - function OnControlAppend(AControl);virtual; + function ControlAppended(AControl);virtual; begin {** @explan(说明) 子控件添加 %% **} end - function OnControlDelete(AControl);virtual; + function ControlDeleted(AControl);virtual; begin {** @explan(说明) 子控件删除 %% @@ -538,7 +544,7 @@ type tcontrol = class(tcomponent) FControls.deli(idx); aparent := actrl.FParent; actrl.FParent := nil; - OnControlDelete(actrl); + ControlDeleted(actrl); //if (actrl.Align<>alNone) and (aparent is class(TWincontrol)) then aparent.DoControlAlign(); ifop := true; end @@ -549,7 +555,7 @@ type tcontrol = class(tcomponent) begin FControls.append(actrl); actrl.FParent := self(true); - OnControlAppend(actrl); + ControlAppended(actrl); ifop := true; end end @@ -1350,22 +1356,49 @@ type tcontrol = class(tcomponent) case tmsg of WM_WINDOWPOSCHANGED: begin + rchange := 0; d := new tvclwindowpos_class(TheMessage.lparam); flags := d.flags; if not((flags .& SWP_NOMOVE)=SWP_NOMOVE)then begin x := d.x; y := d.y; - if x <> FLeft then FLeft := x; - if y <> FTop then FTop := y; + if x <> FLeft then + begin + FLeft := x; + rchange .|=1; + end + if y <> FTop then + begin + FTop := y; + rchange .|=2; + end end if not((flags .& SWP_NOSIZE)=SWP_NOSIZE)then begin cx := d.cx; cy := d.cy; - if cx <> FWidth then FWidth := cx; - if cy <> FHeight then FHeight := cy; + if cx <> FWidth then + begin + FWidth := cx; + rchange .|=4; + end + if cy <> FHeight then + begin + FHeight := cy; + rchange .|=8; + end end + if rchange then + begin + mtic; + obj := class(tUIglobalData).uigetdata("tuiapplication"); + if obj then + begin + obj.Notification(self(true),array("type":"possize","flag",rchange,"data":array(fleft,ftop,FWidth,FHeight))); + end + //echo "\r\n note change mtoc:",caption,"===",mtoc; + end end {WM_SIZE: begin diff --git a/funcext/tvclib/tgraphiccontrol.tsf b/funcext/tvclib/tgraphiccontrol.tsf index 22a0e31..e3d7793 100644 --- a/funcext/tvclib/tgraphiccontrol.tsf +++ b/funcext/tvclib/tgraphiccontrol.tsf @@ -70,6 +70,13 @@ type tgraphiccontrol = class(TControl) if nv <> Visible then begin inherited; + //////添加visible的位置调整处理/////////// + p := Parent; + if(p is class(TWinControl))and p.HandleAllocated()then + begin + if Align <> alNone then return p.DoControlAlign(); + end + ////////////////// InvalidateRectForce(); end end @@ -84,7 +91,9 @@ type tgraphiccontrol = class(TControl) begin if not ifarray(rec)then return InvalidateRectForce(); nrec := array(FLeft+rec[0],FTop+rec[1],FLeft+rec[2],FTop+rec[3]); - return Parent.InvalidateRect(nrec,false); + p := Parent; + if p then + return Parent.InvalidateRect(nrec,false); end end function WMPaint(o,Message:TLMPaint):LM_PAINT;override; diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 7c07695..ad6d04b 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -706,7 +706,7 @@ type TLabel = class(TGraphicControl) function publishs();override; begin return array("name","action","align","anchors","caption","enabled","font", - "popupmenu","visible", + "popupmenu","visible","textalign", "height","width","left","top","color","bkbitmap","parentcolor","parentfont","transparent", "onpopupmenu","onmousedown","onmouseup"); end @@ -3055,7 +3055,7 @@ type TPairSplitter=class(tcustomcontrol) // {** @explan(说明) 添加side **} - if not(ASide is class(TPairSplitterSide))then return-1; + if not(ASide is class(TPairSplitterSide))then return -1; if ASide.Parent=self then begin if FSides.indexof(ASide)<0 {and FSides.count<2}then diff --git a/funcext/tvclib/twincontrol.tsf b/funcext/tvclib/twincontrol.tsf index 951755b..24d7f3c 100644 --- a/funcext/tvclib/twincontrol.tsf +++ b/funcext/tvclib/twincontrol.tsf @@ -2218,10 +2218,28 @@ type TWinControl = class(tcontrol) end function HitWindowborder(o,e,hit);virtual; begin - if not(WsSizeBox)and DesigningSizer()and(Align=alNone)then + {if not(WsSizeBox)and DesigningSizer()and(Align=alNone)then begin e.Result := hit; e.skip := true; + end} + al := Align; + if not(WsSizeBox)and DesigningSizer() and(al<>alClient)then + begin + if (al = alNone) or + (hit= HTTOP and al =alBottom) or + (hit= HTBOTTOM and al =alTop) or + (hit= HTRIGHT and al =alLeft) or + (hit= HTLEFT and al =alRight) + then + begin + e.Result := hit; + e.skip := true; + if (csDesigning in ComponentState) then + begin + if al <> alNone then _send_(WM_USER,1644,1644,1); + end + end end end private //设计器相关,消息 @@ -2267,7 +2285,28 @@ type TWinControl = class(tcontrol) if msg = WM_RBUTTONDOWN then begin CallMessgeFunction(OnDesignRClick,self(true),e); - end + end else + if msg = WM_USER then + begin + if e.wparam=1644 and e.lparam=1644 then + begin + //Align=alNone; + al := Align; + + if al in array(alLeft,alRight,alTop,alBottom) then + begin + bs := UnAlignBounds; + bs2 := BoundsRect; + if bs <> bs2 then + begin + Align := alNone; + Align := al; + end + end + + end + + end end inherited; end; diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index ace689b..f2e7f84 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -1991,7 +1991,7 @@ type tsgtkapi = class(tgtkapis) if not(cx>0 and cy>0) then return ; if obj then begin - g_gtk_drag_window.BKBitmap := obj[i]; + g_gtk_drag_window.BKBitmap := obj[iTrack]; cx+=2; cy+=2; end @@ -2011,7 +2011,7 @@ type tsgtkapi = class(tgtkapis) if not g_gtk_drag_window then return ; g_gtk_drag_lock_window := class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwndLock); if not g_gtk_drag_lock_window then return ; - g_gtk_drag_window.Parent := g_gtk_drag_lock_window; + //g_gtk_drag_window.Parent := g_gtk_drag_lock_window; g_gtk_drag_window.Enabled := false; ImageList_DragMove(x,y); g_gtk_drag_window.show( 0x4); diff --git a/funcext/tvclib/utslvclauxiliary.tsf b/funcext/tvclib/utslvclauxiliary.tsf index e878c06..8939f07 100644 --- a/funcext/tvclib/utslvclauxiliary.tsf +++ b/funcext/tvclib/utslvclauxiliary.tsf @@ -332,6 +332,7 @@ type tarray1dlk=class // **} _data := array(); _len := 0; + onchangelock := true; end function CallCompare(v1,v2,f); begin @@ -346,6 +347,7 @@ type tarray1dlk=class // @param(v)() tsl数据 %% **} _data[_len++]:= v; + dochanged("append"); end; function geti(i); //获取 begin @@ -365,6 +367,7 @@ type tarray1dlk=class // if i >= 0 and i<_len then begin _data[i]:= v; + dochanged("set"); end end function deli(i); //删除 @@ -376,7 +379,9 @@ type tarray1dlk=class // //len := length(_data)-1; if i<0 or i >= _len then return-1; _len -= 1; - return deleteindex(_data,i,1); + r := deleteindex(_data,i,1); + dochanged("del"); + return r; end function delis(i); begin @@ -385,7 +390,11 @@ type tarray1dlk=class // @param(i)(array) 删除的id %% **} dels := getdels(i); + bkonchangelock := onchangelock; + onchangelock := true; for ii,v in dels do deli(v); + onchangelock := bkonchangelock; + dochanged("dels"); end function getdels(i); //删除多行 begin @@ -439,6 +448,7 @@ type tarray1dlk=class // _data := _data[0:i]union array(v)union _data[i+1:]; end _len++; + dochanged("insert"); end function findvid(v1,func,lx); //查找序号,func通过送入的比较函数 begin @@ -534,6 +544,7 @@ type tarray1dlk=class // begin ret := _data[i]; _data[i]:= v; + dochanged("replace"); return ret; end else return nil; @@ -561,6 +572,7 @@ type tarray1dlk=class // begin SwapNoCheck(sl[ii],sl[ii+1]); end + dochanged("order"); end function swap(i,j); //交换 begin @@ -576,9 +588,17 @@ type tarray1dlk=class // //_data[i]:=_data[j]; //_data[j] := vi; end + dochanged("order"); end property CompareValue read FCompareValue write FCompareValue; + property onchanged read fonchanged write fonchanged; + onchangelock; private + function dochanged(info); + begin + if onchangelock then return ; + CallMessgeFunction(fonchanged,self(true),info); + end function SwapNoCheck(i,j); begin vi := _data[i]; @@ -614,6 +634,7 @@ type tarray1dlk=class // deli(i); end end + fonchanged; end type TFpList=class(tarray1dlk) {** @@ -883,7 +904,7 @@ type tnumindexarray = Class begin if vi=v then return i; end - return-1; + return -1; end function LastIndexOf(v); begin @@ -891,7 +912,7 @@ type tnumindexarray = Class begin if v=FData[i]then return i; end - return-1; + return -1; end function GetValueByIndex(idx);virtual; begin diff --git a/funcext/tvclib/utslvclcoolbar.tsf b/funcext/tvclib/utslvclcoolbar.tsf new file mode 100644 index 0000000..edfd435 --- /dev/null +++ b/funcext/tvclib/utslvclcoolbar.tsf @@ -0,0 +1,677 @@ +unit utslvclcoolbar; +interface +uses utslvclauxiliary,utslvclgdi; +type tcustomcoolbar=class(tcustomcontrol) + function Create(AOwner); + begin + fcoolbands := new tcoolbarlines(); + frowheight := 30; + fbtnwidth := 20; + fautosize := true; + inherited; + FWill_Drag := true; + cimgst(); + fsizebtncolor := _wapi.GetSysColor(COLOR_MENUBAR); + fdragbtncolor := fsizebtncolor; + + end + function ControlAppended(AControl);override; + begin + {** + @explan(说明) 子控件添加 %% + **} + it := new tcoolband(AControl); + fcoolbands.appendrow(it); + end + function ControlDeleted(AControl);override; + begin + {** + @explan(说明) 子控件删除 %% + **} + fcoolbands.deleteitem(AControl); + end + function Notification(o,op);override; + begin + return inherited; + if ifarray(op) then + begin + ctls := controls; + if (ctls.IndexOf(o)>=0) then + begin + //echo tostn(op); + flg := op["flag"]; + if flag>0 and ((flag .& 4 ) or (flg .& 8)) then + begin + echo "\r\n",tostn(op); + end + end + end + inherited; + end + + function MouseUp(o,e);override; + begin + if csDesigning in ComponentState then exit; + if e.button=mbLeft then + begin + if FIs_Draging then + begin + _wapi.ImageList_DragLeave(self.Handle); + _wapi.ImageList_EndDrag(); + if fdragenode then + begin + r := fcoolbands.getnodebyxy(e.xpos,e.ypos); + if fcoolbands.moveitemto(fdragenode,r[0],r[1]) then + begin + doControlALign(); + InvalidateRect(nil,false); + r := getarrange(); + echo tostn(r); + end + end else + if fsizenode then + begin + ctl := fsizenode.fctl; + clr := ctl.BoundsRect; + y := e.ypos; + if y> clr[1] and (y10 then + begin + ctl.Width := nwid; + doControlALign(); + InvalidateRect(nil,false); + end + end + end + + r := ClientRect; + EnabledChild(true); + FWill_Drag := true; + FIs_Draging := false; + _wapi.clipcursor(0); + end + end + inherited; + end + function MouseDown(o,e);override; + begin + if csDesigning in ComponentState then exit; + if e.button=mbLeft then + begin + xy := e.pos; + trk := -1; + for i,v in fcoolbands.data do + begin + + if pointinrect(xy,v.fdragrect) then + begin + trk := 0; + fdragenode := v; + fsizenode := nil; + break; + end + if pointinrect(xy,v.fsizerect) then + begin + trk := 1; + fdragenode := nil; + fsizenode := v; + break; + end + + end + if trk<0 then return ; + nxy := clienttowindow(e.xpos,e.ypos); + if FWill_Drag then + begin + FWill_Drag := false; + FIs_Draging := true; + + _wapi.ImageList_BeginDrag(FDRageimglist.Handle,trk,12,12); + + _wapi.ImageList_DragEnter(self.Handle,nxy[0],nxy[1]); + crect := clientrect; + ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3])); + _wapi.clipcursor(ps); + EnabledChild(false); + end + end + inherited; + end + function MouseMove(o,e);override; + begin + if FIs_Draging then + begin + nxy := clienttowindow(e.xpos,e.ypos); + _wapi.ImageList_DragMove(nxy[0],nxy[1]); + end + inherited; + end + function doControlALign();override; + begin + mwid := 10; + swid := 12; + y := 0; + rhs := fcoolbands.getrowheights(); + if autosize then + begin + rc := ClientRect; + nh := sum(rhs); + h := rc[3]-rc[1]; + dh := h-nh; + if abs(dh)>4 then + begin + Align := alNone; + Height := (border*2)+nh; + Align := alTop; + return ; + end + end + for i,v in fcoolbands.data2 do + begin + x := 0; + for j,bsi in v do + begin + ctl := bsi.fctl; + if ctl.Visible then + begin + bsi.fdragrect := array(x,y,x+mwid,y+rhs[i]); + h := ctl.Height; + w := ctl.Width; + x += mwid; + bsi.fctlrect := array(x,y,w,h); + dy := 0; + if (rhs[i]-h)>2 then + begin + dy := integer((rhs[i]-h)/2); + end + ctl.SetBounds(x,y+dy,w,h); + x+=w; + bsi.fsizerect := array(x,y,x+swid,y+rhs[i]); + x+=swid; + end else + begin + bsi.fdragrect := array(0,0,0,0); + bsi.fctlrect := array(0,0,0,0); + bsi.fsizerect := array(0,0,0,0); + end + + end + bsi.fsizerect := array(0,0,0,0); + y+=rhs[i]; + end + end + function paint();override; + begin + dc := canvas; + cl := dc.brush.color; + bcl := dc.pen.color; + dc.pen.color := 0xDCDCDC; + rhs := fcoolbands.getrowheights(); + y := 0; + for i:= 0 to length(rhs)-2 do + begin + y +=rhs[i]; + dc.moveto(array(0,y)); + dc.lineto(array(width,y)); + end + for i,v in fcoolbands.data do + begin + //dc.brush.color := 0x87CEEB; + dc.brush.color := fdragbtncolor; + rc1 := v.fdragrect; + rc1[0]+=1; + rc1[1]+=1; + rc1[2]-=1; + rc1[3]-=1; + dc.fillrect(rc1); + ply := array( rc1[array(0,1)], + rc1[array(2,1)], + rc1[array(2,3)], + rc1[array(0,3)], + rc1[array(0,1)] + ); + dc.draw("polyline",ply) ; + //dc.brush.color := 0xEEE8AA; + dc.brush.color := fsizebtncolor; + rc1 := v.fsizerect; + rc1[0]+=1; + rc1[1]+=1; + rc1[2]-=1; + rc1[3]-=1; + dc.fillrect(rc1); + ply := array( rc1[array(0,1)], + rc1[array(2,1)], + rc1[array(2,3)], + rc1[array(0,3)], + rc1[array(0,1)] + ); + dc.draw("polyline",ply) ; + end + dc.brush.color := cl; + dc.pen.color := bcl; + end + function Recycling();override; + begin + inherited; + //if FDRageimglist then _wapi.ImageList_Destroy(FDRageimglist); + end + property autosize read fautosize write setautosize; + property arrange read getarrange write setarrange; + property dragbtncolor:color read fdragbtncolor write fdragbtncolor; + property sizebtncolor:color read fsizebtncolor write fsizebtncolor; + private + fautosize ; + fdragbtncolor; + fsizebtncolor; + function arange2a(s); + begin + ss := str2array(s,";"); + rs := array(); + for i,v in ss do + begin + if trim(v) then + begin + str2array(v,","); + end + end + + end + function getarrange(); + begin + ar := ""; + ctls := controls; + for i,vi in fcoolbands.data2 do + begin + for j,v in vi do + begin + ar+= inttostr(ctls.indexof(v.fctl)); + ar+=","; + end + ar[length(ar)] := ";"; + end + if ar then ar[length(ar):] := ""; + return ar; + end + function setarrange(ar); + begin + ctls := controls; + ct := ctls.count-1; + if ct<0 then return ; + idxs := 0->(ct); + fcoolbands_ := new tnumindexarray(); + for i,v in str2array(ar,";") do + begin + if v then + begin + line := new tnumindexarray(); + for j,vj in str2array(v,",") do + begin + idx := strtointdef(vj,-1); + if idx>=0 then + begin + vidx := idxs[idx]; + if vidx>=0 then + begin + reindex(idxs,array(idx:nil)); + line.Push(new tcoolband(ctls[vidx])); + end + end + end + if line.length() then + begin + fcoolbands_.Push(line); + end + end + end + for i,v in idxs do + begin + line := new tnumindexarray(); + line.Push(new tcoolband(ctls[vidx])); + fcoolbands_.Push(line); + end + fcoolbands := fcoolbands_; + if HandleAllocated() then + begin + doControlALign(); + end + end + function setautosize(v); + begin + nv := v?true:false; + if nv<>fautosize then + begin + fautosize := v; + if nv then + begin + doControlALign(); + end + end + end + function EnabledChild(f); + begin + fcoolbands.EnabledChild(f); + end + function cimgst(); + begin + FDRageimglist := new TCustomImageList(self); + FDRageimglist.Width := 24; + FDRageimglist.Height := 24; + bmp := new TcustomBitmap(); + bmp.readvcon(HexFormatStrToTsl(getmovebmp())); + FDRageimglist.addbmp(bmp); + bmp.readvcon(HexFormatStrToTsl(getsizebmp())); + FDRageimglist.addbmp(bmp); + + end + + fdragenode; + fsizenode; + + fcoolbands; + frowheight; + fbtnwidth; + FIs_Draging;// + FWill_Drag;// + FDRageimglist;// + +end +implementation +type tcoolband = class + function create(ctl); + begin + fctl := ctl; + end + function destroy(); + begin + end + function enabled(f); + begin + if not f then + begin + if fenable<>nil then return ; + fenable := fctl.Enabled; + fctl.Enabled := false; + end else + begin + fctl.Enabled := fenable; + fenable := nil; + end + end + function operator[](idx); + begin + try + return invoke(fctl,idx); + except + return 0; + end + end + fctl; + fdragrect; + fsizerect; + fctlrect; + private + fenable; +end +type tcoolbarlines = class + function create(); + begin + flines := new tnumindexarray(); + end + function appendrow(cb); //追加一行 + begin + line := new tnumindexarray(); + line.Push(cb); + flines.Push(line); + end + function unshiftrow(cb); //在前面 + begin + line := new tnumindexarray(); + flines.unshift(line); + end + function deleteitem(it,f); //删除一项 + begin + for i,v in flines.data do + begin + for j ,vj in v.data do + begin + if vj = it then + begin + v.splice(j,1); + if v.length()<1 then + begin + flines.splice(i,1);//删除 + end + end + end + end + end + function moveitemto(it,nit,f);//移动到坐标 + begin + if it=nit then return 0; + {id1 := -1; + id2 := -1; + for i ,v in data do + begin + if v= it then + begin + id1 := i; + if id2>-1 then break; + end + if v=nit then + begin + id2 := i; + if id1>-1 then break; + end + end + //it 为移动的 + //nid 为锚点 + case f of + 0,1: //前 + begin + if (id2-id1)=1 then return 0; + end + + 2: //前一行 + begin + + end + 3: //后 + begin + if (id1-id2)=1 then return 0; + end + 4: //后一行 + begin + + end + + end } + deleteitem(it);//删掉 + case f of + 0,1: //前 + begin + ifg := 0; + end + 2: //前一行 + begin + line := new tnumindexarray(); + line.push(it); + flines.unshift(line); + return 1; + end + 3: //后 + begin + ifg :=2; + end + 4: //后一行 + begin + line := new tnumindexarray(); + line.push(it); + flines.Push(line); + return 1; + end + + end + for i,v in flines.data do + begin + for j ,vj in v.data do + begin + if vj = nit then + begin + if ifg then //后面 + begin + v.splice(j+1,0,it); + end else + begin + v.splice(j,0,it); + end + end + end + end + return true; + end + function getrowheights(); //总高度 + begin + r := array(25); + for i,v in flines.data do + begin + h := 0; + for j,vj in v.data do + begin + h := max(h,vj["height"]); + end + r[i] := h; + end + return r; + end + function EnabledChild(f); + begin + for i,v in flines.data do + begin + for j,vj in v.data do + begin + vj.enabled(f); + end + end + end + function getnodebyxy(x,y); + begin + rs := getrowheights(); + b := 0; + bdr := 3; + rl := length(rs)-1; + for i,v in rs do + begin + if v<1 then continue; + if y>=b and y<=b+v then //确定行 + begin + for j,bsi in flines[i].data do + begin + + rc := bsi.fctlrect; + rt := -1; + if (x>=(rc[0])) and ( x<=(rc[0]+rc[2])) and + (y>=(rc[1]+bdr)) and ( y<=(rc[1]+rc[3]-bdr)) then + begin + rt := 0; + end + if x<(rc[0]+bdr) then + begin + rt := 1; + end + if i=0 then + begin + if y<(rc[1]+bdr) then + begin + rt := 2; + end + end + if i=rl then + begin + if y>(rc[1]+rc[3]-bdr) then + begin + rt := 4; + end + end + if rt>-1 then return array(bsi,rt,i,j); + end + return array(bsi,3,i,j); + end + b+=v; + end + ri := length(rs)-1; + return array((flines[ri])[0],4,ri,0); + end + property data2 read getdata2; + property data read getdata; + property lines read flines; + private + function getdata(); + begin + r := array(); + k := 0; + for i,v in flines.data do + begin + for j,vj in v.data do + begin + r[k] := vj; + k++; + end + end + return r; + end + function getdata2(); + begin + r := array(); + k := 0; + for i,v in flines.data do + begin + for j,vj in v.data do + begin + r[i,j] := vj; + end + end + return r; + end + flines; + +end +function getmovebmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +10002E801000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000017D49444154 +484BB594BF2F044114C7FD1DFE06FF8446F41285CE3FA0D048682FA1500912AD6 +8509C50A1D128885CA1398DECE5E2E2ECB27B2EB72C479E7C9F9D313BB3676692 +BB4FF2B29BF9F13EB3F366678C468C97E0F4F68DC30767C1D6D92B4D2CB538F0E +E8A93404DEE2BB10AB6CFBB4672112E12AB6061F785932DEEC585C478A2CF8655 +9066DFB2B042707D9FD1453DE33E1BCE4506AAC01543803DAF54138A7BE6EA663 +7421694B17290F057E91404EA69F159A53A4FFF4FA4403D2D28A8CE65FA4ED38D +36CD349F683DEAE4AD7F88AFD3252CA8DEA4B2538FF99D671E88C4E3774D8EC9E +0911A519FE636A3D239885AF0C1F358707835588095015DF0107F958E1771524B +799EDCA2E5FD4476624F5103442F3F8A83B6488C53B758FD010B455E3DEEC841F +5D667DE6A47DD62353928088038A661D7EF984EADB58DE4C010FC87586510F6F3 +163B5641D95501D03694ABA2ECB2AB1CFD1E88A15C7623BFAE0112E9C92176C1B +9C8AAC465E50267014061F5CBCC8697C01FA21F97353FCB2FCC13D10000000049 +454E44AE42608200"; + +end +function getsizebmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +100020E01000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA864000000A349444154 +484BED93BB0E84300C04F3E7499B3675DA7C674E8B6CB45C1E46C09D0462240A6 +CD603065CFD31AFC0E4E1821042F5DECB598BD5074301C2CEB9E5E80DB1FA4A57 +808086638C526D41CF9234021E9E5292EA185C33936C04FCD83967A9DAE0DA916 +415F0F0528A54F7834C4FB20A78356705B85965B322961C5D110F07FF7DC90A4B +2EFF4C15EB47E2FEF75A98A10020380B5B7D30155CC12B30B9BBA0D60F44173C9 +EBDFC87F10000000049454E44AE42608200"; +end + +initialization + +end. \ No newline at end of file