Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Functions
gtkflatbutton.h File Reference
#include <gdk/gdk.h>
#include <gtk/gtkbin.h>
#include <gtk/gtkenums.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GtkFlatButton
struct  _GtkFlatButtonClass

Defines

#define GTK_TYPE_FLAT_BUTTON   (gtk_flat_button_get_type ())
#define GTK_FLAT_BUTTON(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLAT_BUTTON, GtkFlatButton))
#define GTK_FLAT_BUTTON_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLAT_BUTTON, GtkFlatButtonClass))
#define GTK_IS_FLAT_BUTTON(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLAT_BUTTON))
#define GTK_IS_FLAT_BUTTON_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLAT_BUTTON))
#define GTK_FLAT_BUTTON_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FLAT_BUTTON, GtkFlatButtonClass))

Typedefs

typedef struct _GtkFlatButton
typedef struct _GtkFlatButtonClass

Functions

GType gtk_flat_button_get_type (void) G_GNUC_CONST
GtkWidget * gtk_flat_button_new (void)
GtkWidget * gtk_flat_button_new_with_label (const gchar *label)
GtkWidget * gtk_flat_button_new_from_stock (const gchar *stock_id)
 gtk_flat_button_new_from_stock: : the name of the stock item
GtkWidget * gtk_flat_button_new_with_mnemonic (const gchar *label)
 gtk_flat_button_new_with_mnemonic: : The text of the button, with an underscore in front of the mnemonic character
void gtk_flat_button_pressed (GtkFlatButton *button)
void gtk_flat_button_released (GtkFlatButton *button)
void gtk_flat_button_clicked (GtkFlatButton *button)
void gtk_flat_button_enter (GtkFlatButton *button)
void gtk_flat_button_leave (GtkFlatButton *button)
void gtk_flat_button_set_relief (GtkFlatButton *button, GtkReliefStyle newstyle)
GtkReliefStyle gtk_flat_button_get_relief (GtkFlatButton *button)
void gtk_flat_button_set_label (GtkFlatButton *button, const gchar *label)
 gtk_flat_button_set_label: : a #GtkFlatButton : a string
G_CONST_RETURN gchar * gtk_flat_button_get_label (GtkFlatButton *button)
 gtk_flat_button_get_label: : a #GtkFlatButton
void gtk_flat_button_set_use_underline (GtkFlatButton *button, gboolean use_underline)
 gtk_flat_button_set_use_underline: : a #GtkFlatButton : TRUE if underlines in the text indicate mnemonics
gboolean gtk_flat_button_get_use_underline (GtkFlatButton *button)
 gtk_flat_button_get_use_underline: : a #GtkFlatButton
void gtk_flat_button_set_use_stock (GtkFlatButton *button, gboolean use_stock)
 gtk_flat_button_set_use_stock: : a #GtkFlatButton : TRUE if the button should use a stock item
gboolean gtk_flat_button_get_use_stock (GtkFlatButton *button)
 gtk_flat_button_get_use_stock: : a #GtkFlatButton
void gtk_flat_button_set_focus_on_click (GtkFlatButton *button, gboolean focus_on_click)
 gtk_flat_button_set_focus_on_click: : a #GtkFlatButton : whether the button grabs focus when clicked with the mouse
gboolean gtk_flat_button_get_focus_on_click (GtkFlatButton *button)
 gtk_flat_button_get_focus_on_click: : a #GtkFlatButton
void gtk_flat_button_set_alignment (GtkFlatButton *button, gfloat xalign, gfloat yalign)
 gtk_flat_button_set_alignment: : a #GtkFlatButton : the horizontal position of the child, 0.0 is left aligned, 1.0 is right aligned : the vertical position of the child, 0.0 is top aligned, 1.0 is bottom aligned
void gtk_flat_button_get_alignment (GtkFlatButton *button, gfloat *xalign, gfloat *yalign)
 gtk_flat_button_get_alignment: : a #GtkFlatButton : return location for horizontal alignment : return location for vertical alignment
