PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/libs/perl/Choicetool/Widgets/Menu.pm

#
Perl | 173 lines | 106 code | 44 blank | 23 comment | 5 complexity | 711af0be96352fc634617e8fc01d119a MD5 | raw file
  1# -*- perl -*-
  2
  3#
  4# Menu.pm
  5#
  6# Copyright (C) 2008, 2009 Francesco Salvestrini
  7#
  8# This program is free software; you can redistribute it and/or modify
  9# it under the terms of the GNU General Public License as published by
 10# the Free Software Foundation; either version 2 of the License, or
 11# (at your option) any later version.
 12#
 13# This program is distributed in the hope that it will be useful,
 14# but WITHOUT ANY WARRANTY; without even the implied warranty of
 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16# GNU General Public License for more details.
 17#
 18# You should have received a copy of the GNU General Public License along
 19# with this program; if not, write to the Free Software Foundation, Inc.,
 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 21#
 22
 23package Choicetool::Widgets::Menu;
 24
 25use 5.8.0;
 26
 27use warnings;
 28use strict;
 29use diagnostics;
 30
 31use Choicetool::Base::Debug;
 32use Choicetool::Base::Trace;
 33use Choicetool::Widgets::Widget;
 34
 35use vars qw(@ISA);
 36@ISA = qw(Choicetool::Widgets::Widget);
 37
 38sub new ($$)
 39{
 40    my $class = shift;
 41    my $id    = shift;
 42
 43    assert(defined($class));
 44
 45    my $self = $class->SUPER::new($id);
 46
 47    return bless($self, $class);
 48}
 49
 50sub type {
 51    my $self  = shift;
 52    my $value = shift;
 53
 54    assert(defined($self));
 55
 56    if (defined($value)) {
 57        $self->{TYPE} = $value;
 58    }
 59
 60    return $self->{TYPE};
 61}
 62
 63sub label {
 64    my $self  = shift;
 65    my $value = shift;
 66
 67    assert(defined($self));
 68
 69    if (defined($value)) {
 70        $self->{LABEL} = $value;
 71    }
 72
 73    return $self->{LABEL};
 74}
 75
 76sub default {
 77    my $self  = shift;
 78    my $value = shift;
 79
 80    assert(defined($self));
 81
 82    if (defined($value)) {
 83        $self->{DEFAULT} = $value;
 84    }
 85
 86    return $self->{DEFAULT};
 87}
 88
 89sub range {
 90    my $self  = shift;
 91    my $value = shift;
 92
 93    assert(defined($self));
 94
 95    if (defined($value)) {
 96        $self->{RANGE} = $value;
 97    }
 98
 99    return $self->{RANGE};
100}
101
102sub help {
103    my $self  = shift;
104    my $value = shift;
105
106    assert(defined($self));
107
108    if (defined($value)) {
109        $self->{HELP} = $value;
110    }
111
112    return $self->{HELP};
113}
114
115sub m4ify_hierarchical_indent ($)
116{
117    my $self = shift;
118
119    assert(defined($self));
120
121    return "  ";
122}
123
124#
125# M4 related methods
126#
127
128sub m4ify_linear_body ($$)
129{
130    my $self   = shift;
131    my $prefix = shift;
132
133    assert(defined($self));
134    assert(defined($prefix));
135    assert(defined($self->id()));
136
137    return
138        $prefix .
139        "CT_UI_MENU_DATA([" .
140        $self->id() .
141        "])\n";
142}
143
144sub m4ify_hierarchical_header ($$)
145{
146    my $self   = shift;
147    my $prefix = shift;
148
149    assert(defined($self));
150    assert(defined($prefix));
151    assert(defined($self->id()));
152    assert(defined($self->label()));
153
154    return
155        $prefix .
156        "CT_UI_MENU_WIDGET([". $self->id() .
157        "],[" .
158        $self->label() .
159        "],[\n";
160}
161
162sub m4ify_hierarchical_footer ($$)
163{
164    my $self   = shift;
165    my $prefix = shift;
166
167    assert(defined($self));
168    assert(defined($prefix));
169
170    return $prefix . "])\n";
171}
172
1731;