gui_message.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : gui_message                                                       *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Allows batch files to pop up message boxes, where supported by the       *
00009 *  operating system.                                                          *
00010 *                                                                             *
00011 *******************************************************************************
00012 * Copyright (c) 2004-$now By Author.  This program is free software; you can  *
00013 * redistribute it and/or modify it under the terms of the GNU General Public  *
00014 * License as published by the Free Software Foundation; either version 2 of   *
00015 * the License or (at your option) any later version.  This is online at:      *
00016 *     http://www.fsf.org/copyleft/gpl.html                                    *
00017 * Please send any updates to: fred@gruntose.com                               *
00018 \*****************************************************************************/
00019 
00020 #include <basis/convert_utf.h>
00021 #include <basis/guards.h>
00022 #include <opsystem/application_shell.h>
00023 #include <loggers/console_logger.h>
00024 #include <data_struct/static_memory_gremlin.h>
00025 
00026 #include <stdlib.h>
00027 
00028 class gui_message : public application_shell
00029 {
00030 public:
00031   gui_message() : application_shell(class_name()) {}
00032   IMPLEMENT_CLASS_NAME("gui_message");
00033   virtual int execute();
00034   void print_instructions_and_exit();
00035 };
00036 
00037 void gui_message::print_instructions_and_exit()
00038 {
00039   log(istring(istring::SPRINTF, "\n\
00040 Usage:\t%s {text} {title}\n\n\
00041 This is a utility that provides scripts with the ability to pop up a\n\
00042 message box for the user.  The user must hit the okay button to proceed.\n\
00043 The text is the main message to show while the title will be used for the\n\
00044 descriptive caption on the box window.  Note that this is only supported\n\
00045 by some operating systems; others may be in truly console mode and have\n\
00046 no access to a graphical message box.\n",
00047       class_name(), class_name()));
00048   exit(0);
00049 }
00050 
00051 int gui_message::execute()
00052 {
00053   if (__argc < 3) print_instructions_and_exit();
00054 #ifdef __WIN32__
00055   // special gui code for windows.
00056   int r = MessageBox(0, to_unicode_temp(__argv[1]), to_unicode_temp(__argv[2]),
00057       MB_OK | MB_TOPMOST);
00058   if (!r) {
00059     istring text = portable::system_error_text(portable::system_error());
00060     log(istring("the error creating messagebox is: ") + text);
00061   }
00062 #else
00063   guards::alert_message(__argv[1], __argv[2]);
00064 #endif
00065   return 0;
00066 }
00067 
00068 HOOPLE_MAIN(gui_message, )
00069 
00070 #ifdef __BUILD_STATIC_APPLICATION__
00071   // static dependencies found by buildor_gen_deps.sh:
00072   #include <basis/array.cpp>
00073   #include <basis/byte_array.cpp>
00074   #include <basis/callstack_tracker.cpp>
00075   #include <basis/chaos.cpp>
00076   #include <basis/convert_utf.cpp>
00077   #include <basis/definitions.cpp>
00078   #include <basis/earth_time.cpp>
00079   #include <basis/guards.cpp>
00080   #include <basis/istring.cpp>
00081   #include <basis/log_base.cpp>
00082   #include <basis/memory_checker.cpp>
00083   #include <basis/mutex.cpp>
00084   #include <basis/object_base.cpp>
00085   #include <basis/outcome.cpp>
00086   #include <basis/packable.cpp>
00087   #include <basis/portable.cpp>
00088   #include <basis/sequence.cpp>
00089   #include <basis/set.cpp>
00090   #include <basis/utility.cpp>
00091   #include <basis/version_record.cpp>
00092   #include <data_struct/amorph.cpp>
00093   #include <data_struct/bit_vector.cpp>
00094   #include <data_struct/byte_hasher.cpp>
00095   #include <data_struct/configurator.cpp>
00096   #include <data_struct/hash_table.cpp>
00097   #include <data_struct/pointer_hash.cpp>
00098   #include <data_struct/stack.cpp>
00099   #include <data_struct/static_memory_gremlin.cpp>
00100   #include <data_struct/string_hash.cpp>
00101   #include <data_struct/string_hasher.cpp>
00102   #include <data_struct/string_table.cpp>
00103   #include <data_struct/symbol_table.cpp>
00104   #include <data_struct/table_configurator.cpp>
00105   #include <loggers/console_logger.cpp>
00106   #include <loggers/file_logger.cpp>
00107   #include <loggers/locked_logger.cpp>
00108   #include <loggers/null_logger.cpp>
00109   #include <loggers/program_wide_logger.cpp>
00110   #include <opsystem/application_base.cpp>
00111   #include <opsystem/application_shell.cpp>
00112   #include <opsystem/byte_filer.cpp>
00113   #include <opsystem/command_line.cpp>
00114   #include <opsystem/critical_events.cpp>
00115   #include <opsystem/directory.cpp>
00116   #include <opsystem/filename.cpp>
00117   #include <opsystem/ini_config.cpp>
00118   #include <opsystem/ini_parser.cpp>
00119   #include <opsystem/path_configuration.cpp>
00120   #include <opsystem/rendezvous.cpp>
00121   #include <textual/byte_format.cpp>
00122   #include <textual/parser_bits.cpp>
00123   #include <textual/string_manipulation.cpp>
00124   #include <textual/tokenizer.cpp>
00125 #endif // __BUILD_STATIC_APPLICATION__
00126 

Generated on Thu Nov 20 04:28:45 2008 for HOOPLE Libraries by  doxygen 1.5.1