void _gtk_flat_button_set_depressed (GtkFlatButton *button, gboolean depressed)
 _gtk_flat_button_set_depressed: : a #GtkFlatButton : TRUE if the button should be drawn with a recessed shadow.
void _gtk_flat_button_paint (GtkFlatButton *button, GdkRectangle *area, GtkStateType state_type, GtkShadowType shadow_type, const gchar *main_detail, const gchar *default_detail)

Class Documentation

struct _GtkFlatButton

Definition at line 50 of file gtkflatbutton.h.

Class Members
guint activate_timeout
GtkBin bin
guint button_down: 1
guint constructed: 1
guint depress_on_activate: 1
guint depressed: 1
GdkWindow * event_window
guint focus_on_click: 1
guint in_button: 1
gchar * label_text
guint relief: 2
guint use_stock: 1
guint use_underline: 1

Define Documentation

#define GTK_FLAT_BUTTON (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLAT_BUTTON, GtkFlatButton))

Definition at line 41 of file gtkflatbutton.h.

#define GTK_FLAT_BUTTON_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLAT_BUTTON, GtkFlatButtonClass))

Definition at line 42 of file gtkflatbutton.h.

#define GTK_FLAT_BUTTON_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FLAT_BUTTON, GtkFlatButtonClass))

Definition at line 45 of file gtkflatbutton.h.

#define GTK_IS_FLAT_BUTTON (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLAT_BUTTON))

Definition at line 43 of file gtkflatbutton.h.

#define GTK_IS_FLAT_BUTTON_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLAT_BUTTON))

Definition at line 44 of file gtkflatbutton.h.

Definition at line 40 of file gtkflatbutton.h.


Typedef Documentation

typedef struct _GtkFlatButton

Definition at line 47 of file gtkflatbutton.h.

typedef struct _GtkFlatButtonClass

Definition at line 48 of file gtkflatbutton.h.


Function Documentation

void _gtk_flat_button_paint ( GtkFlatButton *  button,
GdkRectangle *  area,
GtkStateType  state_type,
GtkShadowType  shadow_type,
const gchar *  main_detail,
const gchar *  default_detail 
)

Definition at line 1009 of file gtkflatbutton.c.

{
  GtkWidget *widget;
  gint width, height;
  gint x, y;
  gint border_width;
  GtkBorder default_border;
  GtkBorder default_outside_border;
  gboolean interior_focus;
  gint focus_width;
  gint focus_pad;
   
  if (GTK_WIDGET_DRAWABLE (button))
    {
      widget = GTK_WIDGET (button);
      border_width = GTK_CONTAINER (widget)->border_width;

      gtk_flat_button_get_props (button, &default_border, &default_outside_border, &interior_focus);
      gtk_widget_style_get (GTK_WIDGET (widget),
                         "focus-line-width", &focus_width,
                         "focus-padding", &focus_pad,
                         NULL); 
       
      x = widget->allocation.x + border_width;
      y = widget->allocation.y + border_width;
      width = widget->allocation.width - border_width * 2;
      height = widget->allocation.height - border_width * 2;

      if (GTK_WIDGET_HAS_DEFAULT (widget) &&
         GTK_FLAT_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
       {
         gtk_paint_box (widget->style, widget->window,
                      GTK_STATE_NORMAL, GTK_SHADOW_IN,
                      area, widget, "buttondefault",
                      x, y, width, height);

         x += default_border.left;
         y += default_border.top;
         width -= default_border.left + default_border.right;
         height -= default_border.top + default_border.bottom;
       }
      else if (GTK_WIDGET_CAN_DEFAULT (widget))
       {
         x += default_outside_border.left;
         y += default_outside_border.top;
         width -= default_outside_border.left + default_outside_border.right;
         height -= default_outside_border.top + default_outside_border.bottom;
       }
       
      if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
       {
         x += focus_width + focus_pad;
         y += focus_width + focus_pad;
         width -= 2 * (focus_width + focus_pad);
         height -= 2 * (focus_width + focus_pad);
       }

      if (button->relief != GTK_RELIEF_NONE || button->depressed ||
         GTK_WIDGET_STATE(widget) == GTK_STATE_PRELIGHT)
       gtk_paint_box (widget->style, widget->window,
                     state_type,
                     shadow_type, area, widget, "button",
                     x, y, width, height);
       
      if (GTK_WIDGET_HAS_FOCUS (widget))
       {
         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);
           }

         gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget),
                        area, widget, "button",
                        x, y, width, height);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _gtk_flat_button_set_depressed ( GtkFlatButton *  button,
gboolean  depressed 
)

