1# ---------------------------------------------------------------------- 2# Curses::UI::Radiobuttonbox 3# 4# (c) 2001-2002 by Maurice Makaay. All rights reserved. 5# This file is part of Curses::UI. Curses::UI is free software. 6# You can redistribute it and/or modify it under the same terms 7# as perl itself. 8# 9# Currently maintained by Marcus Thiesen 10# e-mail: marcus@cpan.thiesenweb.de 11# ---------------------------------------------------------------------- 12 13# TODO: fix dox 14 15package Curses::UI::Radiobuttonbox; 16 17use strict; 18use Curses; 19use Curses::UI::Common; 20use Curses::UI::Listbox; 21use Curses::UI::Widget; 22 23use vars qw( 24 $VERSION 25 @ISA 26); 27 28$VERSION = '1.10'; 29 30@ISA = qw( 31 Curses::UI::Listbox 32); 33 34sub new () 35{ 36 my $class = shift; 37 38 my %userargs = @_; 39 keys_to_lowercase(\%userargs); 40 41 my %args = ( 42 %userargs, 43 -radio => 1, # Force radiobuttons 44 -multi => 0, # Force no multiselect 45 ); 46 47 # Compute the needed with if -width is undefined. 48 # The extra 4 positions are for the radiobutton drawing. 49 $args{-width} = 4 + width_by_windowscrwidth(maxlabelwidth(%args), %args) 50 unless defined $args{-width}; 51 52 # Create the entry. 53 my $this = $class->SUPER::new( %args); 54 55 return $this; 56} 57 581; 59 60 61=pod 62 63=head1 NAME 64 65Curses::UI::Radiobuttonbox - Create and manipulate radiobuttonbox widgets 66 67=head1 CLASS HIERARCHY 68 69 Curses::UI::Widget 70 Curses::UI::Searchable 71 | 72 +----Curses::UI::Listbox 73 | 74 +----Curses::UI::Radiobuttonbox 75 76 77 78=head1 SYNOPSIS 79 80 use Curses::UI; 81 my $cui = new Curses::UI; 82 my $win = $cui->add('window_id', 'Window'); 83 84 my $radiobuttonbox = $win->add( 85 'myradiobuttonbox', 'Radiobuttonbox', 86 -values => [1, 2, 3], 87 -labels => { 1 => 'One', 88 2 => 'Two', 89 3 => 'Three' }, 90 ); 91 92 $radiobuttonbox->focus(); 93 my $selected = $radiobuttonbox->get(); 94 95 96=head1 DESCRIPTION 97 98Curses::UI::Radiobuttonbox is a widget that can be used 99to create a radiobutton listbox. Only one value can be 100selected at a time. This kind of listbox looks somewhat 101like this: 102 103 +----------+ 104 |< > One | 105 |<o> Two | 106 |< > Three | 107 +----------+ 108 109A Radiobuttonbox is derived from Curses::UI::Listbox. The 110only special thing about this class is that the 111B<-radio> option is forced to a true value. So for the 112usage of Curses::UI::Radiobuttonbox see 113L<Curses::UI::Listbox|Curses::UI::Listbox>). 114 115 116 117 118=head1 SEE ALSO 119 120L<Curses::UI|Curses::UI>, 121L<Curses::UI::Listbox|Curses::UI::Listbox>, 122 123 124 125 126=head1 AUTHOR 127 128Copyright (c) 2001-2002 Maurice Makaay. All rights reserved. 129 130Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de) 131 132 133This package is free software and is provided "as is" without express 134or implied warranty. It may be used, redistributed and/or modified 135under the same terms as perl itself. 136 137