Animations.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Common.h"
  5. #include "Animations.h"
  6. #include "Animations96.h"
  7. #include "Animations120.h"
  8. #include "Animations144.h"
  9. #include "Animations192.h"
  10. #include "GUITools.h"
  11. #include "GUIConfiguration.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "PngImageList"
  15. #ifndef NO_RESOURCES
  16. #pragma resource "*.dfm"
  17. #endif
  18. //---------------------------------------------------------------------------
  19. static TAnimationsModule * AnimationsModule = NULL;
  20. //---------------------------------------------------------------------------
  21. TAnimationsModule * __fastcall GetAnimationsModule()
  22. {
  23. if (AnimationsModule == NULL)
  24. {
  25. HANDLE ResourceModule = GUIConfiguration->ChangeToDefaultResourceModule();
  26. try
  27. {
  28. AnimationsModule = new TAnimationsModule(Application);
  29. }
  30. __finally
  31. {
  32. GUIConfiguration->ChangeResourceModule(ResourceModule);
  33. }
  34. }
  35. return AnimationsModule;
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall ReleaseAnimationsModule()
  39. {
  40. if (AnimationsModule != NULL)
  41. {
  42. SAFE_DESTROY(AnimationsModule);
  43. }
  44. }
  45. //---------------------------------------------------------------------------
  46. __fastcall TAnimationsModule::TAnimationsModule(TComponent * Owner)
  47. : TDataModule(Owner)
  48. {
  49. int PixelsPerInch = Screen->PixelsPerInch;
  50. TDataModule * ScaledModule;
  51. if (PixelsPerInch >= 192)
  52. {
  53. ScaledModule = new TAnimations192Module(Application);
  54. }
  55. else if (PixelsPerInch >= 144)
  56. {
  57. ScaledModule = new TAnimations144Module(Application);
  58. }
  59. else if (PixelsPerInch >= 120)
  60. {
  61. ScaledModule = new TAnimations120Module(Application);
  62. }
  63. else
  64. {
  65. ScaledModule = new TAnimations96Module(Application);
  66. }
  67. try
  68. {
  69. // Not really necessary as we never acccess AnimationImages by name
  70. CopyDataModule(this, ScaledModule);
  71. }
  72. __finally
  73. {
  74. delete ScaledModule;
  75. }
  76. AnimationImages = DebugNotNull(dynamic_cast<TPngImageList *>(FindComponent(AnimationImages->Name)));
  77. }
  78. //---------------------------------------------------------------------------
  79. __fastcall TAnimationsModule::~TAnimationsModule()
  80. {
  81. }
  82. //---------------------------------------------------------------------------