MG: removed the 1x1 bitmap from TBitBtn

git-svn-id: trunk@3337 -
This commit is contained in:
lazarus 2002-09-13 16:58:27 +00:00
parent c7aeefd819
commit 5aab225599
8 changed files with 206 additions and 101 deletions

View File

@ -160,21 +160,27 @@ end;
const
LastWrittenGetMemCnt: longint = 0;
HiddenGetMemCnt: longint = 0;
procedure CheckHeapWrtMemCnt(const txt: ansistring);
var
p: pointer;
CurGetMemCount, DiffGetMemCount: longint;
StartGetMemCnt, CurGetMemCount, DiffGetMemCount: longint;
begin
CurGetMemCount:=MemCheck_getmem_cnt;
StartGetMemCnt:=MemCheck_getmem_cnt;
CurGetMemCount:=StartGetMemCnt-HiddenGetMemCnt;
DiffGetMemCount:=CurGetMemCount-LastWrittenGetMemCnt;
LastWrittenGetMemCnt:=CurGetMemCount;
writeln('>>> memcheck.pp - CheckHeap2 "',txt,'" ',
CurGetMemCount,' +',DiffGetMemCount);
CurGetMemCount,'(',StartGetMemCnt,') +',DiffGetMemCount);
QuickTrace:=false;
GetMem(p,4);
FreeMem(p);
QuickTrace:=true;
// don't count mem counts of this proc
inc(HiddenGetMemCnt,MemCheck_getmem_cnt-StartGetMemCnt);
end;
function MemCheck_getmem_cnt: longint;

View File

