try fix autosize in TToolBar

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1184 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2010-03-22 19:48:23 +00:00
parent 98dcd62339
commit 76a44434e5
2 changed files with 58 additions and 42 deletions

View File

@ -158,6 +158,7 @@
<link id="TRxDBGrid">RxDBGrid</link>-а.</p> <link id="TRxDBGrid">RxDBGrid</link>-а.</p>
</descr> </descr>
</element> </element>
@ -556,6 +557,7 @@
<link id="TRxDBGrid">RxDBGrid</link>-а.</p> <link id="TRxDBGrid">RxDBGrid</link>-а.</p>
</descr> </descr>
<seealso> <seealso>
@ -1104,6 +1106,7 @@ TRxDBCalcEdit является наследником TDBCalcEdit и имеет
<b>Count</b> <b>Count</b>
@ -1115,7 +1118,9 @@ TRxDBCalcEdit является наследником TDBCalcEdit и имеет
</element> </element>
<element name="TFolderLister.Count"> <element name="TFolderLister.Count">
<short>Количество прочитанных файлов/каталогов</short> <short>Количество прочитанных файлов/каталогов</short>
<descr>Свойство содержит в себе кол-во прочитанных файлов</descr> <descr>
<p>Свойство содержит в себе кол-во прочитанных файлов</p>
</descr>
<seealso> <seealso>
<link id="TFolderLister.Files"/> <link id="TFolderLister.Files"/>
</seealso> </seealso>
@ -1125,34 +1130,8 @@ TRxDBCalcEdit является наследником TDBCalcEdit и имеет
<short>Свойство FileFolder</short> <short>Свойство FileFolder</short>
<descr> <descr>
<b>property FileFolder:string</b> <b>property FileFolder:string</b>
Свойство FileFolder определяет каталог с файлами, который будет сканироваться при вызове метода <p>Свойство FileFolder определяет каталог с файлами, который будет сканироваться при вызове метода <link id="TFolderLister.Execute">Execute</link> и по содержимому которого будет произведено заполнение массива Files</p>
</descr>
<b>Execute</b> и по содержимому которого будет произведено заполнение массива Files</descr>
<seealso> <seealso>
<link id="TFolderLister.Execute"/> <link id="TFolderLister.Execute"/>
</seealso> </seealso>
@ -1161,13 +1140,17 @@ TRxDBCalcEdit является наследником TDBCalcEdit и имеет
<short>Свойство OnExecuteItem</short> <short>Свойство OnExecuteItem</short>
<descr> <descr>
<b>property OnExecuteItem:TNotifyEvent</b> <b>property OnExecuteItem:TNotifyEvent</b>
Свойство OnExecuteItem вызывается при выборе пункта меню, которые было сформировано по элементам массива Files</descr> <p>Свойство OnExecuteItem вызывается при выборе пункта меню, которые было сформировано по элементам массива <link id="TFolderLister.Files">Files</link>
</p>
</descr>
</element> </element>
<element name="TFolderLister.MenuItem"> <element name="TFolderLister.MenuItem">
<short>Свойство MenuItem</short> <short>Свойство MenuItem</short>
<descr> <descr>
<b>property MenuItem:TMenuItem;</b> <b>property MenuItem:TMenuItem;</b>
Данное свойство определяет место в меню, где будет добавлено в виде подменю содержимое каталога FileFolder</descr> <p>Данное свойство определяет место в меню, где будет добавлено в виде подменю содержимое каталога <link id="TFolderLister.FileFolder">FileFolder</link>
</p>
</descr>
<seealso> <seealso>
<link id="TFolderLister.Execute"/> <link id="TFolderLister.Execute"/>
</seealso> </seealso>
@ -2398,6 +2381,7 @@ Description
<b>const</b> SearchDomain, FileName: <b>const</b> SearchDomain, FileName:
@ -2415,6 +2399,7 @@ Description
<b>String</b>; <b>String</b>;
@ -2432,6 +2417,7 @@ Description
<b>out</b> UserName, DomainName: <b>out</b> UserName, DomainName:
@ -2449,6 +2435,7 @@ Description
<b>String</b>); <b>String</b>);
</p> </p>
<p>Процедура возвращает имя и домен пользователя операционной системы владельца указанного файла. </p> <p>Процедура возвращает имя и домен пользователя операционной системы владельца указанного файла. </p>
@ -2483,6 +2470,7 @@ Description
<b>const</b> DirName: <b>const</b> DirName:
@ -2494,6 +2482,7 @@ Description
<b>string</b>): <b>string</b>):
@ -2505,6 +2494,7 @@ Description
<b>string</b>;</p> <b>string</b>;</p>
<p>Функция проверяет все разделители каталогов в указанном имени файла/каталога и, если нужно, меняет их на значение константы<b>DirectorySeparator</b>.</p> <p>Функция проверяет все разделители каталогов в указанном имени файла/каталога и, если нужно, меняет их на значение константы<b>DirectorySeparator</b>.</p>
</descr> </descr>
@ -2530,6 +2520,7 @@ Description
<b>string</b>;</p> <b>string</b>;</p>
<p>Функция <b>GetUserName</b> возвращает имя оператора, залогиненго в системе</p> <p>Функция <b>GetUserName</b> возвращает имя оператора, залогиненго в системе</p>
</descr> </descr>

View File

