2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifndef nsResizerFrame_h___
|
|
|
|
#define nsResizerFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-28 02:03:19 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsTitleBarFrame.h"
|
|
|
|
|
2009-12-23 10:45:44 -08:00
|
|
|
class nsIBaseWindow;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsResizerFrame : public nsTitleBarFrame
|
|
|
|
{
|
|
|
|
protected:
|
2008-06-15 18:36:28 -07:00
|
|
|
struct Direction {
|
2012-08-22 08:56:38 -07:00
|
|
|
int8_t mHorizontal;
|
|
|
|
int8_t mVertical;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
friend nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2015-01-06 01:27:56 -08:00
|
|
|
explicit nsResizerFrame(nsStyleContext* aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 00:36:33 -08:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsEventStatus* aEventStatus) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-01 20:46:03 -07:00
|
|
|
virtual void MouseClicked(nsPresContext* aPresContext,
|
2015-03-21 09:28:04 -07:00
|
|
|
mozilla::WidgetMouseEvent* aEvent) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2009-12-23 10:45:44 -08:00
|
|
|
nsIContent* GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWindow);
|
|
|
|
|
2008-06-15 18:36:28 -07:00
|
|
|
Direction GetDirection();
|
2012-07-30 17:43:29 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust the window position and size in a direction according to the mouse
|
|
|
|
* movement and the resizer direction. The minimum and maximum size is used
|
|
|
|
* to constrain the size.
|
|
|
|
*
|
|
|
|
* @param aPos left or top position
|
|
|
|
* @param aSize width or height
|
|
|
|
* @param aMinSize minimum width or height
|
|
|
|
* @param aMacSize maximum width or height
|
|
|
|
* @param aMovement the amount the mouse was moved
|
|
|
|
* @param aResizerDirection resizer direction returned by GetDirection
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static void AdjustDimensions(int32_t* aPos, int32_t* aSize,
|
|
|
|
int32_t aMinSize, int32_t aMaxSize,
|
|
|
|
int32_t aMovement, int8_t aResizerDirection);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-18 07:25:36 -07:00
|
|
|
struct SizeInfo {
|
|
|
|
nsString width, height;
|
|
|
|
};
|
|
|
|
static void SizeInfoDtorFunc(void *aObject, nsIAtom *aPropertyName,
|
|
|
|
void *aPropertyValue, void *aData);
|
|
|
|
static void ResizeContent(nsIContent* aContent, const Direction& aDirection,
|
|
|
|
const SizeInfo& aSizeInfo, SizeInfo* aOriginalSizeInfo);
|
|
|
|
static void MaybePersistOriginalSize(nsIContent* aContent, const SizeInfo& aSizeInfo);
|
|
|
|
static void RestoreOriginalSize(nsIContent* aContent);
|
2012-07-27 15:01:12 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2015-02-15 10:52:28 -08:00
|
|
|
LayoutDeviceIntRect mMouseDownRect;
|
2015-02-01 14:27:41 -08:00
|
|
|
LayoutDeviceIntPoint mMouseDownPoint;
|
2007-03-22 10:30:00 -07:00
|
|
|
}; // class nsResizerFrame
|
|
|
|
|
|
|
|
#endif /* nsResizerFrame_h___ */
|