1 /* -*- Mode: C++; tab-width: 4; 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 6 #ifndef NSWINDOW_H_ 7 #define NSWINDOW_H_ 8 9 #include "nsBaseWidget.h" 10 #include "gfxPoint.h" 11 12 #include "nsTArray.h" 13 14 @class UIWindow; 15 @class UIView; 16 @class ChildView; 17 18 class nsWindow final : public nsBaseWidget { 19 typedef nsBaseWidget Inherited; 20 21 public: 22 nsWindow(); 23 24 NS_INLINE_DECL_REFCOUNTING_INHERITED(nsWindow, Inherited) 25 26 // 27 // nsIWidget 28 // 29 30 [[nodiscard]] virtual nsresult 31 Create(nsIWidget* aParent, nsNativeWidget aNativeParent, const LayoutDeviceIntRect& aRect, 32 nsWidgetInitData* aInitData = nullptr) override; 33 virtual void Destroy() override; 34 virtual void Show(bool aState) override; Enable(bool aState)35 virtual void Enable(bool aState) override {} IsEnabled()36 virtual bool IsEnabled() const override { return true; } IsVisible()37 virtual bool IsVisible() const override { return mVisible; } 38 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override; 39 virtual LayoutDeviceIntPoint WidgetToScreenOffset() override; 40 41 virtual void SetBackgroundColor(const nscolor& aColor) override; 42 virtual void* GetNativeData(uint32_t aDataType) override; 43 44 virtual void Move(double aX, double aY) override; 45 virtual void SetSizeMode(nsSizeMode aMode) override; 46 void EnteredFullScreen(bool aFullScreen); 47 virtual void Resize(double aWidth, double aHeight, bool aRepaint) override; 48 virtual void Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override; 49 virtual LayoutDeviceIntRect GetScreenBounds() override; 50 void ReportMoveEvent(); 51 void ReportSizeEvent(); 52 void ReportSizeModeEvent(nsSizeMode aMode); 53 54 CGFloat BackingScaleFactor(); 55 void BackingScaleFactorChanged(); GetDPI()56 virtual float GetDPI() override { 57 // XXX: terrible 58 return 326.0f; 59 } GetDefaultScaleInternal()60 virtual double GetDefaultScaleInternal() override { return BackingScaleFactor(); } 61 virtual int32_t RoundsWidgetCoordinatesTo() override; 62 SetTitle(const nsAString & aTitle)63 virtual nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; } 64 65 virtual void Invalidate(const LayoutDeviceIntRect& aRect) override; 66 virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override; 67 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override; 68 69 void WillPaintWindow(); 70 bool PaintWindow(LayoutDeviceIntRegion aRegion); 71 HasModalDescendents()72 bool HasModalDescendents() { return false; } 73 74 // virtual nsresult 75 // NotifyIME(const IMENotification& aIMENotification) override; 76 virtual void SetInputContext(const InputContext& aContext, const InputContextAction& aAction); 77 virtual InputContext GetInputContext(); 78 /* 79 virtual bool ExecuteNativeKeyBinding( 80 NativeKeyBindingsType aType, 81 const mozilla::WidgetKeyboardEvent& aEvent, 82 DoCommandCallback aCallback, 83 void* aCallbackData) override; 84 */ 85 86 protected: 87 virtual ~nsWindow(); 88 void BringToFront(); 89 nsWindow* FindTopLevel(); 90 bool IsTopLevel(); 91 nsresult GetCurrentOffset(uint32_t& aOffset, uint32_t& aLength); 92 nsresult DeleteRange(int aOffset, int aLen); 93 94 void TearDownView(); 95 96 ChildView* mNativeView; 97 bool mVisible; 98 nsTArray<nsWindow*> mChildren; 99 nsWindow* mParent; 100 InputContext mInputContext; 101 102 void OnSizeChanged(const mozilla::gfx::IntSize& aSize); 103 104 static void DumpWindows(); 105 static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0); 106 static void LogWindow(nsWindow* win, int index, int indent); 107 }; 108 109 #endif /* NSWINDOW_H_ */ 110