lcl, ideintf: formatting

git-svn-id: trunk@18488 -
This commit is contained in:
paul 2009-01-29 08:33:56 +00:00
parent d43decb3b2
commit 13512410f8
2 changed files with 70 additions and 63 deletions

View File

@ -1057,8 +1057,9 @@ function TOICustomPropertyGrid.InitHints: boolean;
begin
if not ShowHint then exit(false);
Result:=true;
if FHintTimer=nil then begin
Result := true;
if FHintTimer = nil then
begin
FHintTimer := TTimer.Create(nil);
FHintTimer.Interval := 500;
FHintTimer.Enabled := False;
@ -1070,7 +1071,7 @@ begin
FHintWindow.Caption := 'This is a hint window'#13#10'Neat huh?';
FHintWindow.HideInterval := 4000;
FHintWindow.AutoHide := True;
end;
end
end;
function TOICustomPropertyGrid.IsCurrentEditorAvailable: Boolean;
@ -1873,25 +1874,26 @@ begin
SetRowValue;
end;
function TOICustomPropertyGrid.GetHintTypeAt(RowIndex: integer; X: integer
): TPropEditHint;
function TOICustomPropertyGrid.GetHintTypeAt(RowIndex: integer; X: integer): TPropEditHint;
var
IconX: integer;
begin
Result:=pehNone;
if (RowIndex<0) or (RowIndex>=RowCount) then exit;
if SplitterX<=X then begin
if (FCurrentButton<>nil)
and (FCurrentButton.Left<=X) then
Result:=pehEditButton
Result := pehNone;
if (RowIndex < 0) or (RowIndex >= RowCount) then
Exit;
if SplitterX <= X then
begin
if (FCurrentButton <> nil) and (FCurrentButton.Left <= X) then
Result := pehEditButton
else
Result:=pehValue;
end else begin
IconX:=GetTreeIconX(RowIndex);
if IconX+Indent>X then
Result:=pehTree
Result := pehValue;
end else
begin
IconX := GetTreeIconX(RowIndex);
if IconX + Indent > X then
Result := pehTree
else
Result:=pehName;
Result := pehName;
end;
end;
@ -1905,7 +1907,7 @@ begin
inherited MouseDown(Button,Shift,X,Y);
//hide the hint
if FHintWindow<>nil then
if FHintWindow <> nil then
FHintWindow.Visible := False;
if Button=mbLeft then begin
@ -1971,17 +1973,20 @@ begin
end;
// to check if the property text fits in its box, if not show a hint
if ShowHint then begin
if ShowHint then
begin
Index := MouseToIndex(y,false);
// do not show a hint for the current row to not hide the editor
if (Index > -1) and (Index<>ItemIndex) then begin
if (Index > -1) and (Index <> ItemIndex) then
begin
fPropRow := GetRow(Index);
if X < SplitterX then begin
if X < SplitterX then
begin
// Mouse is over property name...
fHint := fPropRow.Name;
if ((Canvas.TextWidth(fHint)+BorderWidth+GetTreeIconX(Index)+Indent)
>= SplitterX)
and InitHints then begin
if ((Canvas.TextWidth(fHint) + BorderWidth + GetTreeIconX(Index) + Indent) >= SplitterX) and
InitHints then
begin
fHintRect := FHintWindow.CalcHintRect(0,fHint,nil);
fPoint := ClientToScreen(
Point(BorderWidth+GetTreeIconX(Index)+Indent,
@ -1990,17 +1995,18 @@ begin
FHintWindow.ActivateHint(fHintRect,fHint);
end;
end
else begin
else
begin
// Mouse is over property value...
fHint := fPropRow.LastPaintedValue;
if length(fHint)>100 then fHint:=copy(fHint,1,100)+'...';
if (Canvas.TextWidth(fHint) > (ClientWidth - BorderWidth - SplitterX))
and InitHints
then begin
if length(fHint) > 100 then fHint := copy(fHint, 1, 100) + '...';
if (Canvas.TextWidth(fHint) > (ClientWidth - BorderWidth - SplitterX)) and
InitHints then
begin
fHintRect := FHintWindow.CalcHintRect(0,fHint,nil);
fpoint := ClientToScreen(Point(SplitterX,fPropRow.Top - TopY-1));
MoveRect(fHintRect,fPoint.x,fPoint.y);
FHintWindow.ActivateHint(fHintRect,fHint);
fpoint := ClientToScreen(Point(SplitterX, fPropRow.Top - TopY - 1));
MoveRect(fHintRect, fPoint.x, fPoint.y);
FHintWindow.ActivateHint(fHintRect, fHint);
end;
end;
end;
@ -2902,55 +2908,56 @@ var
HintType: TPropEditHint;
ClientPosition: TPoint;
begin
if FHintTimer<>nil then
if FHintTimer <> nil then
FHintTimer.Enabled := False;
if (not InitHints) then exit;
Position := Mouse.CursorPos;
Window := FindLCLWindow(Position);
if not(Assigned(Window)) then Exit;
If (Window<>Self) and (not IsParentOf(Window)) then exit;
if not Assigned(Window) then Exit;
If (Window <> Self) and (not IsParentOf(Window)) then exit;
ClientPosition := ScreenToClient(Position);
if ((ClientPosition.X <=0) or (ClientPosition.X >= Width)
or (ClientPosition.Y <= 0) or (ClientPosition.Y >= Height)) then
if ((ClientPosition.X <=0) or (ClientPosition.X >= Width) or
(ClientPosition.Y <= 0) or (ClientPosition.Y >= Height)) then
Exit;
AHint := '';
Index:=MouseToIndex(ClientPosition.Y,false);
if (Index>=0) and (Index<FRows.Count) then
Index := MouseToIndex(ClientPosition.Y, False);
if (Index >= 0) and (Index < FRows.Count) then
begin
//IconX:=GetTreeIconX(Index);
PointedRow:=Rows[Index];
if Assigned(PointedRow) and Assigned(PointedRow.Editor) then begin
if Index<>ItemIndex then begin
PointedRow := Rows[Index];
if Assigned(PointedRow) and Assigned(PointedRow.Editor) then
begin
if Index <> ItemIndex then
begin
HintType := GetHintTypeAt(Index,Position.X);
if (HintType = pehName) and Assigned(OnPropertyHint) then begin
if OnPropertyHint(Self,PointedRow,Position,FHintWindow,Rect,AHint) then
begin
FHintWindow.ActivateHint(Rect,AHint);
end;
if (HintType = pehName) and Assigned(OnPropertyHint) then
begin
if OnPropertyHint(Self, PointedRow, Position, FHintWindow, Rect, AHint) then
FHintWindow.ActivateHint(Rect, AHint);
exit;
end;
AHint := PointedRow.Editor.GetHint(HintType,Position.X,Position.Y);
AHint := PointedRow.Editor.GetHint(HintType, Position.X, Position.Y);
end;
end;
end;
if AHint = '' then Exit;
Rect := FHintWindow.CalcHintRect(0,AHint,nil); //no maxwidth
Rect.Left := Position.X+10;
Rect.Top := Position.Y+10;
Rect.Right := Rect.Left + Rect.Right+3;
Rect.Bottom := Rect.Top + Rect.Bottom+3;
Rect.Left := Position.X + 10;
Rect.Top := Position.Y + 10;
Rect.Right := Rect.Left + Rect.Right + 3;
Rect.Bottom := Rect.Top + Rect.Bottom + 3;
FHintWindow.ActivateHint(Rect,AHint);
FHintWindow.ActivateHint(Rect, AHint);
end;
Procedure TOICustomPropertyGrid.ResetHintTimer;
begin
if FHintWindow=nil then exit;
if FHintWindow = nil then exit;
if FHintWIndow.Visible then
FHintWindow.Visible := False;
@ -2998,7 +3005,7 @@ var
begin
if not CanEditRowValue then exit;
if FHintTimer<>nil then
if FHintTimer <> nil then
FHintTimer.Enabled := False;
if (FCurrentEdit = ValueComboBox) then
@ -4277,9 +4284,9 @@ function TObjectInspectorDlg.OnGridPropertyHint(Sender: TObject;
PointedRow: TOIPropertyGridRow; ScreenPos: TPoint; aHintWindow: THintWindow;
out HintWinRect: TRect; out AHint: string): boolean;
begin
Result:=false;
Result := False;
if Assigned(FOnPropertyHint) then
Result:=FOnPropertyHint(Sender,PointedRow,ScreenPos,aHintWindow,HintWinRect,AHint);
Result := FOnPropertyHint(Sender, PointedRow, ScreenPos, aHintWindow, HintWinRect, AHint);
end;
procedure TObjectInspectorDlg.SetAvailComboBoxText;
@ -4662,9 +4669,9 @@ procedure TObjectInspectorDlg.OnShowHintPopupMenuItemClick(Sender : TObject);
var
Page: TObjectInspectorPage;
begin
for Page:=Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page]<>nil then
GridControl[Page].ShowHint:=not GridControl[Page].ShowHint;
for Page := Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page] <> nil then
GridControl[Page].ShowHint := not GridControl[Page].ShowHint;
end;
procedure TObjectInspectorDlg.OnShowOptionsPopupMenuItemClick(Sender: TObject);

View File

@ -80,12 +80,12 @@ end;
procedure THintWindow.AutoHideHint(Sender : TObject);
Begin
if FAutoHideTimer<>nil then
begin
if FAutoHideTimer <> nil then
TCustomTimer(FAutoHideTimer).Enabled := False;
if Visible then
Visible := False;//Hide;
End;
end;
procedure THintWindow.Paint;
var