=head1 NAME

CFX5::Win32::Output - Functions for controllable output under Windows NT

=head1 SYNOPSIS

This module provides functions for doing various sorts of output under
Windows NT, using native dialog boxes etc. This includes handling
consoles (see the -noconsole switch), and displaying messages.\

It should never be included under UNIX. Most users will not want it
under NT either, as it is used by all the functions in
L<CFX5::Output> anyway.

=cut

package CFX5::Win32::Output;

use strict;

use vars qw($CVSVersion);
$CVSVersion='$Id$ ';

use Exporter;
use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS);

@ISA=qw(Exporter);
@EXPORT_OK=qw();

use Win32::GUI();

=head1 DESCRIPTION

=head2 INITIALISATION

=head2 MESSAGE BOXES

=head3 show_message

  show_message("A Message", "A Title", "error");

Calls the Win32 MessageBox function to display a message with a single
OK button, and waits for the user to press on OK. Valid strings for
the third argument are:

=over

=item error

=item warning

=item information

=item none

=back

Unrecognised arguments will be treated as "none".

=cut

sub show_message {
  my ($msg, $title, $icon) = @_;

  $icon=0 unless defined $icon;
  my $flags=0;
  if ($icon eq "error") { $flags |= 16; }
  elsif ($icon eq "warning") { $flags |= 32; }
  elsif ($icon eq "information") { $flags |= 64; }

  # MB_SETFOREGROUND -- bring the dialog box to the foreground (?)
  $flags += 0x10000;

  Win32::GUI::MessageBox(0, $msg, $title, $flags);
}

=head2 CONSOLE FUNCTIONS

=head3 show_console

  CFX5::Win32::Output::show_console();

  Show the perl console
=cut 

sub show_console {
  my $con = Win32::GUI::GetPerlWindow();
  Win32::GUI::Show($con); 
}

=head3 hide_console

  CFX5::Win32::Output::hide_console();

  Hides the perl console

=cut

sub hide_console {
  my $con = Win32::GUI::GetPerlWindow();
  Win32::GUI::Hide($con);
}

=head2 SCREEN SIZE

  ($x,$y) = CFX5::Win32::Output::screen_size();

Returns the size, in pixels, of the current display

=cut

sub screen_size {
  my $x=Win32::GUI::GetSystemMetrics(0);
  my $y=Win32::GUI::GetSystemMetrics(1);
  return ($x,$y);
}

1;
