* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkorientable.h"
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
+#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "a11y/gtkpanedaccessible.h"
priv->child1 = NULL;
priv->child2 = NULL;
priv->handle = NULL;
- priv->cursor_type = GDK_CROSS;
priv->handle_pos.width = 5;
priv->handle_pos.height = 5;
{
case PROP_ORIENTATION:
priv->orientation = g_value_get_enum (value);
+ _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
priv->cursor_type = GDK_SB_H_DOUBLE_ARROW;
if (priv->child1 && gtk_widget_get_visible (priv->child1))
{
get_preferred_size_for_size (priv->child1, orientation, size, &child_min, &child_nat);
- *minimum = child_min;
+ if (priv->child1_shrink && priv->orientation == orientation)
+ *minimum = 0;
+ else
+ *minimum = child_min;
*natural = child_nat;
}
if (priv->orientation == orientation)
{
- *minimum += child_min;
+ if (!priv->child2_shrink)
+ *minimum += child_min;
*natural += child_nat;
}
else
window = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
- gdk_window_set_user_data (window, paned);
+ gtk_widget_register_window (widget, window);
gtk_style_context_set_background (gtk_widget_get_style_context (widget), window);
if (child)
priv->handle = gdk_window_new (window,
&attributes, attributes_mask);
- gdk_window_set_user_data (priv->handle, paned);
+ gtk_widget_register_window (widget, priv->handle);
if (attributes_mask & GDK_WA_CURSOR)
g_object_unref (attributes.cursor);
if (priv->child2)
gtk_widget_set_parent_window (priv->child2, NULL);
- gdk_window_set_user_data (priv->child2_window, NULL);
+ gtk_widget_unregister_window (widget, priv->child2_window);
gdk_window_destroy (priv->child2_window);
priv->child2_window = NULL;
if (priv->child1)
gtk_widget_set_parent_window (priv->child1, NULL);
- gdk_window_set_user_data (priv->child1_window, NULL);
+ gtk_widget_unregister_window (widget, priv->child1_window);
gdk_window_destroy (priv->child1_window);
priv->child1_window = NULL;
if (priv->handle)
{
- gdk_window_set_user_data (priv->handle, NULL);
+ gtk_widget_unregister_window (widget, priv->handle);
gdk_window_destroy (priv->handle);
priv->handle = NULL;
}
static void
update_drag (GtkPaned *paned,
- GdkEventCrossing *crossing)
+ /* relative to priv->handle */
+ int xpos,
+ int ypos)
{
GtkPanedPrivate *priv = paned->priv;
GtkAllocation allocation;
gint pos;
gint handle_size;
gint size;
+ gint x, y;
+ gdk_window_get_position (priv->handle, &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_pointer (widget, &pos, NULL);
+ {
+ pos = xpos + x - allocation.x;
+ }
else
- gtk_widget_get_pointer (widget, NULL, &pos);
+ {
+ pos = ypos + y - allocation.y;
+ }
pos -= priv->drag_pos;
"handle-size", &handle_size,
NULL);
- gtk_widget_get_allocation (widget, &allocation);
size = allocation.width - pos - handle_size;
}
else
GtkPanedPrivate *priv = paned->priv;
if (priv->in_drag)
- update_drag (paned, event);
+ update_drag (paned, event->x, event->y);
else
{
priv->handle_prelit = TRUE;
GtkPanedPrivate *priv = paned->priv;
if (priv->in_drag)
- update_drag (paned);
+ update_drag (paned, event->x, event->y);
else
{
priv->handle_prelit = FALSE;
GtkPanedPrivate *priv = paned->priv;
if (!priv->in_drag &&
- (event->window == priv->handle) && (event->button == 1))
+ (event->window == priv->handle) && (event->button == GDK_BUTTON_PRIMARY))
{
/* We need a server grab here, not gtk_grab_add(), since
* we don't want to pass events on to the widget's children */
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
- if (priv->in_drag && (event->button == 1))
+ if (priv->in_drag && (event->button == GDK_BUTTON_PRIMARY))
{
stop_drag (paned);
if (priv->in_drag)
{
- update_drag (paned);
+ update_drag (paned, event->x, event->y);
return TRUE;
}