界面库

修正combobox bug
This commit is contained in:
JianjunLiu 2022-10-31 11:51:52 +08:00
parent 0262217ded
commit 39d57baf2e
2 changed files with 46 additions and 42 deletions

View File

@ -10,7 +10,7 @@ type tcustomtabitem = class() //TTCITEMA
FCaption;
FVisible;
FPageSheet;
function SetVisible(v);
function SetVisible(v);//设置可见
begin
nv := v?true:false;
if nv<>FVisible then
@ -18,7 +18,7 @@ type tcustomtabitem = class() //TTCITEMA
FVisible := v;
end
end
function SetCaption(s);
function SetCaption(s);//设置标签
begin
if ifstring(s) and s<>FCaption then
begin
@ -28,14 +28,14 @@ type tcustomtabitem = class() //TTCITEMA
end
end
public
function Create();
function Create();//构造
begin
FVisible:= true;
end
property Caption read FCaption write SetCaption;
property PageSheet read FPageSheet Write FPageSheet;
end
type tcustomtabsheet = class(TCustomControl)
type tcustomtabsheet = class(TCustomControl) //控件页面
{**
@explan(说明)page控件页面 %%
**}
@ -51,7 +51,7 @@ type tcustomtabsheet = class(TCustomControl)
Parent.SetTabText(id,s);
end
end
function SetParent(p);override;
function SetParent(p);override; //设置父窗口
begin
if (P is class(tcustompagecontrol) ) and parent<>p then
begin
@ -61,7 +61,7 @@ type tcustomtabsheet = class(TCustomControl)
oldparent.RemovePage(self);
end
inherited;
parent.addtabitem(self);
parent.addtabitem(self(true));
end else
if not(p is class(TWincontrol)) then
begin
@ -74,15 +74,15 @@ type tcustomtabsheet = class(TCustomControl)
end
end
public
function paint();override;
function paint();override; //设计器模式下绘制网格
begin
drawdesigninggrid();
end
function DesigningMove();override;
function DesigningMove();override;//移动
begin
return false;
end
function DesigningSizer();override;
function DesigningSizer();override;//调整大小
begin
return false;
end
@ -91,7 +91,6 @@ type tcustomtabsheet = class(TCustomControl)
inherited;
Caption := "tab";
Visible := false;
FTabVisible := True;
end
function CreateParams(p);override;
begin
@ -101,13 +100,12 @@ type tcustomtabsheet = class(TCustomControl)
end
type tcustompagecontrol = class(TCustomControl)
private
FirstViewIndex;
FirstViewIndex; //第一个展示的序号
FCurrentid;
FPrevid;
FTabItems; //
FOnSelChange;
FOnSelChanging;
FOnSelChanging; //正在改变
//FOnrclick;
FTabPosition;
FTabHeight;
@ -298,15 +296,21 @@ type tcustompagecontrol = class(TCustomControl)
if FCurrentid= id then return ;
if id>=0 and id<FTabItems.length() then
begin
if OnSelChanging then
begin
e := new tuieventbase(0,FPrevid,FCurrentid,0); //m,w,l,h
doonSelChanging(self(true),e);
if e.skip then return ;
end
FPrevid := FCurrentid;
FCurrentid := id;
InsureIdxVisible(id);
InvalidateRect(nil,false);
DoControlAlign();
if OnSelChanging then
doonSelChanging(self(true),new tuieventbase(0,0,0,0));
if OnSelChange then
doonSelChange(self(true),new tuieventbase(0,0,0,0));
begin
doonSelChange(self(true),new tuieventbase(0,FPrevid,FCurrentid,0));
end
end else
if FTabItems.length()=0 then
begin
@ -422,8 +426,7 @@ type tcustompagecontrol = class(TCustomControl)
FPrevid := -1;
FTabItems := new tnumindexarray();
end
Function SetCurSel(id);
Function SetCurSel(id); //设置当前序号
begin
if id is class(tcustomtabsheet) then
begin
@ -435,24 +438,23 @@ type tcustompagecontrol = class(TCustomControl)
setselidx(iid);
end
end
function paint();override; //绘制
begin
PaintTabs();
PaintScroll();
end
function MouseUp(o,e);override;
function MouseUp(o,e);override;//鼠标弹起
begin
ps := e.pos();
if e.button()=mbRight then return ;
if FScrollBtnRect and pointinrect(ps,fnextrect) then
mb := e.button();
//if mb=mbRight then return ;
if (mb=mbLeft) and FScrollBtnRect and pointinrect(ps,fnextrect) then
begin
if e.Button() = mbLeft then
ScrollNext();
return ;
end else
if FScrollBtnRect and pointinrect(ps,Fprevrect) then
if (mb=mbLeft) and FScrollBtnRect and pointinrect(ps,Fprevrect) then
begin
if e.Button() = mbLeft then
scrollprev();
@ -465,17 +467,16 @@ type tcustompagecontrol = class(TCustomControl)
if v and pointinrect(ps,v) then
begin
setselidx(i);
if e.Button() = mbLeft then
if Onclick and (mb = mbLeft) then
begin
CallMessgeFunction(Onclick,o,e);
end else
if e.Button() = mbRight then
if onrclick and (mb = mbRight) then
begin
CallMessgeFunction(onrclick,o,e);
end
end
e.skip := true;
//
end
end
function doonSelChange(o,e);virtual;
@ -492,18 +493,18 @@ type tcustompagecontrol = class(TCustomControl)
if r then return r;
return array(0,0,0,0);
end
function GetTabText(AIndex);
function GetTabText(AIndex);//获得caption
begin
r := "";
if AIndex<FTabItems.Count and AIndex>0 then return FTabItems[AIndex].Caption;
return r;
end
function IsContainer(cd);override;
function IsContainer(cd);override;//是否容纳
begin
if cd is class(tcustomtabsheet) then return true;
return false;
end
function GetPageID(page);
function GetPageID(page);//获得page序号
begin
{**
@explan(说明)获取page的序号 %%
@ -521,7 +522,7 @@ type tcustompagecontrol = class(TCustomControl)
end
return r;
end
function DoControlAlign();override;
function DoControlAlign();override;//调整位置
begin
CalcTabs();
for i := 0 to FTabItems.length()-1 do
@ -548,7 +549,7 @@ type tcustompagecontrol = class(TCustomControl)
end
end
end
function RemovePageTab(id);
function RemovePageTab(id);//移除sheet
begin
if not(id>=0) then return ;
FTabItems.splice(id,1);
@ -570,7 +571,7 @@ type tcustompagecontrol = class(TCustomControl)
CalcTabs();
InvalidateRect(nil,false);
end
function RemovePage(i);
function RemovePage(i);//移除sheet
begin
{**
@explan(说明)移除page %%
@ -636,7 +637,6 @@ type tcustompagecontrol = class(TCustomControl)
begin
inherited;
end
function AppendPage(page);
begin
{**

View File

@ -4048,9 +4048,11 @@ type TcustomComboBox=class(TCustomComboBoxbase)
end
FEdit.onchange := function(o,e);
begin
if feditischanging then return feditischanging := false;
if not(o.Readonly) then
begin
feditischanging := true;
if Foneditchanged then
CallMessgeFunction(Foneditchanged,o,e);
if FMultisel then return feditischanging:=false;
t := o.Text;
@ -4083,7 +4085,9 @@ type TcustomComboBox=class(TCustomComboBoxbase)
begin
if feditischanging then return ;
r := getCurrentItemText();
feditischanging := true;
FEdit.Text := r;
feditischanging := false;
ShowDropDown(false);
CallMessgeFunction(OnSelchanged,self(true),e);
end