1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 /**
7  * gtkdrawing.h: GTK widget rendering utilities
8  *
9  * gtkdrawing provides an API for rendering GTK widgets in the
10  * current theme to a pixmap or window, without requiring an actual
11  * widget instantiation, similar to the Macintosh Appearance Manager
12  * or Windows XP's DrawThemeBackground() API.
13  */
14 
15 #ifndef _GTK_DRAWING_H_
16 #define _GTK_DRAWING_H_
17 
18 #include <gdk/gdk.h>
19 #include <gtk/gtk.h>
20 #include <algorithm>
21 #include "mozilla/Span.h"
22 
23 /*** type definitions ***/
24 typedef struct {
25   guint8 active;
26   guint8 focused;
27   guint8 selected;
28   guint8 inHover;
29   guint8 disabled;
30   guint8 isDefault;
31   guint8 canDefault;
32   /* The depressed state is for buttons which remain active for a longer period:
33    * activated toggle buttons or buttons showing a popup menu. */
34   guint8 depressed;
35   guint8 backdrop;
36   gint32 curpos; /* curpos and maxpos are used for scrollbars */
37   gint32 maxpos;
38   gint32 scale; /* actual widget scale */
39 } GtkWidgetState;
40 
41 /**
42  * A size in the same GTK pixel units as GtkBorder and GdkRectangle.
43  */
44 struct MozGtkSize {
45   gint width;
46   gint height;
47 
48   MozGtkSize& operator+=(const GtkBorder& aBorder) {
49     width += aBorder.left + aBorder.right;
50     height += aBorder.top + aBorder.bottom;
51     return *this;
52   }
53   MozGtkSize operator+(const GtkBorder& aBorder) const {
54     MozGtkSize result = *this;
55     return result += aBorder;
56   }
57   bool operator<(const MozGtkSize& aOther) const {
58     return (width < aOther.width && height <= aOther.height) ||
59            (width <= aOther.width && height < aOther.height);
60   }
IncludeMozGtkSize61   void Include(MozGtkSize aOther) {
62     width = std::max(width, aOther.width);
63     height = std::max(height, aOther.height);
64   }
RotateMozGtkSize65   void Rotate() {
66     gint tmp = width;
67     width = height;
68     height = tmp;
69   }
70 };
71 
72 typedef struct {
73   bool initialized;
74   struct {
75     MozGtkSize scrollbar;
76     MozGtkSize thumb;
77     MozGtkSize button;
78   } size;
79   struct {
80     GtkBorder scrollbar;
81     GtkBorder track;
82   } border;
83   struct {
84     GtkBorder thumb;
85   } margin;
86 } ScrollbarGTKMetrics;
87 
88 typedef struct {
89   bool initialized;
90   MozGtkSize minSizeWithBorder;
91   GtkBorder borderAndPadding;
92 } ToggleGTKMetrics;
93 
94 typedef struct {
95   MozGtkSize minSizeWithBorderMargin;
96   GtkBorder buttonMargin;
97   gint iconXPosition;
98   gint iconYPosition;
99   bool visible;
100   bool firstButton;
101   bool lastButton;
102 } ToolbarButtonGTKMetrics;
103 
104 #define TOOLBAR_BUTTONS 3
105 typedef struct {
106   bool initialized;
107   ToolbarButtonGTKMetrics button[TOOLBAR_BUTTONS];
108 } ToolbarGTKMetrics;
109 
110 typedef struct {
111   bool initialized;
112   GtkBorder decorationSize;
113 } CSDWindowDecorationSize;
114 
115 typedef enum {
116   MOZ_GTK_STEPPER_DOWN = 1 << 0,
117   MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
118   MOZ_GTK_STEPPER_VERTICAL = 1 << 2
119 } GtkScrollbarButtonFlags;
120 
121 typedef enum { MOZ_GTK_TRACK_OPAQUE = 1 << 0 } GtkScrollbarTrackFlags;
122 
123 /** flags for tab state **/
124 typedef enum {
125   /* first eight bits are used to pass a margin */
126   MOZ_GTK_TAB_MARGIN_MASK = 0xFF,
127   /* the first tab in the group */
128   MOZ_GTK_TAB_FIRST = 1 << 9,
129   /* the selected tab */
130   MOZ_GTK_TAB_SELECTED = 1 << 10
131 } GtkTabFlags;
132 
133 /*** result/error codes ***/
134 #define MOZ_GTK_SUCCESS 0
135 #define MOZ_GTK_UNKNOWN_WIDGET -1
136 #define MOZ_GTK_UNSAFE_THEME -2
137 
138 /*** checkbox/radio flags ***/
139 #define MOZ_GTK_WIDGET_CHECKED 1
140 #define MOZ_GTK_WIDGET_INCONSISTENT (1 << 1)
141 
142 /*** widget type constants ***/
143 enum WidgetNodeType : int {
144   /* Paints a GtkButton. flags is a GtkReliefStyle. */
145   MOZ_GTK_BUTTON,
146   /* Paints a button with image and no text */
147   MOZ_GTK_TOOLBAR_BUTTON,
148   /* Paints a toggle button */
149   MOZ_GTK_TOGGLE_BUTTON,
150   /* Paints a button arrow */
151   MOZ_GTK_BUTTON_ARROW,
152 
153   /* Paints the container part of a GtkCheckButton. */
154   MOZ_GTK_CHECKBUTTON_CONTAINER,
155   /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
156   MOZ_GTK_CHECKBUTTON,
157   /* Paints the label of a GtkCheckButton (focus outline) */
158   MOZ_GTK_CHECKBUTTON_LABEL,
159 
160   /* Paints the container part of a GtkRadioButton. */
161   MOZ_GTK_RADIOBUTTON_CONTAINER,
162   /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
163   MOZ_GTK_RADIOBUTTON,
164   /* Paints the label of a GtkRadioButton (focus outline) */
165   MOZ_GTK_RADIOBUTTON_LABEL,
166   /**
167    * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
168    * the arrow direction.
169    */
170   MOZ_GTK_SCROLLBAR_BUTTON,
171 
172   /* Horizontal GtkScrollbar counterparts */
173   MOZ_GTK_SCROLLBAR_HORIZONTAL,
174   MOZ_GTK_SCROLLBAR_CONTENTS_HORIZONTAL,
175   /* Paints the trough (track) of a GtkScrollbar. */
176   MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL,
177   /* Paints the slider (thumb) of a GtkScrollbar. */
178   MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
179 
180   /* Vertical GtkScrollbar counterparts */
181   MOZ_GTK_SCROLLBAR_VERTICAL,
182   MOZ_GTK_SCROLLBAR_CONTENTS_VERTICAL,
183   MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL,
184   MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
185 
186   /* Paints a GtkScale. */
187   MOZ_GTK_SCALE_HORIZONTAL,
188   MOZ_GTK_SCALE_VERTICAL,
189   /* Paints a GtkScale trough. */
190   MOZ_GTK_SCALE_CONTENTS_HORIZONTAL,
191   MOZ_GTK_SCALE_CONTENTS_VERTICAL,
192   MOZ_GTK_SCALE_TROUGH_HORIZONTAL,
193   MOZ_GTK_SCALE_TROUGH_VERTICAL,
194   /* Paints a GtkScale thumb. */
195   MOZ_GTK_SCALE_THUMB_HORIZONTAL,
196   MOZ_GTK_SCALE_THUMB_VERTICAL,
197   /* Paints a GtkSpinButton */
198   MOZ_GTK_INNER_SPIN_BUTTON,
199   MOZ_GTK_SPINBUTTON,
200   MOZ_GTK_SPINBUTTON_UP,
201   MOZ_GTK_SPINBUTTON_DOWN,
202   MOZ_GTK_SPINBUTTON_ENTRY,
203   /* Paints the gripper of a GtkHandleBox. */
204   MOZ_GTK_GRIPPER,
205   /* Paints a GtkEntry. */
206   MOZ_GTK_ENTRY,
207   /* Paints a GtkExpander. */
208   MOZ_GTK_EXPANDER,
209   /* Paints a GtkTextView or gets the style context corresponding to the
210      root node of a GtkTextView. */
211   MOZ_GTK_TEXT_VIEW,
212   /* The "text" window or node of a GtkTextView */
213   MOZ_GTK_TEXT_VIEW_TEXT,
214   /* The "selection" node of a GtkTextView.text */
215   MOZ_GTK_TEXT_VIEW_TEXT_SELECTION,
216   /* Paints a GtkOptionMenu. */
217   MOZ_GTK_DROPDOWN,
218   /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
219   MOZ_GTK_DROPDOWN_ARROW,
220   /* Paints an entry in an editable option menu */
221   MOZ_GTK_DROPDOWN_ENTRY,
222 
223   /* Paints the background of a GtkHandleBox. */
224   MOZ_GTK_TOOLBAR,
225   /* Paints a toolbar separator */
226   MOZ_GTK_TOOLBAR_SEPARATOR,
227   /* Paints a GtkToolTip */
228   MOZ_GTK_TOOLTIP,
229   /* Paints a GtkBox from GtkToolTip  */
230   MOZ_GTK_TOOLTIP_BOX,
231   /* Paints a GtkLabel of GtkToolTip */
232   MOZ_GTK_TOOLTIP_BOX_LABEL,
233   /* Paints a GtkFrame (e.g. a status bar panel). */
234   MOZ_GTK_FRAME,
235   /* Paints the border of a GtkFrame */
236   MOZ_GTK_FRAME_BORDER,
237   /* Paints a resize grip for a GtkTextView */
238   MOZ_GTK_RESIZER,
239   /* Paints a GtkProgressBar. */
240   MOZ_GTK_PROGRESSBAR,
241   /* Paints a trough (track) of a GtkProgressBar */
242   MOZ_GTK_PROGRESS_TROUGH,
243   /* Paints a progress chunk of a GtkProgressBar. */
244   MOZ_GTK_PROGRESS_CHUNK,
245   /* Paints a progress chunk of an indeterminated GtkProgressBar. */
246   MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE,
247   /* Paints a progress chunk of a vertical indeterminated GtkProgressBar. */
248   MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE,
249   /* Used as root style of whole GtkNotebook widget */
250   MOZ_GTK_NOTEBOOK,
251   /* Used as root style of active GtkNotebook area which contains tabs and
252      arrows. */
253   MOZ_GTK_NOTEBOOK_HEADER,
254   /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
255   MOZ_GTK_TAB_TOP,
256   /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
257   MOZ_GTK_TAB_BOTTOM,
258   /* Paints the background and border of a GtkNotebook. */
259   MOZ_GTK_TABPANELS,
260   /* Paints a GtkArrow for a GtkNotebook. flags is a GtkArrowType. */
261   MOZ_GTK_TAB_SCROLLARROW,
262   /* Paints the expander and border of a GtkTreeView */
263   MOZ_GTK_TREEVIEW,
264   /* Paints the border of a GtkTreeView */
265   MOZ_GTK_TREEVIEW_VIEW,
266   /* Paints treeheader cells */
267   MOZ_GTK_TREE_HEADER_CELL,
268   /* Paints sort arrows in treeheader cells */
269   MOZ_GTK_TREE_HEADER_SORTARROW,
270   /* Paints an expander for a GtkTreeView */
271   MOZ_GTK_TREEVIEW_EXPANDER,
272   /* Paints the background of the menu bar. */
273   MOZ_GTK_MENUBAR,
274   /* Paints the background of menus, context menus. */
275   MOZ_GTK_MENUPOPUP,
276   /* Paints the arrow of menuitems that contain submenus */
277   MOZ_GTK_MENUARROW,
278   /* Paints an arrow in a toolbar button. flags is a GtkArrowType. */
279   MOZ_GTK_TOOLBARBUTTON_ARROW,
280   /* Paints items of menubar. */
281   MOZ_GTK_MENUBARITEM,
282   /* Paints items of popup menus. */
283   MOZ_GTK_MENUITEM,
284   /* Paints a menuitem with check indicator, or the gets the style context for
285      a menuitem that contains a checkbox. */
286   MOZ_GTK_CHECKMENUITEM,
287   /* Gets the style context for a checkbox in a check menuitem. */
288   MOZ_GTK_CHECKMENUITEM_INDICATOR,
289   MOZ_GTK_RADIOMENUITEM,
290   MOZ_GTK_RADIOMENUITEM_INDICATOR,
291   MOZ_GTK_MENUSEPARATOR,
292   /* GtkVPaned base class */
293   MOZ_GTK_SPLITTER_HORIZONTAL,
294   /* GtkHPaned base class */
295   MOZ_GTK_SPLITTER_VERTICAL,
296   /* Paints a GtkVPaned separator */
297   MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL,
298   /* Paints a GtkHPaned separator */
299   MOZ_GTK_SPLITTER_SEPARATOR_VERTICAL,
300   /* Paints the background of a window, dialog or page. */
301   MOZ_GTK_WINDOW,
302   /* Used only as a container for MOZ_GTK_HEADER_BAR. */
303   MOZ_GTK_HEADERBAR_WINDOW,
304   /* Used only as a container for MOZ_GTK_HEADER_BAR_MAXIMIZED. */
305   MOZ_GTK_HEADERBAR_WINDOW_MAXIMIZED,
306   /* Window container for all widgets */
307   MOZ_GTK_WINDOW_CONTAINER,
308   /* Used for widget tree construction. */
309   MOZ_GTK_COMBOBOX,
310   /* Paints a GtkComboBox button widget. */
311   MOZ_GTK_COMBOBOX_BUTTON,
312   /* Paints a GtkComboBox arrow widget. */
313   MOZ_GTK_COMBOBOX_ARROW,
314   /* Paints a GtkComboBox separator widget. */
315   MOZ_GTK_COMBOBOX_SEPARATOR,
316   /* Used for widget tree construction. */
317   MOZ_GTK_COMBOBOX_ENTRY,
318   /* Paints a GtkComboBox entry widget. */
319   MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA,
320   /* Paints a GtkComboBox entry button widget. */
321   MOZ_GTK_COMBOBOX_ENTRY_BUTTON,
322   /* Paints a GtkComboBox entry arrow widget. */
323   MOZ_GTK_COMBOBOX_ENTRY_ARROW,
324   /* Used for scrolled window shell. */
325   MOZ_GTK_SCROLLED_WINDOW,
326   /* Paints a GtkHeaderBar */
327   MOZ_GTK_HEADER_BAR,
328   /* Paints a GtkHeaderBar in maximized state */
329   MOZ_GTK_HEADER_BAR_MAXIMIZED,
330   /* Container for GtkHeaderBar buttons */
331   MOZ_GTK_HEADER_BAR_BUTTON_BOX,
332   /* Paints GtkHeaderBar title buttons.
333    * Keep the order here as MOZ_GTK_HEADER_BAR_BUTTON_* are processed
334    * as an array from MOZ_GTK_HEADER_BAR_BUTTON_CLOSE to the last one.
335    */
336   MOZ_GTK_HEADER_BAR_BUTTON_CLOSE,
337   MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE,
338   MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE,
339 
340   /* MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE is a state of
341    * MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE button and it's used as
342    * an icon placeholder only.
343    */
344   MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE_RESTORE,
345 
346   /* Client-side window decoration node. Available on GTK 3.20+. */
347   MOZ_GTK_WINDOW_DECORATION,
348   MOZ_GTK_WINDOW_DECORATION_SOLID,
349 
350   MOZ_GTK_WIDGET_NODE_COUNT
351 };
352 
353 /* ButtonLayout represents a GTK CSD button and whether its on the left or
354  * right side of the tab bar */
355 struct ButtonLayout {
356   WidgetNodeType mType;
357   bool mAtRight;
358 };
359 
360 /*** General library functions ***/
361 /**
362  * Initializes the drawing library.  You must call this function
363  * prior to using any other functionality.
364  * returns: MOZ_GTK_SUCCESS if there were no errors
365  *          MOZ_GTK_UNSAFE_THEME if the current theme engine is known
366  *                               to crash with gtkdrawing.
367  */
368 gint moz_gtk_init();
369 
370 /**
371  * Updates the drawing library when the theme changes.
372  */
373 void moz_gtk_refresh();
374 
375 /**
376  * Perform cleanup of the drawing library. You should call this function
377  * when your program exits, or you no longer need the library.
378  *
379  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
380  */
381 gint moz_gtk_shutdown();
382 
383 /*** Widget drawing ***/
384 /**
385  * Paint a widget in the current theme.
386  * widget:    a constant giving the widget to paint
387  * drawable:  the drawable to paint to;
388  *            it's colormap must be moz_gtk_widget_get_colormap().
389  * rect:      the bounding rectangle for the widget
390  * state:     the state of the widget.  ignored for some widgets.
391  * flags:     widget-dependant flags; see the WidgetNodeType definition.
392  * direction: the text direction, to draw the widget correctly LTR and RTL.
393  */
394 gint moz_gtk_widget_paint(WidgetNodeType widget, cairo_t* cr,
395                           GdkRectangle* rect, GtkWidgetState* state, gint flags,
396                           GtkTextDirection direction);
397 
398 /*** Widget metrics ***/
399 /**
400  * Get the border size of a widget
401  * left/right:  [OUT] the widget's left/right border
402  * top/bottom:  [OUT] the widget's top/bottom border
403  * direction:   the text direction for the widget.  Callers depend on this
404  *              being used only for MOZ_GTK_DROPDOWN widgets, and cache
405  *              results for other widget types across direction values.
406  *
407  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
408  */
409 gint moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
410                                gint* right, gint* bottom,
411                                GtkTextDirection direction);
412 
413 /**
414  * Get the border size of a notebook tab
415  * left/right:  [OUT] the tab's left/right border
416  * top/bottom:  [OUT] the tab's top/bottom border
417  * direction:   the text direction for the widget
418  * flags:       tab-dependant flags; see the GtkTabFlags definition.
419  * widget:      tab widget
420  *
421  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
422  */
423 gint moz_gtk_get_tab_border(gint* left, gint* top, gint* right, gint* bottom,
424                             GtkTextDirection direction, GtkTabFlags flags,
425                             WidgetNodeType widget);
426 
427 /**
428  * Get the desired size of a GtkCheckButton
429  * indicator_size:     [OUT] the indicator size
430  * indicator_spacing:  [OUT] the spacing between the indicator and its
431  *                     container
432  *
433  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
434  */
435 gint moz_gtk_checkbox_get_metrics(gint* indicator_size,
436                                   gint* indicator_spacing);
437 
438 /**
439  * Get metrics of the toggle (radio or checkbox)
440  * isRadio:            [IN] true when requesting metrics for the radio button
441  * returns:    pointer to ToggleGTKMetrics struct
442  */
443 const ToggleGTKMetrics* GetToggleMetrics(WidgetNodeType aWidgetType);
444 
445 /**
446  * Get the desired size of a GtkRadioButton
447  * indicator_size:     [OUT] the indicator size
448  * indicator_spacing:  [OUT] the spacing between the indicator and its
449  *                     container
450  *
451  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
452  */
453 gint moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
454 
455 /** Returns the size of the focus ring for outline:auto.
456  * focus_h_width:      [OUT] the horizontal width
457  * focus_v_width:      [OUT] the vertical width
458  *
459  * returns:    MOZ_GTK_SUCCESS
460  */
461 gint moz_gtk_get_focus_outline_size(gint* focus_h_width, gint* focus_v_width);
462 
463 /** Get the horizontal padding for the menuitem widget or checkmenuitem widget.
464  * horizontal_padding: [OUT] The left and right padding of the menuitem or
465  * checkmenuitem
466  *
467  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
468  */
469 gint moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding);
470 
471 gint moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding);
472 
473 /**
474  * Some GTK themes draw their indication for the default button outside
475  * the button (e.g. the glow in New Wave). This gets the extra space necessary.
476  *
477  * border_top:  [OUT] extra space to add above
478  * border_left:  [OUT] extra space to add to the left
479  * border_bottom:  [OUT] extra space to add underneath
480  * border_right:  [OUT] extra space to add to the right
481  *
482  * returns:   MOZ_GTK_SUCCESS if there was no error, an error code otherwise
483  */
484 gint moz_gtk_button_get_default_overflow(gint* border_top, gint* border_left,
485                                          gint* border_bottom,
486                                          gint* border_right);
487 
488 /**
489  * Gets the minimum size of a GtkScale.
490  * orient:           [IN] the scale orientation
491  * scale_width:      [OUT] the width of the scale
492  * scale_height:     [OUT] the height of the scale
493  */
494 void moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width,
495                                gint* scale_height);
496 
497 /**
498  * Get the desired size of a GtkScale thumb
499  * orient:           [IN] the scale orientation
500  * thumb_length:     [OUT] the length of the thumb
501  * thumb_height:     [OUT] the height of the thumb
502  *
503  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
504  */
505 gint moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length,
506                                     gint* thumb_height);
507 
508 /**
509  * Get the metrics in GTK pixels for a scrollbar.
510  * aOrientation:     [IN] the scrollbar orientation
511  */
512 const ScrollbarGTKMetrics* GetScrollbarMetrics(GtkOrientation aOrientation);
513 
514 /**
515  * Get the metrics in GTK pixels for a scrollbar which is active
516  * (selected by mouse pointer).
517  * aOrientation:     [IN] the scrollbar orientation
518  */
519 const ScrollbarGTKMetrics* GetActiveScrollbarMetrics(
520     GtkOrientation aOrientation);
521 
522 /**
523  * Get the desired size of a dropdown arrow button
524  * width:   [OUT] the desired width
525  * height:  [OUT] the desired height
526  *
527  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
528  */
529 gint moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height);
530 
531 /**
532  * Get the desired size of a scroll arrow widget
533  * width:   [OUT] the desired width
534  * height:  [OUT] the desired height
535  *
536  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
537  */
538 gint moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height);
539 
540 /**
541  * Get the desired size of an arrow in a button
542  *
543  * widgetType: [IN]  the widget for which to get the arrow size
544  * width:      [OUT] the desired width
545  * height:     [OUT] the desired height
546  */
547 void moz_gtk_get_arrow_size(WidgetNodeType widgetType, gint* width,
548                             gint* height);
549 
550 /**
551  * Get the minimum height of a entry widget
552  * min_content_height:    [OUT] the minimum height of the content box.
553  * border_padding_height: [OUT] the size of borders and paddings.
554  */
555 void moz_gtk_get_entry_min_height(gint* min_content_height,
556                                   gint* border_padding_height);
557 
558 /**
559  * Get the desired size of a toolbar separator
560  * size:    [OUT] the desired width
561  *
562  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
563  */
564 gint moz_gtk_get_toolbar_separator_width(gint* size);
565 
566 /**
567  * Get the size of a regular GTK expander that shows/hides content
568  * size:    [OUT] the size of the GTK expander, size = width = height.
569  *
570  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
571  */
572 gint moz_gtk_get_expander_size(gint* size);
573 
574 /**
575  * Get the size of a treeview's expander (we call them twisties)
576  * size:    [OUT] the size of the GTK expander, size = width = height.
577  *
578  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
579  */
580 gint moz_gtk_get_treeview_expander_size(gint* size);
581 
582 /**
583  * Get the desired height of a menu separator
584  * size:    [OUT] the desired height
585  *
586  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
587  */
588 gint moz_gtk_get_menu_separator_height(gint* size);
589 
590 /**
591  * Get the desired size of a splitter
592  * orientation:   [IN]  GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL
593  * size:          [OUT] width or height of the splitter handle
594  *
595  * returns:    MOZ_GTK_SUCCESS if there was no error, an error code otherwise
596  */
597 gint moz_gtk_splitter_get_metrics(gint orientation, gint* size);
598 
599 /**
600  * Get the YTHICKNESS of a tab (notebook extension).
601  */
602 gint moz_gtk_get_tab_thickness(WidgetNodeType aNodeType);
603 
604 /**
605  * Get ToolbarButtonGTKMetrics for recent theme.
606  */
607 const ToolbarButtonGTKMetrics* GetToolbarButtonMetrics(
608     WidgetNodeType aAppearance);
609 
610 /**
611  * Get toolbar button layout.
612  * aButtonLayout:  [OUT] An array which will be filled by ButtonLayout
613  *                       references to visible titlebar buttons. Must contain at
614  *                       least TOOLBAR_BUTTONS entries if non-empty.
615  * aReversedButtonsPlacement: [OUT] True if the buttons are placed in opposite
616  *                                  titlebar corner.
617  *
618  * returns:    Number of returned entries at aButtonLayout.
619  */
620 size_t GetGtkHeaderBarButtonLayout(mozilla::Span<ButtonLayout>,
621                                    bool* aReversedButtonsPlacement);
622 
623 /**
624  * Get size of CSD window extents.
625  *
626  * aIsPopup: [IN] Get decoration size for popup or toplevel window.
627  *
628  * returns: Calculated (or estimated) decoration size of given aGtkWindow.
629  */
630 GtkBorder GetCSDDecorationSize(bool aIsPopup);
631 
632 #endif
633