@ -47,8 +47,12 @@ type
TOIOptions = class
private
FCustomXMLCfg: TXMLConfig;
FFilename:string;
FFileAge: longint;
FXMLCfg: TXMLConfig;
FFileHasChangedOnDisk: boolean;
FSaveBounds: boolean;
FLeft: integer;
FTop: integer;
@ -59,6 +63,10 @@ type
FGridBackgroundColor: TColor;
FShowHints: boolean;
procedure SetFilename(const NewFilename: string);
function FileHasChangedOnDisk: boolean;
function GetXMLCfg: TXMLConfig;
procedure FileUpdated;
public
constructor Create;
destructor Destroy; override;
@ -66,7 +74,8 @@ type
function Save:boolean;
procedure Assign(AnObjInspector: TObjectInspector);
procedure AssignTo(AnObjInspector: TObjectInspector);
property Filename:string read FFilename write FFilename;
property Filename:string read FFilename write SetFilename;
property CustomXMLCfg: TXMLConfig read FCustomXMLCfg write FCustomXMLCfg;
property SaveBounds:boolean read FSaveBounds write FSaveBounds;
property Left:integer read FLeft write FLeft;
@ -1548,6 +1557,42 @@ end;
{ TOIOptions }
procedure TOIOptions.SetFilename(const NewFilename: string);
begin
if FFilename=NewFilename then exit;
FFilename:=NewFilename;
FFileHasChangedOnDisk:=true;
end;
function TOIOptions.FileHasChangedOnDisk: boolean;
begin
Result:=FFileHasChangedOnDisk
or ((FFilename<>'') and (FFileAge<>0) and (FileAge(FFilename)<>FFileAge));
FFileHasChangedOnDisk:=Result;
end;
function TOIOptions.GetXMLCfg: TXMLConfig;
begin
if CustomXMLCfg<>nil then begin
Result:=CustomXMLCfg;
end else begin
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
FXMLCfg.Free;
FXMLCfg:=TXMLConfig.Create(FFilename);
end;
Result:=FXMLCfg;
end;
end;
procedure TOIOptions.FileUpdated;
begin
FFileHasChangedOnDisk:=false;
if FFilename<>'' then
FFileAge:=FileAge(FFilename)
else
FFileAge:=0;
end;
constructor TOIOptions.Create;
begin
inherited Create;
@ -1566,7 +1611,7 @@ end;
destructor TOIOptions.Destroy;
begin
FXMLCfg.Free;
inherited Destroy;
end;
@ -1576,30 +1621,27 @@ begin
Result:=false;
if not FileExists(FFilename) then exit;
try
XMLConfig:=TXMLConfig.Create(FFileName);
try
FSaveBounds:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Valid'
,false);
if FSaveBounds then begin
FLeft:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Left',0);
FTop:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Top',0);
FWidth:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Width',250);
FHeight:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Height',400);
end;
FPropertyGridSplitterX:=XMLConfig.GetValue(
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',110);
if FPropertyGridSplitterX<10 then FPropertyGridSplitterX:=10;
FEventGridSplitterX:=XMLConfig.GetValue(
'ObjectInspectorOptions/Bounds/EventGridSplitterX',110);
if FEventGridSplitterX<10 then FEventGridSplitterX:=10;
XMLConfig:=GetXMLCfg;
FGridBackgroundColor:=XMLConfig.GetValue(
'ObjectInspectorOptions/GridBackgroundColor',clBtnFace);
FShowHints:=XMLConfig.GetValue(
'ObjectInspectorOptions/ShowHints',false);
finally
XMLConfig.Free;
FSaveBounds:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Valid'
,false);
if FSaveBounds then begin
FLeft:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Left',0);
FTop:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Top',0);
FWidth:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Width',250);
FHeight:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Height',400);
end;
FPropertyGridSplitterX:=XMLConfig.GetValue(
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',110);
if FPropertyGridSplitterX<10 then FPropertyGridSplitterX:=10;
FEventGridSplitterX:=XMLConfig.GetValue(
'ObjectInspectorOptions/Bounds/EventGridSplitterX',110);
if FEventGridSplitterX<10 then FEventGridSplitterX:=10;
FGridBackgroundColor:=XMLConfig.GetValue(
'ObjectInspectorOptions/GridBackgroundColor',clBtnFace);
FShowHints:=XMLConfig.GetValue(
'ObjectInspectorOptions/ShowHints',false);
except
exit;
end;
@ -1611,29 +1653,27 @@ var XMLConfig: TXMLConfig;
begin
Result:=false;
try
XMLConfig:=TXMLConfig.Create(FFileName);
try
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Valid',FSaveBounds);
if FSaveBounds then begin
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Left',FLeft);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Top',FTop);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Width',FWidth);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Height',FHeight);
end;
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX'
,FPropertyGridSplitterX);
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/EventGridSplitterX'
,FEventGridSplitterX);
XMLConfig:=GetXMLCfg;
XMLConfig.SetValue('ObjectInspectorOptions/GridBackgroundColor'
,FGridBackgroundColor);
XMLConfig.SetValue('ObjectInspectorOptions/ShowHints',FShowHints);
finally
XMLConfig.Flush;
XMLConfig.Free;
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Valid',FSaveBounds);
if FSaveBounds then begin
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Left',FLeft);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Top',FTop);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Width',FWidth);
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Height',FHeight);
end;
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX'
,FPropertyGridSplitterX);
XMLConfig.SetValue(
'ObjectInspectorOptions/Bounds/EventGridSplitterX'
,FEventGridSplitterX);
XMLConfig.SetValue('ObjectInspectorOptions/GridBackgroundColor'
,FGridBackgroundColor);
XMLConfig.SetValue('ObjectInspectorOptions/ShowHints',FShowHints);
if XMLConfig<>CustomXMLCfg then XMLConfig.Flush;
except
exit;
end;

View File

