mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 22:56:46 +02:00
IDE: use font style instead of colors for Options dialog filter
git-svn-id: trunk@35707 -
This commit is contained in:
parent
8d5fd4cd9f
commit
721d8f2b59
@ -26,7 +26,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Controls, Buttons, Forms, StdCtrls, Graphics,
|
Classes, SysUtils, LCLProc, Controls, Buttons, Forms, StdCtrls, Graphics,
|
||||||
ComCtrls, Grids;
|
ComCtrls, Grids, maps;
|
||||||
|
|
||||||
const
|
const
|
||||||
NoParent = -1;
|
NoParent = -1;
|
||||||
@ -37,6 +37,9 @@ type
|
|||||||
|
|
||||||
// types
|
// types
|
||||||
|
|
||||||
|
// Original font styles, used by filter.
|
||||||
|
TDefaultFontStyles = TMap; // specialize <TControl, TFontStyles>;
|
||||||
|
|
||||||
TIDEOptionsHandler = (
|
TIDEOptionsHandler = (
|
||||||
iohBeforeRead,
|
iohBeforeRead,
|
||||||
iohAfterRead,
|
iohAfterRead,
|
||||||
@ -111,9 +114,12 @@ type
|
|||||||
FOnSaveIDEOptions: TOnSaveIDEOptions;
|
FOnSaveIDEOptions: TOnSaveIDEOptions;
|
||||||
FRec: PIDEOptionsEditorRec;
|
FRec: PIDEOptionsEditorRec;
|
||||||
FGroupRec: PIDEOptionsGroupRec;
|
FGroupRec: PIDEOptionsGroupRec;
|
||||||
|
FDefaultStyles: TDefaultFontStyles;
|
||||||
protected
|
protected
|
||||||
procedure DoOnChange;
|
procedure DoOnChange;
|
||||||
public
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
function Check: Boolean; virtual;
|
function Check: Boolean; virtual;
|
||||||
function GetTitle: String; virtual; abstract;
|
function GetTitle: String; virtual; abstract;
|
||||||
procedure Setup(ADialog: TAbstractOptionsEditorDialog); virtual; abstract;
|
procedure Setup(ADialog: TAbstractOptionsEditorDialog); virtual; abstract;
|
||||||
@ -123,6 +129,7 @@ type
|
|||||||
class function SupportedOptionsClass: TAbstractIDEOptionsClass; virtual; abstract;
|
class function SupportedOptionsClass: TAbstractIDEOptionsClass; virtual; abstract;
|
||||||
class function DefaultCollapseChildNodes: Boolean; virtual;
|
class function DefaultCollapseChildNodes: Boolean; virtual;
|
||||||
function FindOptionControl(AClass: TControlClass): TControl;
|
function FindOptionControl(AClass: TControlClass): TControl;
|
||||||
|
procedure RememberDefaultStyles;
|
||||||
function ContainsTextInCaption(AText: string): Boolean;
|
function ContainsTextInCaption(AText: string): Boolean;
|
||||||
|
|
||||||
property OnLoadIDEOptions: TOnLoadIDEOptions read FOnLoadIDEOptions write FOnLoadIDEOptions;
|
property OnLoadIDEOptions: TOnLoadIDEOptions read FOnLoadIDEOptions write FOnLoadIDEOptions;
|
||||||
@ -205,6 +212,9 @@ function RegisterIDEOptionsEditor(AGroupIndex: Integer;
|
|||||||
function IDEEditorGroups: TIDEOptionsGroupList;
|
function IDEEditorGroups: TIDEOptionsGroupList;
|
||||||
|
|
||||||
const
|
const
|
||||||
|
// Font style used by filter
|
||||||
|
MatchFontStyle: TFontStyles = [fsBold, fsItalic, fsUnderline]; // Color = clFuchsia;
|
||||||
|
|
||||||
// predefined environment options groups
|
// predefined environment options groups
|
||||||
GroupEnvironment = 100;
|
GroupEnvironment = 100;
|
||||||
EnvOptionsFiles = 100;
|
EnvOptionsFiles = 100;
|
||||||
@ -380,6 +390,18 @@ end;
|
|||||||
|
|
||||||
{ TAbstractIDEOptionsEditor }
|
{ TAbstractIDEOptionsEditor }
|
||||||
|
|
||||||
|
constructor TAbstractIDEOptionsEditor.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FDefaultStyles:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TAbstractIDEOptionsEditor.Destroy;
|
||||||
|
begin
|
||||||
|
FDefaultStyles.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAbstractIDEOptionsEditor.DoOnChange;
|
procedure TAbstractIDEOptionsEditor.DoOnChange;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnChange) then
|
if Assigned(FOnChange) then
|
||||||
@ -410,10 +432,11 @@ function TAbstractIDEOptionsEditor.FindOptionControl(AClass: TControlClass): TCo
|
|||||||
begin
|
begin
|
||||||
if AControl is AClass then
|
if AControl is AClass then
|
||||||
exit(AControl);
|
exit(AControl);
|
||||||
|
// Search child controls inside this one.
|
||||||
if AControl is TWinControl then begin
|
if AControl is TWinControl then begin
|
||||||
AWinControl:=TWinControl(AControl);
|
AWinControl:=TWinControl(AControl);
|
||||||
for i:=0 to AWinControl.ControlCount-1 do begin
|
for i:=0 to AWinControl.ControlCount-1 do begin
|
||||||
Result:=Search(AWinControl.Controls[i]);
|
Result:=Search(AWinControl.Controls[i]); // Recursive call.
|
||||||
if Result<>nil then exit;
|
if Result<>nil then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -424,12 +447,43 @@ begin
|
|||||||
Result:=Search(GetParentForm(Self));
|
Result:=Search(GetParentForm(Self));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TAbstractIDEOptionsEditor.RememberDefaultStyles;
|
||||||
|
// Store original font styles of controls to a map so the filter can restore them.
|
||||||
|
|
||||||
|
procedure Search(AControl: TControl);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
AWinControl: TWinControl;
|
||||||
|
begin
|
||||||
|
// Store only if there is any style defined
|
||||||
|
if AControl.Font.Style <> [] then begin
|
||||||
|
Assert(AControl.Font.Style<>MatchFontStyle, 'Do not use the same font style that filter uses.');
|
||||||
|
// FDefaultStyles.SetData(AControl, AControl.Font.Style);
|
||||||
|
end;
|
||||||
|
// Search child controls inside this one.
|
||||||
|
if AControl is TWinControl then begin
|
||||||
|
AWinControl:=TWinControl(AControl);
|
||||||
|
for i:=0 to AWinControl.ControlCount-1 do
|
||||||
|
Search(AWinControl.Controls[i]); // Recursive call.
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if FDefaultStyles=nil then begin
|
||||||
|
// FDefaultStyles:=TDefaultFontStyles.Create(ituPtrSize, SizeOf(TFontStyles));
|
||||||
|
Search(Self);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TAbstractIDEOptionsEditor.ContainsTextInCaption(AText: string): Boolean;
|
function TAbstractIDEOptionsEditor.ContainsTextInCaption(AText: string): Boolean;
|
||||||
const
|
|
||||||
FoundColor = clFuchsia;
|
|
||||||
var
|
var
|
||||||
LowerText: String;
|
LowerText: String;
|
||||||
|
|
||||||
|
function SearchComboBox(AControl: TCustomComboBox): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=False; // ToDo...
|
||||||
|
end;
|
||||||
|
|
||||||
function SearchListBox(AControl: TCustomListBox): Boolean;
|
function SearchListBox(AControl: TCustomListBox): Boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -437,54 +491,69 @@ var
|
|||||||
Result:=False;
|
Result:=False;
|
||||||
for i := 0 to AControl.Items.Count-1 do begin
|
for i := 0 to AControl.Items.Count-1 do begin
|
||||||
if Pos(LowerText, LowerCase(AControl.Items[i]))>0 then begin
|
if Pos(LowerText, LowerCase(AControl.Items[i]))>0 then begin
|
||||||
if Length(LowerText)>2 then
|
//if Length(LowerText)>2 then
|
||||||
DebugLn('TAbstractIDEOptionsEditor.ContainsTextInCaption: Searching "',
|
// DebugLn('TAbstractIDEOptionsEditor.ContainsTextInCaption: Searching "',
|
||||||
LowerText, '", Found "', AControl.Items[i], '", in ListBox ', AControl.Name);
|
// LowerText, '", Found "', AControl.Items[i], '", in ListBox ', AControl.Name);
|
||||||
// ToDo: Indicate found item somehow.
|
// ToDo: Indicate found item somehow.
|
||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SearchListView(AControl: TListView): Boolean;
|
function SearchListView(AControl: TCustomListView): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False; // ToDo...
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SearchStringGrid(AControl: TStringGrid): Boolean;
|
function SearchTreeView(AControl: TCustomTreeView): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False; // ToDo...
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SearchStringGrid(AControl: TCustomStringGrid): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=False; // ToDo...
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SearchMemo(AControl: TCustomMemo): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=False; // Memo.Caption returns all the lines, skip.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Search(AControl: TControl): Boolean;
|
function Search(AControl: TControl): Boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Found: SizeInt;
|
AWinControl: TWinControl;
|
||||||
AWinControl, SubCtrl: TWinControl;
|
DefStyle: TFontStyles;
|
||||||
lb: TListBox;
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
// *** First find matches in different controls ***
|
// *** First find matches in different controls ***
|
||||||
if AControl is TMemo then begin // Memo.Caption returns all the lines, skip.
|
// TSynEdit can't be used here in IdeOptionsIntf !
|
||||||
end
|
//if AControl is TSynEdit then Found:=SearchSynEdit(AControl)
|
||||||
//else if AControl is TSynEdit then // Can't be used here in IdeOptionsIntf !
|
if AControl is TCustomComboBox then
|
||||||
// Found:=SearchSynEdit(AControl)
|
Result:=SearchComboBox(TCustomComboBox(AControl))
|
||||||
//else if AControl is TComboBox then
|
|
||||||
// Found:=SearchComboBox(AControl)
|
|
||||||
else if AControl is TCustomListBox then
|
else if AControl is TCustomListBox then
|
||||||
Result:=SearchListBox(TCustomListBox(AControl))
|
Result:=SearchListBox(TCustomListBox(AControl))
|
||||||
else if AControl is TListView then
|
else if AControl is TCustomListView then
|
||||||
Result:=SearchListView(TListView(AControl))
|
Result:=SearchListView(TCustomListView(AControl))
|
||||||
else if AControl is TStringGrid then
|
else if AControl is TCustomTreeView then
|
||||||
Result:=SearchStringGrid(TStringGrid(AControl))
|
Result:=SearchTreeView(TCustomTreeView(AControl))
|
||||||
|
else if AControl is TCustomStringGrid then
|
||||||
|
Result:=SearchStringGrid(TCustomStringGrid(AControl))
|
||||||
|
else if AControl is TCustomMemo then
|
||||||
|
Result:=SearchMemo(TCustomMemo(AControl))
|
||||||
else begin
|
else begin
|
||||||
Result:=Pos(LowerText, LowerCase(AControl.Caption))>0;
|
Result:=Pos(LowerText, LowerCase(AControl.Caption))>0;
|
||||||
// ToDo: How to change text color on a button?
|
// Indicate the match
|
||||||
// if AControl is TButton then begin end else
|
|
||||||
if Result then
|
if Result then
|
||||||
AControl.Font.Color:=FoundColor // Indicate the match
|
AControl.Font.Style:=MatchFontStyle
|
||||||
else if AControl.Font.Color=FoundColor then
|
// or, remove the indication.
|
||||||
AControl.Font.Color:=clDefault; // Remove the indication of a found item.
|
else if AControl.Font.Style=MatchFontStyle then begin
|
||||||
|
DefStyle:=[];
|
||||||
|
// if FDefaultStyles.HasId(AControl) then
|
||||||
|
// FDefaultStyles.GetData(AControl, DefStyle);
|
||||||
|
AControl.Font.Style:=DefStyle;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Check child controls inside this one.
|
// Check child controls inside this one.
|
||||||
|
Loading…
Reference in New Issue
Block a user