merge with master, with minor conflict fixes
[ardour.git] / gtk2_ardour / gtk-custom-ruler.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 /* modified by andreas meyer <hexx3000@gmx.de> */
28
29 #ifndef __GTK_CUSTOM_RULER_H__
30 #define __GTK_CUSTOM_RULER_H__
31
32 #include <gdk/gdk.h>
33 #include <gtk/gtkwidget.h>
34
35
36 G_BEGIN_DECLS
37
38 #define GTK_TYPE_CUSTOM_RULER            (gtk_custom_ruler_get_type ())
39 #define GTK_CUSTOM_RULER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CUSTOM_RULER, GtkCustomRuler))
40 #define GTK_CUSTOM_RULER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CUSTOM_RULER, GtkCustomRulerClass))
41 #define GTK_IS_CUSTOM_RULER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CUSTOM_RULER))
42 #define GTK_IS_CUSTOM_RULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CUSTOM_RULER))
43 #define GTK_CUSTOM_RULER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CUSTOM_RULER, GtkCustomRulerClass))
44
45 typedef struct _GtkCustomRuler          GtkCustomRuler;
46 typedef struct _GtkCustomRulerClass     GtkCustomRulerClass;
47 typedef struct _GtkCustomMetric         GtkCustomMetric;
48 typedef struct _GtkCustomRulerMark      GtkCustomRulerMark;
49
50 struct _GtkCustomRuler {
51   GtkWidget widget;
52
53   GdkPixmap *backing_store;
54   GdkGC *non_gr_exp_gc;
55   GtkCustomMetric *metric;
56   gint xsrc, ysrc;
57   gint slider_size;
58   gboolean show_position;
59
60   /* The upper limit of the ruler (in points) */
61   gdouble lower;
62   /* The lower limit of the ruler */
63   gdouble upper;
64   /* The position of the mark on the ruler */
65   gdouble position;
66   /* The maximum size of the ruler */
67   gdouble max_size;
68 };
69
70 struct _GtkCustomRulerClass {
71   GtkWidgetClass parent_class;
72
73   void (* draw_ticks) (GtkCustomRuler *ruler);
74   void (* draw_pos)   (GtkCustomRuler *ruler);
75 };
76
77 typedef enum {
78    GtkCustomRulerMarkMajor,
79    GtkCustomRulerMarkMinor,
80    GtkCustomRulerMarkMicro
81 } GtkCustomRulerMarkStyle;
82
83 struct _GtkCustomRulerMark {
84   gchar                  *label;
85   gdouble                 position;
86   GtkCustomRulerMarkStyle style;
87 };
88
89 struct _GtkCustomMetric {
90   gfloat units_per_pixel;
91   gint (* get_marks) (GtkCustomRulerMark **marks, gdouble lower, gdouble upper, gint maxchars);
92 };
93
94 GType   gtk_custom_ruler_get_type            (void);
95 void    gtk_custom_ruler_set_metric          (GtkCustomRuler *ruler, GtkCustomMetric *metric);
96 void    gtk_custom_ruler_set_range           (GtkCustomRuler *ruler,
97                                               gdouble lower,
98                                               gdouble upper,
99                                               gdouble position,
100                                               gdouble  max_size);
101 void    gtk_custom_ruler_draw_ticks          (GtkCustomRuler *ruler);
102 void    gtk_custom_ruler_draw_pos            (GtkCustomRuler *ruler);
103 void    gtk_custom_ruler_set_show_position   (GtkCustomRuler *rule, gboolean yn);
104
105 G_END_DECLS
106
107 #endif /* __GTK_CUSTOM_RULER_H__ */