1 /* 2 * Copyright 2001-2010, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Adi Oanca <adioanca@gmail.com> 8 * Stephan Aßmus <superstippi@gmx.de> 9 * Axel Dörfler <axeld@pinc-software.de> 10 * Brecht Machiels <brecht@mos6581.org> 11 * Clemens Zeidler <haiku@clemens-zeidler.de> 12 * Ingo Weinhold <ingo_weinhold@gmx.de> 13 */ 14 #ifndef DEFAULT_WINDOW_BEHAVIOUR_H 15 #define DEFAULT_WINDOW_BEHAVIOUR_H 16 17 18 #include "WindowBehaviour.h" 19 20 #include "Decorator.h" 21 #include "MagneticBorder.h" 22 #include "ServerCursor.h" 23 24 25 class Desktop; 26 class Window; 27 28 29 class DefaultWindowBehaviour : public WindowBehaviour { 30 public: 31 DefaultWindowBehaviour(Window* window); 32 virtual ~DefaultWindowBehaviour(); 33 34 virtual bool MouseDown(BMessage* message, BPoint where, 35 int32 lastHitRegion, int32& clickCount, 36 int32& _hitRegion); 37 virtual void MouseUp(BMessage* message, BPoint where); 38 virtual void MouseMoved(BMessage *message, BPoint where, 39 bool isFake); 40 41 virtual void ModifiersChanged(int32 modifiers); 42 43 protected: 44 virtual bool AlterDeltaForSnap(Window* window, BPoint& delta, 45 bigtime_t now); 46 private: 47 enum Action { 48 ACTION_NONE, 49 ACTION_ZOOM, 50 ACTION_CLOSE, 51 ACTION_MINIMIZE, 52 ACTION_TAB, 53 ACTION_DRAG, 54 ACTION_SLIDE_TAB, 55 ACTION_RESIZE, 56 ACTION_RESIZE_BORDER 57 }; 58 59 enum { 60 // 1 for the "natural" resize border, -1 for the opposite, so 61 // multiplying the movement delta by that value results in the 62 // size change. 63 LEFT = -1, 64 TOP = -1, 65 NONE = 0, 66 RIGHT = 1, 67 BOTTOM = 1 68 }; 69 70 struct State; 71 struct MouseTrackingState; 72 struct DragState; 73 struct ResizeState; 74 struct SlideTabState; 75 struct ResizeBorderState; 76 struct DecoratorButtonState; 77 struct ManageWindowState; 78 79 // to keep gcc 2 happy 80 friend struct State; 81 friend struct MouseTrackingState; 82 friend struct DragState; 83 friend struct ResizeState; 84 friend struct SlideTabState; 85 friend struct ResizeBorderState; 86 friend struct DecoratorButtonState; 87 friend struct ManageWindowState; 88 89 private: 90 bool _IsControlModifier(int32 modifiers) const; 91 bool _IsWindowModifier(int32 modifiers) const; 92 Decorator::Region _RegionFor(const BMessage* message, 93 int32& tab) const; 94 95 ServerCursor* _ResizeCursorFor(int8 horizontal, 96 int8 vertical); 97 98 void _SetMoveCursor(); 99 void _SetNotAllowedCursor(); 100 void _SetResizeCursor(int8 horizontal, 101 int8 vertical); 102 void _SetBorderResizeCursor(BPoint where); 103 void _ResetCursor(); 104 105 void _UpdateResizeArrows(BPoint where); 106 static void _ComputeResizeDirection(float x, float y, 107 int8& _horizontal, int8& _vertical); 108 109 void _NextState(State* state); 110 111 protected: 112 Window* fWindow; 113 Desktop* fDesktop; 114 State* fState; 115 int32 fLastModifiers; 116 117 MagneticBorder fMagneticBorder; 118 }; 119 120 121 #endif // DEFAULT_WINDOW_BEHAVIOUR_H 122