mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 17:30:10 +00:00
gtk: add gtk_entry_get_text_area() and gtk_entry_get_icon_area()
as replacement for the removed get_foo_window() functions, so draw() callbacks can figure where to paint.
This commit is contained in:
parent
95610f2a14
commit
ba9efeda4b
@ -1075,6 +1075,7 @@ gtk_entry_get_current_icon_drag_source
|
|||||||
gtk_entry_get_cursor_hadjustment
|
gtk_entry_get_cursor_hadjustment
|
||||||
gtk_entry_get_has_frame
|
gtk_entry_get_has_frame
|
||||||
gtk_entry_get_icon_activatable
|
gtk_entry_get_icon_activatable
|
||||||
|
gtk_entry_get_icon_area
|
||||||
gtk_entry_get_icon_at_pos
|
gtk_entry_get_icon_at_pos
|
||||||
gtk_entry_get_icon_gicon
|
gtk_entry_get_icon_gicon
|
||||||
gtk_entry_get_icon_name
|
gtk_entry_get_icon_name
|
||||||
@ -1093,6 +1094,7 @@ gtk_entry_get_overwrite_mode
|
|||||||
gtk_entry_get_progress_fraction
|
gtk_entry_get_progress_fraction
|
||||||
gtk_entry_get_progress_pulse_step
|
gtk_entry_get_progress_pulse_step
|
||||||
gtk_entry_get_text
|
gtk_entry_get_text
|
||||||
|
gtk_entry_get_text_area
|
||||||
gtk_entry_get_text_length
|
gtk_entry_get_text_length
|
||||||
gtk_entry_get_type G_GNUC_CONST
|
gtk_entry_get_type G_GNUC_CONST
|
||||||
gtk_entry_get_visibility
|
gtk_entry_get_visibility
|
||||||
|
@ -6655,6 +6655,47 @@ gtk_entry_set_buffer (GtkEntry *entry,
|
|||||||
gtk_entry_recompute (entry);
|
gtk_entry_recompute (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_entry_get_text_area:
|
||||||
|
* @entry: a #GtkEntry
|
||||||
|
* @text_area: Return location for the text area.
|
||||||
|
*
|
||||||
|
* Returns the area where the entry's text is drawn. This function is
|
||||||
|
* useful when drawing something to the entry in a draw callback.
|
||||||
|
*
|
||||||
|
* See also gtk_entry_get_icon_area().
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gtk_entry_get_text_area (GtkEntry *entry,
|
||||||
|
GdkRectangle *text_area)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||||
|
g_return_if_fail (text_area != NULL);
|
||||||
|
|
||||||
|
if (entry->text_area)
|
||||||
|
{
|
||||||
|
GtkAllocation allocation;
|
||||||
|
gint x, y;
|
||||||
|
|
||||||
|
gtk_widget_get_allocation (GTK_WIDGET (entry), &allocation);
|
||||||
|
gdk_window_get_position (entry->text_area, &x, &y);
|
||||||
|
|
||||||
|
text_area->x = x - allocation.x;
|
||||||
|
text_area->y = y - allocation.y;
|
||||||
|
text_area->width = gdk_window_get_width (entry->text_area);
|
||||||
|
text_area->height = gdk_window_get_height (entry->text_area);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text_area->x = 0;
|
||||||
|
text_area->y = 0;
|
||||||
|
text_area->width = 0;
|
||||||
|
text_area->height = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_entry_set_text:
|
* gtk_entry_set_text:
|
||||||
* @entry: a #GtkEntry
|
* @entry: a #GtkEntry
|
||||||
@ -8064,6 +8105,56 @@ gtk_entry_get_current_icon_drag_source (GtkEntry *entry)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_entry_get_icon_area:
|
||||||
|
* @entry: A #GtkEntry
|
||||||
|
* @icon_pos: Icon position
|
||||||
|
* @icon_area: Return location for the icon's area
|
||||||
|
*
|
||||||
|
* Returns the area where entry's icon at @icon_pos is drawn.
|
||||||
|
* This function is useful when drawing something to the
|
||||||
|
* entry in a draw callback.
|
||||||
|
*
|
||||||
|
* See also gtk_entry_get_text_area()
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_entry_get_icon_area (GtkEntry *entry,
|
||||||
|
GtkEntryIconPosition icon_pos,
|
||||||
|
GdkRectangle *icon_area)
|
||||||
|
{
|
||||||
|
GtkEntryPrivate *priv;
|
||||||
|
EntryIconInfo *icon_info;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||||
|
g_return_if_fail (icon_area != NULL);
|
||||||
|
|
||||||
|
priv = GTK_ENTRY_GET_PRIVATE (entry);
|
||||||
|
|
||||||
|
icon_info = priv->icons[icon_pos];
|
||||||
|
|
||||||
|
if (icon_info)
|
||||||
|
{
|
||||||
|
GtkAllocation primary;
|
||||||
|
GtkAllocation secondary;
|
||||||
|
|
||||||
|
get_icon_allocations (entry, &primary, &secondary);
|
||||||
|
|
||||||
|
if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
|
||||||
|
*icon_area = primary;
|
||||||
|
else
|
||||||
|
*icon_area = secondary;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
icon_area->x = 0;
|
||||||
|
icon_area->y = 0;
|
||||||
|
icon_area->width = 0;
|
||||||
|
icon_area->height = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_has_tooltip (GtkEntry *entry)
|
ensure_has_tooltip (GtkEntry *entry)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +172,9 @@ GtkEntryBuffer* gtk_entry_get_buffer (GtkEntry *entry);
|
|||||||
void gtk_entry_set_buffer (GtkEntry *entry,
|
void gtk_entry_set_buffer (GtkEntry *entry,
|
||||||
GtkEntryBuffer *buffer);
|
GtkEntryBuffer *buffer);
|
||||||
|
|
||||||
|
void gtk_entry_get_text_area (GtkEntry *entry,
|
||||||
|
GdkRectangle *text_area);
|
||||||
|
|
||||||
void gtk_entry_set_visibility (GtkEntry *entry,
|
void gtk_entry_set_visibility (GtkEntry *entry,
|
||||||
gboolean visible);
|
gboolean visible);
|
||||||
gboolean gtk_entry_get_visibility (GtkEntry *entry);
|
gboolean gtk_entry_get_visibility (GtkEntry *entry);
|
||||||
@ -301,6 +304,9 @@ void gtk_entry_set_icon_drag_source (GtkEntry *
|
|||||||
GtkTargetList *target_list,
|
GtkTargetList *target_list,
|
||||||
GdkDragAction actions);
|
GdkDragAction actions);
|
||||||
gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
|
gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
|
||||||
|
void gtk_entry_get_icon_area (GtkEntry *entry,
|
||||||
|
GtkEntryIconPosition icon_pos,
|
||||||
|
GdkRectangle *icon_area);
|
||||||
|
|
||||||
gboolean gtk_entry_im_context_filter_keypress (GtkEntry *entry,
|
gboolean gtk_entry_im_context_filter_keypress (GtkEntry *entry,
|
||||||
GdkEventKey *event);
|
GdkEventKey *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user