00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1999, 2001, 2002, 2005, 2006, 2008 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see 00017 // <http://www.gnu.org/licenses/>. 00018 // 00019 00020 #ifndef LIBAEGIS_WIDE_OUTPUT_HEADER_H 00021 #define LIBAEGIS_WIDE_OUTPUT_HEADER_H 00022 00023 #include <common/wstring.h> 00024 #include <libaegis/wide_output.h> 00025 00029 class wide_output_header: 00030 public wide_output 00031 { 00032 public: 00033 typedef aegis_shared_ptr<wide_output_header> hpointer; 00034 00038 ~wide_output_header(); 00039 00040 private: 00047 wide_output_header(const wide_output::pointer &deeper); 00048 00049 public: 00054 static hpointer open(const wide_output::pointer &deeper); 00055 00056 void title(const char *, const char *); 00057 00058 static void 00059 title(wide_output::pointer fp, const char *l1, const char *l2) 00060 { 00061 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 00062 if (hp) 00063 hp->title(l1, l2); 00064 } 00065 00066 void need(int); 00067 00068 void need1(int); 00069 00070 static void 00071 need1(wide_output::pointer fp, int x) 00072 { 00073 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 00074 if (hp) 00075 hp->need1(x); 00076 } 00077 00078 void eject(); 00079 00080 static void 00081 eject(wide_output::pointer fp) 00082 { 00083 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 00084 if (hp) 00085 hp->eject(); 00086 } 00087 00088 bool is_at_top_of_page(); 00089 00090 static bool 00091 is_at_top_of_page(wide_output::pointer fp) 00092 { 00093 wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get()); 00094 return (hp && hp->is_at_top_of_page()); 00095 } 00096 00097 protected: 00098 // See base class for documentation. 00099 nstring filename(); 00100 00101 // See base class for documentation. 00102 int page_width(); 00103 00104 // See base class for documentation. 00105 int page_length(); 00106 00107 // See base class for documentation. 00108 const char *type_name() const; 00109 00110 // See base class for documentation. 00111 void write_inner(const wchar_t *data, size_t len); 00112 00113 // See base class for documentation. 00114 void flush_inner(); 00115 00116 // See base class for documentation. 00117 void end_of_line_inner(); 00118 00119 private: 00120 pointer deeper; 00121 wstring title1; 00122 wstring title2; 00123 int line_number; 00124 int length; 00125 int width; 00126 bool is_a_printer; 00127 int column; 00128 int page_number; 00129 time_t page_time; 00130 bool already_top_diverted; 00131 00132 void left_and_right(const wstring &lhs, const char *rhs); 00133 void top_of_page_processing(); 00134 void bottom_of_page_processing(); 00135 00139 wide_output_header(); 00140 00144 wide_output_header(const wide_output_header &); 00145 00149 wide_output_header &operator=(const wide_output_header &); 00150 }; 00151 00152 #endif // LIBAEGIS_WIDE_OUTPUT_HEADER_H