2005-08-20 11:11:55 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains painting functions for each of the gtk2 widgets.
|
|
|
|
* Adapted from the gtkdrawing.c, and gtk+2.0 source.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gdk/gdkprivate.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "gtkdrawing.h"
|
2015-01-30 02:53:46 +03:00
|
|
|
#include "mozilla/Assertions.h"
|
2011-05-05 17:11:35 +04:00
|
|
|
#include "prinrval.h"
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
#include <math.h>
|
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
|
|
|
#include <stdbool.h> // for MOZ_ASSERT_UNREACHABLE
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
#define XTHICKNESS(style) (style->xthickness)
|
|
|
|
#define YTHICKNESS(style) (style->ythickness)
|
|
|
|
#define WINDOW_IS_MAPPED(window) ((window) && GDK_IS_WINDOW(window) && gdk_window_is_visible(window))
|
|
|
|
|
|
|
|
static GtkWidget* gProtoWindow;
|
2009-03-06 09:43:13 +03:00
|
|
|
static GtkWidget* gProtoLayout;
|
2005-08-20 11:13:45 +04:00
|
|
|
static GtkWidget* gButtonWidget;
|
2007-12-03 12:14:18 +03:00
|
|
|
static GtkWidget* gToggleButtonWidget;
|
2008-03-12 13:54:22 +03:00
|
|
|
static GtkWidget* gButtonArrowWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkWidget* gCheckboxWidget;
|
|
|
|
static GtkWidget* gRadiobuttonWidget;
|
2005-08-20 11:13:14 +04:00
|
|
|
static GtkWidget* gHorizScrollbarWidget;
|
|
|
|
static GtkWidget* gVertScrollbarWidget;
|
2006-07-13 21:40:49 +04:00
|
|
|
static GtkWidget* gSpinWidget;
|
2006-05-30 17:50:48 +04:00
|
|
|
static GtkWidget* gHScaleWidget;
|
|
|
|
static GtkWidget* gVScaleWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkWidget* gEntryWidget;
|
2008-03-17 00:05:46 +03:00
|
|
|
static GtkWidget* gComboBoxWidget;
|
|
|
|
static GtkWidget* gComboBoxButtonWidget;
|
|
|
|
static GtkWidget* gComboBoxArrowWidget;
|
|
|
|
static GtkWidget* gComboBoxSeparatorWidget;
|
2008-01-14 14:12:29 +03:00
|
|
|
static GtkWidget* gComboBoxEntryWidget;
|
2008-03-12 13:54:22 +03:00
|
|
|
static GtkWidget* gComboBoxEntryTextareaWidget;
|
|
|
|
static GtkWidget* gComboBoxEntryButtonWidget;
|
|
|
|
static GtkWidget* gComboBoxEntryArrowWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkWidget* gHandleBoxWidget;
|
2005-08-20 11:13:48 +04:00
|
|
|
static GtkWidget* gToolbarWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkWidget* gFrameWidget;
|
2007-11-15 10:35:41 +03:00
|
|
|
static GtkWidget* gStatusbarWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkWidget* gProgressWidget;
|
|
|
|
static GtkWidget* gTabWidget;
|
2005-08-20 11:13:16 +04:00
|
|
|
static GtkWidget* gTooltipWidget;
|
2005-08-20 11:13:48 +04:00
|
|
|
static GtkWidget* gMenuBarWidget;
|
|
|
|
static GtkWidget* gMenuBarItemWidget;
|
|
|
|
static GtkWidget* gMenuPopupWidget;
|
|
|
|
static GtkWidget* gMenuItemWidget;
|
2008-02-20 13:12:33 +03:00
|
|
|
static GtkWidget* gImageMenuItemWidget;
|
2005-08-20 11:14:21 +04:00
|
|
|
static GtkWidget* gCheckMenuItemWidget;
|
2007-11-07 12:14:58 +03:00
|
|
|
static GtkWidget* gTreeViewWidget;
|
2009-04-06 05:32:20 +04:00
|
|
|
static GtkTreeViewColumn* gMiddleTreeViewColumn;
|
2007-11-07 12:14:58 +03:00
|
|
|
static GtkWidget* gTreeHeaderCellWidget;
|
2007-11-13 11:43:03 +03:00
|
|
|
static GtkWidget* gTreeHeaderSortArrowWidget;
|
2007-11-15 06:47:16 +03:00
|
|
|
static GtkWidget* gExpanderWidget;
|
2007-12-03 12:13:29 +03:00
|
|
|
static GtkWidget* gToolbarSeparatorWidget;
|
2007-12-11 12:09:09 +03:00
|
|
|
static GtkWidget* gMenuSeparatorWidget;
|
2007-12-21 14:17:01 +03:00
|
|
|
static GtkWidget* gHPanedWidget;
|
|
|
|
static GtkWidget* gVPanedWidget;
|
2008-02-10 11:36:46 +03:00
|
|
|
static GtkWidget* gScrolledWindowWidget;
|
2005-08-20 11:13:48 +04:00
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static style_prop_t style_prop_func;
|
2008-03-11 11:55:54 +03:00
|
|
|
static gboolean have_arrow_scaling;
|
2006-05-02 03:23:33 +04:00
|
|
|
static gboolean is_initialized;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-04-01 12:33:40 +04:00
|
|
|
/* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
|
|
|
|
that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
|
2008-04-04 12:59:13 +04:00
|
|
|
things they may want to do. */
|
2008-04-01 12:33:40 +04:00
|
|
|
static void
|
|
|
|
moz_gtk_set_widget_name(GtkWidget* widget)
|
|
|
|
{
|
|
|
|
gtk_widget_set_name(widget, "MozillaGtkWidget");
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_enable_style_props(style_prop_t styleGetProp)
|
|
|
|
{
|
|
|
|
style_prop_func = styleGetProp;
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2005-08-20 11:13:45 +04:00
|
|
|
ensure_window_widget()
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
if (!gProtoWindow) {
|
|
|
|
gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
|
2005-08-20 11:13:45 +04:00
|
|
|
gtk_widget_realize(gProtoWindow);
|
2008-04-01 12:33:40 +04:00
|
|
|
moz_gtk_set_widget_name(gProtoWindow);
|
2005-08-20 11:13:45 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
setup_widget_prototype(GtkWidget* widget)
|
|
|
|
{
|
|
|
|
ensure_window_widget();
|
2009-03-06 09:43:13 +03:00
|
|
|
if (!gProtoLayout) {
|
|
|
|
gProtoLayout = gtk_fixed_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(gProtoWindow), gProtoLayout);
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
2009-03-06 09:43:13 +03:00
|
|
|
gtk_container_add(GTK_CONTAINER(gProtoLayout), widget);
|
2005-08-20 11:11:55 +04:00
|
|
|
gtk_widget_realize(widget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_button_widget()
|
|
|
|
{
|
|
|
|
if (!gButtonWidget) {
|
|
|
|
gButtonWidget = gtk_button_new_with_label("M");
|
|
|
|
setup_widget_prototype(gButtonWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-21 14:17:01 +03:00
|
|
|
static gint
|
|
|
|
ensure_hpaned_widget()
|
|
|
|
{
|
|
|
|
if (!gHPanedWidget) {
|
|
|
|
gHPanedWidget = gtk_hpaned_new();
|
|
|
|
setup_widget_prototype(gHPanedWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_vpaned_widget()
|
|
|
|
{
|
|
|
|
if (!gVPanedWidget) {
|
|
|
|
gVPanedWidget = gtk_vpaned_new();
|
|
|
|
setup_widget_prototype(gVPanedWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-03 12:14:18 +03:00
|
|
|
static gint
|
|
|
|
ensure_toggle_button_widget()
|
|
|
|
{
|
|
|
|
if (!gToggleButtonWidget) {
|
|
|
|
gToggleButtonWidget = gtk_toggle_button_new();
|
|
|
|
setup_widget_prototype(gToggleButtonWidget);
|
|
|
|
/* toggle button must be set active to get the right style on hover. */
|
|
|
|
GTK_TOGGLE_BUTTON(gToggleButtonWidget)->active = TRUE;
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-12 13:54:22 +03:00
|
|
|
static gint
|
|
|
|
ensure_button_arrow_widget()
|
|
|
|
{
|
|
|
|
if (!gButtonArrowWidget) {
|
|
|
|
ensure_toggle_button_widget();
|
|
|
|
|
|
|
|
gButtonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
|
|
|
|
gtk_container_add(GTK_CONTAINER(gToggleButtonWidget), gButtonArrowWidget);
|
|
|
|
gtk_widget_realize(gButtonArrowWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
ensure_checkbox_widget()
|
|
|
|
{
|
|
|
|
if (!gCheckboxWidget) {
|
|
|
|
gCheckboxWidget = gtk_check_button_new_with_label("M");
|
|
|
|
setup_widget_prototype(gCheckboxWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_radiobutton_widget()
|
|
|
|
{
|
|
|
|
if (!gRadiobuttonWidget) {
|
|
|
|
gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
|
|
|
|
setup_widget_prototype(gRadiobuttonWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_scrollbar_widget()
|
|
|
|
{
|
2005-08-20 11:13:14 +04:00
|
|
|
if (!gVertScrollbarWidget) {
|
|
|
|
gVertScrollbarWidget = gtk_vscrollbar_new(NULL);
|
|
|
|
setup_widget_prototype(gVertScrollbarWidget);
|
|
|
|
}
|
|
|
|
if (!gHorizScrollbarWidget) {
|
|
|
|
gHorizScrollbarWidget = gtk_hscrollbar_new(NULL);
|
|
|
|
setup_widget_prototype(gHorizScrollbarWidget);
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-13 21:40:49 +04:00
|
|
|
static gint
|
|
|
|
ensure_spin_widget()
|
|
|
|
{
|
|
|
|
if (!gSpinWidget) {
|
|
|
|
gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
|
|
|
|
setup_widget_prototype(gSpinWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
static gint
|
|
|
|
ensure_scale_widget()
|
|
|
|
{
|
|
|
|
if (!gHScaleWidget) {
|
|
|
|
gHScaleWidget = gtk_hscale_new(NULL);
|
|
|
|
setup_widget_prototype(gHScaleWidget);
|
|
|
|
}
|
|
|
|
if (!gVScaleWidget) {
|
|
|
|
gVScaleWidget = gtk_vscale_new(NULL);
|
|
|
|
setup_widget_prototype(gVScaleWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
ensure_entry_widget()
|
|
|
|
{
|
|
|
|
if (!gEntryWidget) {
|
|
|
|
gEntryWidget = gtk_entry_new();
|
|
|
|
setup_widget_prototype(gEntryWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
/* We need to have pointers to the inner widgets (button, separator, arrow)
|
|
|
|
* of the ComboBox to get the correct rendering from theme engines which
|
|
|
|
* special cases their look. Since the inner layout can change, we ask GTK
|
|
|
|
* to NULL our pointers when they are about to become invalid because the
|
|
|
|
* corresponding widgets don't exist anymore. It's the role of
|
|
|
|
* g_object_add_weak_pointer().
|
|
|
|
* Note that if we don't find the inner widgets (which shouldn't happen), we
|
|
|
|
* fallback to use generic "non-inner" widgets, and they don't need that kind
|
|
|
|
* of weak pointer since they are explicit children of gProtoWindow and as
|
|
|
|
* such GTK holds a strong reference to them. */
|
|
|
|
static void
|
|
|
|
moz_gtk_get_combo_box_inner_button(GtkWidget *widget, gpointer client_data)
|
|
|
|
{
|
|
|
|
if (GTK_IS_TOGGLE_BUTTON(widget)) {
|
|
|
|
gComboBoxButtonWidget = widget;
|
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
|
|
|
(gpointer) &gComboBoxButtonWidget);
|
|
|
|
gtk_widget_realize(widget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-03-17 00:05:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
if (GTK_IS_SEPARATOR(widget)) {
|
|
|
|
gComboBoxSeparatorWidget = widget;
|
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
|
|
|
(gpointer) &gComboBoxSeparatorWidget);
|
|
|
|
} else if (GTK_IS_ARROW(widget)) {
|
|
|
|
gComboBoxArrowWidget = widget;
|
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
|
|
|
(gpointer) &gComboBoxArrowWidget);
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
gtk_widget_realize(widget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-03-17 00:05:46 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:05 +04:00
|
|
|
static gint
|
2008-03-17 00:05:46 +03:00
|
|
|
ensure_combo_box_widgets()
|
2005-08-20 11:14:05 +04:00
|
|
|
{
|
2008-04-01 12:33:40 +04:00
|
|
|
GtkWidget* buttonChild;
|
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
if (gComboBoxButtonWidget && gComboBoxArrowWidget)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
|
|
|
/* Create a ComboBox if needed */
|
|
|
|
if (!gComboBoxWidget) {
|
|
|
|
gComboBoxWidget = gtk_combo_box_new();
|
|
|
|
setup_widget_prototype(gComboBoxWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get its inner Button */
|
|
|
|
gtk_container_forall(GTK_CONTAINER(gComboBoxWidget),
|
|
|
|
moz_gtk_get_combo_box_inner_button,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (gComboBoxButtonWidget) {
|
|
|
|
/* Get the widgets inside the Button */
|
|
|
|
buttonChild = GTK_BIN(gComboBoxButtonWidget)->child;
|
|
|
|
if (GTK_IS_HBOX(buttonChild)) {
|
|
|
|
/* appears-as-list = FALSE, cell-view = TRUE; the button
|
|
|
|
* contains an hbox. This hbox is there because the ComboBox
|
|
|
|
* needs to place a cell renderer, a separator, and an arrow in
|
|
|
|
* the button when appears-as-list is FALSE. */
|
|
|
|
gtk_container_forall(GTK_CONTAINER(buttonChild),
|
|
|
|
moz_gtk_get_combo_box_button_inner_widgets,
|
|
|
|
NULL);
|
|
|
|
} else if(GTK_IS_ARROW(buttonChild)) {
|
|
|
|
/* appears-as-list = TRUE, or cell-view = FALSE;
|
|
|
|
* the button only contains an arrow */
|
|
|
|
gComboBoxArrowWidget = buttonChild;
|
|
|
|
g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
|
|
|
|
&gComboBoxArrowWidget);
|
|
|
|
gtk_widget_realize(gComboBoxArrowWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gComboBoxArrowWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-03-17 00:05:46 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Shouldn't be reached with current internal gtk implementation; we
|
|
|
|
* use a generic toggle button as last resort fallback to avoid
|
|
|
|
* crashing. */
|
|
|
|
ensure_toggle_button_widget();
|
|
|
|
gComboBoxButtonWidget = gToggleButtonWidget;
|
2005-08-20 11:14:05 +04:00
|
|
|
}
|
2008-03-17 00:05:46 +03:00
|
|
|
|
|
|
|
if (!gComboBoxArrowWidget) {
|
|
|
|
/* Shouldn't be reached with current internal gtk implementation;
|
|
|
|
* we gButtonArrowWidget as last resort fallback to avoid
|
|
|
|
* crashing. */
|
|
|
|
ensure_button_arrow_widget();
|
|
|
|
gComboBoxArrowWidget = gButtonArrowWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We don't test the validity of gComboBoxSeparatorWidget since there
|
|
|
|
* is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it
|
|
|
|
* is invalid we just won't paint it. */
|
|
|
|
|
2005-08-20 11:14:05 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
/* We need to have pointers to the inner widgets (entry, button, arrow) of
|
|
|
|
* the ComboBoxEntry to get the correct rendering from theme engines which
|
|
|
|
* special cases their look. Since the inner layout can change, we ask GTK
|
|
|
|
* to NULL our pointers when they are about to become invalid because the
|
|
|
|
* corresponding widgets don't exist anymore. It's the role of
|
|
|
|
* g_object_add_weak_pointer().
|
|
|
|
* Note that if we don't find the inner widgets (which shouldn't happen), we
|
|
|
|
* fallback to use generic "non-inner" widgets, and they don't need that kind
|
|
|
|
* of weak pointer since they are explicit children of gProtoWindow and as
|
|
|
|
* such GTK holds a strong reference to them. */
|
|
|
|
static void
|
|
|
|
moz_gtk_get_combo_box_entry_inner_widgets(GtkWidget *widget,
|
|
|
|
gpointer client_data)
|
2008-01-14 14:12:29 +03:00
|
|
|
{
|
2008-03-11 11:55:54 +03:00
|
|
|
if (GTK_IS_TOGGLE_BUTTON(widget)) {
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryButtonWidget = widget;
|
2008-03-11 11:55:54 +03:00
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
2008-03-12 13:54:22 +03:00
|
|
|
(gpointer) &gComboBoxEntryButtonWidget);
|
2008-03-11 11:55:54 +03:00
|
|
|
} else if (GTK_IS_ENTRY(widget)) {
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryTextareaWidget = widget;
|
2008-03-11 11:55:54 +03:00
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
2008-03-12 13:54:22 +03:00
|
|
|
(gpointer) &gComboBoxEntryTextareaWidget);
|
2008-03-11 11:55:54 +03:00
|
|
|
} else
|
|
|
|
return;
|
|
|
|
gtk_widget_realize(widget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-01-14 14:12:29 +03:00
|
|
|
}
|
|
|
|
|
2008-01-22 03:15:06 +03:00
|
|
|
static void
|
2008-03-11 11:55:54 +03:00
|
|
|
moz_gtk_get_combo_box_entry_arrow(GtkWidget *widget, gpointer client_data)
|
2008-01-22 03:15:06 +03:00
|
|
|
{
|
2008-03-11 11:55:54 +03:00
|
|
|
if (GTK_IS_ARROW(widget)) {
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryArrowWidget = widget;
|
2008-03-11 11:55:54 +03:00
|
|
|
g_object_add_weak_pointer(G_OBJECT(widget),
|
2008-03-12 13:54:22 +03:00
|
|
|
(gpointer) &gComboBoxEntryArrowWidget);
|
2008-03-11 11:55:54 +03:00
|
|
|
gtk_widget_realize(widget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-03-11 11:55:54 +03:00
|
|
|
}
|
2008-01-22 03:15:06 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
2008-03-11 11:55:54 +03:00
|
|
|
ensure_combo_box_entry_widgets()
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2008-04-01 12:33:40 +04:00
|
|
|
GtkWidget* buttonChild;
|
|
|
|
|
2008-03-18 22:31:50 +03:00
|
|
|
if (gComboBoxEntryTextareaWidget &&
|
|
|
|
gComboBoxEntryButtonWidget &&
|
|
|
|
gComboBoxEntryArrowWidget)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
2008-03-11 11:55:54 +03:00
|
|
|
|
2008-03-18 22:31:50 +03:00
|
|
|
/* Create a ComboBoxEntry if needed */
|
|
|
|
if (!gComboBoxEntryWidget) {
|
|
|
|
gComboBoxEntryWidget = gtk_combo_box_entry_new();
|
|
|
|
setup_widget_prototype(gComboBoxEntryWidget);
|
|
|
|
}
|
2008-03-11 11:55:54 +03:00
|
|
|
|
2008-03-18 22:31:50 +03:00
|
|
|
/* Get its inner Entry and Button */
|
|
|
|
gtk_container_forall(GTK_CONTAINER(gComboBoxEntryWidget),
|
|
|
|
moz_gtk_get_combo_box_entry_inner_widgets,
|
|
|
|
NULL);
|
2008-03-11 11:55:54 +03:00
|
|
|
|
2008-03-18 22:31:50 +03:00
|
|
|
if (!gComboBoxEntryTextareaWidget) {
|
|
|
|
ensure_entry_widget();
|
|
|
|
gComboBoxEntryTextareaWidget = gEntryWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gComboBoxEntryButtonWidget) {
|
|
|
|
/* Get the Arrow inside the Button */
|
|
|
|
buttonChild = GTK_BIN(gComboBoxEntryButtonWidget)->child;
|
|
|
|
if (GTK_IS_HBOX(buttonChild)) {
|
|
|
|
/* appears-as-list = FALSE, cell-view = TRUE; the button
|
|
|
|
* contains an hbox. This hbox is there because ComboBoxEntry
|
|
|
|
* inherits from ComboBox which needs to place a cell renderer,
|
|
|
|
* a separator, and an arrow in the button when appears-as-list
|
|
|
|
* is FALSE. Here the hbox should only contain an arrow, since
|
|
|
|
* a ComboBoxEntry doesn't need all those widgets in the
|
|
|
|
* button. */
|
|
|
|
gtk_container_forall(GTK_CONTAINER(buttonChild),
|
|
|
|
moz_gtk_get_combo_box_entry_arrow,
|
|
|
|
NULL);
|
|
|
|
} else if(GTK_IS_ARROW(buttonChild)) {
|
|
|
|
/* appears-as-list = TRUE, or cell-view = FALSE;
|
|
|
|
* the button only contains an arrow */
|
|
|
|
gComboBoxEntryArrowWidget = buttonChild;
|
|
|
|
g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
|
|
|
|
&gComboBoxEntryArrowWidget);
|
|
|
|
gtk_widget_realize(gComboBoxEntryArrowWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gComboBoxEntryArrowWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-03-11 11:55:54 +03:00
|
|
|
}
|
2008-03-18 22:31:50 +03:00
|
|
|
} else {
|
|
|
|
/* Shouldn't be reached with current internal gtk implementation;
|
|
|
|
* we use a generic toggle button as last resort fallback to avoid
|
|
|
|
* crashing. */
|
|
|
|
ensure_toggle_button_widget();
|
|
|
|
gComboBoxEntryButtonWidget = gToggleButtonWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
2008-03-18 22:31:50 +03:00
|
|
|
|
|
|
|
if (!gComboBoxEntryArrowWidget) {
|
|
|
|
/* Shouldn't be reached with current internal gtk implementation;
|
|
|
|
* we gButtonArrowWidget as last resort fallback to avoid
|
|
|
|
* crashing. */
|
|
|
|
ensure_button_arrow_widget();
|
|
|
|
gComboBoxEntryArrowWidget = gButtonArrowWidget;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
ensure_handlebox_widget()
|
|
|
|
{
|
|
|
|
if (!gHandleBoxWidget) {
|
|
|
|
gHandleBoxWidget = gtk_handle_box_new();
|
|
|
|
setup_widget_prototype(gHandleBoxWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
static gint
|
|
|
|
ensure_toolbar_widget()
|
|
|
|
{
|
|
|
|
if (!gToolbarWidget) {
|
|
|
|
ensure_handlebox_widget();
|
|
|
|
gToolbarWidget = gtk_toolbar_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(gHandleBoxWidget), gToolbarWidget);
|
|
|
|
gtk_widget_realize(gToolbarWidget);
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(gToolbarWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:13:48 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-03 12:13:29 +03:00
|
|
|
static gint
|
|
|
|
ensure_toolbar_separator_widget()
|
|
|
|
{
|
|
|
|
if (!gToolbarSeparatorWidget) {
|
|
|
|
ensure_toolbar_widget();
|
2007-12-19 14:33:45 +03:00
|
|
|
gToolbarSeparatorWidget = GTK_WIDGET(gtk_separator_tool_item_new());
|
2007-12-03 12:13:29 +03:00
|
|
|
setup_widget_prototype(gToolbarSeparatorWidget);
|
|
|
|
}
|
2007-12-19 14:33:45 +03:00
|
|
|
return MOZ_GTK_SUCCESS;
|
2007-12-03 12:13:29 +03:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
ensure_tooltip_widget()
|
|
|
|
{
|
|
|
|
if (!gTooltipWidget) {
|
2005-08-20 11:13:16 +04:00
|
|
|
gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
|
|
|
|
gtk_widget_realize(gTooltipWidget);
|
2008-04-01 12:33:40 +04:00
|
|
|
moz_gtk_set_widget_name(gTooltipWidget);
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_tab_widget()
|
|
|
|
{
|
|
|
|
if (!gTabWidget) {
|
|
|
|
gTabWidget = gtk_notebook_new();
|
|
|
|
setup_widget_prototype(gTabWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_progress_widget()
|
|
|
|
{
|
|
|
|
if (!gProgressWidget) {
|
|
|
|
gProgressWidget = gtk_progress_bar_new();
|
|
|
|
setup_widget_prototype(gProgressWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-15 10:35:41 +03:00
|
|
|
static gint
|
|
|
|
ensure_statusbar_widget()
|
|
|
|
{
|
|
|
|
if (!gStatusbarWidget) {
|
|
|
|
gStatusbarWidget = gtk_statusbar_new();
|
|
|
|
setup_widget_prototype(gStatusbarWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
ensure_frame_widget()
|
|
|
|
{
|
|
|
|
if (!gFrameWidget) {
|
2007-11-15 10:35:41 +03:00
|
|
|
ensure_statusbar_widget();
|
2005-08-20 11:11:55 +04:00
|
|
|
gFrameWidget = gtk_frame_new(NULL);
|
2007-11-15 10:35:41 +03:00
|
|
|
gtk_container_add(GTK_CONTAINER(gStatusbarWidget), gFrameWidget);
|
|
|
|
gtk_widget_realize(gFrameWidget);
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
static gint
|
|
|
|
ensure_menu_bar_widget()
|
|
|
|
{
|
|
|
|
if (!gMenuBarWidget) {
|
|
|
|
gMenuBarWidget = gtk_menu_bar_new();
|
|
|
|
setup_widget_prototype(gMenuBarWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_menu_bar_item_widget()
|
|
|
|
{
|
|
|
|
if (!gMenuBarItemWidget) {
|
|
|
|
ensure_menu_bar_widget();
|
|
|
|
gMenuBarItemWidget = gtk_menu_item_new();
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget),
|
|
|
|
gMenuBarItemWidget);
|
|
|
|
gtk_widget_realize(gMenuBarItemWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gMenuBarItemWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:13:48 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_menu_popup_widget()
|
|
|
|
{
|
|
|
|
if (!gMenuPopupWidget) {
|
|
|
|
ensure_menu_bar_item_widget();
|
|
|
|
gMenuPopupWidget = gtk_menu_new();
|
|
|
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuBarItemWidget),
|
|
|
|
gMenuPopupWidget);
|
|
|
|
gtk_widget_realize(gMenuPopupWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gMenuPopupWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:13:48 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_menu_item_widget()
|
|
|
|
{
|
|
|
|
if (!gMenuItemWidget) {
|
|
|
|
ensure_menu_popup_widget();
|
|
|
|
gMenuItemWidget = gtk_menu_item_new_with_label("M");
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
|
|
|
|
gMenuItemWidget);
|
|
|
|
gtk_widget_realize(gMenuItemWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gMenuItemWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:13:48 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-20 13:12:33 +03:00
|
|
|
static gint
|
|
|
|
ensure_image_menu_item_widget()
|
|
|
|
{
|
|
|
|
if (!gImageMenuItemWidget) {
|
|
|
|
ensure_menu_popup_widget();
|
|
|
|
gImageMenuItemWidget = gtk_image_menu_item_new();
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
|
|
|
|
gImageMenuItemWidget);
|
|
|
|
gtk_widget_realize(gImageMenuItemWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gImageMenuItemWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-02-20 13:12:33 +03:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-11 12:09:09 +03:00
|
|
|
static gint
|
|
|
|
ensure_menu_separator_widget()
|
|
|
|
{
|
|
|
|
if (!gMenuSeparatorWidget) {
|
|
|
|
ensure_menu_popup_widget();
|
|
|
|
gMenuSeparatorWidget = gtk_separator_menu_item_new();
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
|
|
|
|
gMenuSeparatorWidget);
|
|
|
|
gtk_widget_realize(gMenuSeparatorWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gMenuSeparatorWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2007-12-11 12:09:09 +03:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
static gint
|
|
|
|
ensure_check_menu_item_widget()
|
|
|
|
{
|
|
|
|
if (!gCheckMenuItemWidget) {
|
|
|
|
ensure_menu_popup_widget();
|
|
|
|
gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
|
|
|
|
gCheckMenuItemWidget);
|
|
|
|
gtk_widget_realize(gCheckMenuItemWidget);
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gCheckMenuItemWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2005-08-20 11:14:21 +04:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-07 12:14:58 +03:00
|
|
|
static gint
|
|
|
|
ensure_tree_view_widget()
|
|
|
|
{
|
|
|
|
if (!gTreeViewWidget) {
|
|
|
|
gTreeViewWidget = gtk_tree_view_new();
|
|
|
|
setup_widget_prototype(gTreeViewWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_tree_header_cell_widget()
|
|
|
|
{
|
|
|
|
if(!gTreeHeaderCellWidget) {
|
2008-02-24 09:20:16 +03:00
|
|
|
/*
|
|
|
|
* Some GTK engines paint the first and last cell
|
|
|
|
* of a TreeView header with a highlight.
|
|
|
|
* Since we do not know where our widget will be relative
|
|
|
|
* to the other buttons in the TreeView header, we must
|
|
|
|
* paint it as a button that is between two others,
|
|
|
|
* thus ensuring it is neither the first or last button
|
|
|
|
* in the header.
|
|
|
|
* GTK doesn't give us a way to do this explicitly,
|
|
|
|
* so we must paint with a button that is between two
|
|
|
|
* others.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GtkTreeViewColumn* firstTreeViewColumn;
|
|
|
|
GtkTreeViewColumn* lastTreeViewColumn;
|
|
|
|
|
2008-02-21 13:46:54 +03:00
|
|
|
ensure_tree_view_widget();
|
2007-11-07 12:14:58 +03:00
|
|
|
|
2008-02-24 09:20:16 +03:00
|
|
|
/* Create and append our three columns */
|
|
|
|
firstTreeViewColumn = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(firstTreeViewColumn, "M");
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), firstTreeViewColumn);
|
|
|
|
|
2008-03-18 22:35:23 +03:00
|
|
|
gMiddleTreeViewColumn = gtk_tree_view_column_new();
|
2009-04-06 05:32:20 +04:00
|
|
|
gtk_tree_view_column_set_title(gMiddleTreeViewColumn, "M");
|
2008-03-18 22:35:23 +03:00
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget),
|
2009-04-06 05:32:20 +04:00
|
|
|
gMiddleTreeViewColumn);
|
2008-02-24 09:20:16 +03:00
|
|
|
|
|
|
|
lastTreeViewColumn = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(lastTreeViewColumn, "M");
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), lastTreeViewColumn);
|
2008-02-21 13:46:54 +03:00
|
|
|
|
2008-02-24 09:20:16 +03:00
|
|
|
/* Use the middle column's header for our button */
|
2009-04-06 05:32:20 +04:00
|
|
|
gTreeHeaderCellWidget = gMiddleTreeViewColumn->button;
|
|
|
|
gTreeHeaderSortArrowWidget = gMiddleTreeViewColumn->arrow;
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gTreeHeaderCellWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-08-14 12:04:28 +04:00
|
|
|
g_object_set_data(G_OBJECT(gTreeHeaderSortArrowWidget),
|
2008-12-10 18:53:28 +03:00
|
|
|
"transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2007-11-07 12:14:58 +03:00
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
2007-11-15 06:47:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
ensure_expander_widget()
|
|
|
|
{
|
|
|
|
if (!gExpanderWidget) {
|
|
|
|
gExpanderWidget = gtk_expander_new("M");
|
|
|
|
setup_widget_prototype(gExpanderWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
2007-11-07 12:14:58 +03:00
|
|
|
|
2008-02-10 11:36:46 +03:00
|
|
|
static gint
|
|
|
|
ensure_scrolled_window_widget()
|
|
|
|
{
|
|
|
|
if (!gScrolledWindowWidget) {
|
|
|
|
gScrolledWindowWidget = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
setup_widget_prototype(gScrolledWindowWidget);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static GtkStateType
|
|
|
|
ConvertGtkState(GtkWidgetState* state)
|
|
|
|
{
|
|
|
|
if (state->disabled)
|
|
|
|
return GTK_STATE_INSENSITIVE;
|
2007-12-03 12:14:18 +03:00
|
|
|
else if (state->depressed)
|
|
|
|
return (state->inHover ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
|
2005-08-20 11:11:55 +04:00
|
|
|
else if (state->inHover)
|
2005-08-20 11:13:51 +04:00
|
|
|
return (state->active ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT);
|
|
|
|
else
|
|
|
|
return GTK_STATE_NORMAL;
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
TSOffsetStyleGCArray(GdkGC** gcs, gint xorigin, gint yorigin)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* there are 5 gc's in each array, for each of the widget states */
|
|
|
|
for (i = 0; i < 5; ++i)
|
|
|
|
gdk_gc_set_ts_origin(gcs[i], xorigin, yorigin);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
TSOffsetStyleGCs(GtkStyle* style, gint xorigin, gint yorigin)
|
|
|
|
{
|
|
|
|
TSOffsetStyleGCArray(style->fg_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->bg_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->light_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->dark_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->mid_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->text_gc, xorigin, yorigin);
|
|
|
|
TSOffsetStyleGCArray(style->base_gc, xorigin, yorigin);
|
|
|
|
gdk_gc_set_ts_origin(style->black_gc, xorigin, yorigin);
|
|
|
|
gdk_gc_set_ts_origin(style->white_gc, xorigin, yorigin);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
moz_gtk_init()
|
|
|
|
{
|
2008-08-14 12:04:28 +04:00
|
|
|
GtkWidgetClass *entry_class;
|
|
|
|
|
2011-02-17 02:01:51 +03:00
|
|
|
if (is_initialized)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
2006-05-02 03:23:33 +04:00
|
|
|
is_initialized = TRUE;
|
2008-03-11 11:55:54 +03:00
|
|
|
have_arrow_scaling = (gtk_major_version > 2 ||
|
|
|
|
(gtk_major_version == 2 && gtk_minor_version >= 12));
|
2005-08-20 11:14:10 +04:00
|
|
|
|
2008-08-14 12:04:28 +04:00
|
|
|
/* Add style property to GtkEntry.
|
|
|
|
* Adding the style property to the normal GtkEntry class means that it
|
|
|
|
* will work without issues inside GtkComboBox and for Spinbuttons. */
|
|
|
|
entry_class = g_type_class_ref(GTK_TYPE_ENTRY);
|
|
|
|
gtk_widget_class_install_style_property(entry_class,
|
|
|
|
g_param_spec_boolean("honors-transparent-bg-hint",
|
|
|
|
"Transparent BG enabling flag",
|
|
|
|
"If TRUE, the theme is able to draw the GtkEntry on non-prefilled background.",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:04:09 +04:00
|
|
|
GdkColormap*
|
|
|
|
moz_gtk_widget_get_colormap()
|
|
|
|
{
|
|
|
|
/* Child widgets inherit the colormap from the GtkWindow. */
|
|
|
|
ensure_window_widget();
|
|
|
|
return gtk_widget_get_colormap(gProtoWindow);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing)
|
|
|
|
{
|
|
|
|
ensure_checkbox_widget();
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
gtk_widget_style_get (gCheckboxWidget,
|
|
|
|
"indicator_size", indicator_size,
|
|
|
|
"indicator_spacing", indicator_spacing,
|
|
|
|
NULL);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2005-08-20 11:14:00 +04:00
|
|
|
moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
ensure_radiobutton_widget();
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
gtk_widget_style_get (gRadiobuttonWidget,
|
|
|
|
"indicator_size", indicator_size,
|
|
|
|
"indicator_spacing", indicator_spacing,
|
|
|
|
NULL);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width)
|
|
|
|
{
|
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width = 0;
|
|
|
|
|
|
|
|
ensure_entry_widget();
|
|
|
|
gtk_widget_style_get(gEntryWidget,
|
|
|
|
"interior-focus", &interior_focus,
|
|
|
|
"focus-line-width", &focus_width,
|
|
|
|
NULL);
|
|
|
|
if (interior_focus) {
|
|
|
|
*focus_h_width = XTHICKNESS(gEntryWidget->style) + focus_width;
|
|
|
|
*focus_v_width = YTHICKNESS(gEntryWidget->style) + focus_width;
|
|
|
|
} else {
|
|
|
|
*focus_h_width = focus_width;
|
|
|
|
*focus_v_width = focus_width;
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-25 21:41:01 +03:00
|
|
|
static gint
|
2007-11-07 12:14:58 +03:00
|
|
|
moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
|
|
|
|
gint* focus_width, gint* focus_pad)
|
2005-08-20 11:14:07 +04:00
|
|
|
{
|
2007-11-07 12:14:58 +03:00
|
|
|
gtk_widget_style_get (widget,
|
2005-08-20 11:14:07 +04:00
|
|
|
"interior-focus", interior_focus,
|
|
|
|
"focus-line-width", focus_width,
|
|
|
|
"focus-padding", focus_pad,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-06-25 01:00:46 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding)
|
|
|
|
{
|
|
|
|
ensure_menu_item_widget();
|
|
|
|
|
|
|
|
gtk_widget_style_get (gMenuItemWidget,
|
|
|
|
"horizontal-padding", horizontal_padding,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding)
|
|
|
|
{
|
|
|
|
ensure_check_menu_item_widget();
|
|
|
|
|
|
|
|
gtk_widget_style_get (gCheckMenuItemWidget,
|
|
|
|
"horizontal-padding", horizontal_padding,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-06-15 01:56:37 +04:00
|
|
|
gint
|
2009-07-04 14:01:16 +04:00
|
|
|
moz_gtk_button_get_default_overflow(gint* border_top, gint* border_left,
|
|
|
|
gint* border_bottom, gint* border_right)
|
2009-06-15 01:56:37 +04:00
|
|
|
{
|
|
|
|
GtkBorder* default_outside_border;
|
2009-07-17 18:22:11 +04:00
|
|
|
|
|
|
|
ensure_button_widget();
|
2009-06-15 01:56:37 +04:00
|
|
|
gtk_widget_style_get(gButtonWidget,
|
|
|
|
"default-outside-border", &default_outside_border,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (default_outside_border) {
|
|
|
|
*border_top = default_outside_border->top;
|
|
|
|
*border_left = default_outside_border->left;
|
|
|
|
*border_bottom = default_outside_border->bottom;
|
|
|
|
*border_right = default_outside_border->right;
|
|
|
|
gtk_border_free(default_outside_border);
|
|
|
|
} else {
|
|
|
|
*border_top = *border_left = *border_bottom = *border_right = 0;
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-07-04 14:01:16 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_button_get_default_border(gint* border_top, gint* border_left,
|
|
|
|
gint* border_bottom, gint* border_right)
|
|
|
|
{
|
|
|
|
GtkBorder* default_border;
|
2009-07-17 18:22:11 +04:00
|
|
|
|
|
|
|
ensure_button_widget();
|
2009-07-04 14:01:16 +04:00
|
|
|
gtk_widget_style_get(gButtonWidget,
|
|
|
|
"default-border", &default_border,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (default_border) {
|
|
|
|
*border_top = default_border->top;
|
|
|
|
*border_left = default_border->left;
|
|
|
|
*border_bottom = default_border->bottom;
|
|
|
|
*border_right = default_border->right;
|
|
|
|
gtk_border_free(default_border);
|
|
|
|
} else {
|
|
|
|
/* see gtkbutton.c */
|
|
|
|
*border_top = *border_left = *border_bottom = *border_right = 1;
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-21 14:17:01 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_splitter_get_metrics(gint orientation, gint* size)
|
|
|
|
{
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
|
|
|
|
ensure_hpaned_widget();
|
|
|
|
gtk_widget_style_get(gHPanedWidget, "handle_size", size, NULL);
|
|
|
|
} else {
|
|
|
|
ensure_vpaned_widget();
|
|
|
|
gtk_widget_style_get(gVPanedWidget, "handle_size", size, NULL);
|
|
|
|
}
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-03-25 21:41:01 +03:00
|
|
|
static gint
|
2008-02-07 12:27:27 +03:00
|
|
|
moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border)
|
|
|
|
{
|
|
|
|
static const GtkBorder default_inner_border = { 1, 1, 1, 1 };
|
|
|
|
GtkBorder *tmp_border;
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL);
|
|
|
|
|
|
|
|
if (tmp_border) {
|
|
|
|
*inner_border = *tmp_border;
|
|
|
|
gtk_border_free(tmp_border);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*inner_border = default_inner_border;
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-07-04 14:01:16 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkReliefStyle relief, GtkWidget* widget,
|
|
|
|
GtkTextDirection direction)
|
|
|
|
{
|
|
|
|
GtkShadowType shadow_type;
|
|
|
|
GtkStyle* style = widget->style;
|
|
|
|
GtkStateType button_state = ConvertGtkState(state);
|
|
|
|
gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
|
|
|
|
|
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
|
|
|
|
moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width, &focus_pad);
|
|
|
|
|
|
|
|
if (WINDOW_IS_MAPPED(drawable)) {
|
|
|
|
gdk_window_set_back_pixmap(drawable, NULL, TRUE);
|
|
|
|
gdk_window_clear_area(drawable, cliprect->x, cliprect->y,
|
|
|
|
cliprect->width, cliprect->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_state(widget, button_state);
|
|
|
|
gtk_widget_set_direction(widget, direction);
|
|
|
|
|
|
|
|
if (state->isDefault)
|
|
|
|
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_DEFAULT);
|
|
|
|
|
|
|
|
GTK_BUTTON(widget)->relief = relief;
|
|
|
|
|
|
|
|
/* Some theme engines love to cause us pain in that gtk_paint_focus is a
|
|
|
|
no-op on buttons and button-like widgets. They only listen to this flag. */
|
|
|
|
if (state->focused && !state->disabled)
|
|
|
|
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
|
|
|
|
|
|
|
|
if (!interior_focus && state->focused) {
|
|
|
|
x += focus_width + focus_pad;
|
|
|
|
y += focus_width + focus_pad;
|
|
|
|
width -= 2 * (focus_width + focus_pad);
|
|
|
|
height -= 2 * (focus_width + focus_pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
shadow_type = button_state == GTK_STATE_ACTIVE ||
|
|
|
|
state->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
|
|
|
|
if (state->isDefault && relief == GTK_RELIEF_NORMAL) {
|
|
|
|
/* handle default borders both outside and inside the button */
|
|
|
|
gint default_top, default_left, default_bottom, default_right;
|
|
|
|
moz_gtk_button_get_default_overflow(&default_top, &default_left,
|
|
|
|
&default_bottom, &default_right);
|
|
|
|
x -= default_left;
|
|
|
|
y -= default_top;
|
|
|
|
width += default_left + default_right;
|
|
|
|
height += default_top + default_bottom;
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, cliprect,
|
|
|
|
widget, "buttondefault", x, y, width, height);
|
|
|
|
|
|
|
|
moz_gtk_button_get_default_border(&default_top, &default_left,
|
|
|
|
&default_bottom, &default_right);
|
|
|
|
x += default_left;
|
|
|
|
y += default_top;
|
|
|
|
width -= (default_left + default_right);
|
|
|
|
height -= (default_top + default_bottom);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (relief != GTK_RELIEF_NONE || state->depressed ||
|
2009-11-27 03:23:40 +03:00
|
|
|
(button_state != GTK_STATE_NORMAL &&
|
|
|
|
button_state != GTK_STATE_INSENSITIVE)) {
|
2009-07-04 14:01:16 +04:00
|
|
|
TSOffsetStyleGCs(style, x, y);
|
|
|
|
/* the following line can trigger an assertion (Crux theme)
|
|
|
|
file ../../gdk/gdkwindow.c: line 1846 (gdk_window_clear_area):
|
|
|
|
assertion `GDK_IS_WINDOW (window)' failed */
|
|
|
|
gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
|
|
|
|
widget, "button", x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state->focused) {
|
|
|
|
if (interior_focus) {
|
|
|
|
x += widget->style->xthickness + focus_pad;
|
|
|
|
y += widget->style->ythickness + focus_pad;
|
|
|
|
width -= 2 * (widget->style->xthickness + focus_pad);
|
|
|
|
height -= 2 * (widget->style->ythickness + focus_pad);
|
|
|
|
} else {
|
|
|
|
x -= focus_width + focus_pad;
|
|
|
|
y -= focus_width + focus_pad;
|
|
|
|
width += 2 * (focus_width + focus_pad);
|
|
|
|
height += 2 * (focus_width + focus_pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, x, y);
|
|
|
|
gtk_paint_focus(style, drawable, button_state, cliprect,
|
|
|
|
widget, "button", x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_DEFAULT);
|
|
|
|
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2009-01-22 03:07:44 +03:00
|
|
|
gboolean selected, gboolean inconsistent,
|
|
|
|
gboolean isradio, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = (selected)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
|
2005-08-20 11:14:00 +04:00
|
|
|
gint indicator_size, indicator_spacing;
|
2005-08-20 11:11:55 +04:00
|
|
|
gint x, y, width, height;
|
2008-03-07 20:58:11 +03:00
|
|
|
gint focus_x, focus_y, focus_width, focus_height;
|
2005-08-20 11:14:00 +04:00
|
|
|
GtkWidget *w;
|
|
|
|
GtkStyle *style;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
if (isradio) {
|
2005-08-20 11:14:00 +04:00
|
|
|
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
|
|
|
|
w = gRadiobuttonWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
} else {
|
2005-08-20 11:14:00 +04:00
|
|
|
moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
|
|
|
|
w = gCheckboxWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
2013-11-02 16:11:30 +04:00
|
|
|
// XXX we should assert rect->height >= indicator_size too
|
|
|
|
// after bug 369581 is fixed.
|
2015-01-30 02:53:46 +03:00
|
|
|
MOZ_ASSERT(rect->width >= indicator_size,
|
|
|
|
"GetMinimumWidgetSize was ignored");
|
2013-11-02 16:11:30 +04:00
|
|
|
|
|
|
|
// Paint it center aligned in the rect.
|
|
|
|
x = rect->x + (rect->width - indicator_size) / 2;
|
2008-03-13 01:03:51 +03:00
|
|
|
y = rect->y + (rect->height - indicator_size) / 2;
|
2005-08-20 11:11:55 +04:00
|
|
|
width = indicator_size;
|
|
|
|
height = indicator_size;
|
2008-03-07 20:58:11 +03:00
|
|
|
|
|
|
|
focus_x = x - indicator_spacing;
|
|
|
|
focus_y = y - indicator_spacing;
|
|
|
|
focus_width = width + 2 * indicator_spacing;
|
|
|
|
focus_height = height + 2 * indicator_spacing;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
style = w->style;
|
2005-08-20 11:11:55 +04:00
|
|
|
TSOffsetStyleGCs(style, x, y);
|
|
|
|
|
2007-08-26 07:24:51 +04:00
|
|
|
gtk_widget_set_sensitive(w, !state->disabled);
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(w, direction);
|
2005-08-20 11:14:00 +04:00
|
|
|
GTK_TOGGLE_BUTTON(w)->active = selected;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
if (isradio) {
|
|
|
|
gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gRadiobuttonWidget, "radiobutton", x, y,
|
|
|
|
width, height);
|
2007-06-27 10:38:51 +04:00
|
|
|
if (state->focused) {
|
|
|
|
gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
|
2008-03-07 20:58:11 +03:00
|
|
|
gRadiobuttonWidget, "radiobutton", focus_x, focus_y,
|
|
|
|
focus_width, focus_height);
|
2007-06-27 10:38:51 +04:00
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
else {
|
2009-01-22 03:07:44 +03:00
|
|
|
/*
|
|
|
|
* 'indeterminate' type on checkboxes. In GTK, the shadow type
|
|
|
|
* must also be changed for the state to be drawn.
|
|
|
|
*/
|
|
|
|
if (inconsistent) {
|
|
|
|
gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), TRUE);
|
|
|
|
shadow_type = GTK_SHADOW_ETCHED_IN;
|
|
|
|
} else {
|
|
|
|
gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), FALSE);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gCheckboxWidget, "checkbutton", x, y, width, height);
|
2007-06-27 10:38:51 +04:00
|
|
|
if (state->focused) {
|
|
|
|
gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
|
2008-03-07 20:58:11 +03:00
|
|
|
gCheckboxWidget, "checkbutton", focus_x, focus_y,
|
|
|
|
focus_width, focus_height);
|
2007-06-27 10:38:51 +04:00
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
static gint
|
|
|
|
calculate_button_inner_rect(GtkWidget* button, GdkRectangle* rect,
|
|
|
|
GdkRectangle* inner_rect,
|
2008-03-25 03:34:27 +03:00
|
|
|
GtkTextDirection direction,
|
|
|
|
gboolean ignore_focus)
|
2008-03-17 00:05:46 +03:00
|
|
|
{
|
|
|
|
GtkBorder inner_border;
|
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
style = button->style;
|
|
|
|
|
|
|
|
/* This mirrors gtkbutton's child positioning */
|
|
|
|
moz_gtk_button_get_inner_border(button, &inner_border);
|
|
|
|
moz_gtk_widget_get_focus(button, &interior_focus,
|
|
|
|
&focus_width, &focus_pad);
|
|
|
|
|
2008-03-25 03:34:27 +03:00
|
|
|
if (ignore_focus)
|
|
|
|
focus_width = focus_pad = 0;
|
|
|
|
|
|
|
|
inner_rect->x = rect->x + XTHICKNESS(style) + focus_width + focus_pad;
|
2008-03-17 00:05:46 +03:00
|
|
|
inner_rect->x += direction == GTK_TEXT_DIR_LTR ?
|
|
|
|
inner_border.left : inner_border.right;
|
|
|
|
inner_rect->y = rect->y + inner_border.top + YTHICKNESS(style) +
|
|
|
|
focus_width + focus_pad;
|
|
|
|
inner_rect->width = MAX(1, rect->width - inner_border.left -
|
2008-03-25 03:34:27 +03:00
|
|
|
inner_border.right - (XTHICKNESS(style) + focus_pad + focus_width) * 2);
|
2008-03-17 00:05:46 +03:00
|
|
|
inner_rect->height = MAX(1, rect->height - inner_border.top -
|
|
|
|
inner_border.bottom - (YTHICKNESS(style) + focus_pad + focus_width) * 2);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
2008-03-12 13:54:22 +03:00
|
|
|
calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
|
|
|
|
GdkRectangle* arrow_rect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2008-03-11 11:55:54 +03:00
|
|
|
/* defined in gtkarrow.c */
|
|
|
|
gfloat arrow_scaling = 0.7;
|
|
|
|
gfloat xalign, xpad;
|
|
|
|
gint extent;
|
2008-03-12 13:54:22 +03:00
|
|
|
GtkMisc* misc = GTK_MISC(arrow);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
if (have_arrow_scaling)
|
2008-03-12 13:54:22 +03:00
|
|
|
gtk_widget_style_get(arrow, "arrow_scaling", &arrow_scaling, NULL);
|
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
extent = MIN((rect->width - misc->xpad * 2),
|
|
|
|
(rect->height - misc->ypad * 2)) * arrow_scaling;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
xalign = direction == GTK_TEXT_DIR_LTR ? misc->xalign : 1.0 - misc->xalign;
|
|
|
|
xpad = misc->xpad + (rect->width - extent) * xalign;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
arrow_rect->x = direction == GTK_TEXT_DIR_LTR ?
|
|
|
|
floor(rect->x + xpad) : ceil(rect->x + xpad);
|
|
|
|
arrow_rect->y = floor(rect->y + misc->ypad +
|
|
|
|
((rect->height - extent) * misc->yalign));
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
arrow_rect->width = arrow_rect->height = extent;
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2008-01-13 07:13:50 +03:00
|
|
|
GtkScrollbarButtonFlags flags,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = (state->active) ?
|
|
|
|
GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
GdkRectangle arrow_rect;
|
|
|
|
GtkStyle* style;
|
2008-01-13 07:13:50 +03:00
|
|
|
GtkWidget *scrollbar;
|
|
|
|
GtkArrowType arrow_type;
|
2008-03-11 11:55:54 +03:00
|
|
|
gint arrow_displacement_x, arrow_displacement_y;
|
2008-01-13 07:13:50 +03:00
|
|
|
const char* detail = (flags & MOZ_GTK_STEPPER_VERTICAL) ?
|
|
|
|
"vscrollbar" : "hscrollbar";
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
ensure_scrollbar_widget();
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
if (flags & MOZ_GTK_STEPPER_VERTICAL)
|
|
|
|
scrollbar = gVertScrollbarWidget;
|
2005-08-20 11:13:14 +04:00
|
|
|
else
|
2008-01-13 07:13:50 +03:00
|
|
|
scrollbar = gHorizScrollbarWidget;
|
2007-01-17 08:17:46 +03:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
gtk_widget_set_direction(scrollbar, direction);
|
2007-12-19 14:35:35 +03:00
|
|
|
|
2006-04-10 02:51:03 +04:00
|
|
|
/* Some theme engines (i.e., ClearLooks) check the scrollbar's allocation
|
|
|
|
to determine where it should paint rounded corners on the buttons.
|
|
|
|
We need to trick them into drawing the buttons the way we want them. */
|
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
scrollbar->allocation.x = rect->x;
|
|
|
|
scrollbar->allocation.y = rect->y;
|
|
|
|
scrollbar->allocation.width = rect->width;
|
|
|
|
scrollbar->allocation.height = rect->height;
|
|
|
|
|
|
|
|
if (flags & MOZ_GTK_STEPPER_VERTICAL) {
|
|
|
|
scrollbar->allocation.height *= 5;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_DOWN) {
|
|
|
|
arrow_type = GTK_ARROW_DOWN;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
|
|
|
scrollbar->allocation.y -= 4 * rect->height;
|
|
|
|
else
|
|
|
|
scrollbar->allocation.y -= rect->height;
|
2006-04-10 02:51:03 +04:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
} else {
|
|
|
|
arrow_type = GTK_ARROW_UP;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
|
|
|
scrollbar->allocation.y -= 3 * rect->height;
|
|
|
|
}
|
2007-01-17 08:17:46 +03:00
|
|
|
} else {
|
2008-01-13 07:13:50 +03:00
|
|
|
scrollbar->allocation.width *= 5;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_DOWN) {
|
|
|
|
arrow_type = GTK_ARROW_RIGHT;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
|
|
|
scrollbar->allocation.x -= 4 * rect->width;
|
|
|
|
else
|
|
|
|
scrollbar->allocation.x -= rect->width;
|
|
|
|
} else {
|
|
|
|
arrow_type = GTK_ARROW_LEFT;
|
|
|
|
if (flags & MOZ_GTK_STEPPER_BOTTOM)
|
|
|
|
scrollbar->allocation.x -= 3 * rect->width;
|
|
|
|
}
|
2007-01-17 08:17:46 +03:00
|
|
|
}
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2008-01-13 07:13:50 +03:00
|
|
|
style = scrollbar->style;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
|
2008-03-11 11:55:54 +03:00
|
|
|
scrollbar, detail, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
arrow_rect.width = rect->width / 2;
|
|
|
|
arrow_rect.height = rect->height / 2;
|
|
|
|
arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
|
|
|
|
arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
|
|
|
|
|
|
|
|
if (state_type == GTK_STATE_ACTIVE) {
|
|
|
|
gtk_widget_style_get(scrollbar,
|
|
|
|
"arrow-displacement-x", &arrow_displacement_x,
|
|
|
|
"arrow-displacement-y", &arrow_displacement_y,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
arrow_rect.x += arrow_displacement_x;
|
|
|
|
arrow_rect.y += arrow_displacement_y;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
2008-01-13 07:13:50 +03:00
|
|
|
scrollbar, detail, arrow_type, TRUE, arrow_rect.x,
|
|
|
|
arrow_rect.y, arrow_rect.width, arrow_rect.height);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2016-04-14 08:47:20 +03:00
|
|
|
moz_gtk_scrollbar_trough_paint(WidgetNodeType widget,
|
2005-08-20 11:13:14 +04:00
|
|
|
GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
2005-08-20 11:13:14 +04:00
|
|
|
GtkScrollbar *scrollbar;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
ensure_scrollbar_widget();
|
2005-08-20 11:13:14 +04:00
|
|
|
|
2015-12-22 07:05:00 +03:00
|
|
|
if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL)
|
2005-08-20 11:13:14 +04:00
|
|
|
scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
|
|
|
|
else
|
|
|
|
scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
|
|
|
|
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
|
|
|
|
|
2005-08-20 11:13:14 +04:00
|
|
|
style = GTK_WIDGET(scrollbar)->style;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_ACTIVE,
|
|
|
|
cliprect, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
|
2005-08-20 11:13:14 +04:00
|
|
|
GTK_WIDGET(scrollbar), "trough", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
if (state->focused) {
|
|
|
|
gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
|
2005-08-20 11:13:14 +04:00
|
|
|
GTK_WIDGET(scrollbar), "trough",
|
2005-08-20 11:11:55 +04:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2016-04-14 08:47:20 +03:00
|
|
|
moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget,
|
2005-08-20 11:13:14 +04:00
|
|
|
GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = (state->inHover || state->active) ?
|
|
|
|
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
|
2008-02-10 08:26:19 +03:00
|
|
|
GtkShadowType shadow_type = GTK_SHADOW_OUT;
|
2005-08-20 11:11:55 +04:00
|
|
|
GtkStyle* style;
|
2005-08-20 11:13:14 +04:00
|
|
|
GtkScrollbar *scrollbar;
|
|
|
|
GtkAdjustment *adj;
|
2008-02-10 08:26:19 +03:00
|
|
|
gboolean activate_slider;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
ensure_scrollbar_widget();
|
2005-08-20 11:13:14 +04:00
|
|
|
|
|
|
|
if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
|
|
|
|
scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
|
|
|
|
else
|
|
|
|
scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
|
|
|
|
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
|
|
|
|
|
2005-08-20 11:13:14 +04:00
|
|
|
/* Make sure to set the scrollbar range before painting so that
|
|
|
|
everything is drawn properly. At least the bluecurve (and
|
|
|
|
maybe other) themes don't draw the top or bottom black line
|
|
|
|
surrounding the scrollbar if the theme thinks that it's butted
|
|
|
|
up against the scrollbar arrows. Note the increases of the
|
|
|
|
clip rect below. */
|
|
|
|
adj = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
|
|
|
|
|
|
|
|
if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
|
|
|
|
adj->page_size = rect->width;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
adj->page_size = rect->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
adj->lower = 0;
|
|
|
|
adj->value = state->curpos;
|
|
|
|
adj->upper = state->maxpos;
|
|
|
|
gtk_adjustment_changed(adj);
|
|
|
|
|
|
|
|
style = GTK_WIDGET(scrollbar)->style;
|
2008-02-10 08:26:19 +03:00
|
|
|
|
2008-03-12 13:52:02 +03:00
|
|
|
gtk_widget_style_get(GTK_WIDGET(scrollbar), "activate-slider",
|
|
|
|
&activate_slider, NULL);
|
2008-02-10 08:26:19 +03:00
|
|
|
|
|
|
|
if (activate_slider && state->active) {
|
|
|
|
shadow_type = GTK_SHADOW_IN;
|
|
|
|
state_type = GTK_STATE_ACTIVE;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2008-02-10 08:26:19 +03:00
|
|
|
gtk_paint_slider(style, drawable, state_type, shadow_type, cliprect,
|
2005-08-20 11:13:14 +04:00
|
|
|
GTK_WIDGET(scrollbar), "slider", rect->x, rect->y,
|
2005-08-20 11:11:55 +04:00
|
|
|
rect->width, rect->height,
|
2005-08-20 11:13:14 +04:00
|
|
|
(widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
|
2005-08-20 11:11:55 +04:00
|
|
|
GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-13 21:40:49 +04:00
|
|
|
static gint
|
2007-12-21 14:30:00 +03:00
|
|
|
moz_gtk_spin_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GtkTextDirection direction)
|
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_spin_widget();
|
|
|
|
gtk_widget_set_direction(gSpinWidget, direction);
|
|
|
|
style = gSpinWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
|
|
|
|
gSpinWidget, "spinbutton",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_spin_updown_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
gboolean isDown, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2006-07-13 21:40:49 +04:00
|
|
|
{
|
|
|
|
GdkRectangle arrow_rect;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
2007-12-21 14:30:00 +03:00
|
|
|
GtkShadowType shadow_type = state_type == GTK_STATE_ACTIVE ?
|
|
|
|
GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
2006-07-13 21:40:49 +04:00
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_spin_widget();
|
|
|
|
style = gSpinWidget->style;
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gSpinWidget, direction);
|
2006-07-13 21:40:49 +04:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gSpinWidget,
|
|
|
|
isDown ? "spinbutton_down" : "spinbutton_up",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
/* hard code these values */
|
|
|
|
arrow_rect.width = 6;
|
|
|
|
arrow_rect.height = 6;
|
|
|
|
arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
|
|
|
|
arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
|
|
|
|
arrow_rect.y += isDown ? -1 : 1;
|
|
|
|
|
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
|
|
|
|
gSpinWidget, "spinbutton",
|
|
|
|
isDown ? GTK_ARROW_DOWN : GTK_ARROW_UP, TRUE,
|
|
|
|
arrow_rect.x, arrow_rect.y,
|
|
|
|
arrow_rect.width, arrow_rect.height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-19 14:34:49 +03:00
|
|
|
GtkOrientation flags, GtkTextDirection direction)
|
2006-05-30 17:50:48 +04:00
|
|
|
{
|
|
|
|
gint x = 0, y = 0;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkWidget* widget;
|
|
|
|
|
|
|
|
ensure_scale_widget();
|
|
|
|
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(widget, direction);
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
style = widget->style;
|
|
|
|
|
|
|
|
if (flags == GTK_ORIENTATION_HORIZONTAL) {
|
|
|
|
x = XTHICKNESS(style);
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
x++;
|
|
|
|
y = YTHICKNESS(style);
|
|
|
|
}
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
|
|
|
|
widget, "trough", rect->x + x, rect->y + y,
|
|
|
|
rect->width - 2*x, rect->height - 2*y);
|
|
|
|
|
|
|
|
if (state->focused)
|
|
|
|
gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-19 14:34:49 +03:00
|
|
|
GtkOrientation flags, GtkTextDirection direction)
|
2006-05-30 17:50:48 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkWidget* widget;
|
|
|
|
gint thumb_width, thumb_height, x, y;
|
|
|
|
|
|
|
|
ensure_scale_widget();
|
|
|
|
widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(widget, direction);
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
style = widget->style;
|
|
|
|
|
|
|
|
/* determine the thumb size, and position the thumb in the center in the opposite axis */
|
|
|
|
if (flags == GTK_ORIENTATION_HORIZONTAL) {
|
|
|
|
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
|
|
|
|
x = rect->x;
|
|
|
|
y = rect->y + (rect->height - thumb_height) / 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
|
|
|
|
x = rect->x + (rect->width - thumb_width) / 2;
|
|
|
|
y = rect->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
|
|
|
|
widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
|
|
|
|
x, y, thumb_width, thumb_height, flags);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type;
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_handlebox_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gHandleBoxWidget, direction);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
style = gHandleBoxWidget->style;
|
|
|
|
shadow_type = GTK_HANDLE_BOX(gHandleBoxWidget)->shadow_type;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gHandleBoxWidget, "handlebox_bin", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-21 14:17:01 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_hpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state)
|
|
|
|
{
|
|
|
|
GtkStateType hpaned_state = ConvertGtkState(state);
|
|
|
|
|
|
|
|
ensure_hpaned_widget();
|
|
|
|
gtk_paint_handle(gHPanedWidget->style, drawable, hpaned_state,
|
|
|
|
GTK_SHADOW_NONE, cliprect, gHPanedWidget, "paned",
|
|
|
|
rect->x, rect->y, rect->width, rect->height,
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_vpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state)
|
|
|
|
{
|
|
|
|
GtkStateType vpaned_state = ConvertGtkState(state);
|
|
|
|
|
|
|
|
ensure_vpaned_widget();
|
|
|
|
gtk_paint_handle(gVPanedWidget->style, drawable, vpaned_state,
|
|
|
|
GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned",
|
|
|
|
rect->x, rect->y, rect->width, rect->height,
|
|
|
|
GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-21 14:30:00 +03:00
|
|
|
GtkWidget* widget, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2008-02-10 11:30:04 +03:00
|
|
|
GtkStateType bg_state = state->disabled ?
|
|
|
|
GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
|
2008-02-11 09:17:21 +03:00
|
|
|
gint x, y, width = rect->width, height = rect->height;
|
2005-08-20 11:11:55 +04:00
|
|
|
GtkStyle* style;
|
2005-08-20 11:13:15 +04:00
|
|
|
gboolean interior_focus;
|
2008-08-14 12:04:28 +04:00
|
|
|
gboolean theme_honors_transparency = FALSE;
|
2005-08-20 11:13:15 +04:00
|
|
|
gint focus_width;
|
2014-06-14 16:48:08 +04:00
|
|
|
int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2007-12-21 14:30:00 +03:00
|
|
|
gtk_widget_set_direction(widget, direction);
|
2007-12-19 14:35:35 +03:00
|
|
|
|
2007-12-21 14:30:00 +03:00
|
|
|
style = widget->style;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-02-11 09:17:21 +03:00
|
|
|
gtk_widget_style_get(widget,
|
|
|
|
"interior-focus", &interior_focus,
|
|
|
|
"focus-line-width", &focus_width,
|
2008-08-14 12:04:28 +04:00
|
|
|
"honors-transparent-bg-hint", &theme_honors_transparency,
|
2008-02-11 09:17:21 +03:00
|
|
|
NULL);
|
2008-02-10 11:30:04 +03:00
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (draw_focus_outline_only) {
|
|
|
|
// Inflate the given 'rect' with the focus outline size.
|
|
|
|
gint h, v;
|
|
|
|
moz_gtk_get_focus_outline_size(&h, &v);
|
|
|
|
rect->x -= h;
|
|
|
|
rect->width += 2 * h;
|
|
|
|
rect->y -= v;
|
|
|
|
rect->height += 2 * v;
|
|
|
|
width = rect->width;
|
|
|
|
height = rect->height;
|
|
|
|
}
|
|
|
|
|
2008-02-11 09:17:21 +03:00
|
|
|
/* gtkentry.c uses two windows, one for the entire widget and one for the
|
|
|
|
* text area inside it. The background of both windows is set to the "base"
|
|
|
|
* color of the new state in gtk_entry_state_changed, but only the inner
|
|
|
|
* textarea window uses gtk_paint_flat_box when exposed */
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2005-08-20 11:13:15 +04:00
|
|
|
|
2007-06-05 07:26:43 +04:00
|
|
|
/* This gets us a lovely greyish disabledish look */
|
2007-12-21 14:30:00 +03:00
|
|
|
gtk_widget_set_sensitive(widget, !state->disabled);
|
2007-06-05 07:26:43 +04:00
|
|
|
|
2008-08-14 12:04:28 +04:00
|
|
|
/* GTK fills the outer widget window with the base color before drawing the widget.
|
|
|
|
* Some older themes rely on this behavior, but many themes nowadays use rounded
|
|
|
|
* corners on their widgets. While most GTK apps are blissfully unaware of this
|
|
|
|
* problem due to their use of the default window background, we render widgets on
|
|
|
|
* many kinds of backgrounds on the web.
|
|
|
|
* If the theme is able to cope with transparency, then we can skip pre-filling
|
|
|
|
* and notify the theme it will paint directly on the canvas. */
|
|
|
|
if (theme_honors_transparency) {
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
|
2008-08-14 12:04:28 +04:00
|
|
|
} else {
|
2012-11-07 01:52:36 +04:00
|
|
|
GdkRectangle clipped_rect;
|
|
|
|
gdk_rectangle_intersect(rect, cliprect, &clipped_rect);
|
|
|
|
if (clipped_rect.width != 0) {
|
|
|
|
gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE,
|
|
|
|
clipped_rect.x, clipped_rect.y,
|
|
|
|
clipped_rect.width, clipped_rect.height);
|
|
|
|
}
|
2008-12-10 18:53:28 +03:00
|
|
|
g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", GINT_TO_POINTER(FALSE));
|
2008-08-14 12:04:28 +04:00
|
|
|
}
|
2005-08-20 11:13:15 +04:00
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (!draw_focus_outline_only) {
|
|
|
|
/* Get the position of the inner window, see _gtk_entry_get_borders */
|
|
|
|
x = XTHICKNESS(style);
|
|
|
|
y = YTHICKNESS(style);
|
2005-08-20 11:13:15 +04:00
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (!interior_focus) {
|
|
|
|
x += focus_width;
|
|
|
|
y += focus_width;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
/* Simulate an expose of the inner window */
|
|
|
|
gtk_paint_flat_box(style, drawable, bg_state, GTK_SHADOW_NONE,
|
|
|
|
cliprect, widget, "entry_bg", rect->x + x,
|
|
|
|
rect->y + y, rect->width - 2*x, rect->height - 2*y);
|
|
|
|
}
|
2008-02-11 09:17:21 +03:00
|
|
|
|
|
|
|
/* Now paint the shadow and focus border.
|
|
|
|
* We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
|
|
|
|
* smaller when focused if the focus is not interior, then the focus. */
|
2005-08-20 11:13:15 +04:00
|
|
|
x = rect->x;
|
|
|
|
y = rect->y;
|
|
|
|
|
2007-08-26 07:24:51 +04:00
|
|
|
if (state->focused && !state->disabled) {
|
2008-02-11 09:17:21 +03:00
|
|
|
/* This will get us the lit borders that focused textboxes enjoy on
|
|
|
|
* some themes. */
|
2007-12-21 14:30:00 +03:00
|
|
|
GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
|
2007-08-26 07:24:51 +04:00
|
|
|
|
|
|
|
if (!interior_focus) {
|
|
|
|
/* Indent the border a little bit if we have exterior focus
|
|
|
|
(this is what GTK does to draw native entries) */
|
|
|
|
x += focus_width;
|
|
|
|
y += focus_width;
|
|
|
|
width -= 2 * focus_width;
|
|
|
|
height -= 2 * focus_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-14 16:48:08 +04:00
|
|
|
if (!draw_focus_outline_only || interior_focus) {
|
|
|
|
gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
|
|
|
cliprect, widget, "entry", x, y, width, height);
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2007-08-26 07:24:51 +04:00
|
|
|
if (state->focused && !state->disabled) {
|
|
|
|
if (!interior_focus) {
|
|
|
|
gtk_paint_focus(style, drawable, GTK_STATE_NORMAL, cliprect,
|
2007-12-21 14:30:00 +03:00
|
|
|
widget, "entry",
|
2007-08-26 07:24:51 +04:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-02-11 09:17:21 +03:00
|
|
|
/* Now unset the focus flag. We don't want other entries to look
|
|
|
|
* like they're focused too! */
|
2007-12-21 14:30:00 +03:00
|
|
|
GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-07 12:14:58 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2007-11-07 12:14:58 +03:00
|
|
|
{
|
2008-01-27 07:27:35 +03:00
|
|
|
gint xthickness, ythickness;
|
|
|
|
|
2007-11-07 12:14:58 +03:00
|
|
|
GtkStyle *style;
|
|
|
|
GtkStateType state_type;
|
|
|
|
|
|
|
|
ensure_tree_view_widget();
|
2008-02-10 11:36:46 +03:00
|
|
|
ensure_scrolled_window_widget();
|
|
|
|
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gTreeViewWidget, direction);
|
2008-02-10 11:36:46 +03:00
|
|
|
gtk_widget_set_direction(gScrolledWindowWidget, direction);
|
2007-11-07 12:14:58 +03:00
|
|
|
|
|
|
|
/* only handle disabled and normal states, otherwise the whole background
|
|
|
|
* area will be painted differently with other states */
|
|
|
|
state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
|
2007-11-13 13:49:40 +03:00
|
|
|
|
|
|
|
/* In GTK the treeview sets the background of the window
|
|
|
|
* which contains the cells to the treeview base color.
|
|
|
|
* If we don't set it here the background color will not be correct.*/
|
|
|
|
gtk_widget_modify_bg(gTreeViewWidget, state_type,
|
|
|
|
&gTreeViewWidget->style->base[state_type]);
|
|
|
|
|
2008-02-10 11:36:46 +03:00
|
|
|
style = gScrolledWindowWidget->style;
|
2008-01-27 07:27:35 +03:00
|
|
|
xthickness = XTHICKNESS(style);
|
|
|
|
ythickness = YTHICKNESS(style);
|
2007-11-07 12:14:58 +03:00
|
|
|
|
2008-02-10 11:36:46 +03:00
|
|
|
TSOffsetStyleGCs(gTreeViewWidget->style, rect->x, rect->y);
|
2007-11-07 12:14:58 +03:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2008-02-10 11:36:46 +03:00
|
|
|
gtk_paint_flat_box(gTreeViewWidget->style, drawable, state_type,
|
|
|
|
GTK_SHADOW_NONE, cliprect, gTreeViewWidget, "treeview",
|
2008-01-27 07:27:35 +03:00
|
|
|
rect->x + xthickness, rect->y + ythickness,
|
|
|
|
rect->width - 2 * xthickness,
|
|
|
|
rect->height - 2 * ythickness);
|
2007-11-19 06:10:30 +03:00
|
|
|
|
2008-01-27 07:27:35 +03:00
|
|
|
gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
2008-02-10 11:36:46 +03:00
|
|
|
cliprect, gScrolledWindowWidget, "scrolled_window",
|
2008-01-27 07:27:35 +03:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
2007-11-07 12:14:58 +03:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2008-03-18 22:35:23 +03:00
|
|
|
gboolean isSorted, GtkTextDirection direction)
|
2007-11-07 12:14:58 +03:00
|
|
|
{
|
2009-04-06 05:32:20 +04:00
|
|
|
gtk_tree_view_column_set_sort_indicator(gMiddleTreeViewColumn,
|
2008-03-18 22:35:23 +03:00
|
|
|
isSorted);
|
|
|
|
|
2007-11-07 12:14:58 +03:00
|
|
|
moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
|
2007-12-19 14:34:49 +03:00
|
|
|
gTreeHeaderCellWidget, direction);
|
2007-11-07 12:14:58 +03:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-13 11:43:03 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect,
|
|
|
|
GtkWidgetState* state, GtkArrowType flags,
|
|
|
|
GtkTextDirection direction)
|
2007-11-13 11:43:03 +03:00
|
|
|
{
|
|
|
|
GdkRectangle arrow_rect;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = GTK_SHADOW_IN;
|
|
|
|
GtkArrowType arrow_type = flags;
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_tree_header_cell_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gTreeHeaderSortArrowWidget, direction);
|
2007-11-13 11:43:03 +03:00
|
|
|
|
|
|
|
/* hard code these values */
|
|
|
|
arrow_rect.width = 11;
|
|
|
|
arrow_rect.height = 11;
|
|
|
|
arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
|
|
|
|
arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
|
|
|
|
|
|
|
|
style = gTreeHeaderSortArrowWidget->style;
|
|
|
|
TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
|
|
|
|
|
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gTreeHeaderSortArrowWidget, "arrow", arrow_type, TRUE,
|
|
|
|
arrow_rect.x, arrow_rect.y,
|
|
|
|
arrow_rect.width, arrow_rect.height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-01-03 10:07:32 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkExpanderStyle expander_state,
|
|
|
|
GtkTextDirection direction)
|
|
|
|
{
|
|
|
|
GtkStyle *style;
|
|
|
|
GtkStateType state_type;
|
|
|
|
|
|
|
|
ensure_tree_view_widget();
|
|
|
|
gtk_widget_set_direction(gTreeViewWidget, direction);
|
|
|
|
|
|
|
|
style = gTreeViewWidget->style;
|
|
|
|
|
|
|
|
/* Because the frame we get is of the entire treeview, we can't get the precise
|
|
|
|
* event state of one expander, thus rendering hover and active feedback useless. */
|
|
|
|
state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",
|
|
|
|
rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:05 +04:00
|
|
|
static gint
|
2008-03-17 00:05:46 +03:00
|
|
|
moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2008-03-25 03:34:27 +03:00
|
|
|
gboolean ishtml, GtkTextDirection direction)
|
2005-08-20 11:14:05 +04:00
|
|
|
{
|
2008-03-17 00:05:46 +03:00
|
|
|
GdkRectangle arrow_rect, real_arrow_rect;
|
|
|
|
gint arrow_size, separator_width;
|
|
|
|
gboolean wide_separators;
|
2005-08-20 11:14:05 +04:00
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
2008-03-17 00:05:46 +03:00
|
|
|
GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkRequisition arrow_req;
|
2005-08-20 11:14:05 +04:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
ensure_combo_box_widgets();
|
2005-08-20 11:14:05 +04:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
/* Also sets the direction on gComboBoxButtonWidget, which is then
|
|
|
|
* inherited by the separator and arrow */
|
|
|
|
moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
|
|
|
|
gComboBoxButtonWidget, direction);
|
|
|
|
|
|
|
|
calculate_button_inner_rect(gComboBoxButtonWidget,
|
2008-03-25 03:34:27 +03:00
|
|
|
rect, &arrow_rect, direction, ishtml);
|
2008-03-17 00:05:46 +03:00
|
|
|
/* Now arrow_rect contains the inner rect ; we want to correct the width
|
|
|
|
* to what the arrow needs (see gtk_combo_box_size_allocate) */
|
|
|
|
gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
|
|
|
|
if (direction == GTK_TEXT_DIR_LTR)
|
|
|
|
arrow_rect.x += arrow_rect.width - arrow_req.width;
|
|
|
|
arrow_rect.width = arrow_req.width;
|
|
|
|
|
|
|
|
calculate_arrow_rect(gComboBoxArrowWidget,
|
|
|
|
&arrow_rect, &real_arrow_rect, direction);
|
2005-08-20 11:14:05 +04:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
style = gComboBoxArrowWidget->style;
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2005-08-20 11:14:05 +04:00
|
|
|
|
2008-04-08 09:49:18 +04:00
|
|
|
gtk_widget_size_allocate(gComboBoxWidget, rect);
|
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gComboBoxArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
|
|
|
|
real_arrow_rect.x, real_arrow_rect.y,
|
|
|
|
real_arrow_rect.width, real_arrow_rect.height);
|
|
|
|
|
|
|
|
|
|
|
|
/* If there is no separator in the theme, there's nothing left to do. */
|
|
|
|
if (!gComboBoxSeparatorWidget)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
|
|
|
style = gComboBoxSeparatorWidget->style;
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
gtk_widget_style_get(gComboBoxSeparatorWidget,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-width", &separator_width,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (wide_separators) {
|
|
|
|
if (direction == GTK_TEXT_DIR_LTR)
|
|
|
|
arrow_rect.x -= separator_width;
|
|
|
|
else
|
|
|
|
arrow_rect.x += arrow_rect.width;
|
|
|
|
|
|
|
|
gtk_paint_box(style, drawable,
|
|
|
|
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
|
|
|
|
cliprect, gComboBoxSeparatorWidget, "vseparator",
|
|
|
|
arrow_rect.x, arrow_rect.y,
|
|
|
|
separator_width, arrow_rect.height);
|
2005-08-20 11:14:05 +04:00
|
|
|
} else {
|
2008-03-17 00:05:46 +03:00
|
|
|
if (direction == GTK_TEXT_DIR_LTR)
|
|
|
|
arrow_rect.x -= XTHICKNESS(style);
|
|
|
|
else
|
|
|
|
arrow_rect.x += arrow_rect.width;
|
2005-08-20 11:14:05 +04:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
gtk_paint_vline(style, drawable, GTK_STATE_NORMAL, cliprect,
|
|
|
|
gComboBoxSeparatorWidget, "vseparator",
|
|
|
|
arrow_rect.y, arrow_rect.y + arrow_rect.height,
|
|
|
|
arrow_rect.x);
|
2005-08-20 11:14:05 +04:00
|
|
|
}
|
2008-03-17 00:05:46 +03:00
|
|
|
|
2005-08-20 11:14:05 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-01-17 13:24:31 +03:00
|
|
|
static gint
|
2010-07-27 18:57:47 +04:00
|
|
|
moz_gtk_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkArrowType arrow_type, GtkTextDirection direction)
|
2008-01-17 13:24:31 +03:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
GdkRectangle arrow_rect;
|
|
|
|
|
2008-03-12 13:54:22 +03:00
|
|
|
ensure_button_arrow_widget();
|
|
|
|
style = gButtonArrowWidget->style;
|
2010-07-27 18:57:47 +04:00
|
|
|
gtk_widget_set_direction(gButtonArrowWidget, direction);
|
2008-01-17 13:24:31 +03:00
|
|
|
|
2008-03-12 20:27:03 +03:00
|
|
|
calculate_arrow_rect(gButtonArrowWidget, rect, &arrow_rect,
|
2010-07-27 18:57:47 +04:00
|
|
|
direction);
|
|
|
|
|
|
|
|
if (direction == GTK_TEXT_DIR_RTL) {
|
|
|
|
if (arrow_type == GTK_ARROW_LEFT)
|
|
|
|
arrow_type = GTK_ARROW_RIGHT;
|
|
|
|
else if (arrow_type == GTK_ARROW_RIGHT)
|
|
|
|
arrow_type = GTK_ARROW_LEFT;
|
|
|
|
}
|
2008-01-17 13:24:31 +03:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
|
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
2010-07-27 18:57:47 +04:00
|
|
|
gButtonArrowWidget, "arrow", arrow_type, TRUE,
|
2008-01-17 13:24:31 +03:00
|
|
|
arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
2008-03-12 13:54:22 +03:00
|
|
|
moz_gtk_combo_box_entry_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect,
|
|
|
|
GtkWidgetState* state,
|
|
|
|
gboolean input_focus,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2008-03-11 11:55:54 +03:00
|
|
|
gint x_displacement, y_displacement;
|
2005-08-20 11:11:55 +04:00
|
|
|
GdkRectangle arrow_rect, real_arrow_rect;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
GtkStyle* style;
|
|
|
|
|
2008-03-11 11:55:54 +03:00
|
|
|
ensure_combo_box_entry_widgets();
|
2007-12-19 14:35:35 +03:00
|
|
|
|
2008-02-10 11:30:04 +03:00
|
|
|
if (input_focus) {
|
|
|
|
/* Some themes draw a complementary focus ring for the dropdown button
|
|
|
|
* when the dropdown entry has focus */
|
2008-03-12 13:54:22 +03:00
|
|
|
GTK_WIDGET_SET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
|
2008-02-10 11:30:04 +03:00
|
|
|
}
|
|
|
|
|
2007-09-17 00:08:12 +04:00
|
|
|
moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryButtonWidget, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-02-10 11:30:04 +03:00
|
|
|
if (input_focus)
|
2008-03-12 13:54:22 +03:00
|
|
|
GTK_WIDGET_UNSET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
|
2008-02-10 11:30:04 +03:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
calculate_button_inner_rect(gComboBoxEntryButtonWidget,
|
2008-03-25 03:34:27 +03:00
|
|
|
rect, &arrow_rect, direction, FALSE);
|
2008-03-11 11:55:54 +03:00
|
|
|
if (state_type == GTK_STATE_ACTIVE) {
|
2008-03-12 13:54:22 +03:00
|
|
|
gtk_widget_style_get(gComboBoxEntryButtonWidget,
|
2008-03-11 11:55:54 +03:00
|
|
|
"child-displacement-x", &x_displacement,
|
|
|
|
"child-displacement-y", &y_displacement,
|
|
|
|
NULL);
|
|
|
|
arrow_rect.x += x_displacement;
|
|
|
|
arrow_rect.y += y_displacement;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2008-03-12 14:34:34 +03:00
|
|
|
calculate_arrow_rect(gComboBoxEntryArrowWidget,
|
|
|
|
&arrow_rect, &real_arrow_rect, direction);
|
2008-02-27 15:10:24 +03:00
|
|
|
|
2008-03-12 13:54:22 +03:00
|
|
|
style = gComboBoxEntryArrowWidget->style;
|
2008-03-11 11:55:54 +03:00
|
|
|
TSOffsetStyleGCs(style, real_arrow_rect.x, real_arrow_rect.y);
|
2008-02-27 15:10:24 +03:00
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
|
2005-08-20 11:11:55 +04:00
|
|
|
real_arrow_rect.x, real_arrow_rect.y,
|
|
|
|
real_arrow_rect.width, real_arrow_rect.height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_container_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-19 14:34:49 +03:00
|
|
|
gboolean isradio, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkStyle* style;
|
2007-12-19 14:33:45 +03:00
|
|
|
GtkWidget *widget;
|
2005-08-20 11:14:00 +04:00
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
if (isradio) {
|
|
|
|
ensure_radiobutton_widget();
|
2007-12-19 14:33:45 +03:00
|
|
|
widget = gRadiobuttonWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
} else {
|
|
|
|
ensure_checkbox_widget();
|
2007-12-19 14:33:45 +03:00
|
|
|
widget = gCheckboxWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(widget, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2007-12-19 14:33:45 +03:00
|
|
|
style = widget->style;
|
|
|
|
moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width,
|
|
|
|
&focus_pad);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
/* The detail argument for the gtk_paint_* calls below are "checkbutton"
|
|
|
|
even for radio buttons, to match what gtk does. */
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
/* this is for drawing a prelight box */
|
2005-08-20 11:13:51 +04:00
|
|
|
if (state_type == GTK_STATE_PRELIGHT || state_type == GTK_STATE_ACTIVE) {
|
2007-12-19 14:33:45 +03:00
|
|
|
gtk_paint_flat_box(style, drawable, GTK_STATE_PRELIGHT,
|
|
|
|
GTK_SHADOW_ETCHED_OUT, cliprect, widget,
|
2005-08-20 11:13:51 +04:00
|
|
|
"checkbutton",
|
2005-08-20 11:11:55 +04:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:51 +04:00
|
|
|
if (state_type != GTK_STATE_NORMAL && state_type != GTK_STATE_PRELIGHT)
|
|
|
|
state_type = GTK_STATE_NORMAL;
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
if (state->focused && !interior_focus) {
|
2007-12-19 14:33:45 +03:00
|
|
|
gtk_paint_focus(style, drawable, state_type, cliprect, widget,
|
2005-08-20 11:14:00 +04:00
|
|
|
"checkbutton",
|
2005-08-20 11:11:55 +04:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_toggle_label_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-19 14:34:49 +03:00
|
|
|
gboolean isradio, GtkTextDirection direction)
|
2005-08-20 11:14:00 +04:00
|
|
|
{
|
|
|
|
GtkStateType state_type;
|
|
|
|
GtkStyle *style;
|
|
|
|
GtkWidget *widget;
|
|
|
|
gboolean interior_focus;
|
|
|
|
|
|
|
|
if (!state->focused)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
|
|
|
if (isradio) {
|
|
|
|
ensure_radiobutton_widget();
|
|
|
|
widget = gRadiobuttonWidget;
|
|
|
|
} else {
|
|
|
|
ensure_checkbox_widget();
|
|
|
|
widget = gCheckboxWidget;
|
|
|
|
}
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(widget, direction);
|
2005-08-20 11:14:00 +04:00
|
|
|
|
|
|
|
gtk_widget_style_get(widget, "interior-focus", &interior_focus, NULL);
|
|
|
|
if (!interior_focus)
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
|
|
|
state_type = ConvertGtkState(state);
|
|
|
|
|
|
|
|
style = widget->style;
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
/* Always "checkbutton" to match gtkcheckbutton.c */
|
|
|
|
gtk_paint_focus(style, drawable, state_type, cliprect, widget,
|
|
|
|
"checkbutton",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_toolbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
2005-08-20 11:13:48 +04:00
|
|
|
GtkShadowType shadow_type;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
ensure_toolbar_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gToolbarWidget, direction);
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
style = gToolbarWidget->style;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE,
|
|
|
|
GTK_STATE_NORMAL,
|
|
|
|
cliprect, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
2008-03-12 13:57:05 +03:00
|
|
|
gtk_widget_style_get(gToolbarWidget, "shadow-type", &shadow_type, NULL);
|
|
|
|
|
|
|
|
gtk_paint_box (style, drawable, GTK_STATE_NORMAL, shadow_type,
|
2005-08-20 11:13:48 +04:00
|
|
|
cliprect, gToolbarWidget, "toolbar",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-03 12:13:29 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_toolbar_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect,
|
|
|
|
GtkTextDirection direction)
|
2007-12-03 12:13:29 +03:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
gint separator_width;
|
|
|
|
gint paint_width;
|
|
|
|
gboolean wide_separators;
|
|
|
|
|
|
|
|
/* Defined as constants in GTK+ 2.10.14 */
|
|
|
|
const double start_fraction = 0.2;
|
|
|
|
const double end_fraction = 0.8;
|
|
|
|
|
|
|
|
ensure_toolbar_separator_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gToolbarSeparatorWidget, direction);
|
|
|
|
|
2007-12-03 12:13:29 +03:00
|
|
|
style = gToolbarSeparatorWidget->style;
|
|
|
|
|
|
|
|
gtk_widget_style_get(gToolbarWidget,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-width", &separator_width,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
if (wide_separators) {
|
|
|
|
if (separator_width > rect->width)
|
|
|
|
separator_width = rect->width;
|
|
|
|
|
|
|
|
gtk_paint_box(style, drawable,
|
|
|
|
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
|
|
|
|
cliprect, gToolbarWidget, "vseparator",
|
|
|
|
rect->x + (rect->width - separator_width) / 2,
|
|
|
|
rect->y + rect->height * start_fraction,
|
|
|
|
separator_width,
|
|
|
|
rect->height * (end_fraction - start_fraction));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
paint_width = style->xthickness;
|
|
|
|
|
|
|
|
if (paint_width > rect->width)
|
|
|
|
paint_width = rect->width;
|
|
|
|
|
|
|
|
gtk_paint_vline(style, drawable,
|
|
|
|
GTK_STATE_NORMAL, cliprect, gToolbarSeparatorWidget,
|
|
|
|
"toolbar",
|
|
|
|
rect->y + rect->height * start_fraction,
|
|
|
|
rect->y + rect->height * end_fraction,
|
|
|
|
rect->x + (rect->width - paint_width) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_tooltip_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_tooltip_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gTooltipWidget, direction);
|
|
|
|
|
2005-08-20 11:13:16 +04:00
|
|
|
style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
|
|
|
|
"gtk-tooltips", "GtkWindow",
|
|
|
|
GTK_TYPE_WINDOW);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2007-12-19 14:33:45 +03:00
|
|
|
style = gtk_style_attach(style, gTooltipWidget->window);
|
2005-08-20 11:11:55 +04:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
2005-08-20 11:13:16 +04:00
|
|
|
cliprect, gTooltipWidget, "tooltip",
|
2005-08-20 11:11:55 +04:00
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-09 10:32:54 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_resizer_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2007-11-09 10:32:54 +03:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
|
2009-06-27 18:40:12 +04:00
|
|
|
ensure_frame_widget();
|
|
|
|
gtk_widget_set_direction(gStatusbarWidget, direction);
|
2007-12-19 14:35:35 +03:00
|
|
|
|
2009-06-27 18:40:12 +04:00
|
|
|
style = gStatusbarWidget->style;
|
2007-11-09 10:32:54 +03:00
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2009-06-27 18:40:12 +04:00
|
|
|
gtk_paint_resize_grip(style, drawable, state_type, cliprect, gStatusbarWidget,
|
|
|
|
"statusbar", (direction == GTK_TEXT_DIR_LTR) ?
|
2007-12-19 14:35:35 +03:00
|
|
|
GDK_WINDOW_EDGE_SOUTH_EAST :
|
|
|
|
GDK_WINDOW_EDGE_SOUTH_WEST,
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
2007-11-09 10:32:54 +03:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_frame_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2007-11-15 10:35:41 +03:00
|
|
|
GtkStyle* style;
|
|
|
|
GtkShadowType shadow_type;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
ensure_frame_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gFrameWidget, direction);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
style = gFrameWidget->style;
|
|
|
|
|
2007-11-15 10:35:41 +03:00
|
|
|
gtk_widget_style_get(gStatusbarWidget, "shadow-type", &shadow_type, NULL);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2007-11-15 10:35:41 +03:00
|
|
|
gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, shadow_type,
|
2005-08-20 11:11:55 +04:00
|
|
|
cliprect, gFrameWidget, "frame", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_progress_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gProgressWidget, direction);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
style = gProgressWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
|
|
|
cliprect, gProgressWidget, "trough", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2011-05-05 17:11:35 +04:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction,
|
2016-04-14 08:47:20 +03:00
|
|
|
WidgetNodeType widget)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_progress_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gProgressWidget, direction);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
style = gProgressWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2011-05-05 17:11:35 +04:00
|
|
|
|
2011-05-16 14:59:10 +04:00
|
|
|
if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
|
|
|
|
widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
|
2011-05-05 17:11:35 +04:00
|
|
|
/**
|
2011-05-16 14:59:10 +04:00
|
|
|
* The bar's size and the bar speed are set depending of the progress'
|
|
|
|
* size. These could also be constant for all progress bars easily.
|
2011-05-05 17:11:35 +04:00
|
|
|
*/
|
2011-05-16 14:59:10 +04:00
|
|
|
gboolean vertical = (widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE);
|
|
|
|
|
|
|
|
/* The size of the dimension we are going to use for the animation. */
|
|
|
|
const gint progressSize = vertical ? rect->height : rect->width;
|
2011-05-05 17:11:35 +04:00
|
|
|
|
|
|
|
/* The bar is using a fifth of the element size, based on GtkProgressBar
|
|
|
|
* activity-blocks property. */
|
2011-05-16 14:59:10 +04:00
|
|
|
const gint barSize = MAX(1, progressSize / 5);
|
2011-05-05 17:11:35 +04:00
|
|
|
|
|
|
|
/* Represents the travel that has to be done for a complete cycle. */
|
2011-05-16 14:59:10 +04:00
|
|
|
const gint travel = 2 * (progressSize - barSize);
|
2011-05-05 17:11:35 +04:00
|
|
|
|
|
|
|
/* period equals to travel / pixelsPerMillisecond
|
2011-05-16 14:59:10 +04:00
|
|
|
* where pixelsPerMillisecond equals progressSize / 1000.0.
|
2011-05-05 17:11:35 +04:00
|
|
|
* This is equivalent to 1600. */
|
2011-05-16 14:59:10 +04:00
|
|
|
static const guint period = 1600;
|
2011-05-05 17:11:35 +04:00
|
|
|
const gint t = PR_IntervalToMilliseconds(PR_IntervalNow()) % period;
|
|
|
|
const gint dx = travel * t / period;
|
|
|
|
|
2011-05-16 14:59:10 +04:00
|
|
|
if (vertical) {
|
|
|
|
rect->y += (dx < travel / 2) ? dx : travel - dx;
|
|
|
|
rect->height = barSize;
|
|
|
|
} else {
|
|
|
|
rect->x += (dx < travel / 2) ? dx : travel - dx;
|
|
|
|
rect->width = barSize;
|
|
|
|
}
|
2011-05-05 17:11:35 +04:00
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
|
|
|
cliprect, gProgressWidget, "bar", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-21 14:51:48 +03:00
|
|
|
gint
|
2016-08-22 06:13:00 +03:00
|
|
|
moz_gtk_get_tab_thickness(WidgetNodeType aNodeType)
|
2007-12-21 14:51:48 +03:00
|
|
|
{
|
|
|
|
ensure_tab_widget();
|
|
|
|
if (YTHICKNESS(gTabWidget->style) < 2)
|
|
|
|
return 2; /* some themes don't set ythickness correctly */
|
|
|
|
|
|
|
|
return YTHICKNESS(gTabWidget->style);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2010-02-12 01:35:55 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2016-08-22 06:13:00 +03:00
|
|
|
GtkTabFlags flags, GtkTextDirection direction,
|
|
|
|
WidgetNodeType widget)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2007-12-21 14:51:48 +03:00
|
|
|
/* When the tab isn't selected, we just draw a notebook extension.
|
|
|
|
* When it is selected, we overwrite the adjacent border of the tabpanel
|
|
|
|
* touching the tab with a pierced border (called "the gap") to make the
|
|
|
|
* tab appear physically attached to the tabpanel; see details below. */
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
GtkStyle* style;
|
2010-02-12 01:35:55 +03:00
|
|
|
GdkRectangle focusRect;
|
2016-08-22 06:13:00 +03:00
|
|
|
gboolean isBottomTab = (widget == MOZ_GTK_TAB_BOTTOM);
|
2007-12-21 14:51:48 +03:00
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
ensure_tab_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gTabWidget, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
style = gTabWidget->style;
|
2010-02-12 01:35:55 +03:00
|
|
|
focusRect = *rect;
|
2005-08-20 11:11:55 +04:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
2007-12-21 14:51:48 +03:00
|
|
|
if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
|
|
|
|
/* Only draw the tab */
|
|
|
|
gtk_paint_extension(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
|
2005-08-20 11:11:55 +04:00
|
|
|
cliprect, gTabWidget, "tab",
|
2007-12-21 14:51:48 +03:00
|
|
|
rect->x, rect->y, rect->width, rect->height,
|
2016-08-22 06:13:00 +03:00
|
|
|
isBottomTab ? GTK_POS_TOP : GTK_POS_BOTTOM );
|
2007-12-21 14:51:48 +03:00
|
|
|
} else {
|
|
|
|
/* Draw the tab and the gap
|
2009-07-27 12:47:05 +04:00
|
|
|
* We want the gap to be positioned exactly on the tabpanel top
|
2007-12-21 14:51:48 +03:00
|
|
|
* border; since tabbox.css may set a negative margin so that the tab
|
|
|
|
* frame rect already overlaps the tabpanel frame rect, we need to take
|
|
|
|
* that into account when drawing. To that effect, nsNativeThemeGTK
|
|
|
|
* passes us this negative margin (bmargin in the graphic below) in the
|
|
|
|
* lowest bits of |flags|. We use it to set gap_voffset, the distance
|
|
|
|
* between the top of the gap and the bottom of the tab (resp. the
|
|
|
|
* bottom of the gap and the top of the tab when we draw a bottom tab),
|
|
|
|
* while ensuring that the gap always touches the border of the tab,
|
|
|
|
* i.e. 0 <= gap_voffset <= gap_height, to avoid surprinsing results
|
|
|
|
* with big negative or positive margins.
|
|
|
|
* Here is a graphical explanation in the case of top tabs:
|
|
|
|
* ___________________________
|
|
|
|
* / \
|
|
|
|
* | T A B |
|
|
|
|
* ----------|. . . . . . . . . . . . . . .|----- top of tabpanel
|
|
|
|
* : ^ bmargin : ^
|
|
|
|
* : | (-negative margin, : |
|
|
|
|
* bottom : v passed in flags) : | gap_height
|
|
|
|
* of -> :.............................: | (the size of the
|
|
|
|
* the tab . part of the gap . | tabpanel top border)
|
|
|
|
* . outside of the tab . v
|
|
|
|
* ----------------------------------------------
|
|
|
|
*
|
|
|
|
* To draw the gap, we use gtk_paint_box_gap(), see comment in
|
|
|
|
* moz_gtk_tabpanels_paint(). This box_gap is made 3 * gap_height tall,
|
|
|
|
* which should suffice to ensure that the only visible border is the
|
|
|
|
* pierced one. If the tab is in the middle, we make the box_gap begin
|
|
|
|
* a bit to the left of the tab and end a bit to the right, adjusting
|
|
|
|
* the gap position so it still is under the tab, because we want the
|
|
|
|
* rendering of a gap in the middle of a tabpanel. This is the role of
|
|
|
|
* the gints gap_{l,r}_offset. On the contrary, if the tab is the
|
|
|
|
* first, we align the start border of the box_gap with the start
|
|
|
|
* border of the tab (left if LTR, right if RTL), by setting the
|
|
|
|
* appropriate offset to 0.*/
|
|
|
|
gint gap_loffset, gap_roffset, gap_voffset, gap_height;
|
|
|
|
|
|
|
|
/* Get height needed by the gap */
|
2016-08-22 06:13:00 +03:00
|
|
|
gap_height = moz_gtk_get_tab_thickness(widget);
|
2007-12-21 14:51:48 +03:00
|
|
|
|
|
|
|
/* Extract gap_voffset from the first bits of flags */
|
|
|
|
gap_voffset = flags & MOZ_GTK_TAB_MARGIN_MASK;
|
|
|
|
if (gap_voffset > gap_height)
|
|
|
|
gap_voffset = gap_height;
|
|
|
|
|
|
|
|
/* Set gap_{l,r}_offset to appropriate values */
|
|
|
|
gap_loffset = gap_roffset = 20; /* should be enough */
|
|
|
|
if (flags & MOZ_GTK_TAB_FIRST) {
|
|
|
|
if (direction == GTK_TEXT_DIR_RTL)
|
|
|
|
gap_roffset = 0;
|
|
|
|
else
|
|
|
|
gap_loffset = 0;
|
|
|
|
}
|
|
|
|
|
2016-08-22 06:13:00 +03:00
|
|
|
if (isBottomTab) {
|
2007-12-21 14:51:48 +03:00
|
|
|
/* Draw the tab */
|
2010-02-12 01:35:55 +03:00
|
|
|
focusRect.y += gap_voffset;
|
|
|
|
focusRect.height -= gap_voffset;
|
2007-12-21 14:51:48 +03:00
|
|
|
gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
|
|
|
|
rect->x, rect->y + gap_voffset, rect->width,
|
|
|
|
rect->height - gap_voffset, GTK_POS_TOP);
|
|
|
|
|
|
|
|
/* Draw the gap; erase with background color before painting in
|
|
|
|
* case theme does not */
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE,
|
|
|
|
GTK_STATE_NORMAL, cliprect,
|
|
|
|
rect->x,
|
|
|
|
rect->y + gap_voffset
|
|
|
|
- gap_height,
|
|
|
|
rect->width, gap_height);
|
|
|
|
gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
|
|
|
cliprect, gTabWidget, "notebook",
|
|
|
|
rect->x - gap_loffset,
|
|
|
|
rect->y + gap_voffset - 3 * gap_height,
|
|
|
|
rect->width + gap_loffset + gap_roffset,
|
|
|
|
3 * gap_height, GTK_POS_BOTTOM,
|
|
|
|
gap_loffset, rect->width);
|
|
|
|
} else {
|
|
|
|
/* Draw the tab */
|
2010-02-12 01:35:55 +03:00
|
|
|
focusRect.height -= gap_voffset;
|
2007-12-21 14:51:48 +03:00
|
|
|
gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
|
|
|
|
GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
|
|
|
|
rect->x, rect->y, rect->width,
|
|
|
|
rect->height - gap_voffset, GTK_POS_BOTTOM);
|
|
|
|
|
|
|
|
/* Draw the gap; erase with background color before painting in
|
|
|
|
* case theme does not */
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE,
|
|
|
|
GTK_STATE_NORMAL, cliprect,
|
|
|
|
rect->x,
|
|
|
|
rect->y + rect->height
|
|
|
|
- gap_voffset,
|
|
|
|
rect->width, gap_height);
|
|
|
|
gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
|
|
|
cliprect, gTabWidget, "notebook",
|
|
|
|
rect->x - gap_loffset,
|
|
|
|
rect->y + rect->height - gap_voffset,
|
|
|
|
rect->width + gap_loffset + gap_roffset,
|
|
|
|
3 * gap_height, GTK_POS_TOP,
|
|
|
|
gap_loffset, rect->width);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
}
|
|
|
|
|
2010-02-12 01:35:55 +03:00
|
|
|
if (state->focused) {
|
|
|
|
/* Paint the focus ring */
|
|
|
|
focusRect.x += XTHICKNESS(style);
|
|
|
|
focusRect.width -= XTHICKNESS(style) * 2;
|
|
|
|
focusRect.y += YTHICKNESS(style);
|
|
|
|
focusRect.height -= YTHICKNESS(style) * 2;
|
|
|
|
|
|
|
|
gtk_paint_focus(style, drawable,
|
|
|
|
/* Believe it or not, NORMAL means a selected tab and
|
|
|
|
ACTIVE means an unselected tab. */
|
|
|
|
(flags & MOZ_GTK_TAB_SELECTED) ? GTK_STATE_NORMAL
|
|
|
|
: GTK_STATE_ACTIVE,
|
|
|
|
cliprect, gTabWidget, "tab",
|
|
|
|
focusRect.x, focusRect.y, focusRect.width, focusRect.height);
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_tabpanels_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
2009-07-09 13:15:48 +04:00
|
|
|
/* We have three problems here:
|
|
|
|
* - Most engines draw gtk_paint_box differently to gtk_paint_box_gap, the
|
|
|
|
* former implies there are no tabs, eg. Clearlooks.
|
|
|
|
* - Wanting a gap of width 0 doesn't actually guarantee a zero-width gap, eg.
|
|
|
|
* Clearlooks.
|
|
|
|
* - Our old approach of a negative X position could cause rendering errors
|
|
|
|
* on the box's corner, eg. themes using the Pixbuf engine.
|
|
|
|
*/
|
2005-08-20 11:11:55 +04:00
|
|
|
GtkStyle* style;
|
2009-07-17 18:22:11 +04:00
|
|
|
GdkRectangle halfClipRect;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
ensure_tab_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gTabWidget, direction);
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
style = gTabWidget->style;
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2009-07-09 13:15:48 +04:00
|
|
|
|
|
|
|
/* Our approach is as follows:
|
|
|
|
* - Draw the box in two passes. Pass in a clip rect to draw the left half of the
|
|
|
|
* box, with the gap specified to the right outside the clip rect so that it is
|
|
|
|
* not drawn.
|
|
|
|
* - The right half is drawn with the gap to the left outside the modified clip rect.
|
|
|
|
*/
|
|
|
|
if (!gdk_rectangle_intersect(rect, cliprect, &halfClipRect))
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
|
|
|
|
halfClipRect.width = (halfClipRect.width / 2) + 1;
|
|
|
|
gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
|
|
|
&halfClipRect, gTabWidget, "notebook", rect->x, rect->y,
|
|
|
|
rect->width, rect->height,
|
|
|
|
GTK_POS_TOP, halfClipRect.width + 1, 0);
|
|
|
|
|
|
|
|
halfClipRect.x += halfClipRect.width;
|
2007-12-21 14:51:48 +03:00
|
|
|
gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
2009-07-09 13:15:48 +04:00
|
|
|
&halfClipRect, gTabWidget, "notebook", rect->x, rect->y,
|
2007-12-21 14:51:48 +03:00
|
|
|
rect->width, rect->height,
|
|
|
|
GTK_POS_TOP, -10, 0);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-15 08:28:44 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_tab_scroll_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkArrowType arrow_type,
|
|
|
|
GtkTextDirection direction)
|
|
|
|
{
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
|
|
|
GtkStyle* style;
|
|
|
|
gint arrow_size = MIN(rect->width, rect->height);
|
|
|
|
gint x = rect->x + (rect->width - arrow_size) / 2;
|
|
|
|
gint y = rect->y + (rect->height - arrow_size) / 2;
|
|
|
|
|
|
|
|
ensure_tab_widget();
|
|
|
|
|
|
|
|
style = gTabWidget->style;
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
if (direction == GTK_TEXT_DIR_RTL) {
|
|
|
|
arrow_type = (arrow_type == GTK_ARROW_LEFT) ?
|
|
|
|
GTK_ARROW_RIGHT : GTK_ARROW_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
|
|
|
|
gTabWidget, "notebook", arrow_type, TRUE,
|
|
|
|
x, y, arrow_size, arrow_size);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_menu_bar_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:13:48 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkShadowType shadow_type;
|
|
|
|
ensure_menu_bar_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gMenuBarWidget, direction);
|
|
|
|
|
2008-03-12 13:57:05 +03:00
|
|
|
gtk_widget_style_get(gMenuBarWidget, "shadow-type", &shadow_type, NULL);
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
style = gMenuBarWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
|
|
|
|
cliprect, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
2008-03-12 13:57:05 +03:00
|
|
|
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, shadow_type,
|
2005-08-20 11:13:48 +04:00
|
|
|
cliprect, gMenuBarWidget, "menubar", rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
moz_gtk_menu_popup_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:13:48 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
ensure_menu_popup_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gMenuPopupWidget, direction);
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
style = gMenuPopupWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
|
|
|
|
cliprect, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
|
|
|
cliprect, gMenuPopupWidget, "menu",
|
|
|
|
rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-11 12:09:09 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_menu_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2007-12-11 12:09:09 +03:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
gboolean wide_separators;
|
|
|
|
gint separator_height;
|
|
|
|
guint horizontal_padding;
|
|
|
|
gint paint_height;
|
|
|
|
|
|
|
|
ensure_menu_separator_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gMenuSeparatorWidget, direction);
|
2007-12-11 12:09:09 +03:00
|
|
|
|
|
|
|
style = gMenuSeparatorWidget->style;
|
|
|
|
|
|
|
|
gtk_widget_style_get(gMenuSeparatorWidget,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-height", &separator_height,
|
|
|
|
"horizontal-padding", &horizontal_padding,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
|
|
|
|
if (wide_separators) {
|
|
|
|
if (separator_height > rect->height)
|
|
|
|
separator_height = rect->height;
|
|
|
|
|
|
|
|
gtk_paint_box(style, drawable,
|
|
|
|
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
|
|
|
|
cliprect, gMenuSeparatorWidget, "hseparator",
|
|
|
|
rect->x + horizontal_padding + style->xthickness,
|
|
|
|
rect->y + (rect->height - separator_height - style->ythickness) / 2,
|
|
|
|
rect->width - 2 * (horizontal_padding + style->xthickness),
|
|
|
|
separator_height);
|
|
|
|
} else {
|
|
|
|
paint_height = style->ythickness;
|
|
|
|
if (paint_height > rect->height)
|
|
|
|
paint_height = rect->height;
|
|
|
|
|
|
|
|
gtk_paint_hline(style, drawable,
|
|
|
|
GTK_STATE_NORMAL, cliprect, gMenuSeparatorWidget,
|
|
|
|
"menuitem",
|
|
|
|
rect->x + horizontal_padding + style->xthickness,
|
|
|
|
rect->x + rect->width - horizontal_padding - style->xthickness - 1,
|
|
|
|
rect->y + (rect->height - style->ythickness) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
static gint
|
2016-05-19 07:55:04 +03:00
|
|
|
moz_gtk_menu_item_paint(WidgetNodeType widget, GdkDrawable* drawable,
|
|
|
|
GdkRectangle* rect, GdkRectangle* cliprect,
|
|
|
|
GtkWidgetState* state, GtkTextDirection direction)
|
2005-08-20 11:13:48 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkShadowType shadow_type;
|
2007-12-04 09:28:34 +03:00
|
|
|
GtkWidget* item_widget;
|
2005-08-20 11:13:48 +04:00
|
|
|
|
|
|
|
if (state->inHover && !state->disabled) {
|
2016-05-19 07:55:04 +03:00
|
|
|
if (widget == MOZ_GTK_MENUBARITEM) {
|
2007-12-04 09:28:34 +03:00
|
|
|
ensure_menu_bar_item_widget();
|
|
|
|
item_widget = gMenuBarItemWidget;
|
|
|
|
} else {
|
|
|
|
ensure_menu_item_widget();
|
|
|
|
item_widget = gMenuItemWidget;
|
|
|
|
}
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(item_widget, direction);
|
2007-12-04 09:28:34 +03:00
|
|
|
|
|
|
|
style = item_widget->style;
|
2005-08-20 11:13:48 +04:00
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
2008-03-12 13:57:05 +03:00
|
|
|
|
|
|
|
gtk_widget_style_get(item_widget, "selected-shadow-type",
|
|
|
|
&shadow_type, NULL);
|
2005-08-20 11:14:10 +04:00
|
|
|
|
2005-08-20 11:13:48 +04:00
|
|
|
gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, shadow_type,
|
2007-12-04 09:28:34 +03:00
|
|
|
cliprect, item_widget, "menuitem", rect->x, rect->y,
|
2005-08-20 11:13:48 +04:00
|
|
|
rect->width, rect->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-29 01:45:21 +03:00
|
|
|
static gint
|
|
|
|
moz_gtk_menu_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-14 10:26:03 +03:00
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
|
|
|
GtkTextDirection direction)
|
2007-11-29 01:45:21 +03:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
|
|
|
|
|
|
|
ensure_menu_item_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gMenuItemWidget, direction);
|
|
|
|
|
2007-11-29 01:45:21 +03:00
|
|
|
style = gMenuItemWidget->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_paint_arrow(style, drawable, state_type,
|
|
|
|
(state_type == GTK_STATE_PRELIGHT) ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
|
|
|
|
cliprect, gMenuItemWidget, "menuitem",
|
2007-12-14 10:26:03 +03:00
|
|
|
(direction == GTK_TEXT_DIR_LTR) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT,
|
2007-11-29 01:45:21 +03:00
|
|
|
TRUE, rect->x, rect->y, rect->width, rect->height);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_check_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|
|
|
GdkRectangle* cliprect, GtkWidgetState* state,
|
2007-12-19 14:34:49 +03:00
|
|
|
gboolean checked, gboolean isradio,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:14:21 +04:00
|
|
|
{
|
2007-12-14 10:02:05 +03:00
|
|
|
GtkStateType state_type = ConvertGtkState(state);
|
2005-08-20 11:14:21 +04:00
|
|
|
GtkStyle* style;
|
|
|
|
GtkShadowType shadow_type = (checked)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
|
|
|
|
gint offset;
|
2011-06-25 01:00:46 +04:00
|
|
|
gint indicator_size, horizontal_padding;
|
2005-08-20 11:14:21 +04:00
|
|
|
gint x, y;
|
2007-12-14 10:26:03 +03:00
|
|
|
|
2016-05-19 07:55:04 +03:00
|
|
|
moz_gtk_menu_item_paint(MOZ_GTK_MENUITEM, drawable, rect, cliprect, state,
|
|
|
|
direction);
|
2007-12-14 10:26:03 +03:00
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
ensure_check_menu_item_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gCheckMenuItemWidget, direction);
|
2005-08-20 11:14:21 +04:00
|
|
|
|
2007-11-29 01:46:14 +03:00
|
|
|
gtk_widget_style_get (gCheckMenuItemWidget,
|
|
|
|
"indicator-size", &indicator_size,
|
2011-06-25 01:00:46 +04:00
|
|
|
"horizontal-padding", &horizontal_padding,
|
2007-11-29 01:46:14 +03:00
|
|
|
NULL);
|
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
if (checked || GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget)->always_show_toggle) {
|
|
|
|
style = gCheckMenuItemWidget->style;
|
2007-12-14 10:26:03 +03:00
|
|
|
|
|
|
|
offset = GTK_CONTAINER(gCheckMenuItemWidget)->border_width +
|
2005-08-20 11:14:21 +04:00
|
|
|
gCheckMenuItemWidget->style->xthickness + 2;
|
2007-12-03 12:16:15 +03:00
|
|
|
|
2007-12-14 10:26:03 +03:00
|
|
|
x = (direction == GTK_TEXT_DIR_RTL) ?
|
2011-06-25 01:00:46 +04:00
|
|
|
rect->width - indicator_size - offset - horizontal_padding: rect->x + offset + horizontal_padding;
|
2005-08-20 11:14:21 +04:00
|
|
|
y = rect->y + (rect->height - indicator_size) / 2;
|
2007-12-14 10:26:03 +03:00
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
TSOffsetStyleGCs(style, x, y);
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget),
|
|
|
|
checked);
|
2007-12-14 10:26:03 +03:00
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
if (isradio) {
|
|
|
|
gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gCheckMenuItemWidget, "option",
|
|
|
|
x, y, indicator_size, indicator_size);
|
|
|
|
} else {
|
|
|
|
gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
|
|
|
|
gCheckMenuItemWidget, "check",
|
|
|
|
x, y, indicator_size, indicator_size);
|
|
|
|
}
|
|
|
|
}
|
2007-12-14 10:26:03 +03:00
|
|
|
|
2005-08-20 11:14:21 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:13:45 +04:00
|
|
|
static gint
|
|
|
|
moz_gtk_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GdkRectangle* cliprect, GtkTextDirection direction)
|
2005-08-20 11:13:45 +04:00
|
|
|
{
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_window_widget();
|
2007-12-19 14:35:35 +03:00
|
|
|
gtk_widget_set_direction(gProtoWindow, direction);
|
|
|
|
|
2005-08-20 11:13:45 +04:00
|
|
|
style = gProtoWindow->style;
|
|
|
|
|
|
|
|
TSOffsetStyleGCs(style, rect->x, rect->y);
|
|
|
|
gtk_style_apply_default_background(style, drawable, TRUE,
|
|
|
|
GTK_STATE_NORMAL,
|
|
|
|
cliprect, rect->x, rect->y,
|
|
|
|
rect->width, rect->height);
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
2016-04-14 08:47:20 +03:00
|
|
|
moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
|
2007-12-14 10:26:03 +03:00
|
|
|
gint* right, gint* bottom, GtkTextDirection direction,
|
|
|
|
gboolean inhtml)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
GtkWidget* w;
|
2005-08-20 11:13:48 +04:00
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
switch (widget) {
|
|
|
|
case MOZ_GTK_BUTTON:
|
2015-10-01 05:30:00 +03:00
|
|
|
case MOZ_GTK_TOOLBAR_BUTTON:
|
2005-08-20 11:14:07 +04:00
|
|
|
{
|
2008-02-07 12:27:27 +03:00
|
|
|
GtkBorder inner_border;
|
2005-08-20 11:14:07 +04:00
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
|
|
|
|
ensure_button_widget();
|
2007-06-05 07:26:43 +04:00
|
|
|
*left = *top = *right = *bottom = GTK_CONTAINER(gButtonWidget)->border_width;
|
|
|
|
|
|
|
|
/* Don't add this padding in HTML, otherwise the buttons will
|
|
|
|
become too big and stuff the layout. */
|
|
|
|
if (!inhtml) {
|
2007-11-07 12:14:58 +03:00
|
|
|
moz_gtk_widget_get_focus(gButtonWidget, &interior_focus, &focus_width, &focus_pad);
|
2008-02-07 12:27:27 +03:00
|
|
|
moz_gtk_button_get_inner_border(gButtonWidget, &inner_border);
|
|
|
|
*left += focus_width + focus_pad + inner_border.left;
|
|
|
|
*right += focus_width + focus_pad + inner_border.right;
|
|
|
|
*top += focus_width + focus_pad + inner_border.top;
|
|
|
|
*bottom += focus_width + focus_pad + inner_border.bottom;
|
2007-06-05 07:26:43 +04:00
|
|
|
}
|
2005-08-20 11:14:07 +04:00
|
|
|
|
2007-06-05 07:26:43 +04:00
|
|
|
*left += gButtonWidget->style->xthickness;
|
|
|
|
*right += gButtonWidget->style->xthickness;
|
|
|
|
*top += gButtonWidget->style->ythickness;
|
|
|
|
*bottom += gButtonWidget->style->ythickness;
|
2005-08-20 11:14:07 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_ENTRY:
|
|
|
|
ensure_entry_widget();
|
|
|
|
w = gEntryWidget;
|
|
|
|
break;
|
2007-11-07 12:14:58 +03:00
|
|
|
case MOZ_GTK_TREEVIEW:
|
|
|
|
ensure_tree_view_widget();
|
|
|
|
w = gTreeViewWidget;
|
|
|
|
break;
|
|
|
|
case MOZ_GTK_TREE_HEADER_CELL:
|
|
|
|
{
|
|
|
|
/* A Tree Header in GTK is just a different styled button
|
|
|
|
* It must be placed in a TreeView for getting the correct style
|
|
|
|
* assigned.
|
|
|
|
* That is why the following code is the same as for MOZ_GTK_BUTTON.
|
|
|
|
* */
|
|
|
|
|
2008-02-07 12:27:27 +03:00
|
|
|
GtkBorder inner_border;
|
2007-11-07 12:14:58 +03:00
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
|
|
|
|
ensure_tree_header_cell_widget();
|
|
|
|
*left = *top = *right = *bottom = GTK_CONTAINER(gTreeHeaderCellWidget)->border_width;
|
|
|
|
|
2008-02-07 12:27:27 +03:00
|
|
|
moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
|
|
|
|
moz_gtk_button_get_inner_border(gTreeHeaderCellWidget, &inner_border);
|
|
|
|
*left += focus_width + focus_pad + inner_border.left;
|
|
|
|
*right += focus_width + focus_pad + inner_border.right;
|
|
|
|
*top += focus_width + focus_pad + inner_border.top;
|
|
|
|
*bottom += focus_width + focus_pad + inner_border.bottom;
|
2007-11-07 12:14:58 +03:00
|
|
|
|
|
|
|
*left += gTreeHeaderCellWidget->style->xthickness;
|
|
|
|
*right += gTreeHeaderCellWidget->style->xthickness;
|
|
|
|
*top += gTreeHeaderCellWidget->style->ythickness;
|
|
|
|
*bottom += gTreeHeaderCellWidget->style->ythickness;
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
2007-11-13 11:43:03 +03:00
|
|
|
case MOZ_GTK_TREE_HEADER_SORTARROW:
|
|
|
|
ensure_tree_header_cell_widget();
|
|
|
|
w = gTreeHeaderSortArrowWidget;
|
|
|
|
break;
|
2008-01-14 14:12:29 +03:00
|
|
|
case MOZ_GTK_DROPDOWN_ENTRY:
|
2008-03-11 11:55:54 +03:00
|
|
|
ensure_combo_box_entry_widgets();
|
2008-03-12 13:54:22 +03:00
|
|
|
w = gComboBoxEntryTextareaWidget;
|
2008-01-14 14:12:29 +03:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_DROPDOWN_ARROW:
|
2008-03-11 11:55:54 +03:00
|
|
|
ensure_combo_box_entry_widgets();
|
2008-03-12 13:54:22 +03:00
|
|
|
w = gComboBoxEntryButtonWidget;
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2005-08-20 11:14:05 +04:00
|
|
|
case MOZ_GTK_DROPDOWN:
|
2007-06-05 07:26:43 +04:00
|
|
|
{
|
2008-03-17 00:05:46 +03:00
|
|
|
/* We need to account for the arrow on the dropdown, so text
|
|
|
|
* doesn't come too close to the arrow, or in some cases spill
|
|
|
|
* into the arrow. */
|
2008-03-25 03:34:27 +03:00
|
|
|
gboolean ignored_interior_focus, wide_separators;
|
|
|
|
gint focus_width, focus_pad, separator_width;
|
2008-03-17 00:05:46 +03:00
|
|
|
GtkRequisition arrow_req;
|
|
|
|
|
|
|
|
ensure_combo_box_widgets();
|
|
|
|
|
2008-03-25 03:34:27 +03:00
|
|
|
*left = GTK_CONTAINER(gComboBoxButtonWidget)->border_width;
|
|
|
|
|
|
|
|
if (!inhtml) {
|
|
|
|
moz_gtk_widget_get_focus(gComboBoxButtonWidget,
|
|
|
|
&ignored_interior_focus,
|
|
|
|
&focus_width, &focus_pad);
|
|
|
|
*left += focus_width + focus_pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
*top = *left + gComboBoxButtonWidget->style->ythickness;
|
|
|
|
*left += gComboBoxButtonWidget->style->xthickness;
|
|
|
|
|
|
|
|
*right = *left; *bottom = *top;
|
2008-03-17 00:05:46 +03:00
|
|
|
|
|
|
|
/* If there is no separator, don't try to count its width. */
|
|
|
|
separator_width = 0;
|
|
|
|
if (gComboBoxSeparatorWidget) {
|
|
|
|
gtk_widget_style_get(gComboBoxSeparatorWidget,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-width", &separator_width,
|
|
|
|
NULL);
|
2007-06-05 07:26:43 +04:00
|
|
|
|
2008-03-17 00:05:46 +03:00
|
|
|
if (!wide_separators)
|
|
|
|
separator_width =
|
|
|
|
XTHICKNESS(gComboBoxSeparatorWidget->style);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
|
2007-06-05 07:26:43 +04:00
|
|
|
|
2007-12-14 10:26:03 +03:00
|
|
|
if (direction == GTK_TEXT_DIR_RTL)
|
2008-03-17 00:05:46 +03:00
|
|
|
*left += separator_width + arrow_req.width;
|
2007-06-05 07:26:43 +04:00
|
|
|
else
|
2008-03-17 00:05:46 +03:00
|
|
|
*right += separator_width + arrow_req.width;
|
|
|
|
|
2007-06-05 07:26:43 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_TABPANELS:
|
|
|
|
ensure_tab_widget();
|
|
|
|
w = gTabWidget;
|
|
|
|
break;
|
|
|
|
case MOZ_GTK_PROGRESSBAR:
|
|
|
|
ensure_progress_widget();
|
|
|
|
w = gProgressWidget;
|
|
|
|
break;
|
2007-12-21 14:30:00 +03:00
|
|
|
case MOZ_GTK_SPINBUTTON_ENTRY:
|
2006-07-13 21:40:49 +04:00
|
|
|
case MOZ_GTK_SPINBUTTON_UP:
|
|
|
|
case MOZ_GTK_SPINBUTTON_DOWN:
|
|
|
|
ensure_spin_widget();
|
|
|
|
w = gSpinWidget;
|
|
|
|
break;
|
2006-05-30 17:50:48 +04:00
|
|
|
case MOZ_GTK_SCALE_HORIZONTAL:
|
|
|
|
ensure_scale_widget();
|
|
|
|
w = gHScaleWidget;
|
|
|
|
break;
|
|
|
|
case MOZ_GTK_SCALE_VERTICAL:
|
|
|
|
ensure_scale_widget();
|
|
|
|
w = gVScaleWidget;
|
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_FRAME:
|
|
|
|
ensure_frame_widget();
|
|
|
|
w = gFrameWidget;
|
|
|
|
break;
|
2005-08-20 11:14:00 +04:00
|
|
|
case MOZ_GTK_CHECKBUTTON_LABEL:
|
|
|
|
case MOZ_GTK_RADIOBUTTON_LABEL:
|
|
|
|
{
|
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
|
|
|
|
/* If the focus is interior, then the label has a border of
|
|
|
|
(focus_width + focus_pad). */
|
2007-11-07 12:14:58 +03:00
|
|
|
if (widget == MOZ_GTK_CHECKBUTTON_LABEL) {
|
|
|
|
ensure_checkbox_widget();
|
|
|
|
moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
|
2005-08-20 11:14:00 +04:00
|
|
|
&focus_width, &focus_pad);
|
2007-11-07 12:14:58 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ensure_radiobutton_widget();
|
|
|
|
moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
|
2005-08-20 11:14:00 +04:00
|
|
|
&focus_width, &focus_pad);
|
2007-11-07 12:14:58 +03:00
|
|
|
}
|
2005-08-20 11:14:00 +04:00
|
|
|
|
|
|
|
if (interior_focus)
|
2007-06-05 07:26:43 +04:00
|
|
|
*left = *top = *right = *bottom = (focus_width + focus_pad);
|
2005-08-20 11:14:00 +04:00
|
|
|
else
|
2007-06-05 07:26:43 +04:00
|
|
|
*left = *top = *right = *bottom = 0;
|
2005-08-20 11:14:00 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_CHECKBUTTON_CONTAINER:
|
|
|
|
case MOZ_GTK_RADIOBUTTON_CONTAINER:
|
2005-08-20 11:14:00 +04:00
|
|
|
{
|
|
|
|
gboolean interior_focus;
|
|
|
|
gint focus_width, focus_pad;
|
|
|
|
|
|
|
|
/* If the focus is _not_ interior, then the container has a border
|
|
|
|
of (focus_width + focus_pad). */
|
|
|
|
if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
|
2007-11-07 12:14:58 +03:00
|
|
|
ensure_checkbox_widget();
|
|
|
|
moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
|
2005-08-20 11:14:00 +04:00
|
|
|
&focus_width, &focus_pad);
|
2005-08-20 11:14:02 +04:00
|
|
|
w = gCheckboxWidget;
|
2005-08-20 11:14:00 +04:00
|
|
|
} else {
|
2007-11-07 12:14:58 +03:00
|
|
|
ensure_radiobutton_widget();
|
|
|
|
moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
|
2005-08-20 11:14:00 +04:00
|
|
|
&focus_width, &focus_pad);
|
2005-08-20 11:14:02 +04:00
|
|
|
w = gRadiobuttonWidget;
|
2005-08-20 11:14:00 +04:00
|
|
|
}
|
|
|
|
|
2007-06-05 07:26:43 +04:00
|
|
|
*left = *top = *right = *bottom = GTK_CONTAINER(w)->border_width;
|
2005-08-20 11:14:00 +04:00
|
|
|
|
|
|
|
if (!interior_focus) {
|
2007-06-05 07:26:43 +04:00
|
|
|
*left += (focus_width + focus_pad);
|
|
|
|
*right += (focus_width + focus_pad);
|
|
|
|
*top += (focus_width + focus_pad);
|
|
|
|
*bottom += (focus_width + focus_pad);
|
2005-08-20 11:14:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
2005-08-20 11:13:48 +04:00
|
|
|
case MOZ_GTK_MENUPOPUP:
|
|
|
|
ensure_menu_popup_widget();
|
|
|
|
w = gMenuPopupWidget;
|
|
|
|
break;
|
2016-05-19 07:55:04 +03:00
|
|
|
case MOZ_GTK_MENUBARITEM:
|
|
|
|
// Bug 1274143 for MOZ_GTK_MENUBARITEM.
|
|
|
|
// Fall through to MOZ_GTK_MENUITEM for now.
|
2005-08-20 11:13:48 +04:00
|
|
|
case MOZ_GTK_MENUITEM:
|
|
|
|
ensure_menu_item_widget();
|
2007-12-04 09:28:34 +03:00
|
|
|
ensure_menu_bar_item_widget();
|
2005-08-20 11:13:48 +04:00
|
|
|
w = gMenuItemWidget;
|
|
|
|
break;
|
2005-08-20 11:14:21 +04:00
|
|
|
case MOZ_GTK_CHECKMENUITEM:
|
|
|
|
case MOZ_GTK_RADIOMENUITEM:
|
|
|
|
ensure_check_menu_item_widget();
|
|
|
|
w = gCheckMenuItemWidget;
|
|
|
|
break;
|
2016-08-22 06:13:00 +03:00
|
|
|
case MOZ_GTK_TAB_TOP:
|
|
|
|
case MOZ_GTK_TAB_BOTTOM:
|
2007-12-21 14:51:48 +03:00
|
|
|
ensure_tab_widget();
|
|
|
|
w = gTabWidget;
|
|
|
|
break;
|
2005-08-20 11:13:45 +04:00
|
|
|
/* These widgets have no borders, since they are not containers. */
|
2007-12-21 14:17:01 +03:00
|
|
|
case MOZ_GTK_SPLITTER_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SPLITTER_VERTICAL:
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_CHECKBUTTON:
|
|
|
|
case MOZ_GTK_RADIOBUTTON:
|
|
|
|
case MOZ_GTK_SCROLLBAR_BUTTON:
|
2015-12-22 07:05:00 +03:00
|
|
|
case MOZ_GTK_SCROLLBAR_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCROLLBAR_VERTICAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
|
2006-05-30 17:50:48 +04:00
|
|
|
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCALE_THUMB_VERTICAL:
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_GRIPPER:
|
|
|
|
case MOZ_GTK_PROGRESS_CHUNK:
|
2011-05-05 17:11:35 +04:00
|
|
|
case MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE:
|
2011-05-16 14:59:10 +04:00
|
|
|
case MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE:
|
2008-04-28 14:06:56 +04:00
|
|
|
case MOZ_GTK_TREEVIEW_EXPANDER:
|
2007-12-03 12:13:29 +03:00
|
|
|
case MOZ_GTK_TOOLBAR_SEPARATOR:
|
2007-12-11 12:09:09 +03:00
|
|
|
case MOZ_GTK_MENUSEPARATOR:
|
2005-08-20 11:13:45 +04:00
|
|
|
/* These widgets have no borders.*/
|
2007-12-21 14:30:00 +03:00
|
|
|
case MOZ_GTK_SPINBUTTON:
|
2005-08-20 11:13:45 +04:00
|
|
|
case MOZ_GTK_TOOLTIP:
|
|
|
|
case MOZ_GTK_WINDOW:
|
2007-11-09 10:32:54 +03:00
|
|
|
case MOZ_GTK_RESIZER:
|
2007-11-29 01:45:21 +03:00
|
|
|
case MOZ_GTK_MENUARROW:
|
2008-01-17 13:24:31 +03:00
|
|
|
case MOZ_GTK_TOOLBARBUTTON_ARROW:
|
2008-02-10 11:32:37 +03:00
|
|
|
case MOZ_GTK_TOOLBAR:
|
|
|
|
case MOZ_GTK_MENUBAR:
|
2008-02-15 08:28:44 +03:00
|
|
|
case MOZ_GTK_TAB_SCROLLARROW:
|
2007-06-05 07:26:43 +04:00
|
|
|
*left = *top = *right = *bottom = 0;
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
default:
|
|
|
|
g_warning("Unsupported widget type: %d", widget);
|
|
|
|
return MOZ_GTK_UNKNOWN_WIDGET;
|
|
|
|
}
|
|
|
|
|
2007-06-05 07:26:43 +04:00
|
|
|
*right = *left = XTHICKNESS(w->style);
|
|
|
|
*bottom = *top = YTHICKNESS(w->style);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-09-04 07:17:00 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom,
|
2016-08-22 06:13:00 +03:00
|
|
|
GtkTextDirection direction, GtkTabFlags flags,
|
|
|
|
WidgetNodeType widget)
|
2014-09-04 07:17:00 +04:00
|
|
|
{
|
2016-08-22 06:13:00 +03:00
|
|
|
moz_gtk_get_widget_border(widget, left, top,
|
2014-09-04 07:17:00 +04:00
|
|
|
right, bottom, direction,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
// Top tabs have no bottom border, bottom tabs have no top border
|
2016-08-22 06:13:00 +03:00
|
|
|
if (widget == MOZ_GTK_TAB_BOTTOM) {
|
2014-09-04 07:17:00 +04:00
|
|
|
*top = 0;
|
|
|
|
} else {
|
|
|
|
*bottom = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
2008-03-12 13:54:22 +03:00
|
|
|
moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
/*
|
2008-03-11 11:55:54 +03:00
|
|
|
* We get the requisition of the drop down button, which includes
|
|
|
|
* all padding, border and focus line widths the button uses,
|
|
|
|
* as well as the minimum arrow size and its padding
|
|
|
|
* */
|
|
|
|
GtkRequisition requisition;
|
|
|
|
ensure_combo_box_entry_widgets();
|
2005-08-20 11:14:00 +04:00
|
|
|
|
2008-03-12 13:54:22 +03:00
|
|
|
gtk_widget_size_request(gComboBoxEntryButtonWidget, &requisition);
|
2008-03-11 11:55:54 +03:00
|
|
|
*width = requisition.width;
|
|
|
|
*height = requisition.height;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-15 08:28:44 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
|
|
|
|
{
|
|
|
|
gint arrow_size;
|
|
|
|
|
|
|
|
ensure_tab_widget();
|
|
|
|
gtk_widget_style_get(gTabWidget,
|
|
|
|
"scroll-arrow-hlength", &arrow_size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
*height = *width = arrow_size;
|
|
|
|
|
2008-03-12 20:27:03 +03:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-03-01 03:12:03 +03:00
|
|
|
void
|
2016-04-14 08:47:20 +03:00
|
|
|
moz_gtk_get_arrow_size(WidgetNodeType widgetType, gint* width, gint* height)
|
2008-03-12 20:27:03 +03:00
|
|
|
{
|
2016-03-01 03:12:03 +03:00
|
|
|
GtkWidget* widget;
|
|
|
|
switch (widgetType) {
|
|
|
|
case MOZ_GTK_DROPDOWN:
|
|
|
|
ensure_combo_box_widgets();
|
|
|
|
widget = gComboBoxArrowWidget;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ensure_button_arrow_widget();
|
|
|
|
widget = gButtonArrowWidget;
|
|
|
|
break;
|
|
|
|
}
|
2008-03-12 20:27:03 +03:00
|
|
|
|
2016-03-01 03:12:03 +03:00
|
|
|
GtkRequisition requisition;
|
|
|
|
gtk_widget_size_request(widget, &requisition);
|
2008-03-12 20:27:03 +03:00
|
|
|
*width = requisition.width;
|
|
|
|
*height = requisition.height;
|
2008-02-15 08:28:44 +03:00
|
|
|
}
|
|
|
|
|
2007-12-03 12:13:29 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_get_toolbar_separator_width(gint* size)
|
|
|
|
{
|
|
|
|
gboolean wide_separators;
|
|
|
|
gint separator_width;
|
|
|
|
GtkStyle* style;
|
|
|
|
|
|
|
|
ensure_toolbar_widget();
|
|
|
|
|
|
|
|
style = gToolbarWidget->style;
|
|
|
|
|
|
|
|
gtk_widget_style_get(gToolbarWidget,
|
|
|
|
"space-size", size,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-width", &separator_width,
|
|
|
|
NULL);
|
|
|
|
|
2007-12-19 14:33:45 +03:00
|
|
|
/* Just in case... */
|
2007-12-03 12:13:29 +03:00
|
|
|
*size = MAX(*size, (wide_separators ? separator_width : style->xthickness));
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-11-15 06:47:16 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_get_expander_size(gint* size)
|
|
|
|
{
|
|
|
|
ensure_expander_widget();
|
|
|
|
gtk_widget_style_get(gExpanderWidget,
|
|
|
|
"expander-size", size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-01-03 10:07:32 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_get_treeview_expander_size(gint* size)
|
|
|
|
{
|
|
|
|
ensure_tree_view_widget();
|
|
|
|
gtk_widget_style_get(gTreeViewWidget,
|
|
|
|
"expander-size", size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-11 12:09:09 +03:00
|
|
|
gint
|
|
|
|
moz_gtk_get_menu_separator_height(gint *size)
|
|
|
|
{
|
|
|
|
gboolean wide_separators;
|
|
|
|
gint separator_height;
|
|
|
|
|
|
|
|
ensure_menu_separator_widget();
|
|
|
|
|
|
|
|
gtk_widget_style_get(gMenuSeparatorWidget,
|
|
|
|
"wide-separators", &wide_separators,
|
|
|
|
"separator-height", &separator_height,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (wide_separators)
|
|
|
|
*size = separator_height + gMenuSeparatorWidget->style->ythickness;
|
|
|
|
else
|
|
|
|
*size = gMenuSeparatorWidget->style->ythickness * 2;
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-07-30 12:29:00 +03:00
|
|
|
void
|
|
|
|
moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
|
|
|
|
gint* scale_height)
|
|
|
|
{
|
|
|
|
moz_gtk_get_scalethumb_metrics(orient, scale_width, scale_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-30 17:50:48 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
|
|
|
|
{
|
|
|
|
GtkWidget* widget;
|
|
|
|
|
|
|
|
ensure_scale_widget();
|
|
|
|
widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
|
|
|
"slider_length", thumb_length,
|
|
|
|
"slider_width", thumb_height,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
2005-08-20 11:14:00 +04:00
|
|
|
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
ensure_scrollbar_widget();
|
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
gtk_widget_style_get (gHorizScrollbarWidget,
|
|
|
|
"slider_width", &metrics->slider_width,
|
|
|
|
"trough_border", &metrics->trough_border,
|
|
|
|
"stepper_size", &metrics->stepper_size,
|
|
|
|
"stepper_spacing", &metrics->stepper_spacing,
|
|
|
|
NULL);
|
2005-08-20 11:11:55 +04:00
|
|
|
|
2005-08-20 11:14:00 +04:00
|
|
|
metrics->min_slider_size =
|
|
|
|
GTK_RANGE(gHorizScrollbarWidget)->min_slider_size;
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|
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
|
|
|
void
|
|
|
|
moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width, int* height) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("get_widget_min_size not available for GTK2");
|
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
|
|
|
|
gint
|
2016-04-14 08:47:20 +03:00
|
|
|
moz_gtk_widget_paint(WidgetNodeType widget, GdkDrawable* drawable,
|
2005-08-20 11:11:55 +04:00
|
|
|
GdkRectangle* rect, GdkRectangle* cliprect,
|
2007-12-19 14:34:49 +03:00
|
|
|
GtkWidgetState* state, gint flags,
|
|
|
|
GtkTextDirection direction)
|
2005-08-20 11:11:55 +04:00
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case MOZ_GTK_BUTTON:
|
2015-10-01 05:30:00 +03:00
|
|
|
case MOZ_GTK_TOOLBAR_BUTTON:
|
2007-12-03 12:14:18 +03:00
|
|
|
if (state->depressed) {
|
|
|
|
ensure_toggle_button_widget();
|
|
|
|
return moz_gtk_button_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkReliefStyle) flags,
|
2007-12-19 14:34:49 +03:00
|
|
|
gToggleButtonWidget, direction);
|
2007-12-03 12:14:18 +03:00
|
|
|
}
|
2005-08-20 11:11:55 +04:00
|
|
|
ensure_button_widget();
|
|
|
|
return moz_gtk_button_paint(drawable, rect, cliprect, state,
|
2007-12-19 14:34:49 +03:00
|
|
|
(GtkReliefStyle) flags, gButtonWidget,
|
|
|
|
direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_CHECKBUTTON:
|
|
|
|
case MOZ_GTK_RADIOBUTTON:
|
|
|
|
return moz_gtk_toggle_paint(drawable, rect, cliprect, state,
|
2009-01-22 03:07:44 +03:00
|
|
|
!!(flags & MOZ_GTK_WIDGET_CHECKED),
|
|
|
|
!!(flags & MOZ_GTK_WIDGET_INCONSISTENT),
|
2007-12-19 14:34:49 +03:00
|
|
|
(widget == MOZ_GTK_RADIOBUTTON),
|
|
|
|
direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_SCROLLBAR_BUTTON:
|
2008-01-13 07:13:50 +03:00
|
|
|
return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkScrollbarButtonFlags) flags,
|
2007-12-19 14:34:49 +03:00
|
|
|
direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2015-12-22 07:05:00 +03:00
|
|
|
case MOZ_GTK_SCROLLBAR_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCROLLBAR_VERTICAL:
|
2005-08-20 11:13:14 +04:00
|
|
|
return moz_gtk_scrollbar_trough_paint(widget, drawable, rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
cliprect, state, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2005-08-20 11:13:14 +04:00
|
|
|
case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
|
|
|
|
return moz_gtk_scrollbar_thumb_paint(widget, drawable, rect,
|
2007-12-19 14:34:49 +03:00
|
|
|
cliprect, state, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2006-05-30 17:50:48 +04:00
|
|
|
case MOZ_GTK_SCALE_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCALE_VERTICAL:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_scale_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkOrientation) flags, direction);
|
2006-05-30 17:50:48 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
|
|
|
|
case MOZ_GTK_SCALE_THUMB_VERTICAL:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkOrientation) flags, direction);
|
2006-05-30 17:50:48 +04:00
|
|
|
break;
|
2007-12-21 14:30:00 +03:00
|
|
|
case MOZ_GTK_SPINBUTTON:
|
|
|
|
return moz_gtk_spin_paint(drawable, rect, direction);
|
|
|
|
break;
|
2006-07-13 21:40:49 +04:00
|
|
|
case MOZ_GTK_SPINBUTTON_UP:
|
|
|
|
case MOZ_GTK_SPINBUTTON_DOWN:
|
2007-12-21 14:30:00 +03:00
|
|
|
return moz_gtk_spin_updown_paint(drawable, rect,
|
|
|
|
(widget == MOZ_GTK_SPINBUTTON_DOWN),
|
|
|
|
state, direction);
|
|
|
|
break;
|
|
|
|
case MOZ_GTK_SPINBUTTON_ENTRY:
|
|
|
|
ensure_spin_widget();
|
|
|
|
return moz_gtk_entry_paint(drawable, rect, cliprect, state,
|
|
|
|
gSpinWidget, direction);
|
2006-07-13 21:40:49 +04:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_GRIPPER:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_gripper_paint(drawable, rect, cliprect, state,
|
|
|
|
direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2007-11-07 12:14:58 +03:00
|
|
|
case MOZ_GTK_TREEVIEW:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_treeview_paint(drawable, rect, cliprect, state,
|
|
|
|
direction);
|
2007-11-07 12:14:58 +03:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_TREE_HEADER_CELL:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_tree_header_cell_paint(drawable, rect, cliprect, state,
|
2008-03-18 22:35:23 +03:00
|
|
|
flags, direction);
|
2007-11-07 12:14:58 +03:00
|
|
|
break;
|
2007-11-13 11:43:03 +03:00
|
|
|
case MOZ_GTK_TREE_HEADER_SORTARROW:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect,
|
|
|
|
state,
|
|
|
|
(GtkArrowType) flags,
|
|
|
|
direction);
|
2007-11-13 11:43:03 +03:00
|
|
|
break;
|
2008-01-03 10:07:32 +03:00
|
|
|
case MOZ_GTK_TREEVIEW_EXPANDER:
|
|
|
|
return moz_gtk_treeview_expander_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkExpanderStyle) flags, direction);
|
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_ENTRY:
|
2007-12-21 14:30:00 +03:00
|
|
|
ensure_entry_widget();
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_entry_paint(drawable, rect, cliprect, state,
|
2007-12-21 14:30:00 +03:00
|
|
|
gEntryWidget, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2005-08-20 11:14:05 +04:00
|
|
|
case MOZ_GTK_DROPDOWN:
|
2008-03-17 00:05:46 +03:00
|
|
|
return moz_gtk_combo_box_paint(drawable, rect, cliprect, state,
|
2008-03-25 03:34:27 +03:00
|
|
|
(gboolean) flags, direction);
|
2005-08-20 11:14:05 +04:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_DROPDOWN_ARROW:
|
2008-03-12 13:54:22 +03:00
|
|
|
return moz_gtk_combo_box_entry_button_paint(drawable, rect, cliprect,
|
|
|
|
state, flags, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2008-01-14 14:12:29 +03:00
|
|
|
case MOZ_GTK_DROPDOWN_ENTRY:
|
2008-03-11 11:55:54 +03:00
|
|
|
ensure_combo_box_entry_widgets();
|
2008-01-14 14:12:29 +03:00
|
|
|
return moz_gtk_entry_paint(drawable, rect, cliprect, state,
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryTextareaWidget, direction);
|
2008-01-14 14:12:29 +03:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_CHECKBUTTON_CONTAINER:
|
|
|
|
case MOZ_GTK_RADIOBUTTON_CONTAINER:
|
|
|
|
return moz_gtk_container_paint(drawable, rect, cliprect, state,
|
2007-12-19 14:34:49 +03:00
|
|
|
(widget == MOZ_GTK_RADIOBUTTON_CONTAINER),
|
|
|
|
direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2005-08-20 11:14:00 +04:00
|
|
|
case MOZ_GTK_CHECKBUTTON_LABEL:
|
|
|
|
case MOZ_GTK_RADIOBUTTON_LABEL:
|
|
|
|
return moz_gtk_toggle_label_paint(drawable, rect, cliprect, state,
|
2007-12-19 14:34:49 +03:00
|
|
|
(widget == MOZ_GTK_RADIOBUTTON_LABEL),
|
|
|
|
direction);
|
2005-08-20 11:14:00 +04:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_TOOLBAR:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_toolbar_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2007-12-03 12:13:29 +03:00
|
|
|
case MOZ_GTK_TOOLBAR_SEPARATOR:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_toolbar_separator_paint(drawable, rect, cliprect,
|
|
|
|
direction);
|
2007-12-03 12:13:29 +03:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_TOOLTIP:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_tooltip_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_FRAME:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_frame_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2007-11-09 10:32:54 +03:00
|
|
|
case MOZ_GTK_RESIZER:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_resizer_paint(drawable, rect, cliprect, state,
|
|
|
|
direction);
|
2007-11-09 10:32:54 +03:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
case MOZ_GTK_PROGRESSBAR:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_progressbar_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_PROGRESS_CHUNK:
|
2011-05-05 17:11:35 +04:00
|
|
|
case MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE:
|
2011-05-16 14:59:10 +04:00
|
|
|
case MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_progress_chunk_paint(drawable, rect, cliprect,
|
2011-05-05 17:11:35 +04:00
|
|
|
direction, widget);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2016-08-22 06:13:00 +03:00
|
|
|
case MOZ_GTK_TAB_TOP:
|
|
|
|
case MOZ_GTK_TAB_BOTTOM:
|
2010-02-12 01:35:55 +03:00
|
|
|
return moz_gtk_tab_paint(drawable, rect, cliprect, state,
|
2016-08-22 06:13:00 +03:00
|
|
|
(GtkTabFlags) flags, direction, widget);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_TABPANELS:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_tabpanels_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:11:55 +04:00
|
|
|
break;
|
2008-02-15 08:28:44 +03:00
|
|
|
case MOZ_GTK_TAB_SCROLLARROW:
|
|
|
|
return moz_gtk_tab_scroll_arrow_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkArrowType) flags, direction);
|
|
|
|
break;
|
2005-08-20 11:13:48 +04:00
|
|
|
case MOZ_GTK_MENUBAR:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_menu_bar_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:13:48 +04:00
|
|
|
break;
|
|
|
|
case MOZ_GTK_MENUPOPUP:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_menu_popup_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:13:48 +04:00
|
|
|
break;
|
2007-12-11 12:09:09 +03:00
|
|
|
case MOZ_GTK_MENUSEPARATOR:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_menu_separator_paint(drawable, rect, cliprect,
|
|
|
|
direction);
|
2007-12-11 12:09:09 +03:00
|
|
|
break;
|
2016-05-19 07:55:04 +03:00
|
|
|
case MOZ_GTK_MENUBARITEM:
|
2005-08-20 11:13:48 +04:00
|
|
|
case MOZ_GTK_MENUITEM:
|
2016-05-19 07:55:04 +03:00
|
|
|
return moz_gtk_menu_item_paint(widget, drawable, rect, cliprect, state,
|
2007-12-19 14:34:49 +03:00
|
|
|
direction);
|
2005-08-20 11:13:48 +04:00
|
|
|
break;
|
2007-11-29 01:45:21 +03:00
|
|
|
case MOZ_GTK_MENUARROW:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_menu_arrow_paint(drawable, rect, cliprect, state,
|
|
|
|
direction);
|
2007-11-29 01:45:21 +03:00
|
|
|
break;
|
2008-01-17 13:24:31 +03:00
|
|
|
case MOZ_GTK_TOOLBARBUTTON_ARROW:
|
2010-07-27 18:57:47 +04:00
|
|
|
return moz_gtk_arrow_paint(drawable, rect, cliprect, state,
|
|
|
|
(GtkArrowType) flags, direction);
|
2008-01-17 13:24:31 +03:00
|
|
|
break;
|
2005-08-20 11:14:21 +04:00
|
|
|
case MOZ_GTK_CHECKMENUITEM:
|
|
|
|
case MOZ_GTK_RADIOMENUITEM:
|
|
|
|
return moz_gtk_check_menu_item_paint(drawable, rect, cliprect, state,
|
2007-12-19 14:34:49 +03:00
|
|
|
(gboolean) flags,
|
|
|
|
(widget == MOZ_GTK_RADIOMENUITEM),
|
|
|
|
direction);
|
2005-08-20 11:14:21 +04:00
|
|
|
break;
|
2007-12-21 14:17:01 +03:00
|
|
|
case MOZ_GTK_SPLITTER_HORIZONTAL:
|
|
|
|
return moz_gtk_vpaned_paint(drawable, rect, cliprect, state);
|
|
|
|
break;
|
|
|
|
case MOZ_GTK_SPLITTER_VERTICAL:
|
|
|
|
return moz_gtk_hpaned_paint(drawable, rect, cliprect, state);
|
|
|
|
break;
|
2005-08-20 11:13:45 +04:00
|
|
|
case MOZ_GTK_WINDOW:
|
2007-12-19 14:34:49 +03:00
|
|
|
return moz_gtk_window_paint(drawable, rect, cliprect, direction);
|
2005-08-20 11:13:45 +04:00
|
|
|
break;
|
2005-08-20 11:11:55 +04:00
|
|
|
default:
|
|
|
|
g_warning("Unknown widget type: %d", widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MOZ_GTK_UNKNOWN_WIDGET;
|
|
|
|
}
|
|
|
|
|
2006-05-02 03:23:33 +04:00
|
|
|
GtkWidget* moz_gtk_get_scrollbar_widget(void)
|
|
|
|
{
|
2015-01-30 02:53:46 +03:00
|
|
|
MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
|
2006-05-02 03:23:33 +04:00
|
|
|
ensure_scrollbar_widget();
|
|
|
|
return gHorizScrollbarWidget;
|
|
|
|
}
|
|
|
|
|
2015-06-17 14:27:00 +03:00
|
|
|
gboolean moz_gtk_has_scrollbar_buttons(void)
|
|
|
|
{
|
|
|
|
gboolean backward, forward, secondary_backward, secondary_forward;
|
|
|
|
MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
|
|
|
|
ensure_scrollbar_widget();
|
|
|
|
gtk_widget_style_get (gHorizScrollbarWidget,
|
|
|
|
"has-backward-stepper", &backward,
|
|
|
|
"has-forward-stepper", &forward,
|
|
|
|
"has-secondary-backward-stepper", &secondary_backward,
|
|
|
|
"has-secondary-forward-stepper", &secondary_forward,
|
|
|
|
NULL);
|
|
|
|
return backward | forward | secondary_forward | secondary_forward;
|
|
|
|
}
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
gint
|
|
|
|
moz_gtk_shutdown()
|
|
|
|
{
|
2008-08-14 12:04:28 +04:00
|
|
|
GtkWidgetClass *entry_class;
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
if (gTooltipWidget)
|
2005-08-20 11:13:16 +04:00
|
|
|
gtk_widget_destroy(gTooltipWidget);
|
2005-08-20 11:11:55 +04:00
|
|
|
/* This will destroy all of our widgets */
|
|
|
|
if (gProtoWindow)
|
|
|
|
gtk_widget_destroy(gProtoWindow);
|
|
|
|
|
2005-08-20 11:14:22 +04:00
|
|
|
gProtoWindow = NULL;
|
2009-03-06 09:43:13 +03:00
|
|
|
gProtoLayout = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gButtonWidget = NULL;
|
2007-12-03 12:14:18 +03:00
|
|
|
gToggleButtonWidget = NULL;
|
2008-03-12 13:54:22 +03:00
|
|
|
gButtonArrowWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gCheckboxWidget = NULL;
|
|
|
|
gRadiobuttonWidget = NULL;
|
|
|
|
gHorizScrollbarWidget = NULL;
|
|
|
|
gVertScrollbarWidget = NULL;
|
2007-12-22 21:59:35 +03:00
|
|
|
gSpinWidget = NULL;
|
2006-05-30 17:50:48 +04:00
|
|
|
gHScaleWidget = NULL;
|
|
|
|
gVScaleWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gEntryWidget = NULL;
|
2008-03-17 00:05:46 +03:00
|
|
|
gComboBoxWidget = NULL;
|
|
|
|
gComboBoxButtonWidget = NULL;
|
|
|
|
gComboBoxSeparatorWidget = NULL;
|
|
|
|
gComboBoxArrowWidget = NULL;
|
2008-01-14 14:12:29 +03:00
|
|
|
gComboBoxEntryWidget = NULL;
|
2008-03-12 13:54:22 +03:00
|
|
|
gComboBoxEntryButtonWidget = NULL;
|
|
|
|
gComboBoxEntryArrowWidget = NULL;
|
|
|
|
gComboBoxEntryTextareaWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gHandleBoxWidget = NULL;
|
|
|
|
gToolbarWidget = NULL;
|
2007-11-15 10:35:41 +03:00
|
|
|
gStatusbarWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gFrameWidget = NULL;
|
|
|
|
gProgressWidget = NULL;
|
|
|
|
gTabWidget = NULL;
|
|
|
|
gTooltipWidget = NULL;
|
|
|
|
gMenuBarWidget = NULL;
|
|
|
|
gMenuBarItemWidget = NULL;
|
|
|
|
gMenuPopupWidget = NULL;
|
|
|
|
gMenuItemWidget = NULL;
|
2008-02-20 13:12:33 +03:00
|
|
|
gImageMenuItemWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
gCheckMenuItemWidget = NULL;
|
2007-11-07 12:14:58 +03:00
|
|
|
gTreeViewWidget = NULL;
|
2008-03-18 22:35:23 +03:00
|
|
|
gMiddleTreeViewColumn = NULL;
|
2007-11-07 12:14:58 +03:00
|
|
|
gTreeHeaderCellWidget = NULL;
|
2007-11-13 11:43:03 +03:00
|
|
|
gTreeHeaderSortArrowWidget = NULL;
|
2007-11-15 06:47:16 +03:00
|
|
|
gExpanderWidget = NULL;
|
2007-12-03 12:13:29 +03:00
|
|
|
gToolbarSeparatorWidget = NULL;
|
2007-12-11 12:09:09 +03:00
|
|
|
gMenuSeparatorWidget = NULL;
|
2007-12-21 14:17:01 +03:00
|
|
|
gHPanedWidget = NULL;
|
|
|
|
gVPanedWidget = NULL;
|
2008-02-10 11:36:46 +03:00
|
|
|
gScrolledWindowWidget = NULL;
|
2005-08-20 11:14:22 +04:00
|
|
|
|
2008-08-14 12:04:28 +04:00
|
|
|
entry_class = g_type_class_peek(GTK_TYPE_ENTRY);
|
|
|
|
g_type_class_unref(entry_class);
|
|
|
|
|
2006-05-02 03:23:33 +04:00
|
|
|
is_initialized = FALSE;
|
|
|
|
|
2005-08-20 11:11:55 +04:00
|
|
|
return MOZ_GTK_SUCCESS;
|
|
|
|
}
|