2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
2000-07-12 03:37:00 +04:00
|
|
|
#ifndef nsResizerFrame_h___
|
|
|
|
#define nsResizerFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-10-28 13:03:19 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2000-07-12 03:37:00 +04:00
|
|
|
#include "nsTitleBarFrame.h"
|
|
|
|
|
2009-12-23 21:45:44 +03:00
|
|
|
class nsIBaseWindow;
|
|
|
|
class nsMenuPopupFrame;
|
|
|
|
|
2000-07-12 03:37:00 +04:00
|
|
|
class nsResizerFrame : public nsTitleBarFrame
|
|
|
|
{
|
|
|
|
protected:
|
2008-06-16 05:36:28 +04:00
|
|
|
struct Direction {
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t mHorizontal;
|
|
|
|
int8_t mVertical;
|
2000-07-12 03:37:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
friend nsIFrame* NS_NewResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsResizerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
virtual void MouseClicked(nsPresContext* aPresContext,
|
2013-10-28 13:03:19 +04:00
|
|
|
mozilla::WidgetMouseEvent* aEvent) MOZ_OVERRIDE;
|
2000-07-12 03:37:00 +04:00
|
|
|
|
|
|
|
protected:
|
2009-12-23 21:45:44 +03:00
|
|
|
nsIContent* GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWindow);
|
|
|
|
|
2008-06-16 05:36:28 +04:00
|
|
|
Direction GetDirection();
|
2012-07-31 04:43:29 +04: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 19:56:38 +04:00
|
|
|
static void AdjustDimensions(int32_t* aPos, int32_t* aSize,
|
|
|
|
int32_t aMinSize, int32_t aMaxSize,
|
|
|
|
int32_t aMovement, int8_t aResizerDirection);
|
2000-07-12 03:37:00 +04:00
|
|
|
|
2011-08-18 18:25:36 +04: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-28 02:01:12 +04:00
|
|
|
|
2000-07-12 03:37:00 +04:00
|
|
|
protected:
|
2009-12-23 21:45:44 +03:00
|
|
|
nsIntRect mMouseDownRect;
|
|
|
|
nsIntPoint mMouseDownPoint;
|
2000-07-12 03:37:00 +04:00
|
|
|
}; // class nsResizerFrame
|
|
|
|
|
|
|
|
#endif /* nsResizerFrame_h___ */
|