Resizer.cpp
上传用户:lusi_8715
上传日期:2007-01-08
资源大小:199k
文件大小:4k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /**************************************************************************************
  2.  *                                                                                    *
  3.  * This application contains code from OpenDivX and is released as a "Larger Work"    *
  4.  * under that license. Consistant with that license, this application is released     *
  5.  * under the GNU General Public License.                                              *
  6.  *                                                                                    *
  7.  * The OpenDivX license can be found at: http://www.projectmayo.com/opendivx/docs.php *
  8.  * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html                      *
  9.  *                                                                                    *
  10.  * Copyright (c) 2001 - Project Mayo                                                  *
  11.  *                                                                                    *
  12.  * Authors: Damien Chavarria <adrc at projectmayo.com>                                *
  13.  *                                                                                    *
  14.  **************************************************************************************/
  15. #include "Resizer.h"
  16. /*
  17.  * The class used to draw
  18.  * the resize frame...
  19.  *
  20.  */
  21. Resizer::Resizer() {
  22. this->lastPt.x = -1;
  23. this->lastPt.y = -1;
  24. }
  25. Resizer::~Resizer() {
  26. }
  27. void Resizer::Start(POINT *pt) {
  28. this->lastPt.x = -1;
  29. this->lastPt.y = -1;
  30. }
  31. void Resizer::Draw(HWND hwnd, POINT *pt1) {
  32. POINT p, pt;
  33. RECT  rect;
  34. HPEN  pen, oldPen;
  35. HDC   dc;
  36. int   oldMode;
  37. pt.x = pt1->x;
  38. pt.y = pt1->y;
  39. GetClientRect(hwnd, &rect);
  40. p.x = rect.left;
  41. p.y = rect.top;
  42. ClientToScreen(hwnd, &p);
  43. dc = GetDC(NULL);
  44. pen    = CreatePen(PS_SOLID, 2, 0);
  45. oldPen = (HPEN) SelectObject(dc, pen);
  46. oldMode = SetROP2(dc, R2_NOT);
  47. /*
  48.  * Draw back if needed
  49.  */
  50. if(this->lastPt.x != 1 && this->lastPt.y != -1) {
  51. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  52. LineTo(dc, this->lastPt.x, p.y + 2);
  53. LineTo(dc, this->lastPt.x, this->lastPt.y);
  54. LineTo(dc, p.x + 2, this->lastPt.y);
  55. LineTo(dc, p.x + 2, p.y + 2);
  56. }
  57. if(pt1->x > 32768 || pt1->y > 32768) {
  58. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  59. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, p.y + 2);
  60. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, p.y + DEFAULT_SKIN_HEIGHT);
  61. LineTo(dc, p.x + 2, p.y + DEFAULT_SKIN_HEIGHT);
  62. LineTo(dc, p.x + 2, p.y + 2);
  63. this->lastPt.x = p.x + DEFAULT_SKIN_WIDTH;
  64. this->lastPt.y = p.y + DEFAULT_SKIN_HEIGHT;
  65. goto end;
  66. }
  67. ClientToScreen(hwnd, &pt);
  68. /*
  69.  * Now check where we are
  70.  */
  71. if((pt.x - p.x) >= DEFAULT_SKIN_WIDTH && (pt.y - p.y) >= DEFAULT_SKIN_HEIGHT) {
  72. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  73. LineTo(dc, pt.x + 5, p.y + 2);
  74. LineTo(dc, pt.x + 5, pt.y + 5);
  75. LineTo(dc, p.x + 2,  pt.y + 5);
  76. LineTo(dc, p.x + 2, p.y + 2);
  77. this->lastPt.x = pt.x + 5;
  78. this->lastPt.y = pt.y + 5;
  79. }
  80. else {
  81. if((pt.x - p.x) >= DEFAULT_SKIN_WIDTH) {
  82. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  83. LineTo(dc, pt.x + 5, p.y + 2);
  84. LineTo(dc, pt.x + 5, p.y + DEFAULT_SKIN_HEIGHT);
  85. LineTo(dc, p.x + 2,  p.y + DEFAULT_SKIN_HEIGHT);
  86. LineTo(dc, p.x + 2, p.y + 2);
  87. this->lastPt.x = pt.x + 5;
  88. this->lastPt.y = p.y + DEFAULT_SKIN_HEIGHT;
  89. }
  90. else {
  91. if((pt.y - p.y) >= DEFAULT_SKIN_HEIGHT) {
  92. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  93. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, p.y + 2);
  94. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, pt.y + 5);
  95. LineTo(dc, p.x + 2, pt.y + 5);
  96. LineTo(dc, p.x + 2, p.y + 2);
  97. this->lastPt.x = p.x + DEFAULT_SKIN_WIDTH;
  98. this->lastPt.y = pt.y + 5;
  99. }
  100. else {
  101. MoveToEx(dc, p.x + 2, p.y + 2, NULL);
  102. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, p.y + 2);
  103. LineTo(dc, p.x + DEFAULT_SKIN_WIDTH, p.y + DEFAULT_SKIN_HEIGHT);
  104. LineTo(dc, p.x + 2, p.y + DEFAULT_SKIN_HEIGHT);
  105. LineTo(dc, p.x + 2, p.y + 2);
  106. this->lastPt.x = p.x + DEFAULT_SKIN_WIDTH;
  107. this->lastPt.y = p.y + DEFAULT_SKIN_HEIGHT;
  108. }
  109. }
  110. }
  111. end:
  112. /*
  113.  * And puts everything back
  114.  */
  115. SetROP2(dc, oldMode);
  116. SelectObject(dc, oldPen);
  117. DeleteObject(pen);
  118. ReleaseDC(NULL, dc);
  119. }
  120. void Resizer::Stop() {
  121. }