Commit Graph

303 Commits

Author SHA1 Message Date
Tristan Van Berkom
d26ac6421b Fixed problems with combination of height-for-width apis and
alignment/margin vfuncs adjust_size_request/allocation

Now get_height_for_width() will internally update the for_width
before passing it to the real height_for_width() vfunc, allowing
margins and extra space for alignments to be stripped, thus requesting
sufficient height for greater than natural widths (and also accounting
for margins properly). Test case adjusted in testadjustsize to ensure
proper behavior.
2010-10-23 00:11:37 +09:00
Tadej Borovšak
55196a705f Add GtkScrollable interface
The GtkScrollable interface provides "hadjustment" and "vadjustment"
properties that are used by GtkScrolledWindow. It replaces
the ::set_scroll_adjustment signal. The scrollable interface
also has ::min-display-width/height properties that can be
used to control the minimally visible part inside a scrolled window.
2010-10-22 11:03:45 +02:00
Michael Natterer
c2f29f2cef gtk: clean up GtkWidget signals
- add slots for damage-event, move-focus and keynav-failed
- reorder signals a bit so related stuff is grouped together
- some indentation fixes in the GtkWidgetClass
- remove the move-focus compat hack from GtkTextView
- turn the move-focus compat hack in GtkWindow into properly
  implementing GtkWidget::move-focus()
2010-10-20 17:02:38 +02:00
Matthias Clasen
d1a9d764a8 Remove gtk_widget_hide_all()
it's useless and a trap for programmers

https://bugzilla.gnome.org/show_bug.cgi?id=438318
2010-10-19 19:31:38 +02:00
Benjamin Otte
ff142ac2ef gtk: Add gtk_widget_queue_draw_region()
People were requesting it and it mirrors the behavior of GdkWindow.
2010-10-18 19:22:44 +02:00
Matthias Clasen
3e2a259a78 docs: fix a cross-reference 2010-10-15 16:58:27 -04:00
Havoc Pennington
031856eb33 Add horizontal and vertical expand flags, compute_expand() to GtkWidget
GtkWidget now has flags for horizontal and vertical expand, and
a compute_expand() method. compute_expand() is used by containers
to set a default expand flag. (If a widget has expand set explicitly,
it always overrides the results of compute_expand.)

GtkContainer has a default implementation of compute_expand which
simply walks over all child widgets and sets expand=TRUE
if any child is expanding.

The overall effect is that you only have to set expand on
leaf nodes in the widget tree, while previously you had to
set expand all the way up the tree as you packed every
container. Also, now containers need not have their own child
properties for expand.

For old containers which do have "expand" child properties,
they should override compute_expand and include the child
properties in whether the container is expand=TRUE.
Also, the old container should use
"child_prop_expand || gtk_widget_compute_expand()" everywhere
it previously used simply "child_prop_expand"

https://bugzilla.gnome.org/show_bug.cgi?id=628902
2010-10-13 10:40:07 -04:00
Matthias Clasen
f106d369a7 Don't link to old stuff 2010-10-12 01:10:32 -04:00
Benjamin Otte
60655a36dc docs: Dn't mark all signals in GtkWidgetClass as private
They are meant to be overwritten by subclasses after all.
2010-10-05 23:25:53 +02:00
Benjamin Otte
5ac6234815 API: gtk: Add gtk_widget_set_visual()
It turns out that the previous handling of just providing a way to set
visuals just on toplevels was not sufficient. In particular it
complicated the various implementations of the tray icon specification.
This patch reintroduces gtk_widget_set_visual() which behaves very
similar to GTK2's gtk_widget_set_colormap().

A future commit will remove the gtk_window_set_visual() function.
2010-09-28 19:11:21 +02:00
Matthias Clasen
d869a1e419 Remove GtkWidgetFlags 2010-09-26 22:18:46 -04:00
Matthias Clasen
f53ad33994 Remove GtkObject completely 2010-09-26 22:18:19 -04:00
Javier Jardón
eac1959d2c Move destroy signal to GtkWidget
Also make GtkWidget derive from GInitiallyUnowned
2010-09-26 22:18:18 -04:00
Benjamin Otte
0795f1e0c9 API: Add gtk_cairo_transform_to_window()
The function reverses the transform that GTK does before emitting a draw
event. So we can use it in "old" widgets to revert the coordinate system
properly.
2010-09-26 15:11:45 +02:00
Benjamin Otte
d9c9259861 Move GtkSizeRequest into GtkWidget
It doesn't make sense to keep them separate as GtkSizeRequest requires a
GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have
one without the other.
It also makes the code a lot easier because no casts are required when
calling functions.

Also, the names would translate to gtk_widget_get_width() and people
agreed that this would be a too generic name, so a "preferred" was added
to the names.

So this patch moves the functions:
gtk_size_request_get_request_mode() => gtk_widget_get_request_mode()
gtk_size_request_get_width() => gtk_widget_get_preferred_width()
gtk_size_request_get_height() => gtk_widget_get_preferred_height()
gtk_size_request_get_size() => gtk_widget_get_preferred_size()
gtk_size_request_get_width_for_height() =>
  gtk_widget_get_preferred_width_for_height()
