summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2009-01-20 05:10:27 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2009-01-20 05:10:27 +0000
commit26490a2dd7224eb021bbbc7c2b6051a68ee5c247 (patch)
treeac93a899ee2bc1935fdbd05cc9c784572f6dc605 /tests
parentb6b52376631e52542237b7f229bb67ab57332746 (diff)
downloadgdk-pixbuf-26490a2dd7224eb021bbbc7c2b6051a68ee5c247.tar.gz
Bug 565656 – Add marks to scales
Bug 565656 – Add marks to scales * gtk/gtkrange.[hc]: Add internal api to define 'stop values' that have a little resistance when dragging the slider over it. * gtk/gtk.symbols: * gtk/gtkscale.[hc] (gtk_scale_add_mark): New function to add a 'mark' to a scale, which will draws a tick, plus optionally some text, and makes the value a stop value. (gtk_scale_clear_values): Removes all marks. * tests/testscale.c: Test for marks on scales * tests/Makefile.am: Integrate it svn path=/trunk/; revision=22149
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/testscale.c149
2 files changed, 152 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 370b997ef..426dea30e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,6 +60,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testrecentchooser \
testrecentchoosermenu \
testrichtext \
+ testscale \
testselection \
$(testsocket_programs) \
testspinbutton \
@@ -137,6 +138,7 @@ testrecentchooser_DEPENDENCIES = $(TEST_DEPS)
testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS)
testrgb_DEPENDENCIES = $(TEST_DEPS)
testrichtext_DEPENDENCIES = $(TEST_DEPS)
+testscale_DEPENDENCIES = $(TEST_DEPS)
testselection_DEPENDENCIES = $(TEST_DEPS)
testsocket_DEPENDENCIES = $(DEPS)
testsocket_child_DEPENDENCIES = $(DEPS)
@@ -194,6 +196,7 @@ testrecentchooser_LDADD = $(LDADDS)
testrecentchoosermenu_LDADD = $(LDADDS)
testrgb_LDADD = $(LDADDS)
testrichtext_LDADD = $(LDADDS)
+testscale_LDADD = $(LDADDS)
testselection_LDADD = $(LDADDS)
testsocket_LDADD = $(LDADDS)
testsocket_child_LDADD = $(LDADDS)
diff --git a/tests/testscale.c b/tests/testscale.c
new file mode 100755
index 000000000..35b287e2d
--- /dev/null
+++ b/tests/testscale.c
@@ -0,0 +1,149 @@
+/* testscale.c - scale mark demo
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Author: Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gtk/gtk.h>
+
+int main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *box;
+ GtkWidget *box2;
+ GtkWidget *frame;
+ GtkWidget *scale;
+ GIcon *icon;
+ gdouble marks[3] = { 0.0, 50.0, 100.0 };
+ const gchar *labels[3] = {
+ "<small>Left</small>",
+ "<small>Middle</small>",
+ "<small>Right</small>"
+ };
+
+ gdouble bath_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
+ const gchar *bath_labels[4] = {
+ "<span color='blue' size='small'>Cold</span>",
+ "<span size='small'>Baby bath</span>",
+ "<span size='small'>Hot tub</span>",
+ "<span color='Red' size='small'>Hot</span>"
+ };
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), "Ranges with marks");
+ box = gtk_vbox_new (FALSE, 5);
+
+ frame = gtk_frame_new ("No marks");
+ scale = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Simple marks");
+ scale = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, NULL);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Labeled marks");
+ scale = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, labels[1]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, labels[2]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Some labels");
+ scale = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_BOTTOM, labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_BOTTOM, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_BOTTOM, labels[2]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Above and below");
+ scale = gtk_hscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[0], GTK_POS_TOP, bath_labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[1], GTK_POS_BOTTOM, bath_labels[1]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[2], GTK_POS_BOTTOM, bath_labels[2]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[3], GTK_POS_TOP, bath_labels[3]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
+
+ box2 = gtk_hbox_new (FALSE, 5);
+ gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0);
+
+ frame = gtk_frame_new ("No marks");
+ scale = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Simple marks");
+ scale = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, NULL);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Labeled marks");
+ scale = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, labels[1]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, labels[2]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Some labels");
+ scale = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[0], GTK_POS_LEFT, labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[1], GTK_POS_LEFT, NULL);
+ gtk_scale_add_mark (GTK_SCALE (scale), marks[2], GTK_POS_LEFT, labels[2]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+
+ frame = gtk_frame_new ("Right and left");
+ scale = gtk_vscale_new_with_range (0, 100, 1);
+ gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[0], GTK_POS_RIGHT, bath_labels[0]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[1], GTK_POS_LEFT, bath_labels[1]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[2], GTK_POS_LEFT, bath_labels[2]);
+ gtk_scale_add_mark (GTK_SCALE (scale), bath_marks[3], GTK_POS_RIGHT, bath_labels[3]);
+ gtk_container_add (GTK_CONTAINER (frame), scale);
+ gtk_box_pack_start (GTK_BOX (box2), frame, FALSE, FALSE, 0);
+
+ gtk_container_add (GTK_CONTAINER (window), box);
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}
+
+