_gtk_flat_button_set_depressed: : a #GtkFlatButton : TRUE if the button should be drawn with a recessed shadow.

Sets whether the button is currently drawn as down or not. This is purely a visual setting, and is meant only for use by derived widgets such as #GtkToggleButton.

Definition at line 1558 of file gtkflatbutton.c.

{
  GtkWidget *widget = GTK_WIDGET (button);

  depressed = depressed != FALSE;

  if (depressed != button->depressed)
    {
      button->depressed = depressed;
      gtk_widget_queue_resize (widget);
    }
}

Here is the caller graph for this function:

void gtk_flat_button_clicked ( GtkFlatButton *  button)

Definition at line 729 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  g_signal_emit (button, button_signals[CLICKED], 0);
}

Here is the caller graph for this function:

void gtk_flat_button_enter ( GtkFlatButton *  button)

Definition at line 737 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  g_signal_emit (button, button_signals[ENTER], 0);
}

Here is the caller graph for this function:

void gtk_flat_button_get_alignment ( GtkFlatButton *  button,
gfloat *  xalign,
gfloat *  yalign 
)

gtk_flat_button_get_alignment: : a #GtkFlatButton : return location for horizontal alignment : return location for vertical alignment

Gets the alignment of the child in the button.

Since: 2.4

Definition at line 1531 of file gtkflatbutton.c.

{
  GtkFlatButtonPrivate *priv;

  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));
  
  priv = GTK_FLAT_BUTTON_GET_PRIVATE (button);
 
  if (xalign) 
    *xalign = priv->xalign;

  if (yalign)
    *yalign = priv->yalign;
}
gboolean gtk_flat_button_get_focus_on_click ( GtkFlatButton *  button)

gtk_flat_button_get_focus_on_click: : a #GtkFlatButton

Returns whether the button grabs focus when it is clicked with the mouse. See gtk_flat_button_set_focus_on_click().

Return value: TRUE if the button grabs focus when it is clicked with the mouse.

Since: 2.4

Definition at line 1477 of file gtkflatbutton.c.

{
  g_return_val_if_fail (GTK_IS_FLAT_BUTTON (button), FALSE);
  
  return button->focus_on_click;
}
G_CONST_RETURN gchar* gtk_flat_button_get_label ( GtkFlatButton *  button)

gtk_flat_button_get_label: : a #GtkFlatButton

Fetches the text from the label of the button, as set by gtk_flat_button_set_label(). If the label text has not been set the return value will be NULL. This will be the case if you create an empty button with gtk_flat_button_new() to use as a container.

Return value: The text of the label widget. This string is owned by the widget and must not be modified or freed.

Definition at line 1341 of file gtkflatbutton.c.

{
  g_return_val_if_fail (GTK_IS_FLAT_BUTTON (button), NULL);
  
  return button->label_text;
}
GtkReliefStyle gtk_flat_button_get_relief ( GtkFlatButton *  button)

Definition at line 767 of file gtkflatbutton.c.

{
  g_return_val_if_fail (button != NULL, GTK_RELIEF_NORMAL);
  g_return_val_if_fail (GTK_IS_FLAT_BUTTON (button), GTK_RELIEF_NORMAL);

  return button->relief;
}

Here is the caller graph for this function:

GType gtk_flat_button_get_type ( void  )

