On Mon, Oct 03, 2005 at 09:52:47PM -0500, Paul Archer wrote:
> My goal in learning/using Prima is to write an image viewing/cataloging
> application like ACDSee (www.acdsystems.com) or Thumbsplus
> (www.cerious.com). That might be biting off more than I can chew, but I'm
> willing to try.
That sounds interesting! I hope you are going to release it as an open
source application? :-)
> Anyway, can anyone (Dmitri?) give me some pointers on what widget(s) to use
> to implement a file list/icon view like these programs have? (See
> www.acdsystems.com/images/products/acdsee/features/acdsee-tour-1-lg.jpg for
> an example of what I mean.)
The easiest would probably be to slightly override ListViewer (it is
meant to be overridden). Below is a small, but complete script which
uses notifications to that effect, altough you would probably want to do
a proper subclassing.
use strict;
use warnings;
use lib qw(/home/tobez/src/Prima);
use Prima qw( Lists Application );
my $w = Prima::MainWindow->create(
name => "IVL",
origin => [ 100, 100],
size => [ 600, 400],
text => "Funny list",
);
$w-> insert(ListViewer =>
origin => [10,10],
size => [580,380],
hScroll => 1,
vScroll => 1,
multiSelect => 0,
extendedSelect => 1,
name => 'ILB',
multiColumn => 1,
itemWidth => 100,
itemHeight => 60,
onDrawItem => \&draw_item,
onMeasureItem => sub { ${$_[2]} = 100 },
items => [1..40],
gridColor => cl::LightGray,
hiliteBackColor=> cl::LightCyan,
);
sub draw_item
{
my ($me, $p, $i, $x1, $y1, $x2, $y2, $sel, $foc) = @_;
my $fore = cl::Black;
my $back = ($sel || $foc) ? $me->colorIndex(ci::Hilite) : $me->backColor;
# of course, you are supposed to paint your thumbnail images here
$p->color($back);
$p->bar($x1, $y1, $x2, $y2);
$p->color($fore);
$p->rectangle($x1+1, $y1+1, $x2-1, $y2-1);
my $h = $p->font->height;
my $s = "Image $i";
my $w = $p->get_text_width($s);
$p->text_out($s, ($x2+$x1-$w)/2, ($y2+$y1-$h)/2);
}
run Prima;
Hope this helps,
\Anton.
-- An undefined problem has an infinite number of solutions. -- Robert A. HumphreyReceived on Tue 04 Oct 2005 - 10:01:05 CEST
This archive was generated by hypermail 2.2.0 : Sat 19 Mar 2011 - 18:35:06 CET