animate.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include <precomp.h>
  2. #include <wasabicfg.h>
  3. #include "animate.h"
  4. #include <api/config/items/cfgitem.h>
  5. //---------------------------------------------------------------------------
  6. void AnimatedRects::draw(const RECT *source, const RECT *dest, int steps)
  7. {
  8. #ifdef WASABI_COMPILE_CONFIG
  9. // {280876CF-48C0-40bc-8E86-73CE6BB462E5}
  10. const GUID options_guid =
  11. { 0x280876cf, 0x48c0, 0x40bc, { 0x8e, 0x86, 0x73, 0xce, 0x6b, 0xb4, 0x62, 0xe5 } };
  12. if (!_intVal(WASABI_API_CONFIG->config_getCfgItemByGuid(options_guid), L"Animated rects")) return;
  13. #else
  14. if (!WASABI_WNDMGR_ANIMATEDRECTS) return;
  15. #endif
  16. //FG> Not anymore, old code, old bugs
  17. //BU you're so cool, Francis
  18. //FG> thank you, you're not too bad either :)
  19. int sizex=source->right-source->left-(dest->right-dest->left);
  20. int sizey=source->bottom-source->top-(dest->bottom-dest->top);
  21. int diffx=source->left-dest->left;
  22. int diffy=(source->top)-dest->top;
  23. #ifdef WIN32
  24. HDC dc;
  25. dc=GetDC(0);
  26. HBRUSH brush = CreateSolidBrush(0xFFFFFF);
  27. HPEN pen = CreatePen(PS_SOLID,0,0xFFFFFF);
  28. HBRUSH obrush = (HBRUSH)SelectObject(dc, brush);
  29. HPEN open = (HPEN)SelectObject(dc, pen);
  30. int oldrop = SetROP2(dc,R2_XORPEN);
  31. #endif
  32. #ifdef LINUX
  33. HDC dc = (HDC)MALLOC( sizeof( hdc_typ ) );
  34. XGCValues gcv;
  35. gcv.foreground = 0xffffff;
  36. gcv.function = GXxor;
  37. gcv.subwindow_mode = IncludeInferiors;
  38. dc->gc = XCreateGC( Linux::getDisplay(), Linux::RootWin(), GCForeground | GCFunction | GCSubwindowMode, &gcv );
  39. #endif
  40. //PORTME
  41. for(int i=0;i<steps;i++) {
  42. int x=dest->left+diffx-((diffx*i)/steps);
  43. int y=dest->top+diffy-((diffy*i)/steps);
  44. int maxx=(source->right-source->left)-((sizex*i)/steps);
  45. int maxy=(source->bottom-source->top)-((sizey*i)/steps);
  46. #ifdef WIN32
  47. int p1x=x,p1y=y;
  48. int p2x=x+maxx,p2y=y;
  49. int p3x=x+maxx,p3y=y+maxy;
  50. int p4x=x,p4y=y+maxy;
  51. MoveToEx(dc,p1x,p1y,NULL);
  52. LineTo(dc,p2x,p2y);
  53. LineTo(dc,p3x,p3y);
  54. LineTo(dc,p4x,p4y);
  55. LineTo(dc,p1x,p1y);
  56. #endif
  57. #ifdef LINUX
  58. XDrawRectangle( Linux::getDisplay(), Linux::RootWin(), dc->gc,
  59. x, y, maxx, maxy );
  60. #endif
  61. //PORTME
  62. Wasabi::Std::usleep(5);
  63. #ifdef WIN32
  64. MoveToEx(dc,p1x,p1y,NULL);
  65. LineTo(dc,p2x,p2y);
  66. LineTo(dc,p3x,p3y);
  67. LineTo(dc,p4x,p4y);
  68. LineTo(dc,p1x,p1y);
  69. #endif
  70. #ifdef LINUX
  71. XDrawRectangle( Linux::getDisplay(), Linux::RootWin(), dc->gc,
  72. x, y, maxx, maxy );
  73. #endif
  74. //PORTME
  75. }
  76. #ifdef WIN32
  77. SetROP2(dc, oldrop);
  78. SelectObject(dc, open);
  79. SelectObject(dc, obrush);
  80. DeleteObject(brush);
  81. DeleteObject(pen);
  82. ReleaseDC(0,dc);
  83. #endif
  84. #ifdef LINUX
  85. XFreeGC( Linux::getDisplay(), dc->gc );
  86. FREE( dc );
  87. #endif
  88. //PORTME
  89. }