IDE: reduced autosizing

git-svn-id: trunk@23900 -
This commit is contained in:
mattias 2010-03-09 17:00:25 +00:00
parent da51b1637f
commit 0374dc7a00
3 changed files with 41 additions and 23 deletions

View File

@ -107,6 +107,7 @@ type
): TRegisteredComponent; override;
procedure RegisterCustomIDEComponents(
const RegisterProc: RegisterUnitComponentProc); override;
procedure ShowHideControls(Show: boolean); override;
public
property NoteBook: TNotebook read FNoteBook write SetNoteBook;
property Selected: TRegisteredComponent read FSelected write SetSelected;
@ -455,31 +456,38 @@ var
ButtonCount: Integer;
MaxBtnPerRow: Integer;
begin
ButtonCount:=0;
// skip the first control (this is the selection tool (TSpeedButton))
for j:= 1 to Page.ControlCount-1 do begin
CurButton:=TSpeedbutton(Page.Controls[j]);
if not (CurButton is TSpeedButton) then continue;
inc(ButtonCount);
end;
if FNoteBook<>nil then
NoteBook.DisableAutoSizing;
try
ButtonCount:=0;
// skip the first control (this is the selection tool (TSpeedButton))
for j:= 1 to Page.ControlCount-1 do begin
CurButton:=TSpeedbutton(Page.Controls[j]);
if not (CurButton is TSpeedButton) then continue;
inc(ButtonCount);
end;
ButtonX:= ((ComponentPaletteBtnWidth*3) div 2) + 2;
ButtonX:= ((ComponentPaletteBtnWidth*3) div 2) + 2;
MaxBtnPerRow:=((Page.ClientWidth - ButtonX) div ComponentPaletteBtnWidth);
if MaxBtnPerRow<1 then MaxBtnPerRow:=1;
Rows:=((ButtonCount-1) div MaxBtnPerRow)+1;
//DebugLn(['TComponentPalette.ReAlignButtons ',DbgSName(Page),' PageIndex=',Page.PageIndex,' ClientRect=',dbgs(Page.ClientRect)]);
// automatically set optimal row count and re-position controls to use height optimally
MaxBtnPerRow:=((Page.ClientWidth - ButtonX) div ComponentPaletteBtnWidth);
if MaxBtnPerRow<1 then MaxBtnPerRow:=1;
Rows:=((ButtonCount-1) div MaxBtnPerRow)+1;
//DebugLn(['TComponentPalette.ReAlignButtons ',DbgSName(Page),' PageIndex=',Page.PageIndex,' ClientRect=',dbgs(Page.ClientRect)]);
// automatically set optimal row count and re-position controls to use height optimally
if Rows <= 0 then Rows:= 1; // avoid division by zero
if Rows <= 0 then Rows:= 1; // avoid division by zero
for j:= 1 to Page.ControlCount-1 do begin
CurButton:=TSpeedbutton(Page.Controls[j]);
if not (CurButton is TSpeedButton) then continue;
CurButton.SetBounds(
ButtonX + ((j-1) div Rows) * ComponentPaletteBtnWidth,
((j-1) mod Rows) * ComponentPaletteBtnHeight,
CurButton.Width,CurButton.Height)
for j:= 1 to Page.ControlCount-1 do begin
CurButton:=TSpeedbutton(Page.Controls[j]);
if not (CurButton is TSpeedButton) then continue;
CurButton.SetBounds(
ButtonX + ((j-1) div Rows) * ComponentPaletteBtnWidth,
((j-1) mod Rows) * ComponentPaletteBtnHeight,
CurButton.Width,CurButton.Height)
end;
finally
if NoteBook<>nil then
NoteBook.EnableAutoSizing;
end;
end;
@ -650,6 +658,16 @@ begin
{$ENDIF}
end;
procedure TComponentPalette.ShowHideControls(Show: boolean);
begin
NoteBook.DisableAutoSizing;
try
inherited ShowHideControls(Show);
finally
NoteBook.EnableAutoSizing;
end;
end;
initialization
{$I ../images/components_images.lrs}

View File

@ -1787,10 +1787,10 @@ begin
// Component Notebook
MainIDEBar.ComponentNotebook := TNotebook.Create(OwningComponent);
with MainIDEBar.ComponentNotebook do begin
Parent := MainIDEBar;
Name := 'ComponentNotebook';
Align := alClient;
Visible:=EnvironmentOptions.ComponentPaletteVisible;
Parent := MainIDEBar;
end;
end;

View File

@ -182,7 +182,7 @@ type
function FindButton(Button: TComponent): TRegisteredComponent;
function CreateNewClassName(const Prefix: string): string;
function IndexOfPageComponent(AComponent: TComponent): integer;
procedure ShowHideControls(Show: boolean);
procedure ShowHideControls(Show: boolean); virtual;
procedure IterateRegisteredClasses(Proc: TGetComponentClass);
procedure RegisterCustomIDEComponents(
const RegisterProc: RegisterUnitComponentProc); virtual;