Google
Web alhem.net

Table_i.h

Go to the documentation of this file.
00001 // Table_i.h
00002 /*
00003 Copyright (C) 2003  Anders Hedstrom
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (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, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 #ifndef _TABLE_I_H
00021 #define _TABLE_I_H
00022 
00023 #ifdef _WIN32
00024 #define STL_USING_STRING
00025 #include <stlhelper.h>
00026 #else
00027 #include <string>
00028 #endif
00029 
00030 namespace Cgi {
00031 
00033 
00034 class Table
00035 {
00036 public:
00037         Table(const std::string &color, int padding = 5, const char *caption = NULL,
00038                 const char *textcolor = NULL, FILE *fil = stdout) : m_fil(fil)
00039         {
00040                 fprintf(m_fil,"<table cellpadding=0 cellspacing=0><tr><td bgcolor=\"%s\">",color.c_str());
00041                 if (caption)
00042                 {
00043                         fprintf(m_fil,"<font color=\"%s\">%s</font></td></tr>",
00044                                 textcolor ? textcolor : "#ffffff", caption);
00045                         fprintf(m_fil,"<tr><td bgcolor=\"%s\">",color.c_str());
00046                 }
00047                 fprintf(m_fil,"<table width=\"100%%\" cellspacing=1 cellpadding=%d>",padding);
00048                 fflush(m_fil);
00049         }
00050         ~Table() {
00051                 fflush(m_fil);
00052                 fprintf(m_fil,"</table>");
00053                 fprintf(m_fil,"</td></tr></table>");
00054                 fflush(m_fil);
00055         }
00056 
00057 private:
00058         FILE *m_fil;
00059 };
00060 
00061 
00062 class Table100
00063 {
00064 public:
00065         Table100(const std::string &color, int padding = 5, const char *caption = NULL,
00066                 const char *textcolor = NULL, FILE *fil = stdout) : m_fil(fil)
00067         {
00068                 fprintf(m_fil,"<table width=\"100%%\" cellpadding=0 cellspacing=0><tr><td bgcolor=\"%s\">",color.c_str());
00069                 if (caption)
00070                 {
00071                         fprintf(m_fil,"<font color=\"%s\">%s</font></td></tr>",
00072                                 textcolor ? textcolor : "#ffffff", caption);
00073                         fprintf(m_fil,"<tr><td bgcolor=\"%s\">",color.c_str());
00074                 }
00075                 fprintf(m_fil,"<table width=\"100%%\" cellspacing=1 cellpadding=%d>",padding);
00076                 fflush(m_fil);
00077         }
00078         ~Table100() {
00079                 fflush(m_fil);
00080                 fprintf(m_fil,"</table>");
00081                 fprintf(m_fil,"</td></tr></table>");
00082                 fflush(m_fil);
00083         }
00084 
00085 private:
00086         FILE *m_fil;
00087 };
00088 
00089 } // namespace
00090 
00091 #endif // _TABLE_I_H

Generated for cgi++ by doxygen 1.3.7

Page, code, and content Copyright (C) 2004 by Anders Hedström