summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/libgtk2ui/native_theme_gtk2.h
blob: 5dc3bdafc4071cb92218d76ebd37774827e94265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_LIBGTK2UI_NATIVE_THEME_GTK2_H_
#define CHROME_BROWSER_UI_LIBGTK2UI_NATIVE_THEME_GTK2_H_

#include <gtk/gtk.h>

#include "chrome/browser/ui/libgtk2ui/owned_widget_gtk2.h"
#include "ui/native_theme/native_theme_base.h"

typedef struct _GdkColor GdkColor;

namespace libgtk2ui {

// A version of NativeTheme that uses GTK2 supplied colours instead of the
// default aura colours. Analogue to NativeThemeWin, except that can't be
// compiled into the main chrome binary like the Windows code can.
class NativeThemeGtk2 : public ui::NativeThemeBase {
 public:
  static NativeThemeGtk2* instance();

  // Overridden from ui::NativeThemeBase:
  virtual gfx::Size GetPartSize(Part part,
                                State state,
                                const ExtraParams& extra) const override;
  virtual void Paint(SkCanvas* canvas,
                     Part part,
                     State state,
                     const gfx::Rect& rect,
                     const ExtraParams& extra) const override;
  virtual SkColor GetSystemColor(ColorId color_id) const override;
  virtual void PaintMenuPopupBackground(
      SkCanvas* canvas,
      const gfx::Size& size,
      const MenuBackgroundExtraParams& menu_background) const override;
  virtual void PaintMenuItemBackground(
      SkCanvas* canvas,
      State state,
      const gfx::Rect& rect,
      const MenuListExtraParams& menu_list) const override;

 private:
  NativeThemeGtk2();
  virtual ~NativeThemeGtk2();

  // Implementation of GetSystemColor.
  GdkColor GetSystemGdkColor(ColorId color_id) const;

  // Returns styles associated with various widget types.
  GtkWidget* GetRealizedWindow() const;
  GtkStyle* GetWindowStyle() const;
  GtkStyle* GetEntryStyle() const;
  GtkStyle* GetLabelStyle() const;
  GtkStyle* GetButtonStyle() const;
  GtkStyle* GetTreeStyle() const;
  GtkStyle* GetTooltipStyle() const;
  GtkStyle* GetMenuStyle() const;
  GtkStyle* GetMenuItemStyle() const;

  void PaintComboboxArrow(SkCanvas* canvas,
                          GtkStateType state,
                          const gfx::Rect& rect) const;

  mutable GtkWidget* fake_window_;
  mutable GtkWidget* fake_tooltip_;
  mutable OwnedWidgetGtk fake_entry_;
  mutable OwnedWidgetGtk fake_label_;
  mutable OwnedWidgetGtk fake_button_;
  mutable OwnedWidgetGtk fake_tree_;

  mutable OwnedWidgetGtk fake_menu_;
  mutable GtkWidget* fake_menu_item_;

  DISALLOW_COPY_AND_ASSIGN(NativeThemeGtk2);
};

}  // namespace libgtk2ui

#endif  // CHROME_BROWSER_UI_LIBGTK2UI_NATIVE_THEME_GTK2_H_