IdeIntf: OI: use DefaultValueFont and ValueFont also for editors and hint window; draw default value in editor combobox with italic style.

git-svn-id: trunk@55025 -
This commit is contained in:
ondrej 2017-05-20 20:30:08 +00:00
parent c1f4cfb81a
commit 7a3d5c7a3f
2 changed files with 36 additions and 7 deletions

View File

@ -18,7 +18,7 @@ interface
uses
Classes, SysUtils, types, LCLProc, Forms, Controls, HelpIntfs, LazHelpIntf,
LMessages, LCLType, TextTools;
LMessages, LCLType, TextTools, Graphics;
type
{ THelpDBIRegExprMessage
@ -189,7 +189,8 @@ type
constructor Create; overload;
destructor Destroy; override;
function HintIsVisible: boolean;
function ShowHint(ScreenPos: TPoint; TheHint: string; const MouseOffset: Boolean = True): boolean;
function ShowHint(ScreenPos: TPoint; TheHint: string; const MouseOffset: Boolean = True;
HintFont: TFont = nil): boolean;
procedure HideHint;
procedure HideIfVisible;
public
@ -361,7 +362,7 @@ begin
end;
function THintWindowManager.ShowHint(ScreenPos: TPoint; TheHint: string;
const MouseOffset: Boolean): boolean;
const MouseOffset: Boolean; HintFont: TFont): boolean;
var
ms: TMemoryStream;
NewWidth, NewHeight: integer;
@ -370,6 +371,8 @@ var
var
HintWinRect: TRect;
begin
if HintFont<>nil then
HintTextWindow.Font := HintFont;
HintWinRect := HintTextWindow.CalcHintRect(Screen.Width, TheHint, Nil);
HintTextWindow.HintRect := HintWinRect; // Adds borders.
if MouseOffset then
@ -381,6 +384,8 @@ var
procedure DoHtml;
begin
if HintFont<>nil then
HintRenderWindow.Font := HintFont;
HtmlHelpProvider.BaseURL:=FBaseURL;
ms:=TMemoryStream.Create;
try

View File

@ -1863,7 +1863,7 @@ begin
else if paPickList in EditorAttributes then
ValueComboBox.Style:=csDropDownList // text field should be readonly
else
ValueComboBox.Style:=csDropDown;
ValueComboBox.Style:=csOwnerDrawFixed;
ValueComboBox.MaxLength:=NewRow.Editor.GetEditLimit;
ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes;
ValueComboBox.Enabled:=not NewRow.IsReadOnly;
@ -1893,6 +1893,10 @@ begin
else
FCurrentEdit.Color:=FValueDifferBackgrndColor;
end;
if NewRow.Editor.IsNotDefaultValue then
FCurrentEdit.Font:=FValueFont
else
FCurrentEdit.Font:=FDefaultValueFont;
FCurrentEdit.Visible:=true;
if (FDragging=false) and FCurrentEdit.Showing and FCurrentEdit.Enabled
and (not NewRow.IsReadOnly) and CanFocus and (Column=oipgcValue)
@ -2376,13 +2380,23 @@ end;
procedure TOICustomPropertyGrid.MouseMove(Shift:TShiftState; X,Y:integer);
var
TheHint: String;
HintType: TPropEditHint;
fPropRow: TOIPropertyGridRow;
procedure DoShow(pt: TPoint); inline;
var
HintFont: TFont;
begin
if WidgetSet.GetLCLCapability(lcTransparentWindow)=LCL_CAPABILITY_NO then
Inc(pt.Y, fPropRow.Height);
FHintManager.ShowHint(ClientToScreen(pt), TheHint, False);
if HintType<>pehValue then
HintFont := Screen.HintFont
else
if fPropRow.Editor.IsNotDefaultValue then
HintFont:=FValueFont
else
HintFont:=FDefaultValueFont;
FHintManager.ShowHint(ClientToScreen(pt), TheHint, False, HintFont);
if FHintManager.CurHintWindow<>nil then
FHintManager.CurHintWindow.OnMouseLeave := @HintMouseLeave;
end;
@ -2390,7 +2404,6 @@ var
var
SplitDistance:integer;
Index, TextLeft: Integer;
HintType: TPropEditHint;
begin
inherited MouseMove(Shift,X,Y);
SplitDistance:=X-SplitterX;
@ -3298,6 +3311,14 @@ begin
end
else if FCurrentEdit=ValueCheckBox then
SetCheckboxState(NewValue);
if (FItemIndex>=0) and (FItemIndex<RowCount) and Assigned(FCurrentEdit) then
begin
if Rows[FItemIndex].Editor.IsNotDefaultValue then
FCurrentEdit.Font:=FValueFont
else
FCurrentEdit.Font:=FDefaultValueFont;
end;
end;
procedure TOICustomPropertyGrid.SetDrawHorzGridLines(const AValue: Boolean);
@ -3441,6 +3462,9 @@ begin
Font.Color:=Pen.Color;
FillRect(ARect);
end;
ValueComboBox.Canvas.Font.Assign(FDefaultValueFont);
if CurRow.Editor.HasDefaultValue and (ItemValue = CurRow.Editor.GetDefaultValue) then
ValueComboBox.Canvas.Font.Style := ValueComboBox.Canvas.Font.Style + [fsItalic];
CurRow.Editor.ListDrawValue(ItemValue,Index,ValueComboBox.Canvas,ARect,AState);
end;
end;
@ -3505,7 +3529,7 @@ begin
else
AHint := PointedRow.Editor.GetHint(HintType, Position.X, Position.Y);
// Show hint if all is well.
if OkToShow and FHintManager.ShowHint(Position, AHint) then begin
if OkToShow and FHintManager.ShowHint(Position, AHint, True, Screen.HintFont) then begin
FHintIndex := Index;
FHintType := HintType;
FShowingLongHint := True;