@ -665,12 +665,25 @@ begin
FAutoSize:=AValue; FAutoSize:=AValue;
if csLoading in ComponentState then exit; if csLoading in ComponentState then exit;
UpdateSize; UpdateSize;
Invalidate; //Invalidate;
end; end;
procedure TToolbarButton.UpdateSize; procedure TToolbarButton.UpdateSize;
var
AWidth:integer;
begin begin
SetBounds(Left, Top, Width, Height); if csLoading in TToolbarItems(FOwnerItem.Collection).FToolPanel.ComponentState then exit;
if Assigned(TToolbarItems(FOwnerItem.Collection).FToolPanel.FImageList) then
begin
AWidth:=TToolbarItems(FOwnerItem.Collection).FToolPanel.FImageList.Width + 8;
if ShowCaption then
AWidth:= AWidth + Canvas.TextWidth(Caption) + Spacing;
end
else
AWidth:=Canvas.TextWidth(Caption);
SetBounds(Left, Top, AWidth, Height);
Invalidate; Invalidate;
end; end;
@ -857,6 +870,8 @@ begin
if FDefButtonHeight<>AValue then if FDefButtonHeight<>AValue then
begin begin
FDefButtonHeight:=AValue; FDefButtonHeight:=AValue;
if csLoading in ComponentState then exit;
for i:=0 to FToolbarItems.Count - 1 do for i:=0 to FToolbarItems.Count - 1 do
FToolbarItems[i].FButton.UpdateSize; FToolbarItems[i].FButton.UpdateSize;
end; end;
@ -869,6 +884,8 @@ begin
if FDefButtonWidth<>AValue then if FDefButtonWidth<>AValue then
begin begin
FDefButtonWidth:=AValue; FDefButtonWidth:=AValue;
if csLoading in ComponentState then exit;
for i:=0 to FToolbarItems.Count - 1 do for i:=0 to FToolbarItems.Count - 1 do
FToolbarItems[i].FButton.UpdateSize; FToolbarItems[i].FButton.UpdateSize;
end; end;
@ -1118,6 +1135,7 @@ end;
procedure TToolPanel.Loaded; procedure TToolPanel.Loaded;
var var
i, L:integer; i, L:integer;
B:TToolbarItem;
begin begin
{ if csDesigning in ComponentState then { if csDesigning in ComponentState then
begin begin
@ -1127,8 +1145,10 @@ begin
inherited Loaded; inherited Loaded;
for i:=0 to FToolbarItems.Count - 1 do for i:=0 to FToolbarItems.Count - 1 do
begin begin
FToolbarItems[i].UpdateLeftAfterLoad; B:=FToolbarItems[i];
FToolbarItems[i].FButton.Align:=BtnAl2Align[FButtonAllign]; B.UpdateLeftAfterLoad;
B.FButton.Align:=BtnAl2Align[FButtonAllign];
// B.FButton.UpdateSize;
end; end;
ReAlignToolBtn; ReAlignToolBtn;
end; end;
@ -1176,10 +1196,13 @@ end;
procedure TToolPanel.SetBounds(aLeft, aTop, aWidth, aHeight: integer); procedure TToolPanel.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
begin begin
if Assigned(FImageList) then if not (csLoading in ComponentState) then
aHeight:=FImageList.Height+8 + BorderWidth * 2 begin
else if Assigned(FImageList) then
aHeight:=FDefButtonHeight + BorderWidth * 2; aHeight:=FImageList.Height+8 + BorderWidth * 2
else
aHeight:=FDefButtonHeight + BorderWidth * 2;
end;
inherited SetBounds(aLeft, aTop, aWidth, aHeight); inherited SetBounds(aLeft, aTop, aWidth, aHeight);
end; end;
@ -1192,6 +1215,7 @@ begin
{ if Assigned(FButton.Action) then { if Assigned(FButton.Action) then
FButton.Action.UnRegisterChanges(FActionLink);} FButton.Action.UnRegisterChanges(FActionLink);}
FButton.Action:=AValue; FButton.Action:=AValue;
if csLoading in TToolbarItems(Collection).FToolPanel.ComponentState then exit;
FButton.UpdateSize; FButton.UpdateSize;
{ if Assigned(AValue) then { if Assigned(AValue) then
AValue.RegisterChanges(FActionLink);} AValue.RegisterChanges(FActionLink);}
@ -1254,8 +1278,9 @@ begin
if FButton.ShowCaption<>AValue then if FButton.ShowCaption<>AValue then
begin begin
FButton.ShowCaption:=AValue; FButton.ShowCaption:=AValue;
FButton.UpdateSize; if not (csLoading in TToolbarItems(Collection).FToolPanel.ComponentState) then
FButton.Invalidate; FButton.UpdateSize;
// FButton.Invalidate;
end; end;
end; end;
@ -1388,7 +1413,7 @@ begin
FButton.Flat:=tpFlatBtns in TToolbarItems(ACollection).FToolPanel.Options; FButton.Flat:=tpFlatBtns in TToolbarItems(ACollection).FToolPanel.Options;
FButton.Transparent:=tpTransparentBtns in TToolbarItems(ACollection).FToolPanel.Options; FButton.Transparent:=tpTransparentBtns in TToolbarItems(ACollection).FToolPanel.Options;
FButton.ShowCaption:=false; FButton.ShowCaption:=false;
FButton.FAutoSize:=true; FButton.FAutoSize:=false;
FButton.FOwnerItem:=Self; FButton.FOwnerItem:=Self;
FButton.FFullPush:=true; FButton.FFullPush:=true;
// if not (csLoading in TToolbarItems(ACollection).FToolPanel.ComponentState) then // if not (csLoading in TToolbarItems(ACollection).FToolPanel.ComponentState) then