gtk_size_request_get_height_for_width() =>
  gtk_widget_get_preferred_height_for_width()
... and moves the corresponding vfuncs to the GtkWidgetClass.

The patch also renames the implementations of the vfuncs in widgets to
include the word "preferrred".
2010-09-26 15:11:45 +02:00
Benjamin Otte
b89920e203 API: Add gtk_widget_draw()
And here's the final patch that all the previous patches were about.
2010-09-26 15:11:43 +02:00
Benjamin Otte
326f887ae7 API: widget: Remove the expose event
gtk_widget_send_expose() now calls the draw function.
2010-09-26 15:11:42 +02:00
Benjamin Otte
45744d9a5f Change semantics of the draw signal
Previously, we tried to move the context's origin to the widget's top
left location, no matter what window the paint was happening on. Now we
only do that for child windows of the widget's window and leave the
context untouched for windows that the widget has created outside its
own hierarchy. In those casses, we also don't clip the context to
the widget's allocation.

Includes fixes to GtkHandlebox for this effect and fixes all known
issues with it.

These semantics assume that gtk_widget_draw() should only draw the parts
of a widget that are inside child windows and not draw stuff that is
located in completely different GdkWindows. In the handlebox case, it
means that it should only draw the handle when it is attached, but not
when it isn't. We'll likely need a special draw function for the
detached handlebox if we want to draw it.
2010-09-26 15:11:42 +02:00
Benjamin Otte
0acec382c8 widget: Clip drawing to the widget's allocation.
I've seen (and written) quite some widgets (and theme engines) that use
cairo_paint() to draw the background. So avoiding overdraw makes sense.

Also move all that setup into a _gtk_widget_draw_internal() function
that will be used by all functions that can be used by other functions
that draw widgets.
2010-09-26 15:11:42 +02:00
Benjamin Otte
90379ed68a widget: Store the expose event in the cairo_t, not just the window
This way we can grab it for propagating expose events. Not sure if we
need to do this once we're all Cairo, but for now we do.
2010-09-26 15:11:36 +02:00
Benjamin Otte
7108586b16 widget: Add draw signal
For now, the draw signal is emitted by default from the expose event, so
widgets can chose to either implement the expose event or the draw
function.
This is for the transitional period from expose event to draw signal.

Note that for now subclasses can only implement the draw function when
none of their parents implemented the expose event.
2010-09-26 15:11:34 +02:00
Benjamin Otte
9507670db4 API: Add API to query width and height when rendering
The functions are gtk_widget_get_allocated_width() and
gtk_widget_get_allocated_height().

They are currently identical to using width/height of
gtk_widget_get_allocation(), but are introduced for ease of use (no need
to use a custom struct) and to free people from having to think about
allocation.x and allocation.y (which is where the origin of the cairo
context in GtkWidget::draw is located).
2010-09-26 15:11:34 +02:00
Benjamin Otte
3607a4c082 API: Remove setters and getters for default colormaps
This removes:
gtk_widget_set_default_colormap()
gtk_widget_get_default_colormap()
gtk_widget_get_default_visual()

Colormaps are gone, and the default visual is the system visual of the
default screen.
2010-09-26 15:11:32 +02:00
Benjamin Otte
c51e8bd9e5 API: Remove colormap setting and getting from GtkWidget
gtk_widget_get_colormap() and gtk_widget_set_colormap() are gone. They
are replaced by visuals.
2010-09-26 15:11:32 +02:00
Benjamin Otte
b479ff9cb5 API: Remove gtk_widget_push_colormap()
And of course, gtk_widget_pop_colormap() is gone, too.
No replacement is necessary, the function is basically unused.
2010-09-26 15:11:31 +02:00
Benjamin Otte
ca8a835874 API: Remove gtk_widget_get_snapshot()
It will be replaced with gtk_widget_draw().
2010-09-26 15:11:11 +02:00
Benjamin Otte
806a7239ae widget: shape_combine_mask => shape_cobine_region
Replace gtk_widget_shape_combine_region() with
gtk_widget_shape_combine_mask() and
gtk_widget_input_shape_combine_region() with
gtk_widget_input_shape_combine_mask().
As GdkBitmap is going away, and the region equivalents already exist,
this seems like pretty much the default step to take.

Includes code to fix up the users.
2010-09-26 15:02:59 +02:00
Matthias Clasen
2f78aa3024 Rename h/v-align to h/valign
And adjust the getters and setters to match. Also include some
documentation by Havoc Pennington about adjustment of size requests
and allocations.
2010-09-15 20:14:56 -04:00
Matthias Clasen
38e09dcbb1 Use gint instead of in for local consistency 2010-09-15 13:22:51 -04:00
Javier Jardón
e3a8e29a6c Add deprecation guards for gtk_widget_size_request() 2010-09-15 03:14:34 +02:00
Javier Jardón
97ffc36540 Add deprecation guards for gtk_widget_get_child_requisition() 2010-09-13 22:37:11 +02:00
Havoc Pennington
474f80442a Add margin and alignment properties to GtkWidget
h-align = START,END,CENTER,FILL
v-align = START,END,CENTER,FILL
margin-left,right,top,bottom
margin