Definition at line 145 of file gtkflatbutton.c.

{
  static GType button_type = 0;

  if (!button_type)
    {
      static const GTypeInfo button_info =
      {
       sizeof (GtkFlatButtonClass),
       NULL,         /* base_init */
       NULL,         /* base_finalize */
       (GClassInitFunc) gtk_flat_button_class_init,
       NULL,         /* class_finalize */
       NULL,         /* class_data */
       sizeof (GtkFlatButton),
       16,           /* n_preallocs */
       (GInstanceInitFunc) gtk_flat_button_init,
      };

      button_type = g_type_register_static (GTK_TYPE_BIN, "GtkFlatButton",
                                       &button_info, 0);
    }

  return button_type;
}

Here is the call graph for this function:

gboolean gtk_flat_button_get_use_stock ( GtkFlatButton *  button)

gtk_flat_button_get_use_stock: : a #GtkFlatButton

Returns whether the button label is a stock item.

Return value: TRUE if the button label is used to select a stock item instead of being used directly as the label text.

Definition at line 1429 of file gtkflatbutton.c.

{
  g_return_val_if_fail (GTK_IS_FLAT_BUTTON (button), FALSE);
  
  return button->use_stock;
}
gboolean gtk_flat_button_get_use_underline ( GtkFlatButton *  button)

gtk_flat_button_get_use_underline: : a #GtkFlatButton

Returns whether an embedded underline in the button label indicates a mnemonic. See gtk_flat_button_set_use_underline ().

Return value: TRUE if an embedded underline in the button label indicates the mnemonic accelerator keys.

Definition at line 1385 of file gtkflatbutton.c.

{
  g_return_val_if_fail (GTK_IS_FLAT_BUTTON (button), FALSE);
  
  return button->use_underline;
}
void gtk_flat_button_leave ( GtkFlatButton *  button)

Definition at line 745 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  g_signal_emit (button, button_signals[LEAVE], 0);
}

Here is the caller graph for this function:

GtkWidget* gtk_flat_button_new ( void  )

Definition at line 573 of file gtkflatbutton.c.

{
  return g_object_new (GTK_TYPE_FLAT_BUTTON, NULL);
}

Here is the caller graph for this function:

GtkWidget* gtk_flat_button_new_from_stock ( const gchar *  stock_id)

gtk_flat_button_new_from_stock: : the name of the stock item

Creates a new #GtkFlatButton containing the image and text from a stock item. Some stock ids have preprocessor macros like #GTK_STOCK_OK and

GTK_STOCK_APPLY.

If is unknown, then it will be treated as a mnemonic label (as for gtk_flat_button_new_with_mnemonic()).

Returns: a new #GtkFlatButton

Definition at line 683 of file gtkflatbutton.c.

{
  return g_object_new (GTK_TYPE_FLAT_BUTTON,
                       "label", stock_id,
                       "use_stock", TRUE,
                       "use_underline", TRUE,
                       NULL);
}
GtkWidget* gtk_flat_button_new_with_label ( const gchar *  label)

Definition at line 664 of file gtkflatbutton.c.

{
  return g_object_new (GTK_TYPE_FLAT_BUTTON, "label", label, NULL);
}
GtkWidget* gtk_flat_button_new_with_mnemonic ( const gchar *  label)

gtk_flat_button_new_with_mnemonic: : The text of the button, with an underscore in front of the mnemonic character

Returns:
: a new #GtkFlatButton

Creates a new #GtkFlatButton containing a label. If characters in are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use '__' (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.

Definition at line 706 of file gtkflatbutton.c.

{
  return g_object_new (GTK_TYPE_FLAT_BUTTON, "label", label, "use_underline", TRUE,  NULL);
}
void gtk_flat_button_pressed ( GtkFlatButton *  button)

Definition at line 712 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  
  g_signal_emit (button, button_signals[PRESSED], 0);
}

Here is the caller graph for this function:

void gtk_flat_button_released ( GtkFlatButton *  button)

