Bug 1849470 - Update in-tree zlib to version 1.3. r=aosmond
[gecko.git] / widget / uikit / nsWindow.h
blobed36e1df63d685ac9d46373dc369cbc99cc2436b
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/. */
6 #ifndef NSWINDOW_H_
7 #define NSWINDOW_H_
9 #include "nsBaseWidget.h"
10 #include "gfxPoint.h"
12 #include "nsTArray.h"
14 @class UIWindow;
15 @class UIView;
16 @class ChildView;
18 class nsWindow final : public nsBaseWidget {
19 typedef nsBaseWidget Inherited;
21 public:
22 nsWindow();
24 NS_INLINE_DECL_REFCOUNTING_INHERITED(nsWindow, Inherited)
27 // nsIWidget
30 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
31 const LayoutDeviceIntRect& aRect,
32 widget::InitData* aInitData = nullptr) override;
33 virtual void Destroy() override;
34 virtual void Show(bool aState) override;
35 virtual void Enable(bool aState) override {}
36 virtual bool IsEnabled() const override { return true; }
37 virtual bool IsVisible() const override { return mVisible; }
38 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
39 virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
41 virtual void SetBackgroundColor(const nscolor& aColor) override;
42 virtual void* GetNativeData(uint32_t aDataType) override;
44 virtual void Move(double aX, double aY) override;
45 virtual nsSizeMode SizeMode() override { return mSizeMode; }
46 virtual void SetSizeMode(nsSizeMode aMode) override;
47 void EnteredFullScreen(bool aFullScreen);
48 virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
49 virtual void Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;
50 virtual LayoutDeviceIntRect GetScreenBounds() override;
51 void ReportMoveEvent();
52 void ReportSizeEvent();
53 void ReportSizeModeEvent(nsSizeMode aMode);
55 CGFloat BackingScaleFactor();
56 void BackingScaleFactorChanged();
57 virtual float GetDPI() override {
58 // XXX: terrible
59 return 326.0f;
61 virtual double GetDefaultScaleInternal() override { return BackingScaleFactor(); }
62 virtual int32_t RoundsWidgetCoordinatesTo() override;
64 virtual nsresult SetTitle(const nsAString& aTitle) override { return NS_OK; }
66 virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
67 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
69 void WillPaintWindow();
70 bool PaintWindow(LayoutDeviceIntRegion aRegion);
72 bool HasModalDescendents() { return false; }
74 // virtual nsresult
75 // NotifyIME(const IMENotification& aIMENotification) override;
76 virtual void SetInputContext(const InputContext& aContext, const InputContextAction& aAction);
77 virtual InputContext GetInputContext();
79 virtual bool ExecuteNativeKeyBinding(
80 NativeKeyBindingsType aType,
81 const mozilla::WidgetKeyboardEvent& aEvent,
82 DoCommandCallback aCallback,
83 void* aCallbackData) override;
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);
94 void TearDownView();
96 ChildView* mNativeView;
97 bool mVisible;
98 nsSizeMode mSizeMode;
99 nsTArray<nsWindow*> mChildren;
100 nsWindow* mParent;
101 InputContext mInputContext;
103 void OnSizeChanged(const mozilla::gfx::IntSize& aSize);
105 static void DumpWindows();
106 static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
107 static void LogWindow(nsWindow* win, int index, int indent);
110 #endif /* NSWINDOW_H_ */