forked from AuroraMiddleware/gtk
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com> * gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case hscale/vscale details, so we can use it for scrollbar as well. * tests/testgtk.c (reformat_value): honor digits from GtkScale * gtk/gtkenums.h (GtkTroughType): Remove this enum (GtkScrollType): add START and END from GtkTroughType * gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using its x/y arguments * gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h, gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c, gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h, gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c, gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses. Notable changes in the process: - stepper_size style property is the height for vertical ranges, width for horizontal; the other dimension matches the trough size - add ability to do NeXT-style steppers (and several other styles that don't make any sense) - added min_slider_length, fixed_slider_length properties to GtkScrollbar - cleaned some private (or at least useless) functions out of gtkscale.h - moved bindings to GtkScale from subclasses, even arrow keys, since blind users don't know scale orientation. - change move_slider action signal to use new GtkScrollType, remove GtkTroughType argument - digits rounds the values a range will input to the given number of decimals, but will not try to force adjustment values set by other controllers. That is, we no longer modify adjustment->value inside a value_changed handler. - added getters for GtkScale setters - middle-click begins a slider drag
This commit is contained in:
parent
741c71eb93
commit
42f429be76
41
ChangeLog
41
ChangeLog
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -1,3 +1,44 @@
|
||||
2001-06-03 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
|
||||
hscale/vscale details, so we can use it for scrollbar as well.
|
||||
|
||||
* tests/testgtk.c (reformat_value): honor digits from GtkScale
|
||||
|
||||
* gtk/gtkenums.h (GtkTroughType): Remove this enum
|
||||
(GtkScrollType): add START and END from GtkTroughType
|
||||
|
||||
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
|
||||
its x/y arguments
|
||||
|
||||
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
|
||||
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
|
||||
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
|
||||
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
|
||||
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
|
||||
|
||||
Notable changes in the process:
|
||||
|
||||
- stepper_size style property is the height for vertical
|
||||
ranges, width for horizontal; the other dimension matches
|
||||
the trough size
|
||||
- add ability to do NeXT-style steppers (and several other styles
|
||||
that don't make any sense)
|
||||
- added min_slider_length, fixed_slider_length properties to
|
||||
GtkScrollbar
|
||||
- cleaned some private (or at least useless) functions out of
|
||||
gtkscale.h
|
||||
- moved bindings to GtkScale from subclasses, even arrow keys,
|
||||
since blind users don't know scale orientation.
|
||||
- change move_slider action signal to use new GtkScrollType,
|
||||
remove GtkTroughType argument
|
||||
- digits rounds the values a range will input to the given
|
||||
number of decimals, but will not try to force adjustment
|
||||
values set by other controllers. That is, we no longer
|
||||
modify adjustment->value inside a value_changed handler.
|
||||
- added getters for GtkScale setters
|
||||
- middle-click begins a slider drag
|
||||
|
||||
Fri Jun 1 18:54:47 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_focus): Initial stab at
|
||||
|
@ -322,3 +322,10 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
|
||||
|
||||
* GdkColorContext is gone; you probably weren't using it anyway.
|
||||
Use GdkColormap and the gdk_rgb_* functions instead.
|
||||
|
||||
* GtkRange/GtkScrollbar/GtkScale were rewritten; this means that most
|
||||
theme engines won't draw them properly, and any custom subclasses of
|
||||
these widgets will need a rewrite (though if you could figure out
|
||||
how to subclass the old version of GtkRange, you have our
|
||||
respect). Also, GtkTroughType is gone.
|
||||
|
||||
|
@ -248,11 +248,11 @@ contains grayscale or red-green-blue data.
|
||||
</para>
|
||||
|
||||
@GTK_SCROLL_NONE:
|
||||
@GTK_SCROLL_JUMP:
|
||||
@GTK_SCROLL_STEP_BACKWARD:
|
||||
@GTK_SCROLL_STEP_FORWARD:
|
||||
@GTK_SCROLL_PAGE_BACKWARD:
|
||||
@GTK_SCROLL_PAGE_FORWARD:
|
||||
@GTK_SCROLL_JUMP:
|
||||
@GTK_SCROLL_STEP_UP:
|
||||
@GTK_SCROLL_STEP_DOWN:
|
||||
@GTK_SCROLL_PAGE_UP:
|
||||
@ -261,6 +261,8 @@ contains grayscale or red-green-blue data.
|
||||
@GTK_SCROLL_STEP_RIGHT:
|
||||
@GTK_SCROLL_PAGE_LEFT:
|
||||
@GTK_SCROLL_PAGE_RIGHT:
|
||||
@GTK_SCROLL_START:
|
||||
@GTK_SCROLL_END:
|
||||
|
||||
<!-- ##### ENUM GtkSelectionMode ##### -->
|
||||
<para>
|
||||
@ -325,16 +327,6 @@ for the default toolbar style.
|
||||
@GTK_TOOLBAR_BOTH_HORIZ: Buttons display icons and text alongside each
|
||||
other, rather than vertically stacked
|
||||
|
||||
<!-- ##### ENUM GtkTroughType ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_TROUGH_NONE:
|
||||
@GTK_TROUGH_START:
|
||||
@GTK_TROUGH_END:
|
||||
@GTK_TROUGH_JUMP:
|
||||
|
||||
<!-- ##### ENUM GtkUpdateType ##### -->
|
||||
<para>
|
||||
|
||||
|
@ -72,6 +72,7 @@ GtkRange
|
||||
|
||||
@range: the object which received the signal.
|
||||
@arg1:
|
||||
<!-- # Unused Parameters # -->
|
||||
@arg2:
|
||||
|
||||
<!-- ##### ARG GtkRange:update-policy ##### -->
|
||||
|
@ -72,16 +72,6 @@ Sets the position in which the current value is displayed.
|
||||
@pos: the position in which the current value is displayed.
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_scale_get_value_width ##### -->
|
||||
<para>
|
||||
An internal function used to get the maximum width needed to display the value
|
||||
string.
|
||||
</para>
|
||||
|
||||
@scale: a #GtkScale.
|
||||
@Returns: the maximum width needed to display the value string.
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GtkScale::format-value ##### -->
|
||||
<para>
|
||||
|
||||
|
@ -286,11 +286,11 @@ typedef enum /*< flags >*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_SCROLL_NONE,
|
||||
GTK_SCROLL_JUMP,
|
||||
GTK_SCROLL_STEP_BACKWARD,
|
||||
GTK_SCROLL_STEP_FORWARD,
|
||||
GTK_SCROLL_PAGE_BACKWARD,
|
||||
GTK_SCROLL_PAGE_FORWARD,
|
||||
GTK_SCROLL_JUMP,
|
||||
GTK_SCROLL_STEP_UP,
|
||||
GTK_SCROLL_STEP_DOWN,
|
||||
GTK_SCROLL_PAGE_UP,
|
||||
@ -298,7 +298,9 @@ typedef enum
|
||||
GTK_SCROLL_STEP_LEFT,
|
||||
GTK_SCROLL_STEP_RIGHT,
|
||||
GTK_SCROLL_PAGE_LEFT,
|
||||
GTK_SCROLL_PAGE_RIGHT
|
||||
GTK_SCROLL_PAGE_RIGHT,
|
||||
GTK_SCROLL_START,
|
||||
GTK_SCROLL_END
|
||||
} GtkScrollType;
|
||||
|
||||
/* list selection modes */
|
||||
@ -353,15 +355,6 @@ typedef enum
|
||||
GTK_TOOLBAR_BOTH_HORIZ
|
||||
} GtkToolbarStyle;
|
||||
|
||||
/* Trough types for GtkRange */
|
||||
typedef enum
|
||||
{
|
||||
GTK_TROUGH_NONE,
|
||||
GTK_TROUGH_START,
|
||||
GTK_TROUGH_END,
|
||||
GTK_TROUGH_JUMP
|
||||
} GtkTroughType;
|
||||
|
||||
/* Data update types (for ranges) */
|
||||
typedef enum
|
||||
{
|
||||
|
508
gtk/gtkhscale.c
508
gtk/gtkhscale.c
@ -1,5 +1,5 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -27,47 +27,14 @@
|
||||
#include <stdio.h>
|
||||
#include "gtkhscale.h"
|
||||
#include "gtksignal.h"
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbindings.h"
|
||||
|
||||
#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
|
||||
#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
|
||||
|
||||
enum {
|
||||
PROP_0
|
||||
};
|
||||
static gpointer parent_class;
|
||||
|
||||
static void gtk_hscale_class_init (GtkHScaleClass *klass);
|
||||
static void gtk_hscale_init (GtkHScale *hscale);
|
||||
static void gtk_hscale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_hscale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_hscale_realize (GtkWidget *widget);
|
||||
static void gtk_hscale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_hscale_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_hscale_pos_trough (GtkHScale *hscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h);
|
||||
static void gtk_hscale_pos_background (GtkHScale *hscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h);
|
||||
static void gtk_hscale_draw_slider (GtkRange *range);
|
||||
static void gtk_hscale_draw_value (GtkScale *scale);
|
||||
|
||||
static void gtk_hscale_clear_background (GtkRange *range);
|
||||
|
||||
static gboolean gtk_hscale_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event);
|
||||
|
||||
GtkType
|
||||
gtk_hscale_get_type (void)
|
||||
@ -94,124 +61,33 @@ gtk_hscale_get_type (void)
|
||||
return hscale_type;
|
||||
}
|
||||
|
||||
#define add_slider_binding(binding_set, keyval, mask, scroll, trough) \
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask, \
|
||||
"move_slider", 2, \
|
||||
GTK_TYPE_SCROLL_TYPE, scroll, \
|
||||
GTK_TYPE_TROUGH_TYPE, trough)
|
||||
|
||||
static void
|
||||
gtk_hscale_class_init (GtkHScaleClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
GtkScaleClass *scale_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class = (GObjectClass*) class;
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
range_class = (GtkRangeClass*) class;
|
||||
scale_class = (GtkScaleClass*) class;
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
range_class = GTK_RANGE_CLASS (class);
|
||||
|
||||
gobject_class->set_property = gtk_hscale_set_property;
|
||||
gobject_class->get_property = gtk_hscale_get_property;
|
||||
|
||||
widget_class->realize = gtk_hscale_realize;
|
||||
widget_class->size_request = gtk_hscale_size_request;
|
||||
widget_class->size_allocate = gtk_hscale_size_allocate;
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
range_class->slider_detail = "hscale";
|
||||
|
||||
range_class->slider_update = _gtk_range_default_hslider_update;
|
||||
range_class->trough_click = _gtk_range_default_htrough_click;
|
||||
range_class->motion = _gtk_range_default_hmotion;
|
||||
range_class->draw_slider = gtk_hscale_draw_slider;
|
||||
range_class->clear_background = gtk_hscale_clear_background;
|
||||
|
||||
scale_class->draw_value = gtk_hscale_draw_value;
|
||||
|
||||
binding_set = gtk_binding_set_by_class (object_class);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Left, 0,
|
||||
GTK_SCROLL_STEP_LEFT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_LEFT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Left, 0,
|
||||
GTK_SCROLL_STEP_LEFT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_LEFT, GTK_TROUGH_NONE);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_Right, 0,
|
||||
GTK_SCROLL_STEP_RIGHT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_RIGHT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Right, 0,
|
||||
GTK_SCROLL_STEP_RIGHT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_RIGHT, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Home, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_START);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Home, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_START);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_End, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_END);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_End, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_END);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkHScale *hscale;
|
||||
|
||||
hscale = GTK_HSCALE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkHScale *hscale;
|
||||
|
||||
hscale = GTK_HSCALE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
widget_class->expose_event = gtk_hscale_expose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_init (GtkHScale *hscale)
|
||||
{
|
||||
GTK_WIDGET_SET_FLAGS (hscale, GTK_NO_WINDOW);
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (hscale);
|
||||
|
||||
range->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
range->flippable = TRUE;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@ -223,305 +99,32 @@ gtk_hscale_new (GtkAdjustment *adjustment)
|
||||
"adjustment", adjustment,
|
||||
NULL);
|
||||
|
||||
GTK_RANGE (hscale) -> flippable = 1;
|
||||
|
||||
return hscale;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_hscale_realize (GtkWidget *widget)
|
||||
static gboolean
|
||||
gtk_hscale_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
GtkRange *range;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
gint x, y, w, h;
|
||||
gint slider_width, slider_length;
|
||||
GtkHScale *hscale;
|
||||
GtkScale *scale;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (widget));
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
|
||||
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
|
||||
|
||||
widget->window = gtk_widget_get_parent_window (widget);
|
||||
gdk_window_ref (widget->window);
|
||||
|
||||
gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &w, &h);
|
||||
|
||||
attributes.x = x;
|
||||
attributes.y = y;
|
||||
attributes.width = w;
|
||||
attributes.height = h;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
|
||||
attributes.event_mask = gtk_widget_get_events (widget) |
|
||||
(GDK_EXPOSURE_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK |
|
||||
GDK_LEAVE_NOTIFY_MASK);
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
|
||||
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
|
||||
|
||||
attributes.width = slider_length;
|
||||
attributes.height = slider_width;
|
||||
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK);
|
||||
|
||||
range->slider = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
gdk_window_set_user_data (range->trough, widget);
|
||||
gdk_window_set_user_data (range->slider, widget);
|
||||
|
||||
gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL);
|
||||
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
|
||||
gdk_window_show (range->slider);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_clear_background (GtkRange *range)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
gint x, y, width, height;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
|
||||
widget = GTK_WIDGET (range);
|
||||
|
||||
gtk_hscale_pos_background (GTK_HSCALE (range), &x, &y, &width, &height);
|
||||
|
||||
gtk_widget_queue_clear_area (GTK_WIDGET (range),
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
GtkScale *scale = GTK_SCALE (widget);
|
||||
gint slider_width, slider_length, trough_border;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (widget));
|
||||
g_return_if_fail (requisition != NULL);
|
||||
|
||||
_gtk_range_get_props (GTK_RANGE (scale),
|
||||
&slider_width, &trough_border, NULL, NULL);
|
||||
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
|
||||
|
||||
requisition->width = (slider_length + trough_border) * 2;
|
||||
requisition->height = (slider_width + trough_border * 2);
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
gint value_width, value_height;
|
||||
gtk_scale_get_value_size (scale, &value_width, &value_height);
|
||||
|
||||
if ((scale->value_pos == GTK_POS_LEFT) ||
|
||||
(scale->value_pos == GTK_POS_RIGHT))
|
||||
{
|
||||
requisition->width += value_width + SCALE_CLASS (scale)->value_spacing;
|
||||
if (requisition->height < value_height)
|
||||
requisition->height = value_height;
|
||||
}
|
||||
else if ((scale->value_pos == GTK_POS_TOP) ||
|
||||
(scale->value_pos == GTK_POS_BOTTOM))
|
||||
{
|
||||
if (requisition->width < value_width)
|
||||
requisition->width = value_width;
|
||||
requisition->height += value_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkRange *range;
|
||||
GtkScale *scale;
|
||||
gint width, height;
|
||||
gint x, y;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
widget->allocation = *allocation;
|
||||
if (GTK_WIDGET_REALIZED (widget))
|
||||
{
|
||||
range = GTK_RANGE (widget);
|
||||
scale = GTK_SCALE (widget);
|
||||
|
||||
gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &width, &height);
|
||||
|
||||
gdk_window_move_resize (range->trough,
|
||||
x, y, width, height);
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_pos_trough (GtkHScale *hscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (hscale);
|
||||
GtkScale *scale = GTK_SCALE (hscale);
|
||||
gint slider_width;
|
||||
gint trough_border;
|
||||
|
||||
_gtk_range_get_props (GTK_RANGE (scale),
|
||||
&slider_width, &trough_border, NULL, NULL);
|
||||
|
||||
*w = widget->allocation.width;
|
||||
*h = (slider_width + trough_border * 2);
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
gint value_width, value_height;
|
||||
gtk_scale_get_value_size (scale, &value_width, &value_height);
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
*x += value_width + SCALE_CLASS (scale)->value_spacing;
|
||||
*y = (widget->allocation.height - *h) / 2;
|
||||
*w -= *x;
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
*w -= value_width + SCALE_CLASS (scale)->value_spacing;
|
||||
*y = (widget->allocation.height - *h) / 2;
|
||||
break;
|
||||
case GTK_POS_TOP:
|
||||
*y = (value_height + (widget->allocation.height - widget->requisition.height) / 2);
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
*y = (widget->allocation.height - widget->requisition.height) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = 0;
|
||||
*y = (widget->allocation.height - *h) / 2;
|
||||
}
|
||||
*x += 1;
|
||||
*w -= 2;
|
||||
|
||||
*x += widget->allocation.x;
|
||||
*y += widget->allocation.y;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_pos_background (GtkHScale *hscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkScale *scale;
|
||||
|
||||
gint tx, ty, twidth, theight;
|
||||
|
||||
g_return_if_fail (hscale != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (hscale));
|
||||
g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
|
||||
|
||||
gtk_hscale_pos_trough (hscale, &tx, &ty, &twidth, &theight);
|
||||
|
||||
widget = GTK_WIDGET (hscale);
|
||||
scale = GTK_SCALE (hscale);
|
||||
|
||||
*x = widget->allocation.x;
|
||||
*y = widget->allocation.y;
|
||||
*w = widget->allocation.width;
|
||||
*h = widget->allocation.height;
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
*w -= twidth;
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
*x += twidth;
|
||||
*w -= twidth;
|
||||
break;
|
||||
case GTK_POS_TOP:
|
||||
*h -= theight;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
*y += theight;
|
||||
*h -= theight;
|
||||
break;
|
||||
}
|
||||
*w = MAX (*w, 0);
|
||||
*h = MAX (*h, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_draw_slider (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (range));
|
||||
|
||||
if (range->slider)
|
||||
{
|
||||
if ((range->in_child == RANGE_CLASS (range)->slider) ||
|
||||
(range->click_child == RANGE_CLASS (range)->slider))
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
gtk_paint_slider (GTK_WIDGET (range)->style, range->slider, state_type,
|
||||
GTK_SHADOW_OUT,
|
||||
NULL, GTK_WIDGET (range), "hscale",
|
||||
0, 0, -1, -1,
|
||||
GTK_ORIENTATION_HORIZONTAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscale_draw_value (GtkScale *scale)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkWidget *widget;
|
||||
gint width, height;
|
||||
gint x, y;
|
||||
|
||||
g_return_if_fail (scale != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCALE (scale));
|
||||
|
||||
widget = GTK_WIDGET (scale);
|
||||
scale = GTK_SCALE (widget);
|
||||
hscale = GTK_HSCALE (widget);
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoRectangle logical_rect;
|
||||
gchar *txt;
|
||||
gint x, y;
|
||||
GtkStateType state_type;
|
||||
gint value_spacing;
|
||||
|
||||
gtk_widget_style_get (widget, "value_spacing", &value_spacing, NULL);
|
||||
|
||||
txt = _gtk_scale_format_value (scale,
|
||||
GTK_RANGE (scale)->adjustment->value);
|
||||
|
||||
@ -529,44 +132,37 @@ gtk_hscale_draw_value (GtkScale *scale)
|
||||
g_free (txt);
|
||||
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
|
||||
|
||||
x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
|
||||
y += (height - logical_rect.height) / 2;
|
||||
x = range->range_rect.x - value_spacing - logical_rect.width;
|
||||
y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2;
|
||||
break;
|
||||
|
||||
case GTK_POS_RIGHT:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
|
||||
|
||||
x += width + SCALE_CLASS (scale)->value_spacing;
|
||||
y += (height - logical_rect.height) / 2;
|
||||
x = range->range_rect.x + range->range_rect.width + value_spacing;
|
||||
y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2;
|
||||
break;
|
||||
|
||||
case GTK_POS_TOP:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
|
||||
|
||||
x += widget->allocation.x + (width - logical_rect.width) / 2;
|
||||
x = CLAMP (x, widget->allocation.x,
|
||||
widget->allocation.x + widget->allocation.width - logical_rect.width);
|
||||
y -= logical_rect.height;
|
||||
x = range->slider_start +
|
||||
(range->slider_end - range->slider_start - logical_rect.width) / 2;
|
||||
x = CLAMP (x, 0, widget->allocation.width - logical_rect.width);
|
||||
y = range->range_rect.y - logical_rect.height - value_spacing;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, NULL, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
|
||||
|
||||
x += widget->allocation.x + (width - logical_rect.width) / 2;
|
||||
x = CLAMP (x, widget->allocation.x,
|
||||
widget->allocation.x + widget->allocation.width - logical_rect.width);
|
||||
y += height;
|
||||
case GTK_POS_BOTTOM:
|
||||
x = range->slider_start +
|
||||
(range->slider_end - range->slider_start - logical_rect.width) / 2;
|
||||
x = CLAMP (x, 0, widget->allocation.width - logical_rect.width);
|
||||
y = range->range_rect.y + range->range_rect.height + value_spacing;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
x = 0;
|
||||
y = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -586,4 +182,6 @@ gtk_hscale_draw_value (GtkScale *scale)
|
||||
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
}
|
||||
|
||||
return (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,34 +30,8 @@
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
|
||||
#define EPSILON 0.01
|
||||
|
||||
#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
|
||||
|
||||
enum {
|
||||
PROP_0
|
||||
};
|
||||
|
||||
static void gtk_hscrollbar_class_init (GtkHScrollbarClass *klass);
|
||||
static void gtk_hscrollbar_init (GtkHScrollbar *hscrollbar);
|
||||
static void gtk_hscrollbar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_hscrollbar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_hscrollbar_realize (GtkWidget *widget);
|
||||
static void gtk_hscrollbar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_hscrollbar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_hscrollbar_draw_step_forw (GtkRange *range);
|
||||
static void gtk_hscrollbar_draw_step_back (GtkRange *range);
|
||||
static void gtk_hscrollbar_slider_update (GtkRange *range);
|
||||
static void gtk_hscrollbar_calc_slider_size (GtkHScrollbar *hscrollbar);
|
||||
|
||||
GtkType
|
||||
gtk_hscrollbar_get_type (void)
|
||||
@ -86,69 +61,17 @@ gtk_hscrollbar_get_type (void)
|
||||
static void
|
||||
gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
|
||||
gobject_class = (GObjectClass*) class;
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
range_class = (GtkRangeClass*) class;
|
||||
|
||||
gobject_class->set_property = gtk_hscrollbar_set_property;
|
||||
gobject_class->get_property = gtk_hscrollbar_get_property;
|
||||
|
||||
widget_class->realize = gtk_hscrollbar_realize;
|
||||
widget_class->size_request = gtk_hscrollbar_size_request;
|
||||
widget_class->size_allocate = gtk_hscrollbar_size_allocate;
|
||||
|
||||
range_class->draw_step_forw = gtk_hscrollbar_draw_step_forw;
|
||||
range_class->draw_step_back = gtk_hscrollbar_draw_step_back;
|
||||
range_class->slider_update = gtk_hscrollbar_slider_update;
|
||||
range_class->trough_click = _gtk_range_default_htrough_click;
|
||||
range_class->motion = _gtk_range_default_hmotion;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkHScrollbar *hscrollbar;
|
||||
|
||||
hscrollbar = GTK_HSCROLLBAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkHScrollbar *hscrollbar;
|
||||
|
||||
hscrollbar = GTK_HSCROLLBAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
GTK_RANGE_CLASS (class)->stepper_detail = "hscrollbar";
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_init (GtkHScrollbar *hscrollbar)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (hscrollbar);
|
||||
|
||||
range->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@ -163,282 +86,3 @@ gtk_hscrollbar_new (GtkAdjustment *adjustment)
|
||||
return hscrollbar;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkRange *range;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
gint slider_width;
|
||||
gint trough_border;
|
||||
gint stepper_size;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, &trough_border,
|
||||
&stepper_size, NULL);
|
||||
|
||||
attributes.x = widget->allocation.x;
|
||||
attributes.y = widget->allocation.y + (widget->allocation.height - widget->requisition.height) / 2;
|
||||
attributes.width = widget->allocation.width;
|
||||
attributes.height = widget->requisition.height;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||
attributes.event_mask = gtk_widget_get_events (widget);
|
||||
attributes.event_mask |= (GDK_EXPOSURE_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK |
|
||||
GDK_LEAVE_NOTIFY_MASK);
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
|
||||
|
||||
range->trough = widget->window;
|
||||
gdk_window_ref (range->trough);
|
||||
|
||||
attributes.x = trough_border;
|
||||
attributes.y = trough_border;
|
||||
attributes.width = stepper_size;
|
||||
attributes.height = stepper_size;
|
||||
|
||||
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
attributes.x = (widget->allocation.width -
|
||||
trough_border -
|
||||
stepper_size);
|
||||
|
||||
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
attributes.x = 0;
|
||||
attributes.y = trough_border;
|
||||
attributes.width = RANGE_CLASS (widget)->min_slider_size;
|
||||
attributes.height = slider_width;
|
||||
|
||||
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK);
|
||||
|
||||
range->slider = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
gtk_hscrollbar_calc_slider_size (GTK_HSCROLLBAR (widget));
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
gdk_window_set_user_data (range->trough, widget);
|
||||
gdk_window_set_user_data (range->slider, widget);
|
||||
gdk_window_set_user_data (range->step_forw, widget);
|
||||
gdk_window_set_user_data (range->step_back, widget);
|
||||
|
||||
gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL);
|
||||
gtk_style_set_background (widget->style, range->step_forw, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->step_back, GTK_STATE_ACTIVE);
|
||||
|
||||
gdk_window_show (range->slider);
|
||||
gdk_window_show (range->step_forw);
|
||||
gdk_window_show (range->step_back);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
gint slider_width;
|
||||
gint trough_border;
|
||||
gint stepper_size;
|
||||
gint stepper_spacing;
|
||||
|
||||
GtkRange *range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, &trough_border,
|
||||
&stepper_size, &stepper_spacing);
|
||||
|
||||
requisition->width = (RANGE_CLASS (widget)->min_slider_size +
|
||||
stepper_size +
|
||||
stepper_spacing +
|
||||
trough_border) * 2;
|
||||
requisition->height = (slider_width +
|
||||
trough_border * 2);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkRange *range;
|
||||
gint trough_border;
|
||||
gint stepper_size;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
widget->allocation = *allocation;
|
||||
if (GTK_WIDGET_REALIZED (widget))
|
||||
{
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, NULL, &trough_border,
|
||||
&stepper_size, NULL);
|
||||
|
||||
gdk_window_move_resize (range->trough,
|
||||
allocation->x,
|
||||
allocation->y + (allocation->height - widget->requisition.height) / 2,
|
||||
allocation->width, widget->requisition.height);
|
||||
gdk_window_move_resize (range->step_back,
|
||||
trough_border,
|
||||
trough_border,
|
||||
stepper_size,
|
||||
widget->requisition.height - trough_border * 2);
|
||||
gdk_window_move_resize (range->step_forw,
|
||||
allocation->width - trough_border -
|
||||
stepper_size,
|
||||
trough_border,
|
||||
stepper_size,
|
||||
widget->requisition.height - trough_border * 2);
|
||||
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_draw_step_forw (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (range));
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (range))
|
||||
{
|
||||
if (range->in_child == RANGE_CLASS (range)->step_forw)
|
||||
{
|
||||
if (range->click_child == RANGE_CLASS (range)->step_forw)
|
||||
state_type = GTK_STATE_ACTIVE;
|
||||
else
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
}
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (range->click_child == RANGE_CLASS (range)->step_forw)
|
||||
shadow_type = GTK_SHADOW_IN;
|
||||
else
|
||||
shadow_type = GTK_SHADOW_OUT;
|
||||
|
||||
gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_forw,
|
||||
state_type, shadow_type,
|
||||
NULL, GTK_WIDGET (range), "hscrollbar",
|
||||
GTK_ARROW_RIGHT,
|
||||
TRUE, 0, 0, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_draw_step_back (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (range));
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (range))
|
||||
{
|
||||
if (range->in_child == RANGE_CLASS (range)->step_back)
|
||||
{
|
||||
if (range->click_child == RANGE_CLASS (range)->step_back)
|
||||
state_type = GTK_STATE_ACTIVE;
|
||||
else
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
}
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (range->click_child == RANGE_CLASS (range)->step_back)
|
||||
shadow_type = GTK_SHADOW_IN;
|
||||
else
|
||||
shadow_type = GTK_SHADOW_OUT;
|
||||
|
||||
gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_back,
|
||||
state_type, shadow_type,
|
||||
NULL, GTK_WIDGET (range), "hscrollbar",
|
||||
GTK_ARROW_LEFT,
|
||||
TRUE, 0, 0, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_slider_update (GtkRange *range)
|
||||
{
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (range));
|
||||
|
||||
gtk_hscrollbar_calc_slider_size (GTK_HSCROLLBAR (range));
|
||||
_gtk_range_default_hslider_update (range);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_hscrollbar_calc_slider_size (GtkHScrollbar *hscrollbar)
|
||||
{
|
||||
GtkRange *range;
|
||||
gint step_back_x;
|
||||
gint step_back_width;
|
||||
gint step_forw_x;
|
||||
gint slider_width;
|
||||
gint slider_height;
|
||||
gint stepper_spacing;
|
||||
gint left, right;
|
||||
gint width;
|
||||
|
||||
g_return_if_fail (hscrollbar != NULL);
|
||||
g_return_if_fail (GTK_IS_HSCROLLBAR (hscrollbar));
|
||||
|
||||
if (GTK_WIDGET_REALIZED (hscrollbar))
|
||||
{
|
||||
range = GTK_RANGE (hscrollbar);
|
||||
|
||||
_gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
|
||||
|
||||
gdk_window_get_size (range->step_back, &step_back_width, NULL);
|
||||
gdk_window_get_position (range->step_back, &step_back_x, NULL);
|
||||
gdk_window_get_position (range->step_forw, &step_forw_x, NULL);
|
||||
|
||||
left = (step_back_x +
|
||||
step_back_width +
|
||||
stepper_spacing);
|
||||
right = step_forw_x - stepper_spacing;
|
||||
width = right - left;
|
||||
|
||||
if ((range->adjustment->page_size > 0) &&
|
||||
(range->adjustment->lower != range->adjustment->upper))
|
||||
{
|
||||
if (range->adjustment->page_size >
|
||||
(range->adjustment->upper - range->adjustment->lower))
|
||||
range->adjustment->page_size = range->adjustment->upper - range->adjustment->lower;
|
||||
|
||||
width = (width * range->adjustment->page_size /
|
||||
(range->adjustment->upper - range->adjustment->lower));
|
||||
|
||||
if (width < RANGE_CLASS (hscrollbar)->min_slider_size)
|
||||
width = RANGE_CLASS (hscrollbar)->min_slider_size;
|
||||
}
|
||||
|
||||
gdk_window_get_size (range->slider, &slider_width, &slider_height);
|
||||
|
||||
if (slider_width != width)
|
||||
{
|
||||
gdk_window_resize (range->slider, width, slider_height);
|
||||
gdk_window_invalidate_rect (range->slider, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2898
gtk/gtkrange.c
2898
gtk/gtkrange.c
File diff suppressed because it is too large
Load Diff
139
gtk/gtkrange.h
139
gtk/gtkrange.h
@ -45,6 +45,9 @@ extern "C" {
|
||||
#define GTK_IS_RANGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RANGE))
|
||||
#define GTK_RANGE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_RANGE, GtkRangeClass))
|
||||
|
||||
/* These two are private/opaque types, ignore */
|
||||
typedef struct _GtkRangeLayout GtkRangeLayout;
|
||||
typedef struct _GtkRangeStepTimer GtkRangeStepTimer;
|
||||
|
||||
typedef struct _GtkRange GtkRange;
|
||||
typedef struct _GtkRangeClass GtkRangeClass;
|
||||
@ -53,116 +56,80 @@ struct _GtkRange
|
||||
{
|
||||
GtkWidget widget;
|
||||
|
||||
GdkWindow *trough;
|
||||
GdkWindow *slider;
|
||||
GdkWindow *step_forw;
|
||||
GdkWindow *step_back;
|
||||
|
||||
gint16 x_click_point;
|
||||
gint16 y_click_point;
|
||||
|
||||
guint8 button;
|
||||
gint8 digits;
|
||||
guint policy : 2;
|
||||
guint scroll_type : 5;
|
||||
guint in_child : 3;
|
||||
guint click_child : 3;
|
||||
guint need_timer : 1;
|
||||
guint flippable : 1;
|
||||
guint inverted : 1;
|
||||
|
||||
guint32 timer;
|
||||
|
||||
gdouble old_value;
|
||||
gdouble old_lower;
|
||||
gdouble old_upper;
|
||||
gdouble old_page_size;
|
||||
|
||||
GtkAdjustment *adjustment;
|
||||
GtkUpdateType update_policy;
|
||||
guint inverted : 1;
|
||||
|
||||
/*< protected >*/
|
||||
|
||||
guint flippable : 1;
|
||||
|
||||
/* Steppers are: < > ---- < >
|
||||
* a b c d
|
||||
*/
|
||||
|
||||
guint has_stepper_a : 1;
|
||||
guint has_stepper_b : 1;
|
||||
guint has_stepper_c : 1;
|
||||
guint has_stepper_d : 1;
|
||||
|
||||
guint need_recalc : 1;
|
||||
|
||||
guint slider_size_fixed : 1;
|
||||
|
||||
gint min_slider_size;
|
||||
|
||||
GtkOrientation orientation;
|
||||
|
||||
/* Area of entire stepper + trough assembly in widget->window coords */
|
||||
GdkRectangle range_rect;
|
||||
/* Slider range along the long dimension, in widget->window coords */
|
||||
gint slider_start, slider_end;
|
||||
|
||||
/* Round off value to this many digits, -1 for no rounding */
|
||||
gint round_digits;
|
||||
|
||||
/*< private >*/
|
||||
guint trough_click_forward : 1; /* trough click was on the forward side of slider */
|
||||
guint update_pending : 1; /* need to emit value_changed */
|
||||
GtkRangeLayout *layout;
|
||||
GtkRangeStepTimer *timer;
|
||||
gint slide_initial_slider_position;
|
||||
gint slide_initial_coordinate;
|
||||
guint update_timeout_id;
|
||||
};
|
||||
|
||||
struct _GtkRangeClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
gint min_slider_size;
|
||||
|
||||
guint8 trough;
|
||||
guint8 slider;
|
||||
guint8 step_forw;
|
||||
guint8 step_back;
|
||||
/* what detail to pass to GTK drawing functions */
|
||||
gchar *slider_detail;
|
||||
gchar *stepper_detail;
|
||||
|
||||
/* action signals for keybindings */
|
||||
void (* move_slider) (GtkRange *range,
|
||||
GtkScrollType scroll,
|
||||
GtkTroughType trough);
|
||||
GtkScrollType scroll);
|
||||
|
||||
/* Completely broken virtual functions, please ignore */
|
||||
|
||||
void (* draw_background) (GtkRange *range);
|
||||
void (* clear_background) (GtkRange *range);
|
||||
void (* draw_trough) (GtkRange *range);
|
||||
void (* draw_slider) (GtkRange *range);
|
||||
void (* draw_step_forw) (GtkRange *range);
|
||||
void (* draw_step_back) (GtkRange *range);
|
||||
void (* slider_update) (GtkRange *range);
|
||||
gboolean (* trough_click) (GtkRange *range,
|
||||
gint x,
|
||||
gint y,
|
||||
gdouble *jump_perc);
|
||||
void (* motion) (GtkRange *range,
|
||||
gint xdelta,
|
||||
gint ydelta);
|
||||
gboolean (* timer) (GtkRange *range);
|
||||
/* Virtual functions */
|
||||
void (* get_range_border) (GtkRange *range,
|
||||
GtkBorder *border);
|
||||
};
|
||||
|
||||
|
||||
GtkType gtk_range_get_type (void) G_GNUC_CONST;
|
||||
GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
|
||||
|
||||
void gtk_range_set_update_policy (GtkRange *range,
|
||||
GtkUpdateType policy);
|
||||
|
||||
void gtk_range_set_adjustment (GtkRange *range,
|
||||
GtkAdjustment *adjustment);
|
||||
GtkAdjustment* gtk_range_get_adjustment (GtkRange *range);
|
||||
|
||||
void gtk_range_set_inverted (GtkRange *range,
|
||||
gboolean setting);
|
||||
gboolean gtk_range_get_inverted (GtkRange *range);
|
||||
|
||||
void _gtk_range_draw_background (GtkRange *range);
|
||||
void _gtk_range_clear_background (GtkRange *range);
|
||||
void _gtk_range_draw_trough (GtkRange *range);
|
||||
void _gtk_range_draw_slider (GtkRange *range);
|
||||
void _gtk_range_draw_step_forw (GtkRange *range);
|
||||
void _gtk_range_draw_step_back (GtkRange *range);
|
||||
void _gtk_range_slider_update (GtkRange *range);
|
||||
gboolean _gtk_range_trough_click (GtkRange *range,
|
||||
gint x,
|
||||
gint y,
|
||||
gdouble *jump_perc);
|
||||
|
||||
void _gtk_range_default_hslider_update (GtkRange *range);
|
||||
void _gtk_range_default_vslider_update (GtkRange *range);
|
||||
gboolean _gtk_range_default_htrough_click (GtkRange *range,
|
||||
gint x,
|
||||
gint y,
|
||||
gdouble *jump_perc);
|
||||
gboolean _gtk_range_default_vtrough_click (GtkRange *range,
|
||||
gint x,
|
||||
gint y,
|
||||
gdouble *jump_perc);
|
||||
void _gtk_range_default_hmotion (GtkRange *range,
|
||||
gint xdelta,
|
||||
gint ydelta);
|
||||
void _gtk_range_default_vmotion (GtkRange *range,
|
||||
gint xdelta,
|
||||
gint ydelta);
|
||||
|
||||
void _gtk_range_get_props (GtkRange *range,
|
||||
gint *slider_width,
|
||||
gint *trough_border,
|
||||
gint *stepper_size,
|
||||
gint *stepper_spacing);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
322
gtk/gtkscale.c
322
gtk/gtkscale.c
@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -28,6 +29,8 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkscale.h"
|
||||
#include "gtkmarshal.h"
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkbindings.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
@ -42,25 +45,22 @@ enum {
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
static void gtk_scale_class_init (GtkScaleClass *klass);
|
||||
static void gtk_scale_init (GtkScale *scale);
|
||||
static void gtk_scale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_scale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_scale_map (GtkWidget *widget);
|
||||
static void gtk_scale_unmap (GtkWidget *widget);
|
||||
|
||||
static void gtk_scale_draw_background (GtkRange *range);
|
||||
|
||||
|
||||
static GtkRangeClass *parent_class = NULL;
|
||||
|
||||
static void gtk_scale_class_init (GtkScaleClass *klass);
|
||||
static void gtk_scale_init (GtkScale *scale);
|
||||
static void gtk_scale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_scale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_scale_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous);
|
||||
static void gtk_scale_get_range_border (GtkRange *range,
|
||||
GtkBorder *border);
|
||||
|
||||
GtkType
|
||||
gtk_scale_get_type (void)
|
||||
@ -103,6 +103,12 @@ single_string_accumulator (GSignalInvocationHint *ihint,
|
||||
return continue_emission;
|
||||
}
|
||||
|
||||
|
||||
#define add_slider_binding(binding_set, keyval, mask, scroll) \
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask, \
|
||||
"move_slider", 1, \
|
||||
GTK_TYPE_SCROLL_TYPE, scroll)
|
||||
|
||||
static void
|
||||
gtk_scale_class_init (GtkScaleClass *class)
|
||||
{
|
||||
@ -110,7 +116,8 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
object_class = (GtkObjectClass*) class;
|
||||
range_class = (GtkRangeClass*) class;
|
||||
@ -121,11 +128,10 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
gobject_class->set_property = gtk_scale_set_property;
|
||||
gobject_class->get_property = gtk_scale_get_property;
|
||||
|
||||
widget_class->map = gtk_scale_map;
|
||||
widget_class->unmap = gtk_scale_unmap;
|
||||
|
||||
range_class->draw_background = gtk_scale_draw_background;
|
||||
widget_class->style_set = gtk_scale_style_set;
|
||||
|
||||
range_class->get_range_border = gtk_scale_get_range_border;
|
||||
|
||||
signals[FORMAT_VALUE] =
|
||||
g_signal_newc ("format_value",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
@ -171,8 +177,99 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
G_MAXINT,
|
||||
31,
|
||||
G_PARAM_READABLE));
|
||||
class->value_spacing = 2;
|
||||
class->draw_value = NULL;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("value_spacing",
|
||||
_("Value spacing"),
|
||||
_("Space between value text and the slider/trough area"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
2,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* All bindings (even arrow keys) are on both h/v scale, because
|
||||
* blind users etc. don't care about scale orientation.
|
||||
*/
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Left, 0,
|
||||
GTK_SCROLL_STEP_LEFT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_LEFT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Left, 0,
|
||||
GTK_SCROLL_STEP_LEFT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_LEFT);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_Right, 0,
|
||||
GTK_SCROLL_STEP_RIGHT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_RIGHT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Right, 0,
|
||||
GTK_SCROLL_STEP_RIGHT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_RIGHT);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Up, 0,
|
||||
GTK_SCROLL_STEP_UP);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Up, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_UP);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Up, 0,
|
||||
GTK_SCROLL_STEP_UP);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_UP);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_Down, 0,
|
||||
GTK_SCROLL_STEP_DOWN);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Down, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_DOWN);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Down, 0,
|
||||
GTK_SCROLL_STEP_DOWN);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_DOWN);
|
||||
|
||||
/* I think most users will find it strange that these move
|
||||
* logically instead of visually...
|
||||
*/
|
||||
|
||||
add_slider_binding (binding_set, GDK_Page_Up, 0,
|
||||
GTK_SCROLL_PAGE_BACKWARD);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Page_Up, 0,
|
||||
GTK_SCROLL_PAGE_BACKWARD);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Page_Down, 0,
|
||||
GTK_SCROLL_PAGE_FORWARD);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Page_Down, 0,
|
||||
GTK_SCROLL_PAGE_FORWARD);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Home, 0,
|
||||
GTK_SCROLL_START);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Home, 0,
|
||||
GTK_SCROLL_START);
|
||||
|
||||
add_slider_binding (binding_set, GDK_End, 0,
|
||||
GTK_SCROLL_END);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_End, 0,
|
||||
GTK_SCROLL_END);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -215,7 +312,7 @@ gtk_scale_get_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DIGITS:
|
||||
g_value_set_int (value, GTK_RANGE (scale)->digits);
|
||||
g_value_set_int (value, scale->digits);
|
||||
break;
|
||||
case PROP_DRAW_VALUE:
|
||||
g_value_set_boolean (value, scale->draw_value);
|
||||
@ -232,63 +329,55 @@ gtk_scale_get_property (GObject *object,
|
||||
static void
|
||||
gtk_scale_init (GtkScale *scale)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (scale);
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (scale, GTK_CAN_FOCUS);
|
||||
GTK_WIDGET_SET_FLAGS (scale, GTK_NO_WINDOW);
|
||||
GTK_RANGE (scale)->digits = 1;
|
||||
|
||||
range->slider_size_fixed = TRUE;
|
||||
range->has_stepper_a = FALSE;
|
||||
range->has_stepper_b = FALSE;
|
||||
range->has_stepper_c = FALSE;
|
||||
range->has_stepper_d = FALSE;
|
||||
|
||||
scale->draw_value = TRUE;
|
||||
scale->value_pos = GTK_POS_TOP;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_map (GtkWidget *widget)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (widget));
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
gdk_window_show (range->trough);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_unmap (GtkWidget *widget)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (widget));
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
if (GTK_WIDGET_NO_WINDOW (widget))
|
||||
gtk_widget_queue_clear (widget);
|
||||
|
||||
gdk_window_hide (range->trough);
|
||||
scale->digits = 1;
|
||||
range->round_digits = scale->digits;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_scale_set_digits (GtkScale *scale,
|
||||
gint digits)
|
||||
{
|
||||
g_return_if_fail (scale != NULL);
|
||||
GtkRange *range;
|
||||
|
||||
g_return_if_fail (GTK_IS_SCALE (scale));
|
||||
|
||||
range = GTK_RANGE (scale);
|
||||
|
||||
digits = CLAMP (digits, -1, 16);
|
||||
|
||||
if (GTK_RANGE (scale)->digits != digits)
|
||||
if (scale->digits != digits)
|
||||
{
|
||||
GTK_RANGE (scale)->digits = digits;
|
||||
|
||||
scale->digits = digits;
|
||||
range->round_digits = digits;
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (scale));
|
||||
|
||||
g_object_notify (G_OBJECT (scale), "digits");
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_scale_get_digits (GtkScale *scale)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SCALE (scale), -1);
|
||||
|
||||
return scale->digits;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_scale_set_draw_value (GtkScale *scale,
|
||||
gboolean draw_value)
|
||||
@ -308,11 +397,18 @@ gtk_scale_set_draw_value (GtkScale *scale,
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_scale_get_draw_value (GtkScale *scale)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SCALE (scale), FALSE);
|
||||
|
||||
return scale->draw_value;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_scale_set_value_pos (GtkScale *scale,
|
||||
GtkPositionType pos)
|
||||
{
|
||||
g_return_if_fail (scale != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (scale));
|
||||
|
||||
if (scale->value_pos != pos)
|
||||
@ -326,10 +422,60 @@ gtk_scale_set_value_pos (GtkScale *scale,
|
||||
}
|
||||
}
|
||||
|
||||
GtkPositionType
|
||||
gtk_scale_get_value_pos (GtkScale *scale)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SCALE (scale), 0);
|
||||
|
||||
return scale->value_pos;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_get_range_border (GtkRange *range,
|
||||
GtkBorder *border)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkScale *scale;
|
||||
gint w, h;
|
||||
|
||||
widget = GTK_WIDGET (range);
|
||||
scale = GTK_SCALE (range);
|
||||
|
||||
_gtk_scale_get_value_size (scale, &w, &h);
|
||||
|
||||
border->left = 0;
|
||||
border->right = 0;
|
||||
border->top = 0;
|
||||
border->bottom = 0;
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
gint value_spacing;
|
||||
gtk_widget_style_get (widget, "value_spacing", &value_spacing, NULL);
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
border->left += w + value_spacing;
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
border->right += w + value_spacing;
|
||||
break;
|
||||
case GTK_POS_TOP:
|
||||
border->top += h + value_spacing;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
border->bottom += h + value_spacing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME this could actually be static at the moment. */
|
||||
void
|
||||
gtk_scale_get_value_size (GtkScale *scale,
|
||||
gint *width,
|
||||
gint *height)
|
||||
_gtk_scale_get_value_size (GtkScale *scale,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
@ -380,39 +526,25 @@ gtk_scale_get_value_size (GtkScale *scale,
|
||||
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_scale_get_value_width (GtkScale *scale)
|
||||
{
|
||||
gint width;
|
||||
|
||||
g_return_val_if_fail (scale != NULL, 0);
|
||||
g_return_val_if_fail (GTK_IS_SCALE (scale), 0);
|
||||
|
||||
gtk_scale_get_value_size (scale, &width, NULL);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_scale_draw_value (GtkScale *scale)
|
||||
{
|
||||
g_return_if_fail (scale != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (scale));
|
||||
|
||||
if (GTK_SCALE_GET_CLASS (scale)->draw_value)
|
||||
GTK_SCALE_GET_CLASS (scale)->draw_value (scale);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_scale_draw_background (GtkRange *range)
|
||||
gtk_scale_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous)
|
||||
{
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (range));
|
||||
gint slider_length;
|
||||
GtkRange *range;
|
||||
|
||||
gtk_scale_draw_value (GTK_SCALE (range));
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"slider_length", &slider_length,
|
||||
NULL);
|
||||
|
||||
range->min_slider_size = slider_length;
|
||||
|
||||
(* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _gtk_scale_format_value:
|
||||
* @scale: a #GtkScale
|
||||
@ -438,6 +570,6 @@ _gtk_scale_format_value (GtkScale *scale,
|
||||
if (fmt)
|
||||
return fmt;
|
||||
else
|
||||
return g_strdup_printf ("%0.*f", GTK_RANGE (scale)->digits,
|
||||
return g_strdup_printf ("%0.*f", scale->digits,
|
||||
value);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ struct _GtkScale
|
||||
{
|
||||
GtkRange range;
|
||||
|
||||
gint digits;
|
||||
guint draw_value : 1;
|
||||
guint value_pos : 2;
|
||||
};
|
||||
@ -60,8 +61,6 @@ struct _GtkScaleClass
|
||||
{
|
||||
GtkRangeClass parent_class;
|
||||
|
||||
gint value_spacing;
|
||||
|
||||
gchar* (* format_value) (GtkRange *range,
|
||||
gdouble value);
|
||||
|
||||
@ -69,19 +68,21 @@ struct _GtkScaleClass
|
||||
};
|
||||
|
||||
GtkType gtk_scale_get_type (void) G_GNUC_CONST;
|
||||
void gtk_scale_set_digits (GtkScale *scale,
|
||||
gint digits);
|
||||
void gtk_scale_set_draw_value (GtkScale *scale,
|
||||
gboolean draw_value);
|
||||
void gtk_scale_set_value_pos (GtkScale *scale,
|
||||
GtkPositionType pos);
|
||||
gint gtk_scale_get_value_width (GtkScale *scale);
|
||||
void gtk_scale_get_value_size (GtkScale *scale,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
void gtk_scale_draw_value (GtkScale *scale);
|
||||
void gtk_scale_set_digits (GtkScale *scale,
|
||||
gint digits);
|
||||
gint gtk_scale_get_digits (GtkScale *scale);
|
||||
void gtk_scale_set_draw_value (GtkScale *scale,
|
||||
gboolean draw_value);
|
||||
gboolean gtk_scale_get_draw_value (GtkScale *scale);
|
||||
void gtk_scale_set_value_pos (GtkScale *scale,
|
||||
GtkPositionType pos);
|
||||
GtkPositionType gtk_scale_get_value_pos (GtkScale *scale);
|
||||
|
||||
|
||||
void _gtk_scale_get_value_size (GtkScale *scale,
|
||||
gint *width,
|
||||
gint *height);
|
||||
gchar *_gtk_scale_format_value (GtkScale *scale,
|
||||
gdouble value);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -25,9 +26,14 @@
|
||||
*/
|
||||
|
||||
#include "gtkscrollbar.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
static void gtk_scrollbar_class_init (GtkScrollbarClass *klass);
|
||||
static void gtk_scrollbar_init (GtkScrollbar *scrollbar);
|
||||
static void gtk_scrollbar_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous);
|
||||
|
||||
static gpointer parent_class;
|
||||
|
||||
GtkType
|
||||
gtk_scrollbar_get_type (void)
|
||||
@ -57,9 +63,101 @@ gtk_scrollbar_get_type (void)
|
||||
static void
|
||||
gtk_scrollbar_class_init (GtkScrollbarClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
widget_class->style_set = gtk_scrollbar_style_set;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("min_slider_length",
|
||||
_("Minimum Slider Length"),
|
||||
_("Minimum length of scrollbar slider"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
7,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("fixed_slider_length",
|
||||
_("Fixed slider size"),
|
||||
_("Don't change slider size, just lock it to the minimum length"),
|
||||
FALSE,
|
||||
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("has_backward_stepper",
|
||||
_("Backward stepper"),
|
||||
_("Display the standard backward arrow button"),
|
||||
TRUE,
|
||||
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("has_forward_stepper",
|
||||
_("Forward stepper"),
|
||||
_("Display the standard forward arrow button"),
|
||||
TRUE,
|
||||
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("has_secondary_backward_stepper",
|
||||
_("Secondary backward stepper"),
|
||||
_("Display a second backward arrow button on the opposite end of the scrollbar"),
|
||||
FALSE,
|
||||
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("has_secondary_forward_stepper",
|
||||
_("Secondary forward stepper"),
|
||||
_("Display a secondary forward arrow button on the opposite end of the scrollbar"),
|
||||
FALSE,
|
||||
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrollbar_init (GtkScrollbar *scrollbar)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (scrollbar);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrollbar_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous)
|
||||
{
|
||||
gint slider_length;
|
||||
gboolean fixed_size;
|
||||
gboolean has_a, has_b, has_c, has_d;
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"min_slider_length", &slider_length,
|
||||
"fixed_slider_length", &fixed_size,
|
||||
"has_backward_stepper", &has_a,
|
||||
"has_secondary_forward_stepper", &has_b,
|
||||
"has_secondary_backward_stepper", &has_c,
|
||||
"has_forward_stepper", &has_d,
|
||||
NULL);
|
||||
|
||||
range->min_slider_size = slider_length;
|
||||
range->slider_size_fixed = fixed_size;
|
||||
|
||||
range->has_stepper_a = has_a;
|
||||
range->has_stepper_b = has_b;
|
||||
range->has_stepper_c = has_c;
|
||||
range->has_stepper_d = has_d;
|
||||
|
||||
(* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3754,14 +3754,19 @@ gtk_default_draw_slider (GtkStyle *style,
|
||||
gtk_paint_box (style, window, state_type, shadow_type,
|
||||
area, widget, detail, x, y, width, height);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_paint_vline (style, window, state_type, area, widget, detail,
|
||||
style->ythickness,
|
||||
height - style->ythickness - 1, width / 2);
|
||||
else
|
||||
gtk_paint_hline (style, window, state_type, area, widget, detail,
|
||||
style->xthickness,
|
||||
width - style->xthickness - 1, height / 2);
|
||||
if (detail &&
|
||||
(strcmp ("hscale", detail) == 0 ||
|
||||
strcmp ("vscale", detail) == 0))
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_paint_vline (style, window, state_type, area, widget, detail,
|
||||
y + style->ythickness,
|
||||
y + height - style->ythickness - 1, x + width / 2);
|
||||
else
|
||||
gtk_paint_hline (style, window, state_type, area, widget, detail,
|
||||
x + style->xthickness,
|
||||
x + width - style->xthickness - 1, y + height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
515
gtk/gtkvscale.c
515
gtk/gtkvscale.c
@ -1,5 +1,5 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -27,46 +27,16 @@
|
||||
#include <stdio.h>
|
||||
#include "gtkvscale.h"
|
||||
#include "gtksignal.h"
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbindings.h"
|
||||
|
||||
#define VALUE_SPACING 2
|
||||
|
||||
#define SCALE_CLASS(w) GTK_SCALE_GET_CLASS (w)
|
||||
#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
|
||||
|
||||
enum {
|
||||
PROP_0
|
||||
};
|
||||
static gpointer parent_class;
|
||||
|
||||
static void gtk_vscale_class_init (GtkVScaleClass *klass);
|
||||
static void gtk_vscale_init (GtkVScale *vscale);
|
||||
static void gtk_vscale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_vscale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_vscale_realize (GtkWidget *widget);
|
||||
static void gtk_vscale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vscale_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_vscale_pos_trough (GtkVScale *vscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h);
|
||||
static void gtk_vscale_pos_background (GtkVScale *vscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h);
|
||||
static void gtk_vscale_draw_slider (GtkRange *range);
|
||||
static void gtk_vscale_draw_value (GtkScale *scale);
|
||||
static void gtk_vscale_clear_background (GtkRange *range);
|
||||
static gboolean gtk_vscale_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event);
|
||||
|
||||
GtkType
|
||||
gtk_vscale_get_type (void)
|
||||
@ -93,136 +63,32 @@ gtk_vscale_get_type (void)
|
||||
return vscale_type;
|
||||
}
|
||||
|
||||
#define add_slider_binding(binding_set, keyval, mask, scroll, trough) \
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask, \
|
||||
"move_slider", 2, \
|
||||
GTK_TYPE_SCROLL_TYPE, scroll, \
|
||||
GTK_TYPE_TROUGH_TYPE, trough)
|
||||
|
||||
static void
|
||||
gtk_vscale_class_init (GtkVScaleClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GObjectClass *gobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
GtkScaleClass *scale_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
range_class = (GtkRangeClass*) class;
|
||||
scale_class = (GtkScaleClass*) class;
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
range_class = GTK_RANGE_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
range_class->slider_detail = "vscale";
|
||||
|
||||
gobject_class->set_property = gtk_vscale_set_property;
|
||||
gobject_class->get_property = gtk_vscale_get_property;
|
||||
|
||||
widget_class->realize = gtk_vscale_realize;
|
||||
widget_class->size_request = gtk_vscale_size_request;
|
||||
widget_class->size_allocate = gtk_vscale_size_allocate;
|
||||
|
||||
range_class->slider_update = _gtk_range_default_vslider_update;
|
||||
range_class->trough_click = _gtk_range_default_vtrough_click;
|
||||
range_class->motion = _gtk_range_default_vmotion;
|
||||
range_class->draw_slider = gtk_vscale_draw_slider;
|
||||
range_class->clear_background = gtk_vscale_clear_background;
|
||||
|
||||
scale_class->draw_value = gtk_vscale_draw_value;
|
||||
|
||||
binding_set = gtk_binding_set_by_class (object_class);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Up, 0,
|
||||
GTK_SCROLL_STEP_UP, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Up, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_UP, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Up, 0,
|
||||
GTK_SCROLL_STEP_UP, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_UP, GTK_TROUGH_NONE);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_Down, 0,
|
||||
GTK_SCROLL_STEP_DOWN, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Down, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_DOWN, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Down, 0,
|
||||
GTK_SCROLL_STEP_DOWN, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK,
|
||||
GTK_SCROLL_PAGE_DOWN, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Page_Up, 0,
|
||||
GTK_SCROLL_PAGE_BACKWARD, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Page_Up, 0,
|
||||
GTK_SCROLL_PAGE_BACKWARD, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Page_Down, 0,
|
||||
GTK_SCROLL_PAGE_FORWARD, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Page_Down, 0,
|
||||
GTK_SCROLL_PAGE_FORWARD, GTK_TROUGH_NONE);
|
||||
|
||||
add_slider_binding (binding_set, GDK_Home, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_START);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_Home, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_START);
|
||||
|
||||
|
||||
add_slider_binding (binding_set, GDK_End, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_END);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KP_End, 0,
|
||||
GTK_SCROLL_NONE, GTK_TROUGH_END);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkVScale *vscale;
|
||||
|
||||
vscale = GTK_VSCALE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkVScale *vscale;
|
||||
|
||||
vscale = GTK_VSCALE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
widget_class->expose_event = gtk_vscale_expose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_init (GtkVScale *vscale)
|
||||
{
|
||||
GTK_WIDGET_SET_FLAGS (vscale, GTK_NO_WINDOW);
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (vscale);
|
||||
|
||||
range->orientation = GTK_ORIENTATION_VERTICAL;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@ -237,298 +103,28 @@ gtk_vscale_new (GtkAdjustment *adjustment)
|
||||
return vscale;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_vscale_realize (GtkWidget *widget)
|
||||
static gboolean
|
||||
gtk_vscale_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
GtkRange *range;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
gint x, y, w, h;
|
||||
gint slider_width, slider_length;
|
||||
GtkVScale *vscale;
|
||||
GtkScale *scale;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCALE (widget));
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
|
||||
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
|
||||
|
||||
widget->window = gtk_widget_get_parent_window (widget);
|
||||
gdk_window_ref (widget->window);
|
||||
|
||||
gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &w, &h);
|
||||
|
||||
attributes.x = x;
|
||||
attributes.y = y;
|
||||
attributes.width = w;
|
||||
attributes.height = h;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
|
||||
attributes.event_mask = gtk_widget_get_events (widget) |
|
||||
(GDK_EXPOSURE_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK |
|
||||
GDK_LEAVE_NOTIFY_MASK);
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
|
||||
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
|
||||
|
||||
attributes.width = slider_width;
|
||||
attributes.height = slider_length;
|
||||
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK);
|
||||
|
||||
range->slider = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
gdk_window_set_user_data (range->trough, widget);
|
||||
gdk_window_set_user_data (range->slider, widget);
|
||||
|
||||
gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL);
|
||||
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
|
||||
gdk_window_show (range->slider);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_clear_background (GtkRange *range)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkScale *scale;
|
||||
gint x, y, width, height;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_SCALE (range));
|
||||
|
||||
widget = GTK_WIDGET (range);
|
||||
scale = GTK_SCALE (range);
|
||||
|
||||
gtk_vscale_pos_background (GTK_VSCALE (widget), &x, &y, &width, &height);
|
||||
|
||||
gtk_widget_queue_clear_area (GTK_WIDGET (range),
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
GtkScale *scale = GTK_SCALE (widget);
|
||||
gint slider_width, slider_length, trough_border;
|
||||
|
||||
_gtk_range_get_props (GTK_RANGE (scale),
|
||||
&slider_width, &trough_border, NULL, NULL);
|
||||
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
|
||||
|
||||
requisition->width = (slider_width + trough_border * 2);
|
||||
requisition->height = (slider_length + trough_border) * 2;
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
gint value_width, value_height;
|
||||
gtk_scale_get_value_size (scale, &value_width, &value_height);
|
||||
|
||||
if ((scale->value_pos == GTK_POS_LEFT) ||
|
||||
(scale->value_pos == GTK_POS_RIGHT))
|
||||
{
|
||||
requisition->width += value_width + SCALE_CLASS (scale)->value_spacing;
|
||||
if (requisition->height < (value_height))
|
||||
requisition->height = value_height;
|
||||
}
|
||||
else if ((scale->value_pos == GTK_POS_TOP) ||
|
||||
(scale->value_pos == GTK_POS_BOTTOM))
|
||||
{
|
||||
if (requisition->width < value_width)
|
||||
requisition->width = value_width;
|
||||
requisition->height += value_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkRange *range;
|
||||
GtkScale *scale;
|
||||
gint width, height;
|
||||
gint x, y;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCALE (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
widget->allocation = *allocation;
|
||||
if (GTK_WIDGET_REALIZED (widget))
|
||||
{
|
||||
range = GTK_RANGE (widget);
|
||||
scale = GTK_SCALE (widget);
|
||||
|
||||
gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &width, &height);
|
||||
|
||||
gdk_window_move_resize (range->trough, x, y, width, height);
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_pos_trough (GtkVScale *vscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (vscale);
|
||||
GtkScale *scale = GTK_SCALE (vscale);
|
||||
gint value_width, value_height;
|
||||
gint slider_width, trough_border;
|
||||
|
||||
_gtk_range_get_props (GTK_RANGE (scale),
|
||||
&slider_width, &trough_border, NULL, NULL);
|
||||
|
||||
*w = (slider_width + trough_border * 2);
|
||||
*h = widget->allocation.height;
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
|
||||
gtk_scale_get_value_size (scale, &value_width, &value_height);
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
*x = (value_width + SCALE_CLASS (scale)->value_spacing +
|
||||
(widget->allocation.width - widget->requisition.width) / 2);
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
*x = (widget->allocation.width - widget->requisition.width) / 2;
|
||||
break;
|
||||
case GTK_POS_TOP:
|
||||
*x = (widget->allocation.width - *w) / 2;
|
||||
*y = value_height;
|
||||
*h -= *y;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
*x = (widget->allocation.width - *w) / 2;
|
||||
*h -= value_height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = (widget->allocation.width - *w) / 2;
|
||||
*y = 0;
|
||||
}
|
||||
*y += 1;
|
||||
*h -= 2;
|
||||
|
||||
*x += widget->allocation.x;
|
||||
*y += widget->allocation.y;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_pos_background (GtkVScale *vscale,
|
||||
gint *x,
|
||||
gint *y,
|
||||
gint *w,
|
||||
gint *h)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkScale *scale;
|
||||
gint slider_width, trough_border;
|
||||
|
||||
gint tx, ty, twidth, theight;
|
||||
|
||||
g_return_if_fail (vscale != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCALE (vscale));
|
||||
g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
|
||||
|
||||
gtk_vscale_pos_trough (vscale, &tx, &ty, &twidth, &theight);
|
||||
|
||||
widget = GTK_WIDGET (vscale);
|
||||
scale = GTK_SCALE (vscale);
|
||||
|
||||
*x = widget->allocation.x;
|
||||
*y = widget->allocation.y;
|
||||
*w = widget->allocation.width;
|
||||
*h = widget->allocation.height;
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
*w -= twidth;
|
||||
break;
|
||||
case GTK_POS_RIGHT:
|
||||
*x += twidth;
|
||||
*w -= twidth;
|
||||
break;
|
||||
case GTK_POS_TOP:
|
||||
*h -= theight;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
*y += theight;
|
||||
*h -= theight;
|
||||
break;
|
||||
}
|
||||
*w = MAX (*w, 0);
|
||||
*h = MAX (*h, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_draw_slider (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCALE (range));
|
||||
|
||||
if (range->slider)
|
||||
{
|
||||
if ((range->in_child == RANGE_CLASS (range)->slider) ||
|
||||
(range->click_child == RANGE_CLASS (range)->slider))
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
gtk_paint_slider (GTK_WIDGET (range)->style, range->slider, state_type,
|
||||
GTK_SHADOW_OUT,
|
||||
NULL, GTK_WIDGET (range), "vscale",
|
||||
0, 0, -1, -1,
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscale_draw_value (GtkScale *scale)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkWidget *widget;
|
||||
gint width, height;
|
||||
gint x, y;
|
||||
|
||||
g_return_if_fail (scale != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCALE (scale));
|
||||
|
||||
widget = GTK_WIDGET (scale);
|
||||
scale = GTK_SCALE (widget);
|
||||
vscale = GTK_VSCALE (widget);
|
||||
|
||||
if (scale->draw_value)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoRectangle logical_rect;
|
||||
gchar *txt;
|
||||
gint x, y;
|
||||
GtkStateType state_type;
|
||||
gint value_spacing;
|
||||
|
||||
gtk_widget_style_get (widget, "value_spacing", &value_spacing, NULL);
|
||||
|
||||
txt = _gtk_scale_format_value (scale,
|
||||
GTK_RANGE (scale)->adjustment->value);
|
||||
@ -537,44 +133,35 @@ gtk_vscale_draw_value (GtkScale *scale)
|
||||
g_free (txt);
|
||||
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||
|
||||
|
||||
switch (scale->value_pos)
|
||||
{
|
||||
case GTK_POS_LEFT:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, NULL);
|
||||
gdk_window_get_position (GTK_RANGE (scale)->slider, NULL, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height);
|
||||
|
||||
x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
|
||||
y += widget->allocation.y + (height - logical_rect.height) / 2 +
|
||||
PANGO_ASCENT (logical_rect);
|
||||
x = range->range_rect.x - logical_rect.width - value_spacing;
|
||||
y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2;
|
||||
y = CLAMP (y, 0, widget->allocation.height - logical_rect.height);
|
||||
break;
|
||||
|
||||
case GTK_POS_RIGHT:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, NULL);
|
||||
gdk_window_get_position (GTK_RANGE (scale)->slider, NULL, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height);
|
||||
|
||||
x += width + SCALE_CLASS (scale)->value_spacing;
|
||||
y += widget->allocation.y + (height - logical_rect.height) / 2 +
|
||||
PANGO_ASCENT (logical_rect);
|
||||
x = range->range_rect.x + range->range_rect.width + value_spacing;
|
||||
y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2;
|
||||
y = CLAMP (y, 0, widget->allocation.height - logical_rect.height);
|
||||
break;
|
||||
|
||||
case GTK_POS_TOP:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
|
||||
|
||||
x += (width - logical_rect.width) / 2;
|
||||
y -= PANGO_DESCENT (logical_rect);
|
||||
x = range->range_rect.x + (range->range_rect.width - logical_rect.width) / 2;
|
||||
y = range->range_rect.y - logical_rect.height - value_spacing;
|
||||
break;
|
||||
case GTK_POS_BOTTOM:
|
||||
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
|
||||
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
|
||||
|
||||
x += (width - logical_rect.width) / 2;
|
||||
y += height + PANGO_ASCENT (logical_rect);
|
||||
case GTK_POS_BOTTOM:
|
||||
x = range->range_rect.x + (range->range_rect.width - logical_rect.width) / 2;
|
||||
y = range->range_rect.y + range->range_rect.height + value_spacing;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
x = 0;
|
||||
y = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -590,8 +177,10 @@ gtk_vscale_draw_value (GtkScale *scale)
|
||||
widget,
|
||||
"vscale",
|
||||
x, y,
|
||||
layout);
|
||||
layout);
|
||||
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
}
|
||||
|
||||
return (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,34 +30,8 @@
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
|
||||
#define EPSILON 0.01
|
||||
|
||||
#define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
};
|
||||
|
||||
static void gtk_vscrollbar_class_init (GtkVScrollbarClass *klass);
|
||||
static void gtk_vscrollbar_init (GtkVScrollbar *vscrollbar);
|
||||
static void gtk_vscrollbar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_vscrollbar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_vscrollbar_realize (GtkWidget *widget);
|
||||
static void gtk_vscrollbar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_vscrollbar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_vscrollbar_draw_step_forw (GtkRange *range);
|
||||
static void gtk_vscrollbar_draw_step_back (GtkRange *range);
|
||||
static void gtk_vscrollbar_slider_update (GtkRange *range);
|
||||
static void gtk_vscrollbar_calc_slider_size (GtkVScrollbar *vscrollbar);
|
||||
|
||||
GtkType
|
||||
gtk_vscrollbar_get_type (void)
|
||||
@ -86,67 +61,17 @@ gtk_vscrollbar_get_type (void)
|
||||
static void
|
||||
gtk_vscrollbar_class_init (GtkVScrollbarClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
range_class = (GtkRangeClass*) class;
|
||||
|
||||
gobject_class->set_property = gtk_vscrollbar_set_property;
|
||||
gobject_class->get_property = gtk_vscrollbar_get_property;
|
||||
|
||||
widget_class->realize = gtk_vscrollbar_realize;
|
||||
widget_class->size_request = gtk_vscrollbar_size_request;
|
||||
widget_class->size_allocate = gtk_vscrollbar_size_allocate;
|
||||
|
||||
range_class->draw_step_forw = gtk_vscrollbar_draw_step_forw;
|
||||
range_class->draw_step_back = gtk_vscrollbar_draw_step_back;
|
||||
range_class->slider_update = gtk_vscrollbar_slider_update;
|
||||
range_class->trough_click = _gtk_range_default_vtrough_click;
|
||||
range_class->motion = _gtk_range_default_vmotion;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkVScrollbar *vscrollbar;
|
||||
|
||||
vscrollbar = GTK_VSCROLLBAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkVScrollbar *vscrollbar;
|
||||
|
||||
vscrollbar = GTK_VSCROLLBAR (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
GTK_RANGE_CLASS (class)->stepper_detail = "vscrollbar";
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_init (GtkVScrollbar *vscrollbar)
|
||||
{
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (vscrollbar);
|
||||
|
||||
range->orientation = GTK_ORIENTATION_VERTICAL;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@ -160,282 +85,3 @@ gtk_vscrollbar_new (GtkAdjustment *adjustment)
|
||||
|
||||
return vscrollbar;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkRange *range;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
gint slider_width;
|
||||
gint stepper_size;
|
||||
gint trough_border;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, &trough_border,
|
||||
&stepper_size, NULL);
|
||||
|
||||
attributes.x = widget->allocation.x + (widget->allocation.width - widget->requisition.width) / 2;
|
||||
attributes.y = widget->allocation.y;
|
||||
attributes.width = widget->requisition.width;
|
||||
attributes.height = widget->allocation.height;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||
attributes.event_mask = gtk_widget_get_events (widget);
|
||||
attributes.event_mask |= (GDK_EXPOSURE_MASK |
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK |
|
||||
GDK_LEAVE_NOTIFY_MASK);
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
|
||||
|
||||
range->trough = widget->window;
|
||||
gdk_window_ref (range->trough);
|
||||
|
||||
attributes.x = trough_border;
|
||||
attributes.y = trough_border;
|
||||
attributes.width = stepper_size;
|
||||
attributes.height = stepper_size;
|
||||
|
||||
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
attributes.y = (widget->allocation.height -
|
||||
trough_border -
|
||||
stepper_size);
|
||||
|
||||
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
attributes.x = trough_border;
|
||||
attributes.y = 0;
|
||||
attributes.width = slider_width;
|
||||
attributes.height = RANGE_CLASS (widget)->min_slider_size;
|
||||
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK);
|
||||
|
||||
range->slider = gdk_window_new (range->trough, &attributes, attributes_mask);
|
||||
|
||||
gtk_vscrollbar_calc_slider_size (GTK_VSCROLLBAR (widget));
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
gdk_window_set_user_data (range->trough, widget);
|
||||
gdk_window_set_user_data (range->slider, widget);
|
||||
gdk_window_set_user_data (range->step_forw, widget);
|
||||
gdk_window_set_user_data (range->step_back, widget);
|
||||
|
||||
gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL);
|
||||
gtk_style_set_background (widget->style, range->step_forw, GTK_STATE_ACTIVE);
|
||||
gtk_style_set_background (widget->style, range->step_back, GTK_STATE_ACTIVE);
|
||||
|
||||
gdk_window_show (range->slider);
|
||||
gdk_window_show (range->step_forw);
|
||||
gdk_window_show (range->step_back);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
gint slider_width;
|
||||
gint trough_border;
|
||||
gint stepper_size;
|
||||
gint stepper_spacing;
|
||||
|
||||
GtkRange *range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, &slider_width, &trough_border,
|
||||
&stepper_size, &stepper_spacing);
|
||||
|
||||
requisition->width = (slider_width +
|
||||
trough_border * 2);
|
||||
requisition->height = (RANGE_CLASS (widget)->min_slider_size +
|
||||
stepper_size +
|
||||
stepper_spacing +
|
||||
trough_border) * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkRange *range;
|
||||
gint trough_border;
|
||||
gint stepper_size;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
|
||||
g_return_if_fail (allocation != NULL);
|
||||
|
||||
widget->allocation = *allocation;
|
||||
if (GTK_WIDGET_REALIZED (widget))
|
||||
{
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
_gtk_range_get_props (range, NULL, &trough_border,
|
||||
&stepper_size, NULL);
|
||||
|
||||
gdk_window_move_resize (range->trough,
|
||||
allocation->x + (allocation->width - widget->requisition.width) / 2,
|
||||
allocation->y,
|
||||
widget->requisition.width, allocation->height);
|
||||
gdk_window_move_resize (range->step_back,
|
||||
trough_border,
|
||||
trough_border,
|
||||
widget->requisition.width - trough_border * 2,
|
||||
stepper_size);
|
||||
gdk_window_move_resize (range->step_forw,
|
||||
trough_border,
|
||||
allocation->height - trough_border -
|
||||
stepper_size,
|
||||
widget->requisition.width - trough_border * 2,
|
||||
stepper_size);
|
||||
|
||||
_gtk_range_slider_update (GTK_RANGE (widget));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_draw_step_forw (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (range));
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (range))
|
||||
{
|
||||
if (range->in_child == RANGE_CLASS (range)->step_forw)
|
||||
{
|
||||
if (range->click_child == RANGE_CLASS (range)->step_forw)
|
||||
state_type = GTK_STATE_ACTIVE;
|
||||
else
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
}
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (range->click_child == RANGE_CLASS (range)->step_forw)
|
||||
shadow_type = GTK_SHADOW_IN;
|
||||
else
|
||||
shadow_type = GTK_SHADOW_OUT;
|
||||
|
||||
gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_forw,
|
||||
state_type, shadow_type,
|
||||
NULL, GTK_WIDGET (range), "vscrollbar",
|
||||
GTK_ARROW_DOWN,
|
||||
TRUE, 0, 0, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_draw_step_back (GtkRange *range)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (range));
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (range))
|
||||
{
|
||||
if (range->in_child == RANGE_CLASS (range)->step_back)
|
||||
{
|
||||
if (range->click_child == RANGE_CLASS (range)->step_back)
|
||||
state_type = GTK_STATE_ACTIVE;
|
||||
else
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
}
|
||||
else
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (range->click_child == RANGE_CLASS (range)->step_back)
|
||||
shadow_type = GTK_SHADOW_IN;
|
||||
else
|
||||
shadow_type = GTK_SHADOW_OUT;
|
||||
|
||||
gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_back,
|
||||
state_type, shadow_type,
|
||||
NULL, GTK_WIDGET (range), "vscrollbar",
|
||||
GTK_ARROW_UP,
|
||||
TRUE, 0, 0, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_slider_update (GtkRange *range)
|
||||
{
|
||||
g_return_if_fail (range != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (range));
|
||||
|
||||
gtk_vscrollbar_calc_slider_size (GTK_VSCROLLBAR (range));
|
||||
_gtk_range_default_vslider_update (range);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_vscrollbar_calc_slider_size (GtkVScrollbar *vscrollbar)
|
||||
{
|
||||
GtkRange *range;
|
||||
gint step_back_y;
|
||||
gint step_back_height;
|
||||
gint step_forw_y;
|
||||
gint stepper_spacing;
|
||||
gint slider_width;
|
||||
gint slider_height;
|
||||
gint top, bottom;
|
||||
gint height;
|
||||
|
||||
g_return_if_fail (vscrollbar != NULL);
|
||||
g_return_if_fail (GTK_IS_VSCROLLBAR (vscrollbar));
|
||||
|
||||
if (GTK_WIDGET_REALIZED (vscrollbar))
|
||||
{
|
||||
range = GTK_RANGE (vscrollbar);
|
||||
|
||||
_gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
|
||||
|
||||
gdk_window_get_size (range->step_back, NULL, &step_back_height);
|
||||
gdk_window_get_position (range->step_back, NULL, &step_back_y);
|
||||
gdk_window_get_position (range->step_forw, NULL, &step_forw_y);
|
||||
|
||||
top = (step_back_y +
|
||||
step_back_height +
|
||||
stepper_spacing);
|
||||
bottom = step_forw_y - stepper_spacing;
|
||||
height = bottom - top;
|
||||
|
||||
if ((range->adjustment->page_size > 0) &&
|
||||
(range->adjustment->lower != range->adjustment->upper))
|
||||
{
|
||||
if (range->adjustment->page_size >
|
||||
(range->adjustment->upper - range->adjustment->lower))
|
||||
range->adjustment->page_size = range->adjustment->upper - range->adjustment->lower;
|
||||
|
||||
height = (height * range->adjustment->page_size /
|
||||
(range->adjustment->upper - range->adjustment->lower));
|
||||
|
||||
if (height < RANGE_CLASS (vscrollbar)->min_slider_size)
|
||||
height = RANGE_CLASS (vscrollbar)->min_slider_size;
|
||||
}
|
||||
|
||||
gdk_window_get_size (range->slider, &slider_width, &slider_height);
|
||||
|
||||
if (slider_height != height)
|
||||
{
|
||||
gdk_window_resize (range->slider, slider_width, height);
|
||||
gdk_window_invalidate_rect (range->slider, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6680,7 +6680,8 @@ static gchar*
|
||||
reformat_value (GtkScale *scale,
|
||||
gdouble value)
|
||||
{
|
||||
return g_strdup_printf ("-->%g<--", value);
|
||||
return g_strdup_printf ("-->%0.*g<--",
|
||||
gtk_scale_get_digits (scale), value);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user