|
@@ -687,63 +687,73 @@ int TThemePageControl::TotalTabsWidth()
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
void TThemePageControl::UpdateTabsCaptionTruncation()
|
|
|
{
|
|
|
- FSessionTabShrink = 0;
|
|
|
- for (int Index = 0; Index < PageCount; Index++)
|
|
|
- {
|
|
|
- Pages[Index]->UpdateCaption();
|
|
|
- }
|
|
|
-
|
|
|
- int TabsWidth = TotalTabsWidth();
|
|
|
- int MaxWidth = ClientWidth - ScaleByTextHeight(this, 8); // arbitrary margin to avoid left/right buttons flicker
|
|
|
- if (TabsWidth > MaxWidth)
|
|
|
+ DisableAlign();
|
|
|
+ Tabs->BeginUpdate();
|
|
|
+ try
|
|
|
{
|
|
|
- int NeedWidth = (TabsWidth - MaxWidth);
|
|
|
- int MaxLen = 0;
|
|
|
- int CaptionsWidth = 0;
|
|
|
+ FSessionTabShrink = 0;
|
|
|
for (int Index = 0; Index < PageCount; Index++)
|
|
|
{
|
|
|
- UnicodeString TabCaption = Pages[Index]->BaseCaption;
|
|
|
- MaxLen = std::max(MaxLen, TabCaption.Length());
|
|
|
- CaptionsWidth += Canvas->TextWidth(TabCaption);
|
|
|
+ Pages[Index]->UpdateCaption();
|
|
|
}
|
|
|
|
|
|
- bool Repeat;
|
|
|
- do
|
|
|
+ int TabsWidth = TotalTabsWidth();
|
|
|
+ int MaxWidth = ClientWidth - ScaleByTextHeight(this, 8); // arbitrary margin to avoid left/right buttons flicker
|
|
|
+ if (TabsWidth > MaxWidth)
|
|
|
{
|
|
|
- int NewShrink;
|
|
|
- if (FSessionTabShrink == 0)
|
|
|
- {
|
|
|
- NewShrink = MaxLen; // remove only new tab caption
|
|
|
- }
|
|
|
- else
|
|
|
+ int NeedWidth = (TabsWidth - MaxWidth);
|
|
|
+ int MaxLen = 0;
|
|
|
+ int CaptionsWidth = 0;
|
|
|
+ for (int Index = 0; Index < PageCount; Index++)
|
|
|
{
|
|
|
- NewShrink = FSessionTabShrink - 1;
|
|
|
+ UnicodeString TabCaption = Pages[Index]->BaseCaption;
|
|
|
+ MaxLen = std::max(MaxLen, TabCaption.Length());
|
|
|
+ CaptionsWidth += Canvas->TextWidth(TabCaption);
|
|
|
}
|
|
|
|
|
|
- if (NewShrink < 1)
|
|
|
- {
|
|
|
- Repeat = false;
|
|
|
- }
|
|
|
- else
|
|
|
+ bool Repeat;
|
|
|
+ do
|
|
|
{
|
|
|
- FSessionTabShrink = NewShrink;
|
|
|
- int NewCaptionsWidth = 0;
|
|
|
- for (int Index = 0; Index < PageCount; Index++)
|
|
|
+ int NewShrink;
|
|
|
+ if (FSessionTabShrink == 0)
|
|
|
+ {
|
|
|
+ NewShrink = MaxLen; // remove only new tab caption
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NewShrink = FSessionTabShrink - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (NewShrink < 1)
|
|
|
+ {
|
|
|
+ Repeat = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- UnicodeString TabCaption = Pages[Index]->TruncatedCaption();
|
|
|
- NewCaptionsWidth += Canvas->TextWidth(TabCaption);
|
|
|
+ FSessionTabShrink = NewShrink;
|
|
|
+ int NewCaptionsWidth = 0;
|
|
|
+ for (int Index = 0; Index < PageCount; Index++)
|
|
|
+ {
|
|
|
+ UnicodeString TabCaption = Pages[Index]->TruncatedCaption();
|
|
|
+ NewCaptionsWidth += Canvas->TextWidth(TabCaption);
|
|
|
+ }
|
|
|
+ int GainedWidth = (CaptionsWidth - NewCaptionsWidth);
|
|
|
+ Repeat = (GainedWidth < NeedWidth);
|
|
|
}
|
|
|
- int GainedWidth = (CaptionsWidth - NewCaptionsWidth);
|
|
|
- Repeat = (GainedWidth < NeedWidth);
|
|
|
}
|
|
|
- }
|
|
|
- while (Repeat);
|
|
|
+ while (Repeat);
|
|
|
|
|
|
- for (int Index = 0; Index < PageCount; Index++)
|
|
|
- {
|
|
|
- Pages[Index]->UpdateCaption();
|
|
|
+ for (int Index = 0; Index < PageCount; Index++)
|
|
|
+ {
|
|
|
+ Pages[Index]->UpdateCaption();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ __finally
|
|
|
+ {
|
|
|
+ Tabs->BeginUpdate();
|
|
|
+ EnableAlign();
|
|
|
+ }
|
|
|
}
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
#ifdef _DEBUG
|