@ -129,6 +129,10 @@ type
TEnvironmentOptions = class
private
FFilename: string;
FFileAge: longint;
FXMLCfg: TXMLConfig;
FFileHasChangedOnDisk: boolean;
FOnApplyWindowLayout: TOnApplyIDEWindowLayout;
// auto save
@ -199,9 +203,12 @@ type
procedure SetOnApplyWindowLayout(const AValue: TOnApplyIDEWindowLayout);
procedure SetFileName(const NewFilename: string);
procedure InitLayoutList;
procedure InternOnApplyWindowLayout(ALayout: TIDEWindowLayout);
procedure SetFileName(const NewFilename: string);
function FileHasChangedOnDisk: boolean;
function GetXMLCfg: TXMLConfig;
procedure FileUpdated;
public
constructor Create;
destructor Destroy; override;
@ -633,6 +640,7 @@ begin
FIDEDialogLayoutList.Free;
IDEOptionDefs.IDEDialogLayoutList:=nil;
fIDEWindowLayoutList.Free;
FXMLCfg.Free;
inherited Destroy;
end;
@ -645,13 +653,14 @@ begin
if (not FileExists(ConfFileName)) then begin
writeln('Note: environment config file not found - using defaults');
end;
FFilename:=ConfFilename;
Filename:=ConfFilename;
end;
procedure TEnvironmentOptions.SetFileName(const NewFilename: string);
begin
if FFilename=NewFilename then exit;
FFilename:=NewFilename;
FFileHasChangedOnDisk:=true;
end;
procedure TEnvironmentOptions.Load(OnlyDesktop:boolean);
@ -715,7 +724,7 @@ var XMLConfig: TXMLConfig;
begin
try
XMLConfig:=TXMLConfig.Create(FFileName);
XMLConfig:=GetXMLCfg;
FileVersion:=XMLConfig.GetValue('EnvironmentOptions/Version/Value',0);
// language
@ -856,12 +865,11 @@ begin
'EnvironmentOptions/AmbigiousFileAction/Value',
AmbigiousFileActionNames[fAmbigiousFileAction]));
XMLConfig.Free;
// object inspector
FObjectInspectorOptions.Filename:=FFilename;
FObjectInspectorOptions.Load;
FObjectInspectorOptions.SaveBounds:=false;
FileUpdated;
except
// ToDo
on E: Exception do
@ -905,7 +913,7 @@ var XMLConfig: TXMLConfig;
begin
try
XMLConfig:=TXMLConfig.Create(FFileName);
XMLConfig:=GetXMLCfg;
XMLConfig.SetValue('EnvironmentOptions/Version/Value',EnvOptsVersion);
// language
@ -1016,17 +1024,15 @@ begin
XMLConfig.SetValue('EnvironmentOptions/AutoDeleteAmbigiousSources/Value',
AmbigiousFileActionNames[fAmbigiousFileAction]);
XMLConfig.Flush;
XMLConfig.Free;
// object inspector
FObjectInspectorOptions.Filename:=FFilename;
FObjectInspectorOptions.SaveBounds:=false;
FObjectInspectorOptions.Save;
XMLConfig.Flush;
FileUpdated;
except
// ToDo
writeln('[TEnvironmentOptions.Save] error writing "',FFilename,'"');
writeln('[TEnvironmentOptions.Save] error writing "',Filename,'"');
end;
end;
@ -1053,48 +1059,31 @@ begin
end;
procedure TEnvironmentOptions.InitLayoutList;
procedure CreateWindowLayout(const TheFormID: string);
var
NewLayout: TIDEWindowLayout;
begin
NewLayout:=TIDEWindowLayout.Create;
with NewLayout do begin
FormID:=TheFormID;
WindowPlacementsAllowed:=[iwpRestoreWindowGeometry,iwpDefault,
iwpCustomPosition,iwpUseWindowManagerSetting];
end;
IDEWindowLayoutList.Add(NewLayout);
end;
var
NewLayout: TIDEWindowLayout;
i: integer;
begin
fIDEWindowLayoutList:=TIDEWindowLayoutList.Create;
// Main IDE bar
NewLayout:=TIDEWindowLayout.Create;
with NewLayout do begin
FormID:=DefaultMainIDEName;
WindowPlacementsAllowed:=[iwpRestoreWindowGeometry,iwpDefault,
iwpCustomPosition,iwpUseWindowManagerSetting];
end;
IDEWindowLayoutList.Add(NewLayout);
CreateWindowLayout(DefaultMainIDEName);
CreateWindowLayout(DefaultObjectInspectorName);
CreateWindowLayout(DefaultSourceNoteBookName);
CreateWindowLayout(DefaultMessagesViewName);
CreateWindowLayout(DefaultUnitDependenciesName);
// object inspector
NewLayout:=TIDEWindowLayout.Create;
with NewLayout do begin
FormID:=DefaultObjectInspectorName;
WindowPlacementsAllowed:=[iwpRestoreWindowGeometry,iwpDefault,
iwpCustomPosition,iwpUseWindowManagerSetting];
end;
IDEWindowLayoutList.Add(NewLayout);
// source editor
NewLayout:=TIDEWindowLayout.Create;
with NewLayout do begin
FormID:=DefaultSourceNoteBookName;
WindowPlacementsAllowed:=[iwpRestoreWindowGeometry,iwpDefault,
iwpCustomPosition,iwpUseWindowManagerSetting];
end;
IDEWindowLayoutList.Add(NewLayout);
// messages view
NewLayout:=TIDEWindowLayout.Create;
with NewLayout do begin
FormID:=DefaultMessagesViewName;
WindowPlacementsAllowed:=[iwpRestoreWindowGeometry,iwpDefault,
iwpCustomPosition,iwpUseWindowManagerSetting];
end;
IDEWindowLayoutList.Add(NewLayout);
for i:=0 to fIDEWindowLayoutList.Count-1 do begin
IDEWindowLayoutList[i].OnApply:=@InternOnApplyWindowLayout;
IDEWindowLayoutList[i].DefaultWindowPlacement:=iwpRestoreWindowGeometry;
@ -1107,6 +1096,33 @@ begin
if Assigned(OnApplyWindowLayout) then OnApplyWindowLayout(ALayout);
end;
function TEnvironmentOptions.FileHasChangedOnDisk: boolean;
begin
Result:=FFileHasChangedOnDisk
or ((FFilename<>'') and (FFileAge<>0) and (FileAge(FFilename)<>FFileAge));
FFileHasChangedOnDisk:=Result;
end;
function TEnvironmentOptions.GetXMLCfg: TXMLConfig;
begin
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
FXMLCfg.Free;
FXMLCfg:=TXMLConfig.Create(Filename);
ObjectInspectorOptions.Filename:=Filename;
ObjectInspectorOptions.CustomXMLCfg:=FXMLCfg;
end;
Result:=FXMLCfg;
end;
procedure TEnvironmentOptions.FileUpdated;
begin
FFileHasChangedOnDisk:=false;
if FFilename<>'' then
FFileAge:=FileAge(FFilename)
else
FFileAge:=0;
end;
procedure TEnvironmentOptions.SetOnApplyWindowLayout(
const AValue: TOnApplyIDEWindowLayout);
begin

