|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 #ifndef nsResizerFrame_h___ |
|
6 #define nsResizerFrame_h___ |
|
7 |
|
8 #include "mozilla/Attributes.h" |
|
9 #include "mozilla/EventForwards.h" |
|
10 #include "nsTitleBarFrame.h" |
|
11 |
|
12 class nsIBaseWindow; |
|
13 class nsMenuPopupFrame; |
|
14 |
|
15 class nsResizerFrame : public nsTitleBarFrame |
|
16 { |
|
17 protected: |
|
18 struct Direction { |
|
19 int8_t mHorizontal; |
|
20 int8_t mVertical; |
|
21 }; |
|
22 |
|
23 public: |
|
24 NS_DECL_FRAMEARENA_HELPERS |
|
25 |
|
26 friend nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
27 |
|
28 nsResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
29 |
|
30 virtual nsresult HandleEvent(nsPresContext* aPresContext, |
|
31 mozilla::WidgetGUIEvent* aEvent, |
|
32 nsEventStatus* aEventStatus) MOZ_OVERRIDE; |
|
33 |
|
34 virtual void MouseClicked(nsPresContext* aPresContext, |
|
35 mozilla::WidgetMouseEvent* aEvent) MOZ_OVERRIDE; |
|
36 |
|
37 protected: |
|
38 nsIContent* GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWindow); |
|
39 |
|
40 Direction GetDirection(); |
|
41 |
|
42 /** |
|
43 * Adjust the window position and size in a direction according to the mouse |
|
44 * movement and the resizer direction. The minimum and maximum size is used |
|
45 * to constrain the size. |
|
46 * |
|
47 * @param aPos left or top position |
|
48 * @param aSize width or height |
|
49 * @param aMinSize minimum width or height |
|
50 * @param aMacSize maximum width or height |
|
51 * @param aMovement the amount the mouse was moved |
|
52 * @param aResizerDirection resizer direction returned by GetDirection |
|
53 */ |
|
54 static void AdjustDimensions(int32_t* aPos, int32_t* aSize, |
|
55 int32_t aMinSize, int32_t aMaxSize, |
|
56 int32_t aMovement, int8_t aResizerDirection); |
|
57 |
|
58 struct SizeInfo { |
|
59 nsString width, height; |
|
60 }; |
|
61 static void SizeInfoDtorFunc(void *aObject, nsIAtom *aPropertyName, |
|
62 void *aPropertyValue, void *aData); |
|
63 static void ResizeContent(nsIContent* aContent, const Direction& aDirection, |
|
64 const SizeInfo& aSizeInfo, SizeInfo* aOriginalSizeInfo); |
|
65 static void MaybePersistOriginalSize(nsIContent* aContent, const SizeInfo& aSizeInfo); |
|
66 static void RestoreOriginalSize(nsIContent* aContent); |
|
67 |
|
68 protected: |
|
69 nsIntRect mMouseDownRect; |
|
70 nsIntPoint mMouseDownPoint; |
|
71 }; // class nsResizerFrame |
|
72 |
|
73 #endif /* nsResizerFrame_h___ */ |