| 1 | # ---------------------------------------------------------------------- | ||
| 2 | # Curses::UI::Dialog::Error | ||
| 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 | package Curses::UI::Dialog::Error; | ||
| 14 | |||
| 15 | use strict; | ||
| 16 | use Curses; | ||
| 17 | use Curses::UI::Common; | ||
| 18 | use Curses::UI::Dialog::Basic; | ||
| 19 | |||
| 20 | use vars qw( | ||
| 21 | $VERSION | ||
| 22 | @ISA | ||
| 23 | ); | ||
| 24 | |||
| 25 | @ISA = qw( | ||
| 26 | Curses::UI::Dialog::Basic | ||
| 27 | Curses::UI::Common | ||
| 28 | ); | ||
| 29 | |||
| 30 | $VERSION = '1.10'; | ||
| 31 | |||
| 32 | sub new () | ||
| 33 | { | ||
| 34 | my $class = shift; | ||
| 35 | |||
| 36 | my %userargs = @_; | ||
| 37 | keys_to_lowercase(\%userargs); | ||
| 38 | |||
| 39 | my %args = ( | ||
| 40 | -message => '', # The message to show | ||
| 41 | -fg => -1, | ||
| 42 | -bg => -1, | ||
| 43 | |||
| 44 | %userargs, | ||
| 45 | |||
| 46 | -ipadleft => 10, # Space for sign | ||
| 47 | -centered => 1, | ||
| 48 | ); | ||
| 49 | |||
| 50 | my $this = $class->SUPER::new(%args); | ||
| 51 | |||
| 52 | unless (defined $this->{-title}) { | ||
| 53 | my $l = $this->root->lang; | ||
| 54 | $this->title($l->get('error_title')); | ||
| 55 | } | ||
| 56 | |||
| 57 | bless $this, $class; | ||
| 58 | } | ||
| 59 | |||
| 60 | sub draw(;$) | ||
| 61 | { | ||
| 62 | my $this = shift; | ||
| 63 | my $no_doupdate = shift || 0; | ||
| 64 | |||
| 65 | # Draw widget | ||
| 66 | $this->SUPER::draw(1) or return $this; | ||
| 67 | |||
| 68 | # Draw sign | ||
| 69 | $this->{-borderscr}->addstr(2, 1, " _"); | ||
| 70 | $this->{-borderscr}->addstr(3, 1, " / \\"); | ||
| 71 | $this->{-borderscr}->addstr(4, 1, " / ! \\"); | ||
| 72 | $this->{-borderscr}->addstr(5, 1, " /_____\\"); | ||
| 73 | $this->{-borderscr}->noutrefresh(); | ||
| 74 | |||
| 75 | $this->{-canvasscr}->noutrefresh(); | ||
| 76 | doupdate() unless $no_doupdate; | ||
| 77 | |||
| 78 | return $this; | ||
| 79 | } | ||
| 80 | |||
| 81 | 1; | ||
| 82 | |||
| 83 | |||
| 84 | =pod | ||
| 85 | |||
| 86 | =head1 NAME | ||
| 87 | |||
| 88 | Curses::UI::Dialog::Error - Create and manipulate error dialogs | ||
| 89 | |||
| 90 | =head1 CLASS HIERARCHY | ||
| 91 | |||
| 92 | Curses::UI::Widget | ||
| 93 | | | ||
| 94 | +----Curses::UI::Container | ||
| 95 | | | ||
| 96 | +----Curses::UI::Window | ||
| 97 | | | ||
| 98 | +----Curses::UI::Dialog::Basic | ||
| 99 | | | ||
| 100 | +----Curses::UI::Dialog::Error | ||
| 101 | |||
| 102 | |||
| 103 | =head1 SYNOPSIS | ||
| 104 | |||
| 105 | use Curses::UI; | ||
| 106 | my $cui = new Curses::UI; | ||
| 107 | my $win = $cui->add('window_id', 'Window'); | ||
| 108 | |||
| 109 | # The hard way. | ||
| 110 | # ------------- | ||
| 111 | my $dialog = $win->add( | ||
| 112 | 'mydialog', 'Dialog::Error', | ||
| 113 | -message => 'The world has gone!' | ||
| 114 | ); | ||
| 115 | $dialog->focus; | ||
| 116 | $win->delete('mydialog'); | ||
| 117 | |||
| 118 | # The easy way (see Curses::UI documentation). | ||
| 119 | # -------------------------------------------- | ||
| 120 | $cui->error(-message => 'The world has gone!'); | ||
| 121 | |||
| 122 | # or even: | ||
| 123 | $cui->error('The world has gone!'); | ||
| 124 | |||
| 125 | |||
| 126 | |||
| 127 | =head1 DESCRIPTION | ||
| 128 | |||
| 129 | Curses::UI::Dialog::Error is a basic error dialog. It is | ||
| 130 | almost the same as L<Curses::UI::Dialog::Basic|Curses::UI::Dialog::Basic>, | ||
| 131 | except for the fact that a warning sign is drawn to the left of | ||
| 132 | the message using ASCII "art": | ||
| 133 | |||
| 134 | _ | ||
| 135 | / \ | ||
| 136 | / ! \ | ||
| 137 | /_____\ | ||
| 138 | |||
| 139 | |||
| 140 | Since this class is very closely related to the basic dialog, | ||
| 141 | see L<Curses::UI::Dialog::Basic|Curses::UI::Dialog::Basic> for | ||
| 142 | a description of the options and methods that you can use. | ||
| 143 | |||
| 144 | |||
| 145 | |||
| 146 | =head1 SEE ALSO | ||
| 147 | |||
| 148 | L<Curses::UI|Curses::UI>, | ||
| 149 | L<Curses::UI::Dialog::Basic|Curses::UI::Dialog::Basic> | ||
| 150 | |||
| 151 | |||
| 152 | |||
| 153 | =head1 AUTHOR | ||
| 154 | |||
| 155 | Copyright (c) 2001-2002 Maurice Makaay. All rights reserved. | ||
| 156 | |||
| 157 | Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de) | ||
| 158 | |||
| 159 | |||
| 160 | This package is free software and is provided "as is" without express | ||
| 161 | or implied warranty. It may be used, redistributed and/or modified | ||
| 162 | under the same terms as perl itself. | ||
| 163 |