1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#!/usr/bin/perl -w
# vim: set ft=perl expandtab shiftwidth=2 softtabstop=2 :
use strict;
use Gtk2::TestHelper tests => 113;
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkStyle.t,v 1.9 2006/08/07 18:36:06 kaffeetisch Exp $
my $window = Gtk2::Window -> new();
$window -> realize();
my $style = Gtk2::Style -> new();
isa_ok($style, "Gtk2::Style");
ok(!$style -> attached());
$style = $style -> attach($window -> window());
isa_ok($style, "Gtk2::Style");
ok($style -> attached());
foreach my $state (qw(normal active prelight selected insensitive)) {
foreach ($style -> fg($state),
$style -> bg($state),
$style -> light($state),
$style -> dark($state),
$style -> mid($state),
$style -> text($state),
$style -> base($state),
$style -> text_aa($state)) {
isa_ok($_, "Gtk2::Gdk::Color");
}
foreach ($style -> fg_gc($state),
$style -> bg_gc($state),
$style -> light_gc($state),
$style -> dark_gc($state),
$style -> mid_gc($state),
$style -> text_gc($state),
$style -> base_gc($state),
$style -> text_aa_gc($state)) {
isa_ok($_, "Gtk2::Gdk::GC");
}
# initially, the bg_pixmap is undef.
ok (! $style->bg_pixmap ($state), 'initially, there is no pixmap');
# set one.
my $pixmap = Gtk2::Gdk::Pixmap->new ($window->window, 16, 16, -1);
isa_ok ($pixmap, 'Gtk2::Gdk::Pixmap');
$style->bg_pixmap ($state, $pixmap);
is ($style -> bg_pixmap($state), $pixmap, 'pixmap is now set');
}
isa_ok($style -> black(), "Gtk2::Gdk::Color");
isa_ok($style -> white(), "Gtk2::Gdk::Color");
isa_ok($style -> black_gc(), "Gtk2::Gdk::GC");
isa_ok($style -> white_gc(), "Gtk2::Gdk::GC");
isa_ok($style -> font_desc(), "Gtk2::Pango::FontDescription");
$style -> set_background($window -> window(), "normal");
$style -> apply_default_background($window -> window(), 1, "active", Gtk2::Gdk::Rectangle -> new(10, 10, 5, 5), 10, 10, 5, 5);
isa_ok($style -> lookup_icon_set("gtk-quit"), "Gtk2::IconSet");
my $source = Gtk2::IconSource -> new();
my $button = Gtk2::Button -> new("Bla");
my $check = Gtk2::CheckButton -> new("Bla");
my $view = Gtk2::TreeView -> new();
my $pixbuf = Gtk2::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10);
$source -> set_pixbuf($pixbuf);
isa_ok($style -> render_icon($source, "ltr", "normal", "button", $button, "detail"), "Gtk2::Gdk::Pixbuf");
my $rectangle = Gtk2::Gdk::Rectangle -> new(10, 10, 10, 10);
$style -> paint_arrow($window -> window(), "normal", "none", $rectangle, $button, "detail", "up", 1, 10, 10, 10, 10);
$style -> paint_box($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_box_gap($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10, "right", 5, 5);
$style -> paint_check($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_diamond($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_extension($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10, "left");
$style -> paint_flat_box($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_focus($window -> window(), "normal", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_handle($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10, "horizontal");
$style -> paint_hline($window -> window(), "normal", $rectangle, $button, "detail", 10, 10, 10);
$style -> paint_option($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_polygon($window -> window(), "normal", "none", $rectangle, $button, "detail", 1, 2, 2, 4, 4, 6, 6);
$style -> paint_shadow($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10);
$style -> paint_shadow_gap($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10, "right", 5, 5);
$style -> paint_slider($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, 10, 10, "horizontal");
# $style -> paint_tab($window -> window(), "normal", "none", $rectangle, $check, "detail", 10, 10, 10, 10);
$style -> paint_vline($window -> window(), "normal", $rectangle, $button, "detail", 10, 10, 10);
$style -> paint_expander($window -> window(), "normal", $rectangle, $view, "detail", 10, 10, "collapsed");
# $style -> paint_layout($window -> window(), "normal", "none", $rectangle, $button, "detail", 10, 10, Gtk2::Pango::Layout -> new(Gtk2::Pango::Context -> new()));
# versions of gtk+ prior to 2.2.0 handled only 'south-east', which isn't so
# bad, except that they actually called g_assert_not_reached() in the branch
# of code that you reach by passing other values. so, eh, never pass anything
# but south-east to old gtk+.
$style -> paint_resize_grip($window -> window(), "normal", $rectangle, $button, "detail", "north-west", 10, 10, 10, 10)
if Gtk2->CHECK_VERSION (2, 2, 0);
$style -> paint_resize_grip($window -> window(), "normal", $rectangle, $button, "detail", "south-east", 10, 10, 10, 10);
$style -> detach();
isa_ok($style, "Gtk2::Style");
ok(!$style -> attached());
$style = Gtk2::Style -> new() -> attach($window -> window());
isa_ok($style, "Gtk2::Style");
ok($style -> attached());
$style -> detach();
isa_ok($style, "Gtk2::Style");
ok(!$style -> attached());
$style = Gtk2::Style -> new();
$style -> attach($window -> window());
$style -> attach($window -> window());
SKIP: {
skip("draw_insertion_cursor is new in 2.4", 0)
unless (Gtk2 -> CHECK_VERSION(2, 4, 5));
$window -> add($button);
Gtk2 -> draw_insertion_cursor($button, $window -> window(), $rectangle, $rectangle, 1, "ltr", 1);
}
SKIP: {
skip("lookup_color is new in 2.10", 1)
unless (Gtk2->CHECK_VERSION(2, 10, 0));
my $color = $style->lookup_color ('foreground');
# at this point we can't verify anything about it...
ok (1);
}
__END__
Copyright (C) 2003-2006 by the gtk2-perl team (see the file AUTHORS for the
full list). See LICENSE for more information.
|