Animations.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Global.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. __fastcall TAnimationsModule::TAnimationsModule(TComponent * Owner)
  39. : TDataModule(Owner)
  40. {
  41. int PixelsPerInch = Screen->PixelsPerInch;
  42. TDataModule * ScaledModule;
  43. if (PixelsPerInch >= 192)
  44. {
  45. ScaledModule = new TAnimations192Module(Application);
  46. }
  47. else if (PixelsPerInch >= 144)
  48. {
  49. ScaledModule = new TAnimations144Module(Application);
  50. }
  51. else if (PixelsPerInch >= 120)
  52. {
  53. ScaledModule = new TAnimations120Module(Application);
  54. }
  55. else
  56. {
  57. ScaledModule = new TAnimations96Module(Application);
  58. }
  59. // Not really necessary as we never acccess AnimationImages by name
  60. CopyDataModule(this, ScaledModule);
  61. AnimationImages = NOT_NULL(dynamic_cast<TPngImageList *>(FindComponent(AnimationImages->Name)));
  62. }
  63. //---------------------------------------------------------------------------