Aegis  4.25.D505
/home/archives/aegis/branch.4/branch.25/delta28933.505/libaegis/wide_output/header.h
Go to the documentation of this file.
00001 //
00002 // aegis - project change supervisor
00003 // Copyright (C) 1999, 2001, 2002, 2005, 2006, 2008, 2012 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 (at
00008 // 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 GNU
00013 // 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 <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIBAEGIS_WIDE_OUTPUT_HEADER_H
00020 #define LIBAEGIS_WIDE_OUTPUT_HEADER_H
00021 
00022 #include <common/ac/time.h>
00023 
00024 #include <common/wstring.h>
00025 #include <libaegis/wide_output.h>
00026 
00030 class wide_output_header:
00031     public wide_output
00032 {
00033 public:
00034     typedef aegis_shared_ptr<wide_output_header> hpointer;
00035 
00039     ~wide_output_header();
00040 
00041 private:
00048     wide_output_header(const wide_output::pointer &deeper);
00049 
00050 public:
00055     static hpointer open(const wide_output::pointer &deeper);
00056 
00057     void title(const nstring &first, const nstring &second);
00058 
00059     static void
00060     title(wide_output::pointer fp, const nstring &l1, const nstring &l2)
00061     {
00062         wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get());
00063         if (hp)
00064             hp->title(l1, l2);
00065     }
00066 
00067     void need(int);
00068 
00069     void need1(int);
00070 
00071     static void
00072     need1(wide_output::pointer fp, int x)
00073     {
00074         wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get());
00075         if (hp)
00076             hp->need1(x);
00077     }
00078 
00079     void eject();
00080 
00081     static void
00082     eject(wide_output::pointer fp)
00083     {
00084         wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get());
00085         if (hp)
00086             hp->eject();
00087     }
00088 
00089     bool is_at_top_of_page();
00090 
00091     static bool
00092     is_at_top_of_page(wide_output::pointer fp)
00093     {
00094         wide_output_header *hp = dynamic_cast<wide_output_header *>(fp.get());
00095         return (hp && hp->is_at_top_of_page());
00096     }
00097 
00098 protected:
00099     // See base class for documentation.
00100     nstring filename();
00101 
00102     // See base class for documentation.
00103     int page_width();
00104 
00105     // See base class for documentation.
00106     int page_length();
00107 
00108     // See base class for documentation.
00109     const char *type_name() const;
00110 
00111     // See base class for documentation.
00112     void write_inner(const wchar_t *data, size_t len);
00113 
00114     // See base class for documentation.
00115     void flush_inner();
00116 
00117     // See base class for documentation.
00118     void end_of_line_inner();
00119 
00120 private:
00121     pointer deeper;
00122     wstring title1;
00123     wstring title2;
00124     int line_number;
00125     int length;
00126     int width;
00127     bool is_a_printer;
00128     int column;
00129     int page_number;
00130     time_t page_time;
00131     bool already_top_diverted;
00132 
00133     void left_and_right(const wstring &lhs, const char *rhs);
00134     void top_of_page_processing();
00135     void bottom_of_page_processing();
00136 
00140     wide_output_header();
00141 
00145     wide_output_header(const wide_output_header &);
00146 
00150     wide_output_header &operator=(const wide_output_header &);
00151 };
00152 
00153 #endif // LIBAEGIS_WIDE_OUTPUT_HEADER_H
00154 // vim: set ts=8 sw=4 et :