diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-09 15:36:54 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-09 15:36:54 +0800 |
commit | a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3 (patch) | |
tree | f67e1349246b009e89f8a2e819b99908394b0268 /calendar/gncal-full-day.c | |
parent | 8e5a66e2c304f3cae73838495868941b6f66c7dc (diff) | |
download | gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.gz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.bz2 gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.lz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.xz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.zst gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.zip |
Show instead of just map the child widget (otherwise the text widget gets
1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (child_map): Show instead of just map the child
widget (otherwise the text widget gets confused and will not focus).
* calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x".
* calobj.h: Added prototype for ical_object_to_vobject().
* gnome-cal.c (gnome_calendar_object_changed): New function. This
should be called when a calendar object is changed.
* gncal-full-day.c (update_from_drag_info): Call
gnome_calendar_object_changed() instead of updating manually.
* calendar.c (calendar_add_object):
(calendar_remove_object): Set the modified flag to true.
* gncal-full-day.c (gncal_full_day_draw): Finished implementing
this function.
svn path=/trunk/; revision=120
Diffstat (limited to 'calendar/gncal-full-day.c')
-rw-r--r-- | calendar/gncal-full-day.c | 262 |
1 files changed, 139 insertions, 123 deletions
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index 90a4813947..db743431ee 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -127,9 +127,7 @@ static void child_map (GncalFullDay *fullday, Child *child) { gdk_window_show (child->window); - - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); + gtk_widget_show (child->widget); /* OK, not just a map... */ } static void @@ -203,16 +201,13 @@ static void child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_child) { GdkRectangle arect, rect, dest; - gint w, h; - - gdk_window_get_size (child->window, &w, &h); if (!area) { arect.x = 0; arect.y = 0; - arect.width = w; - arect.height = h; + arect.width = child->width; + arect.height = child->height; area = &arect; } @@ -221,7 +216,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch rect.x = 0; rect.y = 0; - rect.width = w; + rect.width = child->width; rect.height = HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) @@ -229,7 +224,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch /* Bottom handle */ - rect.y = h - HANDLE_SIZE; + rect.y = child->height - HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); @@ -284,6 +279,8 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + /* FIXME: need notify calendar of change? */ + return FALSE; } @@ -457,11 +454,10 @@ calc_labels_width (GncalFullDay *fullday) } static void -layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) +layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows, int left_x) { - int c_x, c_y, c_width, c_height; + int c_y, c_width, c_height; GtkWidget *widget; - int labels_width; int height, f_rows; int row_height; @@ -469,26 +465,23 @@ layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) widget = GTK_WIDGET (fullday); - labels_width = calc_labels_width (fullday); /* FIXME: this is expensive to do for each child */ - get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows); height = widget->allocation.height - 2 * widget->style->klass->ythickness; row_height = height / f_rows; - c_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + labels_width; c_y = widget->style->klass->ythickness; /* FIXME: for now, the children overlap. Make it layout them nicely. */ - c_width = widget->allocation.width - (widget->style->klass->xthickness + c_x); + c_width = widget->allocation.width - (widget->style->klass->xthickness + left_x); c_y += child->lower_row * row_height; c_height = child->rows_used * row_height; /* Position child */ - child_set_pos (fullday, child, c_x, c_y, c_width, c_height); + child_set_pos (fullday, child, left_x, c_y, c_width, c_height); } static void @@ -496,11 +489,17 @@ layout_children (GncalFullDay *fullday) { struct layout_row *rows; GList *children; + GtkWidget *widget; + int left_x; rows = layout_get_rows (fullday); + widget = GTK_WIDGET (fullday); + + left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday); + for (children = fullday->children; children; children = children->next) - layout_child (fullday, children->data, rows); + layout_child (fullday, children->data, rows, left_x); g_free (rows); } @@ -722,9 +721,111 @@ gncal_full_day_unrealize (GtkWidget *widget) } static void +paint_back (GncalFullDay *fullday, GdkRectangle *area) +{ + GtkWidget *widget; + GdkRectangle rect, dest; + int x1, y1, width, height; + int labels_width, division_x; + int rows, row_height; + int i, y; + struct tm tm; + char buf[256]; + + widget = GTK_WIDGET (fullday); + + x1 = widget->style->klass->xthickness; + y1 = widget->style->klass->ythickness; + width = widget->allocation.width - 2 * x1; + height = widget->allocation.height - 2 * y1; + + /* Clear and paint frame shadow */ + + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + gtk_draw_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + /* Clear space for labels */ + + labels_width = calc_labels_width (fullday); + + rect.x = x1; + rect.y = y1; + rect.width = 2 * TEXT_BORDER + labels_width; + rect.height = height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) + gdk_draw_rectangle (widget->window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + dest.x, dest.y, + dest.width, dest.height); + + /* Vertical division */ + + division_x = x1 + 2 * TEXT_BORDER + labels_width; + + gtk_draw_vline (widget->style, widget->window, + GTK_STATE_NORMAL, + y1, + y1 + height - 1, + division_x); + + /* Horizontal divisions */ + + get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); + + row_height = height / rows; /* includes division line at bottom of row */ + + y = y1 + row_height - 1; + + for (i = 1; i < rows; i++) { + gdk_draw_line (widget->window, + widget->style->black_gc, + x1, y, + x1 + width - 1, y); + + y += row_height; + } + + /* Labels */ + + y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; + + rect.height = row_height - 1; + + for (i = 0; i < rows; i++) { + mktime (&tm); + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + strftime (buf, 256, "%X", &tm); + + gdk_draw_string (widget->window, + widget->style->font, + widget->style->fg_gc[GTK_STATE_NORMAL], + x1 + TEXT_BORDER, + y + widget->style->font->ascent, + buf); + } + + rect.y += row_height; + y += row_height; + + tm.tm_min += fullday->interval; + } +} + +static void gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) { GncalFullDay *fullday; + GList *children; + Child *child; + GdkRectangle rect, dest; g_return_if_fail (widget != NULL); g_return_if_fail (GNCAL_IS_FULL_DAY (widget)); @@ -735,7 +836,23 @@ gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) fullday = GNCAL_FULL_DAY (widget); - /* FIXME */ + paint_back (fullday, area); + + for (children = fullday->children; children; children = children->next) { + child = children->data; + + rect.x = child->x; + rect.y = child->y; + rect.width = child->width; + rect.height = child->height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + dest.x -= child->x; + dest.y -= child->y; + + child_draw (fullday, child, &dest, TRUE); + } + } } static void @@ -957,11 +1074,9 @@ update_from_drag_info (GncalFullDay *fullday) child_range_changed (fullday, di->child); - /* FIXME: notify calendar of change */ + /* Notify calendar of change */ - /* FIXME: re-layout or let notification do it? */ - - layout_children (fullday); + gnome_calendar_object_changed (fullday->calendar, di->child->ico); } static gint @@ -1021,105 +1136,6 @@ gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event) return FALSE; } -static void -paint_back (GncalFullDay *fullday, GdkRectangle *area) -{ - GtkWidget *widget; - GdkRectangle rect, dest; - int x1, y1, width, height; - int labels_width, division_x; - int rows, row_height; - int i, y; - struct tm tm; - char buf[256]; - - widget = GTK_WIDGET (fullday); - - x1 = widget->style->klass->xthickness; - y1 = widget->style->klass->ythickness; - width = widget->allocation.width - 2 * x1; - height = widget->allocation.height - 2 * y1; - - /* Clear and paint frame shadow */ - - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - /* Clear space for labels */ - - labels_width = calc_labels_width (fullday); - - rect.x = x1; - rect.y = y1; - rect.width = 2 * TEXT_BORDER + labels_width; - rect.height = height; - - if (gdk_rectangle_intersect (&rect, area, &dest)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - dest.x, dest.y, - dest.width, dest.height); - - /* Vertical division */ - - division_x = x1 + 2 * TEXT_BORDER + labels_width; - - gtk_draw_vline (widget->style, widget->window, - GTK_STATE_NORMAL, - y1, - y1 + height - 1, - division_x); - - /* Horizontal divisions */ - - get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); - - row_height = height / rows; /* includes division line at bottom of row */ - - y = y1 + row_height - 1; - - for (i = 1; i < rows; i++) { - gdk_draw_line (widget->window, - widget->style->black_gc, - x1, y, - x1 + width - 1, y); - - y += row_height; - } - - /* Labels */ - - y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; - - rect.height = row_height - 1; - - for (i = 0; i < rows; i++) { - mktime (&tm); - - if (gdk_rectangle_intersect (&rect, area, &dest)) { - strftime (buf, 256, "%X", &tm); - - gdk_draw_string (widget->window, - widget->style->font, - widget->style->fg_gc[GTK_STATE_NORMAL], - x1 + TEXT_BORDER, - y + widget->style->font->ascent, - buf); - } - - rect.y += row_height; - y += row_height; - - tm.tm_min += fullday->interval; - } -} - static gint gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event) { |