Browse Source

Scaling menu items recursively + Scaling menu list width

Source commit: d9c4ae4f5ce7f190bcc2204d4f534bb1c996ff7d
Martin Prikryl 9 năm trước cách đây
mục cha
commit
8355e5a72e
1 tập tin đã thay đổi với 31 bổ sung20 xóa
  1. 31 20
      source/windows/VCLCommon.cpp

+ 31 - 20
source/windows/VCLCommon.cpp

@@ -592,6 +592,36 @@ void __fastcall VerifyControl(TControl * Control)
 }
 #endif
 //---------------------------------------------------------------------------
+static void __fastcall ApplySystemSettingsOnTBItem(TTBCustomToolbar * Toolbar, TTBCustomItem * Item)
+{
+  TTBEditItem * EditItem = dynamic_cast<TTBEditItem *>(Item);
+  if (EditItem != NULL)
+  {
+    EditItem->EditWidth = ScaleByTextHeight(Toolbar, EditItem->EditWidth);
+
+    TTBXComboBoxItem * ComboBoxItem = dynamic_cast<TTBXComboBoxItem *>(EditItem);
+    if (ComboBoxItem != NULL)
+    {
+      ComboBoxItem->MinListWidth =
+        ScaleByTextHeight(Toolbar, ComboBoxItem->MinListWidth);
+      ComboBoxItem->MaxListWidth =
+        ScaleByTextHeight(Toolbar, ComboBoxItem->MaxListWidth);
+    }
+  }
+
+  TTBXCustomList * CustomList = dynamic_cast<TTBXCustomList *>(Item);
+  if (CustomList != NULL)
+  {
+    CustomList->MaxWidth = ScaleByTextHeight(Toolbar, CustomList->MaxWidth);
+    CustomList->MinWidth = ScaleByTextHeight(Toolbar, CustomList->MinWidth);
+  }
+
+  for (int ItemIndex = 0; ItemIndex < Item->Count; ItemIndex++)
+  {
+    ApplySystemSettingsOnTBItem(Toolbar, Item->Items[ItemIndex]);
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall ApplySystemSettingsOnControl(TControl * Control)
 {
   #ifdef _DEBUG
@@ -627,26 +657,7 @@ void __fastcall ApplySystemSettingsOnControl(TControl * Control)
   TTBCustomToolbar * Toolbar = dynamic_cast<TTBCustomToolbar *>(Control);
   if (Toolbar != NULL)
   {
-    TTBCustomItem * Items = Toolbar->Items;
-    for (int ItemIndex = 0; ItemIndex < Items->Count; ItemIndex++)
-    {
-      // We should recurse
-      TTBCustomItem * Item = Items->Items[ItemIndex];
-      TTBEditItem * EditItem = dynamic_cast<TTBEditItem *>(Item);
-      if (EditItem != NULL)
-      {
-        EditItem->EditWidth = ScaleByTextHeight(Toolbar, EditItem->EditWidth);
-
-        TTBXComboBoxItem * ComboBoxItem = dynamic_cast<TTBXComboBoxItem *>(EditItem);
-        if (ComboBoxItem != NULL)
-        {
-          ComboBoxItem->MinListWidth =
-            ScaleByTextHeight(Toolbar, ComboBoxItem->MinListWidth);
-          ComboBoxItem->MaxListWidth =
-            ScaleByTextHeight(Toolbar, ComboBoxItem->MaxListWidth);
-        }
-      }
-    }
+    ApplySystemSettingsOnTBItem(Toolbar, Toolbar->Items);
   }
 
   TCustomListView * ListView = dynamic_cast<TCustomListView *>(Control);