#include "gtkseparatormenuitem.h"
#include "gtkselection.h"
#include "gtksettings.h"
-#include "gtksizerequest.h"
#include "gtkspinbutton.h"
#include "gtkstock.h"
#include "gtktextutil.h"
DISPLAY_BLANK /* In invisible mode, nothing shown at all */
} DisplayMode;
-/* GObject, GtkObject methods
+/* GObject methods
*/
static void gtk_entry_editable_init (GtkEditableInterface *iface);
static void gtk_entry_cell_editable_init (GtkCellEditableIface *iface);
GValue *value,
GParamSpec *pspec);
static void gtk_entry_finalize (GObject *object);
-static void gtk_entry_destroy (GtkObject *object);
static void gtk_entry_dispose (GObject *object);
/* GtkWidget methods
*/
+static void gtk_entry_destroy (GtkWidget *widget);
static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget);
static void gtk_entry_map (GtkWidget *widget);
static void gtk_entry_draw_progress (GtkWidget *widget,
cairo_t *cr,
GdkWindow *window);
-static gint gtk_entry_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gtk_entry_draw (GtkWidget *widget,
+ cairo_t *cr);
static gint gtk_entry_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_entry_button_release (GtkWidget *widget,
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class;
- GtkObjectClass *gtk_object_class;
GtkBindingSet *binding_set;
widget_class = (GtkWidgetClass*) class;
- gtk_object_class = (GtkObjectClass *)class;
gobject_class->dispose = gtk_entry_dispose;
gobject_class->finalize = gtk_entry_finalize;
gobject_class->set_property = gtk_entry_set_property;
gobject_class->get_property = gtk_entry_get_property;
+ widget_class->destroy = gtk_entry_destroy;
widget_class->map = gtk_entry_map;
widget_class->unmap = gtk_entry_unmap;
widget_class->realize = gtk_entry_realize;
widget_class->unrealize = gtk_entry_unrealize;
widget_class->size_request = gtk_entry_size_request;
widget_class->size_allocate = gtk_entry_size_allocate;
- widget_class->expose_event = gtk_entry_expose;
+ widget_class->draw = gtk_entry_draw;
widget_class->enter_notify_event = gtk_entry_enter_notify;
widget_class->leave_notify_event = gtk_entry_leave_notify;
widget_class->button_press_event = gtk_entry_button_press;
widget_class->popup_menu = gtk_entry_popup_menu;
- gtk_object_class->destroy = gtk_entry_destroy;
-
class->move_cursor = gtk_entry_move_cursor;
class->insert_at_cursor = gtk_entry_insert_at_cursor;
class->delete_from_cursor = gtk_entry_delete_from_cursor;
}
static void
-gtk_entry_destroy (GtkObject *object)
+gtk_entry_destroy (GtkWidget *widget)
{
- GtkEntry *entry = GTK_ENTRY (object);
+ GtkEntry *entry = GTK_ENTRY (widget);
entry->current_pos = entry->selection_bound = 0;
_gtk_entry_reset_im_context (entry);
entry->recompute_idle = 0;
}
- GTK_OBJECT_CLASS (gtk_entry_parent_class)->destroy (object);
+ GTK_WIDGET_CLASS (gtk_entry_parent_class)->destroy (widget);
}
static void
gint frame_height;
gint xborder, yborder;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
_gtk_entry_get_borders (entry, &xborder, &yborder);
if (gtk_widget_get_realized (widget))
- gdk_drawable_get_size (gtk_widget_get_window (widget), NULL, &frame_height);
+ frame_height = gdk_window_get_height (gtk_widget_get_window (widget));
else
frame_height = requisition.height;
GtkRequisition requisition;
GtkWidget *widget = GTK_WIDGET (entry);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
if (x)
if (icon_info->pixbuf == NULL)
return;
- gdk_drawable_get_size (icon_info->window, &width, &height);
+ width = gdk_window_get_width (icon_info->window);
+ height = gdk_window_get_height (icon_info->window);
/* size_allocate hasn't been called yet. These are the default values.
*/
window = gtk_widget_get_window (widget);
- gdk_drawable_get_size (window, &width, &height);
+ width = gdk_window_get_width (window);
+ height = gdk_window_get_height (window);
/* Fix a problem with some themes which assume that entry->text_area's
* width equals widget->window's width
state = gtk_widget_has_focus (widget) ?
GTK_STATE_ACTIVE : gtk_widget_get_state (widget);
- gtk_cairo_paint_shadow (style, cr,
+ gtk_paint_shadow (style, cr,
state, priv->shadow_type,
widget, "entry", x, y, width, height);
width += 2 * priv->focus_width;
height += 2 * priv->focus_width;
- gtk_cairo_paint_focus (style, cr,
+ gtk_paint_focus (style, cr,
gtk_widget_get_state (widget),
widget, "entry",
0, 0, width, height);
*x = progress_border.left;
*y = progress_border.top;
- gdk_drawable_get_size (gtk_widget_get_window (widget), width, height);
-
- *width -= progress_border.left + progress_border.right;
- *height -= progress_border.top + progress_border.bottom;
+ *width = gdk_window_get_width (gtk_widget_get_window (widget))
+ - progress_border.left - progress_border.right;
+ *height = gdk_window_get_height (gtk_widget_get_window (widget))
+ - progress_border.top - progress_border.bottom;
if (gtk_widget_has_focus (widget) && !private->interior_focus)
{
if (!gtk_widget_get_sensitive (widget))
state = GTK_STATE_INSENSITIVE;
- gtk_cairo_paint_box (gtk_widget_get_style (widget), cr,
+ gtk_paint_box (gtk_widget_get_style (widget), cr,
state, GTK_SHADOW_OUT,
widget, "entry-progress",
x, y,
}
static gint
-gtk_entry_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_entry_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkStyle *style;
GtkStateType state;
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
- cairo_t *cr;
int i;
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
style = gtk_widget_get_style (widget);
state = gtk_widget_has_focus (widget) ?
GTK_STATE_ACTIVE : gtk_widget_get_state (widget);
- if (gtk_widget_get_window (widget) == event->window)
+ if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
gtk_entry_draw_frame (widget, cr);
- if (entry->text_area == event->window)
+ if (gtk_cairo_should_draw_window (cr, entry->text_area))
{
- gint width, height;
+ cairo_save (cr);
- gdk_drawable_get_size (entry->text_area, &width, &height);
+ gtk_cairo_transform_to_window (cr, widget, entry->text_area);
- gtk_cairo_paint_flat_box (style, cr,
+ gtk_paint_flat_box (style, cr,
state, GTK_SHADOW_NONE,
widget, "entry_bg",
- 0, 0, width, height);
+ 0, 0,
+ gdk_window_get_width (entry->text_area),
+ gdk_window_get_height (entry->text_area));
gtk_entry_draw_progress (widget, cr, entry->text_area);
gtk_widget_has_focus (widget) &&
entry->selection_bound == entry->current_pos && entry->cursor_visible)
gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
+
+ cairo_restore (cr);
}
for (i = 0; i < MAX_ICONS; i++)
{
EntryIconInfo *icon_info = priv->icons[i];
- if (icon_info != NULL && event->window == icon_info->window)
+ if (icon_info != NULL && gtk_cairo_should_draw_window (cr, icon_info->window))
{
- gint width, height;
+ cairo_save (cr);
- gdk_drawable_get_size (icon_info->window, &width, &height);
+ gtk_cairo_transform_to_window (cr, widget, icon_info->window);
- gtk_cairo_paint_flat_box (style, cr,
+ gtk_paint_flat_box (style, cr,
state, GTK_SHADOW_NONE,
widget, "entry_bg",
- 0, 0, width, height);
+ 0, 0,
+ gdk_window_get_width (icon_info->window),
+ gdk_window_get_height (icon_info->window));
gtk_entry_draw_progress (widget, cr, icon_info->window);
draw_icon (widget, cr, i);
+ cairo_restore (cr);
+
break;
}
}
- cairo_destroy (cr);
-
return FALSE;
}
if (event->window == icon_info->window)
{
- gint width, height;
-
- gdk_drawable_get_size (icon_info->window, &width, &height);
-
icon_info->pressed = FALSE;
if (should_prelight (entry, i) &&
event->x >= 0 && event->y >= 0 &&
- event->x < width && event->y < height)
+ event->x < gdk_window_get_width (icon_info->window) &&
+ event->y < gdk_window_get_height (icon_info->window))
{
icon_info->prelight = TRUE;
gtk_widget_queue_draw (widget);
}
else
{
- gint height;
- gdk_drawable_get_size (entry->text_area, NULL, &height);
-
if (event->y < 0)
tmp_pos = 0;
- else if (event->y >= height)
+ else if (event->y >= gdk_window_get_height (entry->text_area))
tmp_pos = gtk_entry_buffer_get_length (get_buffer (entry));
else
tmp_pos = gtk_entry_find_position (entry, event->x + entry->scroll_offset);
cairo_t *cr)
{
GtkWidget *widget = GTK_WIDGET (entry);
+ GtkStateType state;
+ GtkStyle *style;
+ GdkColor text_color, bar_text_color;
+ gint pos_x, pos_y;
+ gint width, height;
+ gint progress_x, progress_y, progress_width, progress_height;
+
/* Nothing to display at all */
if (gtk_entry_get_display_mode (entry) == DISPLAY_BLANK)
return;
- if (gtk_widget_is_drawable (widget))
- {
- GtkStateType state;
- GtkStyle *style;
- GdkColor text_color, bar_text_color;
- gint pos_x, pos_y;
- gint width, height;
- gint progress_x, progress_y, progress_width, progress_height;
-
- state = GTK_STATE_SELECTED;
- if (!gtk_widget_get_sensitive (widget))
- state = GTK_STATE_INSENSITIVE;
- style = gtk_widget_get_style (widget);
- text_color = style->text[gtk_widget_get_state (widget)];
- bar_text_color = style->fg[state];
+ state = GTK_STATE_SELECTED;
+ if (!gtk_widget_get_sensitive (widget))
+ state = GTK_STATE_INSENSITIVE;
+ style = gtk_widget_get_style (widget);
+ text_color = style->text[gtk_widget_get_state (widget)];
+ bar_text_color = style->fg[state];
- get_progress_area (widget,
- &progress_x, &progress_y,
- &progress_width, &progress_height);
+ get_progress_area (widget,
+ &progress_x, &progress_y,
+ &progress_width, &progress_height);
- /* If the color is the same, or the progress area has a zero
- * size, then we only need to draw once. */
- if ((text_color.pixel == bar_text_color.pixel) ||
- ((progress_width == 0) || (progress_height == 0)))
- {
- draw_text_with_color (entry, cr, &text_color);
- }
- else
- {
- gdk_drawable_get_size (entry->text_area, &width, &height);
+ /* If the color is the same, or the progress area has a zero
+ * size, then we only need to draw once. */
+ if ((text_color.pixel == bar_text_color.pixel) ||
+ ((progress_width == 0) || (progress_height == 0)))
+ {
+ draw_text_with_color (entry, cr, &text_color);
+ }
+ else
+ {
+ width = gdk_window_get_width (entry->text_area);
+ height = gdk_window_get_height (entry->text_area);
- cairo_save (cr);
+ cairo_save (cr);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_clip (cr);
- cairo_save (cr);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_clip (cr);
+ cairo_save (cr);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_rectangle (cr, 0, 0, width, height);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_rectangle (cr, 0, 0, width, height);
- gdk_window_get_position (entry->text_area, &pos_x, &pos_y);
- progress_x -= pos_x;
- progress_y -= pos_y;
+ gdk_window_get_position (entry->text_area, &pos_x, &pos_y);
+ progress_x -= pos_x;
+ progress_y -= pos_y;
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
-
- draw_text_with_color (entry, cr, &text_color);
- cairo_restore (cr);
+ cairo_rectangle (cr, progress_x, progress_y,
+ progress_width, progress_height);
+ cairo_clip (cr);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
+
+ draw_text_with_color (entry, cr, &text_color);
+ cairo_restore (cr);
- cairo_rectangle (cr, progress_x, progress_y,
- progress_width, progress_height);
- cairo_clip (cr);
+ cairo_rectangle (cr, progress_x, progress_y,
+ progress_width, progress_height);
+ cairo_clip (cr);
- draw_text_with_color (entry, cr, &bar_text_color);
+ draw_text_with_color (entry, cr, &bar_text_color);
- cairo_restore (cr);
- }
+ cairo_restore (cr);
}
}
else
text_dir = GTK_TEXT_DIR_RTL;
- gtk_cairo_draw_insertion_cursor (widget, cr,
+ gtk_draw_insertion_cursor (widget, cr,
cursor_location,
is_primary, text_dir, draw_arrow);
}
GtkWidget *widget = GTK_WIDGET (entry);
GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
-
- if (gtk_widget_is_drawable (widget))
- {
- GdkRectangle cursor_location;
- gboolean split_cursor;
- PangoRectangle cursor_rect;
- GtkBorder inner_border;
- gint xoffset;
- gint text_area_height;
- gint cursor_index;
- gboolean block;
- gboolean block_at_line_end;
- PangoLayout *layout;
- const char *text;
+ GdkRectangle cursor_location;
+ gboolean split_cursor;
+ PangoRectangle cursor_rect;
+ GtkBorder inner_border;
+ gint xoffset;
+ gint text_area_height;
+ gint cursor_index;
+ gboolean block;
+ gboolean block_at_line_end;
+ PangoLayout *layout;
+ const char *text;
- _gtk_entry_effective_inner_border (entry, &inner_border);
+ _gtk_entry_effective_inner_border (entry, &inner_border);
- xoffset = inner_border.left - entry->scroll_offset;
+ xoffset = inner_border.left - entry->scroll_offset;
- gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
+ text_area_height = gdk_window_get_height (entry->text_area);
- layout = gtk_entry_ensure_layout (entry, TRUE);
- text = pango_layout_get_text (layout);
- cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
- if (!entry->overwrite_mode)
- block = FALSE;
- else
- block = _gtk_text_util_get_block_cursor_location (layout,
- cursor_index, &cursor_rect, &block_at_line_end);
+ layout = gtk_entry_ensure_layout (entry, TRUE);
+ text = pango_layout_get_text (layout);
+ cursor_index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text;
+ if (!entry->overwrite_mode)
+ block = FALSE;
+ else
+ block = _gtk_text_util_get_block_cursor_location (layout,
+ cursor_index, &cursor_rect, &block_at_line_end);
- if (!block)
- {
- gint strong_x, weak_x;
- PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
- PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
- gint x1 = 0;
- gint x2 = 0;
+ if (!block)
+ {
+ gint strong_x, weak_x;
+ PangoDirection dir1 = PANGO_DIRECTION_NEUTRAL;
+ PangoDirection dir2 = PANGO_DIRECTION_NEUTRAL;
+ gint x1 = 0;
+ gint x2 = 0;
- gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
+ gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
- g_object_get (gtk_widget_get_settings (widget),
- "gtk-split-cursor", &split_cursor,
- NULL);
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-split-cursor", &split_cursor,
+ NULL);
- dir1 = entry->resolved_dir;
-
- if (split_cursor)
- {
- x1 = strong_x;
+ dir1 = entry->resolved_dir;
+
+ if (split_cursor)
+ {
+ x1 = strong_x;
- if (weak_x != strong_x)
- {
- dir2 = (entry->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
- x2 = weak_x;
- }
- }
- else
+ if (weak_x != strong_x)
{
- if (keymap_direction == entry->resolved_dir)
- x1 = strong_x;
- else
- x1 = weak_x;
+ dir2 = (entry->resolved_dir == PANGO_DIRECTION_LTR) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+ x2 = weak_x;
}
+ }
+ else
+ {
+ if (keymap_direction == entry->resolved_dir)
+ x1 = strong_x;
+ else
+ x1 = weak_x;
+ }
- cursor_location.x = xoffset + x1;
- cursor_location.y = inner_border.top;
- cursor_location.width = 0;
- cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
+ cursor_location.x = xoffset + x1;
+ cursor_location.y = inner_border.top;
+ cursor_location.width = 0;
+ cursor_location.height = text_area_height - inner_border.top - inner_border.bottom;
+ draw_insertion_cursor (entry, cr,
+ &cursor_location, TRUE, dir1,
+ dir2 != PANGO_DIRECTION_NEUTRAL);
+
+ if (dir2 != PANGO_DIRECTION_NEUTRAL)
+ {
+ cursor_location.x = xoffset + x2;
draw_insertion_cursor (entry, cr,
- &cursor_location, TRUE, dir1,
- dir2 != PANGO_DIRECTION_NEUTRAL);
-
- if (dir2 != PANGO_DIRECTION_NEUTRAL)
- {
- cursor_location.x = xoffset + x2;
- draw_insertion_cursor (entry, cr,
- &cursor_location, FALSE, dir2,
- TRUE);
- }
+ &cursor_location, FALSE, dir2,
+ TRUE);
}
- else /* overwrite_mode */
- {
- GdkColor cursor_color;
- GdkRectangle rect;
- gint x, y;
+ }
+ else /* overwrite_mode */
+ {
+ GdkColor cursor_color;
+ GdkRectangle rect;
+ gint x, y;
- cairo_save (cr);
+ cairo_save (cr);
- get_layout_position (entry, &x, &y);
+ get_layout_position (entry, &x, &y);
- rect.x = PANGO_PIXELS (cursor_rect.x) + x;
- rect.y = PANGO_PIXELS (cursor_rect.y) + y;
- rect.width = PANGO_PIXELS (cursor_rect.width);
- rect.height = PANGO_PIXELS (cursor_rect.height);
+ rect.x = PANGO_PIXELS (cursor_rect.x) + x;
+ rect.y = PANGO_PIXELS (cursor_rect.y) + y;
+ rect.width = PANGO_PIXELS (cursor_rect.width);
+ rect.height = PANGO_PIXELS (cursor_rect.height);
- _gtk_widget_get_cursor_color (widget, &cursor_color);
- gdk_cairo_set_source_color (cr, &cursor_color);
- gdk_cairo_rectangle (cr, &rect);
- cairo_fill (cr);
+ _gtk_widget_get_cursor_color (widget, &cursor_color);
+ gdk_cairo_set_source_color (cr, &cursor_color);
+ gdk_cairo_rectangle (cr, &rect);
+ cairo_fill (cr);
- if (!block_at_line_end)
- {
- gdk_cairo_rectangle (cr, &rect);
- cairo_clip (cr);
- cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
- pango_cairo_show_layout (cr, layout);
- }
-
- cairo_restore (cr);
+ if (!block_at_line_end)
+ {
+ gdk_cairo_rectangle (cr, &rect);
+ cairo_clip (cr);
+ cairo_move_to (cr, x, y);
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
+ pango_cairo_show_layout (cr, layout);
}
+
+ cairo_restore (cr);
}
}
_gtk_entry_effective_inner_border (entry, &inner_border);
- gdk_drawable_get_size (entry->text_area, &text_area_width, NULL);
+ text_area_width = gdk_window_get_width (entry->text_area);
text_area_width -= inner_border.left + inner_border.right;
if (text_area_width < 0)
text_area_width = 0;
* @entry: a #GtkEntry
*
* Returns the #GdkWindow which contains the text. This function is
- * useful when drawing something to the entry in an expose-event
+ * useful when drawing something to the entry in a draw
* callback because it enables the callback to distinguish between
* the text window and entry's icon windows.
*
*
* Returns the #GdkWindow which contains the entry's icon at
* @icon_pos. This function is useful when drawing something to the
- * entry in an expose-event callback because it enables the callback
+ * entry in a draw callback because it enables the callback
* to distinguish between the text window and entry's icon windows.
*
* See also gtk_entry_get_text_window().
gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (entry->popup_menu),
- &menu_req, NULL);
- gdk_drawable_get_size (entry->text_area, NULL, &height);
+ gtk_widget_get_preferred_size (entry->popup_menu,
+ &menu_req, NULL);
+ height = gdk_window_get_height (entry->text_area);
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL);
_gtk_entry_effective_inner_border (entry, &inner_border);