Browse Source

Removing AnimationsModule stub

Source commit: 4c0e0f48ca2dcffaf2ccb5830797da4932b73bd2
Martin Prikryl 8 years ago
parent
commit
4ed697a8eb

+ 0 - 8
source/ScpResources.cbproj

@@ -63,14 +63,6 @@
 		<TASM_Debugging>None</TASM_Debugging>
 	</PropertyGroup>
 	<ItemGroup>
-		<CppCompile Include="forms\Animations.cpp">
-			<Form>AnimationsModule</Form>
-			<FormType>dfm</FormType>
-			<DesignClass>TDataModule</DesignClass>
-			<DependentOn>forms\Animations.h</DependentOn>
-			<BuildOrder>1</BuildOrder>
-		</CppCompile>
-		<FormResources Include="forms\Animations.dfm"/>
 		<CppCompile Include="forms\Animations120.cpp">
 			<Form>Animations120Module</Form>
 			<FormType>dfm</FormType>

+ 0 - 85
source/forms/Animations.cpp

@@ -1,85 +0,0 @@
-//---------------------------------------------------------------------------
-#include <vcl.h>
-#pragma hdrstop
-
-#include "Common.h"
-#include "Animations.h"
-#include "Animations96.h"
-#include "Animations120.h"
-#include "Animations144.h"
-#include "Animations192.h"
-#include "GUITools.h"
-#include "GUIConfiguration.h"
-//---------------------------------------------------------------------------
-#pragma package(smart_init)
-#pragma link "PngImageList"
-#ifndef NO_RESOURCES
-#pragma resource "*.dfm"
-#endif
-//---------------------------------------------------------------------------
-static TAnimationsModule * AnimationsModule = NULL;
-//---------------------------------------------------------------------------
-TAnimationsModule * __fastcall GetAnimationsModule()
-{
-  if (AnimationsModule == NULL)
-  {
-    HANDLE ResourceModule = GUIConfiguration->ChangeToDefaultResourceModule();
-    try
-    {
-      AnimationsModule = new TAnimationsModule(Application);
-    }
-    __finally
-    {
-      GUIConfiguration->ChangeResourceModule(ResourceModule);
-    }
-  }
-  return AnimationsModule;
-}
-//---------------------------------------------------------------------------
-void __fastcall ReleaseAnimationsModule()
-{
-  if (AnimationsModule != NULL)
-  {
-    SAFE_DESTROY(AnimationsModule);
-  }
-}
-//---------------------------------------------------------------------------
-__fastcall TAnimationsModule::TAnimationsModule(TComponent * Owner)
-  : TDataModule(Owner)
-{
-  int PixelsPerInch = Screen->PixelsPerInch;
-  TDataModule * ScaledModule;
-  if (PixelsPerInch >= 192)
-  {
-    ScaledModule = new TAnimations192Module(Application);
-  }
-  else if (PixelsPerInch >= 144)
-  {
-    ScaledModule = new TAnimations144Module(Application);
-  }
-  else if (PixelsPerInch >= 120)
-  {
-    ScaledModule = new TAnimations120Module(Application);
-  }
-  else
-  {
-    ScaledModule = new TAnimations96Module(Application);
-  }
-
-  try
-  {
-    // Not really necessary as we never acccess AnimationImages by name
-    CopyDataModule(this, ScaledModule);
-  }
-  __finally
-  {
-    delete ScaledModule;
-  }
-
-  AnimationImages = DebugNotNull(dynamic_cast<TPngImageList *>(FindComponent(AnimationImages->Name)));
-}
-//---------------------------------------------------------------------------
-__fastcall TAnimationsModule::~TAnimationsModule()
-{
-}
-//---------------------------------------------------------------------------

+ 0 - 12
source/forms/Animations.dfm

@@ -1,12 +0,0 @@
-object AnimationsModule: TAnimationsModule
-  OldCreateOrder = False
-  Height = 150
-  Width = 215
-  object AnimationImages: TPngImageList
-    Height = 32
-    Width = 32
-    PngImages = <>
-    Left = 40
-    Top = 16
-  end
-end

+ 0 - 20
source/forms/Animations.h

