]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcheckbutton.c
changed reversed_[12] to reserved_[12] in gtk_*_get_type functions.
[~andy/gtk] / gtk / gtkcheckbutton.c
index 9266120179851aefa6bcc2888d78344a087919c2..38bc73b824758a5eae82dc6a8c7a89c33c894466 100644 (file)
@@ -12,8 +12,9 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
 #include "gtkcheckbutton.h"
 #include "gtklabel.h"
@@ -45,10 +46,10 @@ static void gtk_real_check_button_draw_indicator (GtkCheckButton      *check_but
 static GtkToggleButtonClass *parent_class = NULL;
 
 
-guint
-gtk_check_button_get_type ()
+GtkType
+gtk_check_button_get_type (void)
 {
-  static guint check_button_type = 0;
+  static GtkType check_button_type = 0;
 
   if (!check_button_type)
     {
@@ -59,8 +60,9 @@ gtk_check_button_get_type ()
        sizeof (GtkCheckButtonClass),
        (GtkClassInitFunc) gtk_check_button_class_init,
        (GtkObjectInitFunc) gtk_check_button_init,
-       (GtkArgSetFunc) NULL,
-        (GtkArgGetFunc) NULL,
+       /* reserved_1 */ NULL,
+        /* reserved_2 */ NULL,
+        (GtkClassInitFunc) NULL,
       };
 
       check_button_type = gtk_type_unique (gtk_toggle_button_get_type (), &check_button_info);
@@ -95,7 +97,7 @@ gtk_check_button_init (GtkCheckButton *check_button)
 }
 
 GtkWidget*
-gtk_check_button_new ()
+gtk_check_button_new (void)
 {
   return GTK_WIDGET (gtk_type_new (gtk_check_button_get_type ()));
 }
@@ -157,25 +159,30 @@ static void
 gtk_check_button_draw_focus (GtkWidget *widget)
 {
   GtkCheckButton *check_button;
-
+  
   g_return_if_fail (widget != NULL);
   g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
-
-  if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
+  
+  if (GTK_WIDGET_DRAWABLE (widget))
     {
       check_button = GTK_CHECK_BUTTON (widget);
       if (check_button->toggle_button.draw_indicator)
        {
+         gint border_width;
+         
+         border_width = GTK_CONTAINER (widget)->border_width;
          if (GTK_WIDGET_HAS_FOCUS (widget))
            gdk_draw_rectangle (widget->window,
-                               widget->style->black_gc, FALSE, 0, 0,
-                               widget->allocation.width - 1,
-                               widget->allocation.height - 1);
+                               widget->style->black_gc, FALSE,
+                               border_width, border_width,
+                               widget->allocation.width - 2 * border_width - 1,
+                               widget->allocation.height - 2 * border_width - 1);
          else
            gdk_draw_rectangle (widget->window,
-                               widget->style->bg_gc[GTK_STATE_NORMAL], FALSE, 0, 0,
-                               widget->allocation.width - 1,
-                               widget->allocation.height - 1);
+                               widget->style->bg_gc[GTK_STATE_NORMAL], FALSE,
+                               border_width, border_width,
+                               widget->allocation.width - 2 * border_width - 1,
+                               widget->allocation.height - 2 * border_width - 1);
        }
       else
        {
@@ -244,9 +251,9 @@ gtk_check_button_size_allocate (GtkWidget     *widget,
                                CHECK_BUTTON_CLASS (widget)->indicator_size +
                                CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1);
          child_allocation.y = GTK_CONTAINER (widget)->border_width + 1;
-         child_allocation.width = (allocation->width - child_allocation.x  -
+         child_allocation.width = MAX (1, allocation->width - child_allocation.x  -
                                    GTK_CONTAINER (widget)->border_width - 1);
-         child_allocation.height = allocation->height - child_allocation.y * 2;
+         child_allocation.height = MAX (1, allocation->height - child_allocation.y * 2);
 
          gtk_widget_size_allocate (button->child, &child_allocation);
        }
@@ -322,6 +329,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
   GtkToggleButton *toggle_button;
   GtkStateType state_type;
   GtkShadowType shadow_type;
+  GdkRectangle restrict_area;
+  GdkRectangle new_area;
   gint width, height;
   gint x, y;
 
@@ -338,17 +347,24 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
          (state_type != GTK_STATE_PRELIGHT))
        state_type = GTK_STATE_NORMAL;
 
-      gtk_style_set_background (widget->style, widget->window, state_type);
-      gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+      restrict_area.x = GTK_CONTAINER (widget)->border_width;
+      restrict_area.y = restrict_area.x;
+      restrict_area.width = widget->allocation.width - restrict_area.x * 2;
+      restrict_area.height = widget->allocation.height - restrict_area.x * 2;
 
+      if (gdk_rectangle_intersect (area, &restrict_area, &new_area))
+       {
+         gtk_style_set_background (widget->style, widget->window, state_type);
+         gdk_window_clear_area (widget->window, new_area.x, new_area.y,
+                                new_area.width, new_area.height);
+       }
+      
       x = CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
       y = (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2;
       width = CHECK_BUTTON_CLASS (widget)->indicator_size;
       height = CHECK_BUTTON_CLASS (widget)->indicator_size;
 
-      if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE)
-       shadow_type = GTK_SHADOW_IN;
-      else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) && toggle_button->active)
+      if (GTK_TOGGLE_BUTTON (widget)->active)
        shadow_type = GTK_SHADOW_IN;
       else
        shadow_type = GTK_SHADOW_OUT;