View File

@ -39,6 +39,7 @@ const
DefaultMainIDEName = 'MainIDE';
DefaultSourceNoteBookName = 'SourceNotebook';
DefaultMessagesViewName = 'MessagesView';
DefaultUnitDependenciesName = 'UnitDependencies';
type
{ TIDEWindowLayout stores information about the position, min/maximized state
@ -87,6 +88,7 @@ type
fOnApply: TOnApplyIDEWindowLayout;
fDefaultWindowPlacement: TIDEWindowPlacement;
function GetFormID: string;
function GetXMLFormID: string;
procedure SetFormID(const AValue: string);
procedure SetOnGetDefaultIDEWindowPos(const AValue: TOnGetDefaultIDEWindowPos);
procedure SetDockModesAllowed(const AValue: TIDEWindowDockModes);
@ -319,7 +321,7 @@ begin
Clear;
// read settings
// build path
P:=GetFormID;
P:=GetXMLFormID;
if P='' then exit;
P:=Path+P+'/';
// placement
@ -353,7 +355,7 @@ var
i: integer;
begin
// build path
P:=GetFormID;
P:=GetXMLFormID;
if P='' then exit;
P:=Path+P+'/';
// placement
@ -425,6 +427,16 @@ begin
Result:=FForm.Name;
end;
function TIDEWindowLayout.GetXMLFormID: string;
var
i: integer;
begin
Result:=GetFormID;
for i:=1 to length(Result) do
if not (Result[i] in ['A'..'Z','a'..'z','_']) then
Result[i]:='_';
end;
procedure TIDEWindowLayout.SetDockParent(const AValue: string);
begin
fDockParent:=AValue;

View File

@ -21,6 +21,7 @@
{ $DEFINE IDE_VERBOSE}
// !!! if you change this flag, you have to make cleanide !!!
{ $DEFINE IDE_MEM_CHECK}
{ $DEFINE IDE_DEBUG}

View File

@ -41,7 +41,12 @@ unit Project;
interface
{$I ide.inc}
uses
{$IFDEF IDE_MEM_CHECK}
MemCheck,
{$ENDIF}
Classes, SysUtils, LCLLinux, LCLType, Laz_XMLCfg, LazConf, CompilerOptions,
FileCtrl, CodeToolManager, CodeCache, Forms, Controls, EditorOptions, Dialogs,
IDEProcs, RunParamsOpts, ProjectDefs, EditDefineTree, DefineTemplates;
@ -251,7 +256,7 @@ type
constructor Create(TheProjectType: TProjectType);
destructor Destroy; override;
function ReadProject(LPIFilename: string): TModalResult;
function ReadProject(const LPIFilename: string): TModalResult;
function WriteProject: TModalResult;
property Units[Index: integer]:TUnitInfo read GetUnits write SetUnits;
@ -1097,7 +1102,7 @@ end;
{------------------------------------------------------------------------------
TProject ReadProject
------------------------------------------------------------------------------}
function TProject.ReadProject(LPIFilename: string): TModalResult;
function TProject.ReadProject(const LPIFilename: string): TModalResult;
procedure LoadFlags;
var f: TProjectFlag;
@ -1122,7 +1127,9 @@ begin
ProjectInfoFile:=LPIFilename;
try
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject A reading lpi');{$ENDIF}
xmlconfig := TXMLConfig.Create(ProjectInfoFile);
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject B done lpi');{$ENDIF}
except
MessageDlg('Unable to read the project info file'#13'"'+ProjectInfoFile+'".'
,mtError,[mbOk],0);
@ -1131,6 +1138,7 @@ begin
end;
try
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF}
ProjectType := ProjectTypeNameToType(xmlconfig.GetValue(
'ProjectOptions/General/ProjectType/Value', ''));
LoadFlags;
@ -1149,6 +1157,7 @@ begin
fJumpHistory.LoadFromXMLConfig(xmlconfig,'ProjectOptions/');
FSrcPath := xmlconfig.GetValue('ProjectOptions/General/SrcPath/Value','');
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject D reading units');{$ENDIF}
NewUnitCount:=xmlconfig.GetValue('ProjectOptions/Units/Count',0);
for i := 0 to NewUnitCount - 1 do begin
NewUnitInfo:=TUnitInfo.Create(nil);
@ -1157,6 +1166,7 @@ begin
xmlconfig,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
// Load the compiler options
CompilerOptions.XMLConfigFile := xmlconfig;
CompilerOptions.ProjectFile := MainFilename;
@ -1166,14 +1176,17 @@ begin
// load the Run Parameter Options
RunParameterOptions.Load(xmlconfig,'ProjectOptions/');
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
ProjectDirectory;
CodeToolBoss.DefineTree.ClearCache;
finally
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject freeing xml');{$ENDIF}
xmlconfig.Free;
xmlconfig:=nil;
end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject END');{$ENDIF}
Result := mrOk;
end;
@ -1916,6 +1929,9 @@ end.
{
$Log$
Revision 1.75 2002/09/13 16:58:26 lazarus
MG: removed the 1x1 bitmap from TBitBtn
Revision 1.74 2002/09/05 19:03:36 lazarus
MG: improved handling of ambigious source files

View File

@ -1,3 +1,5 @@
// included by graphics.pp
{******************************************************************************
TBitMap
******************************************************************************
@ -457,9 +459,15 @@ begin
end;
end;
// included by graphics.pp
{ =============================================================================
$Log$
Revision 1.19 2002/09/13 16:58:27 lazarus
MG: removed the 1x1 bitmap from TBitBtn
Revision 1.18 2002/09/12 05:56:15 lazarus
MG: gradient fill, minor issues from Andrew

View File

@ -1,3 +1,5 @@
// included by buttons.pp
{
*****************************************************************************
* *
@ -44,6 +46,7 @@ begin
FOriginal.Free;
FOriginal:= Value;
FOriginal.OnChange := @GlyphChanged;
FNumGlyphs:=1;
if (FOriginal <> nil) and (FOriginal.Height > 0) then begin
if FOriginal.Width mod FOriginal.Height = 0 then begin
GlyphCount:= FOriginal.Width div FOriginal.Height;
@ -112,3 +115,6 @@ begin
GlyphChanged(FOriginal);
end;
end;
// included by buttons.pp