* patch from Luca Minuti

git-svn-id: trunk@7043 -
This commit is contained in:
marc 2005-03-30 22:51:26 +00:00
parent 28cf256e02
commit 3d07b12402
3 changed files with 203 additions and 103 deletions

View File

@ -471,6 +471,18 @@ type
ObjectInspectorColorsGroupBox: TGroupBox;
OIBackgroundColorLabel: TLabel;
OIBackgroundColorButton: TColorButton;
OISubPropsColorLabel: TLabel;
OISubPropsColorButton: TColorButton;
OIReferencesColorLabel: TLabel;
OIReferencesColorButton: TColorButton;
OIValueColorLabel: TLabel;
OIValueColorButton: TColorButton;
OIDefaultValueColorLabel: TLabel;
OIDefaultValueColorButton: TColorButton;
OIPropNameColorLabel: TLabel;
OIPropNameColorButton: TColorButton;
OIMiscGroupBox: TGroupBox;
OIDefaultItemHeightSpinEdit: TSpinEdit;
OIDefaultItemHeightLabel: TLabel;
@ -538,8 +550,6 @@ type
procedure GridGroupBoxResize(Sender: TObject);
procedure GuideLinesGroupBoxResize(Sender: TObject);
procedure LazarusDirGroupBoxResize(Sender: TObject);
procedure OIMiscGroupBoxResize(Sender: TObject);
procedure ObjectInspectorColorsGroupBoxResize(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure OnBackupPageResize(Sender: TObject);
@ -566,6 +576,8 @@ type
FOldFPCSourceDir: string;
FOldMakeFilename: string;
FOldTestDir: string;
function CreateColorItem(ATop:Integer; AParent:TWinControl;ACaption:String):TColorButton;
procedure SetCategoryPage(const AValue: TEnvOptsDialogPage);
procedure SetupFilesPage(Page: integer);
procedure SetupDesktopPage(Page: integer);
@ -2897,19 +2909,22 @@ begin
end;
procedure TEnvironmentOptionsDialog.ResizeObjectInspectorPage;
var
HalfWidth:integer;
begin
HalfWidth:=ClientWidth div 2;
// object inspector
with ObjectInspectorColorsGroupBox do begin
Left:=6;
Left:=5;
Top:=2;
Width:=200;
Height:=55;
Width:= HalfWidth-15;
Height:=180;
end;
with OIMiscGroupBox do begin
Left:=ObjectInspectorColorsGroupBox.Left;
Top:=ObjectInspectorColorsGroupBox.Top+ObjectInspectorColorsGroupBox.Height+5;
Width:=200;
Left:=HalfWidth+5;
Top:=ObjectInspectorColorsGroupBox.Top;
Width:=HalfWidth-15;
Height:=77;
end;
end;
@ -3421,39 +3436,6 @@ begin
SetBounds(x+1,0,w-2-x-1,LazarusDirComboBox.Height);
end;
procedure TEnvironmentOptionsDialog.OIMiscGroupBoxResize(Sender: TObject);
begin
with OIDefaultItemHeightSpinEdit do begin
Left:=6;
Top:=4;
Width:=50;
end;
with OIDefaultItemHeightLabel do begin
Left:=OIDefaultItemHeightSpinEdit.Left+OIDefaultItemHeightSpinEdit.Width+5;
Top:=OIDefaultItemHeightSpinEdit.Top+2;
Width:=OIMiscGroupBox.ClientWidth-Left-5;
end;
end;
procedure TEnvironmentOptionsDialog.ObjectInspectorColorsGroupBoxResize(
Sender: TObject);
begin
with OIBackgroundColorButton do begin
Left:=6;
Top:=6;
Width:=50;
Height:=25;
end;
with OIBackgroundColorLabel do begin
Left:=OIBackgroundColorButton.Left+OIBackgroundColorButton.Width+5;
Top:=OIBackgroundColorButton.Top;
Width:=Max(ObjectInspectorColorsGroupBox.ClientWidth-Left-5,10);
Height:=23;
end;
end;
procedure TEnvironmentOptionsDialog.OkButtonClick(Sender: TObject);
begin
if not CheckValues then exit;
@ -3612,6 +3594,17 @@ begin
// object inspector
OIBackgroundColorButton.ButtonColor:=
ObjectInspectorOptions.GridBackgroundColor;
OISubPropsColorButton.ButtonColor:=
ObjectInspectorOptions.SubPropertiesColor;
OIReferencesColorButton.ButtonColor:=
ObjectInspectorOptions.ReferencesColor;
OIValueColorButton.ButtonColor:=
ObjectInspectorOptions.ValueColor;
OIDefaultValueColorButton.ButtonColor:=
ObjectInspectorOptions.DefaultValueColor;
OIPropNameColorButton.ButtonColor:=
ObjectInspectorOptions.PropertyNameColor;
OIDefaultItemHeightSpinEdit.Value:=
ObjectInspectorOptions.DefaultItemHeight;
OIShowHintCheckBox.Checked :=
@ -3747,6 +3740,17 @@ begin
// object inspector
ObjectInspectorOptions.GridBackgroundColor:=
OIBackgroundColorButton.ButtonColor;
ObjectInspectorOptions.SubPropertiesColor:=
OISubPropsColorButton.ButtonColor;
ObjectInspectorOptions.ReferencesColor:=
OIReferencesColorButton.ButtonColor;
ObjectInspectorOptions.ValueColor:=
OIValueColorButton.ButtonColor;
ObjectInspectorOptions.DefaultValueColor:=
OIDefaultValueColorButton.ButtonColor;
ObjectInspectorOptions.PropertyNameColor:=
OIPropNameColorButton.ButtonColor;
ObjectInspectorOptions.DefaultItemHeight:=
RoundToInt(OIDefaultItemHeightSpinEdit.Value);
ObjectInspectorOptions.ShowHints :=
@ -3855,57 +3859,70 @@ begin
end;
end;
function TEnvironmentOptionsDialog.CreateColorItem(
ATop:Integer; AParent:TWinControl;ACaption:String):TColorButton;
var
ColorButton:TColorButton;
ColorLabel:TLabel;
begin
ColorButton:=TColorButton.Create(Self);
with ColorButton do begin
Name:='ColorButton'+IntToStr(ATop);
Left:=6;
Top:=ATop;
Width:=50;
Height:=25;
Parent:=AParent;
end;
ColorLabel:=TLabel.Create(Self);
with ColorLabel do begin
Name:='ColorLabel'+IntToStr(ATop);
Left:=ColorButton.Left+ColorButton.Width+5;
Top:=ColorButton.Top+2;
Width:=AParent.ClientWidth-Left-5;
Height:=23;
Parent:=AParent;
Caption:=ACaption;//dlgBackColor;
end;
Result:=ColorButton;
end;
procedure TEnvironmentOptionsDialog.SetupObjectInspectorPage(Page: integer);
var MaxX: integer;
var HalfWidth: integer;
begin
NoteBook.Page[Page].OnResize:=@OnObjectInspectorPageResize;
MaxX:=ClientWidth-5;
HalfWidth:=ClientWidth div 2;
// object inspector
ObjectInspectorColorsGroupBox:=TGroupBox.Create(Self);
with ObjectInspectorColorsGroupBox do begin
Name:='ObjectInspectorColorsGroupBox';
Left:=6;
Left:=5;
Top:=2;
Width:=(MaxX div 2) - 15;
Height:=55;
Width:= HalfWidth-15;
Height:=180;
Parent:=NoteBook.Page[Page];
Caption:=dlgEnvColors;
OnResize:=@ObjectInspectorColorsGroupBoxResize;
end;
OIBackgroundColorButton:=TColorButton.Create(Self);
with OIBackgroundColorButton do begin
Name:='OIBackgroundColorButton';
Left:=6;
Top:=6;
Width:=50;
Height:=25;
Parent:=ObjectInspectorColorsGroupBox;
end;
OIBackgroundColorButton:=CreateColorItem(5, ObjectInspectorColorsGroupBox, dlgBackColor);
OISubPropsColorButton:=CreateColorItem(30, ObjectInspectorColorsGroupBox, dlgSubPropkColor);
OIReferencesColorButton:=CreateColorItem(55, ObjectInspectorColorsGroupBox, dlgReferenceColor);
OIValueColorButton:=CreateColorItem(80, ObjectInspectorColorsGroupBox, dlgValueColor);
OIDefaultValueColorButton:=CreateColorItem(105, ObjectInspectorColorsGroupBox, dlgDefValueColor);
OIPropNameColorButton:=CreateColorItem(130, ObjectInspectorColorsGroupBox, dlgPropNameColor);
OIBackgroundColorLabel:=TLabel.Create(Self);
with OIBackgroundColorLabel do begin
Name:='OIBackgroundColorLabel';
Left:=OIBackgroundColorButton.Left+OIBackgroundColorButton.Width+5;
Top:=OIBackgroundColorButton.Top+2;
Width:=ObjectInspectorColorsGroupBox.ClientWidth-Left-5;
Height:=23;
Parent:=ObjectInspectorColorsGroupBox;
Caption:=dlgBackColor;
end;
OIMiscGroupBox:=TGroupBox.Create(Self);
with OIMiscGroupBox do begin
Name:='OIMiscGroupBox';
Left:=ObjectInspectorColorsGroupBox.Left;
Top:=ObjectInspectorColorsGroupBox.Top+ObjectInspectorColorsGroupBox.Height+5;
Width:=200;
Left:=HalfWidth+5;
Top:=ObjectInspectorColorsGroupBox.Top;
Width:=HalfWidth-15;
Height:=77;
Parent:=NoteBook.Page[Page];
Caption:=dlgOIMiscellaneous;
OnResize:=@OIMiscGroupBoxResize;
end;
OIDefaultItemHeightSpinEdit:=TSpinEdit.Create(Self);

View File

@ -718,7 +718,13 @@ resourcestring
dlgnoAutomaticRenaming = 'no automatic renaming';
dlgAmbigWarn = 'Warn on compile';
dlgIgnoreVerb = 'Ignore';
dlgBackColor = 'Background color';
dlgBackColor = 'Background';
dlgSubPropkColor = 'Subpropertes';
dlgReferenceColor = 'Reference';
dlgValueColor = 'Value';
dlgDefValueColor = 'Default value';
dlgPropNameColor = 'Property name';
dlgOIMiscellaneous = 'Miscellaneous';
dlgOIItemHeight = 'Item height';
dlgEnvColors = 'Colors';

View File

@ -1,3 +1,4 @@
{ $Id$}
{
*****************************************************************************
* *
@ -116,6 +117,11 @@ type
FHeight: integer;
FGridSplitterX: array[TObjectInspectorPage] of integer;
FPropertyNameColor: TColor;
FDefaultValueColor: TColor;
FSubPropertiesColor: TColor;
FValueColor: TColor;
FReferencesColor: TColor;
FGridBackgroundColor: TColor;
FShowHints: boolean;
function FPropertyGridSplitterX(Page: TObjectInspectorPage): integer;
@ -146,6 +152,16 @@ type
property GridBackgroundColor: TColor read FGridBackgroundColor
write FGridBackgroundColor;
property SubPropertiesColor: TColor read FSubPropertiesColor
write FSubPropertiesColor;
property ReferencesColor: TColor read FReferencesColor
write FReferencesColor;
property ValueColor: TColor read FValueColor
write FValueColor;
property DefaultValueColor: TColor read FDefaultValueColor
write FDefaultValueColor;
property PropertyNameColor: TColor read FPropertyNameColor
write FPropertyNameColor;
property ShowHints: boolean read FShowHints
write FShowHints;
end;
@ -211,6 +227,8 @@ type
TOICustomPropertyGrid = class(TCustomControl)
private
FBackgroundColor:TColor;
FReferencesColor: TColor;
FSubPropertiesColor: TColor;
FChangeStep: integer;
FCurrentButton: TWinControl; // nil or ValueButton
FCurrentEdit: TWinControl; // nil or ValueEdit or ValueComboBox
@ -257,6 +275,7 @@ type
procedure SetSplitterX(const NewValue:integer);
procedure SetTopY(const NewValue:integer);
function GetPropNameColor(ARow:TOIPropertyGridRow):TColor;
function GetTreeIconX(Index:integer):integer;
function RowRect(ARow:integer):TRect;
procedure PaintRow(ARow:integer);
@ -293,6 +312,8 @@ type
procedure WMVScroll(var Msg: TWMScroll); message WM_VSCROLL;
procedure SetBackgroundColor(const AValue: TColor);
procedure SetReferences(const AValue: TColor);
procedure SetSubPropertiesColor(const AValue: TColor);
procedure UpdateScrollBar;
procedure FillComboboxItems;
protected
@ -342,6 +363,10 @@ type
public
property BackgroundColor: TColor read FBackgroundColor
write SetBackgroundColor default clBtnFace;
property ReferencesColor: TColor read FReferencesColor
write SetReferences default clMaroon;
property SubPropertiesColor: TColor read FSubPropertiesColor
write SetSubPropertiesColor default clGreen;
property BorderStyle default bsSingle;
property CurrentEditValue: string read GetCurrentEditValue
write SetCurrentEditValue;
@ -451,12 +476,10 @@ type
FavouriteGrid: TOICustomPropertyGrid;
StatusBar: TStatusBar;
MainPopupMenu: TPopupMenu;
ColorsPopupMenuItem: TMenuItem;
SetDefaultPopupMenuItem: TMenuItem;
AddToFavouritesPopupMenuItem: TMenuItem;
RemoveFromFavouritesPopupMenuItem: TMenuItem;
UndoPropertyPopupMenuItem: TMenuItem;
BackgroundColPopupMenuItem: TMenuItem;
ShowHintsPopupMenuItem: TMenuItem;
ShowComponentTreePopupMenuItem: TMenuItem;
ShowOptionsPopupMenuItem: TMenuItem;
@ -468,7 +491,6 @@ type
procedure OnAddToFavouritesPopupmenuItemClick(Sender: TObject);
procedure OnRemoveFromFavouritesPopupmenuItemClick(Sender: TObject);
procedure OnUndoPopupmenuItemClick(Sender: TObject);
procedure OnBackgroundColPopupMenuItemClick(Sender: TObject);
procedure OnShowHintPopupMenuItemClick(Sender: TObject);
procedure OnShowOptionsPopupMenuItemClick(Sender: TObject);
procedure OnShowComponentTreePopupMenuItemClick(Sender: TObject);
@ -617,6 +639,8 @@ begin
FPreferredSplitterX:=FSplitterX;
FIndent:=9;
FBackgroundColor:=clBtnFace;
FReferencesColor:=clMaroon;
FSubPropertiesColor:=clGreen;
FNameFont:=TFont.Create;
FNameFont.Color:=clWindowText;
FValueFont:=TFont.Create;
@ -1643,6 +1667,30 @@ begin
end;
end;
function TOICustomPropertyGrid.GetPropNameColor(ARow:TOIPropertyGridRow):TColor;
var
ParentRow:TOIPropertyGridRow;
IsObjectSubProperty:Boolean;
begin
// Try to guest if ARow, or one of its parents, is a subproperty
// of an object (and not an item of a set)
IsObjectSubProperty:=false;
ParentRow:=ARow.Parent;
while Assigned(ParentRow) do
begin
if ParentRow.Editor is TPersistentPropertyEditor then
IsObjectSubProperty:=true;
ParentRow:=ParentRow.Parent;
end;
if IsObjectSubProperty then
Result := FSubPropertiesColor
else if ARow.Editor is TPersistentPropertyEditor then
Result := FReferencesColor
else
Result := FNameFont.Color;
end;
procedure TOICustomPropertyGrid.SetBounds(aLeft,aTop,aWidth,aHeight:integer);
begin
//writeln('[TOICustomPropertyGrid.SetBounds] ',Name,' ',aLeft,',',aTop,',',aWidth,',',aHeight,' Visible=',Visible);
@ -1770,6 +1818,7 @@ begin
// draw name
OldFont:=Font;
Font:=FNameFont;
Font.Color := GetPropNameColor(CurRow);
CurRow.Editor.PropDrawName(Canvas,NameTextRect,DrawState);
Font:=OldFont;
// draw frame for name
@ -2156,6 +2205,20 @@ begin
Invalidate;
end;
procedure TOICustomPropertyGrid.SetReferences(const AValue: TColor);
begin
if FReferencesColor=AValue then exit;
FReferencesColor:=AValue;
Invalidate;
end;
procedure TOICustomPropertyGrid.SetSubPropertiesColor(const AValue: TColor);
begin
if FSubPropertiesColor=AValue then exit;
FSubPropertiesColor:=AValue;
Invalidate;
end;
//------------------------------------------------------------------------------
{ TOIPropertyGridRow }
@ -2372,6 +2435,11 @@ begin
FComponentTreeHeight:=100;
FGridBackgroundColor:=clBtnFace;
FDefaultValueColor:=clWindowText;
FSubPropertiesColor:= clGreen;
FValueColor:=clMaroon;
FReferencesColor:= clMaroon;
FPropertyNameColor:=clWindowText;
end;
function TOIOptions.Load: boolean;
@ -2417,7 +2485,18 @@ begin
Path+'ComponentTree/Height/Value',100);
FGridBackgroundColor:=ConfigStore.GetValue(
Path+'GridBackgroundColor',clBtnFace);
Path+'Color/GridBackground',clBtnFace);
FDefaultValueColor:=ConfigStore.GetValue(
Path+'Color/DefaultValue', clWindowText);
FSubPropertiesColor:=ConfigStore.GetValue(
Path+'Color/SubProperties', clGreen);
FValueColor:=ConfigStore.GetValue(
Path+'Color/Value', clMaroon);
FReferencesColor:=ConfigStore.GetValue(
Path+'Color/References',clMaroon);
FPropertyNameColor:=ConfigStore.GetValue(
Path+'Color/PropertyName',clWindowText);
FShowHints:=ConfigStore.GetValue(
Path+'ShowHints',false);
except
@ -2462,8 +2541,19 @@ begin
ConfigStore.SetDeleteValue(Path+'ComponentTree/Height/Value',
FComponentTreeHeight,100);
ConfigStore.SetDeleteValue(Path+'GridBackgroundColor',
ConfigStore.SetDeleteValue(Path+'Color/GridBackground',
FGridBackgroundColor,clBackground);
ConfigStore.SetDeleteValue(Path+'Color/DefaultValue',
FDefaultValueColor,clBackground);
ConfigStore.SetDeleteValue(Path+'Color/SubProperties',
FSubPropertiesColor,clBackground);
ConfigStore.SetDeleteValue(Path+'Color/Value',
FValueColor,clBackground);
ConfigStore.SetDeleteValue(Path+'Color/References',
FReferencesColor,clBackground);
ConfigStore.SetDeleteValue(Path+'Color/PropertyName',
FPropertyNameColor,clWindowText);
ConfigStore.SetDeleteValue(Path+'ShowHints',FShowHints,
false);
except
@ -2489,7 +2579,14 @@ begin
FDefaultItemHeight:=AnObjInspector.DefaultItemHeight;
FShowComponentTree:=AnObjInspector.ShowComponentTree;
FComponentTreeHeight:=AnObjInspector.ComponentTreeHeight;
FGridBackgroundColor:=AnObjInspector.PropertyGrid.BackgroundColor;
FSubPropertiesColor:=AnObjInspector.PropertyGrid.SubPropertiesColor;
FReferencesColor:=AnObjInspector.PropertyGrid.ReferencesColor;
FValueColor:=AnObjInspector.PropertyGrid.ValueFont.Color;
FDefaultValueColor:=AnObjInspector.PropertyGrid.DefaultValueFont.Color;
FPropertyNameColor:=AnObjInspector.PropertyGrid.NameFont.Color;
FShowHints:=AnObjInspector.PropertyGrid.ShowHint;
end;
@ -2507,6 +2604,11 @@ begin
Grid.PrefferedSplitterX:=FGridSplitterX[Page];
Grid.SplitterX:=FGridSplitterX[Page];
Grid.BackgroundColor:=FGridBackgroundColor;
Grid.SubPropertiesColor:=FSubPropertiesColor;
Grid.ReferencesColor:=FReferencesColor;
Grid.ValueFont.Color:=FValueColor;
Grid.DefaultValueFont.Color:=FDefaultValueColor;
Grid.NameFont.Color:=FPropertyNameColor;
Grid.ShowHint:=FShowHints;
end;
AnObjInspector.DefaultItemHeight:=FDefaultItemHeight;
@ -2604,11 +2706,6 @@ begin
'Undo','Set property value to last valid value',
@OnUndoPopupmenuItemClick,false,true,true);
AddSeparatorMenuItem(nil,'OptionsSeparatorMenuItem',true);
AddPopupMenuItem(ColorsPopupmenuItem,nil,'ColorsPopupMenuItem','Set Colors',''
,nil,false,true,true);
AddPopupMenuItem(BackgroundColPopupMenuItem,ColorsPopupMenuItem
,'BackgroundColPopupMenuItem','Background','Grid background color'
,@OnBackgroundColPopupMenuItemClick,false,true,true);
AddPopupMenuItem(ShowHintsPopupMenuItem,nil
,'ShowHintPopupMenuItem','Show Hints','Grid hints'
,@OnShowHintPopupMenuItemClick,false,true,true);
@ -3009,26 +3106,6 @@ begin
CurGrid.CurrentEditValue:=CurRow.Editor.GetVisualValue;
end;
procedure TObjectInspector.OnBackgroundColPopupMenuItemClick(Sender :TObject);
var
ColorDialog:TColorDialog;
Page: TObjectInspectorPage;
begin
ColorDialog:=TColorDialog.Create(nil);
try
with ColorDialog do begin
Color:=PropertyGrid.BackgroundColor;
if Execute then begin
for Page:=Low(TObjectInspectorPage) to High(TObjectInspectorPage) do
if GridControl[Page]<>nil then
GridControl[Page].BackgroundColor:=Color;
end;
end;
finally
ColorDialog.Free;
end;
end;
procedure TObjectInspector.OnGridModified(Sender: TObject);
begin
if Assigned(FOnModified) then FOnModified(Self);