|
@@ -7,7 +7,9 @@
|
|
|
#include "Glyphs120.h"
|
|
|
#include "Glyphs144.h"
|
|
|
#include "Glyphs192.h"
|
|
|
+#include "Common.h"
|
|
|
#include "GUITools.h"
|
|
|
+#include "GUIConfiguration.h"
|
|
|
//---------------------------------------------------------------------------
|
|
|
#pragma package(smart_init)
|
|
|
#pragma link "PngImageList"
|
|
@@ -19,6 +21,7 @@ __fastcall TGlyphsModule::TGlyphsModule(TComponent* Owner)
|
|
|
: TDataModule(Owner)
|
|
|
{
|
|
|
FPixelsPerInch = USER_DEFAULT_SCREEN_DPI;
|
|
|
+ FLargerToolbar = 0;
|
|
|
SetPixelsPerInch(Screen->PixelsPerInch);
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
@@ -28,45 +31,77 @@ __fastcall TGlyphsModule::TGlyphsModule()
|
|
|
{
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TGlyphsModule::SetPixelsPerInch(int PixelsPerInch)
|
|
|
+void TGlyphsModule::SetPixelsPerInch(int PixelsPerInch)
|
|
|
{
|
|
|
- PixelsPerInch = NormalizePixelsPerInch(PixelsPerInch);
|
|
|
- if (FPixelsPerInch != PixelsPerInch)
|
|
|
+ int BasePixelsPerInch = NormalizePixelsPerInch(PixelsPerInch);
|
|
|
+ if (FBasePixelsPerInch != BasePixelsPerInch)
|
|
|
{
|
|
|
- std::unique_ptr<TDataModule> ScaledModule;
|
|
|
- if (PixelsPerInch >= 192)
|
|
|
- {
|
|
|
- ScaledModule.reset(new TGlyphs192Module(Application));
|
|
|
- }
|
|
|
- else if (PixelsPerInch >= 144)
|
|
|
- {
|
|
|
- ScaledModule.reset(new TGlyphs144Module(Application));
|
|
|
- }
|
|
|
- else if (PixelsPerInch >= 120)
|
|
|
- {
|
|
|
- ScaledModule.reset(new TGlyphs120Module(Application));
|
|
|
- }
|
|
|
- else
|
|
|
+ FBasePixelsPerInch = BasePixelsPerInch;
|
|
|
+ UpdatePixelsPerInch();
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TGlyphsModule::SetLargerToolbar(int LargerToolbar)
|
|
|
+{
|
|
|
+ if (FLargerToolbar != LargerToolbar)
|
|
|
+ {
|
|
|
+ FLargerToolbar = LargerToolbar;
|
|
|
+ UpdatePixelsPerInch();
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+bool TGlyphsModule::GetLargerToolbarPossible()
|
|
|
+{
|
|
|
+ return (LargerPixelsPerInch(FBasePixelsPerInch, 1) > FBasePixelsPerInch);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void TGlyphsModule::UpdatePixelsPerInch()
|
|
|
+{
|
|
|
+ HANDLE ResourceModule = GUIConfiguration->ChangeToDefaultResourceModule();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ int PixelsPerInch = LargerPixelsPerInch(FBasePixelsPerInch, FLargerToolbar);
|
|
|
+ if (FPixelsPerInch != PixelsPerInch)
|
|
|
{
|
|
|
- // Do not have a separate 96 DPI module, as this module needs to
|
|
|
- // have the images loaded as they are used on design time.
|
|
|
- // Performance impact of loading 96 DPI images when they are not needed is not that big.
|
|
|
- ScaledModule.reset(new TGlyphsModule());
|
|
|
- }
|
|
|
+ std::unique_ptr<TDataModule> ScaledModule;
|
|
|
+ if (PixelsPerInch >= 192)
|
|
|
+ {
|
|
|
+ ScaledModule.reset(new TGlyphs192Module(Application));
|
|
|
+ }
|
|
|
+ else if (PixelsPerInch >= 144)
|
|
|
+ {
|
|
|
+ ScaledModule.reset(new TGlyphs144Module(Application));
|
|
|
+ }
|
|
|
+ else if (PixelsPerInch >= 120)
|
|
|
+ {
|
|
|
+ ScaledModule.reset(new TGlyphs120Module(Application));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Do not have a separate 96 DPI module, as this module needs to
|
|
|
+ // have the images loaded as they are used on design time.
|
|
|
+ // Performance impact of loading 96 DPI images when they are not needed is not that big.
|
|
|
+ ScaledModule.reset(new TGlyphsModule());
|
|
|
+ }
|
|
|
|
|
|
- if (ScaledModule.get() != NULL)
|
|
|
- {
|
|
|
- for (int Index = 0; Index < ComponentCount; Index++)
|
|
|
+ if (ScaledModule.get() != NULL)
|
|
|
{
|
|
|
- TComponent * TargetComponent = Components[Index];
|
|
|
- TComponent * SourceComponent = ScaledModule->FindComponent(TargetComponent->Name);
|
|
|
- if (DebugAlwaysTrue(SourceComponent != NULL))
|
|
|
+ for (int Index = 0; Index < ComponentCount; Index++)
|
|
|
{
|
|
|
- TargetComponent->Assign(SourceComponent);
|
|
|
+ TComponent * TargetComponent = Components[Index];
|
|
|
+ TComponent * SourceComponent = ScaledModule->FindComponent(TargetComponent->Name);
|
|
|
+ if (DebugAlwaysTrue(SourceComponent != NULL))
|
|
|
+ {
|
|
|
+ TargetComponent->Assign(SourceComponent);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- FPixelsPerInch = PixelsPerInch;
|
|
|
+ FPixelsPerInch = PixelsPerInch;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ __finally
|
|
|
+ {
|
|
|
+ GUIConfiguration->ChangeResourceModule(ResourceModule);
|
|
|
}
|
|
|
}
|