2005-08-20 11:11:46 +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/. */
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2014-10-02 06:01:21 +04:00
|
|
|
#ifndef _GTK_NSNATIVETHEMEGTK_H_
|
|
|
|
#define _GTK_NSNATIVETHEMEGTK_H_
|
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
#include "nsITheme.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2005-08-20 11:13:34 +04:00
|
|
|
#include "nsIObserver.h"
|
2005-08-20 11:14:11 +04:00
|
|
|
#include "nsNativeTheme.h"
|
2017-06-07 08:27:18 +03:00
|
|
|
#include "nsThemeConstants.h"
|
2005-08-20 11:12:11 +04:00
|
|
|
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gtk/gtk.h>
|
2005-08-20 11:13:04 +04:00
|
|
|
#include "gtkdrawing.h"
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2017-06-07 08:27:18 +03:00
|
|
|
class nsNativeThemeGTK final : private nsNativeTheme,
|
|
|
|
public nsITheme,
|
|
|
|
public nsIObserver {
|
2005-08-20 11:11:46 +04:00
|
|
|
public:
|
2010-11-13 11:19:38 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-03-08 05:15:57 +04:00
|
|
|
|
|
|
|
NS_DECL_NSIOBSERVER
|
2005-08-20 11:13:34 +04:00
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
// The nsITheme interface.
|
2017-06-09 22:14:53 +03:00
|
|
|
NS_IMETHOD DrawWidgetBackground(gfxContext* aContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIFrame* aFrame, uint8_t aWidgetType,
|
2005-08-20 11:11:46 +04:00
|
|
|
const nsRect& aRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsRect& aDirtyRect) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2011-04-17 05:22:44 +04:00
|
|
|
NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
|
2015-01-21 00:39:44 +03:00
|
|
|
uint8_t aWidgetType,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIntMargin* aResult) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
virtual bool GetWidgetPadding(nsDeviceContext* aContext,
|
2015-01-21 00:39:44 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIntMargin* aResult) override;
|
2005-08-20 11:14:07 +04:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
virtual bool GetWidgetOverflow(nsDeviceContext* aContext,
|
2015-01-21 00:39:44 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
uint8_t aWidgetType,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsRect* aOverflowRect) override;
|
2005-09-01 01:00:52 +04:00
|
|
|
|
2014-06-27 13:19:00 +04:00
|
|
|
NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIFrame* aFrame, uint8_t aWidgetType,
|
2015-03-30 18:36:14 +03:00
|
|
|
mozilla::LayoutDeviceIntSize* aResult,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* aIsOverridable) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2016-04-21 02:49:09 +03:00
|
|
|
bool* aShouldRepaint,
|
|
|
|
const nsAttrValue* aOldValue) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ThemeChanged() override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD_(bool) ThemeSupportsWidget(nsPresContext* aPresContext,
|
2015-01-21 00:39:44 +03:00
|
|
|
nsIFrame* aFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint8_t aWidgetType) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType) override;
|
2007-02-16 04:53:43 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) override;
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ThemeNeedsComboboxDropmarker() override;
|
2007-05-18 07:04:04 +04:00
|
|
|
|
2010-06-18 05:19:21 +04:00
|
|
|
virtual Transparency GetWidgetTransparency(nsIFrame* aFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint8_t aWidgetType) override;
|
2010-06-18 05:19:21 +04:00
|
|
|
|
2005-08-20 11:11:46 +04:00
|
|
|
nsNativeThemeGTK();
|
2014-07-09 01:23:18 +04:00
|
|
|
|
|
|
|
protected:
|
2005-08-20 11:11:46 +04:00
|
|
|
virtual ~nsNativeThemeGTK();
|
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
private:
|
2016-10-20 07:57:55 +03:00
|
|
|
GtkTextDirection GetTextDirection(nsIFrame* aFrame);
|
2010-07-15 02:31:41 +04:00
|
|
|
gint GetTabMarginPixels(nsIFrame* aFrame);
|
2012-08-22 19:56:38 +04:00
|
|
|
bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
|
2016-04-14 08:47:20 +03:00
|
|
|
WidgetNodeType& aGtkWidgetType,
|
|
|
|
GtkWidgetState* aState, gint* aWidgetFlags);
|
2012-08-22 19:56:38 +04:00
|
|
|
bool GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType,
|
2010-07-15 02:31:41 +04:00
|
|
|
nsIntMargin* aExtra);
|
2005-08-20 11:12:27 +04:00
|
|
|
|
2005-08-20 11:14:11 +04:00
|
|
|
void RefreshWidgetWindow(nsIFrame* aFrame);
|
Bug 1289148 - Fixing scrollbar metrics for GTK >= 3.20 r=karlt
The Gtk 3.20 scrollbars has moved towards usual box model. The scrollbar,
trough,thumb and scrollbar button can now have margin, padding and border set,
different for each direction (ie. left, right, bottom, top). The scrollbar
metrics become ignored in Gtk 3.20 and later.
* Draw scrollbar element [for GTK 3.20+]
* The border for scrollbar, trough, thumb and scrollbar buttons is newly
calculated as margin+padding+border [for GTK 3.20+].
* The margin is subtracted for scrollbar, trough and sb buttons during paint
function [for GTK 3.6+]
* All scrollbar widget's borders transfered from
nsNativeThemeGTK::GetWidgetBorder to the moz_gtk_get_widget_border.
* Added helper function NativeThemeToGtkTheme for mapping mozilla's widget type
to the gtk widget type.
* Scrollbar troughs are now drawn even when there is not enough room for
the thumb [GTK 3.20+]
MozReview-Commit-ID: jd2q67gKM1
--HG--
extra : rebase_source : ecc8b85401845113d84c6c5a48219a0c3d4f8de3
2016-10-17 01:37:13 +03:00
|
|
|
WidgetNodeType NativeThemeToGtkTheme(uint8_t aWidgetType, nsIFrame* aFrame);
|
2005-08-20 11:11:46 +04:00
|
|
|
|
2017-06-07 08:27:18 +03:00
|
|
|
uint8_t mDisabledWidgetTypes[(ThemeWidgetType_COUNT + 7) / 8];
|
|
|
|
uint8_t mSafeWidgetStates[ThemeWidgetType_COUNT * 4]; // 32 bits per widget
|
2005-08-20 11:13:00 +04:00
|
|
|
static const char* sDisabledEngines[];
|
2017-06-07 08:27:17 +03:00
|
|
|
|
2017-06-07 08:27:18 +03:00
|
|
|
// Because moz_gtk_get_widget_border can be slow, we cache its results
|
|
|
|
// by widget type. Each bit in mBorderCacheValid says whether the
|
|
|
|
// corresponding entry in mBorderCache is valid.
|
2017-06-07 08:27:17 +03:00
|
|
|
void GetCachedWidgetBorder(nsIFrame* aFrame, uint8_t aWidgetType,
|
|
|
|
GtkTextDirection aDirection, nsIntMargin* aResult);
|
2017-06-07 08:27:18 +03:00
|
|
|
uint8_t mBorderCacheValid[(MOZ_GTK_WIDGET_NODE_COUNT + 7) / 8];
|
|
|
|
nsIntMargin mBorderCache[MOZ_GTK_WIDGET_NODE_COUNT];
|
2005-08-20 11:11:46 +04:00
|
|
|
};
|
2014-10-02 06:01:21 +04:00
|
|
|
|
|
|
|
#endif
|