These should obsolete all such similar properties on
layout containers, GtkMisc, GtkAlignment, GtkContainer::border-width

Margin is outside the size request.
If margin were not outside the set_size_request() it would not work the
same way as container-supplied (child property) padding.

Conceptually set_size_request() forces the value from the subclass
(the original unadjusted request) and then we go on to adjust
the request further by adding the margin.
2010-09-12 21:47:10 -04:00
Havoc Pennington
cd2a19a68d GtkWidget: add adjust_size_request adjust_size_allocation virtual funcs
Use these new methods to handle set_size_request (aka aux_info)
inside gtkwidget.c, instead of having external code mess with it.

The virtual functions can be used for other purposes in the
future. For example, GtkContainer::border_width could be
automatically implemented for all container subclasses.
2010-09-12 21:47:10 -04:00
Tristan Van Berkom
843be48572 Moved GtkSizeRequest cache to GtkWidget->priv
Now that we have a private data installed directly on
the GtkWidget instance it makes no sense to cache the size
requests on widget qdata. This change will generally make
GTK+ memory less fragmented as well as significantly speed
up the size request process.
2010-09-09 17:19:18 +09:00
Javier Jardón
a76d198508 GtkWidget: Move public members to private structure 2010-09-08 21:28:16 +02:00
Tristan Van Berkom
9934007420 Completely removed requisition cache from GtkWidget instance structure.
Since we have a new mechanism for requesting sizes: GtkSizeRequestIface;
it makes no sense to maintain this cache on the GtkWidget structure...
removing the requisition cache however does not break the old "size-request"
signal which is there for backwards compatability reasons.

In any case widget->requisition should not have been accessed,
gtk_widget_get_child_requisition() would have been the correct way
to consult the cache.

This commit also deprecates the newly added gtk_widget_get_requisition()
API and makes it fallback on gtk_size_request_get_size().
2010-09-08 18:50:24 +02:00
Tristan Van Berkom
278957a5a4 Removed x/y/x_set/y_set from GtkWidgetAuxInfo
These members of GtkWidgetAuxData can no longer be set after
the removal of deprecated gtk_widget_set_uposition(), now removed
these members completely and removed the access to them from
gtk_widget_size_allocate().
2010-09-07 16:21:44 +09:00
Havoc Pennington
c50db9c208 Use a bitfield for Widget::private_flags, ::state, ::saved_state
This recovers 10 bits, since state and saved_state as uint8 both
wasted 5 bits. Now we can add 10 more flags.

Also, a possible future patch could just do 1-bit bitfields
for the private flags instead of using manual bit twiddling.

https://bugzilla.gnome.org/show_bug.cgi?id=628884
2010-09-07 00:13:11 -04:00
Havoc Pennington
d7d940c71e Add more "reserved for expansion" fields to GtkWidgetClass
Only 3 were left. 3.x cycle may need more.

https://bugzilla.gnome.org/show_bug.cgi?id=628807
2010-09-05 21:42:35 -04:00
Javier Jardón
eaab96c066 Use GSlice for GtkRequisition
Also add gtk_requisition_new to avoid memory allocator confusions when
using GtkRequisitions.

Based on a Christian Persch patch.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=461618
2010-07-10 06:13:45 +02:00
Benjamin Otte
300e6b84cd s/GdkRegion/cairo_region_t/ in all of gtk
https://bugzilla.gnome.org/show_bug.cgi?id=613284
2010-06-29 16:06:38 +02:00
Matthias Clasen
233388e693 Fix a parameter name mismatch 2010-06-04 16:15:58 -04:00
Javier Jardón
86441c6427 gtkwidget.h: Fix a typo
Fix a type introduced in
commit 818d444e2f

Reported by Garrett Regier.
2010-05-27 22:01:15 +02:00
Javier Jardón
818d444e2f Remove GTK_NO_REPARENT deprecated widget flag 2010-05-27 18:05:02 +02:00
Javier Jardón
45aa82d85f Deprecate GTK_NO_REPARENT 2010-05-27 18:04:05 +02:00
Matthias Clasen
bd4609b140 Merge the xi2-for-master branch 2010-05-25 18:38:44 -04:00
Javier Jardón
9fa9d792a8 Remove GTK_WIDGET_* macros 2010-05-03 01:51:21 +02:00
Michael Natterer
5e29973773 Remove all traces of GDK_PIXBUF/GTK_DISABLE_SINGLE_INCLUDES
...and disallow inclusion of individual files unconditionally.
2010-05-03 01:51:18 +02:00
Javier Jardón
0d322676dc Remove deprecated GtkWidget functions 2010-05-03 01:41:37 +02:00
Christian Dywan
16011da879 Remove some deprecated functions from GtkWidget 2010-05-03 01:40:40 +02:00