@@ -1,20 +0,0 @@
-//---------------------------------------------------------------------------
-#ifndef AnimationsH
-#define AnimationsH
-//---------------------------------------------------------------------------
-#include <System.Classes.hpp>
-#include "PngImageList.hpp"
-#include <Vcl.Controls.hpp>
-#include <Vcl.ImgList.hpp>
-//---------------------------------------------------------------------------
-class TAnimationsModule : public TDataModule
-{
-__published:
-  TPngImageList *AnimationImages;
-
-public:
-  __fastcall TAnimationsModule(TComponent * Owner);
-  virtual __fastcall ~TAnimationsModule();
-};
-//---------------------------------------------------------------------------
-#endif

+ 52 - 2
source/windows/GUITools.cpp

@@ -19,10 +19,14 @@
 #include <StrUtils.hpp>
 #include <limits>
 #include <Glyphs.h>
-#include <Animations.h>
 #include <PasTools.hpp>
 #include <VCLCommon.h>
 #include <Vcl.ScreenTips.hpp>
+
+#include "Animations96.h"
+#include "Animations120.h"
+#include "Animations144.h"
+#include "Animations192.h"
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
@@ -910,6 +914,52 @@ bool __fastcall TLocalCustomCommand::IsFileCommand(const UnicodeString & Command
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
+static TDataModule * AnimationsModule = NULL;
+static TPngImageList * AnimationsImages = NULL;
+//---------------------------------------------------------------------------
+TPngImageList * __fastcall GetAnimationsImages()
+{
+  if (AnimationsModule == NULL)
+  {
+    HANDLE ResourceModule = GUIConfiguration->ChangeToDefaultResourceModule();
+    try
+    {
+      int PixelsPerInch = Screen->PixelsPerInch;
+      if (PixelsPerInch >= 192)
+      {
+        AnimationsModule = new TAnimations192Module(Application);
+      }
+      else if (PixelsPerInch >= 144)
+      {
+        AnimationsModule = new TAnimations144Module(Application);
+      }
+      else if (PixelsPerInch >= 120)
+      {
+        AnimationsModule = new TAnimations120Module(Application);
+      }
+      else
+      {
+        AnimationsModule = new TAnimations96Module(Application);
+      }
+
+      AnimationsImages = DebugNotNull(dynamic_cast<TPngImageList *>(AnimationsModule->FindComponent(L"AnimationImages")));
+    }
+    __finally
+    {
+      GUIConfiguration->ChangeResourceModule(ResourceModule);
+    }
+  }
+  return AnimationsImages;
+}
+//---------------------------------------------------------------------------
+void __fastcall ReleaseAnimationsModule()
+{
+  if (AnimationsModule != NULL)
+  {
+    SAFE_DESTROY(AnimationsModule);
+  }
+}
+//---------------------------------------------------------------------------
 __fastcall TFrameAnimation::TFrameAnimation()
 {
   FFirstFrame = -1;
@@ -922,7 +972,7 @@ void __fastcall TFrameAnimation::Init(TPaintBox * PaintBox, const UnicodeString
 //---------------------------------------------------------------------------
 void __fastcall TFrameAnimation::DoInit(TPaintBox * PaintBox, TPngImageList * ImageList, const UnicodeString & Name, bool Null)
 {
-  FImageList = (ImageList != NULL) ? ImageList : GetAnimationsModule()->AnimationImages;
+  FImageList = (ImageList != NULL) ? ImageList : GetAnimationsImages();
   FFirstFrame = -1;
   FFirstLoopFrame = -1;
   DebugAssert((PaintBox->OnPaint == NULL) || (PaintBox->OnPaint == PaintBoxPaint));

+ 3 - 0
source/windows/GUITools.h

@@ -81,6 +81,9 @@ namespace Pngimagelist
 }
 using namespace Pngimagelist;
 //---------------------------------------------------------------------------
+TPngImageList * __fastcall GetAnimationsImages();
+void __fastcall ReleaseAnimationsModule();
+//---------------------------------------------------------------------------
 class TFrameAnimation
 {
 public:

+ 0 - 4
source/windows/WinInterface.h

@@ -484,10 +484,6 @@ void __fastcall SetShortCutCombo(TComboBox * ComboBox, TShortCut Value);
 TShortCut __fastcall GetShortCutCombo(TComboBox * ComboBox);
 bool __fastcall IsCustomShortCut(TShortCut ShortCut);
 
-class TAnimationsModule;
-TAnimationsModule * __fastcall GetAnimationsModule();
-void __fastcall ReleaseAnimationsModule();
-
 #ifdef _DEBUG
 void __fastcall ForceTracing();
 #endif