设计器

优化细节
This commit is contained in:
JianjunLiu
2023-01-10 11:27:05 +08:00
parent 8ed3ce6baa
commit 12f73f17d6
8 changed files with 185 additions and 26 deletions
+68 -6
View File
@@ -1799,8 +1799,11 @@ type TColorbox=class(TcustomListBox)
public
function create(aOwner);override;
begin
inherited;
inherited;
fcustomcolor := nil;
arr := array(
("value":"Custom","color":nil),
("value":"None","color":nil),
("value":"Black","color":0),
("value":"Maroon","color":128),
("value":"Green","color":32768),
@@ -1825,6 +1828,25 @@ type TColorbox=class(TcustomListBox)
("value":"MedGray","color":10789024));
setData(arr);
end
function MouseUp(o,e);override;
begin
inherited;
idx := GetIdxByYpos(e.ypos);
if idx =0 then
begin
if not FCdlg then
begin
FCdlg := new TColorChooseADlg(self);
FCdlg.parent := self;
end
if FCdlg.OpenDlg() then
begin
cl := FCdlg.result;
setcustomcolor(cl);
end
end
end
function getColor(n);
begin
{**
@@ -1869,15 +1891,20 @@ type TColorbox=class(TcustomListBox)
end
function CheckListItem(v);override;
begin
return ifarray(v)and ifstring(v["value"])and ifnumber(v["color"]);
return ifarray(v) and ifstring(v["value"]) ;//and ifnumber(v["color"]);
end
function PaintIdexText(idx,rc,cvs);override;
begin
rl := integer((rc[3]-rc[1])* 0.15);
rrect := array(rc[0]+rl,rc[1]+rl,rc[0]-rl+rc[3]-rc[1],rc[3]-rl);
cvs.brush.color := getColor(idx);
cvs.fillrect(rrect);
rrect := array(rc[0]+rl,rc[1]+rl,rc[0]-rl+rc[3]-rc[1],rc[3]-rl);
cl := getColor(idx);
if cl>=0 or cl<0 then
begin
cvs.brush.color := cl;
cvs.fillrect(rrect);
end
rc[0]+= rc[3]-rc[1];
rc[1]+= 2;
cvs.drawtext(getColorName(idx),rc,DT_NOPREFIX);
end
function publishs();override;
@@ -1890,7 +1917,21 @@ type TColorbox=class(TcustomListBox)
"onselchanged","onnotification"
);
end
private
property customcolor read fcustomcolor write setcustomcolor;
function setcustomcolor(cl);
begin
if fcustomcolor<>cl and (cl>=0 or cl<0) then
begin
fcustomcolor := cl;
r := FitemData[0];
r["color"] := cl;
FitemData.splice(0,1,r);
p := parent ;
if p then p.Notification(self,"customcolorchanged");
end
end
fcustomcolor;
FCdlg;
multiSel;
end
@@ -1998,6 +2039,18 @@ type TColorCombobox=class(TCustomComboBoxbase)
**}
return FListBox.getColor(id);
end
function Notification(o,op);override;
begin
if o=FListBox and op="customcolorchanged" then
begin
if onSelchanged and (FListBox.ItemIndex=0) then
begin
CallMessgeFunction(OnSelChanged,self(true),new tuieventbase(0,0,0,0));
end
return InvalidateRect(nil,false) ;
end
return inherited;
end
function publishs();override;
begin
return array("name","anchors","font","color",
@@ -2006,7 +2059,16 @@ type TColorCombobox=class(TCustomComboBoxbase)
"readonly","itemindex",
"onselchanged","ondropdown","oncloseup","onnotification");
end
property customcolor read getcustomcolor write setcustomcolor;
private
function getcustomcolor();
begin
return FListBox.customcolor;
end
function setcustomcolor(cl);
begin
FListBox.customcolor := cl;
end
function SetItemIndex(idx);override;
begin
FListBox.SetCurrentSelection(idx);
+1 -1
View File
@@ -2549,7 +2549,7 @@ type TWinControl = class(tcontrol)
begin
ctb := class(tUIglobalData).uigetdata("G_T_TOOLBAR_");
if (c is class(TcustomMenu)) or (c is ctb) or (c is class(TCustomAction)) then
begin
begin
if c.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end
cc := c.Components ;
+14 -2
View File
@@ -2938,7 +2938,17 @@ type TSynCompletion = class(TSynCompletionList)
end
end
type TSynHighLighter = class(TComponent) //语法高亮类型
Type TToken = class
type thtcolor = class()
function create(cl);
begin
if cl>0 or cl<=0 then FColor := cl;
else FColor := 0;
end
property color read fcolor write fcolor;
private
fcolor;
end
Type TToken = class()
FValue; //值
FPos; //位置
FLen; //长度
@@ -3098,6 +3108,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin
inherited;
fsymcolor := 0xa000a0;
fnumbercolor := 0x666666;
fkeywordcolor := 0x0000ff;
fstringcolor := 0xff00ff;
fannotationcolor := 0xff0000;
@@ -3244,6 +3255,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
property stringcolor:color read fstringcolor write fstringcolor;
property annotationcolor:color read fannotationcolor write fannotationcolor;
property symcolor:color read fsymcolor write fsymcolor;
property numbercolor:color read fnumbercolor write fnumbercolor;
property ignorecase:bool read fignorecase write setignorecase;
private
function setignorecase(i);
@@ -3580,7 +3592,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
fstringcolor;
fannotationcolor;
fsymcolor;
fnumbercolor;
//
fswordpairs;
fswordpairshash;
+3 -3
View File
@@ -296,7 +296,7 @@ private
begin
end else
CallMessgeFunction(Onclick,o,e);
CallMessgeFunction(Onclick,o,e);
end
function DoMeasureItem(o,e);virtual;
begin
@@ -459,8 +459,8 @@ private
if cmd = 'doshortcut' then
begin
if csDesigning in ComponentState then return ;
if Visible and Enabled and Parent and GetMenuType(0) then
begin
if FVisible and Enabled and Parent and GetMenuType(0) then
begin
if d = ShortCut then
begin
DoClick(self,new tuieventbase(0,0,0,0));
+13 -4
View File
@@ -1308,7 +1308,7 @@ type teditable=class(TSLUIBASE) //
end
"ecselbkcolor":
begin
if pm>0 or pm<0 then fselbkcolor := pm;
if pm>=0 or pm<0 then fselbkcolor := pm;
return fselbkcolor;
end
"ecplaceholdercolor":
@@ -3799,7 +3799,7 @@ type TcustomListBox=class(TCustomListBoxbase)
end
function setselbkcolor(v);
begin
if (v>0 or v<0) and v<>fselbkcolor then
if (v>=0 or v<0) and v<>fselbkcolor then
begin
fselbkcolor := v;
end
@@ -3829,8 +3829,11 @@ type TcustomListBox=class(TCustomListBoxbase)
if(idx >= min(FSelBegin,FSelEnd)and idx <= max(FSelBegin,FSelEnd))or(FMultisel=2 and FMultisel3Data[idx])then
begin
r := true;
cvs.brush.Color := fselbkcolor;//0xFFE7CB;//rgb(204,231,255);
cvs.FillRect(rc);
if fselbkcolor<>Color then
begin
cvs.brush.Color := fselbkcolor;//0xFFE7CB;//rgb(204,231,255);
cvs.FillRect(rc);
end
end
return r;
end
@@ -4058,6 +4061,7 @@ type TCustomComboBoxbase=class(TCustomControl)
inherited;
end
published
property itemcount read GetItemCount ;
property ItemIndex:tsl read GetItemIndex write SetItemIndex;
property OnSelchanged:eventhandler read FOnSelchanged write FOnSelchanged;
property ondropdown:eventhandler read Fondropdown write Fondropdown;
@@ -4110,6 +4114,11 @@ type TCustomComboBoxbase=class(TCustomControl)
Fondropdown; //下拉
Foncloseup; //收起
FBtnWidth;
function GetItemCount();
begin
if not FListBox then return 0;
return FListBox.ItemCount;
end
function SetmaxListItemShow(v);//显示项目数量
begin
if v>0 then