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