ResizeView.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is Vision.
  13. *
  14. * The Initial Developer of the Original Code is The Vision Team.
  15. * Portions created by The Vision Team are
  16. * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
  17. * Reserved.
  18. *
  19. * Contributor(s): Wade Majors <wade@ezri.org>
  20. * Rene Gollent
  21. * Todd Lair
  22. * Andrew Bazan
  23. * Ted Stodgell <kart@hal-pc.org>
  24. */
  25. #include <Window.h>
  26. #include <Message.h>
  27. #include <assert.h>
  28. #include "ResizeView.h"
  29. #include "VisionBase.h"
  30. #include "Vision.h"
  31. ResizeView::ResizeView (BView *child, BRect frame, const char *title,
  32. uint32 resizeMode, uint32 flags) :
  33. BView (frame, title, resizeMode, flags),
  34. mousePressed (false),
  35. attachedView (child),
  36. cursor (kHorizontalResizeCursor)
  37. {
  38. assert (attachedView != NULL);
  39. SetViewColor (ui_color (B_PANEL_BACKGROUND_COLOR));
  40. }
  41. ResizeView::~ResizeView()
  42. {
  43. }
  44. void
  45. ResizeView::MouseDown (BPoint)
  46. {
  47. SetMouseEventMask (B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS|B_SUSPEND_VIEW_FOCUS|B_NO_POINTER_HISTORY);
  48. mousePressed = true;
  49. vision_app->SetCursor (&cursor);
  50. }
  51. void
  52. ResizeView::MouseUp (BPoint)
  53. {
  54. mousePressed = false;
  55. vision_app->SetCursor (B_HAND_CURSOR);
  56. }
  57. void
  58. ResizeView::MouseMoved (BPoint, uint32, const BMessage *)
  59. {
  60. SetViewCursor (&cursor);
  61. if (mousePressed)
  62. {
  63. BWindow *window (Window ());
  64. BMessage *windowmsg (window->CurrentMessage());
  65. BPoint windowCoord;
  66. windowmsg->FindPoint ("where", &windowCoord);
  67. BMessage msg (M_RESIZE_VIEW);
  68. if (windowCoord.x <= 0.0 || windowCoord.x >= window->Bounds().right)
  69. return;
  70. msg.AddPoint ("loc", windowCoord);
  71. msg.AddPointer ("view", attachedView);
  72. window->PostMessage (&msg);
  73. }
  74. }