Re: modify style in gtkperl
- From: Mark Stratman <mark sporkstorms org>
- To: Max Moser <mmo remote-exploit org>
- Cc: gtk-perl-list gnome org
- Subject: Re: modify style in gtkperl
- Date: 24 Jan 2002 13:58:23 -0600
H. Pennington wrote a nice little primer, available at
http://www106.pair.com/rhp/gtk-colors.html.
It is written for C, though... so here's the basics of how to do it in
Perl. Be sure to give it a read anyhow, since it touches on some (non
c-specific) important points.
# create a new Gtk::Gdk::Color instance.
$color = Gtk::Gdk::Color->parse_color("red");
# Aside note:
# You can optionally set the r, g, b values to whatever you want.
# These are 16-bit values.
# I've never done it this way, and am not sure how you'd get a color
# object in the first place. Maybe create your own little constructor?:
# $color = bless { 'blue' => 0, 'green' => 0, 'red' => 0, pixel => 0},
# 'Gtk::Gdk::Color';
#$color->blue($blue_val);
#$color->red($red_val);
#$color->green($green_val);
# Get the widget's colormap
$colormap = $widget->get_colormap();
# Allocate your $color in the colormap
$colormap->color_alloc($color);
# Create a new RcStyle object
$style = Gtk::RcStyle->new();
# Note that modify_color() wants a Gtk::RcFlags object as it's first
# argument, but I'm not sure how to do this. An array ref of text
# flags seems to work. RcFlags (in C) is just an enum. See
# http://developer.gnome.org/doc/API/gtk/gtk-resource-files.html
# for more info about styles, and their flags.
# You may need different flags here, depending on what you're doing.
$flags = [ 'fg', 'bg', 'text' ];
# the StateType can be any, we'll just use the current.
$state = $widget->state();
$style->modify_color($flags, $state, $color);
$widget->modify_style($style);
On Wed, 2002-01-23 at 15:58, Max Moser wrote:
Hi there
I just want to know how to change a style of a widget. in the gtk references i saw modify style function.
I want to change the color of the progressbar depending on his value.
Any hints / samples how to do that in gtkperl?
Greetings
Max Moser
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
--
@j=qw{-.2-2.- -2.4- -3.2-. -2.-.-2};
print map{s e(.)(\d)e$1x$2eeg;y.-.1.;y-.-0-;
chr unpack"N",pack"B32",substr'0'x32 .$_,-32} j;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]