]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkwindow-decorate.c
docs: Move documentation to inline comments: GtkCellRenderer
[~andy/gtk] / gtk / gtkwindow-decorate.c
index f0d6db56f8cec58099570168832f18bc575c7edf..1a276f85b499a28063d8d534228963ecec33cf01 100644 (file)
  * Authors: Alexander Larsson <alexl@redhat.com>
  */
 
-#include <config.h>
+#include "config.h"
 #include "gtkprivate.h"
 #include "gtkwindow.h"
 #include "gtkmain.h"
+#include "gtkwindow-decorate.h"
+#include "gtkintl.h"
 
 
-#ifdef GDK_WINDOWING_FB
-#define DECORATE_WINDOWS
-#endif
-
 #ifdef DECORATE_WINDOWS
-#include "linux-fb/gdkfb.h"
 
 typedef enum
 {
@@ -146,21 +143,21 @@ gtk_decorated_window_init (GtkWindow   *window)
   deco->maximizable = FALSE;
   deco->real_inner_move = FALSE;
  
-  g_object_set_data_full (G_OBJECT (window), "gtk-window-decoration", deco,
+  g_object_set_data_full (G_OBJECT (window), I_("gtk-window-decoration"), deco,
                          (GDestroyNotify) gtk_decoration_free);
   
   gtk_window_set_has_frame (window, TRUE);
 
   g_signal_connect (window,
-                   "frame_event",
+                   "frame-event",
                    G_CALLBACK (gtk_decorated_window_frame_event),
                    window);
   g_signal_connect (window,
-                   "focus_in_event",
+                   "focus-in-event",
                    G_CALLBACK (gtk_decorated_window_focus_change),
                    window);
   g_signal_connect (window,
-                   "focus_out_event",
+                   "focus-out-event",
                    G_CALLBACK (gtk_decorated_window_focus_change),
                    window);
   g_signal_connect (window,
@@ -281,15 +278,6 @@ gtk_decorated_window_realize (GtkWindow   *window)
   font_desc = pango_font_description_from_string(DECORATION_TITLE_FONT);
   pango_layout_set_font_description (deco->title_layout, font_desc);
   pango_font_description_free (font_desc);
-  
-  gdk_fb_window_set_child_handler (window->frame,
-                                  gtk_decorated_window_inner_change,
-                                  gtk_decorated_window_inner_get_pos,
-                                  window);
-
-  /* This is a huge hack to make frames have the same shape as
-     the window they wrap */
-  gdk_window_shape_combine_mask (window->frame, GDK_FB_USE_CHILD_SHAPE, 0, 0);
 }
 
 
@@ -382,7 +370,7 @@ gtk_decorated_window_motion_notify (GtkWidget       *widget,
       dx = x - deco->last_x;
       dy = y - deco->last_y;
 
-      _gtk_window_reposition (window, win_x + dx, win_y + dy);
+      gtk_window_move (window, win_x + dx, win_y + dy);
     }
 
   if (deco->resize != RESIZE_NONE)
@@ -566,14 +554,14 @@ gtk_decorated_window_window_state (GtkWidget             *widget,
          _gtk_window_constrain_size (window, w, h, &w, &h);
          if (w != deco->last_w || h != deco->last_h)
            {
-             _gtk_window_reposition (window, DECORATION_BORDER_LEFT, DECORATION_BORDER_TOP);
+             gtk_window_move (window, DECORATION_BORDER_LEFT, DECORATION_BORDER_TOP);
              gdk_window_resize (widget->window, w, h);
              deco->maximized = TRUE;
            }
        }
       else
        {
-         _gtk_window_reposition (window, deco->last_x, deco->last_y);
+         gtk_window_move (window, deco->last_x, deco->last_y);
          _gtk_window_constrain_size (window, deco->last_w, deco->last_h,
                                      &deco->last_w, &deco->last_h);
          gdk_window_resize (widget->window, deco->last_w, deco->last_h);
@@ -591,6 +579,7 @@ gtk_decorated_window_paint (GtkWidget    *widget,
   GtkWindowDecoration *deco = get_decoration (window);
   gint x1, y1, x2, y2;
   GtkStateType border_state;
+  cairo_t *cr;
 
   if (deco->decorated)
     {
@@ -636,6 +625,16 @@ gtk_decorated_window_paint (GtkWidget    *widget,
                     DECORATION_BORDER_LEFT - 2, DECORATION_BORDER_TOP - 2,
                     width - (DECORATION_BORDER_LEFT + DECORATION_BORDER_RIGHT) + 3,
                     height - (DECORATION_BORDER_TOP + DECORATION_BORDER_BOTTOM) + 3);
+      
+      cr = gdk_cairo_create (frame);
+      cairo_set_line_width (cr, 1.0);
+      cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+      if (area)
+        {
+          gdk_cairo_rectangle (cr, &area);
+          cairo_clip (cr);
+        }
 
       if (deco->maximizable)
        {
@@ -646,20 +645,16 @@ gtk_decorated_window_paint (GtkWidget    *widget,
          x2 = x1 + DECORATION_BUTTON_SIZE;
          y2 = y1 + DECORATION_BUTTON_SIZE;
 
-         if (area)
-           gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], area);
+          gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
+          cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
+          cairo_fill (cr);
 
-         gdk_draw_rectangle (frame, widget->style->bg_gc[widget->state], TRUE,
-                             x1, y1, x2 - x1, y2 - y1);
-
-         gdk_draw_line (frame, widget->style->black_gc, x1 + 1, y1 + 1, x2 - 2, y1 + 1);
-
-         gdk_draw_rectangle (frame, widget->style->black_gc, FALSE,
-                             x1 + 1, y1 + 2,
-                             DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
-
-         if (area)
-           gdk_gc_set_clip_rectangle (widget->style->black_gc, NULL);
+          gdk_cairo_set_source_rgb (cr, 0, 0, 0);
+          cairo_rectangle (cr, x1 + 1, y1 + 1, x2 - x1 - 3, 1);
+          cairo_move_to (cr, x1 + 1.5, y1 + 1.5);
+          cairo_line_to (cr, x2 - 1.5, y1 + 1.5);
+          cairo_rectangle (cr, x1 + 1.5, y1 + 2.5, DECORATION_BUTTON_SIZE - 3, DECORATION_BUTTON_SIZE - 4);
+          cairo_stroke (cr);
        }
       
       /* Close button: */
@@ -669,41 +664,25 @@ gtk_decorated_window_paint (GtkWidget    *widget,
       x2 = width - DECORATION_BORDER_LEFT;
       y2 = DECORATION_BUTTON_Y_OFFSET + DECORATION_BUTTON_SIZE;
 
-      if (area)
-       gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], area);
-
-      gdk_draw_rectangle (frame, widget->style->bg_gc[widget->state], TRUE,
-                         x1, y1, x2 - x1, y2 - y1);
-
-      if (area)
-       gdk_gc_set_clip_rectangle (widget->style->bg_gc[widget->state], NULL);
-      
-      if (area)
-       gdk_gc_set_clip_rectangle (widget->style->black_gc, area);
-
-      gdk_draw_line (frame, widget->style->black_gc, x1, y1, x2-1, y2-1);
+      gdk_cairo_set_source_color (cr, &widget->style->bg[widget->state]);
+      cairo_rectangle (cr, x1, y1, x2 - x1, y2 - y1);
+      cairo_fill (cr);
 
-      gdk_draw_line (frame, widget->style->black_gc, x1, y2-1, x2-1, y1);
-
-      if (area)
-       gdk_gc_set_clip_rectangle (widget->style->black_gc, NULL);
-      
-      
+      /* draw an X */
+      cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+      cairo_line_to (cr, x2 - 0.5, y2 - 0.5);
+      cairo_move_to (cr, x1 + 0.5, y2 - 0.5);
+      cairo_line_to (cr, x2 - 0.5, y1 + 0.5);
+      cairo_stroke (cr);
 
       /* Title */
       if (deco->title_layout)
        {
-         if (area)
-           gdk_gc_set_clip_rectangle (widget->style->fg_gc [border_state], area);
-
-         gdk_draw_layout (frame,
-                          widget->style->fg_gc [border_state],
-                          DECORATION_BORDER_LEFT, 1,
-                          deco->title_layout);
-         if (area)
-           gdk_gc_set_clip_rectangle (widget->style->fg_gc [border_state], NULL);
+          gdk_cairo_set_source_color (cr, widget->style->fg [border_state]);
+          pango_cairo_show_layout (cr, deco->title_layout);
        }
-      
+
+      cairo_destroy (cr);
     }
 }
 
@@ -724,7 +703,7 @@ gtk_decorated_window_recalculate_regions (GtkWindow *window)
   n_regions += 2; /* close, Title */
   if (deco->maximizable)
     n_regions += 1;
-  if (window->allow_shrink || window->allow_grow)
+  if (gtk_window_get_resizable (window))
     n_regions += 2;
 
   if (deco->n_regions != n_regions)
@@ -766,7 +745,7 @@ gtk_decorated_window_recalculate_regions (GtkWindow *window)
   region->type = GTK_WINDOW_REGION_TITLE;
   region++;
   
-  if (window->allow_shrink || window->allow_grow)
+  if (gtk_window_get_resizable (window))
     {
       region->rect.x = width - (DECORATION_BORDER_RIGHT + 10);
       region->rect.y = height - DECORATION_BORDER_BOTTOM;
@@ -823,10 +802,7 @@ gtk_decorated_window_move_resize_window (GtkWindow   *window,
                                         gint         width,
                                         gint         height)
 {
-  gdk_window_move_resize (GTK_WIDGET (window)->window,
+  gdk_window_move_resize (gtk_widget_get_window (GTK_WIDGET (window)),
                          x, y, width, height);
 }
 #endif
-
-
-