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