Definition at line 721 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  g_signal_emit (button, button_signals[RELEASED], 0);
}

Here is the caller graph for this function:

void gtk_flat_button_set_alignment ( GtkFlatButton *  button,
gfloat  xalign,
gfloat  yalign 
)

gtk_flat_button_set_alignment: : a #GtkFlatButton : the horizontal position of the child, 0.0 is left aligned, 1.0 is right aligned : the vertical position of the child, 0.0 is top aligned, 1.0 is bottom aligned

Sets the alignment of the child. This property has no effect unless the child is a #GtkMisc or a #GtkAligment.

Since: 2.4

Definition at line 1498 of file gtkflatbutton.c.

{
  GtkFlatButtonPrivate *priv;

  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));
  
  priv = GTK_FLAT_BUTTON_GET_PRIVATE (button);

  priv->xalign = xalign;
  priv->yalign = yalign;
  priv->align_set = 1;

  maybe_set_alignment (button, GTK_BIN (button)->child);

  g_object_freeze_notify (G_OBJECT (button));
  g_object_notify (G_OBJECT (button), "xalign");
  g_object_notify (G_OBJECT (button), "yalign");
  g_object_thaw_notify (G_OBJECT (button));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_flat_button_set_focus_on_click ( GtkFlatButton *  button,
gboolean  focus_on_click 
)

gtk_flat_button_set_focus_on_click: : a #GtkFlatButton : whether the button grabs focus when clicked with the mouse

Sets whether the button will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.

Since: 2.4

Definition at line 1449 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));
  
  focus_on_click = focus_on_click != FALSE;

  if (button->focus_on_click != focus_on_click)
    {
      button->focus_on_click = focus_on_click;
      
      g_object_notify (G_OBJECT (button), "focus_on_click");
    }
}

Here is the caller graph for this function:

void gtk_flat_button_set_label ( GtkFlatButton *  button,
const gchar *  label 
)

gtk_flat_button_set_label: : a #GtkFlatButton : a string

Sets the text of the label of the button to . This text is also used to select the stock item if gtk_flat_button_set_use_stock() is used.

This will also clear any previously set labels.

Definition at line 1311 of file gtkflatbutton.c.

{
  gchar *new_label;
  
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  new_label = g_strdup (label);
  g_free (button->label_text);
  button->label_text = new_label;
  
  gtk_flat_button_construct_child (button);
  
  g_object_notify (G_OBJECT (button), "label");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_flat_button_set_relief ( GtkFlatButton *  button,
GtkReliefStyle  newstyle 
)

Definition at line 753 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  if (newrelief != button->relief) 
    {
       button->relief = newrelief;
       g_object_notify (G_OBJECT (button), "relief");
       gtk_widget_queue_draw (GTK_WIDGET (button));
    }
}

Here is the caller graph for this function:

void gtk_flat_button_set_use_stock ( GtkFlatButton *  button,
gboolean  use_stock 
)

gtk_flat_button_set_use_stock: : a #GtkFlatButton : TRUE if the button should use a stock item

If true, the label set on the button is used as a stock id to select the stock item for the button.

Definition at line 1401 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  use_stock = use_stock != FALSE;

  if (use_stock != button->use_stock)
    {
      button->use_stock = use_stock;
  
      gtk_flat_button_construct_child (button);
      
      g_object_notify (G_OBJECT (button), "use_stock");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gtk_flat_button_set_use_underline ( GtkFlatButton *  button,
gboolean  use_underline 
)

gtk_flat_button_set_use_underline: : a #GtkFlatButton : TRUE if underlines in the text indicate mnemonics

If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.

Definition at line 1357 of file gtkflatbutton.c.

{
  g_return_if_fail (GTK_IS_FLAT_BUTTON (button));

  use_underline = use_underline != FALSE;

  if (use_underline != button->use_underline)
    {
      button->use_underline = use_underline;
  
      gtk_flat_button_construct_child (button);
      
      g_object_notify (G_OBJECT (button), "use_underline");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: