comparison src/gtkimhtml.c @ 1980:5b79252ea95c

[gaim-migrate @ 1990] hi there committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 09 Jun 2001 23:57:28 +0000
parents e43c267b1a8a
children fc0a285c207a
comparison
equal deleted inserted replaced
1979:e43c267b1a8a 1980:5b79252ea95c
209 209
210 static void 210 static void
211 gtk_imhtml_realize (GtkWidget *widget) 211 gtk_imhtml_realize (GtkWidget *widget)
212 { 212 {
213 GtkIMHtml *imhtml; 213 GtkIMHtml *imhtml;
214 GdkWindowAttr attributes;
215 gint attributes_mask;
214 216
215 g_return_if_fail (widget != NULL); 217 g_return_if_fail (widget != NULL);
216 g_return_if_fail (GTK_IS_IMHTML (widget)); 218 g_return_if_fail (GTK_IS_IMHTML (widget));
217 219
218 imhtml = GTK_IMHTML (widget); 220 imhtml = GTK_IMHTML (widget);
219 221 GTK_WIDGET_SET_FLAGS (imhtml, GTK_REALIZED);
220 if (GTK_WIDGET_CLASS (parent_class)->realize) 222
221 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); 223 attributes.window_type = GDK_WINDOW_CHILD;
224 attributes.x = widget->allocation.x;
225 attributes.y = widget->allocation.y;
226 attributes.width = widget->allocation.width;
227 attributes.height = widget->allocation.height;
228 attributes.wclass = GDK_INPUT_OUTPUT;
229 attributes.visual = gtk_widget_get_visual (widget);
230 attributes.colormap = gtk_widget_get_colormap (widget);
231 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
232
233 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
234
235 widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
236 &attributes, attributes_mask);
237 gdk_window_set_user_data (widget->window, widget);
238
239 attributes.x = 0;
240 attributes.y = 0;
241 attributes.event_mask = gtk_widget_get_events (widget)
242 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
243 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK;
244
245 GTK_LAYOUT (imhtml)->bin_window = gdk_window_new (widget->window,
246 &attributes, attributes_mask);
247 gdk_window_set_user_data (GTK_LAYOUT (imhtml)->bin_window, widget);
222 248
223 widget->style = gtk_style_attach (widget->style, widget->window); 249 widget->style = gtk_style_attach (widget->style, widget->window);
224 gdk_window_set_events (GTK_LAYOUT (imhtml)->bin_window,
225 (gdk_window_get_events (GTK_LAYOUT (imhtml)->bin_window)
226 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
227 | GDK_POINTER_MOTION_MASK | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK));
228 250
229 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); 251 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor);
230 252
231 gdk_color_alloc (gtk_widget_get_colormap (widget), imhtml->default_bg_color); 253 gdk_window_set_background (widget->window, &widget->style->base [GTK_WIDGET_STATE (widget)]);
232 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, imhtml->default_bg_color); 254 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window,
255 &widget->style->base [GTK_WIDGET_STATE (widget)]);
233 } 256 }
234 257
235 static gboolean 258 static gboolean
236 similar_colors (GdkColor *bg, 259 similar_colors (GdkColor *bg,
237 GdkColor *fg) 260 GdkColor *fg)
625 static void 648 static void
626 gtk_imhtml_size_allocate (GtkWidget *widget, 649 gtk_imhtml_size_allocate (GtkWidget *widget,
627 GtkAllocation *allocation) 650 GtkAllocation *allocation)
628 { 651 {
629 GtkIMHtml *imhtml; 652 GtkIMHtml *imhtml;
653 GtkLayout *layout;
630 654
631 g_return_if_fail (widget != NULL); 655 g_return_if_fail (widget != NULL);
632 g_return_if_fail (GTK_IS_IMHTML (widget)); 656 g_return_if_fail (GTK_IS_IMHTML (widget));
633 g_return_if_fail (allocation != NULL); 657 g_return_if_fail (allocation != NULL);
634 658
635 imhtml = GTK_IMHTML (widget); 659 imhtml = GTK_IMHTML (widget);
636 660 layout = GTK_LAYOUT (widget);
637 if (GTK_WIDGET_CLASS (parent_class)->size_allocate) 661
638 ( *GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); 662 widget->allocation = *allocation;
663
664 if (GTK_WIDGET_REALIZED (widget)) {
665 gdk_window_move_resize (widget->window,
666 allocation->x, allocation->y,
667 allocation->width, allocation->height);
668 gdk_window_move_resize (layout->bin_window,
669 0, 0,
670 allocation->width, allocation->height);
671 }
672
673 layout->hadjustment->page_size = allocation->width;
674 layout->hadjustment->page_increment = allocation->width / 2;
675 layout->hadjustment->lower = 0;
676 layout->hadjustment->upper = imhtml->xsize;
677
678 layout->vadjustment->page_size = allocation->height;
679 layout->vadjustment->page_increment = allocation->height / 2;
680 layout->vadjustment->lower = 0;
681 layout->vadjustment->upper = imhtml->y + 5;
682
683 gtk_signal_emit_by_name (GTK_OBJECT (layout->hadjustment), "changed");
684 gtk_signal_emit_by_name (GTK_OBJECT (layout->vadjustment), "changed");
639 685
640 if (allocation->width == imhtml->xsize) { 686 if (allocation->width == imhtml->xsize) {
641 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y + 5 - allocation->height)) { 687 if ((GTK_LAYOUT (imhtml)->vadjustment->value > imhtml->y + 5 - allocation->height)) {
642 if (imhtml->y + 5 > allocation->height) 688 if (imhtml->y + 5 > allocation->height)
643 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment, 689 gtk_adjustment_set_value (GTK_LAYOUT (imhtml)->vadjustment,
648 return; 694 return;
649 } 695 }
650 696
651 imhtml->xsize = allocation->width; 697 imhtml->xsize = allocation->width;
652 698
653 gtk_imhtml_redraw_all (imhtml); 699 if (GTK_WIDGET_REALIZED (widget))
700 gtk_imhtml_redraw_all (imhtml);
654 } 701 }
655 702
656 static void 703 static void
657 gtk_imhtml_select_none (GtkIMHtml *imhtml) 704 gtk_imhtml_select_none (GtkIMHtml *imhtml)
658 { 705 {
1331 1378
1332 static void 1379 static void
1333 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment, 1380 gtk_imhtml_adjustment_changed (GtkAdjustment *adjustment,
1334 GtkIMHtml *imhtml) 1381 GtkIMHtml *imhtml)
1335 { 1382 {
1336 gint width, height; 1383 gint dx, dy;
1337 GdkWindow *window; 1384 GtkLayout *layout = GTK_LAYOUT (imhtml);
1338 1385 GtkWidget *widget = GTK_WIDGET (imhtml);
1339 if (!GTK_WIDGET_MAPPED (imhtml)) 1386
1387 dx = (gint) layout->hadjustment->value - layout->xoffset;
1388 dy = (gint) layout->vadjustment->value - layout->yoffset;
1389
1390 layout->xoffset = (gint) layout->hadjustment->value;
1391 layout->yoffset = (gint) layout->vadjustment->value;
1392
1393 if (!GTK_WIDGET_MAPPED (imhtml) || !GTK_WIDGET_REALIZED (imhtml))
1340 return; 1394 return;
1341 1395
1342 if (GTK_LAYOUT (imhtml)->freeze_count) 1396 if (layout->freeze_count)
1343 return; 1397 return;
1344 1398
1345 window = GTK_LAYOUT (imhtml)->bin_window; 1399 if (dx > 0) {
1346 gdk_window_get_size (window, &width, &height); 1400 gdk_window_resize (layout->bin_window,
1347 gdk_window_clear_area (window, 0, 0, width, BORDER_SIZE + 10); 1401 widget->allocation.width + dx,
1348 gdk_window_clear_area (window, 0, MAX (height - BORDER_SIZE - 10, 0), width, BORDER_SIZE + 10); 1402 widget->allocation.height);
1403 gdk_window_move (layout->bin_window, -dx, 0);
1404 gdk_window_move_resize (layout->bin_window,
1405 0, 0,
1406 widget->allocation.width,
1407 widget->allocation.height);
1408 } else if (dx) {
1409 gdk_window_move_resize (layout->bin_window,
1410 dx, 0,
1411 widget->allocation.width - dx,
1412 widget->allocation.height);
1413 gdk_window_move (layout->bin_window, 0, 0);
1414 gdk_window_resize (layout->bin_window,
1415 widget->allocation.width,
1416 widget->allocation.height);
1417 }
1418
1419 if (dy > 0) {
1420 gdk_window_resize (layout->bin_window,
1421 widget->allocation.width,
1422 widget->allocation.height + dy);
1423 gdk_window_move (layout->bin_window, 0, -dy);
1424 gdk_window_move_resize (layout->bin_window,
1425 0, 0,
1426 widget->allocation.width,
1427 widget->allocation.height);
1428 } else if (dy) {
1429 gdk_window_move_resize (layout->bin_window,
1430 0, dy,
1431 widget->allocation.width,
1432 widget->allocation.height - dy);
1433 gdk_window_move (layout->bin_window, 0, 0);
1434 gdk_window_resize (layout->bin_window,
1435 widget->allocation.width,
1436 widget->allocation.height);
1437 }
1349 1438
1350 gtk_imhtml_draw_exposed (imhtml); 1439 gtk_imhtml_draw_exposed (imhtml);
1351 } 1440 }
1352 1441
1353 static void 1442 static void
2062 imhtml->llheight = HR_HEIGHT * 2; 2151 imhtml->llheight = HR_HEIGHT * 2;
2063 new_line (imhtml); 2152 new_line (imhtml);
2064 add_text_renderer (imhtml, bit, NULL); 2153 add_text_renderer (imhtml, bit, NULL);
2065 } 2154 }
2066 2155
2067 gtk_layout_set_size (GTK_LAYOUT (imhtml), imhtml->xsize, imhtml->y + 5); 2156 GTK_LAYOUT (imhtml)->height = imhtml->y + 5;
2157 GTK_LAYOUT (imhtml)->vadjustment->upper = imhtml->y + 5;
2158 gtk_signal_emit_by_name (GTK_OBJECT (GTK_LAYOUT (imhtml)->vadjustment), "changed");
2068 } 2159 }
2069 2160
2070 void 2161 void
2071 gtk_imhtml_show_smileys (GtkIMHtml *imhtml, 2162 gtk_imhtml_show_smileys (GtkIMHtml *imhtml,
2072 gboolean show) 2163 gboolean show)