Line data Source code
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 :
14 0 : class nsResizerFrame final : public nsTitleBarFrame
15 : {
16 : protected:
17 : struct Direction {
18 : int8_t mHorizontal;
19 : int8_t mVertical;
20 : };
21 :
22 : public:
23 0 : NS_DECL_FRAMEARENA_HELPERS(nsResizerFrame)
24 :
25 : friend nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
26 :
27 : explicit nsResizerFrame(nsStyleContext* aContext);
28 :
29 : virtual nsresult HandleEvent(nsPresContext* aPresContext,
30 : mozilla::WidgetGUIEvent* aEvent,
31 : nsEventStatus* aEventStatus) override;
32 :
33 : virtual void MouseClicked(mozilla::WidgetMouseEvent* aEvent) override;
34 :
35 : protected:
36 : nsIContent* GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWindow);
37 :
38 : Direction GetDirection();
39 :
40 : /**
41 : * Adjust the window position and size in a direction according to the mouse
42 : * movement and the resizer direction. The minimum and maximum size is used
43 : * to constrain the size.
44 : *
45 : * @param aPos left or top position
46 : * @param aSize width or height
47 : * @param aMinSize minimum width or height
48 : * @param aMacSize maximum width or height
49 : * @param aMovement the amount the mouse was moved
50 : * @param aResizerDirection resizer direction returned by GetDirection
51 : */
52 : static void AdjustDimensions(int32_t* aPos, int32_t* aSize,
53 : int32_t aMinSize, int32_t aMaxSize,
54 : int32_t aMovement, int8_t aResizerDirection);
55 :
56 0 : struct SizeInfo {
57 : nsString width, height;
58 : };
59 : static void SizeInfoDtorFunc(void *aObject, nsIAtom *aPropertyName,
60 : void *aPropertyValue, void *aData);
61 : static void ResizeContent(nsIContent* aContent, const Direction& aDirection,
62 : const SizeInfo& aSizeInfo, SizeInfo* aOriginalSizeInfo);
63 : static void MaybePersistOriginalSize(nsIContent* aContent, const SizeInfo& aSizeInfo);
64 : static void RestoreOriginalSize(nsIContent* aContent);
65 :
66 : protected:
67 : LayoutDeviceIntRect mMouseDownRect;
68 : LayoutDeviceIntPoint mMouseDownPoint;
69 : }; // class nsResizerFrame
70 :
71 : #endif /* nsResizerFrame_h___ */
|